mirror of
https://gitlab.isc.org/isc-projects/dhcp
synced 2025-08-31 06:15:55 +00:00
Support new generalized option_state usage.
This commit is contained in:
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char copyright[] =
|
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 */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include "dhcpd.h"
|
#include "dhcpd.h"
|
||||||
@@ -38,7 +38,7 @@ void bootp (packet)
|
|||||||
struct sockaddr_in to;
|
struct sockaddr_in to;
|
||||||
struct in_addr from;
|
struct in_addr from;
|
||||||
struct hardware hto;
|
struct hardware hto;
|
||||||
struct option_state options;
|
struct option_state *options = (struct option_state *)0;
|
||||||
struct subnet *subnet;
|
struct subnet *subnet;
|
||||||
struct lease *lease;
|
struct lease *lease;
|
||||||
struct iaddr ip_address;
|
struct iaddr ip_address;
|
||||||
@@ -114,30 +114,33 @@ void bootp (packet)
|
|||||||
|
|
||||||
/* Run the executable statements to compute the client and server
|
/* Run the executable statements to compute the client and server
|
||||||
options. */
|
options. */
|
||||||
|
option_state_allocate (&options, "bootrequest");
|
||||||
memset (&options, 0, sizeof options);
|
|
||||||
|
|
||||||
/* Execute the subnet statements. */
|
/* Execute the subnet statements. */
|
||||||
execute_statements_in_scope (packet, &options, &options,
|
execute_statements_in_scope (packet, options, options,
|
||||||
lease -> subnet -> group,
|
lease -> subnet -> group,
|
||||||
(struct group *)0);
|
(struct group *)0);
|
||||||
|
|
||||||
/* Execute the host statements. */
|
/* 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);
|
lease -> subnet -> group);
|
||||||
|
|
||||||
/* Drop the request if it's not allowed for this client. */
|
/* Drop the request if it's not allowed for this client. */
|
||||||
if (evaluate_boolean_option_cache (packet, &options,
|
if (evaluate_boolean_option_cache (packet, options,
|
||||||
lookup_option (options.dhcp_hash,
|
lookup_option (&dhcp_universe,
|
||||||
|
options,
|
||||||
SV_ALLOW_BOOTP))) {
|
SV_ALLOW_BOOTP))) {
|
||||||
log_info ("%s: bootp disallowed", msgbuf);
|
log_info ("%s: bootp disallowed", msgbuf);
|
||||||
|
option_state_dereference (&options, "bootrequest");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (evaluate_boolean_option_cache (packet, &options,
|
if (evaluate_boolean_option_cache (packet, options,
|
||||||
lookup_option (options.dhcp_hash,
|
lookup_option (&dhcp_universe,
|
||||||
|
options,
|
||||||
SV_ALLOW_BOOTING))) {
|
SV_ALLOW_BOOTING))) {
|
||||||
log_info ("%s: booting disallowed", msgbuf);
|
log_info ("%s: booting disallowed", msgbuf);
|
||||||
|
option_state_dereference (&options, "bootrequest");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,8 +161,7 @@ void bootp (packet)
|
|||||||
name buffers. */
|
name buffers. */
|
||||||
|
|
||||||
outgoing.packet_length =
|
outgoing.packet_length =
|
||||||
cons_options (packet, outgoing.raw, 0,
|
cons_options (packet, outgoing.raw, 0, options,
|
||||||
&options, (struct agent_options *)0,
|
|
||||||
0, 0, 1, (struct data_string *)0);
|
0, 0, 1, (struct data_string *)0);
|
||||||
if (outgoing.packet_length < BOOTP_MIN_LEN)
|
if (outgoing.packet_length < BOOTP_MIN_LEN)
|
||||||
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 ->
|
raw.siaddr = (lease -> subnet -> shared_network ->
|
||||||
interface -> primary_address);
|
interface -> primary_address);
|
||||||
memset (&d1, 0, sizeof d1);
|
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 &&
|
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 there was more than one answer, take the first. */
|
||||||
if (d1.len >= 4 && d1.data)
|
if (d1.len >= 4 && d1.data)
|
||||||
memcpy (&raw.siaddr, d1.data, 4);
|
memcpy (&raw.siaddr, d1.data, 4);
|
||||||
@@ -193,9 +195,9 @@ void bootp (packet)
|
|||||||
raw.giaddr = packet -> raw -> giaddr;
|
raw.giaddr = packet -> raw -> giaddr;
|
||||||
|
|
||||||
/* Figure out the filename. */
|
/* Figure out the filename. */
|
||||||
oc = lookup_option (options.dhcp_hash, SV_FILENAME);
|
oc = lookup_option (&dhcp_universe, options, SV_FILENAME);
|
||||||
if (oc &&
|
if (oc &&
|
||||||
evaluate_option_cache (&d1, packet, &options, oc)) {
|
evaluate_option_cache (&d1, packet, options, oc)) {
|
||||||
memcpy (raw.file, d1.data,
|
memcpy (raw.file, d1.data,
|
||||||
d1.len > sizeof raw.file ? sizeof raw.file : d1.len);
|
d1.len > sizeof raw.file ? sizeof raw.file : d1.len);
|
||||||
if (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);
|
memcpy (raw.file, packet -> raw -> file, sizeof raw.file);
|
||||||
|
|
||||||
/* Choose a server name as above. */
|
/* 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 &&
|
if (oc &&
|
||||||
evaluate_option_cache (&d1, packet, &options, oc)) {
|
evaluate_option_cache (&d1, packet, options, oc)) {
|
||||||
memcpy (raw.sname, d1.data,
|
memcpy (raw.sname, d1.data,
|
||||||
d1.len > sizeof raw.sname ? sizeof raw.sname : d1.len);
|
d1.len > sizeof raw.sname ? sizeof raw.sname : d1.len);
|
||||||
if (sizeof raw.sname > d1.len)
|
if (sizeof raw.sname > d1.len)
|
||||||
@@ -217,6 +219,9 @@ void bootp (packet)
|
|||||||
data_string_forget (&d1, "bootrequest");
|
data_string_forget (&d1, "bootrequest");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* We're done with the option state. */
|
||||||
|
option_state_dereference (&options, "bootrequest");
|
||||||
|
|
||||||
/* Set up the hardware destination address... */
|
/* Set up the hardware destination address... */
|
||||||
hto.htype = packet -> raw -> htype;
|
hto.htype = packet -> raw -> htype;
|
||||||
hto.hlen = packet -> raw -> hlen;
|
hto.hlen = packet -> raw -> hlen;
|
||||||
|
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char copyright[] =
|
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 */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include "dhcpd.h"
|
#include "dhcpd.h"
|
||||||
@@ -70,7 +70,7 @@ void classification_setup ()
|
|||||||
void classify_client (packet)
|
void classify_client (packet)
|
||||||
struct packet *packet;
|
struct packet *packet;
|
||||||
{
|
{
|
||||||
execute_statements (packet, &packet -> options,
|
execute_statements (packet, packet -> options,
|
||||||
(struct option_state *)0,
|
(struct option_state *)0,
|
||||||
default_classification_rules);
|
default_classification_rules);
|
||||||
}
|
}
|
||||||
@@ -93,7 +93,7 @@ int check_collection (packet, collection)
|
|||||||
class if we've already billed it to a different class. */
|
class if we've already billed it to a different class. */
|
||||||
if (class -> submatch) {
|
if (class -> submatch) {
|
||||||
status = evaluate_data_expression (&data, packet,
|
status = evaluate_data_expression (&data, packet,
|
||||||
&packet -> options,
|
packet -> options,
|
||||||
class -> submatch);
|
class -> submatch);
|
||||||
if (status) {
|
if (status) {
|
||||||
if ((nc = ((struct class *)
|
if ((nc = ((struct class *)
|
||||||
@@ -132,7 +132,8 @@ int check_collection (packet, collection)
|
|||||||
sizeof (struct lease *),
|
sizeof (struct lease *),
|
||||||
"check_collection"));
|
"check_collection"));
|
||||||
if (!nc -> billed_leases) {
|
if (!nc -> billed_leases) {
|
||||||
log_error ("no memory for billing");
|
log_error ("no memory for%s",
|
||||||
|
" billing");
|
||||||
data_string_forget
|
data_string_forget
|
||||||
(&nc -> hash_string,
|
(&nc -> hash_string,
|
||||||
"check_collection");
|
"check_collection");
|
||||||
@@ -158,7 +159,7 @@ int check_collection (packet, collection)
|
|||||||
}
|
}
|
||||||
|
|
||||||
status = (evaluate_boolean_expression_result
|
status = (evaluate_boolean_expression_result
|
||||||
(packet, &packet -> options, class -> expr));
|
(packet, packet -> options, class -> expr));
|
||||||
if (status) {
|
if (status) {
|
||||||
matched = 1;
|
matched = 1;
|
||||||
#if defined (DEBUG_CLASS_MATCHING)
|
#if defined (DEBUG_CLASS_MATCHING)
|
||||||
|
Reference in New Issue
Block a user