All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Typedefs | Functions | Variables
listen.c File Reference
#include <freeradius-devel/radiusd.h>
#include <freeradius-devel/modules.h>
#include <freeradius-devel/rad_assert.h>
#include <freeradius-devel/process.h>
#include <freeradius-devel/protocol.h>
#include <freeradius-devel/modpriv.h>
#include <freeradius-devel/net.h>
#include <freeradius-devel/detail.h>
#include <freeradius-devel/udp.h>
#include "command.c"
+ Include dependency graph for listen.c:

Go to the source code of this file.

Data Structures

struct  listen_config_t
 

Macros

#define ADDSTRING(_x)   strlcpy(buffer, _x, bufsize);FORWARD
 
#define FORWARD   len = strlen(buffer); if (len >= (bufsize + 1)) return 0;buffer += len;bufsize -= len
 
#define NO_LISTENER   { .name = "undefined", }
 
#define WAS_PROXIED   (request->proxy)
 

Typedefs

typedef struct listen_config_t listen_config_t
 

Functions

static int _listen_config_free (listen_config_t *lc)
 
static int _listener_free (rad_listen_t *this)
 
static int acct_socket_recv (rad_listen_t *listener)
 
static int acct_socket_send (rad_listen_t *listener, REQUEST *request)
 
static int auth_socket_recv (rad_listen_t *listener)
 
static int auth_socket_send (rad_listen_t *listener, REQUEST *request)
 
RADCLIENTclient_listener_find (rad_listen_t *listener, fr_ipaddr_t const *ipaddr, uint16_t src_port)
 
static int client_socket_decode (UNUSED rad_listen_t *listener, REQUEST *request)
 
static int client_socket_encode (UNUSED rad_listen_t *listener, REQUEST *request)
 
static int coa_socket_recv (rad_listen_t *listener)
 
static int command_tcp_recv (rad_listen_t *listener)
 
static int command_tcp_send (rad_listen_t *listener, REQUEST *request)
 
static int command_write_magic (int newfd, listen_socket_t *sock)
 
void common_packet_debug (REQUEST *request, RADIUS_PACKET *packet, bool received)
 
static void common_socket_free (rad_listen_t *this)
 
int common_socket_open (CONF_SECTION *cs, rad_listen_t *this)
 
int common_socket_parse (CONF_SECTION *cs, rad_listen_t *this)
 
int common_socket_print (rad_listen_t const *this, char *buffer, size_t bufsize)
 
static int do_proxy (REQUEST *request)
 
static int dual_tcp_accept (rad_listen_t *listener)
 
static int dual_tcp_recv (rad_listen_t *listener)
 
static rad_listen_tlisten_alloc (TALLOC_CTX *ctx, RAD_LISTEN_TYPE type, fr_protocol_t *proto)
 
static int listen_bind (rad_listen_t *this)
 
int listen_bootstrap (CONF_SECTION *server, CONF_SECTION *cs, char const *server_name)
 
void listen_free (rad_listen_t **head)
 Free a linked list of listeners. More...
 
int listen_init (rad_listen_t **head, bool spawn_workers)
 Search for listeners in the server. More...
 
static rad_listen_tlisten_parse (listen_config_t *lc)
 
static int listener_cmp (void const *one, void const *two)
 
rad_listen_tlistener_find_byipaddr (fr_ipaddr_t const *ipaddr, uint16_t port, int proto)
 Find a listener associated with an IP address/port/transport proto. More...
 
RADCLIENT_LISTlistener_find_client_list (fr_ipaddr_t const *ipaddr, uint16_t port, int proto)
 Find client list associated with a listener. More...
 
static int listener_unlink (UNUSED void *ctx, UNUSED void *data)
 
rad_listen_tproxy_new_listener (TALLOC_CTX *ctx, home_server_t *home, uint16_t src_port)
 
static int proxy_socket_decode (UNUSED rad_listen_t *listener, REQUEST *request)
 
static int proxy_socket_encode (UNUSED rad_listen_t *listener, REQUEST *request)
 
static int proxy_socket_recv (rad_listen_t *listener)
 
static int proxy_socket_send (rad_listen_t *listener, REQUEST *request)
 
static int proxy_socket_tcp_recv (rad_listen_t *listener)
 
int rad_coa_recv (REQUEST *request)
 
int rad_status_server (REQUEST *request)
 
static int stats_socket_recv (rad_listen_t *listener)
 

Variables

static CONF_PARSER limit_config []
 
static listen_config_tlisten_config = NULL
 
static TALLOC_CTX * listen_ctx = NULL
 
static fr_protocol_t master_listen []
 
static CONF_PARSER performance_config []
 

Data Structure Documentation

