mirror of
https://gitlab.isc.org/isc-projects/dhcp
synced 2025-08-29 13:28:14 +00:00
Pass client state to eval functions.
This commit is contained in:
parent
2e7a6cd54f
commit
66e9cecfa6
@ -41,7 +41,7 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char ocopyright[] =
|
static char ocopyright[] =
|
||||||
"$Id: dhclient.c,v 1.117 2000/11/24 03:52:37 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 Internet Software Consortium. All rights reserved.\n";
|
"$Id: dhclient.c,v 1.118 2000/11/28 22:10:52 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 Internet Software Consortium. All rights reserved.\n";
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include "dhcpd.h"
|
#include "dhcpd.h"
|
||||||
@ -249,7 +249,7 @@ int main (argc, argv, envp)
|
|||||||
/* Default to the DHCP/BOOTP port. */
|
/* Default to the DHCP/BOOTP port. */
|
||||||
if (!local_port) {
|
if (!local_port) {
|
||||||
if (relay && giaddr.s_addr != INADDR_LOOPBACK) {
|
if (relay && giaddr.s_addr != INADDR_LOOPBACK) {
|
||||||
local_port = 67;
|
local_port = htons (67);
|
||||||
} else {
|
} else {
|
||||||
ent = getservbyname ("dhcpc", "udp");
|
ent = getservbyname ("dhcpc", "udp");
|
||||||
if (!ent)
|
if (!ent)
|
||||||
@ -265,7 +265,7 @@ int main (argc, argv, envp)
|
|||||||
/* If we're faking a relay agent, and we're not using loopback,
|
/* If we're faking a relay agent, and we're not using loopback,
|
||||||
use the server port, not the client port. */
|
use the server port, not the client port. */
|
||||||
if (relay && giaddr.s_addr != INADDR_LOOPBACK)
|
if (relay && giaddr.s_addr != INADDR_LOOPBACK)
|
||||||
remote_port = 67;
|
remote_port = htons (67);
|
||||||
else
|
else
|
||||||
remote_port = htons (ntohs (local_port) - 1); /* XXX */
|
remote_port = htons (ntohs (local_port) - 1); /* XXX */
|
||||||
|
|
||||||
@ -679,7 +679,7 @@ void dhcpack (packet)
|
|||||||
DHO_DHCP_LEASE_TIME);
|
DHO_DHCP_LEASE_TIME);
|
||||||
memset (&ds, 0, sizeof ds);
|
memset (&ds, 0, sizeof ds);
|
||||||
if (oc &&
|
if (oc &&
|
||||||
evaluate_option_cache (&ds, packet, (struct lease *)0,
|
evaluate_option_cache (&ds, packet, (struct lease *)0, client,
|
||||||
packet -> options, client -> new -> options,
|
packet -> options, client -> new -> options,
|
||||||
&global_scope, oc, MDL)) {
|
&global_scope, oc, MDL)) {
|
||||||
if (ds.len > 3)
|
if (ds.len > 3)
|
||||||
@ -709,7 +709,7 @@ void dhcpack (packet)
|
|||||||
oc = lookup_option (&dhcp_universe, client -> new -> options,
|
oc = lookup_option (&dhcp_universe, client -> new -> options,
|
||||||
DHO_DHCP_RENEWAL_TIME);
|
DHO_DHCP_RENEWAL_TIME);
|
||||||
if (oc &&
|
if (oc &&
|
||||||
evaluate_option_cache (&ds, packet, (struct lease *)0,
|
evaluate_option_cache (&ds, packet, (struct lease *)0, client,
|
||||||
packet -> options, client -> new -> options,
|
packet -> options, client -> new -> options,
|
||||||
&global_scope, oc, MDL)) {
|
&global_scope, oc, MDL)) {
|
||||||
if (ds.len > 3)
|
if (ds.len > 3)
|
||||||
@ -734,7 +734,7 @@ void dhcpack (packet)
|
|||||||
oc = lookup_option (&dhcp_universe, client -> new -> options,
|
oc = lookup_option (&dhcp_universe, client -> new -> options,
|
||||||
DHO_DHCP_REBINDING_TIME);
|
DHO_DHCP_REBINDING_TIME);
|
||||||
if (oc &&
|
if (oc &&
|
||||||
evaluate_option_cache (&ds, packet, (struct lease *)0,
|
evaluate_option_cache (&ds, packet, (struct lease *)0, client,
|
||||||
packet -> options, client -> new -> options,
|
packet -> options, client -> new -> options,
|
||||||
&global_scope, oc, MDL)) {
|
&global_scope, oc, MDL)) {
|
||||||
if (ds.len > 3)
|
if (ds.len > 3)
|
||||||
@ -847,7 +847,7 @@ void state_bound (cpp)
|
|||||||
DHO_DHCP_SERVER_IDENTIFIER);
|
DHO_DHCP_SERVER_IDENTIFIER);
|
||||||
if (oc &&
|
if (oc &&
|
||||||
evaluate_option_cache (&ds, (struct packet *)0, (struct lease *)0,
|
evaluate_option_cache (&ds, (struct packet *)0, (struct lease *)0,
|
||||||
(struct option_state *)0,
|
client, (struct option_state *)0,
|
||||||
client -> active -> options,
|
client -> active -> options,
|
||||||
&global_scope, oc, MDL)) {
|
&global_scope, oc, MDL)) {
|
||||||
if (ds.len > 3) {
|
if (ds.len > 3) {
|
||||||
@ -1098,7 +1098,8 @@ struct client_lease *packet_to_lease (packet, client)
|
|||||||
memset (&data, 0, sizeof data);
|
memset (&data, 0, sizeof data);
|
||||||
if (oc &&
|
if (oc &&
|
||||||
client -> config -> vendor_space_name &&
|
client -> config -> vendor_space_name &&
|
||||||
evaluate_option_cache (&data, packet, (struct lease *)0,
|
evaluate_option_cache (&data, packet,
|
||||||
|
(struct lease *)0, client,
|
||||||
packet -> options, lease -> options,
|
packet -> options, lease -> options,
|
||||||
&global_scope, oc, MDL)) {
|
&global_scope, oc, MDL)) {
|
||||||
if (data.len) {
|
if (data.len) {
|
||||||
@ -1117,7 +1118,7 @@ struct client_lease *packet_to_lease (packet, client)
|
|||||||
oc = lookup_option (&dhcp_universe, lease -> options,
|
oc = lookup_option (&dhcp_universe, lease -> options,
|
||||||
DHO_DHCP_OPTION_OVERLOAD);
|
DHO_DHCP_OPTION_OVERLOAD);
|
||||||
if (oc &&
|
if (oc &&
|
||||||
evaluate_option_cache (&data, packet, (struct lease *)0,
|
evaluate_option_cache (&data, packet, (struct lease *)0, client,
|
||||||
packet -> options, lease -> options,
|
packet -> options, lease -> options,
|
||||||
&global_scope, oc, MDL)) {
|
&global_scope, oc, MDL)) {
|
||||||
if (data.len > 0)
|
if (data.len > 0)
|
||||||
@ -1168,8 +1169,9 @@ struct client_lease *packet_to_lease (packet, client)
|
|||||||
|
|
||||||
execute_statements_in_scope ((struct binding_value **)0,
|
execute_statements_in_scope ((struct binding_value **)0,
|
||||||
(struct packet *)packet,
|
(struct packet *)packet,
|
||||||
(struct lease *)0, lease -> options,
|
(struct lease *)0, client,
|
||||||
lease -> options, &global_scope,
|
lease -> options, lease -> options,
|
||||||
|
&global_scope,
|
||||||
client -> config -> on_receipt,
|
client -> config -> on_receipt,
|
||||||
(struct group *)0);
|
(struct group *)0);
|
||||||
|
|
||||||
@ -1733,7 +1735,7 @@ void make_client_options (client, lease, type, sid, rip, prl, op)
|
|||||||
if (client -> config -> on_transmission)
|
if (client -> config -> on_transmission)
|
||||||
execute_statements_in_scope
|
execute_statements_in_scope
|
||||||
((struct binding_value **)0,
|
((struct binding_value **)0,
|
||||||
(struct packet *)0, (struct lease *)0,
|
(struct packet *)0, (struct lease *)0, client,
|
||||||
(lease ? lease -> options : (struct option_state *)0),
|
(lease ? lease -> options : (struct option_state *)0),
|
||||||
*op, &global_scope,
|
*op, &global_scope,
|
||||||
client -> config -> on_transmission,
|
client -> config -> on_transmission,
|
||||||
@ -1760,7 +1762,7 @@ void make_discover (client, lease)
|
|||||||
/* Set up the option buffer... */
|
/* Set up the option buffer... */
|
||||||
client -> packet_length =
|
client -> packet_length =
|
||||||
cons_options ((struct packet *)0, &client -> packet,
|
cons_options ((struct packet *)0, &client -> packet,
|
||||||
(struct lease *)0, 0,
|
(struct lease *)0, client, 0,
|
||||||
(struct option_state *)0, options,
|
(struct option_state *)0, options,
|
||||||
&global_scope, 0, 0, 0, (struct data_string *)0,
|
&global_scope, 0, 0, 0, (struct data_string *)0,
|
||||||
client -> config -> vendor_space_name);
|
client -> config -> vendor_space_name);
|
||||||
@ -1829,7 +1831,7 @@ void make_request (client, lease)
|
|||||||
/* Set up the option buffer... */
|
/* Set up the option buffer... */
|
||||||
client -> packet_length =
|
client -> packet_length =
|
||||||
cons_options ((struct packet *)0, &client -> packet,
|
cons_options ((struct packet *)0, &client -> packet,
|
||||||
(struct lease *)0, 0,
|
(struct lease *)0, client, 0,
|
||||||
(struct option_state *)0, options,
|
(struct option_state *)0, options,
|
||||||
&global_scope, 0, 0, 0, (struct data_string *)0,
|
&global_scope, 0, 0, 0, (struct data_string *)0,
|
||||||
client -> config -> vendor_space_name);
|
client -> config -> vendor_space_name);
|
||||||
@ -1895,7 +1897,7 @@ void make_decline (client, lease)
|
|||||||
memset (&client -> packet, 0, sizeof (client -> packet));
|
memset (&client -> packet, 0, sizeof (client -> packet));
|
||||||
client -> packet_length =
|
client -> packet_length =
|
||||||
cons_options ((struct packet *)0, &client -> packet,
|
cons_options ((struct packet *)0, &client -> packet,
|
||||||
(struct lease *)0, 0,
|
(struct lease *)0, client, 0,
|
||||||
(struct option_state *)0, options,
|
(struct option_state *)0, options,
|
||||||
&global_scope, 0, 0, 0, (struct data_string *)0,
|
&global_scope, 0, 0, 0, (struct data_string *)0,
|
||||||
client -> config -> vendor_space_name);
|
client -> config -> vendor_space_name);
|
||||||
@ -1953,7 +1955,7 @@ void make_release (client, lease)
|
|||||||
/* Set up the option buffer... */
|
/* Set up the option buffer... */
|
||||||
client -> packet_length =
|
client -> packet_length =
|
||||||
cons_options ((struct packet *)0, &client -> packet,
|
cons_options ((struct packet *)0, &client -> packet,
|
||||||
(struct lease *)0, 0,
|
(struct lease *)0, client, 0,
|
||||||
(struct option_state *)0, options,
|
(struct option_state *)0, options,
|
||||||
&global_scope, 0, 0, 0, (struct data_string *)0,
|
&global_scope, 0, 0, 0, (struct data_string *)0,
|
||||||
client -> config -> vendor_space_name);
|
client -> config -> vendor_space_name);
|
||||||
@ -2043,6 +2045,7 @@ void rewrite_client_leases ()
|
|||||||
|
|
||||||
void write_lease_option (struct option_cache *oc,
|
void write_lease_option (struct option_cache *oc,
|
||||||
struct packet *packet, struct lease *lease,
|
struct packet *packet, struct lease *lease,
|
||||||
|
struct client_state *client_state,
|
||||||
struct option_state *in_options,
|
struct option_state *in_options,
|
||||||
struct option_state *cfg_options,
|
struct option_state *cfg_options,
|
||||||
struct binding_scope **scope,
|
struct binding_scope **scope,
|
||||||
@ -2062,7 +2065,7 @@ void write_lease_option (struct option_cache *oc,
|
|||||||
name = "";
|
name = "";
|
||||||
dot = "";
|
dot = "";
|
||||||
}
|
}
|
||||||
if (evaluate_option_cache (&ds, packet, lease,
|
if (evaluate_option_cache (&ds, packet, lease, client_state,
|
||||||
in_options, cfg_options, scope, oc, MDL)) {
|
in_options, cfg_options, scope, oc, MDL)) {
|
||||||
fprintf (leaseFile,
|
fprintf (leaseFile,
|
||||||
" option %s%s%s %s;\n",
|
" option %s%s%s %s;\n",
|
||||||
@ -2133,7 +2136,7 @@ int write_client_lease (client, lease, rewrite, makesure)
|
|||||||
|
|
||||||
for (i = 0; i < lease -> options -> universe_count; i++) {
|
for (i = 0; i < lease -> options -> universe_count; i++) {
|
||||||
option_space_foreach ((struct packet *)0, (struct lease *)0,
|
option_space_foreach ((struct packet *)0, (struct lease *)0,
|
||||||
(struct option_state *)0,
|
client, (struct option_state *)0,
|
||||||
lease -> options, &global_scope,
|
lease -> options, &global_scope,
|
||||||
universes [i],
|
universes [i],
|
||||||
client, write_lease_option);
|
client, write_lease_option);
|
||||||
@ -2218,6 +2221,7 @@ struct envadd_state {
|
|||||||
|
|
||||||
void client_option_envadd (struct option_cache *oc,
|
void client_option_envadd (struct option_cache *oc,
|
||||||
struct packet *packet, struct lease *lease,
|
struct packet *packet, struct lease *lease,
|
||||||
|
struct client_state *client_state,
|
||||||
struct option_state *in_options,
|
struct option_state *in_options,
|
||||||
struct option_state *cfg_options,
|
struct option_state *cfg_options,
|
||||||
struct binding_scope **scope,
|
struct binding_scope **scope,
|
||||||
@ -2227,7 +2231,7 @@ void client_option_envadd (struct option_cache *oc,
|
|||||||
struct data_string data;
|
struct data_string data;
|
||||||
memset (&data, 0, sizeof data);
|
memset (&data, 0, sizeof data);
|
||||||
|
|
||||||
if (evaluate_option_cache (&data, packet, lease,
|
if (evaluate_option_cache (&data, packet, lease, client_state,
|
||||||
in_options, cfg_options, scope, oc, MDL)) {
|
in_options, cfg_options, scope, oc, MDL)) {
|
||||||
if (data.len) {
|
if (data.len) {
|
||||||
char name [256];
|
char name [256];
|
||||||
@ -2272,9 +2276,8 @@ void script_write_params (client, prefix, lease)
|
|||||||
|
|
||||||
memset (&data, 0, sizeof data);
|
memset (&data, 0, sizeof data);
|
||||||
oc = lookup_option (&dhcp_universe, lease -> options, DHO_SUBNET_MASK);
|
oc = lookup_option (&dhcp_universe, lease -> options, DHO_SUBNET_MASK);
|
||||||
if (oc && evaluate_option_cache (&data,
|
if (oc && evaluate_option_cache (&data, (struct packet *)0,
|
||||||
(struct packet *)0,
|
(struct lease *)0, client,
|
||||||
(struct lease *)0,
|
|
||||||
(struct option_state *)0,
|
(struct option_state *)0,
|
||||||
lease -> options,
|
lease -> options,
|
||||||
&global_scope, oc, MDL)) {
|
&global_scope, oc, MDL)) {
|
||||||
@ -2296,7 +2299,7 @@ void script_write_params (client, prefix, lease)
|
|||||||
if (!oc ||
|
if (!oc ||
|
||||||
!(evaluate_option_cache
|
!(evaluate_option_cache
|
||||||
(&data, (struct packet *)0,
|
(&data, (struct packet *)0,
|
||||||
(struct lease *)0,
|
(struct lease *)0, client,
|
||||||
(struct option_state *)0,
|
(struct option_state *)0,
|
||||||
lease -> options,
|
lease -> options,
|
||||||
&global_scope, oc, MDL))) {
|
&global_scope, oc, MDL))) {
|
||||||
@ -2321,7 +2324,7 @@ void script_write_params (client, prefix, lease)
|
|||||||
|
|
||||||
for (i = 0; i < lease -> options -> universe_count; i++) {
|
for (i = 0; i < lease -> options -> universe_count; i++) {
|
||||||
option_space_foreach ((struct packet *)0, (struct lease *)0,
|
option_space_foreach ((struct packet *)0, (struct lease *)0,
|
||||||
(struct option_state *)0,
|
client, (struct option_state *)0,
|
||||||
lease -> options, &global_scope,
|
lease -> options, &global_scope,
|
||||||
universes [i],
|
universes [i],
|
||||||
&es, client_option_envadd);
|
&es, client_option_envadd);
|
||||||
@ -2582,7 +2585,7 @@ void do_release(client)
|
|||||||
DHO_DHCP_SERVER_IDENTIFIER);
|
DHO_DHCP_SERVER_IDENTIFIER);
|
||||||
if (oc &&
|
if (oc &&
|
||||||
evaluate_option_cache (&ds, (struct packet *)0,
|
evaluate_option_cache (&ds, (struct packet *)0,
|
||||||
(struct lease *)0,
|
(struct lease *)0, client,
|
||||||
(struct option_state *)0,
|
(struct option_state *)0,
|
||||||
client -> active -> options,
|
client -> active -> options,
|
||||||
&global_scope, oc, MDL)) {
|
&global_scope, oc, MDL)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user