2
0
mirror of https://gitlab.isc.org/isc-projects/dhcp synced 2025-08-30 13:57:50 +00:00

Support new generalized option_state usage.

This commit is contained in:
Ted Lemon
1999-04-05 16:34:33 +00:00
parent dd6e44a55b
commit 7e6f3635e8
2 changed files with 29 additions and 23 deletions

View File

@@ -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;

View File

@@ -22,7 +22,7 @@
#ifndef lint
static char copyright[] =
"$Id: class.c,v 1.10 1999/03/16 05:50:42 mellon Exp $ Copyright (c) 1998 The Internet Software Consortium. All rights reserved.\n";
"$Id: class.c,v 1.11 1999/04/05 16:34:33 mellon Exp $ Copyright (c) 1998 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -70,7 +70,7 @@ void classification_setup ()
void classify_client (packet)
struct packet *packet;
{
execute_statements (packet, &packet -> options,
execute_statements (packet, packet -> options,
(struct option_state *)0,
default_classification_rules);
}
@@ -93,7 +93,7 @@ int check_collection (packet, collection)
class if we've already billed it to a different class. */
if (class -> submatch) {
status = evaluate_data_expression (&data, packet,
&packet -> options,
packet -> options,
class -> submatch);
if (status) {
if ((nc = ((struct class *)
@@ -132,7 +132,8 @@ int check_collection (packet, collection)
sizeof (struct lease *),
"check_collection"));
if (!nc -> billed_leases) {
log_error ("no memory for billing");
log_error ("no memory for%s",
" billing");
data_string_forget
(&nc -> hash_string,
"check_collection");
@@ -158,7 +159,7 @@ int check_collection (packet, collection)
}
status = (evaluate_boolean_expression_result
(packet, &packet -> options, class -> expr));
(packet, packet -> options, class -> expr));
if (status) {
matched = 1;
#if defined (DEBUG_CLASS_MATCHING)