mirror of
https://gitlab.isc.org/isc-projects/dhcp
synced 2025-08-31 14:25:41 +00:00
Support new generalized option_state usage.
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static char copyright[] =
|
||||
"$Id: bootp.c,v 1.42 1999/03/30 18:12:34 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
|
||||
"$Id: bootp.c,v 1.43 1999/04/05 16:31:54 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
|
||||
#endif /* not lint */
|
||||
|
||||
#include "dhcpd.h"
|
||||
@@ -38,7 +38,7 @@ void bootp (packet)
|
||||
struct sockaddr_in to;
|
||||
struct in_addr from;
|
||||
struct hardware hto;
|
||||
struct option_state options;
|
||||
struct option_state *options = (struct option_state *)0;
|
||||
struct subnet *subnet;
|
||||
struct lease *lease;
|
||||
struct iaddr ip_address;
|
||||
@@ -114,30 +114,33 @@ void bootp (packet)
|
||||
|
||||
/* Run the executable statements to compute the client and server
|
||||
options. */
|
||||
|
||||
memset (&options, 0, sizeof options);
|
||||
option_state_allocate (&options, "bootrequest");
|
||||
|
||||
/* Execute the subnet statements. */
|
||||
execute_statements_in_scope (packet, &options, &options,
|
||||
execute_statements_in_scope (packet, options, options,
|
||||
lease -> subnet -> group,
|
||||
(struct group *)0);
|
||||
|
||||
/* Execute the host statements. */
|
||||
execute_statements_in_scope (packet, &options, &options, hp -> group,
|
||||
execute_statements_in_scope (packet, options, options, hp -> group,
|
||||
lease -> subnet -> group);
|
||||
|
||||
/* Drop the request if it's not allowed for this client. */
|
||||
if (evaluate_boolean_option_cache (packet, &options,
|
||||
lookup_option (options.dhcp_hash,
|
||||
if (evaluate_boolean_option_cache (packet, options,
|
||||
lookup_option (&dhcp_universe,
|
||||
options,
|
||||
SV_ALLOW_BOOTP))) {
|
||||
log_info ("%s: bootp disallowed", msgbuf);
|
||||
option_state_dereference (&options, "bootrequest");
|
||||
return;
|
||||
}
|
||||
|
||||
if (evaluate_boolean_option_cache (packet, &options,
|
||||
lookup_option (options.dhcp_hash,
|
||||
if (evaluate_boolean_option_cache (packet, options,
|
||||
lookup_option (&dhcp_universe,
|
||||
options,
|
||||
SV_ALLOW_BOOTING))) {
|
||||
log_info ("%s: booting disallowed", msgbuf);
|
||||
option_state_dereference (&options, "bootrequest");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -158,8 +161,7 @@ void bootp (packet)
|
||||
name buffers. */
|
||||
|
||||
outgoing.packet_length =
|
||||
cons_options (packet, outgoing.raw, 0,
|
||||
&options, (struct agent_options *)0,
|
||||
cons_options (packet, outgoing.raw, 0, options,
|
||||
0, 0, 1, (struct data_string *)0);
|
||||
if (outgoing.packet_length < BOOTP_MIN_LEN)
|
||||
outgoing.packet_length = BOOTP_MIN_LEN;
|
||||
@@ -181,9 +183,9 @@ void bootp (packet)
|
||||
raw.siaddr = (lease -> subnet -> shared_network ->
|
||||
interface -> primary_address);
|
||||
memset (&d1, 0, sizeof d1);
|
||||
oc = lookup_option (options.dhcp_hash, SV_NEXT_SERVER);
|
||||
oc = lookup_option (&dhcp_universe, options, SV_NEXT_SERVER);
|
||||
if (oc &&
|
||||
evaluate_option_cache (&d1, packet, &options, oc)) {
|
||||
evaluate_option_cache (&d1, packet, options, oc)) {
|
||||
/* If there was more than one answer, take the first. */
|
||||
if (d1.len >= 4 && d1.data)
|
||||
memcpy (&raw.siaddr, d1.data, 4);
|
||||
@@ -193,9 +195,9 @@ void bootp (packet)
|
||||
raw.giaddr = packet -> raw -> giaddr;
|
||||
|
||||
/* Figure out the filename. */
|
||||
oc = lookup_option (options.dhcp_hash, SV_FILENAME);
|
||||
oc = lookup_option (&dhcp_universe, options, SV_FILENAME);
|
||||
if (oc &&
|
||||
evaluate_option_cache (&d1, packet, &options, oc)) {
|
||||
evaluate_option_cache (&d1, packet, options, oc)) {
|
||||
memcpy (raw.file, d1.data,
|
||||
d1.len > sizeof raw.file ? sizeof raw.file : d1.len);
|
||||
if (sizeof raw.file > d1.len)
|
||||
@@ -206,9 +208,9 @@ void bootp (packet)
|
||||
memcpy (raw.file, packet -> raw -> file, sizeof raw.file);
|
||||
|
||||
/* Choose a server name as above. */
|
||||
oc = lookup_option (options.dhcp_hash, SV_SERVER_NAME);
|
||||
oc = lookup_option (&dhcp_universe, options, SV_SERVER_NAME);
|
||||
if (oc &&
|
||||
evaluate_option_cache (&d1, packet, &options, oc)) {
|
||||
evaluate_option_cache (&d1, packet, options, oc)) {
|
||||
memcpy (raw.sname, d1.data,
|
||||
d1.len > sizeof raw.sname ? sizeof raw.sname : d1.len);
|
||||
if (sizeof raw.sname > d1.len)
|
||||
@@ -217,6 +219,9 @@ void bootp (packet)
|
||||
data_string_forget (&d1, "bootrequest");
|
||||
}
|
||||
|
||||
/* We're done with the option state. */
|
||||
option_state_dereference (&options, "bootrequest");
|
||||
|
||||
/* Set up the hardware destination address... */
|
||||
hto.htype = packet -> raw -> htype;
|
||||
hto.hlen = packet -> raw -> hlen;
|
||||
|
Reference in New Issue
Block a user