The FreeRADIUS server $Id: a4e7f8c94e8038b7627bcf52356b7ed15955c1d7 $
Loading...
Searching...
No Matches
Macros | Functions | Variables
fd_config.c File Reference

BIO abstractions for configuring file descriptors. More...

#include <freeradius-devel/server/cf_parse.h>
#include <freeradius-devel/server/tmpl.h>
#include <freeradius-devel/util/perm.h>
#include <freeradius-devel/bio/fd_priv.h>
#include <freeradius-devel/bio/network.h>
+ Include dependency graph for fd_config.c:

Go to the source code of this file.

Macros

#define NETWORKS_CONFIG
 

Functions

static int client_transport_parse (TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
 Parse "transport" and then set the subconfig.
 
static int common_transport_parse (UNUSED TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, UNUSED conf_parser_t const *rule, conf_parser_t const *transport_table[FR_BIO_FD_TRANSPORT_SIZE])
 Parse "transport" and then set the subconfig.
 
static int mode_parse (UNUSED TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, UNUSED conf_parser_t const *rule)
 
static int networks_forbidden (CONF_SECTION *subcs, char const *what)
 Check if the socket has a networks section where it doesn't make sense.
 
static int networks_parse (TALLOC_CTX *ctx, UNUSED void *out, void *parent, CONF_ITEM *ci, UNUSED conf_parser_t const *rule)
 Parse the "networks" subsection, and create the trie which filters packets and connections.
 
static int send_recv_buf_parse (TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
 Parse a socket buffer size, and check that it fits into the "int" taken by setsockopt()
 
static int server_transport_parse (TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
 Parse "transport" and then set the subconfig.
 

Variables

static conf_parser_t const client_file_config []
 
static const conf_parser_t client_file_sub_config []
 
static conf_parser_t const client_tcp_config []
 
static const conf_parser_t client_tcp_sub_config []
 
static conf_parser_t const client_tcp_unconnected_config []
 
static const conf_parser_t client_tcp_unconnected_sub_config []
 
static conf_parser_t const * client_transport_configs [FR_BIO_FD_TRANSPORT_SIZE]
 
static conf_parser_t const client_udp_config []
 
static const conf_parser_t client_udp_sub_config []
 
static conf_parser_t const client_udp_unconnected_config []
 
static const conf_parser_t client_udp_unconnected_sub_config []
 
static conf_parser_t const client_unix_config []
 
static const conf_parser_t client_unix_sub_config []
 
const conf_parser_t fr_bio_fd_client_config []
 
const conf_parser_t fr_bio_fd_server_config []
 
static fr_table_num_sorted_t mode_names []
 
static size_t mode_names_len = NUM_ELEMENTS(mode_names)
 
static const conf_parser_t networks_config []
 
static conf_parser_t const server_file_config []
 
static const conf_parser_t server_file_sub_config []
 
static const conf_parser_t server_peercred_config []
 
static conf_parser_t const server_tcp_config []
 
static const conf_parser_t server_tcp_sub_config []
 
static conf_parser_t const * server_transport_configs [FR_BIO_FD_TRANSPORT_SIZE]
 
static conf_parser_t const server_udp_config []
 
static const conf_parser_t server_udp_sub_config []
 
static conf_parser_t const server_unix_config []
 
static const conf_parser_t server_unix_sub_config []
 
static fr_table_num_sorted_t transport_types []
 Mapping table of transport names to the transport types.
 
static size_t transport_types_len = NUM_ELEMENTS(transport_types)
 

Detailed Description

BIO abstractions for configuring file descriptors.

Id
c3c7009cca4f5a25ea278949d1ef57de1a94cc3c

Definition in file fd_config.c.

Macro Definition Documentation

◆ NETWORKS_CONFIG

#define NETWORKS_CONFIG
Value:
.subcs = (void const *) networks_config, .func = networks_parse }
@ CONF_FLAG_OK_MISSING
OK if it's missing.
Definition cf_parse.h:491
@ CONF_FLAG_SUBSECTION
Instead of putting the information into a configuration structure, the configuration file routines MA...
Definition cf_parse.h:460
#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:350
static int networks_parse(TALLOC_CTX *ctx, UNUSED void *out, void *parent, CONF_ITEM *ci, UNUSED conf_parser_t const *rule)
Parse the "networks" subsection, and create the trie which filters packets and connections.
Definition fd_config.c:92
static const conf_parser_t networks_config[]
Definition fd_config.c:80

Definition at line 116 of file fd_config.c.

Function Documentation

◆ client_transport_parse()

static int client_transport_parse ( TALLOC_CTX *  ctx,
void *  out,
void *  parent,
CONF_ITEM *  ci,
conf_parser_t const *  rule 
)
static

Parse "transport" and then set the subconfig.

Definition at line 379 of file fd_config.c.

+ Here is the call graph for this function:

◆ common_transport_parse()

static int common_transport_parse ( UNUSED TALLOC_CTX *  ctx,
void *  out,
void *  parent,
CONF_ITEM *  ci,
UNUSED conf_parser_t const *  rule,
conf_parser_t const *  transport_table[FR_BIO_FD_TRANSPORT_SIZE] 
)
static

Parse "transport" and then set the subconfig.

Definition at line 149 of file fd_config.c.

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

◆ mode_parse()

static int mode_parse ( UNUSED TALLOC_CTX *  ctx,
void *  out,
UNUSED void *  parent,
CONF_ITEM *  ci,
UNUSED conf_parser_t const *  rule 
)
static

Definition at line 42 of file fd_config.c.

+ Here is the call graph for this function:

◆ networks_forbidden()

static int networks_forbidden ( CONF_SECTION *  subcs,
char const *  what 
)
static

Check if the socket has a networks section where it doesn't make sense.

Only unconnected UDP server sockets and TCP server listening sockets check the source of packets and connections. A client which makes outbound connections either makes connections to known destinations, or (for UDP) checks that responses match the 4-tuple of requests.

Definition at line 125 of file fd_config.c.

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

◆ networks_parse()

static int networks_parse ( TALLOC_CTX *  ctx,
UNUSED void *  out,
void *  parent,
CONF_ITEM *  ci,
UNUSED conf_parser_t const *  rule 
)
static

Parse the "networks" subsection, and create the trie which filters packets and connections.

The "networks" rule is the last rule of its transport subsection. The socket "ipaddr" has already been parsed, which means that we know the address family of the socket.

Definition at line 92 of file fd_config.c.

+ Here is the call graph for this function:

◆ send_recv_buf_parse()

static int send_recv_buf_parse ( TALLOC_CTX *  ctx,
void *  out,
void *  parent,
CONF_ITEM *  ci,
conf_parser_t const *  rule 
)
static

Parse a socket buffer size, and check that it fits into the "int" taken by setsockopt()

Note that this function parses a plain integer. cf_table_parse_uint32() looks the value up in a table taken from rule->uctx, and these rules have no uctx.

Definition at line 63 of file fd_config.c.

+ Here is the call graph for this function:

◆ server_transport_parse()

static int server_transport_parse ( TALLOC_CTX *  ctx,
void *  out,
void *  parent,
CONF_ITEM *  ci,
conf_parser_t const *  rule 
)
static

Parse "transport" and then set the subconfig.

Definition at line 566 of file fd_config.c.

+ Here is the call graph for this function:

Variable Documentation

◆ client_file_config

conf_parser_t const client_file_config[]
static
Initial value:
= {
{ FR_CONF_POINTER("file", 0, CONF_FLAG_SUBSECTION, NULL), .subcs = (void const *) client_file_sub_config },
}
#define CONF_PARSER_TERMINATOR
Definition cf_parse.h:722
static const conf_parser_t client_file_sub_config[]
Definition fd_config.c:341

Definition at line 351 of file fd_config.c.

◆ client_file_sub_config

const conf_parser_t client_file_sub_config[]
static
Initial value:
= {
{ FR_CONF_OFFSET("permissions", fr_bio_fd_config_t, perm), .dflt = "0600", .func = cf_parse_permissions },
{ FR_CONF_OFFSET("mode", fr_bio_fd_config_t, flags), .dflt = "read-write", .func = mode_parse },
}
int cf_parse_permissions(UNUSED TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, UNUSED conf_parser_t const *rule)
Generic function for resolving permissions to a mode-t.
Definition cf_parse.c:1909
#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:280
@ CONF_FLAG_REQUIRED
Error out if no matching CONF_PAIR is found, and no dflt value is set.
Definition cf_parse.h:466
#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:268
Configuration for sockets.
Definition fd.h:93
static int mode_parse(UNUSED TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, UNUSED conf_parser_t const *rule)
Definition fd_config.c:42

Definition at line 341 of file fd_config.c.

◆ client_tcp_config

conf_parser_t const client_tcp_config[]
static
Initial value:
= {
{ FR_CONF_POINTER("tcp", 0, CONF_FLAG_SUBSECTION, NULL), .subcs = (void const *) client_tcp_sub_config },
}
static const conf_parser_t client_tcp_sub_config[]
Definition fd_config.c:310

Definition at line 335 of file fd_config.c.

◆ client_tcp_sub_config

const conf_parser_t client_tcp_sub_config[]
static
Initial value:
= {
{ FR_CONF_OFFSET("port", fr_bio_fd_config_t, dst_port) },
{ FR_CONF_OFFSET_TYPE_FLAGS("src_ipv4addr", FR_TYPE_IPV4_ADDR, 0, fr_bio_fd_config_t, src_ipaddr) },
{ FR_CONF_OFFSET_TYPE_FLAGS("src_ipv6addr", FR_TYPE_IPV6_ADDR, 0, fr_bio_fd_config_t, src_ipaddr) },
{ FR_CONF_OFFSET("src_port", fr_bio_fd_config_t, src_port) },
{ FR_CONF_OFFSET("src_port_start", fr_bio_fd_config_t, src_port_start) },
{ FR_CONF_OFFSET("src_port_end", fr_bio_fd_config_t, src_port_end) },
{ FR_CONF_OFFSET("interface", fr_bio_fd_config_t, interface) },
{ FR_CONF_OFFSET("delay_tcp_writes", fr_bio_fd_config_t, tcp_delay) },
}
#define FR_CONF_OFFSET_IS_SET(_name, _type, _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:294
#define FR_CONF_OFFSET_TYPE_FLAGS(_name, _type, _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:238
static int send_recv_buf_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
Parse a socket buffer size, and check that it fits into the "int" taken by setsockopt()
Definition fd_config.c:63
@ FR_TYPE_IPV4_ADDR
32 Bit IPv4 Address.
@ FR_TYPE_UINT32
32 Bit unsigned integer.
@ FR_TYPE_IPV6_ADDR
128 Bit IPv6 Address.
@ FR_TYPE_COMBO_IP_ADDR
IPv4 or IPv6 address depending on length.

Definition at line 310 of file fd_config.c.

◆ client_tcp_unconnected_config

conf_parser_t const client_tcp_unconnected_config[]
static
Initial value:
= {
{ FR_CONF_POINTER("tcp", 0, CONF_FLAG_SUBSECTION, NULL), .subcs = (void const *) client_tcp_unconnected_sub_config },
}
static const conf_parser_t client_tcp_unconnected_sub_config[]
Definition fd_config.c:288

Definition at line 303 of file fd_config.c.

◆ client_tcp_unconnected_sub_config

const conf_parser_t client_tcp_unconnected_sub_config[]
static
Initial value:
= {
{ FR_CONF_OFFSET_TYPE_FLAGS("src_ipv4addr", FR_TYPE_IPV4_ADDR, 0, fr_bio_fd_config_t, src_ipaddr) },
{ FR_CONF_OFFSET_TYPE_FLAGS("src_ipv6addr", FR_TYPE_IPV6_ADDR, 0, fr_bio_fd_config_t, src_ipaddr) },
{ FR_CONF_OFFSET("interface", fr_bio_fd_config_t, interface) },
{ FR_CONF_OFFSET("delay_tcp_writes", fr_bio_fd_config_t, tcp_delay) },
}

Definition at line 288 of file fd_config.c.

◆ client_transport_configs

conf_parser_t const* client_transport_configs[FR_BIO_FD_TRANSPORT_SIZE]
static
Initial value:
= {
}
@ FR_BIO_FD_TRANSPORT_TCP
TCP over IPv4 or IPv6.
Definition fd.h:80
@ FR_BIO_FD_TRANSPORT_UDP
UDP over IPv4 or IPv6.
Definition fd.h:81
@ FR_BIO_FD_TRANSPORT_UNIX
Unix domain socket, named by 'path'.
Definition fd.h:82
@ FR_BIO_FD_TRANSPORT_FILE
regular file, named by 'filename'
Definition fd.h:79
static conf_parser_t const client_file_config[]
Definition fd_config.c:351
static conf_parser_t const client_udp_config[]
Definition fd_config.c:251
static conf_parser_t const client_unix_config[]
Definition fd_config.c:363
static conf_parser_t const client_tcp_config[]
Definition fd_config.c:335

Definition at line 369 of file fd_config.c.

◆ client_udp_config

conf_parser_t const client_udp_config[]
static
Initial value:
= {
{ FR_CONF_POINTER("udp", 0, CONF_FLAG_SUBSECTION, NULL), .subcs = (void const *) client_udp_sub_config },
}
static const conf_parser_t client_udp_sub_config[]
Definition fd_config.c:224

Definition at line 251 of file fd_config.c.

◆ client_udp_sub_config

const conf_parser_t client_udp_sub_config[]
static
Initial value:
= {
{ FR_CONF_OFFSET("port", fr_bio_fd_config_t, dst_port) },
{ FR_CONF_OFFSET_TYPE_FLAGS("src_ipv4addr", FR_TYPE_IPV4_ADDR, 0, fr_bio_fd_config_t, src_ipaddr) },
{ FR_CONF_OFFSET_TYPE_FLAGS("src_ipv6addr", FR_TYPE_IPV6_ADDR, 0, fr_bio_fd_config_t, src_ipaddr) },
{ FR_CONF_OFFSET("src_port", fr_bio_fd_config_t, src_port) },
{ FR_CONF_OFFSET("src_port_start", fr_bio_fd_config_t, src_port_start) },
{ FR_CONF_OFFSET("src_port_end", fr_bio_fd_config_t, src_port_end) },
{ FR_CONF_OFFSET("interface", fr_bio_fd_config_t, interface) },
}

Definition at line 224 of file fd_config.c.

◆ client_udp_unconnected_config

conf_parser_t const client_udp_unconnected_config[]
static
Initial value:
= {
{ FR_CONF_POINTER("udp", 0, CONF_FLAG_SUBSECTION, NULL), .subcs = (void const *) client_udp_unconnected_sub_config },
}
static const conf_parser_t client_udp_unconnected_sub_config[]
Definition fd_config.c:258

Definition at line 278 of file fd_config.c.

◆ client_udp_unconnected_sub_config

const conf_parser_t client_udp_unconnected_sub_config[]
static
Initial value:
= {
{ FR_CONF_OFFSET_TYPE_FLAGS("src_ipv4addr", FR_TYPE_IPV4_ADDR, 0, fr_bio_fd_config_t, src_ipaddr) },
{ FR_CONF_OFFSET_TYPE_FLAGS("src_ipv6addr", FR_TYPE_IPV6_ADDR, 0, fr_bio_fd_config_t, src_ipaddr) },
{ FR_CONF_OFFSET("interface", fr_bio_fd_config_t, interface) },
{ FR_CONF_OFFSET("src_port_start", fr_bio_fd_config_t, src_port_start) },
{ FR_CONF_OFFSET("src_port_end", fr_bio_fd_config_t, src_port_end) },
}

Definition at line 258 of file fd_config.c.

◆ client_unix_config

conf_parser_t const client_unix_config[]
static
Initial value:
= {
{ FR_CONF_POINTER("unix", 0, CONF_FLAG_SUBSECTION, NULL), .subcs = (void const *) client_unix_sub_config },
}
static const conf_parser_t client_unix_sub_config[]
Definition fd_config.c:357

Definition at line 363 of file fd_config.c.

◆ client_unix_sub_config

const conf_parser_t client_unix_sub_config[]
static
Initial value:

Definition at line 357 of file fd_config.c.

◆ fr_bio_fd_client_config

const conf_parser_t fr_bio_fd_client_config[]
Initial value:
= {
{ FR_CONF_OFFSET("transport", fr_bio_fd_config_t, transport), .func = client_transport_parse },
{ FR_CONF_OFFSET("async", fr_bio_fd_config_t, async), .dflt = "true" },
}
static int client_transport_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
Parse "transport" and then set the subconfig.
Definition fd_config.c:379

Definition at line 439 of file fd_config.c.

◆ fr_bio_fd_server_config

const conf_parser_t fr_bio_fd_server_config[]
Initial value:
= {
{ FR_CONF_OFFSET("transport", fr_bio_fd_config_t, transport), .func = server_transport_parse },
{ FR_CONF_OFFSET("async", fr_bio_fd_config_t, async), .dflt = "true" },
}
static int server_transport_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
Parse "transport" and then set the subconfig.
Definition fd_config.c:566

Definition at line 614 of file fd_config.c.

◆ mode_names

fr_table_num_sorted_t mode_names[]
static
Initial value:
= {
{ L("read-only"), O_RDONLY },
{ L("read-write"), O_RDWR },
{ L("ro"), O_RDONLY },
{ L("rw"), O_RDWR },
{ L("wo"), O_WRONLY },
{ L("write-only"), O_WRONLY },
}
#define L(_str)
Helper for initialising arrays of string literals.
Definition build.h:245

Definition at line 32 of file fd_config.c.

◆ mode_names_len

size_t mode_names_len = NUM_ELEMENTS(mode_names)
static

Definition at line 40 of file fd_config.c.

◆ networks_config

const conf_parser_t networks_config[]
static
Initial value:
= {
}
@ CONF_FLAG_MULTI
CONF_PAIR can have multiple copies.
Definition cf_parse.h:483
@ FR_TYPE_COMBO_IP_PREFIX
IPv4 or IPv6 address prefix depending on length.

Definition at line 80 of file fd_config.c.

◆ server_file_config

conf_parser_t const server_file_config[]
static
Initial value:
= {
{ FR_CONF_POINTER("file", 0, CONF_FLAG_SUBSECTION, NULL), .subcs = (void const *) server_file_sub_config },
}
static const conf_parser_t server_file_sub_config[]
Definition fd_config.c:510

Definition at line 520 of file fd_config.c.

◆ server_file_sub_config

const conf_parser_t server_file_sub_config[]
static
Initial value:
= {
{ FR_CONF_OFFSET("permissions", fr_bio_fd_config_t, perm), .dflt = "0600", .func = cf_parse_permissions },
{ FR_CONF_OFFSET("mkdir", fr_bio_fd_config_t, mkdir) },
}

Definition at line 510 of file fd_config.c.

◆ server_peercred_config

const conf_parser_t server_peercred_config[]
static
Initial value:
= {
{ FR_CONF_OFFSET("uid", fr_bio_fd_config_t, uid), .func = cf_parse_uid },
{ FR_CONF_OFFSET("gid", fr_bio_fd_config_t, gid), .func = cf_parse_gid },
}
int cf_parse_gid(TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, UNUSED conf_parser_t const *rule)
Generic function for resolving GID strings to uid_t values.
Definition cf_parse.c:1894
int cf_parse_uid(TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule)

Definition at line 526 of file fd_config.c.

◆ server_tcp_config

conf_parser_t const server_tcp_config[]
static
Initial value:
= {
{ FR_CONF_POINTER("tcp", 0, CONF_FLAG_SUBSECTION, NULL), .subcs = (void const *) server_tcp_sub_config },
}
static const conf_parser_t server_tcp_sub_config[]
Definition fd_config.c:483

Definition at line 504 of file fd_config.c.

◆ server_tcp_sub_config

const conf_parser_t server_tcp_sub_config[]
static
Initial value:
= {
{ FR_CONF_OFFSET("port", fr_bio_fd_config_t, src_port) },
{ FR_CONF_OFFSET("interface", fr_bio_fd_config_t, interface) },
{ FR_CONF_OFFSET("delay_tcp_writes", fr_bio_fd_config_t, tcp_delay) },
}
#define NETWORKS_CONFIG
Definition fd_config.c:116

Definition at line 483 of file fd_config.c.

◆ server_transport_configs

conf_parser_t const* server_transport_configs[FR_BIO_FD_TRANSPORT_SIZE]
static
Initial value:
= {
}
static conf_parser_t const server_unix_config[]
Definition fd_config.c:547
static conf_parser_t const server_file_config[]
Definition fd_config.c:520
static conf_parser_t const server_udp_config[]
Definition fd_config.c:477
static conf_parser_t const server_tcp_config[]
Definition fd_config.c:504

Definition at line 556 of file fd_config.c.

◆ server_udp_config

conf_parser_t const server_udp_config[]
static
Initial value:
= {
{ FR_CONF_POINTER("udp", 0, CONF_FLAG_SUBSECTION, NULL), .subcs = (void const *) server_udp_sub_config },
}
static const conf_parser_t server_udp_sub_config[]
Definition fd_config.c:456

Definition at line 477 of file fd_config.c.

◆ server_udp_sub_config

const conf_parser_t server_udp_sub_config[]
static
Initial value:

Definition at line 456 of file fd_config.c.

◆ server_unix_config

conf_parser_t const server_unix_config[]
static
Initial value:
= {
{ FR_CONF_POINTER("unix", 0, CONF_FLAG_SUBSECTION, NULL), .subcs = (void const *) server_unix_sub_config },
}
static const conf_parser_t server_unix_sub_config[]
Definition fd_config.c:533

Definition at line 547 of file fd_config.c.

◆ server_unix_sub_config

const conf_parser_t server_unix_sub_config[]
static
Initial value:
= {
{ FR_CONF_OFFSET("permissions", fr_bio_fd_config_t, perm), .dflt = "0600", .func = cf_parse_permissions },
{ FR_CONF_OFFSET("mode", fr_bio_fd_config_t, flags), .dflt = "read-only", .func = mode_parse },
{ FR_CONF_OFFSET("mkdir", fr_bio_fd_config_t, mkdir) },
{ FR_CONF_POINTER("peercred", 0, CONF_FLAG_SUBSECTION, NULL), .subcs = (void const *) server_peercred_config },
}
static const conf_parser_t server_peercred_config[]
Definition fd_config.c:526

Definition at line 533 of file fd_config.c.

◆ transport_types

fr_table_num_sorted_t transport_types[]
static
Initial value:
= {
}

Mapping table of transport names to the transport types.

Definition at line 138 of file fd_config.c.

◆ transport_types_len

size_t transport_types_len = NUM_ELEMENTS(transport_types)
static

Definition at line 144 of file fd_config.c.