All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions | Variables
client.c File Reference

Manage clients allowed to communicate with the server. More...

#include <freeradius-devel/radiusd.h>
#include <freeradius-devel/rad_assert.h>
#include <sys/stat.h>
#include <ctype.h>
#include <fcntl.h>
+ Include dependency graph for client.c:

Go to the source code of this file.

Data Structures

struct  radclient_list
 

Macros

#define namecmp(a)   ((!old->a && !client->a) || (old->a && client->a && (strcmp(old->a, client->a) == 0)))
 

Functions

bool client_add (RADCLIENT_LIST *clients, RADCLIENT *client)
 Add a client to a RADCLIENT_LIST. More...
 
bool client_add_dynamic (RADCLIENT_LIST *clients, RADCLIENT *master, RADCLIENT *c)
 Add a dynamic client. More...
 
RADCLIENTclient_afrom_cs (TALLOC_CTX *ctx, CONF_SECTION *cs, bool in_server, bool with_coa)
 Allocate a new client from a config section. More...
 
RADCLIENTclient_afrom_query (TALLOC_CTX *ctx, char const *identifier, char const *secret, char const *shortname, char const *type, char const *server, bool require_ma)
 Add a client from a result set (SQL) More...
 
RADCLIENTclient_afrom_request (RADCLIENT_LIST *clients, REQUEST *request)
 Create a new client, consuming all attributes in the control list of the request. More...
 
void client_delete (RADCLIENT_LIST *clients, RADCLIENT *client)
 
RADCLIENTclient_find (RADCLIENT_LIST const *clients, fr_ipaddr_t const *ipaddr, int proto)
 
RADCLIENTclient_find_old (fr_ipaddr_t const *ipaddr)
 
RADCLIENTclient_findbynumber (RADCLIENT_LIST const *clients, int number)
 
void client_free (RADCLIENT *client)
 
static int client_ipaddr_cmp (void const *one, void const *two)
 
void client_list_free (RADCLIENT_LIST *clients)
 
RADCLIENT_LISTclient_list_init (CONF_SECTION *cs)
 
RADCLIENT_LISTclient_list_parse_section (CONF_SECTION *section, UNUSED bool tls_required)
 Create the linked list of clients from the new configuration type. More...
 
int client_map_section (CONF_SECTION *out, CONF_SECTION const *map, client_value_cb_t func, void *data)
 Create a client CONF_SECTION using a mapping section to map values from a result set to client attributes. More...
 
static int client_num_cmp (void const *one, void const *two)
 
RADCLIENTclient_read (char const *filename, int in_server, int flag)
 

Variables

static fr_ipaddr_t cl_ipaddr
 
static char const * cl_srcipaddr = NULL
 
static const CONF_PARSER client_config []
 
static fr_fifo_tdeleted_clients = NULL
 
static const CONF_PARSER dynamic_config []
 
static char const * hs_proto = NULL
 
static CONF_PARSER limit_config []
 
static RADCLIENT_LISTroot_clients = NULL
 
static rbtree_ttree_num = NULL
 
static int tree_num_max = 0
 

Detailed Description

Manage clients allowed to communicate with the server.

Id:
566b4cc08ae8bd0513a90dc1267f52bad581a9d9

Definition in file client.c.


Data Structure Documentation

struct radclient_list

Definition at line 43 of file client.c.

+ Collaboration diagram for radclient_list:
Data Fields
uint32_t min_prefix
rbtree_t * trees[129]

Macro Definition Documentation

#define namecmp (   a)    ((!old->a && !client->a) || (old->a && client->a && (strcmp(old->a, client->a) == 0)))

Function Documentation

bool client_add ( RADCLIENT_LIST clients,
RADCLIENT client 
)

Add a client to a RADCLIENT_LIST.

Parameters
clientslist to add client to, may be NULL if global client list is being used.
clientto add.
Returns
  • true on success.
  • false on failure.

Definition at line 192 of file client.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool client_add_dynamic ( RADCLIENT_LIST clients,
RADCLIENT master,
RADCLIENT c 
)