struct listen_config_t

Definition at line 73 of file listen.c.

+ Collaboration diagram for listen_config_t:
Data Fields
CONF_SECTION * cs configuration for this listener
lt_dlhandle * handle to dynamically loaded library (if any)
rad_listen_t * listener created from this configuration
struct listen_config_t * next the next listener
fr_protocol_t * proto same as Listen-Socket-Type

pointer to the protocol handler.

CONF_SECTION * server encapsulating server configuratiuon
char const * server_name name of the virtual server (if any)
RAD_LISTEN_TYPE type

Macro Definition Documentation

#define ADDSTRING (   _x)    strlcpy(buffer, _x, bufsize);FORWARD
#define FORWARD   len = strlen(buffer); if (len >= (bufsize + 1)) return 0;buffer += len;bufsize -= len
#define NO_LISTENER   { .name = "undefined", }

Definition at line 2508 of file listen.c.

#define WAS_PROXIED   (request->proxy)

Typedef Documentation

Function Documentation

static int _listen_config_free ( listen_config_t lc)
static

Definition at line 99 of file listen.c.

+ Here is the caller graph for this function:

static int _listener_free ( rad_listen_t this)
static

Definition at line 2831 of file listen.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int acct_socket_recv ( rad_listen_t listener)
static

Definition at line 1915 of file listen.c.

+ Here is the call graph for this function:

static int acct_socket_send ( rad_listen_t listener,
REQUEST request 
)
static

Definition at line 1668 of file listen.c.

+ Here is the call graph for this function:

static int auth_socket_recv ( rad_listen_t listener)
static

Definition at line 1801 of file listen.c.

+ Here is the call graph for this function:

static int auth_socket_send ( rad_listen_t listener,
REQUEST request 
)
static

Definition at line 1634 of file listen.c.

+ Here is the call graph for this function:

RADCLIENT* client_listener_find ( rad_listen_t listener,
fr_ipaddr_t const *  ipaddr,
uint16_t  src_port 
)

Definition at line 344 of file listen.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int client_socket_decode ( UNUSED rad_listen_t listener,
REQUEST request 
)
static

Definition at line 2441 of file listen.c.

+ Here is the call graph for this function:

static int client_socket_encode ( UNUSED rad_listen_t listener,
REQUEST request 
)
static

Definition at line 2421 of file listen.c.

+ Here is the call graph for this function:

static int coa_socket_recv ( rad_listen_t listener)
static

Definition at line 2201 of file listen.c.

+ Here is the call graph for this function:

static int command_tcp_recv ( rad_listen_t listener)
static

+ Here is the caller graph for this function:

static int command_tcp_send ( rad_listen_t listener,
REQUEST request 
)
static

+ Here is the caller graph for this function:

static int command_write_magic ( int  newfd,
listen_socket_t sock 
)
static

+ Here is the caller graph for this function:

void common_packet_debug ( REQUEST request,
RADIUS_PACKET packet,
bool  received 
)

Definition at line 1153 of file listen.c.

+ Here is the call graph for this function:

static void common_socket_free ( rad_listen_t this)
static

Definition at line 995 of file listen.c.

int common_socket_open ( CONF_SECTION cs,
rad_listen_t this 
)

Definition at line 1599 of file listen.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int common_socket_parse ( CONF_SECTION cs,
rad_listen_t this 
)

Definition at line 1274 of file listen.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int common_socket_print ( rad_listen_t const *  this,
char *  buffer,
size_t  bufsize 
)

Definition at line 1021 of file listen.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int do_proxy ( REQUEST request)
static

Definition at line 2010 of file listen.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int dual_tcp_accept ( rad_listen_t listener)
static

Definition at line 816 of file listen.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int dual_tcp_recv ( rad_listen_t listener)
static

Definition at line 698 of file listen.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static rad_listen_t * listen_alloc ( TALLOC_CTX *  ctx,
RAD_LISTEN_TYPE  type,
fr_protocol_t proto 
)
static

Definition at line 2898 of file listen.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int listen_bind ( rad_listen_t this)
static

Definition at line 2649 of file listen.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int listen_bootstrap ( CONF_SECTION server,
CONF_SECTION cs,
char const *  server_name 
)

Definition at line 109 of file listen.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void listen_free ( rad_listen_t **  head)

Free a linked list of listeners.

Parameters
headof list to free.

Definition at line 3233 of file listen.c.

+ Here is the caller graph for this function:

int listen_init ( rad_listen_t **  head,
bool  spawn_workers 
)

Search for listeners in the server.

Parameters
[out]headWhere to write listener. Must point to a NULL pointer.
[in]spawn_workersWhether we're spawning child threads.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 3123 of file listen.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static rad_listen_t * listen_parse ( listen_config_t lc)
static

