33 static unsigned char global_host_once = 1;
35 static int parse_binding_value(
struct parse *cfile,
38 static void parse_authoring_byte_order (
struct parse *cfile);
39 static void parse_lease_id_format (
struct parse *cfile);
41 static int parse_iaid_duid(
struct parse *cfile,
struct ia_xx** ia,
42 u_int32_t *iaid,
const char*
file,
int line);
69 #if defined(LDAP_CONFIGURATION) 70 if (res != ISC_R_SUCCESS)
73 return ldap_read_config ();
80 int group_type,
int leasep)
93 ttype = trace_readleases_type;
95 ttype = trace_readconf_type;
104 if (status != ISC_R_SUCCESS)
114 tflen = strlen (dbuf);
115 ulen = ulen - tflen - 1;
116 fbuf = dbuf + tflen + 1;
121 if ((file = open (filename, O_RDONLY | O_CLOEXEC)) < 0) {
123 log_error (
"Can't open lease database %s: %m --",
125 log_error (
" check for failed database %s!",
127 log_error (
"Please read the dhcpd.leases manual%s",
129 log_fatal (
"don't know what to do about this.");
131 log_fatal (
"Can't open %s: %m", filename);
135 cfile = (
struct parse *)0;
136 #if defined (TRACING) 137 flen = lseek (file, (off_t)0, SEEK_END);
140 log_fatal (
"Can't lseek on %s: %m", filename);
142 if (lseek (file, (off_t)0, SEEK_SET) < 0)
145 if (flen > 0x7FFFFFFFUL)
146 log_fatal (
"%s: file is too long to buffer.", filename);
151 tflen = strlen (filename);
154 log_fatal (
"No memory for %s (%d bytes)",
158 strcpy (dbuf, filename);
161 fbuf = dbuf + tflen + 1;
162 result = read (file, fbuf, ulen);
164 log_fatal (
"Can't read in %s: %m", filename);
166 log_fatal (
"%s: short read of %d bytes instead of %d.",
167 filename, ulen, result);
173 status =
new_parse(&cfile, -1, fbuf, ulen, filename, 0);
175 status =
new_parse(&cfile, file, NULL, 0, filename, 0);
177 if (status != ISC_R_SUCCESS || cfile == NULL)
185 #if defined (TRACING) 191 #if defined (TRACING) 198 static int postconf_initialized;
199 static int leaseconf_initialized;
204 tflen = strlen (data);
205 flen = len - tflen - 1;
206 fbuf = data + tflen + 1;
212 status =
new_parse(&cfile, -1, fbuf, flen, data, 0);
213 if (status == ISC_R_SUCCESS || cfile != NULL) {
214 if (ttype == trace_readleases_type)
223 if (!postconf_initialized && ttype == trace_readconf_type) {
225 postconf_initialized = 1;
228 if (!leaseconf_initialized && ttype == trace_readleases_type) {
230 leaseconf_initialized = 1;
251 token =
peek_token (&val, (
unsigned *)0, cfile);
276 token =
next_token (&val, (
unsigned *)0, cfile);
279 if (token ==
LEASE) {
283 lease_dereference (&lease,
MDL);
286 "possibly corrupt lease file");
287 }
else if (token ==
IA_NA) {
289 }
else if (token ==
IA_TA) {
291 }
else if (token ==
IA_PD) {
293 }
else if (token ==
CLASS) {
299 }
else if (token ==
HOST) {
301 }
else if (token ==
GROUP) {
303 #if defined (FAILOVER_PROTOCOL) 306 (cfile, (dhcp_failover_state_t *)0);
313 parse_authoring_byte_order(cfile);
315 log_error (
"Corrupt lease file - possible data loss!");
376 token =
peek_token (&val, (
unsigned *)0, cfile);
381 token =
next_token (&val, (
unsigned *)0, cfile);
383 parse_warn (cfile,
"filename string expected.");
387 if (status != ISC_R_SUCCESS)
396 if (global_host_once &&
398 global_host_once = 0;
399 log_error(
"WARNING: Host declarations are " 400 "global. They are not limited to " 401 "the scope you declared them in.");
407 "host declarations not allowed here.");
418 "group declarations not allowed here.");
429 parse_warn (cfile,
"shared-network parameters not %s.",
444 "subnet declarations not allowed here.");
470 status = shared_network_allocate (&share,
MDL);
471 if (status != ISC_R_SUCCESS)
472 log_fatal (
"Can't allocate shared subnet: %s",
473 isc_result_totext (status));
475 log_fatal (
"Can't allocate group for shared net");
506 share->
name = strdup(n);
508 if (share->
name == NULL)
509 log_fatal(
"Out of memory allocating default " 510 "shared network name (\"%s\").", n);
518 shared_network_dereference(&share,
MDL);
525 "class declarations not allowed here.");
536 "class declarations not allowed here.");
547 "class declarations not allowed here.");
558 "class declarations not allowed here.");
568 memset (&hardware, 0,
sizeof hardware);
569 if (host_decl && memcmp(&hardware, &(host_decl->
interface),
570 sizeof(hardware)) != 0) {
571 parse_warn(cfile,
"Host %s hardware address already " 572 "configured.", host_decl->
name);
578 host_decl ->
interface = hardware;
580 parse_warn (cfile,
"hardware address parameter %s",
581 "not allowed here.");
593 "Only one fixed address " 594 "declaration per host.");
600 "fixed-address parameter not " 610 parse_warn (cfile,
"pool declared within pool.");
613 parse_warn (cfile,
"pool declared outside of network");
624 "range declaration not allowed here.");
637 "range6 declaration not allowed here.");
648 "prefix6 declaration not allowed here.");
659 "fixed-prefix6 declaration not " 670 parse_warn (cfile,
"pool6 declared within pool.");
673 parse_warn (cfile,
"pool6 declared outside of network");
684 token =
next_token (&val, (
unsigned *)0, cfile);
687 group -> authoritative = 0;
697 group -> authoritative = 1;
700 parse_warn (cfile,
"authority makes no sense here.");
710 log_fatal(
"Server identifier not in hash (%s:%d).",
717 token =
peek_token (&val, (
unsigned *)0, cfile);
718 if (token ==
SPACE) {
721 "option space definitions %s",
722 "may not be scoped.");
732 if (status == ISC_R_SUCCESS) {
733 token =
peek_token (&val, (
unsigned *)0, cfile);
737 "option definitions%s",
738 " may not be scoped.");
750 option_name_hash_delete(
753 option_code_hash_delete(
777 (&et, cfile, 1, option,
781 goto insert_statement;
789 parse_warn (cfile,
"failover peers may only be %s",
790 "defined in shared-network");
791 log_error (
"declarations and the outer scope.");
795 token =
next_token (&val, (
unsigned *)0, cfile);
796 #if defined (FAILOVER_PROTOCOL) 811 token =
next_token (&val, (
unsigned *)0, cfile);
812 parse_lease_id_format(cfile);
823 "expecting a declaration");
826 "expecting a parameter %s",
879 #if defined (FAILOVER_PROTOCOL) 887 dhcp_failover_state_t *peer;
892 unsigned hba_len =
sizeof hba;
896 dhcp_failover_config_t *cp;
898 token =
next_token (&val, (
unsigned *)0, cfile);
905 token =
next_token (&val, (
unsigned *)0, cfile);
909 log_fatal (
"no memory for peer name %s", name);
912 parse_warn (cfile,
"expecting failover peer name.");
918 peer = (dhcp_failover_state_t *)0;
921 token =
next_token (&val, (
unsigned *)0, cfile);
924 parse_warn (cfile,
"failover peer reference not %s",
925 "in shared-network declaration");
928 parse_warn (cfile,
"reference to unknown%s%s",
929 " failover peer ", name);
933 dhcp_failover_state_reference
937 dhcp_failover_state_dereference (&peer,
MDL);
940 }
else if (token ==
STATE) {
942 parse_warn (cfile,
"state declaration for unknown%s%s",
943 " failover peer ", name);
948 dhcp_failover_state_dereference (&peer,
MDL);
951 }
else if (token !=
LBRACE) {
958 parse_warn (cfile,
"redeclaration of failover peer %s", name);
960 dhcp_failover_state_dereference (&peer,
MDL);
965 status = dhcp_failover_state_allocate (&peer,
MDL);
966 if (status != ISC_R_SUCCESS)
967 log_fatal (
"Can't allocate failover peer %s: %s",
968 name, isc_result_totext (status));
976 token =
next_token (&val, (
unsigned *)0, cfile);
982 peer -> i_am = primary;
986 peer -> i_am = secondary;
989 "secondary may not define %s",
990 "load balance settings.");
994 cp = &peer -> partner;
1001 dhcp_failover_state_dereference (&peer,
MDL);
1011 token =
next_token (&val, (
unsigned *)0, cfile);
1016 cp -> port = atoi (val);
1020 tp = &peer->max_lease_misbalance;
1024 tp = &peer->max_lease_ownership;
1028 tp = &peer->max_balance;
1032 tp = &peer->min_balance;
1036 tp = &peer->auto_partner_down;
1040 tp = &cp -> max_response_delay;
1042 token =
next_token (&val, (
unsigned *)0, cfile);
1046 dhcp_failover_state_dereference (&peer,
MDL);
1053 tp = &cp -> max_flying_updates;
1062 if (peer -> i_am == secondary)
1064 "secondary may not define %s",
1065 "load balance settings.");
1069 dhcp_failover_state_dereference (&peer,
MDL);
1072 if (hba_len != 32) {
1074 "HBA must be exactly 32 bytes.");
1083 memcpy (peer -> hba, hba, 32);
1087 token =
next_token (&val, (
unsigned *)0, cfile);
1088 if (peer -> i_am == secondary)
1090 "secondary may not define %s",
1091 "load balance settings.");
1095 dhcp_failover_state_dereference (&peer,
MDL);
1101 "0 and 256, inclusive");
1103 memset (hba, 0,
sizeof hba);
1104 for (i = 0; i < split; i++) {
1106 hba [i / 8] |= (1 << (i & 7));
1113 token =
next_token (&val, (
unsigned *)0, cfile);
1120 token =
next_token (&val, (
unsigned *)0, cfile);
1125 token =
next_token (&val, (
unsigned *)0, cfile);
1130 token =
next_token (&val, (
unsigned *)0, cfile);
1135 peer -> load_balance_max_secs = atoi (val);
1140 "invalid statement in peer declaration");
1142 dhcp_failover_state_dereference (&peer,
MDL);
1147 dhcp_failover_state_dereference (&peer,
MDL);
1150 }
while (token !=
RBRACE);
1155 if (!peer -> partner.address)
1156 parse_warn (cfile,
"peer address may not be omitted");
1159 peer->me.port = DEFAULT_FAILOVER_PORT;
1160 if (!peer->partner.port)
1161 peer->partner.port = DEFAULT_FAILOVER_PORT;
1163 if (peer -> i_am == primary) {
1166 "primary failover server must have hba or split.");
1167 }
else if (!peer -> mclt) {
1169 "primary failover server must have mclt.");
1173 if (!peer->max_lease_misbalance)
1174 peer->max_lease_misbalance = DEFAULT_MAX_LEASE_MISBALANCE;
1175 if (!peer->max_lease_ownership)
1176 peer->max_lease_ownership = DEFAULT_MAX_LEASE_OWNERSHIP;
1177 if (!peer->max_balance)
1178 peer->max_balance = DEFAULT_MAX_BALANCE_TIME;
1179 if (!peer->min_balance)
1180 peer->min_balance = DEFAULT_MIN_BALANCE_TIME;
1181 if (!peer->me.max_flying_updates)
1182 peer->me.max_flying_updates = DEFAULT_MAX_FLYING_UPDATES;
1183 if (!peer->me.max_response_delay)
1184 peer->me.max_response_delay = DEFAULT_MAX_RESPONSE_DELAY;
1196 if (status != ISC_R_SUCCESS)
1198 peer -> name, isc_result_totext (status));
1199 dhcp_failover_state_dereference (&peer,
MDL);
1203 dhcp_failover_state_t *peer)
1208 dhcp_failover_state_t *state;
1209 dhcp_failover_config_t *cp;
1212 token =
next_token (&val, (
unsigned *)0, cfile);
1213 if (token !=
PEER) {
1219 token =
next_token (&val, (
unsigned *)0, cfile);
1223 log_fatal (
"failover peer name %s: no memory",
1227 parse_warn (cfile,
"expecting failover peer name.");
1233 state = (dhcp_failover_state_t *)0;
1236 parse_warn (cfile,
"unknown failover peer: %s", name);
1241 token =
next_token (&val, (
unsigned *)0, cfile);
1242 if (token !=
STATE) {
1249 state = (dhcp_failover_state_t *)0;
1250 dhcp_failover_state_reference (&state, peer,
MDL);
1252 token =
next_token (&val, (
unsigned *)0, cfile);
1257 dhcp_failover_state_dereference (&state,
MDL);
1261 token =
next_token (&val, (
unsigned *)0, cfile);
1268 token =
next_token (&val, (
unsigned *)0, cfile);
1269 if (token !=
STATE) {
1274 &cp -> state, &cp -> stos);
1278 cp = &state -> partner;
1282 if (state -> i_am == primary) {
1284 "mclt not valid for primary");
1287 token =
next_token (&val, (
unsigned *)0, cfile);
1292 state -> mclt = atoi (val);
1297 parse_warn (cfile,
"expecting state setting.");
1300 dhcp_failover_state_dereference (&state,
MDL);
1303 }
while (token !=
RBRACE);
1304 dhcp_failover_state_dereference (&state,
MDL);
1308 struct parse *cfile;
1317 token =
next_token (&val, (
unsigned *)0, cfile);
1372 parse_warn (cfile,
"unknown failover state");
1377 token =
next_token (&val, (
unsigned *)0, cfile);
1378 if (token ==
SEMI) {
1421 void parse_authoring_byte_order (
struct parse *cfile)
1430 "authoring-byte-order specified too late.\n" 1431 "It must occur before the first lease in file\n");
1436 token =
next_token(&val, (
unsigned *)0, cfile);
1445 parse_warn(cfile,
"authoring-byte-order is invalid: " 1446 " it must be big-endian or little-endian.");
1452 log_error (
"WARNING: Lease file authored using different" 1453 " byte order, will attempt to convert");
1457 if (token !=
SEMI) {
1458 parse_warn(cfile,
"corrupt lease file; expecting a semicolon");
1478 void parse_lease_id_format (
struct parse *cfile)
1493 parse_warn(cfile,
"lease-id-format is invalid: " 1494 " it must be octal or hex.");
1503 if (token !=
SEMI) {
1504 parse_warn(cfile,
"corrupt lease file; expecting a semicolon");
1542 void get_permit(cfile, permit_head, is_allow, valid_from, valid_until)
1543 struct
parse *cfile;
1544 struct
permit **permit_head;
1546 TIME *valid_from, *valid_until;
1551 int need_clients = 1;
1616 permit->
class = NULL;
1624 if (*valid_from || *valid_until) {
1625 parse_warn(cfile,
"duplicate \"after\" clause.");
1641 parse_warn (cfile,
"expecting permit type.");
1651 if ((need_clients != 0) &&
1659 while (*permit_head)
1660 permit_head = &((*permit_head)->next);
1661 *permit_head = permit;
1674 struct permit *plp, *prp;
1681 for (plp = lhs; plp; plp = plp ->
next) {
1683 for (prp = rhs; prp; prp = prp ->
next) {
1684 if (prp -> type == plp -> type &&
1686 prp ->
class == plp ->
class)) {
1717 struct
parse *cfile;
1718 struct group *group;
1725 int declaration = 0;
1726 isc_result_t status;
1727 struct lease *lpchain = NULL, *lp;
1730 status = pool_allocate(&pool,
MDL);
1731 if (status != ISC_R_SUCCESS)
1733 isc_result_totext (status));
1743 parse_warn(cfile,
"Dynamic pools are only valid inside " 1744 "subnet or shared-network statements.");
1753 #if defined (FAILOVER_PROTOCOL) 1756 dhcp_failover_state_reference
1762 pool_dereference(&pool,
MDL);
1775 "expecting \"failover peer\".");
1779 #if defined (FAILOVER_PROTOCOL) 1781 dhcp_failover_state_dereference
1786 #if defined (FAILOVER_PROTOCOL) 1790 if (token !=
PEER) {
1802 dhcp_failover_state_dereference
1806 if (status != ISC_R_SUCCESS)
1808 "failover peer %s: %s", val,
1809 isc_result_totext (status));
1859 #if defined (FAILOVER_PROTOCOL) 1875 for (lp = lpchain; lp; lp = lp->
next) {
1876 pool_dereference(&lp->pool,
MDL);
1877 pool_reference(&lp->pool, pp,
MDL);
1880 #if defined (BINARY_LEASES) 1894 for (; *p; p = &((*p)->next))
1896 pool_reference(p, pool,
MDL);
1902 parse_warn(cfile,
"Pool declaration with no address range.");
1903 log_error(
"Pool declarations must always contain at least");
1911 lease_reference(&lp, lpchain,
MDL);
1912 lease_dereference(&lpchain,
MDL);
1914 lease_reference(&lpchain, lp->
next,
MDL);
1915 lease_dereference(&lp->next,
MDL);
1916 lease_dereference(&lp,
MDL);
1919 pool_dereference(&pool,
MDL);
1926 struct
parse *cfile;
1931 token =
next_token (&val, (
unsigned *)0, cfile);
1944 struct
parse *cfile;
1945 struct group *group;
1951 int declaration = 0;
1954 isc_result_t status;
1961 parse_warn (cfile,
"expecting a name for host declaration.");
1967 status = host_allocate (&host,
MDL);
1968 if (status != ISC_R_SUCCESS)
1969 log_fatal (
"can't allocate host decl struct %s: %s",
1970 name, isc_result_totext (status));
1971 host -> name =
name;
1973 log_fatal (
"can't clone group for host %s", name);
1975 host_dereference (&host,
MDL);
1983 token =
peek_token (&val, (
unsigned *)0, cfile);
1990 parse_warn (cfile,
"unexpected end of file");
2012 if (token ==
GROUP) {
2015 token =
next_token (&val, (
unsigned *)0, cfile);
2018 "expecting string or identifier.");
2024 val, strlen (val),
MDL)) {
2025 parse_warn (cfile,
"unknown group %s in host %s",
2028 if (host -> named_group)
2029 group_object_dereference
2030 (&host -> named_group,
MDL);
2031 group_object_reference (&host -> named_group,
2033 group_object_dereference (&go,
MDL);
2042 unsigned char *t = 0;
2050 "client identifier.",
2056 token =
peek_token (&val, (
unsigned *)0, cfile);
2060 host -> client_identifier.terminated = 1;
2065 (
unsigned char *)0, &len,
':', 16, 8);
2068 "expecting hex list.");
2071 s = (
const char *)t;
2074 (&host -> client_identifier.buffer,
2075 len + host -> client_identifier.terminated,
MDL))
2076 log_fatal (
"no memory for uid for host %s.",
2078 host -> client_identifier.data =
2079 host -> client_identifier.buffer -> data;
2080 host -> client_identifier.len = len;
2081 memcpy (host -> client_identifier.buffer -> data, s,
2082 len + host -> client_identifier.terminated);
2094 "only one host-identifier allowed " 2105 "host-identifier v6relopt " 2106 "must have a number");
2110 host->
relays = atoi(val);
2113 "host-identifier v6relopt " 2114 "must have a number >= 0");
2118 }
else if (token !=
OPTION) {
2120 "host-identifier must be an option" 2128 if ((status != ISC_R_SUCCESS) || (option == NULL)) {
2167 (
unsigned char *)host -> name,
2168 strlen (host -> name),
MDL)) {
2170 host_dereference (&hp,
MDL);
2174 if (host -> group -> statements ||
2175 (host -> group -> authoritative !=
2177 if (host -> group -> next)
2197 if (status != ISC_R_SUCCESS)
2198 parse_warn (cfile,
"host %s: %s", host -> name,
2199 isc_result_totext (status));
2201 host_dereference (&host,
MDL);
2209 struct
parse *cfile;
2210 struct group *group;
2215 struct class *
class = NULL, *pc = NULL;
2216 int declaration = 0;
2223 isc_result_t status = ISC_R_FAILURE;
2224 int matchedonce = 0;
2225 int submatchedonce = 0;
2243 class_reference(&
class, pc,
MDL);
2245 class_dereference(&pc,
MDL);
2260 data.
len = strlen (val);
2263 log_fatal (
"no memory for class name.");
2267 tname = type ?
"implicit-vendor-class" :
"implicit-user-class";
2277 log_fatal (
"No memory for class name %s.", tname);
2292 class_dereference (&pc,
MDL);
2298 memcpy ((
char *)data.
buffer -> data, val,
2301 memset (&data, 0,
sizeof data);
2304 class_dereference (&pc,
MDL);
2308 parse_warn (cfile,
"Expecting string or hex list.");
2310 class_dereference (&pc,
MDL);
2318 class_hash_lookup (&
class, pc -> hash,
2325 status = subclass_allocate (&
class,
MDL);
2327 status = class_allocate (&
class,
MDL);
2331 class_reference (&
class -> superclass, pc,
MDL);
2332 class -> lease_limit = pc -> lease_limit;
2333 if (
class -> lease_limit) {
2334 class -> billed_leases =
2335 dmalloc (
class -> lease_limit *
2337 if (!
class -> billed_leases)
2339 memset (
class -> billed_leases, 0,
2340 (
class -> lease_limit *
2341 sizeof (
struct lease *)));
2346 log_fatal (
"No memory for subclass hash.");
2347 class_hash_add (pc -> hash,
2348 (
const char *)
class -> hash_string.data,
2349 class -> hash_string.len,
2350 (
void *)
class,
MDL);
2355 log_fatal (
"no memory to clone class group.");
2364 log_fatal (
"no memory for class statement.");
2365 stmt -> op = supersede_option_statement;
2368 stmt -> data.option -> data = data;
2372 option_code_hash_lookup(
2377 class -> statements = stmt;
2390 if (
class -> superclass) {
2392 if (token ==
SEMI) {
2396 status = class_reference (cp,
class,
MDL);
2397 class_dereference (&
class,
MDL);
2399 class_dereference (&pc,
MDL);
2400 return cp ? (status == ISC_R_SUCCESS) : 1;
2409 class_dereference (&
class,
MDL);
2411 class_dereference (&pc,
MDL);
2422 parse_warn (cfile,
"unexpected end of file");
2424 }
else if (token ==
DYNAMIC) {
2436 }
else if (token ==
MATCH) {
2439 "invalid match in subclass.");
2450 "one 'match if' clause.");
2461 "expecting boolean expr.");
2465 #if defined (DEBUG_EXPRESSION_PARSE) 2471 }
else if (token ==
SPAWN) {
2475 "invalid spawn in subclass.");
2479 class -> spawning = 1;
2481 if (token !=
WITH) {
2483 "expecting with after spawn");
2488 if (submatchedonce) {
2490 "can't override existing %s.",
2502 "expecting data expr.");
2506 #if defined (DEBUG_EXPRESSION_PARSE) 2512 }
else if (token ==
LEASE) {
2515 if (token !=
LIMIT) {
2528 class -> lease_limit = atoi (val);
2531 class -> billed_leases =
2532 dmalloc (
class -> lease_limit *
2534 if (!
class -> billed_leases)
2535 log_fatal (
"no memory for billed leases.");
2536 memset (
class -> billed_leases, 0,
2537 (
class -> lease_limit *
2538 sizeof (
struct lease *)));
2550 struct class *theclass = NULL;
2553 if (status == ISC_R_SUCCESS) {
2555 class_dereference(&theclass,
MDL);
2558 class_hash_delete(pc->hash,
2570 class_reference (&c ->
nic,
class,
MDL);
2575 status = class_reference (cp,
class,
MDL);
2576 class_dereference (&
class,
MDL);
2578 class_dereference (&pc,
MDL);
2579 return cp ? (status == ISC_R_SUCCESS) : 1;
2586 struct
parse *cfile;
2587 struct group *group;
2593 int declaration = 0;
2594 isc_result_t status;
2597 status = shared_network_allocate (&share,
MDL);
2598 if (status != ISC_R_SUCCESS)
2599 log_fatal (
"Can't allocate shared subnet: %s",
2600 isc_result_totext (status));
2602 log_fatal (
"Can't clone group for shared net");
2608 token =
peek_token (&val, (
unsigned *)0, cfile);
2613 parse_warn (cfile,
"zero-length shared network name");
2614 val =
"<no-name-given>";
2618 log_fatal (
"no memory for shared network name");
2624 "expecting a name for shared-network");
2626 shared_network_dereference (&share,
MDL);
2630 share -> name =
name;
2633 shared_network_dereference (&share,
MDL);
2638 token =
peek_token (&val, (
unsigned *)0, cfile);
2643 "empty shared-network decl");
2646 shared_network_dereference (&share,
MDL);
2650 parse_warn (cfile,
"unexpected end of file");
2654 token =
next_token (&val, (
unsigned *)0, cfile);
2666 shared_network_dereference (&share,
MDL);
2671 common_subnet_parsing(
struct parse *cfile,
2675 struct subnet *t, *u;
2677 int declaration = 0;
2682 subnet_dereference(&subnet,
MDL);
2693 parse_warn (cfile,
"unexpected end of file");
2711 subnet_reference(&share->
subnets, subnet,
MDL);
2723 subnet_dereference(&share->
subnets,
2725 subnet_reference(&share->
subnets,
2728 subnet_dereference(&subnet,
MDL);
2735 subnet_dereference(&subnet,
MDL);
2743 struct
parse *cfile;
2748 struct subnet *subnet;
2750 unsigned char addr [4];
2751 unsigned len =
sizeof addr;
2752 isc_result_t status;
2754 subnet = (
struct subnet *)0;
2755 status = subnet_allocate (&subnet,
MDL);
2756 if (status != ISC_R_SUCCESS)
2757 log_fatal (
"Allocation of new subnet failed: %s",
2758 isc_result_totext (status));
2773 log_fatal(
"Allocation of group for new subnet failed.");
2776 subnet_reference (&subnet -> group -> subnet, subnet,
MDL);
2780 subnet_dereference (&subnet,
MDL);
2783 memcpy (iaddr.
iabuf, addr, len);
2785 subnet ->
net = iaddr;
2787 token =
next_token (&val, (
unsigned *)0, cfile);
2796 subnet_dereference (&subnet,
MDL);
2799 memcpy (iaddr.
iabuf, addr, len);
2809 if (maskstr == NULL) {
2810 log_fatal(
"Allocation of subnet maskstr failed: %s",
2815 "subnet %s netmask %s: bad subnet number/mask combination.",
2818 subnet_dereference (&subnet,
MDL);
2823 common_subnet_parsing(cfile, share, subnet);
2831 #if !defined(DHCPv6) 2835 struct subnet *subnet;
2836 isc_result_t status;
2841 const static int mask[] = { 0x00, 0x80, 0xC0, 0xE0,
2842 0xF0, 0xF8, 0xFC, 0xFE };
2845 #if defined(DHCP4o6) 2847 parse_warn(cfile,
"subnet6 statement is only supported " 2848 "in DHCPv6 and DHCPv4o6 modes.");
2854 parse_warn(cfile,
"subnet6 statement is only supported " 2862 status = subnet_allocate(&subnet,
MDL);
2863 if (status != ISC_R_SUCCESS) {
2864 log_fatal(
"Allocation of new subnet failed: %s",
2865 isc_result_totext(status));
2881 log_fatal(
"Allocation of group for new subnet failed.");
2887 subnet_dereference(&subnet,
MDL);
2892 if (token !=
SLASH) {
2909 parse_warn(cfile,
"Expecting a number between 0 and 128.");
2915 parse_warn(cfile,
"New subnet mask too short.");
2925 if (ofs < subnet->netmask.len) {
2928 while (--ofs >= 0) {
2934 if (memcmp(&iaddr, &subnet->
net, 16) != 0) {
2936 "subnet %s/%d: prefix not long enough for address.",
2938 subnet_dereference(&subnet,
MDL);
2943 if (!common_subnet_parsing(cfile, share, subnet)) {
2952 struct
parse *cfile;
2953 struct group *group;
2958 int declaration = 0;
2960 isc_result_t status;
2968 log_fatal(
"no memory for explicit group.");
2976 log_fatal(
"no memory for group decl name %s", val);
2998 }
else if (token ==
DYNAMIC) {
3002 }
else if (token ==
STATIC) {
3017 strlen(name),
MDL)) {
3023 status = group_object_allocate(&t,
MDL);
3024 if (status != ISC_R_SUCCESS)
3025 log_fatal(
"no memory for group decl %s: %s",
3026 val, isc_result_totext(status));
3035 group_object_dereference(&t,
MDL);
3045 struct parse *cfile,
3082 if (token ==
COMMA) {
3085 }
while (token ==
COMMA);
3119 unsigned char addr [4];
3120 unsigned len =
sizeof addr;
3128 int noequal, newbinding;
3131 isc_result_t status;
3135 unsigned buflen = 0;
3136 struct class *
class;
3138 lease = (
struct lease *)0;
3139 status = lease_allocate (&lease,
MDL);
3140 if (status != ISC_R_SUCCESS)
3145 lease_dereference (&lease,
MDL);
3152 lease_dereference (&lease,
MDL);
3157 token =
next_token (&val, (
unsigned *)0, cfile);
3161 parse_warn (cfile,
"unexpected end of file");
3164 strncpy (tbuf, val,
sizeof tbuf);
3165 tbuf [(
sizeof tbuf) - 1] = 0;
3217 token =
peek_token (&val, (
unsigned *)0, cfile);
3219 unsigned char *tuid;
3221 if (buflen < sizeof lease ->
uid_buf) {
3226 tuid = ((
unsigned char *)
3230 lease_dereference (&lease,
3237 memcpy (tuid, val, lease ->
uid_len);
3238 lease ->
uid = tuid;
3242 (cfile, (
unsigned char *)0,
3243 &buflen,
':', 16, 8));
3244 if (!lease ->
uid) {
3245 lease_dereference (&lease,
MDL);
3251 lease ->
uid = (
unsigned char *)0;
3259 if (!lease ->
uid) {
3266 token =
next_token (&val, (
unsigned *)0, cfile);
3270 lease_dereference (&lease,
MDL);
3305 token =
next_token (&val, (
unsigned *)0, cfile);
3311 goto do_binding_state;
3321 goto do_binding_state;
3327 token =
next_token (&val, (
unsigned *)0, cfile);
3328 if (token !=
STATE) {
3333 token =
next_token (&val, (
unsigned *)0, cfile);
3371 "%s: expecting a binding state.",
3377 if (seenbit == 256) {
3386 if (!(seenmask & 128))
3390 if (!(seenmask & 512))
3392 }
else if (seenbit == 128)
3394 else if (seenbit == 512)
3397 log_fatal(
"Impossible condition at %s:%d.",
3405 token =
peek_token (&val, (
unsigned *)0, cfile);
3410 lease_dereference (&lease,
MDL);
3420 "expecting a hostname.");
3422 lease_dereference (&lease,
MDL);
3430 class = (struct class *)0;
3431 token =
next_token (&val, (
unsigned *)0, cfile);
3432 if (token ==
CLASS) {
3434 (
unsigned *)0, cfile);
3442 if (lease -> billing_class)
3443 class_dereference (&lease -> billing_class,
3448 "unknown class %s", val);
3451 if (lease -> billing_class)
3452 class_dereference (&lease -> billing_class,
3462 class_reference (&lease -> billing_class,
3464 class_dereference (&
class,
MDL);
3473 lease_dereference (&lease,
MDL);
3478 on->
data.
on.statements) {
3485 on->
data.
on.statements) {
3503 "agent option expected.");
3510 log_error (
"no memory to stash agent option");
3514 *p; p = &((*p) -> cdr))
3518 &((*p) -> car)), oc,
MDL);
3526 token =
next_token (&val, (
unsigned *)0, cfile);
3529 "%s can't be a variable name",
3533 lease_dereference (&lease,
MDL);
3542 binding = (
struct binding *)0;
3545 if (!lease -> scope)
3547 (&lease -> scope,
MDL)))
3553 memset (binding, 0,
sizeof *binding);
3556 if (!binding ->
name)
3559 strcpy (binding ->
name, val);
3567 log_fatal(
"no memory for binding value.");
3570 token =
next_token (&val, (
unsigned *)0, cfile);
3571 if (token !=
EQUAL) {
3573 "expecting '=' in set statement.");
3578 if (!parse_binding_value(cfile, nv)) {
3580 lease_dereference(&lease,
MDL);
3601 if (!strcasecmp (val,
"ddns-fwd-name")) {
3605 }
else if (!strcasecmp (val,
"ddns-rev-name")) {
3610 parse_warn(cfile,
"Unexpected configuration " 3614 lease_dereference (&lease,
MDL);
3618 if (seenmask & seenbit) {
3620 "Too many %s parameters in lease %s\n",
3623 seenmask |= seenbit;
3628 if (!(seenmask & 256)) {
3632 #if defined (FAILOVER_PROTOCOL) 3639 #if defined (FAILOVER_PROTOCOL) 3652 if (!(seenmask & 65536))
3655 lease_reference (lp, lease,
MDL);
3656 lease_dereference (&lease,
MDL);
3675 if ((cfile == NULL) || (value == NULL))
3682 value->
type = binding_data;
3695 value->
type = binding_data;
3715 }
else if (token ==
PERCENT) {
3719 parse_warn(cfile,
"expecting decimal number.");
3724 value->
type = binding_numeric;
3726 }
else if (token ==
NAME) {
3728 value->
type = binding_boolean;
3729 if (!strcasecmp(val,
"true"))
3731 else if (!strcasecmp(val,
"false"))
3734 parse_warn(cfile,
"expecting true or false");
3740 parse_warn (cfile,
"expecting a constant value.");
3753 struct
parse *cfile;
3754 struct group *group;
3756 struct
pool *inpool;
3757 struct
lease **lpchain;
3759 struct iaddr low, high, net;
3760 unsigned char addr [4];
3761 unsigned len =
sizeof addr;
3765 struct subnet *subnet;
3768 isc_result_t status;
3779 memcpy (low.
iabuf, addr, len);
3783 token =
peek_token (&val, (
unsigned *)0, cfile);
3790 memcpy (high.
iabuf, addr, len);
3794 token =
next_token (&val, (
unsigned *)0, cfile);
3795 if (token !=
SEMI) {
3802 subnet = group -> subnet;
3806 for (subnet = share ->
subnets;
3807 subnet; subnet = subnet -> next_sibling) {
3809 if (
addr_eq (net, subnet -> net))
3813 parse_warn (cfile,
"address range not on network %s",
3815 log_error (
"Be sure to place pool statement after %s",
3816 "related subnet declarations.");
3822 struct pool *last = (
struct pool *)0;
3827 for (pool = share ->
pools; pool; pool = pool ->
next) {
3832 permit_dynamic_bootp_clients)) ||
3837 permit_all_clients))) {
3846 status = pool_allocate (&pool,
MDL);
3847 if (status != ISC_R_SUCCESS)
3848 log_fatal (
"no memory for ad-hoc pool: %s",
3849 isc_result_totext (status));
3852 log_fatal (
"no memory for ad-hoc permit.");
3858 pool -> permit_list = p;
3861 pool -> prohibit_list = p;
3865 pool_reference (&last ->
next, pool,
MDL);
3867 pool_reference (&share ->
pools, pool,
MDL);
3871 log_fatal (
"no memory for anon pool group.");
3873 pool = (
struct pool *)0;
3875 pool_reference (&pool, last,
MDL);
3877 pool_reference (&pool, share ->
pools,
MDL);
3880 pool = (
struct pool *)0;
3881 pool_reference (&pool, inpool,
MDL);
3884 #if defined (FAILOVER_PROTOCOL) 3888 parse_warn (cfile,
"dynamic-bootp flag is %s",
3889 "not permitted for address");
3890 log_error (
"range declarations where there is a failover");
3891 log_error (
"peer in scope. If you wish to declare an");
3892 log_error (
"address range from which dynamic bootp leases");
3893 log_error (
"can be allocated, please declare it within a");
3894 log_error (
"pool declaration that also contains the \"no");
3895 log_error (
"failover\" statement. The failover protocol");
3896 log_error (
"itself does not permit dynamic bootp - this");
3897 log_error (
"is not a limitation specific to the ISC DHCP");
3898 log_error (
"server. Please don't ask me to defend this");
3899 log_error (
"until you have read and really tried %s",
3901 log_error (
"the failover protocol specification.");
3911 pool_dereference (&pool,
MDL);
3916 add_ipv6_pool_to_subnet(
struct subnet *subnet, u_int16_t type,
3917 struct iaddr *lo_addr,
int bits,
int units,
3920 struct in6_addr tmp_in6_addr;
3927 if (lo_addr->
len !=
sizeof(tmp_in6_addr)) {
3928 log_fatal(
"Internal error: Attempt to add non-IPv6 address " 3929 "to IPv6 shared network.");
3931 memcpy(&tmp_in6_addr, lo_addr->
iabuf,
sizeof(tmp_in6_addr));
3934 bits, units,
MDL) != ISC_R_SUCCESS) {
3949 subnet_reference(&pool->
subnet, subnet,
MDL);
3963 while (pond->
ipv6_pools[num_pools] != NULL) {
3971 if (num_pools > 0) {
3973 sizeof(
struct ipv6_pool *) * num_pools);
4001 if ((units - bits) > (
sizeof(isc_uint64_t) * 8)) {
4006 isc_uint64_t space_left
4009 = (isc_uint64_t)(1) << (units -
bits);
4011 if (addon > space_left) {
4048 add_ipv6_pond_to_network(
struct group *group,
4051 struct ipv6_pond *pond = NULL, *last = NULL;
4053 isc_result_t status;
4070 if (status != ISC_R_SUCCESS)
4071 log_fatal (
"no memory for ad-hoc ipv6 pond: %s",
4072 isc_result_totext (status));
4075 log_fatal (
"no memory for ad-hoc ipv6 permit.");
4078 p->
type = permit_all_clients;
4091 log_fatal (
"no memory for anon pool group.");
4104 struct group *group,
4106 struct iaddr lo, hi;
4116 parse_warn(cfile,
"range6 statement is only supported " 4123 if (group->
subnet == NULL)
4136 parse_warn(cfile,
"range6 start address is outside the subnet");
4144 memset(&net, 0,
sizeof(net));
4151 if (token ==
SLASH) {
4164 if ((bits < 0) || (bits > 128)) {
4165 parse_warn(cfile,
"networks have 0 to 128 bits");
4171 "network mask smaller than subnet mask");
4186 parse_warn(cfile,
"temporary mask too short");
4224 "range6 end address is outside the subnet");
4233 if (
range2cidr(&nets, &lo, &hi) != ISC_R_SUCCESS) {
4234 log_fatal(
"Error converting range to CIDR networks");
4245 if (inpond != NULL) {
4248 add_ipv6_pond_to_network(group, &pond);
4252 for (p=nets; p != NULL; p=p->
next) {
4253 add_ipv6_pool_to_subnet(group->
subnet, type,
4265 if (token !=
SEMI) {
4276 struct group *group,
4278 struct iaddr lo, hi;
4287 parse_warn(cfile,
"prefix6 statement is only supported " 4294 if (group->
subnet == NULL)
4314 " is outside the subnet");
4334 " is outside the subnet");
4344 if (token !=
SLASH) {
4358 if ((bits <= 0) || (bits >= 128)) {
4359 parse_warn(cfile,
"networks have 0 to 128 bits (exclusive)");
4370 parse_warn(cfile,
"network mask smaller than subnet mask");
4383 if (token !=
SEMI) {
4393 if (
range2cidr(&nets, &lo, &hi) != ISC_R_SUCCESS) {
4394 log_fatal(
"Error converting prefix to CIDR");
4403 if (inpond != NULL) {
4406 add_ipv6_pond_to_network(group, &pond);
4409 for (p = nets; p != NULL; p = p->
next) {
4442 while (*h != NULL) {
4462 if (token !=
SLASH) {
4478 if (token !=
SEMI) {
4491 parse_warn(cfile,
"networks have 0 to 128 bits");
4527 struct parse *cfile;
4528 struct group *group;
4535 int declaration = 0;
4536 isc_result_t status;
4540 if (status != ISC_R_SUCCESS)
4542 isc_result_totext (status));
4549 parse_warn(cfile,
"pool6s are only valid inside " 4550 "subnet statements.");
4623 for (; *p; p = &((*p)->next))
4630 parse_warn (cfile,
"Pool6 declaration with no %s.",
4631 "address range6 or prefix6");
4632 log_error (
"Pool6 declarations must always contain at least");
4633 log_error (
"one range6 or prefix6 statement.");
4651 struct
parse *cfile;
4656 unsigned char rf = flag;
4665 token =
next_token (&val, (
unsigned *)0, cfile);
4700 parse_warn (cfile,
"expecting allow/deny key");
4708 log_fatal(
"Unable to find server option %u (%s:%d).",
4718 #if !defined(DHCPv6) 4723 struct ia_xx *ia = NULL;
4725 struct ia_xx *old_ia;
4734 char addr_buf[
sizeof(
"ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")];
4735 isc_boolean_t newbinding;
4743 parse_warn(cfile,
"IA_NA is only supported in DHCPv6 mode.");
4748 if (!parse_iaid_duid(cfile, &ia, &iaid,
MDL)) {
4756 parse_warn(cfile,
"corrupt lease file; expecting left brace");
4763 if (token ==
RBRACE)
break;
4765 if (token ==
CLTT) {
4772 "expecting IAADDR or right brace");
4779 "expecting IPv6 address");
4787 "expecting left brace");
4797 if (token ==
RBRACE)
break;
4806 "unexpected end of file");
4812 if (token !=
STATE) {
4846 if (token !=
SEMI) {
4863 prefer = atoi (val);
4872 if (token ==
SEMI) {
4876 "corrupt lease file; " 4877 "expecting semicolon.");
4900 if (token ==
SEMI) {
4904 "corrupt lease file; " 4905 "expecting semicolon.");
4917 if ((token !=
NAME) &&
4949 if (bnd->
name == NULL) {
4953 strcpy(bnd->
name, val);
4955 newbinding = ISC_TRUE;
4957 newbinding = ISC_FALSE;
4966 if (token !=
EQUAL) {
4972 if (!parse_binding_value(cfile, nv)) {
5004 if (on_star[0] == NULL) {
5032 "expecting ia_na contents, " 5041 "missing state in iaaddr");
5044 if (end_time == -1) {
5046 "missing end time in iaaddr");
5051 if (iasubopt_allocate(&iaaddr,
MDL) != ISC_R_SUCCESS) {
5056 iaaddr->
state = state;
5058 iaaddr->
valid = valid;
5062 if (scope != NULL) {
5074 (i < 2) && on_star[i] != NULL ;
5077 on_star[i]->
data.
on.statements) {
5083 on_star[i]->
data.
on.statements) {
5094 &iaaddr->
addr) != ISC_R_SUCCESS) {
5095 inet_ntop(AF_INET6, &iaaddr->
addr,
5096 addr_buf,
sizeof(addr_buf));
5097 log_error(
"No pool found for IA_NA address %s",
5105 iaaddr, ia) != ISC_R_SUCCESS) {
5106 inet_ntop(AF_INET6, &iaaddr->
addr,
5107 addr_buf,
sizeof(addr_buf));
5108 parse_warn(cfile,
"duplicate na lease for address %s",
5154 #if !defined(DHCPv6) 5159 struct ia_xx *ia = NULL;
5161 struct ia_xx *old_ia;
5170 char addr_buf[
sizeof(
"ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")];
5171 isc_boolean_t newbinding;
5179 parse_warn(cfile,
"IA_TA is only supported in DHCPv6 mode.");
5184 if (!parse_iaid_duid(cfile, &ia, &iaid,
MDL)) {
5192 parse_warn(cfile,
"corrupt lease file; expecting left brace");
5199 if (token ==
RBRACE)
break;
5201 if (token ==
CLTT) {
5208 "expecting IAADDR or right brace");
5215 "expecting IPv6 address");
5223 "expecting left brace");
5233 if (token ==
RBRACE)
break;
5242 "unexpected end of file");
5248 if (token !=
STATE) {
5282 if (token !=
SEMI) {
5299 prefer = atoi (val);
5308 if (token ==
SEMI) {
5312 "corrupt lease file; " 5313 "expecting semicolon.");
5336 if (token ==
SEMI) {
5340 "corrupt lease file; " 5341 "expecting semicolon.");
5353 if ((token !=
NAME) &&
5385 if (bnd->
name == NULL) {
5389 strcpy(bnd->
name, val);
5391 newbinding = ISC_TRUE;
5393 newbinding = ISC_FALSE;
5402 if (token !=
EQUAL) {
5408 if (!parse_binding_value(cfile, nv)) {
5440 if (on_star[0] == NULL) {
5468 "expecting ia_ta contents, " 5477 "missing state in iaaddr");
5480 if (end_time == -1) {
5482 "missing end time in iaaddr");
5487 if (iasubopt_allocate(&iaaddr,
MDL) != ISC_R_SUCCESS) {
5492 iaaddr->
state = state;
5494 iaaddr->
valid = valid;
5498 if (scope != NULL) {
5510 (i < 2) && on_star[i] != NULL ;
5513 on_star[i]->
data.
on.statements) {
5519 on_star[i]->
data.
on.statements) {
5530 &iaaddr->
addr) != ISC_R_SUCCESS) {
5531 inet_ntop(AF_INET6, &iaaddr->
addr,
5532 addr_buf,
sizeof(addr_buf));
5533 log_error(
"No pool found for IA_TA address %s",
5541 iaaddr, ia) != ISC_R_SUCCESS) {
5542 inet_ntop(AF_INET6, &iaaddr->
addr,
5543 addr_buf,
sizeof(addr_buf));
5544 parse_warn(cfile,
"duplicate ta lease for address %s",
5590 #if !defined(DHCPv6) 5595 struct ia_xx *ia = NULL;
5597 struct ia_xx *old_ia;
5607 char addr_buf[
sizeof(
"ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")];
5608 isc_boolean_t newbinding;
5616 parse_warn(cfile,
"IA_PD is only supported in DHCPv6 mode.");
5621 if (!parse_iaid_duid(cfile, &ia, &iaid,
MDL)) {
5629 parse_warn(cfile,
"corrupt lease file; expecting left brace");
5636 if (token ==
RBRACE)
break;
5638 if (token ==
CLTT) {
5644 parse_warn(cfile,
"corrupt lease file; expecting " 5645 "IAPREFIX or right brace");
5652 "expecting IPv6 prefix");
5660 "expecting left brace");
5670 if (token ==
RBRACE)
break;
5679 "unexpected end of file");
5685 if (token !=
STATE) {
5719 if (token !=
SEMI) {
5736 prefer = atoi (val);
5745 if (token ==
SEMI) {
5749 "corrupt lease file; " 5750 "expecting semicolon.");
5773 if (token ==
SEMI) {
5777 "corrupt lease file; " 5778 "expecting semicolon.");
5790 if ((token !=
NAME) &&
5822 if (bnd->
name == NULL) {
5826 strcpy(bnd->
name, val);
5828 newbinding = ISC_TRUE;
5830 newbinding = ISC_FALSE;
5839 if (token !=
EQUAL) {
5845 if (!parse_binding_value(cfile, nv)) {
5877 if (on_star[0] == NULL) {
5905 "expecting ia_pd contents, " 5914 "missing state in iaprefix");
5917 if (end_time == -1) {
5919 "missing end time in iaprefix");
5924 if (iasubopt_allocate(&iapref,
MDL) != ISC_R_SUCCESS) {
5928 iapref->
plen = plen;
5929 iapref->
state = state;
5931 iapref->
valid = valid;
5935 if (scope != NULL) {
5947 (i < 2) && on_star[i] != NULL ;
5950 on_star[i]->
data.
on.statements) {
5956 on_star[i]->
data.
on.statements) {
5967 &iapref->
addr) != ISC_R_SUCCESS) {
5968 inet_ntop(AF_INET6, &iapref->
addr,
5969 addr_buf,
sizeof(addr_buf));
5970 log_error(
"No pool found for prefix %s", addr_buf);
5977 iapref, ia) != ISC_R_SUCCESS) {
5978 inet_ntop(AF_INET6, &iapref->
addr,
5979 addr_buf,
sizeof(addr_buf));
5980 parse_warn(cfile,
"duplicate pd lease for address %s",
6040 unsigned char bytes[128];
6043 len =
parse_X(cfile, bytes,
sizeof(bytes));
6050 memset(&duid, 0x0,
sizeof(duid));
6052 log_fatal(
"parse_server_duid: out of memory");
6081 u_int32_t enterprise_number;
6108 parse_warn(cfile,
"enterprise number expected");
6112 enterprise_number = atoi(val);
6124 memset(&duid, 0,
sizeof(duid));
6127 log_fatal(
"Out of memory storing DUID");
6145 else if (token ==
LL) {
6168 memset(&ll_addr, 0,
sizeof(ll_addr));
6176 memset(&duid, 0,
sizeof(duid));
6177 duid.
len = 2 + 2 + ll_addr.
len;
6179 log_fatal(
"Out of memory storing DUID");
6200 else if (token ==
LLT) {
6230 llt_time = atoi(val);
6232 memset(&ll_addr, 0,
sizeof(ll_addr));
6240 memset(&duid, 0,
sizeof(duid));
6241 duid.
len = 2 + 2 + 4 + ll_addr.
len;
6243 log_fatal(
"Out of memory storing DUID");
6267 else if (token ==
NUMBER) {
6268 duid_type_num = atoi(val);
6280 memset(&duid, 0,
sizeof(duid));
6283 log_fatal(
"Out of memory storing DUID");
6297 parse_warn(cfile,
"DUID type of LLT, EN, or LL expected");
6306 if (token !=
SEMI) {
6330 memcpy(&value, source, 4);
6334 "authoring-byte-order not in the lease file.\n" 6335 "Assuming file byte order matches this server.\n");
6340 value = (((value >> 24) & 0xff) |
6341 ((value << 8) & 0xff0000) |
6342 ((value >> 8) & 0xff00) |
6343 ((value << 24) & 0xff000000));
6364 parse_iaid_duid(
struct parse* cfile,
struct ia_xx** ia, u_int32_t *iaid,
6366 unsigned char bytes[132];
6370 log_error(
"parse_iaid_duid: ia ptr cannot be null");
6375 len =
parse_X(cfile, bytes,
sizeof(bytes));
6378 "iaid+ia_xx string too short");
6387 if (
ia_allocate(ia, *iaid, (
const char*)bytes + 4, len - 4, file, line)
6389 log_fatal(
"parse_iaid_duid:Out of memory.");
struct iaddrcidrnet cidrnet
#define GROUP_OBJECT_DYNAMIC
void parse_option_space_decl(struct parse *cfile)
int parse_X(struct parse *cfile, u_int8_t *buf, unsigned max)
int executable_statement_reference(struct executable_statement **ptr, struct executable_statement *bp, const char *file, int line)
int executable_statement_allocate(struct executable_statement **ptr, const char *file, int line)
int parse_lease_declaration(struct lease **lp, struct parse *cfile)
void parse_server_duid_conf(struct parse *cfile)
isc_result_t parse_option_name(struct parse *cfile, int allocate, int *known, struct option **opt)
void parse_trace_setup(void)
void trace_conf_input(trace_type_t *, unsigned, char *)
int parse_option_code_definition(struct parse *cfile, struct option *option)
isc_result_t read_conf_file(const char *filename, struct group *group, int group_type, int leasep)
struct universe * universe
int binding_value_dereference(struct binding_value **v, const char *file, int line)
isc_result_t delete_group(struct group_object *group, int writep)
isc_result_t add_lease6(struct ipv6_pool *pool, struct iasubopt *lease, time_t valid_lifetime_end_time)
int executable_statement_dereference(struct executable_statement **ptr, const char *file, int line)
trace_type_t * trace_type_register(const char *, void *, void(*)(trace_type_t *, unsigned, char *), void(*)(trace_type_t *), const char *, int)
const char * piaddr(const struct iaddr addr)
#define CLASS_TYPE_VENDOR
void parse_fixed_prefix6(struct parse *cfile, struct host_decl *host_decl)
struct permit * new_permit(const char *, int)
isc_result_t end_parse(struct parse **cfile)
int parse_statement(struct parse *cfile, struct group *group, int type, struct host_decl *host_decl, int declaration)
int permit_list_match(struct permit *lhs, struct permit *rhs)
void * dmalloc(unsigned, const char *, int)
char * piaddrmask(struct iaddr *addr, struct iaddr *mask)
isc_result_t ia_dereference(struct ia_xx **ia, const char *file, int line)
int option_cache_dereference(struct option_cache **ptr, const char *file, int line)
void parse_pool6_statement(struct parse *, struct group *, int)
struct universe server_universe
struct iaddr ip_addr(struct iaddr subnet, struct iaddr mask, u_int32_t host_address)
int parse_data_expression(struct expression **expr, struct parse *cfile, int *lose)
struct ipv6_pond * ipv6_pond
int binding_value_reference(struct binding_value **ptr, struct binding_value *src, const char *file, int line)
#define HOST_DECL_DYNAMIC
#define CLASS_DECL_DELETED
int int int log_debug(const char *,...) __attribute__((__format__(__printf__
enum executable_statement::statement_op op
uint32_t parse_byte_order_uint32(const void *source)
struct executable_statement * on_release
int option_reference(struct option **dest, struct option *src, const char *file, int line)
void print_expression(char *name, struct expression *expr) const
struct universe dhcp_universe
int group_reference(struct group **ptr, struct group *bp, const char *file, int line)
void data_string_forget(struct data_string *data, const char *file, int line)
struct shared_network * shared_network
isc_result_t ipv6_pond_reference(struct ipv6_pond **pond, struct ipv6_pond *src, const char *file, int line)
reference an IPv6 pond structure.
int option_cache_reference(struct option_cache **ptr, struct option_cache *src, const char *file, int line)
struct option_cache * fixed_addr
struct group * root_group
enum binding_value::@15 type
struct data_string hash_string
const char * path_dhcpd_db
int log_error(const char *,...) __attribute__((__format__(__printf__
struct collection * collections
int binding_scope_dereference(struct binding_scope **ptr, const char *file, int line)
void free_permit(struct permit *, const char *, int)
struct binding_scope * scope
dhcp_failover_state_t * failover_peer
int parse_semi(struct parse *cfile)
struct ipv6_pond * ipv6_pond
struct executable_statement * next
dhcp_failover_state_t * failover_peer
int parse_fixed_addr_param(struct option_cache **oc, struct parse *cfile, enum dhcp_token type)
enum dhcp_token peek_token(const char **rval, unsigned *rlen, struct parse *cfile)
isc_result_t lease_file_subparse(struct parse *cfile)
struct data_string client_identifier
struct permit * prohibit_list
int parse_string(struct parse *cfile, char **sptr, unsigned *lptr)
void parse_failover_state_declaration(struct parse *, dhcp_failover_state_t *)
void expression_dereference(struct expression **eptr, const char *file, int line)
#define DHO_DHCP_SERVER_IDENTIFIER
void log_fatal(const char *,...) __attribute__((__format__(__printf__
void get_permit(struct parse *cfile, struct permit **permit_head, int is_allow, TIME *valid_from, TIME *valid_until)
Parse allow and deny statements.
void parse_ia_ta_declaration(struct parse *cfile)
int binding_value_allocate(struct binding_value **cptr, const char *file, int line)
struct executable_statement * statements
int parse_cshl(struct data_string *data, struct parse *cfile)
void parse_group_declaration(struct parse *cfile, struct group *group)
int option_cache_allocate(struct option_cache **cptr, const char *file, int line)
union expression::expr_union data
#define CLASS_DECL_DYNAMIC
struct hardware hardware_addr
struct iaddr subnet_number(struct iaddr addr, struct iaddr mask)
void postdb_startup(void)
isc_result_t ipv6_pool_allocate(struct ipv6_pool **pool, u_int16_t type, const struct in6_addr *start_addr, int bits, int units, const char *file, int line)
Create a new IPv6 lease pool structure.
enum dhcp_token next_token(const char **rval, unsigned *rlen, struct parse *cfile)
int subnet_inner_than(const struct subnet *, const struct subnet *, int)
time_t hard_lifetime_end_time
struct permit * prohibit_list
host_hash_t * host_name_hash
void parse_ia_na_declaration(struct parse *cfile)
#define CLASS_TYPE_SUBCLASS
isc_result_t delete_host(struct host_decl *, int)
void enter_shared_network(struct shared_network *)
isc_result_t cleanup_lease6(ia_hash_t *ia_table, struct ipv6_pool *pool, struct iasubopt *lease, struct ia_xx *ia)
Cleans up leases when reading from a lease file.
binding_state_t binding_state
int buffer_allocate(struct buffer **ptr, unsigned len, const char *file, int line)
struct option_cache * option
void postconf_initialization(int)
int binding_scope_allocate(struct binding_scope **ptr, const char *file, int line)
void putULong(unsigned char *, u_int32_t)
int group_dereference(struct group **ptr, const char *file, int line)
#define skip_token(a, b, c)
void enter_lease(struct lease *)
int parse_boolean_expression(struct expression **expr, struct parse *cfile, int *lose)
struct iaddrcidrnetlist * next
option_name_hash_t * name_hash
unsigned char * parse_numeric_aggregate(struct parse *cfile, unsigned char *buf, unsigned *max, int separator, int base, unsigned size)
struct data_string iaid_duid
isc_result_t free_iaddrcidrnetlist(struct iaddrcidrnetlist **result)
int parse_lbrace(struct parse *cfile)
void parse_subnet6_declaration(struct parse *cfile, struct shared_network *share)
int make_concat(struct expression **expr, struct expression *left, struct expression *right)
TIME parse_date(struct parse *cfile)
struct expression * submatch
void dfree(void *, const char *, int)
void set_server_duid(struct data_string *new_duid)
isc_result_t add_ipv6_pool(struct ipv6_pool *pool)
int parse_ip6_addr(struct parse *cfile, struct iaddr *addr)
struct data_string host_id
int parse_ip_addr_or_hostname(struct expression **expr, struct parse *cfile, int uniform)
void set_server_duid_type(int type)
int parse_option_decl(struct option_cache **oc, struct parse *cfile)
isc_result_t conf_file_subparse(struct parse *cfile, struct group *group, int group_type)
struct ipv6_pool ** ipv6_pools
void skip_to_semi(struct parse *cfile)
int option_cache(struct option_cache **oc, struct data_string *dp, struct expression *expr, struct option *option, const char *file, int line)
void skip_to_rbrace(struct parse *cfile, int brace_count)
void new_address_range(struct parse *, struct iaddr, struct iaddr, struct subnet *, struct pool *, struct lease **)
isc_result_t find_failover_peer(dhcp_failover_state_t **, const char *, const char *, int)
int parse_on_statement(struct executable_statement **result, struct parse *cfile, int *lose)
struct shared_network * shared_network
isc_result_t ipv6_pool_dereference(struct ipv6_pool **pool, const char *file, int line)
de-reference an IPv6 pool structure.
isc_result_t find_ipv6_pool(struct ipv6_pool **pool, u_int16_t type, const struct in6_addr *addr)
int addr_eq(struct iaddr addr1, struct iaddr addr2)
struct executable_statement::@7::@9 on
char * parse_host_name(struct parse *cfile)
int parse_option_statement(struct executable_statement **result, struct parse *cfile, int lookups, struct option *option, enum statement_op op)
isc_result_t delete_class(struct class *, int)
isc_result_t enter_failover_peer(dhcp_failover_state_t *)
union executable_statement::@7 data
void parse_shared_net_declaration(struct parse *cfile, struct group *group)
void db_startup(int testp)
int parse_option_data(struct expression **expr, struct parse *cfile, int lookups, struct option *option)
union binding_value::value value
struct shared_network * shared_network
struct lease ** billed_leases
const char * path_dhcpd_conf
struct data_string const_data
u_int32_t host_addr(struct iaddr addr, struct iaddr mask)
void parse_address_range(struct parse *cfile, struct group *group, int type, struct pool *inpool, struct lease **lpchain)
int parse_ip6_addr_expr(struct expression **expr, struct parse *cfile)
struct iaddrcidrnetlist * fixed_prefix
struct group_object * named_group
struct binding * bindings
isc_result_t ipv6_pond_allocate(struct ipv6_pond **pond, const char *file, int line)
Create a new IPv6 pond structure.
isc_boolean_t is_cidr_mask_valid(const struct iaddr *addr, int bits)
int binding_scope_reference(struct binding_scope **ptr, struct binding_scope *bp, const char *file, int line)
binding_state_t rewind_binding_state
void parse_failover_state(struct parse *, enum failover_state *, TIME *)
void parse_host_declaration(struct parse *cfile, struct group *group)
int make_const_data(struct expression **expr, const unsigned char *data, unsigned len, int terminated, int allocate, const char *file, int line)
void parse_subnet_declaration(struct parse *cfile, struct shared_network *share)
void parse_failover_peer(struct parse *, struct group *, int)
void parse_address_range6(struct parse *cfile, struct group *group, struct ipv6_pond *)
#define SV_BOOT_UNKNOWN_CLIENTS
TIME parse_date_core(struct parse *cfile)
isc_result_t iasubopt_dereference(struct iasubopt **iasubopt, const char *file, int line)
struct binding_value * value
isc_result_t supersede_group(struct group_object *group, int writep)
isc_result_t find_class(struct class **c, const char *s, const char *file, int line)
void parse_prefix6(struct parse *cfile, struct group *group, struct ipv6_pond *)
struct option * host_id_option
isc_result_t ia_allocate(struct ia_xx **ia, u_int32_t iaid, const char *duid, unsigned int duid_len, const char *file, int line)
int option_chain_head_allocate(struct option_chain_head **ptr, const char *file, int line)
int parse_ip6_prefix(struct parse *cfile, struct iaddr *addr, u_int8_t *plen)
struct subnet * next_sibling
isc_result_t ia_add_iasubopt(struct ia_xx *ia, struct iasubopt *iasubopt, const char *file, int line)
struct interface_info * interface
isc_result_t ipv6_pond_dereference(struct ipv6_pond **pond, const char *file, int line)
de-reference an IPv6 pond structure.
void enter_subnet(struct subnet *)
isc_result_t enter_host(struct host_decl *, int, int)
void parse_ia_pd_declaration(struct parse *cfile)
group_hash_t * group_name_hash
struct executable_statement * statements
#define DHO_VENDOR_CLASS_IDENTIFIER
struct universe agent_universe
isc_result_t trace_get_file(trace_type_t *, const char *, unsigned *, char **)
struct ipv6_pool ** pools
char * piaddrcidr(const struct iaddr *addr, unsigned int bits)
option_code_hash_t * code_hash
void parse_server_duid(struct parse *cfile)
pair cons(caddr_t car, pair cdr)
struct executable_statement * on_expiry
struct binding * find_binding(struct binding_scope *scope, const char *name)
struct shared_network * shared_network
int parse_class_declaration(struct class **cp, struct parse *cfile, struct group *group, int type)
void new_shared_network_interface(struct parse *, struct shared_network *, const char *)
struct permit * permit_list
void putUShort(unsigned char *, u_int32_t)
isc_result_t trace_write_packet(trace_type_t *, unsigned, const char *, const char *, int)
isc_result_t range2cidr(struct iaddrcidrnetlist **result, const struct iaddr *lo, const struct iaddr *hi)
struct shared_network * shared_network
void trace_conf_stop(trace_type_t *ttype)
int parse_allow_deny(struct option_cache **oc, struct parse *cfile, int flag)
isc_result_t ia_reference(struct ia_xx **ia, struct ia_xx *src, const char *file, int line)
const unsigned char * data
struct binding_scope * scope
void data_string_copy(struct data_string *dest, const struct data_string *src, const char *file, int line)
isc_result_t ipv6_pool_reference(struct ipv6_pool **pool, struct ipv6_pool *src, const char *file, int line)
reference an IPv6 pool structure.
struct hardware interface
struct permit * permit_list
int parse_executable_statement(struct executable_statement **result, struct parse *cfile, int *lose, enum expression_context case_context)
void parse_hardware_param(struct parse *cfile, struct hardware *hardware)
int clone_group(struct group **gp, struct group *group, const char *file, int line)
int parse_warn(struct parse *cfile, const char *fmt,...)
binding_state_t next_binding_state
struct interface_info * interface
isc_result_t new_parse(struct parse **cfile, int file, char *inbuf, unsigned buflen, const char *name, int eolp)
void parse_pool_statement(struct parse *cfile, struct group *group, int type)
Parse a pool statement.
#define GROUP_OBJECT_STATIC
int option_dereference(struct option **dest, const char *file, int line)
#define SV_CLIENT_UPDATES