Add a dynamic client.

Definition at line 708 of file client.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

RADCLIENT* client_afrom_cs ( TALLOC_CTX *  ctx,
CONF_SECTION cs,
bool  in_server,
bool  with_coa 
)

Allocate a new client from a config section.

Parameters
ctxto allocate new clients in.
csto process as a client.
in_serverWhether the client should belong to a specific virtual server.
with_coaIf true and coa_server or coa_pool aren't specified automatically, create a coa home_server section and add it to the client CONF_SECTION.
Returns
new RADCLIENT struct.

Definition at line 858 of file client.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

RADCLIENT* client_afrom_query ( TALLOC_CTX *  ctx,
char const *  identifier,
char const *  secret,
char const *  shortname,
char const *  type,
char const *  server,
bool  require_ma 
)

Add a client from a result set (SQL)

Todo:
This function should die. SQL should use client_afrom_cs.
Parameters
ctxTalloc context.
identifierClient IP Address / IPv4 subnet / IPv6 subnet / FQDN.
secretClient secret.
shortnameClient friendly name.
typeNAS-Type.
serverVirtual-Server to associate clients with.
require_maIf true all packets from client must include a message-authenticator.
Returns
  • New client.
  • NULL on error.

Definition at line 1131 of file client.c.

+ Here is the call graph for this function:

RADCLIENT* client_afrom_request ( RADCLIENT_LIST clients,
REQUEST request 
)

Create a new client, consuming all attributes in the control list of the request.

Parameters
clientslist to add new client to.
requestFake request.
Returns
  • New client on success.
  • NULL on error.

Definition at line 1175 of file client.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void client_delete ( RADCLIENT_LIST clients,
RADCLIENT client 
)

Definition at line 378 of file client.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

RADCLIENT* client_find ( RADCLIENT_LIST const *  clients,
fr_ipaddr_t const *  ipaddr,
int  proto 
)

Definition at line 431 of file client.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

RADCLIENT* client_find_old ( fr_ipaddr_t const *  ipaddr)

Definition at line 472 of file client.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

RADCLIENT* client_findbynumber ( RADCLIENT_LIST const *  clients,
int  number 
)

Definition at line 402 of file client.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void client_free ( RADCLIENT client)

Definition at line 62 of file client.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 104 of file client.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void client_list_free ( RADCLIENT_LIST clients)

Definition at line 140 of file client.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

RADCLIENT_LIST* client_list_init ( CONF_SECTION cs)

Definition at line 173 of file client.c.

+ Here is the caller graph for this function:

RADCLIENT_LIST* client_list_parse_section ( CONF_SECTION section,
UNUSED bool  tls_required 
)

Create the linked list of clients from the new configuration type.

Definition at line 532 of file client.c.

+ Here is the call graph for this function:

int client_map_section ( CONF_SECTION out,
CONF_SECTION const *  map,
client_value_cb_t  func,
void *  data 
)

Create a client CONF_SECTION using a mapping section to map values from a result set to client attributes.

If we hit a CONF_SECTION we recurse and process its CONF_PAIRS too.

Note
Caller should free CONF_SECTION passed in as out, on error. Contents of that section will be in an undefined state.
Parameters
[in,out]outSection to perform mapping on. Either the root of the client config, or a parent section (when this function is called recursively). Should be alloced with cf_section_alloc, or if there's a separate template section, the result of calling cf_section_dup on that section.
[in]mapsection.
[in]functo call to retrieve CONF_PAIR values. Must return a talloced buffer containing the value.
[in]datato pass to func, usually a result pointer.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 775 of file client.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 128 of file client.c.

+ Here is the caller graph for this function:

RADCLIENT* client_read ( char const *  filename,
int  in_server,
int  flag 
)

Definition at line 1449 of file client.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

fr_ipaddr_t cl_ipaddr
static

Definition at line 477 of file client.c.

char const* cl_srcipaddr = NULL
static

Definition at line 478 of file client.c.

const CONF_PARSER client_config[]
static