Definition at line 3052 of file listen.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int listener_cmp ( void const *  one,
void const *  two 
)
static

Definition at line 1257 of file listen.c.

+ Here is the caller graph for this function:

rad_listen_t* listener_find_byipaddr ( fr_ipaddr_t const *  ipaddr,
uint16_t  port,
int  proto 
)

Find a listener associated with an IP address/port/transport proto.

Parameters
[in]ipaddrlistener is bound to.
[in]portlistener is bound to.
[in]protoof listener, one of the IPPROTO_* macros.
Returns
  • Listener matching ipaddr/port/proto.
  • NULL if no listeners match.

Definition at line 3302 of file listen.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

RADCLIENT_LIST* listener_find_client_list ( fr_ipaddr_t const *  ipaddr,
uint16_t  port,
int  proto 
)

Find client list associated with a listener.

Parameters
[in]ipaddrlistener is bound to.
[in]portlistener is bound to.
[in]protoof listener, one of the IPPROTO_* macros.
Returns
  • List of clients.
  • NULL if no matching listeners found.

Definition at line 3264 of file listen.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int listener_unlink ( UNUSED void *  ctx,
UNUSED void *  data 
)
static

Definition at line 1264 of file listen.c.

+ Here is the caller graph for this function:

rad_listen_t* proxy_new_listener ( TALLOC_CTX *  ctx,
home_server_t home,
uint16_t  src_port 
)

Definition at line 2927 of file listen.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int proxy_socket_decode ( UNUSED rad_listen_t listener,
REQUEST request 
)
static

Definition at line 2495 of file listen.c.

+ Here is the call graph for this function:

static int proxy_socket_encode ( UNUSED rad_listen_t listener,
REQUEST request 
)
static

Definition at line 2477 of file listen.c.

+ Here is the call graph for this function:

static int proxy_socket_recv ( rad_listen_t listener)
static

Definition at line 2286 of file listen.c.

+ Here is the call graph for this function:

static int proxy_socket_send ( rad_listen_t listener,
REQUEST request 
)
static

Definition at line 1710 of file listen.c.

+ Here is the call graph for this function:

static int proxy_socket_tcp_recv ( rad_listen_t listener)
static

Definition at line 2354 of file listen.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int rad_coa_recv ( REQUEST request)

Definition at line 2045 of file listen.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int rad_status_server ( REQUEST request)

Definition at line 596 of file listen.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int stats_socket_recv ( rad_listen_t listener)
static

Definition at line 1733 of file listen.c.

+ Here is the call graph for this function:

Variable Documentation

CONF_PARSER limit_config[]
static
Initial value:
= {
{ FR_CONF_OFFSET("max_pps", PW_TYPE_INTEGER, listen_socket_t, max_rate) },
{ FR_CONF_OFFSET("max_connections", PW_TYPE_INTEGER, listen_socket_t, limit.max_connections), .dflt = "16" },
{ FR_CONF_OFFSET("lifetime", PW_TYPE_INTEGER, listen_socket_t, limit.lifetime), .dflt = "0" },
{ FR_CONF_OFFSET("idle_timeout", PW_TYPE_INTEGER, listen_socket_t, limit.idle_timeout), .dflt = STRINGIFY(30) },
}
#define CONF_PARSER_TERMINATOR
Definition: conffile.h:289
#define STRINGIFY(x)
Definition: build.h:34
32 Bit unsigned integer.
Definition: radius.h:34
#define FR_CONF_OFFSET(_n, _t, _s, _f)
Definition: conffile.h:168

Definition at line 1234 of file listen.c.

listen_config_t* listen_config = NULL
static

Definition at line 86 of file listen.c.

TALLOC_CTX* listen_ctx = NULL
static

Definition at line 85 of file listen.c.

static fr_protocol_t master_listen
static

Definition at line 97 of file listen.c.

CONF_PARSER performance_config[]
static
Initial value:
= {
{ FR_CONF_OFFSET("skip_duplicate_checks", PW_TYPE_BOOLEAN, rad_listen_t, nodup) },
{ FR_CONF_OFFSET("synchronous", PW_TYPE_BOOLEAN, rad_listen_t, synchronous) },
{ FR_CONF_OFFSET("workers", PW_TYPE_INTEGER, rad_listen_t, workers) },
}
#define CONF_PARSER_TERMINATOR
Definition: conffile.h:289
A truth value.
Definition: radius.h:56
32 Bit unsigned integer.
Definition: radius.h:34
#define FR_CONF_OFFSET(_n, _t, _s, _f)
Definition: conffile.h:168

Definition at line 1224 of file listen.c.