The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Data Structures | Macros | Functions | Variables
client.c File Reference

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

#include <freeradius-devel/protocol/freeradius/freeradius.internal.h>
#include <freeradius-devel/server/cf_file.h>
#include <freeradius-devel/server/cf_parse.h>
#include <freeradius-devel/server/client.h>
#include <freeradius-devel/server/main_config.h>
#include <freeradius-devel/server/module.h>
#include <freeradius-devel/server/virtual_servers.h>
#include <freeradius-devel/unlang/call.h>
#include <freeradius-devel/util/debug.h>
#include <freeradius-devel/util/base16.h>
#include <freeradius-devel/util/misc.h>
#include <freeradius-devel/util/trie.h>
#include <ctype.h>
#include <fcntl.h>
#include <sys/stat.h>
+ Include dependency graph for client.c:

Go to the source code of this file.

Data Structures

struct  fr_client_list_s
 Group of clients. More...
 

Macros

#define namecmp(a)   ((!old->a && !client->a) || (old->a && client->a && (strcmp(old->a, client->a) == 0)))
 
#define TLS_UNUSED   UNUSED
 Create a list of clients from a client section. More...
 

Functions

bool client_add (fr_client_list_t *clients, fr_client_t *client)
 Add a client to a fr_client_list_t. More...
 
fr_client_tclient_afrom_cs (TALLOC_CTX *ctx, CONF_SECTION *cs, CONF_SECTION *server_cs, size_t extra)
 Allocate a new client from a config section. More...
 
fr_client_tclient_afrom_request (TALLOC_CTX *ctx, request_t *request)
 Create a new client, consuming all attributes in the control list of the request. More...
 
static int8_t client_cmp (void const *one, void const *two)
 
void client_delete (fr_client_list_t *clients, fr_client_t *client)
 
fr_client_tclient_find (fr_client_list_t const *clients, fr_ipaddr_t const *ipaddr, int proto)
 
fr_client_tclient_findbynumber (UNUSED const fr_client_list_t *clients, UNUSED int number)
 
void client_free (fr_client_t *client)
 Free a client. More...
 
fr_client_tclient_from_request (request_t *request)
 Search up a list of requests trying to locate one which has a client. More...
 
void client_list_free (void)
 
fr_client_list_tclient_list_init (CONF_SECTION *cs)
 Return a new client list. More...
 
fr_client_list_tclient_list_parse_section (CONF_SECTION *section, int proto, TLS_UNUSED bool tls_required)
 
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...
 
fr_client_tclient_read (char const *filename, CONF_SECTION *server_cs, bool check_dns)
 Read a single client from a file. More...
 

Variables

static fr_ipaddr_t cl_ipaddr
 
static char const * cl_srcipaddr = NULL
 
static const conf_parser_t client_config []
 
static char const * hs_proto = NULL
 
static conf_parser_t limit_config []
 
static fr_client_list_troot_clients = NULL
 Global client list. More...
 

Detailed Description

Manage clients allowed to communicate with the server.

Id
7b5f3dc09929f5996d10cebad77273d4e595f302

Definition in file client.c.


Data Structure Documentation

◆ fr_client_list_s

struct fr_client_list_s

Group of clients.

Definition at line 52 of file client.c.

+ Collaboration diagram for fr_client_list_s:
Data Fields
char const * name Name of the client list.
fr_rb_tree_t * tree[129]

Macro Definition Documentation

◆ namecmp

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

◆ TLS_UNUSED

#define TLS_UNUSED   UNUSED

Create a list of clients from a client section.

Iterates over all client definitions in the specified section, adding them to a client list.

Definition at line 464 of file client.c.

Function Documentation

◆ client_add()

bool client_add ( fr_client_list_t clients,
fr_client_t client 
)

Add a client to a fr_client_list_t.

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 184 of file client.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ client_afrom_cs()

fr_client_t* client_afrom_cs ( TALLOC_CTX *  ctx,
CONF_SECTION cs,
CONF_SECTION server_cs,
size_t  extra 
)

Allocate a new client from a config section.

Parameters
ctxto allocate new clients in.
csto process as a client.
server_csThe virtual server that this client belongs to.
extra0 allocate sizeof(fr_client_t) bytes >sizeof(client_t) number of bytes to allocate
Returns
new fr_client_t struct.

Definition at line 697 of file client.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ client_afrom_request()

fr_client_t* client_afrom_request ( TALLOC_CTX *  ctx,
request_t request 
)

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

Parameters
ctxthe talloc context
requestcontaining the client attributes.
Returns
  • New client on success.
  • NULL on error.

Definition at line 915 of file client.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ client_cmp()

static int8_t client_cmp ( void const *  one,
void const *  two 
)
static

Definition at line 67 of file client.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ client_delete()

void client_delete ( fr_client_list_t clients,
fr_client_t client 
)

Definition at line 339 of file client.c.

+ Here is the call graph for this function:

◆ client_find()

fr_client_t* client_find ( fr_client_list_t const *  clients,
fr_ipaddr_t const *  ipaddr,
int  proto 
)

Definition at line 375 of file client.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ client_findbynumber()

