![]() |
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 dependency graph for rlm_isc_dhcp.c: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 | 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 (unlang_result_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 (unlang_result_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 761 of file rlm_isc_dhcp.c.
Collaboration diagram for isc_host_ether_t:| Data Fields | ||
|---|---|---|
| uint8_t | ether[6] | |
| rlm_isc_dhcp_info_t * | host | |
| struct isc_host_uid_t |
Definition at line 783 of file rlm_isc_dhcp.c.
Collaboration diagram for isc_host_uid_t:| 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 166 of file rlm_isc_dhcp.c.
Collaboration diagram for rlm_isc_dhcp_cmd_t:| 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 182 of file rlm_isc_dhcp.c.
Collaboration diagram for rlm_isc_dhcp_info_s:| 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 76 of file rlm_isc_dhcp.c.
Collaboration diagram for rlm_isc_dhcp_t:| 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 124 of file rlm_isc_dhcp.c.
Collaboration diagram for rlm_isc_dhcp_tokenizer_t:| 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 109 of file rlm_isc_dhcp.c.
Definition at line 104 of file rlm_isc_dhcp.c.
| #define isc_ignore ISC_IGNORE, NULL, NULL |
Definition at line 1904 of file rlm_isc_dhcp.c.
| #define isc_invalid ISC_INVALID, NULL, NULL |
Definition at line 1905 of file rlm_isc_dhcp.c.
Definition at line 1903 of file rlm_isc_dhcp.c.
| #define MAYBE_SEMICOLON (2) |
Definition at line 67 of file rlm_isc_dhcp.c.
Definition at line 1667 of file rlm_isc_dhcp.c.
| #define NO_SEMICOLON (0) |
Definition at line 65 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 832 of file rlm_isc_dhcp.c.
| #define YES_SEMICOLON (1) |
Definition at line 66 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 149 of file rlm_isc_dhcp.c.
| typedef struct rlm_isc_dhcp_info_s rlm_isc_dhcp_info_t |
Definition at line 63 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 148 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 151 of file rlm_isc_dhcp.c.
|
static |
Definition at line 1647 of file rlm_isc_dhcp.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Apply all rules except fixed IP.
Definition at line 1787 of file rlm_isc_dhcp.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Apply fixed IPs.
Definition at line 1737 of file rlm_isc_dhcp.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Definition at line 1598 of file rlm_isc_dhcp.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
|
static |
Definition at line 766 of file rlm_isc_dhcp.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
|
static |
Definition at line 788 of file rlm_isc_dhcp.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
|
static |
Definition at line 1150 of file rlm_isc_dhcp.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Recursively match subwords inside of a command string.
Definition at line 532 of file rlm_isc_dhcp.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
|
static |
|
static |
|
static |
filename STRING
Definition at line 1672 of file rlm_isc_dhcp.c.
Here is the call graph for this function:
|
static |
host NAME { ... }
Hosts are global, and are keyed by MAC `hardware ethernet`, and by `client-identifier`.
Definition at line 1374 of file rlm_isc_dhcp.c.
Here is the call graph for this function:
|
static |
|
static |
next-server IPADDR
Definition at line 1709 of file rlm_isc_dhcp.c.
Here is the call graph for this function:
|
static |
Definition at line 997 of file rlm_isc_dhcp.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
option new-name code new-code = definition ;
"new-name" can also be SPACE.NAME
Definition at line 852 of file rlm_isc_dhcp.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
option space name [ [ code width number ] [ length width number ] [ hash size number ] ] ;
Definition at line 808 of file rlm_isc_dhcp.c.
Here is the caller graph for this function:
|
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 1071 of file rlm_isc_dhcp.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Parse a section { ... }.
Definition at line 2037 of file rlm_isc_dhcp.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
server-identifier IPADDR
This is really "option dhcp-server-identifier IPADDR" But whatever
Definition at line 1701 of file rlm_isc_dhcp.c.
Here is the call graph for this function:
|
static |
server-name STRING
Definition at line 1685 of file rlm_isc_dhcp.c.
Here is the call graph for this function:
|
static |
subnet IPADDR netmask MASK { ... }
Definition at line 1518 of file rlm_isc_dhcp.c.
Here is the call graph for this function:
|
static |
Open a file and read it into a parent.
Definition at line 2098 of file rlm_isc_dhcp.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Definition at line 296 of file rlm_isc_dhcp.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
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 342 of file rlm_isc_dhcp.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
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 212 of file rlm_isc_dhcp.c.
Here is the caller graph for this function:
|
static |
Definition at line 257 of file rlm_isc_dhcp.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Definition at line 46 of file rlm_isc_dhcp.c.
|
static |
Definition at line 42 of file rlm_isc_dhcp.c.
|
static |
Definition at line 44 of file rlm_isc_dhcp.c.
|
static |
Definition at line 48 of file rlm_isc_dhcp.c.
|
static |
Definition at line 47 of file rlm_isc_dhcp.c.
|
static |
Definition at line 45 of file rlm_isc_dhcp.c.
|
static |
Definition at line 43 of file rlm_isc_dhcp.c.
|
static |
Table of commands that we allow.
Definition at line 1911 of file rlm_isc_dhcp.c.
|
static |
Definition at line 34 of file rlm_isc_dhcp.c.
|
static |
Definition at line 97 of file rlm_isc_dhcp.c.
| module_rlm_t rlm_isc_dhcp |
Definition at line 2230 of file rlm_isc_dhcp.c.
| fr_dict_autoload_t rlm_isc_dhcp_dict |
Definition at line 37 of file rlm_isc_dhcp.c.
| fr_dict_attr_autoload_t rlm_isc_dhcp_dict_attr |
Definition at line 51 of file rlm_isc_dhcp.c.
|
static |
Definition at line 205 of file rlm_isc_dhcp.c.
1.9.8