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;
1949 struct host_decl *host;
1951 int declaration = 0;
1954 isc_result_t status;
1961 parse_warn (cfile,
"expecting a name for host declaration.");
1966 host = (
struct host_decl *)0;
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)) {
2165 struct host_decl *hp = (
struct host_decl *)0;
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.");
2268 "implicit-vendor-class" :
"implicit-user-class";
2279 log_fatal (
"No memory for class name %s.", tname);
2280 strcpy (name, tname);
2294 class_dereference (&pc,
MDL);
2300 memcpy ((
char *)data.
buffer -> data, val,
2303 memset (&data, 0,
sizeof data);
2306 class_dereference (&pc,
MDL);
2310 parse_warn (cfile,
"Expecting string or hex list.");
2312 class_dereference (&pc,
MDL);
2320 class_hash_lookup (&
class, pc -> hash,
2327 status = subclass_allocate (&
class,
MDL);
2329 status = class_allocate (&
class,
MDL);
2333 class_reference (&
class -> superclass, pc,
MDL);
2334 class -> lease_limit = pc -> lease_limit;
2335 if (
class -> lease_limit) {
2336 class -> billed_leases =
2337 dmalloc (
class -> lease_limit *
2339 if (!
class -> billed_leases)
2341 memset (
class -> billed_leases, 0,
2342 (
class -> lease_limit *
2343 sizeof (
struct lease *)));
2348 log_fatal (
"No memory for subclass hash.");
2349 class_hash_add (pc -> hash,
2350 (
const char *)
class -> hash_string.data,
2351 class -> hash_string.len,
2352 (
void *)
class,
MDL);
2357 log_fatal (
"no memory to clone class group.");
2366 log_fatal (
"no memory for class statement.");
2367 stmt -> op = supersede_option_statement;
2370 stmt -> data.option -> data = data;
2374 option_code_hash_lookup(
2379 class -> statements = stmt;
2392 if (
class -> superclass) {
2394 if (token ==
SEMI) {
2398 status = class_reference (cp,
class,
MDL);
2399 class_dereference (&
class,
MDL);
2401 class_dereference (&pc,
MDL);
2402 return cp ? (status == ISC_R_SUCCESS) : 1;
2411 class_dereference (&
class,
MDL);
2413 class_dereference (&pc,
MDL);
2424 parse_warn (cfile,
"unexpected end of file");
2426 }
else if (token ==
DYNAMIC) {
2438 }
else if (token ==
MATCH) {
2441 "invalid match in subclass.");
2452 "one 'match if' clause.");
2463 "expecting boolean expr.");
2467 #if defined (DEBUG_EXPRESSION_PARSE) 2473 }
else if (token ==
SPAWN) {
2477 "invalid spawn in subclass.");
2481 class -> spawning = 1;
2483 if (token !=
WITH) {
2485 "expecting with after spawn");
2490 if (submatchedonce) {
2492 "can't override existing %s.",
2504 "expecting data expr.");
2508 #if defined (DEBUG_EXPRESSION_PARSE) 2514 }
else if (token ==
LEASE) {
2517 if (token !=
LIMIT) {
2530 class -> lease_limit = atoi (val);
2533 class -> billed_leases =
2534 dmalloc (
class -> lease_limit *
2536 if (!
class -> billed_leases)
2537 log_fatal (
"no memory for billed leases.");
2538 memset (
class -> billed_leases, 0,
2539 (
class -> lease_limit *
2540 sizeof (
struct lease *)));
2552 struct class *theclass = NULL;
2555 if (status == ISC_R_SUCCESS) {
2557 class_dereference(&theclass,
MDL);
2560 class_hash_delete(pc->hash,
2572 class_reference (&c ->
nic,
class,
MDL);
2577 status = class_reference (cp,
class,
MDL);
2578 class_dereference (&
class,
MDL);
2580 class_dereference (&pc,
MDL);
2581 return cp ? (status == ISC_R_SUCCESS) : 1;
2588 struct parse *cfile;
2589 struct group *group;
2595 int declaration = 0;
2596 isc_result_t status;
2599 status = shared_network_allocate (&share,
MDL);
2600 if (status != ISC_R_SUCCESS)
2601 log_fatal (
"Can't allocate shared subnet: %s",
2602 isc_result_totext (status));
2604 log_fatal (
"Can't clone group for shared net");
2610 token =
peek_token (&val, (
unsigned *)0, cfile);
2615 parse_warn (cfile,
"zero-length shared network name");
2616 val =
"<no-name-given>";
2620 log_fatal (
"no memory for shared network name");
2626 "expecting a name for shared-network");
2628 shared_network_dereference (&share,
MDL);
2632 share -> name =
name;
2635 shared_network_dereference (&share,
MDL);
2640 token =
peek_token (&val, (
unsigned *)0, cfile);
2645 "empty shared-network decl");
2648 shared_network_dereference (&share,
MDL);
2652 parse_warn (cfile,
"unexpected end of file");
2656 token =
next_token (&val, (
unsigned *)0, cfile);
2665 (
struct host_decl *)0,
2668 shared_network_dereference (&share,
MDL);
2673 common_subnet_parsing(
struct parse *cfile,
2677 struct subnet *t, *u;
2679 int declaration = 0;
2684 subnet_dereference(&subnet,
MDL);
2695 parse_warn (cfile,
"unexpected end of file");
2713 subnet_reference(&share->
subnets, subnet,
MDL);
2725 subnet_dereference(&share->
subnets,
2727 subnet_reference(&share->
subnets,
2730 subnet_dereference(&subnet,
MDL);
2737 subnet_dereference(&subnet,
MDL);
2745 struct parse *cfile;
2750 struct subnet *subnet;
2752 unsigned char addr [4];
2753 unsigned len =
sizeof addr;
2754 isc_result_t status;
2756 subnet = (
struct subnet *)0;
2757 status = subnet_allocate (&subnet,
MDL);
2758 if (status != ISC_R_SUCCESS)
2759 log_fatal (
"Allocation of new subnet failed: %s",
2760 isc_result_totext (status));
2775 log_fatal(
"Allocation of group for new subnet failed.");
2778 subnet_reference (&subnet -> group -> subnet, subnet,
MDL);
2782 subnet_dereference (&subnet,
MDL);
2785 memcpy (iaddr.
iabuf, addr, len);
2787 subnet ->
net = iaddr;
2789 token =
next_token (&val, (
unsigned *)0, cfile);
2798 subnet_dereference (&subnet,
MDL);
2801 memcpy (iaddr.
iabuf, addr, len);
2811 if (maskstr == NULL) {
2812 log_fatal(
"Allocation of subnet maskstr failed: %s",
2817 "subnet %s netmask %s: bad subnet number/mask combination.",
2820 subnet_dereference (&subnet,
MDL);
2825 common_subnet_parsing(cfile, share, subnet);
2833 #if !defined(DHCPv6) 2837 struct subnet *subnet;
2838 isc_result_t status;
2843 const static int mask[] = { 0x00, 0x80, 0xC0, 0xE0,
2844 0xF0, 0xF8, 0xFC, 0xFE };
2847 #if defined(DHCP4o6) 2849 parse_warn(cfile,
"subnet6 statement is only supported " 2850 "in DHCPv6 and DHCPv4o6 modes.");
2856 parse_warn(cfile,
"subnet6 statement is only supported " 2864 status = subnet_allocate(&subnet,
MDL);
2865 if (status != ISC_R_SUCCESS) {
2866 log_fatal(
"Allocation of new subnet failed: %s",
2867 isc_result_totext(status));
2883 log_fatal(
"Allocation of group for new subnet failed.");
2889 subnet_dereference(&subnet,
MDL);
2894 if (token !=
SLASH) {
2911 parse_warn(cfile,
"Expecting a number between 0 and 128.");
2917 parse_warn(cfile,
"New subnet mask too short.");
2927 if (ofs < subnet->netmask.len) {
2930 while (--ofs >= 0) {
2936 if (memcmp(&iaddr, &subnet->
net, 16) != 0) {
2938 "subnet %s/%d: prefix not long enough for address.",
2940 subnet_dereference(&subnet,
MDL);
2945 if (!common_subnet_parsing(cfile, share, subnet)) {
2954 struct parse *cfile;
2955 struct group *group;
2960 int declaration = 0;
2962 isc_result_t status;
2970 log_fatal(
"no memory for explicit group.");
2978 log_fatal(
"no memory for group decl name %s", val);
3000 }
else if (token ==
DYNAMIC) {
3004 }
else if (token ==
STATIC) {
3019 strlen(name),
MDL)) {
3025 status = group_object_allocate(&t,
MDL);
3026 if (status != ISC_R_SUCCESS)
3027 log_fatal(
"no memory for group decl %s: %s",
3028 val, isc_result_totext(status));
3037 group_object_dereference(&t,
MDL);
3047 struct parse *cfile,
3084 if (token ==
COMMA) {
3087 }
while (token ==
COMMA);
3121 unsigned char addr [4];
3122 unsigned len =
sizeof addr;
3130 int noequal, newbinding;
3133 isc_result_t status;
3137 unsigned buflen = 0;
3138 struct class *
class;
3140 lease = (
struct lease *)0;
3141 status = lease_allocate (&lease,
MDL);
3142 if (status != ISC_R_SUCCESS)
3147 lease_dereference (&lease,
MDL);
3154 lease_dereference (&lease,
MDL);
3159 token =
next_token (&val, (
unsigned *)0, cfile);
3163 parse_warn (cfile,
"unexpected end of file");
3166 strncpy (tbuf, val,
sizeof tbuf);
3167 tbuf [(
sizeof tbuf) - 1] = 0;
3219 token =
peek_token (&val, (
unsigned *)0, cfile);
3221 unsigned char *tuid;
3223 if (buflen < sizeof lease ->
uid_buf) {
3228 tuid = ((
unsigned char *)
3232 lease_dereference (&lease,
3239 memcpy (tuid, val, lease ->
uid_len);
3240 lease ->
uid = tuid;
3244 (cfile, (
unsigned char *)0,
3245 &buflen,
':', 16, 8));
3246 if (!lease ->
uid) {
3247 lease_dereference (&lease,
MDL);
3253 lease ->
uid = (
unsigned char *)0;
3261 if (!lease ->
uid) {
3268 token =
next_token (&val, (
unsigned *)0, cfile);
3272 lease_dereference (&lease,
MDL);
3307 token =
next_token (&val, (
unsigned *)0, cfile);
3313 goto do_binding_state;
3323 goto do_binding_state;
3329 token =
next_token (&val, (
unsigned *)0, cfile);
3330 if (token !=
STATE) {
3335 token =
next_token (&val, (
unsigned *)0, cfile);
3373 "%s: expecting a binding state.",
3379 if (seenbit == 256) {
3388 if (!(seenmask & 128))
3392 if (!(seenmask & 512))
3394 }
else if (seenbit == 128)
3396 else if (seenbit == 512)
3399 log_fatal(
"Impossible condition at %s:%d.",
3407 token =
peek_token (&val, (
unsigned *)0, cfile);
3412 lease_dereference (&lease,
MDL);
3422 "expecting a hostname.");
3424 lease_dereference (&lease,
MDL);
3432 class = (struct class *)0;
3433 token =
next_token (&val, (
unsigned *)0, cfile);
3434 if (token ==
CLASS) {
3436 (
unsigned *)0, cfile);
3444 if (lease -> billing_class)
3445 class_dereference (&lease -> billing_class,
3450 "unknown class %s", val);
3453 if (lease -> billing_class)
3454 class_dereference (&lease -> billing_class,
3464 class_reference (&lease -> billing_class,
3466 class_dereference (&
class,
MDL);
3475 lease_dereference (&lease,
MDL);
3480 on->
data.
on.statements) {
3487 on->
data.
on.statements) {
3505 "agent option expected.");
3512 log_error (
"no memory to stash agent option");
3516 *p; p = &((*p) -> cdr))
3520 &((*p) -> car)), oc,
MDL);
3528 token =
next_token (&val, (
unsigned *)0, cfile);
3531 "%s can't be a variable name",
3535 lease_dereference (&lease,
MDL);
3544 binding = (
struct binding *)0;
3547 if (!lease -> scope)
3549 (&lease -> scope,
MDL)))
3555 memset (binding, 0,
sizeof *binding);
3558 if (!binding ->
name)
3561 strcpy (binding ->
name, val);
3569 log_fatal(
"no memory for binding value.");
3572 token =
next_token (&val, (
unsigned *)0, cfile);
3573 if (token !=
EQUAL) {
3575 "expecting '=' in set statement.");
3580 if (!parse_binding_value(cfile, nv)) {
3582 lease_dereference(&lease,
MDL);
3603 if (!strcasecmp (val,
"ddns-fwd-name")) {
3607 }
else if (!strcasecmp (val,
"ddns-rev-name")) {
3612 parse_warn(cfile,
"Unexpected configuration " 3616 lease_dereference (&lease,
MDL);
3620 if (seenmask & seenbit) {
3622 "Too many %s parameters in lease %s\n",
3625 seenmask |= seenbit;
3630 if (!(seenmask & 256)) {
3634 #if defined (FAILOVER_PROTOCOL) 3641 #if defined (FAILOVER_PROTOCOL) 3654 if (!(seenmask & 65536))
3657 lease_reference (lp, lease,
MDL);
3658 lease_dereference (&lease,
MDL);
3677 if ((cfile == NULL) || (value == NULL))
3684 value->
type = binding_data;
3697 value->
type = binding_data;
3717 }
else if (token ==
PERCENT) {
3721 parse_warn(cfile,
"expecting decimal number.");
3726 value->
type = binding_numeric;
3728 }
else if (token ==
NAME) {
3730 value->
type = binding_boolean;
3731 if (!strcasecmp(val,
"true"))
3733 else if (!strcasecmp(val,
"false"))
3736 parse_warn(cfile,
"expecting true or false");
3742 parse_warn (cfile,
"expecting a constant value.");
3755 struct parse *cfile;
3756 struct group *group;
3758 struct pool *inpool;
3759 struct lease **lpchain;
3761 struct iaddr low, high, net;
3762 unsigned char addr [4];
3763 unsigned len =
sizeof addr;
3767 struct subnet *subnet;
3770 isc_result_t status;
3781 memcpy (low.
iabuf, addr, len);
3785 token =
peek_token (&val, (
unsigned *)0, cfile);
3792 memcpy (high.
iabuf, addr, len);
3796 token =
next_token (&val, (
unsigned *)0, cfile);
3797 if (token !=
SEMI) {
3804 subnet = group -> subnet;
3808 for (subnet = share ->
subnets;
3809 subnet; subnet = subnet -> next_sibling) {
3811 if (
addr_eq (net, subnet -> net))
3815 parse_warn (cfile,
"address range not on network %s",
3817 log_error (
"Be sure to place pool statement after %s",
3818 "related subnet declarations.");
3824 struct pool *last = (
struct pool *)0;
3829 for (pool = share ->
pools; pool; pool = pool ->
next) {
3834 permit_dynamic_bootp_clients)) ||
3839 permit_all_clients))) {
3848 status = pool_allocate (&pool,
MDL);
3849 if (status != ISC_R_SUCCESS)
3850 log_fatal (
"no memory for ad-hoc pool: %s",
3851 isc_result_totext (status));
3854 log_fatal (
"no memory for ad-hoc permit.");
3860 pool -> permit_list = p;
3863 pool -> prohibit_list = p;
3867 pool_reference (&last ->
next, pool,
MDL);
3869 pool_reference (&share ->
pools, pool,
MDL);
3873 log_fatal (
"no memory for anon pool group.");
3875 pool = (
struct pool *)0;
3877 pool_reference (&pool, last,
MDL);
3879 pool_reference (&pool, share ->
pools,
MDL);
3882 pool = (
struct pool *)0;
3883 pool_reference (&pool, inpool,
MDL);
3886 #if defined (FAILOVER_PROTOCOL) 3890 parse_warn (cfile,
"dynamic-bootp flag is %s",
3891 "not permitted for address");
3892 log_error (
"range declarations where there is a failover");
3893 log_error (
"peer in scope. If you wish to declare an");
3894 log_error (
"address range from which dynamic bootp leases");
3895 log_error (
"can be allocated, please declare it within a");
3896 log_error (
"pool declaration that also contains the \"no");
3897 log_error (
"failover\" statement. The failover protocol");
3898 log_error (
"itself does not permit dynamic bootp - this");
3899 log_error (
"is not a limitation specific to the ISC DHCP");
3900 log_error (
"server. Please don't ask me to defend this");
3901 log_error (
"until you have read and really tried %s",
3903 log_error (
"the failover protocol specification.");
3913 pool_dereference (&pool,
MDL);
3918 add_ipv6_pool_to_subnet(
struct subnet *subnet, u_int16_t type,
3919 struct iaddr *lo_addr,
int bits,
int units,
3922 struct in6_addr tmp_in6_addr;
3929 if (lo_addr->
len !=
sizeof(tmp_in6_addr)) {
3930 log_fatal(
"Internal error: Attempt to add non-IPv6 address " 3931 "to IPv6 shared network.");
3933 memcpy(&tmp_in6_addr, lo_addr->
iabuf,
sizeof(tmp_in6_addr));
3936 bits, units,
MDL) != ISC_R_SUCCESS) {
3951 subnet_reference(&pool->
subnet, subnet,
MDL);
3965 while (pond->
ipv6_pools[num_pools] != NULL) {
3973 if (num_pools > 0) {
3975 sizeof(
struct ipv6_pool *) * num_pools);
4003 if ((units - bits) > (
sizeof(isc_uint64_t) * 8)) {
4008 isc_uint64_t space_left
4011 = (isc_uint64_t)(1) << (units -
bits);
4013 if (addon > space_left) {
4050 add_ipv6_pond_to_network(
struct group *group,
4053 struct ipv6_pond *pond = NULL, *last = NULL;
4055 isc_result_t status;
4072 if (status != ISC_R_SUCCESS)
4073 log_fatal (
"no memory for ad-hoc ipv6 pond: %s",
4074 isc_result_totext (status));
4077 log_fatal (
"no memory for ad-hoc ipv6 permit.");
4080 p->
type = permit_all_clients;
4093 log_fatal (
"no memory for anon pool group.");
4106 struct group *group,
4108 struct iaddr lo, hi;
4118 parse_warn(cfile,
"range6 statement is only supported " 4125 if (group->
subnet == NULL)
4138 parse_warn(cfile,
"range6 start address is outside the subnet");
4146 memset(&net, 0,
sizeof(net));
4153 if (token ==
SLASH) {
4166 if ((bits < 0) || (bits > 128)) {
4167 parse_warn(cfile,
"networks have 0 to 128 bits");
4173 "network mask smaller than subnet mask");
4188 parse_warn(cfile,
"temporary mask too short");
4226 "range6 end address is outside the subnet");
4235 if (
range2cidr(&nets, &lo, &hi) != ISC_R_SUCCESS) {
4236 log_fatal(
"Error converting range to CIDR networks");
4247 if (inpond != NULL) {
4250 add_ipv6_pond_to_network(group, &pond);
4254 for (p=nets; p != NULL; p=p->
next) {
4255 add_ipv6_pool_to_subnet(group->
subnet, type,
4267 if (token !=
SEMI) {
4278 struct group *group,
4280 struct iaddr lo, hi;
4289 parse_warn(cfile,
"prefix6 statement is only supported " 4296 if (group->
subnet == NULL)
4316 " is outside the subnet");
4336 " is outside the subnet");
4346 if (token !=
SLASH) {
4360 if ((bits <= 0) || (bits >= 128)) {
4361 parse_warn(cfile,
"networks have 0 to 128 bits (exclusive)");
4372 parse_warn(cfile,
"network mask smaller than subnet mask");
4385 if (token !=
SEMI) {
4395 if (
range2cidr(&nets, &lo, &hi) != ISC_R_SUCCESS) {
4396 log_fatal(
"Error converting prefix to CIDR");
4405 if (inpond != NULL) {
4408 add_ipv6_pond_to_network(group, &pond);
4411 for (p = nets; p != NULL; p = p->
next) {
4444 while (*h != NULL) {
4464 if (token !=
SLASH) {
4480 if (token !=
SEMI) {
4493 parse_warn(cfile,
"networks have 0 to 128 bits");
4529 struct parse *cfile;
4530 struct group *group;
4537 int declaration = 0;
4538 isc_result_t status;
4542 if (status != ISC_R_SUCCESS)
4544 isc_result_totext (status));
4551 parse_warn(cfile,
"pool6s are only valid inside " 4552 "subnet statements.");
4625 for (; *p; p = &((*p)->next))
4632 parse_warn (cfile,
"Pool6 declaration with no %s.",
4633 "address range6 or prefix6");
4634 log_error (
"Pool6 declarations must always contain at least");
4635 log_error (
"one range6 or prefix6 statement.");
4653 struct parse *cfile;
4658 unsigned char rf = flag;
4667 token =
next_token (&val, (
unsigned *)0, cfile);
4702 parse_warn (cfile,
"expecting allow/deny key");
4710 log_fatal(
"Unable to find server option %u (%s:%d).",
4720 #if !defined(DHCPv6) 4725 struct ia_xx *ia = NULL;
4727 struct ia_xx *old_ia;
4736 char addr_buf[
sizeof(
"ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")];
4737 isc_boolean_t newbinding;
4745 parse_warn(cfile,
"IA_NA is only supported in DHCPv6 mode.");
4750 if (!parse_iaid_duid(cfile, &ia, &iaid,
MDL)) {
4758 parse_warn(cfile,
"corrupt lease file; expecting left brace");
4765 if (token ==
RBRACE)
break;
4767 if (token ==
CLTT) {
4774 "expecting IAADDR or right brace");
4781 "expecting IPv6 address");
4789 "expecting left brace");
4799 if (token ==
RBRACE)
break;
4808 "unexpected end of file");
4814 if (token !=
STATE) {
4848 if (token !=
SEMI) {
4865 prefer = atoi (val);
4874 if (token ==
SEMI) {
4878 "corrupt lease file; " 4879 "expecting semicolon.");
4902 if (token ==
SEMI) {
4906 "corrupt lease file; " 4907 "expecting semicolon.");
4919 if ((token !=
NAME) &&
4951 if (bnd->
name == NULL) {
4955 strcpy(bnd->
name, val);
4957 newbinding = ISC_TRUE;
4959 newbinding = ISC_FALSE;
4968 if (token !=
EQUAL) {
4974 if (!parse_binding_value(cfile, nv)) {
5006 if (on_star[0] == NULL) {
5034 "expecting ia_na contents, " 5043 "missing state in iaaddr");
5046 if (end_time == -1) {
5048 "missing end time in iaaddr");
5053 if (iasubopt_allocate(&iaaddr,
MDL) != ISC_R_SUCCESS) {
5058 iaaddr->
state = state;
5060 iaaddr->
valid = valid;
5064 if (scope != NULL) {
5076 (i < 2) && on_star[i] != NULL ;
5079 on_star[i]->
data.
on.statements) {
5085 on_star[i]->
data.
on.statements) {
5096 &iaaddr->
addr) != ISC_R_SUCCESS) {
5097 inet_ntop(AF_INET6, &iaaddr->
addr,
5098 addr_buf,
sizeof(addr_buf));
5099 log_error(
"No pool found for IA_NA address %s",
5107 iaaddr, ia) != ISC_R_SUCCESS) {
5108 inet_ntop(AF_INET6, &iaaddr->
addr,
5109 addr_buf,
sizeof(addr_buf));
5110 parse_warn(cfile,
"duplicate na lease for address %s",
5156 #if !defined(DHCPv6) 5161 struct ia_xx *ia = NULL;
5163 struct ia_xx *old_ia;
5172 char addr_buf[
sizeof(
"ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")];
5173 isc_boolean_t newbinding;
5181 parse_warn(cfile,
"IA_TA is only supported in DHCPv6 mode.");
5186 if (!parse_iaid_duid(cfile, &ia, &iaid,
MDL)) {
5194 parse_warn(cfile,
"corrupt lease file; expecting left brace");
5201 if (token ==
RBRACE)
break;
5203 if (token ==
CLTT) {
5210 "expecting IAADDR or right brace");
5217 "expecting IPv6 address");
5225 "expecting left brace");
5235 if (token ==
RBRACE)
break;
5244 "unexpected end of file");
5250 if (token !=
STATE) {
5284 if (token !=
SEMI) {
5301 prefer = atoi (val);
5310 if (token ==
SEMI) {
5314 "corrupt lease file; " 5315 "expecting semicolon.");
5338 if (token ==
SEMI) {
5342 "corrupt lease file; " 5343 "expecting semicolon.");
5355 if ((token !=
NAME) &&
5387 if (bnd->
name == NULL) {
5391 strcpy(bnd->
name, val);
5393 newbinding = ISC_TRUE;
5395 newbinding = ISC_FALSE;
5404 if (token !=
EQUAL) {
5410 if (!parse_binding_value(cfile, nv)) {
5442 if (on_star[0] == NULL) {
5470 "expecting ia_ta contents, " 5479 "missing state in iaaddr");
5482 if (end_time == -1) {
5484 "missing end time in iaaddr");
5489 if (iasubopt_allocate(&iaaddr,
MDL) != ISC_R_SUCCESS) {
5494 iaaddr->
state = state;
5496 iaaddr->
valid = valid;
5500 if (scope != NULL) {
5512 (i < 2) && on_star[i] != NULL ;
5515 on_star[i]->
data.
on.statements) {
5521 on_star[i]->
data.
on.statements) {
5532 &iaaddr->
addr) != ISC_R_SUCCESS) {
5533 inet_ntop(AF_INET6, &iaaddr->
addr,
5534 addr_buf,
sizeof(addr_buf));
5535 log_error(
"No pool found for IA_TA address %s",
5543 iaaddr, ia) != ISC_R_SUCCESS) {
5544 inet_ntop(AF_INET6, &iaaddr->
addr,
5545 addr_buf,
sizeof(addr_buf));
5546 parse_warn(cfile,
"duplicate ta lease for address %s",
5592 #if !defined(DHCPv6) 5597 struct ia_xx *ia = NULL;
5599 struct ia_xx *old_ia;
5609 char addr_buf[
sizeof(
"ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")];
5610 isc_boolean_t newbinding;
5618 parse_warn(cfile,
"IA_PD is only supported in DHCPv6 mode.");
5623 if (!parse_iaid_duid(cfile, &ia, &iaid,
MDL)) {
5631 parse_warn(cfile,
"corrupt lease file; expecting left brace");
5638 if (token ==
RBRACE)
break;
5640 if (token ==
CLTT) {
5646 parse_warn(cfile,
"corrupt lease file; expecting " 5647 "IAPREFIX or right brace");
5654 "expecting IPv6 prefix");
5662 "expecting left brace");
5672 if (token ==
RBRACE)
break;
5681 "unexpected end of file");
5687 if (token !=
STATE) {
5721 if (token !=
SEMI) {
5738 prefer = atoi (val);
5747 if (token ==
SEMI) {
5751 "corrupt lease file; " 5752 "expecting semicolon.");
5775 if (token ==
SEMI) {
5779 "corrupt lease file; " 5780 "expecting semicolon.");
5792 if ((token !=
NAME) &&
5824 if (bnd->
name == NULL) {
5828 strcpy(bnd->
name, val);
5830 newbinding = ISC_TRUE;
5832 newbinding = ISC_FALSE;
5841 if (token !=
EQUAL) {
5847 if (!parse_binding_value(cfile, nv)) {
5879 if (on_star[0] == NULL) {
5907 "expecting ia_pd contents, " 5916 "missing state in iaprefix");
5919 if (end_time == -1) {
5921 "missing end time in iaprefix");
5926 if (iasubopt_allocate(&iapref,
MDL) != ISC_R_SUCCESS) {
5930 iapref->
plen = plen;
5931 iapref->
state = state;
5933 iapref->
valid = valid;
5937 if (scope != NULL) {
5949 (i < 2) && on_star[i] != NULL ;
5952 on_star[i]->
data.
on.statements) {
5958 on_star[i]->
data.
on.statements) {
5970 &iapref->
addr) != ISC_R_SUCCESS) ||
5972 inet_ntop(AF_INET6, &iapref->
addr,
5973 addr_buf,
sizeof(addr_buf));
5974 log_error(
"No pool found for prefix %s/%d", addr_buf,
5982 iapref, ia) != ISC_R_SUCCESS) {
5983 inet_ntop(AF_INET6, &iapref->
addr,
5984 addr_buf,
sizeof(addr_buf));
5985 parse_warn(cfile,
"duplicate pd lease for address %s",
6045 unsigned char bytes[128];
6048 len =
parse_X(cfile, bytes,
sizeof(bytes));
6055 memset(&duid, 0x0,
sizeof(duid));
6057 log_fatal(
"parse_server_duid: out of memory");
6086 u_int32_t enterprise_number;
6113 parse_warn(cfile,
"enterprise number expected");
6117 enterprise_number = atoi(val);
6129 memset(&duid, 0,
sizeof(duid));
6132 log_fatal(
"Out of memory storing DUID");
6150 else if (token ==
LL) {
6173 memset(&ll_addr, 0,
sizeof(ll_addr));
6181 memset(&duid, 0,
sizeof(duid));
6182 duid.
len = 2 + 2 + ll_addr.
len;
6184 log_fatal(
"Out of memory storing DUID");
6205 else if (token ==
LLT) {
6235 llt_time = atoi(val);
6237 memset(&ll_addr, 0,
sizeof(ll_addr));
6245 memset(&duid, 0,
sizeof(duid));
6246 duid.
len = 2 + 2 + 4 + ll_addr.
len;
6248 log_fatal(
"Out of memory storing DUID");
6272 else if (token ==
NUMBER) {
6273 duid_type_num = atoi(val);
6285 memset(&duid, 0,
sizeof(duid));
6288 log_fatal(
"Out of memory storing DUID");
6302 parse_warn(cfile,
"DUID type of LLT, EN, or LL expected");
6311 if (token !=
SEMI) {
6335 memcpy(&value, source, 4);
6339 "authoring-byte-order not in the lease file.\n" 6340 "Assuming file byte order matches this server.\n");
6345 value = (((value >> 24) & 0xff) |
6346 ((value << 8) & 0xff0000) |
6347 ((value >> 8) & 0xff00) |
6348 ((value << 24) & 0xff000000));
6369 parse_iaid_duid(
struct parse* cfile,
struct ia_xx** ia, u_int32_t *iaid,
6371 unsigned char bytes[132];
6375 log_error(
"parse_iaid_duid: ia ptr cannot be null");
6380 len =
parse_X(cfile, bytes,
sizeof(bytes));
6383 "iaid+ia_xx string too short");
6392 if (
ia_allocate(ia, *iaid, (
const char*)bytes + 4, len - 4, file, line)
6394 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)
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)
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)
trace_type_t * trace_type_register(const char *, void *, void(*)(trace_type_t *, unsigned, char *), void(*)(trace_type_t *), const char *, int)
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 * dmalloc(size_t, const char *, int)
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