fr_client_t* client_findbynumber ( UNUSED const fr_client_list_t clients,
UNUSED int  number 
)

Definition at line 366 of file client.c.

+ Here is the caller graph for this function:

◆ client_free()

void client_free ( fr_client_t client)

Free a client.

It's up to the caller to ensure that it's deleted from any fr_client_list_t.

Definition at line 95 of file client.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ client_from_request()

fr_client_t* client_from_request ( request_t request)

Search up a list of requests trying to locate one which has a client.

Definition at line 1092 of file client.c.

+ Here is the caller graph for this function:

◆ client_list_free()

void client_list_free ( void  )

Definition at line 86 of file client.c.

+ Here is the caller graph for this function:

◆ client_list_init()

fr_client_list_t* client_list_init ( CONF_SECTION cs)

Return a new client list.

Note
The container won't contain any clients.
Returns
  • New client list on success.
  • NULL on error (OOM).

Definition at line 110 of file client.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ client_list_parse_section()

fr_client_list_t* client_list_parse_section ( CONF_SECTION section,
int  proto,
TLS_UNUSED bool  tls_required 
)

Definition at line 467 of file client.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ client_map_section()

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 615 of file client.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ client_read()

fr_client_t* client_read ( char const *  filename,
CONF_SECTION server_cs,
bool  check_dns 
)

Read a single client from a file.

This function supports asynchronous runtime loading of clients.

Parameters
[in]filenameTo read clients from.
[in]server_csof virtual server clients should be added to.
[in]check_dnsCheck reverse lookup of IP address matches filename.
Returns
  • The new client on success.
  • NULL on failure.

Definition at line 1040 of file client.c.

+ Here is the call graph for this function:

Variable Documentation

◆ cl_ipaddr

fr_ipaddr_t cl_ipaddr
static

Definition at line 418 of file client.c.

◆ cl_srcipaddr

char const* cl_srcipaddr = NULL
static

Definition at line 419 of file client.c.

◆ client_config

const conf_parser_t client_config[]
static
Initial value:
= {
{ FR_CONF_POINTER("src_ipaddr", FR_TYPE_STRING, 0, &cl_srcipaddr) },
{ FR_CONF_OFFSET("shortname", fr_client_t, shortname) },
{ FR_CONF_OFFSET("nas_type", fr_client_t, nas_type) },
{ FR_CONF_OFFSET("track_connections", fr_client_t, use_connected) },
{ FR_CONF_OFFSET("require_message_authenticator", fr_client_t, message_authenticator) },
{ FR_CONF_OFFSET("dedup_authenticator", fr_client_t, dedup_authenticator) },
{ FR_CONF_OFFSET("response_window", fr_client_t, response_window) },
{ FR_CONF_POINTER("limit", 0, CONF_FLAG_SUBSECTION, NULL), .subcs = (void const *) limit_config },
}
#define CONF_PARSER_TERMINATOR
Definition: cf_parse.h:626
#define FR_CONF_OFFSET(_name, _struct, _field)
conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct
Definition: cf_parse.h:268
#define FR_CONF_POINTER(_name, _type, _flags, _res_p)
conf_parser_t which parses a single CONF_PAIR producing a single global result
Definition: cf_parse.h:310
#define FR_CONF_OFFSET_FLAGS(_name, _flags, _struct, _field)
conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct
Definition: cf_parse.h:256
@ CONF_FLAG_SECRET
Only print value if debug level >= 3.
Definition: cf_parse.h:410
@ CONF_FLAG_SUBSECTION
Instead of putting the information into a configuration structure, the configuration file routines MA...
Definition: cf_parse.h:400
Describes a host allowed to send packets to the server.
Definition: client.h:77
@ FR_TYPE_IPV6_PREFIX
IPv6 Prefix.
Definition: merged_model.c:89
@ FR_TYPE_STRING
String of printable characters.
Definition: merged_model.c:83
@ FR_TYPE_COMBO_IP_PREFIX
IPv4 or IPv6 address prefix depending on length.
Definition: merged_model.c:92
@ FR_TYPE_IPV4_PREFIX
IPv4 Prefix.
Definition: merged_model.c:87
static char * secret
Definition: radclient-ng.c:69
static fr_ipaddr_t cl_ipaddr
Definition: client.c:418
static conf_parser_t limit_config[]
Definition: client.c:422
static char const * cl_srcipaddr
Definition: client.c:419
static char const * hs_proto
Definition: client.c:420

Definition at line 431 of file client.c.

◆ hs_proto

char const* hs_proto = NULL
static

Definition at line 420 of file client.c.

◆ limit_config

conf_parser_t limit_config[]
static
Initial value:
= {
{ FR_CONF_OFFSET("max_connections", fr_client_t, limit.max_connections), .dflt = "16" },
{ FR_CONF_OFFSET("lifetime", fr_client_t, limit.lifetime), .dflt = "0" },
{ FR_CONF_OFFSET("idle_timeout", fr_client_t, limit.idle_timeout), .dflt = "30s" },
}

Definition at line 422 of file client.c.

◆ root_clients

fr_client_list_t* root_clients = NULL
static

Global client list.

Definition at line 64 of file client.c.