34static void maybe_return_agent_options(
struct packet *
packet,
45#if defined(DHCPv6) && defined(DHCP4o6)
51#if defined(DELAYED_ACK)
67static char dhcp_message [256];
68static int site_code_min;
70static int find_min_site_code(
struct universe *);
71static isc_result_t lowest_site_code(
const void *,
unsigned,
void *);
73static const char *dhcp_type_names [] = {
84 "DHCPLEASEUNASSIGNED",
91# define send_packet trace_packet_send
103 memset (&client_identifier, 0,
sizeof client_identifier);
118 return "\"no client id\"";
146 errmsg =
"unknown network segment";
158#if defined(DHCPv6) && defined(DHCP4o6)
160 log_info(
"DHCP4o6 %s from %s via %s: %s",
s,
165 :
"<no identifier>"),
175 :
"<no identifier>"),
213 sizeof packet -> raw -> ciaddr);
228 if (
lease -> uid_len) {
238 memset (&data, 0,
sizeof data);
253 if ((
lease -> hardware_addr.hbuf [0] !=
254 packet -> raw -> htype) ||
255 (
lease -> hardware_addr.hlen - 1 !=
288 switch (
packet -> packet_type) {
322 errmsg =
"unknown packet type";
339#if defined (FAILOVER_PROTOCOL)
351 s =
"Hostname Unsuitable for Printing";
358#if defined(DHCPv6) && defined(DHCP4o6)
361 "DHCP4o6 DHCPDISCOVER from %s %s%s%svia %s",
368 :
"<no identifier>")),
369 s ?
"(" :
"",
s ?
s :
"",
s ?
") " :
"",
378 :
"<no identifier>")),
379 s ?
"(" :
"",
s ?
s :
"",
s ?
") " :
"",
382 :
packet ->
interface -> name);
386#if defined(DHCPv6) && defined(DHCP4o6)
388 log_info (
"DHCP4o6 packet from unknown subnet: %s",
392 log_info (
"Packet from unknown subnet: %s",
397#if defined (FAILOVER_PROTOCOL)
419#if defined (DEBUG_FIND_LEASE)
435 log_error (
"%s: peer holds all free leases",
438 log_error (
"%s: network %s: no free leases",
445#if defined (FAILOVER_PROTOCOL)
461 log_debug (
"%s: load balance to peer %s",
465 log_debug (
"%s: cancel load balance to peer %s - %s",
479 when =
lease -> ends;
503#if defined (FAILOVER_PROTOCOL)
540 s =
"Hostname Unsuitable for Printing";
546 memset (&data, 0,
sizeof data);
567#if defined(DHCPv6) && defined(DHCP4o6)
570 "DHCP4o6 DHCPREQUEST for %s%s from %s %s%s%svia %s",
578 :
"<no identifier>")),
579 s ?
"(" :
"",
s ?
s :
"",
s ?
") " :
"",
584 "DHCPREQUEST for %s%s from %s %s%s%svia %s",
590 :
"<no identifier>")),
591 s ?
"(" :
"",
s ?
s :
"",
s ?
") " :
"",
594 :
packet ->
interface -> name);
596#if defined (FAILOVER_PROTOCOL)
643 ?
"released" :
"expired");
750 (
packet -> raw -> ciaddr.s_addr &&
766 ?
"not authoritative" :
"unknown subnet"));
827 log_info (
"DHCPRELEASE from %s specified requested-address.",
876 (
lease -> hardware_addr.hlen !=
packet -> raw -> hlen + 1 ||
877 lease -> hardware_addr.hbuf [0] !=
packet -> raw -> htype ||
885 s =
lease -> client_hostname;
887 s =
"Hostname Unsuitable for Printing";
901#if defined(DHCPv6) && defined(DHCP4o6)
904 "DHCP4o6 DHCPRELEASE of %s from %s %s%s%svia "
913 :
"<no identifier>")),
914 s ?
"(" :
"",
s ?
s :
"",
s ?
") " :
"",
916 lease ?
"" :
"not ");
920 "DHCPRELEASE of %s from %s %s%s%svia %s (%sfound)",
926 :
"<no identifier>")),
927 s ?
"(" :
"",
s ?
s :
"",
s ?
") " :
"",
930 :
packet ->
interface -> name,
931 lease ?
"" : "not ");
933#if defined (FAILOVER_PROTOCOL)
957#if defined(FAILOVER_PROTOCOL)
999 s =
lease -> client_hostname;
1001 s =
"Hostname Unsuitable for Printing";
1008#if defined(DHCPv6) && defined(DHCP4o6)
1011 "DHCP4o6 DHCPDECLINE of %s from %s %s%s%svia %s",
1019 :
"<no identifier>")),
1020 s ?
"(" :
"",
s ?
s :
"",
s ?
") " :
"",
1025 "DHCPDECLINE of %s from %s %s%s%svia %s",
1031 :
"<no identifier>")),
1032 s ?
"(" :
"",
s ?
s :
"",
s ?
") " :
"",
1035 :
packet ->
interface -> name);
1048 for (
i =
packet -> class_count;
i > 0;
i--) {
1060 packet -> options, options,
1064#if defined (FAILOVER_PROTOCOL)
1084 status =
"abandoned";
1086 status =
"not found";
1094#if defined(FAILOVER_PROTOCOL)
1103#if defined(RELAY_PORT)
1138#if defined(RELAY_PORT)
1141#if defined (DEBUG_INFORM_HOST)
1183#if defined(DHCPv6) && defined(DHCP4o6)
1186 "DHCP4o6 DHCPINFORM from %s via %s",
1203#if defined(RELAY_PORT)
1225 log_info(
"%s: ignored (invalid subnet selection option).",
msgbuf);
1240 oc->expression,
MDL);
1257 log_info(
"%s: unknown subnet for %s address %s",
1269 log_info(
"%s: not authoritative for subnet %s",
1272 log_info(
"If this DHCP server is authoritative for%s",
1274 log_info(
"please write an `authoritative;' directi%s",
1275 "ve either in the");
1276 log_info(
"subnet declaration or in some scope that%s",
1278 log_info(
"subnet declaration - for example, write %s",
1280 log_info(
"of the dhcpd.conf file.");
1290 memset(&raw, 0,
sizeof raw);
1293 maybe_return_agent_options(
packet, options);
1359#if defined (DEBUG_INFORM_HOST)
1361 log_debug (
"dhcpinform: found host by ID "
1362 "-- checking fixed-address match");
1370 memset(&fixed_addr, 0,
sizeof(fixed_addr));
1374 h->fixed_addr,
MDL))
1377#if defined (DEBUG_INFORM_HOST)
1381 (
i +
cip.len) <= fixed_addr.
len;
1384 cip.iabuf,
cip.len) == 0) {
1385#if defined (DEBUG_INFORM_HOST)
1387 "host with matching "
1388 "fixed-address by ID");
1403#if defined (DEBUG_INFORM_HOST)
1405 "without fixed-address by ID");
1418#if defined (DEBUG_INFORM_HOST)
1420 log_debug (
"dhcpinform: found host by HW "
1421 "-- checking fixed-address match");
1430 memset (&fixed_addr, 0,
sizeof(fixed_addr));
1434 h->fixed_addr,
MDL))
1437#if defined (DEBUG_INFORM_HOST)
1441 (
i +
cip.len) <= fixed_addr.
len;
1444 cip.iabuf,
cip.len) == 0) {
1445#if defined (DEBUG_INFORM_HOST)
1447 "host with matching "
1448 "fixed-address by HW");
1469#if defined (DEBUG_INFORM_HOST)
1470 log_debug (
"dhcpinform: found host without "
1471 "fixed-address by HW");
1481#if defined (DEBUG_INFORM_HOST)
1487 log_info (
"dhcpinform: matching host with "
1488 "fixed-address different than "
1489 "client IP detected?!");
1497#if defined (DEBUG_INFORM_HOST)
1498 log_info (
"dhcpinform: applying host (group) options");
1519 if (
i >=
sizeof(raw.
file)) {
1520 log_info(
"file name longer than packet field "
1521 "truncated - field: %lu name: %d %.*s",
1522 (
unsigned long)
sizeof(raw.
file),
i,
1524 i =
sizeof(raw.
file);
1539 if (
i >=
sizeof(raw.
sname)) {
1540 log_info(
"server name longer than packet field "
1541 "truncated - field: %lu name: %d %.*s",
1542 (
unsigned long)
sizeof(raw.
sname),
i,
1556 if (!
oc->expression)
1601 packet -> options, options,
1606 (
const char *)
d1.data,
d1.len,
1616 options -> site_universe = u ->
index;
1641 packet -> options, options,
1656 packet -> options, options,
1660 if (
d1.len >= 4 &&
d1.data)
1705#if defined(DHCPv6) && defined(DHCP4o6)
1709 "DHCP4o6 DHCPACK to %s (%s) via",
piaddr(
cip),
1713 "<no client hardware address>");
1721 log_fatal(
"No memory to store DHCP4o6 reply.");
1738 to.sin_len =
sizeof to;
1740 memset (to.sin_zero, 0,
sizeof to.sin_zero);
1762#if defined(RELAY_PORT)
1778 "<no client hardware address>");
1786 outgoing.packet_length, from, &to, NULL);
1788 log_error ("%s:%d: Failed to send %d byte long packet over %s "
1789 "interface.", MDL, outgoing.packet_length,
1822#if defined(RELAY_PORT)
1831 memset (&raw, 0,
sizeof raw);
1836 log_error (
"No memory for DHCPNAK message type.");
1842 log_error (
"No memory for expr_const expression.");
1853#if defined(RELAY_PORT)
1859 log_error (
"No memory for DHCPNAK message type.");
1864 (
unsigned char *)dhcp_message,
1866 log_error (
"No memory for expr_const expression.");
1882#if defined(SERVER_ID_FOR_NAK)
1950#if defined(DHCPv6) && defined(DHCP4o6)
1952 log_info (
"DHCP4o6 DHCPNAK on %s to %s via %s",
1956 packet -> raw -> chaddr),
1960 log_info (
"DHCPNAK on %s to %s via %s",
1965 :
packet ->
interface -> name);
1974#if defined(DHCPv6) && defined(DHCP4o6)
1981 log_fatal(
"No memory to store DHCP4o6 reply.");
1994 to.sin_len =
sizeof to;
1996 memset (to.sin_zero, 0,
sizeof to.sin_zero);
2001 to.sin_addr = raw.
giaddr;
2003#if defined(RELAY_PORT)
2016 log_error (
"%s:%d: Failed to send %d byte long "
2017 "packet over %s interface.",
MDL,
2033 log_error (
"%s:%d: Failed to send %d byte long packet over %s "
2146 log_error(
"Pool threshold reset - shared subnet: %s; "
2147 "address: %s; low threshold %d/%d.",
2176 log_error(
"Pool threshold exceeded - shared subnet: %s; "
2177 "address: %s; high threshold %d%% %d/%d.",
2226#if defined(DELAYED_ACK)
2247 else if (
lease -> host)
2253 log_fatal (
"unable to allocate lease state!");
2254 state -> got_requested_address =
packet -> got_requested_address;
2261 state -> got_server_identifier = 1;
2301 for (
i =
packet -> class_count;
i > 0;
i--) {
2327 state -> options, &
lease -> scope,
2373 !
host -> client_identifier.len &&
2434 log_info(
"%s: configured min-secs value (%d) "
2435 "is greater than secs field (%d). "
2436 "message dropped.",
msg,
d1.data[0],
2467 packet -> options, state -> options,
2580 if (
lease -> billing_class) {
2581 for (
i = 0;
i <
packet -> class_count;
i++)
2583 lease -> billing_class)
2585 if (
i ==
packet -> class_count) {
2617 log_info(
"%s: no available billing: lease "
2618 "limit reached in all matching "
2619 "classes (last: '%s')",
msg,
cname);
2652 packet -> options, state -> options,
2661 packet -> options, state -> options,
2670 log_info (
"%s: can't allocate temporary lease structure: %s",
2715 if (
s1 && (
d1.len == 4)) {
2753 "reservation made on %s.",
2813 if (
d1.len == 1 &&
d1.data[0] > 0 &&
2832 total / (count / 100) :
2833 (total * 100) / count;
2835 log_debug(
"Adap-lease: Total: %d, Free: %d, "
2836 "Ends: %d, Adaptive: %d, Fill: %d, "
2846 log_info(
"Pool over threshold, time "
2847 "for %s reduced from %d to "
2922#if defined (FAILOVER_PROTOCOL)
2975 if (
lt->tstp <
lt->tsfp)
2976 lt->tsfp =
lt->tstp;
3063 if (
d1.len <=
sizeof(
lt->uid_buf)) {
3065 lt->uid =
lt->uid_buf;
3066 lt->uid_max =
sizeof(
lt->uid_buf);
3067 lt->uid_len =
d1.len;
3069 unsigned char *
tuid;
3070 lt->uid_max =
d1.len;
3071 lt->uid_len =
d1.len;
3171 }
else if (
oc &&
s1) {
3174 log_error (
"no memory for client hostname.");
3188 sizeof packet -> raw -> chaddr);
3196 log_debug (
"Cannot reuse: lease is changing to RESERVED");
3215 if ((!offer || offer ==
DHCPACK) &&
3235 sizeof packet -> raw -> chaddr);
3247#if !defined(DELAYED_ACK)
3278 !offer || offer ==
DHCPACK, 0, 0)) {
3298 state -> offer = offer;
3331 state -> max_message_size =
3362 if (state -> offer) {
3367 &state -> offer, 1, 0, 0,
MDL)) {
3372 state -> options,
oc);
3380 state->
from.
len =
sizeof(from);
3383 state -> offered_expiry -
cur_time;
3395 state -> options,
oc);
3435 if (state ->
ip -> address_count) {
3437 sizeof state ->
ip -> addresses [0];
3438 memcpy (state -> from.iabuf,
3439 &state ->
ip -> addresses [0],
3445 memset (&state -> siaddr, 0,
sizeof state -> siaddr);
3451 packet -> options, state -> options,
3455 if (
d1.len >= 4 &&
d1.data)
3456 memcpy (&state -> siaddr,
d1.data, 4);
3475 state -> options,
oc);
3518 state -> options,
oc);
3531 packet -> options, state -> options, &
lease -> scope,
3547 state -> options,
oc);
3560 packet -> options, state -> options,
3565 (
const char *)
d1.data,
d1.len,
3572 state -> options -> site_universe = u ->
index;
3594 packet -> options, state -> options,
3602 lease -> state = state;
3616#if defined(DELAYED_ACK)
3748 log_debug (
"Pinging:%s, state: %d, same client? %s, "
3749 " orig_cltt %s, elasped: %ld, timeout in: %d.%d secs" ,
3766#if defined(DELAYED_ACK)
3791 log_fatal(
"delayed_ack_enqueue: no memory!");
3874#if defined(FAILOVER_PROTOCOL)
3877 if (
ack->lease->pool) {
3880 fpeer =
ack->lease->pool->failover_peer;
3888 if (
ack->lease->state ==
NULL)
3889 log_error(
"delayed ack for %s has gone stale",
3905#if defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
3928 unsigned packet_length;
3936#if defined(RELAY_PORT)
3943 log_fatal (
"dhcp_reply was supplied lease with no state!");
3946 memset (&raw, 0,
sizeof raw);
3951 if (state -> filename.len && state -> filename.data) {
3953 state -> filename.data,
3954 state -> filename.len >
sizeof raw.
file
3955 ?
sizeof raw.
file : state -> filename.len);
3956 if (
sizeof raw.
file > state -> filename.len)
3957 memset (&raw.
file [state -> filename.len], 0,
3958 (
sizeof raw.
file) - state -> filename.len);
3960 log_info(
"file name longer than packet field "
3961 "truncated - field: %lu name: %d %.*s",
3962 (
unsigned long)
sizeof(raw.
file),
3963 state->filename.len, (
int)state->filename.len,
3964 state->filename.data);
3970 if (state -> server_name.len && state -> server_name.data) {
3972 state -> server_name.data,
3973 state -> server_name.len >
sizeof raw.
sname
3974 ?
sizeof raw.
sname : state -> server_name.len);
3975 if (
sizeof raw.
sname > state -> server_name.len)
3977 (
sizeof raw.
sname) - state -> server_name.len);
3979 log_info(
"server name longer than packet field "
3980 "truncated - field: %lu name: %d %.*s",
3981 (
unsigned long)
sizeof(raw.
sname),
3989 &
lease -> hardware_addr.hbuf [1],
sizeof raw.
chaddr);
3990 raw.
hlen =
lease -> hardware_addr.hlen - 1;
4009 state -> max_message_size,
4010 state ->
packet -> options,
4013 &state -> parameter_request_list,
4018 raw.
siaddr = state -> siaddr;
4021 raw.
xid = state -> xid;
4022 raw.
secs = state -> secs;
4023 raw.
flags = state -> bootp_flags;
4024 raw.
hops = state -> hops;
4027 if (
lease -> client_hostname) {
4030 s =
lease -> client_hostname;
4032 s =
"Hostname Unsuitable for Printing";
4041#if defined(DHCPv6) && defined(DHCP4o6)
4044 log_info (
"DHCP4o6 %s on %s to %s %s%s%svia %s",
4047 ?
"DHCPACK" :
"DHCPOFFER")
4050 (
lease -> hardware_addr.hlen
4052 lease -> hardware_addr.hlen - 1,
4053 &
lease -> hardware_addr.hbuf [1])
4055 s ?
"(" :
"",
s ?
s :
"",
s ?
") " :
"",
4062 packet_length,
MDL)) {
4063 log_fatal(
"No memory to store DHCP4o6 reply.");
4068 &raw, packet_length);
4079 log_info (
"%s on %s to %s %s%s%svia %s",
4081 ? (state ->
offer ==
DHCPACK ?
"DHCPACK" :
"DHCPOFFER")
4084 (
lease -> hardware_addr.hlen > 1
4086 lease -> hardware_addr.hlen - 1,
4087 &
lease -> hardware_addr.hbuf [1])
4089 s ?
"(" :
"",
s ?
s :
"",
s ?
") " :
"",
4092 : state ->
ip -> name));
4095 dump_raw ((
unsigned char *)&raw, packet_length);
4104 to.sin_len =
sizeof to;
4106 memset (to.sin_zero, 0,
sizeof to.sin_zero);
4108#if defined(RELAY_PORT)
4114 to.sin_addr = raw.
giaddr;
4116#if defined(RELAY_PORT)
4126 packet_length, raw.
siaddr, &to,
4129 log_error (
"%s:%d: Failed to send %d byte long "
4130 "packet over %s interface.",
MDL,
4152 }
else if (raw.
ciaddr.s_addr &&
4159 to.sin_addr = raw.
ciaddr;
4164 packet_length, raw.
siaddr, &to,
4167 log_error(
"%s:%d: Failed to send %d byte long"
4168 " packet over %s interface.",
MDL,
4184 to.sin_addr = raw.
yiaddr;
4200 log_error (
"%s:%d: Failed to send %d byte long "
4201 "packet over %s interface.",
MDL,
4202 packet_length, state->
ip->
name);
4233#if defined(FAILOVER_PROTOCOL)
4251 if (
packet -> raw -> ciaddr.s_addr) {
4265 packet -> got_requested_address = 1;
4280 memset (&client_identifier, 0,
sizeof client_identifier);
4293 client_identifier.
len,
MDL)) {
4299#if defined (DEBUG_FIND_LEASE)
4301 log_info (
"Found host for client identifier: %s.",
4312 client_identifier.
len,
MDL);
4328#if defined (DEBUG_FIND_LEASE)
4330 log_info (
"Found host for link address: %s.",
4348#if defined (DEBUG_FIND_LEASE)
4350 log_info (
"Found host via host-identifier");
4365 strcpy (dhcp_message,
"requested address is incorrect");
4366#if defined (DEBUG_FIND_LEASE)
4367 log_info (
"Client's fixed-address %s doesn't match %s%s",
4386#if defined (DEBUG_FIND_LEASE)
4387 log_info (
"trying next lease matching client id: %s",
4391#if defined (FAILOVER_PROTOCOL)
4403#if defined (DEBUG_FIND_LEASE)
4404 log_info(
"not active or not mine to allocate: %s",
4412#if defined (DEBUG_FIND_LEASE)
4413 log_info (
"wrong network segment: %s",
4426#if defined (DEBUG_FIND_LEASE)
4445#if defined (DEBUG_FIND_LEASE)
4447 log_info (
"Found lease for client id: %s.",
4463#if defined (DEBUG_FIND_LEASE)
4464 log_info (
"trying next lease matching hw addr: %s",
4467#if defined (FAILOVER_PROTOCOL)
4480#if defined (DEBUG_FIND_LEASE)
4481 log_info(
"not active or not mine to allocate: %s",
4501#if defined (DEBUG_FIND_LEASE)
4502 log_info (
"wrong client identifier: %s",
4508#if defined (DEBUG_FIND_LEASE)
4509 log_info (
"wrong network segment: %s",
4518#if defined (DEBUG_FIND_LEASE)
4522 if (!
packet -> raw -> ciaddr.s_addr)
4536#if defined (DEBUG_FIND_LEASE)
4538 log_info (
"Found lease for hardware address: %s.",
4549#if defined (DEBUG_FIND_LEASE)
4551 log_info (
"Found lease for requested address: %s.",
4571#if defined (DEBUG_FIND_LEASE)
4572 log_info (
"...but it was on the wrong shared network.");
4574 strcpy (dhcp_message,
"requested address on bad subnet");
4597 (
unsigned)(
ip_lease -> hardware_addr.hlen - 1))))) {
4608#if defined (DEBUG_FIND_LEASE)
4609 log_info (
"rejecting lease for requested address.");
4630#if defined (DEBUG_FIND_LEASE)
4631 log_info(
"ip lease not active or not ours to offer.");
4647 log_error (
"client %s has duplicate%s on %s",
4658 !
packet -> raw -> ciaddr.s_addr &&
4675 log_error (
"Dynamic and static leases present for %s.",
4677 log_error (
"Remove host declaration %s or remove %s",
4684 log_error (
"from the dynamic address pool for %s",
4690 "database conflict - call for help!");
4694#if defined (DEBUG_FIND_LEASE)
4695 log_info (
"requested address not available.");
4708#if defined (DEBUG_FIND_LEASE)
4709 log_info (
"hardware lease and uid lease are identical.");
4715#if defined (DEBUG_FIND_LEASE)
4716 log_info (
"hardware lease and ip lease are identical.");
4721#if defined (DEBUG_FIND_LEASE)
4722 log_info (
"uid lease and ip lease are identical.");
4744 if (!
packet -> raw -> ciaddr.s_addr)
4754 if (!
packet -> raw -> ciaddr.s_addr)
4763 strcpy (dhcp_message,
"requested address not available");
4771#if defined (DEBUG_FIND_LEASE)
4772 log_info (
"no applicable lease found for DHCPREQUEST.");
4782#if defined (DEBUG_FIND_LEASE)
4783 log_info (
"choosing fixed address.");
4791 if (!
packet -> raw -> ciaddr.s_addr)
4793#if defined (DEBUG_FIND_LEASE)
4794 log_info (
"not choosing requested address (!).");
4798#if defined (DEBUG_FIND_LEASE)
4799 log_info (
"choosing lease on requested address.");
4812 log_error(
"uid lease %s for client %s is duplicate "
4816 uid_lease->subnet->shared_network->name);
4818 if (!
packet -> raw -> ciaddr.s_addr &&
4822#if defined (DEBUG_FIND_LEASE)
4823 log_info (
"not choosing uid lease.");
4829#if defined (DEBUG_FIND_LEASE)
4839#if defined (DEBUG_FIND_LEASE)
4840 log_info (
"not choosing hardware lease.");
4850 client_identifier.
len &&
4852 client_identifier.
data,
4853 client_identifier.
len))
4854 :
packet -> packet_type == 0)) {
4858#if defined (DEBUG_FIND_LEASE)
4859 log_info (
"choosing hardware lease.");
4862#if defined (DEBUG_FIND_LEASE)
4863 log_info (
"not choosing hardware lease: %s.",
4883 if (!
p->fixed_addr) {
4905 if (
p->n_ipaddr !=
NULL)
4923 log_error (
"Reclaiming REQUESTed abandoned IP address %s.",
4951#if defined (DEBUG_FIND_LEASE)
4959#if defined (DEBUG_FIND_LEASE)
4960 log_info (
"Not returning a lease.");
4992 if (!
lease -> uid) {
5026 if ((
pool -> prohibit_list &&
5028 (
pool -> permit_list &&
5032#if defined (FAILOVER_PROTOCOL)
5151 log_error(
"Reclaiming abandoned lease %s.",
5160 log_debug(
"soft impossible condition (%s:%d): stale "
5161 "host \"%s\" found on lease %s",
MDL,
5180 struct permit *permit_list;
5185 for (
p = permit_list;
p;
p =
p ->
next) {
5186 switch (
p ->
type) {
5198 if (
packet -> authenticated)
5203 if (!
packet -> authenticated)
5211 if (!
packet -> options_valid ||
5217 for (
i = 0;
i <
packet -> class_count;
i++) {
5218 if (
p ->
class ==
packet -> classes [
i])
5221 packet -> classes [
i] -> superclass &&
5222 (
packet -> classes [
i] -> superclass ==
5237#if defined(DHCPv6) && defined(DHCP4o6)
5330 ia.len =
sizeof(*first_link_addr);
5357 log_error(
"No interface and no link address "
5358 "can't determine DHCP4o6 shared network");
5372#if defined(DHCPv6) && defined(DHCP4o6)
5416 memset (&data, 0,
sizeof data);
5425 if (data.
len != 4) {
5499 memset(from, 0,
sizeof(*from));
5507 if (
d.len ==
sizeof(*from)) {
5509 memcpy(from,
d.data,
sizeof(*from));
5538 (
unsigned char *)a,
sizeof(*a),
5637find_min_site_code(
struct universe *u)
5647 site_code_min = 224;
5650 if (site_code_min < 224) {
5651 log_error(
"WARNING: site-local option codes less than 224 have "
5652 "been deprecated by RFC3942. You have options "
5653 "listed in site local space %s that number as low as "
5654 "%d. Please investigate if these should be declared "
5655 "as regular options rather than site-local options, "
5656 "or migrated up past 224.",
5657 u->
name, site_code_min);
5664 if (site_code_min < 128)
5665 site_code_min = 128;
5674 return site_code_min;
5678lowest_site_code(
const void *key,
unsigned len,
void *
object)
5840 if (
d1.len == 1 && (
d1.data[0] < 100))
5887 log_debug(
"reuse_lease: lease age %ld (secs)"
5888 " under %d%% threshold, reply with "
5889 "unaltered, existing lease for %s",
int buffer_allocate(struct buffer **ptr, unsigned len, const char *file, int line)
int expression_reference(struct expression **ptr, struct expression *src, const char *file, int line)
void data_string_forget(struct data_string *data, const char *file, int line)
int option_chain_head_reference(struct option_chain_head **ptr, struct option_chain_head *bp, const char *file, int line)
int option_state_allocate(struct option_state **ptr, const char *file, int line)
int option_state_dereference(struct option_state **ptr, const char *file, int line)
int packet_reference(struct packet **ptr, struct packet *bp, const char *file, int line)
int binding_scope_reference(struct binding_scope **ptr, struct binding_scope *bp, const char *file, int line)
void data_string_copy(struct data_string *dest, const struct data_string *src, const char *file, int line)
int option_cache_allocate(struct option_cache **cptr, const char *file, int line)
int option_chain_head_dereference(struct option_chain_head **ptr, const char *file, int line)
void add_timeout(struct timeval *when, void *where, void *what, tvref_t ref, tvunref_t unref)
void cancel_timeout(void *where, void *what)
void save_option(struct universe *universe, struct option_state *options, struct option_cache *oc)
int option_cache_dereference(struct option_cache **ptr, const char *file, int line)
void delete_option(struct universe *universe, struct option_state *options, int code)
struct option_cache * lookup_option(struct universe *universe, struct option_state *options, unsigned code)
int get_option_int(int *result, struct universe *universe, struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *cfg_options, struct option_state *options, struct binding_scope **scope, unsigned code, const char *file, int line)
int cons_options(struct packet *inpacket, struct dhcp_packet *outpacket, struct lease *lease, struct client_state *client_state, int mms, struct option_state *in_options, struct option_state *cfg_options, struct binding_scope **scope, int overload_avail, int terminate, int bootpp, struct data_string *prl, const char *vuname)
char * print_dotted_quads(unsigned len, const u_int8_t *data)
char * print_hw_addr(int htype, const int hlen, const unsigned char *data) const
const char * print_time(TIME t)
void dump_raw(unsigned char *buf, unsigned len) const
#define FAILOVER_PROTOCOL
u_int32_t getUShort(const unsigned char *)
u_int32_t getULong(const unsigned char *)
void putULong(unsigned char *, u_int32_t)
void dhcpack(struct packet *packet)
void do_release(struct client_state *client)
int find_subnet(struct subnet **sp, struct iaddr addr, const char *file, int line)
void unbill_class(struct lease *lease)
int write_lease(struct lease *lease)
int permitted(struct packet *packet, struct permit *permit_list)
void ack_lease(struct packet *packet, struct lease *lease, unsigned int offer, TIME when, char *msg, int ms_nulltp, struct host_decl *hp)
void dhcpinform(struct packet *packet, int ms_nulltp)
void dhcp(struct packet *packet)
void dhcp_reply(struct lease *lease)
void eval_network_statements(struct option_state **network_options, struct packet *packet, struct group *network_group)
Builds option set from statements at the global and network scope.
char * print_hw_addr_or_client_id(struct packet *packet)
const int dhcp_type_name_max
char * print_client_identifier_from_packet(struct packet *packet)
int mockup_lease(struct lease **lp, struct packet *packet, struct shared_network *share, struct host_decl *hp)
void dhcprelease(struct packet *packet, int ms_nulltp)
void dhcprequest(struct packet *packet, int ms_nulltp, struct lease *ip_lease)
void use_host_decl_name(struct packet *packet, struct lease *lease, struct option_state *options)
Adds hostname option when use-host-decl-names is enabled.
int locate_network(struct packet *packet)
void dhcpdiscover(struct packet *packet, int ms_nulltp)
int allocate_lease(struct lease **lp, struct packet *packet, struct pool *pool, int *peer_has_leases)
void check_pool_threshold(struct packet *packet, struct lease *lease, struct lease_state *state)
void nak_lease(struct packet *packet, struct iaddr *cip, struct group *network_group)
Constructs and sends a DHCP Nak.
int find_lease(struct lease **lp, struct packet *packet, struct shared_network *share, int *ours, int *peer_has_leases, struct lease *ip_lease_in, const char *file, int line)
void echo_client_id(struct packet *packet, struct lease *lease, struct option_state *in_options, struct option_state *out_options)
Adds a dhcp-client-id option to a set of options Given a set of input options, it searches for echo-c...
void dhcpdecline(struct packet *packet, int ms_nulltp)
void get_server_source_address(struct in_addr *from, struct option_state *options, struct option_state *out_options, struct packet *packet)
#define DHO_DHCP_MAX_MESSAGE_SIZE
#define DHO_DHCP_PARAMETER_REQUEST_LIST
#define DHO_VENDOR_CLASS_IDENTIFIER
#define DHO_SUBNET_SELECTION
#define DHO_DHCP_CLIENT_IDENTIFIER
#define DHO_PXE_CLIENT_ID
#define DHO_DHCP_MESSAGE_TYPE
#define DHCPLEASEUNASSIGNED
#define DHO_DHCP_RENEWAL_TIME
#define DHO_DHCP_REBINDING_TIME
#define DHO_DHCP_SERVER_IDENTIFIER
#define DHO_DHCP_REQUESTED_ADDRESS
#define DHO_DHCP_LEASE_TIME
void dump_raw(const unsigned char *, unsigned)
#define DEFAULT_DEFAULT_LEASE_TIME
#define DEFAULT_PING_TIMEOUT_MS
#define SV_ECHO_CLIENT_ID
u_int16_t dhcp_check_relayport(struct packet *packet)
#define SV_MIN_LEASE_TIME
void(* tvunref_t)(void *, const char *, int)
void execute_statements_in_scope(struct binding_value **result, struct packet *, struct lease *, struct client_state *, struct option_state *, struct option_state *, struct binding_scope **, struct group *, struct group *, struct on_star *)
int bill_class(struct lease *, struct class *)
#define DEFAULT_CACHE_THRESHOLD
int db_printable(const unsigned char *)
int option_chain_head_reference(struct option_chain_head **, struct option_chain_head *, const char *, int)
struct universe agent_universe
struct in_addr limited_broadcast
#define SV_LOG_THRESHOLD_LOW
void free_lease_state(struct lease_state *, const char *, int)
int find_hosts_by_haddr(struct host_decl **, int, const unsigned char *, unsigned, const char *, int)
#define LEASE_NOT_EMPTY(LQ)
void(* tvref_t)(void *, void *, const char *, int)
#define SV_STASH_AGENT_OPTIONS
void dump_packet(struct packet *)
int find_lease_by_uid(struct lease **, const unsigned char *, unsigned, const char *, int)
void abandon_lease(struct lease *, const char *)
struct ipv6_pool ** pools
void dhcpleasequery(struct packet *, int)
#define SV_USE_LEASE_ADDR_FOR_DEFAULT_ROUTE
ssize_t send_packet(struct interface_info *, struct packet *, struct dhcp_packet *, size_t, struct in_addr, struct sockaddr_in *, struct hardware *)
#define FIND_PERCENT(count, percent)
#define SV_BOOT_UNKNOWN_CLIENTS
#define SV_IGNORE_CLIENT_UIDS
int find_hosts_by_uid(struct host_decl **, const unsigned char *, unsigned, const char *, int)
int supersede_lease(struct lease *, struct lease *, int, int, int, int)
void save_option(struct universe *, struct option_state *, struct option_cache *)
int find_grouped_subnet(struct subnet **, struct shared_network *, struct iaddr, const char *, int)
void echo_client_id(struct packet *, struct lease *, struct option_state *, struct option_state *)
Adds a dhcp-client-id option to a set of options Given a set of input options, it searches for echo-c...
#define DEFAULT_MIN_ACK_DELAY_USECS
#define MS_NULL_TERMINATION
int find_lease_by_hw_addr(struct lease **, const unsigned char *, unsigned, const char *, int)
#define SV_CACHE_THRESHOLD
#define SV_PING_CLTT_SECS
int ddns_updates(struct packet *, struct lease *, struct lease *, struct iasubopt *, struct iasubopt *, struct option_state *)
#define SV_MAX_LEASE_TIME
#define SV_ONE_LEASE_PER_CLIENT
#define SV_GET_LEASE_HOSTNAMES
struct universe server_universe
isc_result_t dhcp_failover_send_updates(dhcp_failover_state_t *)
void eval_network_statements(struct option_state **options, struct packet *packet, struct group *network_group)
Builds option set from statements at the global and network scope.
struct universe dhcp_universe
#define SV_BOOTP_LEASE_CUTOFF
int find_hosts_by_option(struct host_decl **, struct packet *, struct option_state *, const char *, int)
#define DEFAULT_MIN_LEASE_TIME
#define SV_USE_HOST_DECL_NAMES
#define SV_LOG_THRESHOLD_HIGH
int find_lease_by_ip_addr(struct lease **, struct iaddr, const char *, int)
#define DEFAULT_PING_CLTT_SECS
#define DEFAULT_DELAYED_ACK
const char * piaddr(struct iaddr)
void classify_client(struct packet *)
void release_lease(struct lease *, struct packet *)
int find_host_for_network(struct subnet **, struct host_decl **, struct iaddr *, struct shared_network *)
#define SV_SITE_OPTION_SPACE
#define DEFAULT_PING_TIMEOUT
int can_unicast_without_arp(struct interface_info *)
#define DEFAULT_MAX_LEASE_TIME
int buffer_allocate(struct buffer **, unsigned, const char *, int)
#define SV_BOOTP_LEASE_LENGTH
#define UNICAST_BROADCAST_HACK
#define DEFAULT_ACK_DELAY_USECS
#define SV_RESERVE_INFINITE
void delete_option(struct universe *, struct option_state *, int)
void lease_ping_timeout(void *)
#define DEFAULT_ACK_DELAY_SECS
int lease_mine_to_reallocate(struct lease *)
int load_balance_mine(struct packet *, dhcp_failover_state_t *)
int option_state_dereference(struct option_state **, const char *, int)
void get_server_source_address(struct in_addr *from, struct option_state *options, struct option_state *out_options, struct packet *packet)
#define SV_ADAPTIVE_LEASE_TIME_THRESHOLD
#define SV_DEFAULT_LEASE_TIME
#define LEASE_GET_FIRST(LQ)
int option_state_allocate(struct option_state **, const char *, int)
int cons_options(struct packet *, struct dhcp_packet *, struct lease *, struct client_state *, int, struct option_state *, struct option_state *, struct binding_scope **, int, int, int, struct data_string *, const char *)
#define SV_PING_TIMEOUT_MS
#define print_hex_1(len, data, limit)
struct lease_state * new_lease_state(const char *, int)
int option_cache_dereference(struct option_cache **, const char *, int)
#define SV_ALWAYS_BROADCAST
struct interface_info * fallback_interface
struct in_addr limited_broadcast
int execute_statements(struct binding_value **result, struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *out_options, struct binding_scope **scope, struct executable_statement *statements, struct on_star *on_star)
void execute_statements_in_scope(struct binding_value **result, struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *out_options, struct binding_scope **scope, struct group *group, struct group *limiting_group, struct on_star *on_star)
int executable_statement_dereference(struct executable_statement **ptr, const char *file, int line)
const char * binding_state_print(enum failover_state state)
int icmp_echorequest(struct iaddr *addr)
struct iaddr ip_addr(struct iaddr subnet, struct iaddr mask, u_int32_t host_address)
const char * piaddr(const struct iaddr addr)
struct group * root_group
void * dmalloc(size_t, const char *, int)
void dfree(void *, const char *, int)
int log_error(const char *,...) __attribute__((__format__(__printf__
int int int log_debug(const char *,...) __attribute__((__format__(__printf__
void log_fatal(const char *,...) __attribute__((__format__(__printf__
int int log_info(const char *,...) __attribute__((__format__(__printf__
struct class * superclass
const unsigned char * data
char sname[DHCP_SNAME_LEN]
u_int8_t hbuf[HARDWARE_ADDR_LEN+1]
struct option_cache * fixed_addr
struct data_string client_identifier
struct host_decl * n_ipaddr
struct hardware interface
struct shared_network * shared_network
struct in_addr * addresses
struct interface_info * ip
struct option_state * options
int got_server_identifier
struct data_string filename server_name
binding_state_t next_binding_state
struct lease_state * state
struct binding_scope * scope
unsigned short cannot_reuse
struct hardware hardware_addr
binding_state_t rewind_binding_state
struct class * billing_class
binding_state_t binding_state
struct executable_statement * on_commit
struct executable_statement * on_expiry
struct executable_statement * on_release
isc_boolean_t agent_options_stashed
struct in6_addr dhcpv6_link_address
struct packet * dhcpv6_container_packet
struct shared_network * shared_network
struct interface_info * interface
struct option_state * options
struct data_string * dhcp4o6_response
struct class * classes[PACKET_MAX_CLASSES]
@ permit_dynamic_bootp_clients
@ permit_authenticated_clients
@ permit_unauthenticated_clients
struct permit * prohibit_list
struct permit * permit_list
dhcp_failover_state_t * failover_peer
struct shared_network * shared_network
struct shared_network * shared_network
option_code_hash_t * code_hash
int option_reference(struct option **dest, struct option *src, const char *file, int line)
universe_hash_t * universe_hash
struct universe ** universes
int binding_scope_dereference(struct binding_scope **ptr, const char *file, int line)
int evaluate_option_cache(struct data_string *result, struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *cfg_options, struct binding_scope **scope, struct option_cache *oc, const char *file, int line)
int evaluate_boolean_option_cache(int *ignorep, struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *cfg_options, struct binding_scope **scope, struct option_cache *oc, const char *file, int line)
int make_const_data(struct expression **expr, const unsigned char *data, unsigned len, int terminated, int allocate, const char *file, int line)
int bind_ds_value(struct binding_scope **scope, const char *name, struct data_string *value)
struct binding_scope * global_scope