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

Intermediary changes

This commit is contained in:
Ted Lemon
1998-10-22 04:52:23 +00:00
parent 94ab0b3be1
commit 14ecb5bacd

View File

@@ -42,7 +42,7 @@
#ifndef lint #ifndef lint
static char copyright[] = static char copyright[] =
"$Id: clparse.c,v 1.16 1998/04/20 18:05:44 mellon Exp $ Copyright (c) 1997 The Internet Software Consortium. All rights reserved.\n"; "$Id: clparse.c,v 1.17 1998/10/22 04:52:23 mellon Exp $ Copyright (c) 1997 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */ #endif /* not lint */
#include "dhcpd.h" #include "dhcpd.h"
@@ -51,7 +51,6 @@ static char copyright[] =
static TIME parsed_time; static TIME parsed_time;
struct client_config top_level_config; struct client_config top_level_config;
u_int32_t requested_lease_time;
/* client-conf-file :== client-declarations EOF /* client-conf-file :== client-declarations EOF
client-declarations :== <nil> client-declarations :== <nil>
@@ -106,11 +105,11 @@ int read_client_conf ()
top_level_config.requested_options top_level_config.requested_options
[top_level_config.requested_option_count++] = [top_level_config.requested_option_count++] =
DHO_HOST_NAME; DHO_HOST_NAME;
requested_lease_time = 7200; top_level_config.requested_lease_time = 7200;
top_level_config.send_options [DHO_DHCP_LEASE_TIME].data top_level_config.send_options.dhcp_options [DHO_DHCP_LEASE_TIME].data
= (unsigned char *)&requested_lease_time; = (unsigned char *)&top_level_config.requested_lease_time;
top_level_config.send_options [DHO_DHCP_LEASE_TIME].len top_level_config.send_options.dhcp_options [DHO_DHCP_LEASE_TIME].len
= sizeof requested_lease_time; = sizeof top_level_config.requested_lease_time;
if ((cfile = fopen (path_dhclient_conf, "r")) != NULL) { if ((cfile = fopen (path_dhclient_conf, "r")) != NULL) {
do { do {
@@ -126,7 +125,7 @@ int read_client_conf ()
} }
/* Set up state and config structures for clients that don't /* Set up state and config structures for clients that don't
have per-interface configuration declarations. */ have per-interface configuration statements. */
config = (struct client_config *)0; config = (struct client_config *)0;
for (ip = interfaces; ip; ip = ip -> next) { for (ip = interfaces; ip; ip = ip -> next) {
if (!ip -> client) { if (!ip -> client) {
@@ -136,6 +135,7 @@ int read_client_conf ()
error ("no memory for client state."); error ("no memory for client state.");
memset (ip -> client, 0, sizeof *(ip -> client)); memset (ip -> client, 0, sizeof *(ip -> client));
} }
if (!ip -> client -> config) { if (!ip -> client -> config) {
if (!config) { if (!config) {
config = (struct client_config *) config = (struct client_config *)
@@ -144,6 +144,12 @@ int read_client_conf ()
error ("no memory for client config."); error ("no memory for client config.");
memcpy (config, &top_level_config, memcpy (config, &top_level_config,
sizeof top_level_config); sizeof top_level_config);
i = DHO_DHCP_LEASE_TIME;
config -> send_options.dhcp_options [i].data =
(unsigned char *)&config -> requested_lease_time;
top_level_config.send_options.dhcp_options [DHO_DHCP_LEASE_TIME].len
= sizeof top_level_config.requested_lease_time;
} }
ip -> client -> config = config; ip -> client -> config = config;
} }
@@ -208,39 +214,47 @@ void parse_client_statement (cfile, ip, config)
int token; int token;
char *val; char *val;
struct option *option; struct option *option;
struct executable_statement *stmt, **p;
enum statement op op;
switch (next_token (&val, cfile)) { switch (next_token (&val, cfile)) {
case SEND: case SEND:
parse_option_decl (cfile, &config -> send_options [0]); p = &config -> on_tranmission;
op = send_option_statement;
do_option:
token = next_token (&val, cfile);
option = parse_option_name (cfile);
if (!option) {
*lose = 1;
return (struct executable_statement *)0;
}
stmt = parse_option_statement (cfile, 1, option,
send_option_statement);
for (; *p; p = &((*p) -> next))
;
*p = stmt;
stmt -> next = (struct executable_statement *)0;
return; return;
case DEFAULT: case DEFAULT:
option = parse_option_decl (cfile, &config -> defaults [0]); p = &config -> on_receipt;
if (option) op = default_option_statement;
config -> default_actions [option -> code] = goto do_option;
ACTION_DEFAULT;
return;
case SUPERSEDE: case SUPERSEDE:
option = parse_option_decl (cfile, &config -> defaults [0]); p = &config -> on_receipt;
if (option) op = supersede_option_statement;
config -> default_actions [option -> code] = goto do_option;
ACTION_SUPERSEDE;
return;
case APPEND: case APPEND:
option = parse_option_decl (cfile, &config -> defaults [0]); p = &config -> on_receipt;
if (option) op = append_option_statement;
config -> default_actions [option -> code] = goto do_option;
ACTION_APPEND;
return;
case PREPEND: case PREPEND:
option = parse_option_decl (cfile, &config -> defaults [0]); p = &config -> on_receipt;
if (option) op = prepend_option_statement;
config -> default_actions [option -> code] = goto do_option;
ACTION_PREPEND;
return;
case MEDIA: case MEDIA:
parse_string_list (cfile, &config -> media, 1); parse_string_list (cfile, &config -> media, 1);