![]() |
The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
Read ISC DHCP configuration files. More...
#include <freeradius-devel/server/base.h>
#include <freeradius-devel/server/module_rlm.h>
#include <freeradius-devel/dhcpv4/dhcpv4.h>
#include <freeradius-devel/util/debug.h>
#include <freeradius-devel/util/skip.h>
#include <freeradius-devel/server/map_proc.h>
Go to the source code of this file.
Data Structures | |
struct | isc_host_ether_t |
struct | isc_host_uid_t |
struct | rlm_isc_dhcp_cmd_t |
Describes the commands that we accept, including it's syntax (i.e. More... | |
struct | rlm_isc_dhcp_info_s |
Holds information about the thing we parsed. More... | |
struct | rlm_isc_dhcp_t |
struct | rlm_isc_dhcp_tokenizer_t |
Holds the state of the current tokenizer. More... | |
Macros | |
#define | DDEBUG(...) |
#define | IDEBUG if (state->debug) DEBUG |
#define | isc_ignore ISC_IGNORE, NULL, NULL |
#define | isc_invalid ISC_INVALID, NULL, NULL |
#define | isc_not_done ISC_NOOP, NULL, NULL |
#define | MAYBE_SEMICOLON (2) |
#define | member_size(type, member) sizeof(((type *)0)->member) |
#define | NO_SEMICOLON (0) |
#define | TYPE_CHECK(name, type) if ((state->token_len == (sizeof(name) - 1)) && (memcmp(state->token, name, sizeof(name) - 1) == 0)) return type |
Parse one type string. | |
#define | vb_ipv4addr vb_ip.addr.v4.s_addr |
#define | YES_SEMICOLON (1) |
Typedefs | |
typedef int(* | rlm_isc_dhcp_apply_t) (rlm_isc_dhcp_t const *inst, request_t *request, rlm_isc_dhcp_info_t *info) |
typedef struct rlm_isc_dhcp_info_s | rlm_isc_dhcp_info_t |
typedef int(* | rlm_isc_dhcp_parse_t) (rlm_isc_dhcp_tokenizer_t *state, rlm_isc_dhcp_info_t *info) |
typedef enum rlm_isc_dhcp_type_t | rlm_isc_dhcp_type_t |
Enumerations | |
enum | rlm_isc_dhcp_type_t { ISC_INVALID = 0 , ISC_NOOP , ISC_IGNORE , ISC_GROUP , ISC_HOST , ISC_SUBNET , ISC_OPTION , ISC_HARDWARE_ETHERNET , ISC_FIXED_ADDRESS } |
Functions | |
static int | add_option_by_da (rlm_isc_dhcp_info_t *info, fr_dict_attr_t const *da) |
static int | apply (rlm_isc_dhcp_t const *inst, request_t *request, rlm_isc_dhcp_info_t *head) |
Apply all rules except fixed IP. | |
static int | apply_fixed_ip (rlm_isc_dhcp_t const *inst, request_t *request) |
Apply fixed IPs. | |
static rlm_isc_dhcp_info_t * | get_host (request_t *request, fr_hash_table_t *hosts_by_ether, fr_hash_table_t *hosts_by_uid) |
static int8_t | host_ether_cmp (void const *one, void const *two) |
static uint32_t | host_ether_hash (void const *data) |
static int8_t | host_uid_cmp (void const *one, void const *two) |
static uint32_t | host_uid_hash (void const *data) |
static fr_type_t | isc2fr_type (rlm_isc_dhcp_tokenizer_t *state) |
static int | match_keyword (rlm_isc_dhcp_info_t *parent, rlm_isc_dhcp_tokenizer_t *state, rlm_isc_dhcp_cmd_t const *tokens, int num_tokens) |
static int | match_subword (rlm_isc_dhcp_tokenizer_t *state, char const *cmd, rlm_isc_dhcp_info_t *info) |
Recursively match subwords inside of a command string. | |
static unlang_action_t | mod_authorize (rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request) |
static int | mod_instantiate (module_inst_ctx_t const *mctx) |
static unlang_action_t | mod_post_auth (rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request) |
static int | parse_filename (UNUSED rlm_isc_dhcp_tokenizer_t *state, rlm_isc_dhcp_info_t *info) |
filename STRING | |
static int | parse_host (rlm_isc_dhcp_tokenizer_t *state, rlm_isc_dhcp_info_t *info) |
host NAME { ... } | |
static int | parse_include (rlm_isc_dhcp_tokenizer_t *state, rlm_isc_dhcp_info_t *info) |
static int | parse_next_server (UNUSED rlm_isc_dhcp_tokenizer_t *state, rlm_isc_dhcp_info_t *info) |
next-server IPADDR | |
static int | parse_option (rlm_isc_dhcp_info_t *parent, rlm_isc_dhcp_tokenizer_t *state, fr_dict_attr_t const *da, char *value) |
static int | parse_option_definition (rlm_isc_dhcp_info_t *parent, rlm_isc_dhcp_tokenizer_t *state, char *name) |
option new-name code new-code = definition ; | |
static int | parse_option_space (UNUSED rlm_isc_dhcp_info_t *parent, UNUSED rlm_isc_dhcp_tokenizer_t *state, UNUSED char *name) |
option space name [ [ code width number ] [ length width number ] [ hash size number ] ] ; | |
static int | parse_options (rlm_isc_dhcp_info_t *parent, rlm_isc_dhcp_tokenizer_t *state) |
Parse "option" command. | |
static int | parse_section (rlm_isc_dhcp_tokenizer_t *state, rlm_isc_dhcp_info_t *info) |
Parse a section { ... }. | |
static int | parse_server_identifier (UNUSED rlm_isc_dhcp_tokenizer_t *state, rlm_isc_dhcp_info_t *info) |
server-identifier IPADDR | |
static int | parse_server_name (UNUSED rlm_isc_dhcp_tokenizer_t *state, rlm_isc_dhcp_info_t *info) |
server-name STRING | |
static int | parse_subnet (rlm_isc_dhcp_tokenizer_t *state, rlm_isc_dhcp_info_t *info) |
subnet IPADDR netmask MASK { ... } | |
static int | read_file (rlm_isc_dhcp_t *inst, rlm_isc_dhcp_info_t *parent, char const *filename) |
Open a file and read it into a parent. | |
static int | read_string (rlm_isc_dhcp_tokenizer_t *state) |
static int | read_token (rlm_isc_dhcp_tokenizer_t *state, fr_token_t hint, int semicolon, bool allow_rcbrace) |
Reads one token into state->token. | |
static int | refill (rlm_isc_dhcp_tokenizer_t *state) |
Refills the read buffer with one line from the file. | |
static int | skip_spaces (rlm_isc_dhcp_tokenizer_t *state, char *p) |
Variables | |
static fr_dict_attr_t const * | attr_boot_filename |
static fr_dict_attr_t const * | attr_client_hardware_address |
static fr_dict_attr_t const * | attr_client_identifier |
static fr_dict_attr_t const * | attr_server_identifier |
static fr_dict_attr_t const * | attr_server_ip_address |
static fr_dict_attr_t const * | attr_server_name |
static fr_dict_attr_t const * | attr_your_ip_address |
static const rlm_isc_dhcp_cmd_t | commands [] |
Table of commands that we allow. | |
static fr_dict_t const * | dict_dhcpv4 |
static const conf_parser_t | module_config [] |
module_rlm_t | rlm_isc_dhcp |
fr_dict_autoload_t | rlm_isc_dhcp_dict [] |
fr_dict_attr_autoload_t | rlm_isc_dhcp_dict_attr [] |
static char const * | spaces = " " |
Read ISC DHCP configuration files.
Definition in file rlm_isc_dhcp.c.
struct isc_host_ether_t |
Definition at line 762 of file rlm_isc_dhcp.c.
Data Fields | ||
---|---|---|
uint8_t | ether[6] | |
rlm_isc_dhcp_info_t * | host |
struct isc_host_uid_t |
Definition at line 784 of file rlm_isc_dhcp.c.
Data Fields | ||
---|---|---|
fr_value_box_t * | client | |
rlm_isc_dhcp_info_t * | host |
struct rlm_isc_dhcp_cmd_t |
Describes the commands that we accept, including it's syntax (i.e.
name), etc.
Definition at line 167 of file rlm_isc_dhcp.c.
Data Fields | ||
---|---|---|
rlm_isc_dhcp_apply_t | apply | |
int | max_argc | |
char const * | name | |
rlm_isc_dhcp_parse_t | parse | |
rlm_isc_dhcp_type_t | type |
struct rlm_isc_dhcp_info_s |
Holds information about the thing we parsed.
Note that this parser is forgiving. We would rather accept things ISC DHCP doesn't accept, than reject things it accepts. Since we only implement a tiny portion of it's configuration, we tend to accept all kinds of things, and then just ignore them.
Definition at line 183 of file rlm_isc_dhcp.c.
Data Fields | ||
---|---|---|
int | argc | |
fr_value_box_t ** | argv | |
rlm_isc_dhcp_info_t * | child | |
rlm_isc_dhcp_cmd_t const * | cmd | |
void * | data | per-thing parsed data. |
fr_hash_table_t * | hosts_by_ether | by MAC address |
fr_hash_table_t * | hosts_by_uid | by client identifier |
rlm_isc_dhcp_info_t ** | last | pointer to last child |
rlm_isc_dhcp_info_t * | next | |
fr_pair_list_t | options | DHCP options. |
rlm_isc_dhcp_info_t * | parent | |
fr_trie_t * | subnets |
struct rlm_isc_dhcp_t |
Definition at line 77 of file rlm_isc_dhcp.c.
Data Fields | ||
---|---|---|
bool | debug | |
char const * | filename | |
rlm_isc_dhcp_info_t * | head | |
fr_hash_table_t * | hosts_by_ether | by MAC address |
fr_hash_table_t * | hosts_by_uid | by client identifier |
bool | pedantic |
struct rlm_isc_dhcp_tokenizer_t |
Holds the state of the current tokenizer.
Definition at line 125 of file rlm_isc_dhcp.c.
Data Fields | ||
---|---|---|
bool | allow_eof | do we allow EOF? (i.e. braces == 0) |
int | braces | how many levels deep we are in a { ... } |
char * | buffer | read buffer |
size_t | bufsize | size of read buffer |
bool | debug | internal developer debugging |
bool | eof | are we at EOF? |
char const * | filename | |
FILE * | fp | |
rlm_isc_dhcp_t * | inst | module instance |
char * | line | where the current line started |
int | lineno | |
char * | ptr | pointer into read buffer |
bool | saw_semicolon | whether we saw a semicolon |
char | string[256] | double quoted strings go here, so we don't mangle the input buffer |
char * | token | current token that we parsed |
size_t | token_len | length of the token |
#define DDEBUG | ( | ... | ) |
Definition at line 110 of file rlm_isc_dhcp.c.
Definition at line 105 of file rlm_isc_dhcp.c.
#define isc_ignore ISC_IGNORE, NULL, NULL |
Definition at line 1910 of file rlm_isc_dhcp.c.
#define isc_invalid ISC_INVALID, NULL, NULL |
Definition at line 1911 of file rlm_isc_dhcp.c.
Definition at line 1909 of file rlm_isc_dhcp.c.
#define MAYBE_SEMICOLON (2) |
Definition at line 68 of file rlm_isc_dhcp.c.
Definition at line 1673 of file rlm_isc_dhcp.c.
#define NO_SEMICOLON (0) |
Definition at line 66 of file rlm_isc_dhcp.c.
#define TYPE_CHECK | ( | name, | |
type | |||
) | if ((state->token_len == (sizeof(name) - 1)) && (memcmp(state->token, name, sizeof(name) - 1) == 0)) return type |
Parse one type string.
boolean [signed|unsigned] integer [width] width is 8, 16, or 32 ip-address ip6-address text string domain-list [compressed] encapsulate _identifier_
Definition at line 833 of file rlm_isc_dhcp.c.
#define vb_ipv4addr vb_ip.addr.v4.s_addr |
Definition at line 1522 of file rlm_isc_dhcp.c.
#define YES_SEMICOLON (1) |
Definition at line 67 of file rlm_isc_dhcp.c.
typedef int(* rlm_isc_dhcp_apply_t) (rlm_isc_dhcp_t const *inst, request_t *request, rlm_isc_dhcp_info_t *info) |
Definition at line 150 of file rlm_isc_dhcp.c.
typedef struct rlm_isc_dhcp_info_s rlm_isc_dhcp_info_t |
Definition at line 64 of file rlm_isc_dhcp.c.
typedef int(* rlm_isc_dhcp_parse_t) (rlm_isc_dhcp_tokenizer_t *state, rlm_isc_dhcp_info_t *info) |
Definition at line 149 of file rlm_isc_dhcp.c.
typedef enum rlm_isc_dhcp_type_t rlm_isc_dhcp_type_t |
enum rlm_isc_dhcp_type_t |
Definition at line 152 of file rlm_isc_dhcp.c.
|
static |
Definition at line 1655 of file rlm_isc_dhcp.c.
|
static |
Apply all rules except fixed IP.
Definition at line 1793 of file rlm_isc_dhcp.c.
|
static |
Apply fixed IPs.
Definition at line 1743 of file rlm_isc_dhcp.c.
|
static |
Definition at line 1607 of file rlm_isc_dhcp.c.
|
static |
|
static |
Definition at line 767 of file rlm_isc_dhcp.c.
|
static |
|
static |
Definition at line 789 of file rlm_isc_dhcp.c.
|
static |
|
static |
Definition at line 1151 of file rlm_isc_dhcp.c.
|
static |
Recursively match subwords inside of a command string.
Definition at line 533 of file rlm_isc_dhcp.c.
|
static |
|
static |
|
static |
|
static |
filename STRING
Definition at line 1678 of file rlm_isc_dhcp.c.
|
static |
host NAME { ... }
Hosts are global, and are keyed by MAC `hardware ethernet`, and by `client-identifier`.
Definition at line 1375 of file rlm_isc_dhcp.c.
|
static |
|
static |
next-server IPADDR
Definition at line 1715 of file rlm_isc_dhcp.c.
|
static |
Definition at line 998 of file rlm_isc_dhcp.c.
|
static |
option new-name code new-code = definition ;
"new-name" can also be SPACE.NAME
Definition at line 853 of file rlm_isc_dhcp.c.
|
static |
option space name [ [ code width number ] [ length width number ] [ hash size number ] ] ;
Definition at line 809 of file rlm_isc_dhcp.c.
|
static |
Parse "option" command.
In any sane system, commands which do different things should have different names. In this syntax, it's all miracles and unicorns. option NAME VALUE ; option new-name code new-code = definition ; option space name [ [ code width number ] [ length width number ] [ hash size number ] ] ;
Definition at line 1072 of file rlm_isc_dhcp.c.
|
static |
Parse a section { ... }.
Definition at line 2043 of file rlm_isc_dhcp.c.
|
static |
server-identifier IPADDR
This is really "option dhcp-server-identifier IPADDR" But whatever
Definition at line 1707 of file rlm_isc_dhcp.c.
|
static |
server-name STRING
Definition at line 1691 of file rlm_isc_dhcp.c.
|
static |
subnet IPADDR netmask MASK { ... }
Definition at line 1527 of file rlm_isc_dhcp.c.
|
static |
Open a file and read it into a parent.
Definition at line 2104 of file rlm_isc_dhcp.c.
|
static |
Definition at line 297 of file rlm_isc_dhcp.c.
|
static |
Reads one token into state->token.
Note that this function *destroys* the input buffer. So if you need to read two tokens, you have to save the first one somewhere *outside* of the input buffer.
Definition at line 343 of file rlm_isc_dhcp.c.
|
static |
Refills the read buffer with one line from the file.
This function also takes care of suppressing blank lines, and lines which only contain comments.
Definition at line 213 of file rlm_isc_dhcp.c.
|
static |
Definition at line 258 of file rlm_isc_dhcp.c.
|
static |
Definition at line 47 of file rlm_isc_dhcp.c.
|
static |
Definition at line 43 of file rlm_isc_dhcp.c.
|
static |
Definition at line 45 of file rlm_isc_dhcp.c.
|
static |
Definition at line 49 of file rlm_isc_dhcp.c.
|
static |
Definition at line 48 of file rlm_isc_dhcp.c.
|
static |
Definition at line 46 of file rlm_isc_dhcp.c.
|
static |
Definition at line 44 of file rlm_isc_dhcp.c.
|
static |
Table of commands that we allow.
Definition at line 1917 of file rlm_isc_dhcp.c.
|
static |
Definition at line 35 of file rlm_isc_dhcp.c.
|
static |
Definition at line 98 of file rlm_isc_dhcp.c.
module_rlm_t rlm_isc_dhcp |
Definition at line 2236 of file rlm_isc_dhcp.c.
fr_dict_autoload_t rlm_isc_dhcp_dict |
Definition at line 38 of file rlm_isc_dhcp.c.
fr_dict_attr_autoload_t rlm_isc_dhcp_dict_attr |
Definition at line 52 of file rlm_isc_dhcp.c.
|
static |
Definition at line 206 of file rlm_isc_dhcp.c.