34#define NUM_DEFAULT_REQUESTED_OPTS 15
38static void parse_client_default_duid(
struct parse *cfile);
39static void parse_client6_lease_statement(
struct parse *cfile);
41static struct dhc6_ia *parse_client6_ia_na_statement(
struct parse *cfile);
42static struct dhc6_ia *parse_client6_ia_ta_statement(
struct parse *cfile);
43static struct dhc6_ia *parse_client6_ia_pd_statement(
struct parse *cfile);
44static struct dhc6_addr *parse_client6_iaaddr_statement(
struct parse *cfile);
45static struct dhc6_addr *parse_client6_iaprefix_statement(
struct parse *cfile);
48static void parse_lease_id_format (
struct parse *cfile);
158 log_fatal(
"Unable to find option definition for "
159 "index %u during default parameter request "
172 log_fatal(
"Unable to find option definition for "
173 "index %u during default parameter request "
184 log_fatal(
"Unable to find option definition for "
185 "index %u during default parameter request "
193 log_fatal(
"Unable to find option definition for "
194 "index %u during default parameter request "
233 log_fatal (
"no memory for top-level on_receipt group");
237 log_fatal (
"no memory for top-level on_transmission group");
248 sizeof(default_client_config) - 1,
249 "default client configuration", 0);
251 log_fatal (
"can't begin default client config!");
273 log_fatal (
"no memory for client state.");
274 memset (
ip -> client, 0,
sizeof *(
ip -> client));
275 ip -> client ->
interface =
ip;
278 if (!
ip -> client -> config) {
284 log_fatal (
"no memory for client config.");
288 ip -> client -> config = config;
303 if ((
file = open (name, O_RDONLY | O_CLOEXEC)) < 0)
358 parse_client_default_duid(cfile);
394 parse_client_default_duid(cfile);
402 parse_client6_lease_statement(cfile);
406 log_error (
"Corrupt lease file - possible data loss!");
453 struct option ***append_list, **new_list, **cat_list;
455 switch (
peek_token (&val, (
unsigned *)0, cfile)) {
458 token =
next_token (&val, (
unsigned *)0, cfile);
460 parse_warn (cfile,
"filename string expected.");
485 parse_warn (cfile,
"key definition not allowed here.");
504 parse_warn(cfile,
"expected REQUEST or REQUIRE list");
510 if (*append_list == NULL) {
516 for (i = 0 ; (*append_list)[i] != NULL ; i++)
527 if (tmp == 0 || new_list == NULL)
534 if (cat_list == NULL) {
535 log_error(
"Unable to allocate memory for new "
541 for (i = 0 ; (*append_list)[i] != NULL ; i++)
546 for (i = 0 ; new_list[i] != 0 ; i++)
555 *append_list = cat_list;
563 token =
peek_token (&val, (
unsigned *)0, cfile);
592 token =
next_token (&val, (
unsigned *)0, cfile);
598 "invalid authentication policy.");
602 config -> auth_policy =
policy;
611 config -> bootp_policy =
policy;
613 parse_warn (cfile,
"expecting a policy type.");
621 token =
peek_token (&val, (
unsigned *)0, cfile);
622 if (token ==
SPACE) {
625 "option space definitions %s",
626 " may not be scoped.");
639 token =
next_token (&val, (
unsigned *)0, cfile);
641 parse_warn (cfile,
"expecting \"code\" keyword.");
648 "option definitions may only appear in %s",
649 "the outermost scope.");
680 parse_warn (cfile,
"hardware address parameter %s",
681 "not allowed here.");
691 parse_warn(cfile,
"anycast mac address parameter "
692 "not allowed here.");
700 config -> requested_options = NULL;
721 token =
next_token (&val, (
unsigned *)0, cfile);
724 "unexpected omapi subtype: %s", val);
728 token =
next_token (&val, (
unsigned *)0, cfile);
730 parse_warn (cfile,
"invalid port number: `%s'", val);
735 if (tmp < 0 || tmp > 65535)
736 parse_warn (cfile,
"invalid omapi port %d.", tmp);
739 "omapi port only works at top level.");
747 token =
next_token (&val, (
unsigned *)0, cfile);
748 if (!strcasecmp (val,
"on") ||
749 !strcasecmp (val,
"true"))
750 config -> do_forward_update = 1;
751 else if (!strcasecmp (val,
"off") ||
752 !strcasecmp (val,
"false"))
753 config -> do_forward_update = 0;
755 parse_warn (cfile,
"expecting boolean value.");
784 parse_string (cfile, &config -> script_name, (
unsigned *)0);
789 token =
next_token (&val, (
unsigned *)0, cfile);
791 parse_warn (cfile,
"expecting 'vendor option space'");
795 token =
next_token (&val, (
unsigned *)0, cfile);
796 if (token !=
SPACE) {
797 parse_warn (cfile,
"expecting 'vendor option space'");
801 token =
next_token (&val, (
unsigned *)0, cfile);
803 parse_warn (cfile,
"expecting an identifier.");
807 config -> vendor_space_name =
dmalloc (strlen (val) + 1,
MDL);
808 if (!config -> vendor_space_name)
809 log_fatal (
"no memory for vendor option space name.");
810 strcpy (config -> vendor_space_name, val);
813 config -> vendor_space_name))
816 log_error (
"vendor option space %s not found.",
817 config -> vendor_space_name);
825 parse_warn (cfile,
"nested interface declaration.");
831 token =
next_token (&val, (
unsigned *)0, cfile);
834 log_fatal (
"no memory for pseudo interface name");
856 parse_lease_id_format(cfile);
860 token =
next_token(&val, (
unsigned*)0, cfile);
881 eptr = &config -> on_transmission ->
statements;
899 for (; *eptr; eptr = &(*eptr) ->
next)
926 token =
peek_token (&val, (
unsigned *)0, cfile);
928 token =
next_token (&val, (
unsigned *)0, cfile);
932 parse_warn (cfile,
"%s: expected option name.", val);
939 parse_warn (cfile,
"%s: expected option name.", val);
944 log_fatal (
"can't allocate pair for option code.");
955 token =
next_token (&val, (
unsigned *)0, cfile);
956 }
while (token ==
COMMA);
968 log_error (
"no memory for option list.");
971 for (q = p; q; q = q -> cdr)
999 token =
next_token (&val, (
unsigned *)0, cfile);
1001 parse_warn (cfile,
"expecting interface name (in quotes).");
1007 log_fatal (
"Can't allocate interface %s.", val);
1014 for (cp = &
ip -> client; *cp; cp = &((*cp) -> next))
1018 if (!
ip -> client) {
1020 ip -> client ->
interface =
ip;
1022 client =
ip -> client;
1025 if (!client -> config)
1031 token =
next_token (&val, (
unsigned *)0, cfile);
1039 token =
peek_token (&val, (
unsigned *)0, cfile);
1042 "unterminated interface declaration.");
1056 isc_result_t status;
1061 interface_reference (&
ip, i,
MDL);
1070 interface_reference (&
ip, i,
MDL);
1080 log_fatal (
"Can't record interface %s: %s",
1081 name, isc_result_totext (status));
1083 if (strlen(
name) >=
sizeof(
ip->name)) {
1084 interface_dereference(&
ip,
MDL);
1090 interface_reference (&
ip ->
next,
1097 status = interface_reference (pi,
ip,
MDL);
1099 status = ISC_R_FAILURE;
1100 interface_dereference (&
ip,
MDL);
1111 log_fatal (
"no memory for client state\n");
1121 if (!client -> config)
1122 log_fatal (
"no memory for client config\n");
1123 memcpy (client -> config, config,
sizeof *config);
1128 log_fatal (
"no memory for client state groups.");
1141 struct parse *cfile;
1150 token =
next_token (&val, (
unsigned *)0, cfile);
1164 log_fatal (
"no memory for lease options.\n");
1167 token =
peek_token (&val, (
unsigned *)0, cfile);
1169 parse_warn (cfile,
"unterminated lease declaration.");
1186 if (!
ip -> client) {
1188 ip -> client ->
interface =
ip;
1191 client =
ip -> client;
1194 if (is_static == 2) {
1195 ip -> client -> alias =
lease;
1211 lease -> next = client -> leases;
1212 client -> leases =
lease;
1227 if (client -> active) {
1228 if (client -> active -> expiry <
cur_time)
1230 else if (client -> active -> address.len ==
1231 lease -> address.len &&
1232 !memcmp (client -> active -> address.iabuf,
1233 lease -> address.iabuf,
1234 lease -> address.len))
1237 client -> active -> next = client -> leases;
1238 client -> leases = client -> active;
1241 client -> active =
lease;
1259 struct parse *cfile;
1270 switch (
next_token (&val, (
unsigned *)0, cfile)) {
1272 token =
next_token (&val, (
unsigned *)0, cfile);
1284 lease -> is_bootp = 1;
1288 token =
next_token (&val, (
unsigned *)0, cfile);
1291 "expecting interface name (in quotes).");
1296 log_fatal (
"Can't allocate interface %s.", val);
1300 token =
next_token (&val, (
unsigned *)0, cfile);
1303 parse_warn (cfile,
"state name precedes interface.");
1306 for (client =
ip -> client; client; client = client ->
next)
1307 if (client ->
name && !strcmp (client ->
name, val))
1311 "lease specified for unknown pseudo.");
1353 parse_warn (cfile,
"expecting lease declaration.");
1357 token =
next_token (&val, (
unsigned *)0, cfile);
1358 if (token !=
SEMI) {
1367parse_client_default_duid(
struct parse *cfile)
1380 memset(&new_duid, 0,
sizeof(new_duid));
1382 parse_warn(cfile,
"Out of memory parsing default DUID.");
1386 new_duid.data = new_duid.buffer->data;
1389 memcpy(new_duid.buffer->data, buf,
len);
1407parse_client6_lease_statement(
struct parse *cfile)
1421 int token, has_ia, no_semi, has_name;
1425 parse_warn(cfile,
"Expecting open curly brace.");
1431 if (
lease == NULL) {
1432 parse_warn(cfile,
"Unable to allocate lease state.");
1438 if (
lease->options == NULL) {
1439 parse_warn(cfile,
"Unable to allocate option cache.");
1447 ia = &
lease->bindings;
1449 while (token !=
RBRACE) {
1454 *ia = parse_client6_ia_na_statement(cfile);
1465 *ia = parse_client6_ia_ta_statement(cfile);
1476 *ia = parse_client6_ia_pd_statement(cfile);
1487 if (iface != NULL) {
1488 parse_warn(cfile,
"Multiple interface names?");
1504 iface = iface->
next) {
1505 if (strcmp(iface->
name, val) == 0)
1509 if (iface == NULL) {
1519 if (client != NULL) {
1526 if (iface == NULL) {
1538 for (client = iface->
client ; client != NULL ;
1539 client = client->
next) {
1540 if ((client->
name != NULL) &&
1541 (strcmp(client->
name, val) == 0))
1545 if (client == NULL) {
1546 parse_warn(cfile,
"Unknown client state %s.",
1556 lease->options, oc);
1568 parse_warn(cfile,
"Unexpected token, %s.", val);
1580 parse_warn(cfile,
"Unexpected end of file.");
1586 log_debug(
"Lease with no IA's discarded from lease db.");
1592 parse_warn(cfile,
"Lease has no interface designation.");
1593 else if (!has_name && (client == NULL)) {
1594 for (client = iface->
client ; client != NULL ;
1595 client = client->
next) {
1596 if (client->
name == NULL)
1601 if (client == NULL) {
1602 parse_warn(cfile,
"No matching client state.");
1608 memset(&ds, 0,
sizeof(ds));
1614 log_error(
"Invalid length of DHCPv6 Preference option "
1615 "(%d != 1)", ds.len);
1620 lease->pref = ds.data[0];
1631 (
lease->server_id.len == 0)) {
1633 log_error(
"Invalid SERVERID option cache.");
1649parse_client6_ia_na_statement(
struct parse *cfile)
1655 int token, no_semi, len;
1660 parse_warn(cfile,
"Out of memory allocating IA_NA state.");
1669 memcpy(ia->
iaid, buf, 4);
1671 parse_warn(cfile,
"Expecting IAID of length 4, got %d.", len);
1679 parse_warn(cfile,
"Expecting open curly brace.");
1687 parse_warn(cfile,
"Unable to allocate option state.");
1695 while (token !=
RBRACE) {
1713 ia->
renew = atoi(val);
1733 *addr = parse_client6_iaaddr_statement(cfile);
1736 addr = &(*addr)->
next;
1764 parse_warn(cfile,
"Unexpected end of file.");
1777parse_client6_ia_ta_statement(
struct parse *cfile)
1783 int token, no_semi, len;
1788 parse_warn(cfile,
"Out of memory allocating IA_TA state.");
1797 memcpy(ia->
iaid, buf, 4);
1799 parse_warn(cfile,
"Expecting IAID of length 4, got %d.", len);
1807 parse_warn(cfile,
"Expecting open curly brace.");
1815 parse_warn(cfile,
"Unable to allocate option state.");
1823 while (token !=
RBRACE) {
1841 *addr = parse_client6_iaaddr_statement(cfile);
1844 addr = &(*addr)->
next;
1872 parse_warn(cfile,
"Unexpected end of file.");
1885parse_client6_ia_pd_statement(
struct parse *cfile)
1891 int token, no_semi, len;
1896 parse_warn(cfile,
"Out of memory allocating IA_PD state.");
1905 memcpy(ia->
iaid, buf, 4);
1907 parse_warn(cfile,
"Expecting IAID of length 4, got %d.", len);
1915 parse_warn(cfile,
"Expecting open curly brace.");
1923 parse_warn(cfile,
"Unable to allocate option state.");
1931 while (token !=
RBRACE) {
1949 ia->
renew = atoi(val);
1969 *pref = parse_client6_iaprefix_statement(cfile);
1972 pref = &(*pref)->
next;
2000 parse_warn(cfile,
"Unexpected end of file.");
2012parse_client6_iaaddr_statement(
struct parse *cfile)
2021 parse_warn(cfile,
"Unable to allocate IAADDR state.");
2035 parse_warn(cfile,
"Expecting open curly bracket.");
2043 parse_warn(cfile,
"Unable to allocate option state.");
2050 while (token !=
RBRACE) {
2057 addr->
starts = atoi(val);
2108 parse_warn(cfile,
"Unexpected end of file.");
2120parse_client6_iaprefix_statement(
struct parse *cfile)
2129 parse_warn(cfile,
"Unable to allocate IAPREFIX state.");
2143 parse_warn(cfile,
"Expecting open curly bracket.");
2151 parse_warn(cfile,
"Unable to allocate option state.");
2158 while (token !=
RBRACE) {
2165 pref->
starts = atoi(val);
2216 parse_warn(cfile,
"Unexpected end of file.");
2226 struct parse *cfile;
2236 for (cur = *lp; cur ->
next; cur = cur ->
next)
2243 token =
next_token (&val, (
unsigned *)0, cfile);
2245 parse_warn (cfile,
"Expecting media options.");
2254 log_fatal (
"no memory for string list entry.");
2256 strcpy (tmp ->
string, val);
2266 token =
next_token (&val, (
unsigned *)0, cfile);
2267 }
while (multiple && token ==
COMMA);
2269 if (token !=
SEMI) {
2276 struct parse *cfile;
2311 parse_warn(cfile,
"zero-length prefix is not permitted "
2312 "for reject statement");
2319 log_fatal (
"no memory for reject list!");
2325 token =
next_token (&val, (
unsigned *)0, cfile);
2326 }
while (token ==
COMMA);
2328 if (token !=
SEMI) {
2341 struct parse *cfile;
2344 parse_warn (cfile,
"allow/deny/ignore not permitted here.");
2365void parse_lease_id_format (
struct parse *cfile)
2379 parse_warn(cfile,
"lease-id-format is invalid: "
2380 " it must be octal or hex.");
2387 ?
"octal" :
"hex"));
struct option * default_requested_options[NUM_DEFAULT_REQUESTED_OPTS+2+1]
void read_client_leases()
void parse_interface_declaration(struct parse *cfile, struct client_config *outer_config, char *name)
isc_result_t read_client_conf()
void make_client_config(struct client_state *client, struct client_config *config)
int parse_allow_deny(struct option_cache **oc, struct parse *cfile, int flag)
void make_client_state(struct client_state **state)
void parse_client_statement(struct parse *cfile, struct interface_info *ip, struct client_config *config)
void discard_duplicate(struct client_lease **lease_list, struct client_lease *lease)
void parse_client_lease_statement(struct parse *cfile, int is_static)
#define NUM_DEFAULT_REQUESTED_OPTS
int parse_option_list(struct parse *cfile, struct option ***list)
void parse_string_list(struct parse *cfile, struct string_list **lp, int multiple)
struct client_config top_level_config
int read_client_conf_file(const char *name, struct interface_info *ip, struct client_config *client)
void parse_reject_statement(struct parse *cfile, struct client_config *config)
int interface_or_dummy(struct interface_info **pi, const char *name)
void parse_client_lease_declaration(struct parse *cfile, struct client_lease *lease, struct interface_info **ipp, struct client_state **clientp)
int buffer_allocate(struct buffer **ptr, unsigned len, const char *file, int line)
int group_allocate(struct group **ptr, const char *file, int line)
void free_pair(pair foo, const char *file, int line)
void data_string_forget(struct data_string *data, const char *file, int line)
int option_state_allocate(struct option_state **ptr, const char *file, int line)
int executable_statement_reference(struct executable_statement **ptr, struct executable_statement *bp, const char *file, int line)
void data_string_copy(struct data_string *dest, const struct data_string *src, const char *file, int line)
pair new_pair(char *file, int line) const
enum dhcp_token peek_token(const char **rval, unsigned *rlen, struct parse *cfile)
enum dhcp_token next_token(const char **rval, unsigned *rlen, struct parse *cfile)
isc_result_t end_parse(struct parse **cfile)
isc_result_t new_parse(struct parse **cfile, int file, char *inbuf, unsigned buflen, const char *name, int eolp)
void save_option(struct universe *universe, struct option_state *options, struct option_cache *oc)
int option_cache_dereference(struct option_cache **ptr, const char *file, int line)
struct option_cache * lookup_option(struct universe *universe, struct option_state *options, unsigned code)
int parse_string(struct parse *cfile, char **sptr, unsigned *lptr)
void skip_to_semi(struct parse *cfile)
int parse_X(struct parse *cfile, u_int8_t *buf, unsigned max)
int parse_semi(struct parse *cfile)
int parse_key(struct parse *cfile)
int parse_option_code_definition(struct parse *cfile, struct option *option)
int parse_ip6_prefix(struct parse *cfile, struct iaddr *addr, u_int8_t *plen)
int parse_ip6_addr(struct parse *cfile, struct iaddr *addr)
int parse_option_decl(struct option_cache **oc, struct parse *cfile)
TIME parse_date(struct parse *cfile)
void skip_to_rbrace(struct parse *cfile, int brace_count)
int parse_warn(struct parse *cfile, const char *fmt,...)
int parse_ip_addr_with_subnet(struct parse *cfile, struct iaddrmatch *match)
void parse_hardware_param(struct parse *cfile, struct hardware *hardware)
void parse_option_space_decl(struct parse *cfile)
int parse_ip_addr(struct parse *cfile, struct iaddr *addr)
int parse_executable_statement(struct executable_statement **result, struct parse *cfile, int *lose, enum expression_context case_context)
isc_result_t parse_option_name(struct parse *cfile, int allocate, int *known, struct option **opt)
void parse_lease_time(struct parse *cfile, TIME *timep)
int bootp_broadcast_always
const char * path_dhclient_duid
const char * path_dhclient_db
void destroy_client_lease(struct client_lease *lease)
const char * path_dhclient_conf
struct data_string default_duid
char * path_dhclient_script
#define D6O_INFORMATION_REFRESH_TIME
#define D6O_DHCP4_O_DHCP6_SERVER
#define D6O_DOMAIN_SEARCH
#define DHO_BROADCAST_ADDRESS
#define DHO_DOMAIN_SEARCH
#define DHO_INTERFACE_MTU
#define DHO_CLASSLESS_STATIC_ROUTES
#define DHO_DOMAIN_NAME_SERVERS
#define skip_token(a, b, c)
void dhc6_lease_destroy(struct dhc6_lease **src, const char *file, int line)
struct universe dhcp_universe
#define INTERFACE_AUTOMATIC
struct interface_info * interfaces
struct interface_info * dummy_interfaces
int executable_statement_dereference(struct executable_statement **ptr, const char *file, int line)
int clone_group(struct group **gp, struct group *group, const char *file, int line)
isc_result_t omapi_auth_key_lookup_name(omapi_auth_key_t **, const char *)
void * dmalloc(size_t, const char *, int)
void dfree(void *, const char *, int)
isc_result_t uerr2isc(int)
int log_error(const char *,...) __attribute__((__format__(__printf__
int int int log_debug(const char *,...) __attribute__((__format__(__printf__
void log_fatal(const char *,...) __attribute__((__format__(__printf__
struct option ** required_options
struct group * on_transmission
struct iaddrmatchlist * reject_list
struct option ** requested_options
struct group * on_receipt
struct option_state * options
struct dhc6_lease * active_lease
struct client_config * config
struct client_lease * leases
struct client_state * next
struct string_list * medium
struct option_state * options
struct option_state * options
enum executable_statement::statement_op op
union executable_statement::@336221350347175166011011356261373334214214051201 data
struct executable_statement * next
struct executable_statement * statements
struct executable_statement::@336221350347175166011011356261373334214214051201::@240325212232200272321314266066265221125200273242 on
struct iaddrmatchlist * next
struct interface_info * next
struct client_state * client
enum option_status status
struct universe * universe
struct string_list * next
option_name_hash_t * name_hash
option_code_hash_t * code_hash
int option_reference(struct option **dest, struct option *src, const char *file, int line)
int option_dereference(struct option **dest, const char *file, int line)
struct universe dhcpv6_universe
struct universe ** universes
int evaluate_option_cache(struct data_string *result, struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *cfg_options, struct binding_scope **scope, struct option_cache *oc, const char *file, int line)
struct binding_scope * global_scope