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/sbuff.h>
#include <freeradius-devel/util/value.h>
#include <freeradius-devel/util/trie.h>
#include <freeradius-devel/util/token.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
95a5c55d3a3cc97ce2ec2a34f66600e3550fb718

Definition in file client.c.


Data Structure Documentation

◆ fr_client_list_s

struct fr_client_list_s

Group of clients.

Definition at line 55 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 475 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 187 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 708 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 930 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 70 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 342 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 378 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 369 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 98 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 1112 of file client.c.

+ Here is the caller graph for this function:

◆ client_list_free()

void client_list_free ( void  )

Definition at line 89 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 113 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 478 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 626 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 1060 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 421 of file client.c.

◆ cl_srcipaddr

char const* cl_srcipaddr = NULL
static

Definition at line 422 of file client.c.

◆ client_config

const conf_parser_t client_config[]
static

Definition at line 434 of file client.c.

◆ hs_proto

char const* hs_proto = NULL
static

Definition at line 423 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" },
}
#define CONF_PARSER_TERMINATOR
Definition: cf_parse.h:627
#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
Describes a host allowed to send packets to the server.
Definition: client.h:80

Definition at line 425 of file client.c.

◆ root_clients

fr_client_list_t* root_clients = NULL
static

Global client list.

Definition at line 67 of file client.c.