Definition at line 494 of file client.c.

fr_fifo_t* deleted_clients = NULL
static

Definition at line 56 of file client.c.

const CONF_PARSER dynamic_config[]
static
Initial value:
= {
{ FR_CONF_OFFSET("FreeRADIUS-Client-IP-Address", PW_TYPE_IPV4_ADDR, RADCLIENT, ipaddr) },
{ FR_CONF_OFFSET("FreeRADIUS-Client-IPv6-Address", PW_TYPE_IPV6_ADDR, RADCLIENT, ipaddr) },
{ FR_CONF_OFFSET("FreeRADIUS-Client-IP-Prefix", PW_TYPE_IPV4_PREFIX, RADCLIENT, ipaddr) },
{ FR_CONF_OFFSET("FreeRADIUS-Client-IPv6-Prefix", PW_TYPE_IPV6_PREFIX, RADCLIENT, ipaddr) },
{ FR_CONF_OFFSET("FreeRADIUS-Client-Src-IP-Address", PW_TYPE_IPV4_ADDR, RADCLIENT, src_ipaddr) },
{ FR_CONF_OFFSET("FreeRADIUS-Client-Src-IPv6-Address", PW_TYPE_IPV6_ADDR, RADCLIENT, src_ipaddr) },
{ FR_CONF_OFFSET("FreeRADIUS-Client-Require-MA", PW_TYPE_BOOLEAN, RADCLIENT, message_authenticator) },
{ FR_CONF_OFFSET("FreeRADIUS-Client-Secret", PW_TYPE_STRING, RADCLIENT, secret), .dflt = "" },
{ FR_CONF_OFFSET("FreeRADIUS-Client-Shortname", PW_TYPE_STRING, RADCLIENT, shortname), .dflt = "" },
{ FR_CONF_OFFSET("FreeRADIUS-Client-NAS-Type", PW_TYPE_STRING, RADCLIENT, nas_type) },
{ FR_CONF_OFFSET("FreeRADIUS-Client-Virtual-Server", PW_TYPE_STRING, RADCLIENT, server) },
}
128 Bit IPv6 Address.
Definition: radius.h:40
#define CONF_PARSER_TERMINATOR
Definition: conffile.h:289
IPv6 Prefix.
Definition: radius.h:41
A truth value.
Definition: radius.h:56
Describes a host allowed to send packets to the server.
Definition: clients.h:35
#define FR_CONF_OFFSET(_n, _t, _s, _f)
Definition: conffile.h:168
static char const * secret
Definition: radclient.c:44
IPv4 Prefix.
Definition: radius.h:52
String of printable characters.
Definition: radius.h:33
32 Bit IPv4 Address.
Definition: radius.h:35

Definition at line 688 of file client.c.

char const* hs_proto = NULL
static

Definition at line 480 of file client.c.

CONF_PARSER limit_config[]
static
Initial value:
= {
{ FR_CONF_OFFSET("max_connections", PW_TYPE_INTEGER, RADCLIENT, limit.max_connections), .dflt = "16" },
{ FR_CONF_OFFSET("lifetime", PW_TYPE_INTEGER, RADCLIENT, limit.lifetime), .dflt = "0" },
{ FR_CONF_OFFSET("idle_timeout", PW_TYPE_INTEGER, RADCLIENT, limit.idle_timeout), .dflt = "30" },
}
uint32_t lifetime
How long before the client is removed.
Definition: clients.h:80
#define CONF_PARSER_TERMINATOR
Definition: conffile.h:289
32 Bit unsigned integer.
Definition: radius.h:34
Describes a host allowed to send packets to the server.
Definition: clients.h:35
#define FR_CONF_OFFSET(_n, _t, _s, _f)
Definition: conffile.h:168

Definition at line 484 of file client.c.

RADCLIENT_LIST* root_clients = NULL
static

Definition at line 53 of file client.c.

rbtree_t* tree_num = NULL
static

Definition at line 50 of file client.c.

int tree_num_max = 0
static

Definition at line 51 of file client.c.