1997-02-18 14:27:53 +00:00
|
|
|
/* clparse.c
|
|
|
|
|
|
|
|
Parser for dhclient config and lease files... */
|
|
|
|
|
|
|
|
/*
|
2008-01-24 02:43:06 +00:00
|
|
|
* Copyright (c) 2004-2008 by Internet Systems Consortium, Inc. ("ISC")
|
2005-03-17 20:15:29 +00:00
|
|
|
* Copyright (c) 1996-2003 by Internet Software Consortium
|
1997-02-18 14:27:53 +00:00
|
|
|
*
|
2005-03-17 20:15:29 +00:00
|
|
|
* Permission to use, copy, modify, and distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
1997-02-18 14:27:53 +00:00
|
|
|
*
|
2005-03-17 20:15:29 +00:00
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
|
|
|
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
1997-02-18 14:27:53 +00:00
|
|
|
*
|
2005-03-17 20:15:29 +00:00
|
|
|
* Internet Systems Consortium, Inc.
|
|
|
|
* 950 Charter Street
|
|
|
|
* Redwood City, CA 94063
|
|
|
|
* <info@isc.org>
|
|
|
|
* http://www.isc.org/
|
2000-03-17 04:00:32 +00:00
|
|
|
*
|
2005-03-17 20:15:29 +00:00
|
|
|
* This software has been written for Internet Systems Consortium
|
2000-03-17 04:00:32 +00:00
|
|
|
* by Ted Lemon in cooperation with Vixie Enterprises and Nominum, Inc.
|
2005-03-17 20:15:29 +00:00
|
|
|
* To learn more about Internet Systems Consortium, see
|
2000-03-17 04:00:32 +00:00
|
|
|
* ``http://www.isc.org/''. To learn more about Vixie Enterprises,
|
|
|
|
* see ``http://www.vix.com''. To learn more about Nominum, Inc., see
|
|
|
|
* ``http://www.nominum.com''.
|
1997-02-18 14:27:53 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "dhcpd.h"
|
2007-05-19 18:47:15 +00:00
|
|
|
#include <errno.h>
|
1997-02-18 14:27:53 +00:00
|
|
|
|
1997-03-28 23:50:15 +00:00
|
|
|
struct client_config top_level_config;
|
|
|
|
|
2007-08-23 16:06:09 +00:00
|
|
|
#define NUM_DEFAULT_REQUESTED_OPTS 9
|
|
|
|
struct option *default_requested_options[NUM_DEFAULT_REQUESTED_OPTS + 1];
|
1998-11-05 18:43:23 +00:00
|
|
|
|
2007-05-08 23:05:22 +00:00
|
|
|
static void parse_client_default_duid(struct parse *cfile);
|
|
|
|
static void parse_client6_lease_statement(struct parse *cfile);
|
2007-07-13 06:43:43 +00:00
|
|
|
#ifdef DHCPv6
|
2008-01-02 23:47:22 +00:00
|
|
|
static struct dhc6_ia *parse_client6_ia_na_statement(struct parse *cfile);
|
|
|
|
static struct dhc6_ia *parse_client6_ia_ta_statement(struct parse *cfile);
|
|
|
|
static struct dhc6_ia *parse_client6_ia_pd_statement(struct parse *cfile);
|
2007-05-08 23:05:22 +00:00
|
|
|
static struct dhc6_addr *parse_client6_iaaddr_statement(struct parse *cfile);
|
2008-01-02 23:47:22 +00:00
|
|
|
static struct dhc6_addr *parse_client6_iaprefix_statement(struct parse *cfile);
|
2007-07-13 06:43:43 +00:00
|
|
|
#endif /* DHCPv6 */
|
2007-05-08 23:05:22 +00:00
|
|
|
|
2001-03-01 18:17:09 +00:00
|
|
|
/* client-conf-file :== client-declarations END_OF_FILE
|
1997-02-18 14:27:53 +00:00
|
|
|
client-declarations :== <nil>
|
|
|
|
| client-declaration
|
|
|
|
| client-declarations client-declaration */
|
|
|
|
|
1999-10-01 03:11:20 +00:00
|
|
|
isc_result_t read_client_conf ()
|
1997-02-18 14:27:53 +00:00
|
|
|
{
|
|
|
|
struct client_config *config;
|
|
|
|
struct interface_info *ip;
|
2008-03-07 20:12:44 +00:00
|
|
|
struct parse *parse;
|
1999-10-01 03:11:20 +00:00
|
|
|
isc_result_t status;
|
2007-08-23 16:06:09 +00:00
|
|
|
unsigned code;
|
|
|
|
|
|
|
|
/* Initialize the default request list. */
|
|
|
|
memset(default_requested_options, 0, sizeof(default_requested_options));
|
|
|
|
|
|
|
|
/* 1 */
|
|
|
|
code = DHO_SUBNET_MASK;
|
|
|
|
option_code_hash_lookup(&default_requested_options[0],
|
|
|
|
dhcp_universe.code_hash, &code, 0, MDL);
|
|
|
|
|
|
|
|
/* 2 */
|
|
|
|
code = DHO_BROADCAST_ADDRESS;
|
|
|
|
option_code_hash_lookup(&default_requested_options[1],
|
|
|
|
dhcp_universe.code_hash, &code, 0, MDL);
|
|
|
|
|
|
|
|
/* 3 */
|
|
|
|
code = DHO_TIME_OFFSET;
|
|
|
|
option_code_hash_lookup(&default_requested_options[2],
|
|
|
|
dhcp_universe.code_hash, &code, 0, MDL);
|
|
|
|
|
|
|
|
/* 4 */
|
|
|
|
code = DHO_ROUTERS;
|
|
|
|
option_code_hash_lookup(&default_requested_options[3],
|
|
|
|
dhcp_universe.code_hash, &code, 0, MDL);
|
|
|
|
|
|
|
|
/* 5 */
|
|
|
|
code = DHO_DOMAIN_NAME;
|
|
|
|
option_code_hash_lookup(&default_requested_options[4],
|
|
|
|
dhcp_universe.code_hash, &code, 0, MDL);
|
|
|
|
|
|
|
|
/* 6 */
|
|
|
|
code = DHO_DOMAIN_NAME_SERVERS;
|
|
|
|
option_code_hash_lookup(&default_requested_options[5],
|
|
|
|
dhcp_universe.code_hash, &code, 0, MDL);
|
|
|
|
|
|
|
|
/* 7 */
|
|
|
|
code = DHO_HOST_NAME;
|
|
|
|
option_code_hash_lookup(&default_requested_options[6],
|
|
|
|
dhcp_universe.code_hash, &code, 0, MDL);
|
|
|
|
|
|
|
|
/* 8 */
|
|
|
|
code = D6O_NAME_SERVERS;
|
|
|
|
option_code_hash_lookup(&default_requested_options[7],
|
|
|
|
dhcpv6_universe.code_hash, &code, 0, MDL);
|
|
|
|
|
|
|
|
/* 9 */
|
|
|
|
code = D6O_DOMAIN_SEARCH;
|
|
|
|
option_code_hash_lookup(&default_requested_options[8],
|
|
|
|
dhcpv6_universe.code_hash, &code, 0, MDL);
|
|
|
|
|
|
|
|
for (code = 0 ; code < NUM_DEFAULT_REQUESTED_OPTS ; code++) {
|
|
|
|
if (default_requested_options[code] == NULL)
|
|
|
|
log_fatal("Unable to find option definition for "
|
|
|
|
"index %u during default parameter request "
|
|
|
|
"assembly.", code);
|
|
|
|
}
|
1997-02-18 14:27:53 +00:00
|
|
|
|
|
|
|
/* Initialize the top level client configuration. */
|
|
|
|
memset (&top_level_config, 0, sizeof top_level_config);
|
|
|
|
|
1997-03-28 23:50:15 +00:00
|
|
|
/* Set some defaults... */
|
|
|
|
top_level_config.timeout = 60;
|
|
|
|
top_level_config.select_interval = 0;
|
|
|
|
top_level_config.reboot_timeout = 10;
|
|
|
|
top_level_config.retry_interval = 300;
|
1999-03-26 19:19:46 +00:00
|
|
|
top_level_config.backoff_cutoff = 15;
|
|
|
|
top_level_config.initial_interval = 3;
|
1999-03-16 06:37:55 +00:00
|
|
|
top_level_config.bootp_policy = P_ACCEPT;
|
2001-03-22 06:56:00 +00:00
|
|
|
top_level_config.script_name = path_dhclient_script;
|
1998-11-05 18:43:23 +00:00
|
|
|
top_level_config.requested_options = default_requested_options;
|
2000-06-24 05:53:35 +00:00
|
|
|
top_level_config.omapi_port = -1;
|
2005-03-17 20:15:29 +00:00
|
|
|
top_level_config.do_forward_update = 1;
|
2007-05-08 23:05:22 +00:00
|
|
|
/* Requested lease time, used by DHCPv6 (DHCPv4 uses the option cache)
|
|
|
|
*/
|
|
|
|
top_level_config.requested_lease = 7200;
|
1997-03-28 23:50:15 +00:00
|
|
|
|
2000-05-16 23:03:49 +00:00
|
|
|
group_allocate (&top_level_config.on_receipt, MDL);
|
1998-11-11 07:48:23 +00:00
|
|
|
if (!top_level_config.on_receipt)
|
1999-02-24 17:56:53 +00:00
|
|
|
log_fatal ("no memory for top-level on_receipt group");
|
1998-11-11 07:48:23 +00:00
|
|
|
|
2000-05-16 23:03:49 +00:00
|
|
|
group_allocate (&top_level_config.on_transmission, MDL);
|
1998-11-11 07:48:23 +00:00
|
|
|
if (!top_level_config.on_transmission)
|
1999-02-24 17:56:53 +00:00
|
|
|
log_fatal ("no memory for top-level on_transmission group");
|
1998-11-11 07:48:23 +00:00
|
|
|
|
2001-06-27 00:31:20 +00:00
|
|
|
status = read_client_conf_file (path_dhclient_conf,
|
|
|
|
(struct interface_info *)0,
|
|
|
|
&top_level_config);
|
2008-03-07 20:12:44 +00:00
|
|
|
|
|
|
|
parse = NULL;
|
2001-06-27 00:31:20 +00:00
|
|
|
if (status != ISC_R_SUCCESS) {
|
|
|
|
;
|
2001-03-22 06:56:00 +00:00
|
|
|
#ifdef LATER
|
|
|
|
/* Set up the standard name service updater routine. */
|
2008-03-07 20:12:44 +00:00
|
|
|
status = new_parse(&parse, -1, default_client_config,
|
|
|
|
sizeof(default_client_config) - 1,
|
|
|
|
"default client configuration", 0);
|
2001-03-22 06:56:00 +00:00
|
|
|
if (status != ISC_R_SUCCESS)
|
|
|
|
log_fatal ("can't begin default client config!");
|
2008-03-07 20:12:44 +00:00
|
|
|
}
|
2001-03-22 06:56:00 +00:00
|
|
|
|
2008-03-07 20:12:44 +00:00
|
|
|
if (parse != NULL) {
|
2001-03-22 06:56:00 +00:00
|
|
|
do {
|
2008-03-07 20:12:44 +00:00
|
|
|
token = peek_token(&val, NULL, cfile);
|
2001-03-22 06:56:00 +00:00
|
|
|
if (token == END_OF_FILE)
|
|
|
|
break;
|
2008-03-07 20:12:44 +00:00
|
|
|
parse_client_statement(cfile, NULL, &top_level_config);
|
2001-03-22 06:56:00 +00:00
|
|
|
} while (1);
|
2008-03-07 20:12:44 +00:00
|
|
|
end_parse(&parse);
|
2001-03-22 06:56:00 +00:00
|
|
|
#endif
|
1998-03-16 20:00:00 +00:00
|
|
|
}
|
1997-02-18 14:27:53 +00:00
|
|
|
|
|
|
|
/* Set up state and config structures for clients that don't
|
1998-10-22 04:52:23 +00:00
|
|
|
have per-interface configuration statements. */
|
1997-02-18 14:27:53 +00:00
|
|
|
config = (struct client_config *)0;
|
|
|
|
for (ip = interfaces; ip; ip = ip -> next) {
|
|
|
|
if (!ip -> client) {
|
|
|
|
ip -> client = (struct client_state *)
|
2000-01-25 00:58:02 +00:00
|
|
|
dmalloc (sizeof (struct client_state), MDL);
|
1997-02-18 14:27:53 +00:00
|
|
|
if (!ip -> client)
|
1999-02-24 17:56:53 +00:00
|
|
|
log_fatal ("no memory for client state.");
|
1997-02-18 14:27:53 +00:00
|
|
|
memset (ip -> client, 0, sizeof *(ip -> client));
|
1999-03-09 19:58:42 +00:00
|
|
|
ip -> client -> interface = ip;
|
1997-02-19 10:53:16 +00:00
|
|
|
}
|
1998-10-22 04:52:23 +00:00
|
|
|
|
1997-02-19 10:53:16 +00:00
|
|
|
if (!ip -> client -> config) {
|
1997-02-18 14:27:53 +00:00
|
|
|
if (!config) {
|
|
|
|
config = (struct client_config *)
|
2000-01-25 00:58:02 +00:00
|
|
|
dmalloc (sizeof (struct client_config),
|
|
|
|
MDL);
|
1997-02-18 14:27:53 +00:00
|
|
|
if (!config)
|
1999-10-01 03:11:20 +00:00
|
|
|
log_fatal ("no memory for client config.");
|
1997-02-18 14:27:53 +00:00
|
|
|
memcpy (config, &top_level_config,
|
|
|
|
sizeof top_level_config);
|
|
|
|
}
|
|
|
|
ip -> client -> config = config;
|
|
|
|
}
|
|
|
|
}
|
1999-10-01 03:11:20 +00:00
|
|
|
return status;
|
1997-02-18 14:27:53 +00:00
|
|
|
}
|
|
|
|
|
2001-06-27 00:31:20 +00:00
|
|
|
int read_client_conf_file (const char *name, struct interface_info *ip,
|
|
|
|
struct client_config *client)
|
|
|
|
{
|
|
|
|
int file;
|
|
|
|
struct parse *cfile;
|
|
|
|
const char *val;
|
|
|
|
int token;
|
|
|
|
isc_result_t status;
|
|
|
|
|
|
|
|
if ((file = open (name, O_RDONLY)) < 0)
|
|
|
|
return uerr2isc (errno);
|
|
|
|
|
2008-03-07 20:12:44 +00:00
|
|
|
cfile = NULL;
|
|
|
|
status = new_parse(&cfile, file, NULL, 0, path_dhclient_conf, 0);
|
|
|
|
if (status != ISC_R_SUCCESS || cfile == NULL)
|
|
|
|
return status;
|
2001-06-27 00:31:20 +00:00
|
|
|
|
|
|
|
do {
|
|
|
|
token = peek_token (&val, (unsigned *)0, cfile);
|
|
|
|
if (token == END_OF_FILE)
|
|
|
|
break;
|
|
|
|
parse_client_statement (cfile, ip, client);
|
|
|
|
} while (1);
|
|
|
|
token = next_token (&val, (unsigned *)0, cfile);
|
|
|
|
status = (cfile -> warnings_occurred
|
|
|
|
? ISC_R_BADPARSE
|
|
|
|
: ISC_R_SUCCESS);
|
|
|
|
end_parse (&cfile);
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-03-01 18:17:09 +00:00
|
|
|
/* lease-file :== client-lease-statements END_OF_FILE
|
1997-02-18 14:27:53 +00:00
|
|
|
client-lease-statements :== <nil>
|
1997-02-22 12:25:32 +00:00
|
|
|
| client-lease-statements LEASE client-lease-statement */
|
1997-02-18 14:27:53 +00:00
|
|
|
|
|
|
|
void read_client_leases ()
|
|
|
|
{
|
1999-10-01 03:11:20 +00:00
|
|
|
int file;
|
2008-03-07 20:12:44 +00:00
|
|
|
isc_result_t status;
|
1999-10-01 03:11:20 +00:00
|
|
|
struct parse *cfile;
|
1999-10-07 06:36:35 +00:00
|
|
|
const char *val;
|
1997-02-18 14:27:53 +00:00
|
|
|
int token;
|
|
|
|
|
|
|
|
/* Open the lease file. If we can't open it, just return -
|
|
|
|
we can safely trust the server to remember our state. */
|
1999-10-01 03:11:20 +00:00
|
|
|
if ((file = open (path_dhclient_db, O_RDONLY)) < 0)
|
1997-02-18 14:27:53 +00:00
|
|
|
return;
|
2008-03-07 20:12:44 +00:00
|
|
|
|
|
|
|
cfile = NULL;
|
|
|
|
status = new_parse(&cfile, file, NULL, 0, path_dhclient_db, 0);
|
|
|
|
if (status != ISC_R_SUCCESS || cfile == NULL)
|
2007-10-05 14:47:43 +00:00
|
|
|
return;
|
1999-10-01 03:11:20 +00:00
|
|
|
|
1997-02-18 14:27:53 +00:00
|
|
|
do {
|
2001-03-17 00:47:39 +00:00
|
|
|
token = next_token (&val, (unsigned *)0, cfile);
|
2001-03-01 18:17:09 +00:00
|
|
|
if (token == END_OF_FILE)
|
1997-02-18 14:27:53 +00:00
|
|
|
break;
|
2007-05-08 23:05:22 +00:00
|
|
|
|
|
|
|
switch (token) {
|
|
|
|
case DEFAULT_DUID:
|
|
|
|
parse_client_default_duid(cfile);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LEASE:
|
|
|
|
parse_client_lease_statement(cfile, 0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LEASE6:
|
|
|
|
parse_client6_lease_statement(cfile);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
1999-02-24 17:56:53 +00:00
|
|
|
log_error ("Corrupt lease file - possible data loss!");
|
1997-02-18 14:27:53 +00:00
|
|
|
skip_to_semi (cfile);
|
|
|
|
break;
|
2007-05-08 23:05:22 +00:00
|
|
|
}
|
1997-02-18 14:27:53 +00:00
|
|
|
} while (1);
|
1999-10-01 03:11:20 +00:00
|
|
|
|
|
|
|
end_parse (&cfile);
|
1997-02-18 14:27:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* client-declaration :==
|
1997-02-22 08:38:32 +00:00
|
|
|
SEND option-decl |
|
|
|
|
DEFAULT option-decl |
|
1997-10-27 20:13:21 +00:00
|
|
|
SUPERSEDE option-decl |
|
1997-05-09 07:48:34 +00:00
|
|
|
PREPEND option-decl |
|
|
|
|
APPEND option-decl |
|
1997-02-18 14:27:53 +00:00
|
|
|
hardware-declaration |
|
2007-08-23 16:06:09 +00:00
|
|
|
ALSO REQUEST option-list |
|
|
|
|
ALSO REQUIRE option-list |
|
1997-02-18 14:27:53 +00:00
|
|
|
REQUEST option-list |
|
|
|
|
REQUIRE option-list |
|
|
|
|
TIMEOUT number |
|
|
|
|
RETRY number |
|
1997-03-05 06:24:21 +00:00
|
|
|
REBOOT number |
|
1997-02-18 14:27:53 +00:00
|
|
|
SELECT_TIMEOUT number |
|
|
|
|
SCRIPT string |
|
2000-10-10 19:44:39 +00:00
|
|
|
VENDOR_SPACE string |
|
1997-02-18 14:27:53 +00:00
|
|
|
interface-declaration |
|
1997-02-22 12:25:32 +00:00
|
|
|
LEASE client-lease-statement |
|
1999-02-25 23:30:43 +00:00
|
|
|
ALIAS client-lease-statement |
|
2000-04-06 22:31:16 +00:00
|
|
|
KEY key-definition */
|
1997-02-18 14:27:53 +00:00
|
|
|
|
|
|
|
void parse_client_statement (cfile, ip, config)
|
1999-10-01 03:11:20 +00:00
|
|
|
struct parse *cfile;
|
1997-02-18 14:27:53 +00:00
|
|
|
struct interface_info *ip;
|
|
|
|
struct client_config *config;
|
|
|
|
{
|
|
|
|
int token;
|
1999-10-07 06:36:35 +00:00
|
|
|
const char *val;
|
2006-06-01 20:23:18 +00:00
|
|
|
struct option *option = NULL;
|
2007-07-13 06:43:43 +00:00
|
|
|
struct executable_statement *stmt;
|
1998-11-06 00:10:58 +00:00
|
|
|
int lose;
|
1998-11-09 02:43:23 +00:00
|
|
|
char *name;
|
1999-03-09 23:38:37 +00:00
|
|
|
enum policy policy;
|
1999-10-07 06:36:35 +00:00
|
|
|
int known;
|
2000-10-10 19:44:39 +00:00
|
|
|
int tmp, i;
|
2001-06-27 00:31:20 +00:00
|
|
|
isc_result_t status;
|
2007-08-23 16:06:09 +00:00
|
|
|
struct option ***append_list, **new_list, **cat_list;
|
1997-02-18 14:27:53 +00:00
|
|
|
|
2001-03-17 00:47:39 +00:00
|
|
|
switch (peek_token (&val, (unsigned *)0, cfile)) {
|
2001-06-27 00:31:20 +00:00
|
|
|
case INCLUDE:
|
|
|
|
next_token (&val, (unsigned *)0, cfile);
|
|
|
|
token = next_token (&val, (unsigned *)0, cfile);
|
|
|
|
if (token != STRING) {
|
|
|
|
parse_warn (cfile, "filename string expected.");
|
|
|
|
skip_to_semi (cfile);
|
|
|
|
} else {
|
|
|
|
status = read_client_conf_file (val, ip, config);
|
|
|
|
if (status != ISC_R_SUCCESS)
|
|
|
|
parse_warn (cfile, "%s: bad parse.", val);
|
|
|
|
parse_semi (cfile);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
|
2000-04-06 22:31:16 +00:00
|
|
|
case KEY:
|
2001-03-17 00:47:39 +00:00
|
|
|
next_token (&val, (unsigned *)0, cfile);
|
1999-03-09 23:38:37 +00:00
|
|
|
if (ip) {
|
|
|
|
/* This may seem arbitrary, but there's a reason for
|
|
|
|
doing it: the authentication key database is not
|
|
|
|
scoped. If we allow the user to declare a key other
|
|
|
|
than in the outer scope, the user is very likely to
|
|
|
|
believe that the key will only be used in that
|
|
|
|
scope. If the user only wants the key to be used on
|
|
|
|
one interface, because it's known that the other
|
|
|
|
interface may be connected to an insecure net and
|
|
|
|
the secret key is considered sensitive, we don't
|
|
|
|
want to lull them into believing they've gotten
|
|
|
|
their way. This is a bit contrived, but people
|
|
|
|
tend not to be entirely rational about security. */
|
2000-04-06 22:31:16 +00:00
|
|
|
parse_warn (cfile, "key definition not allowed here.");
|
1999-03-09 23:38:37 +00:00
|
|
|
skip_to_semi (cfile);
|
|
|
|
break;
|
|
|
|
}
|
2000-04-06 22:31:16 +00:00
|
|
|
parse_key (cfile);
|
1999-03-09 23:38:37 +00:00
|
|
|
return;
|
|
|
|
|
2007-08-23 16:06:09 +00:00
|
|
|
case TOKEN_ALSO:
|
|
|
|
/* consume ALSO */
|
|
|
|
next_token(&val, NULL, cfile);
|
|
|
|
|
|
|
|
/* consume type of ALSO list. */
|
|
|
|
token = next_token(&val, NULL, cfile);
|
|
|
|
|
|
|
|
if (token == REQUEST) {
|
|
|
|
append_list = &config->requested_options;
|
|
|
|
} else if (token == REQUIRE) {
|
|
|
|
append_list = &config->required_options;
|
|
|
|
} else {
|
|
|
|
parse_warn(cfile, "expected REQUEST or REQUIRE list");
|
|
|
|
skip_to_semi(cfile);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If there is no list, cut the concat short. */
|
|
|
|
if (*append_list == NULL) {
|
|
|
|
parse_option_list(cfile, append_list);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Count the length of the existing list. */
|
|
|
|
for (i = 0 ; (*append_list)[i] != NULL ; i++)
|
|
|
|
; /* This space intentionally left blank. */
|
|
|
|
|
|
|
|
/* If there's no codes on the list, cut the concat short. */
|
|
|
|
if (i == 0) {
|
|
|
|
parse_option_list(cfile, append_list);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
tmp = parse_option_list(cfile, &new_list);
|
|
|
|
|
|
|
|
if (tmp == 0 || new_list == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Allocate 'i + tmp' buckets plus a terminator. */
|
|
|
|
cat_list = dmalloc(sizeof(struct option *) * (i + tmp + 1),
|
|
|
|
MDL);
|
|
|
|
|
|
|
|
if (cat_list == NULL) {
|
|
|
|
log_error("Unable to allocate memory for new "
|
|
|
|
"request list.");
|
|
|
|
skip_to_semi(cfile);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0 ; (*append_list)[i] != NULL ; i++)
|
|
|
|
option_reference(&cat_list[i], (*append_list)[i], MDL);
|
|
|
|
|
|
|
|
tmp = i;
|
|
|
|
|
|
|
|
for (i = 0 ; new_list[i] != 0 ; i++)
|
|
|
|
option_reference(&cat_list[tmp++], new_list[i], MDL);
|
|
|
|
|
|
|
|
cat_list[tmp] = 0;
|
|
|
|
|
|
|
|
/* XXX: We cannot free the old list, because it may have been
|
|
|
|
* XXX: assigned from an outer configuration scope (or may be
|
|
|
|
* XXX: the static default setting).
|
|
|
|
*/
|
|
|
|
*append_list = cat_list;
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
1999-03-09 23:38:37 +00:00
|
|
|
/* REQUIRE can either start a policy statement or a
|
2007-01-29 10:25:55 +00:00
|
|
|
comma-separated list of names of required options. */
|
1999-03-09 23:38:37 +00:00
|
|
|
case REQUIRE:
|
2001-03-17 00:47:39 +00:00
|
|
|
next_token (&val, (unsigned *)0, cfile);
|
|
|
|
token = peek_token (&val, (unsigned *)0, cfile);
|
1999-03-09 23:38:37 +00:00
|
|
|
if (token == AUTHENTICATION) {
|
|
|
|
policy = P_REQUIRE;
|
|
|
|
goto do_policy;
|
|
|
|
}
|
|
|
|
parse_option_list (cfile, &config -> required_options);
|
|
|
|
return;
|
|
|
|
|
|
|
|
case IGNORE:
|
2001-03-17 00:47:39 +00:00
|
|
|
next_token (&val, (unsigned *)0, cfile);
|
1999-03-09 23:38:37 +00:00
|
|
|
policy = P_IGNORE;
|
|
|
|
goto do_policy;
|
|
|
|
|
|
|
|
case ACCEPT:
|
2001-03-17 00:47:39 +00:00
|
|
|
next_token (&val, (unsigned *)0, cfile);
|
1999-03-09 23:38:37 +00:00
|
|
|
policy = P_ACCEPT;
|
|
|
|
goto do_policy;
|
|
|
|
|
|
|
|
case PREFER:
|
2001-03-17 00:47:39 +00:00
|
|
|
next_token (&val, (unsigned *)0, cfile);
|
1999-03-09 23:38:37 +00:00
|
|
|
policy = P_PREFER;
|
|
|
|
goto do_policy;
|
|
|
|
|
|
|
|
case DONT:
|
2001-03-17 00:47:39 +00:00
|
|
|
next_token (&val, (unsigned *)0, cfile);
|
1999-03-09 23:38:37 +00:00
|
|
|
policy = P_DONT;
|
|
|
|
goto do_policy;
|
|
|
|
|
|
|
|
do_policy:
|
2001-03-17 00:47:39 +00:00
|
|
|
token = next_token (&val, (unsigned *)0, cfile);
|
1999-03-09 23:38:37 +00:00
|
|
|
if (token == AUTHENTICATION) {
|
|
|
|
if (policy != P_PREFER &&
|
|
|
|
policy != P_REQUIRE &&
|
|
|
|
policy != P_DONT) {
|
1999-10-01 03:11:20 +00:00
|
|
|
parse_warn (cfile,
|
|
|
|
"invalid authentication policy.");
|
1999-03-09 23:38:37 +00:00
|
|
|
skip_to_semi (cfile);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
config -> auth_policy = policy;
|
2000-06-02 21:27:21 +00:00
|
|
|
} else if (token != TOKEN_BOOTP) {
|
1999-03-09 23:38:37 +00:00
|
|
|
if (policy != P_PREFER &&
|
|
|
|
policy != P_IGNORE &&
|
|
|
|
policy != P_ACCEPT) {
|
1999-10-01 03:11:20 +00:00
|
|
|
parse_warn (cfile, "invalid bootp policy.");
|
1999-03-09 23:38:37 +00:00
|
|
|
skip_to_semi (cfile);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
config -> bootp_policy = policy;
|
|
|
|
} else {
|
1999-10-01 03:11:20 +00:00
|
|
|
parse_warn (cfile, "expecting a policy type.");
|
1999-03-09 23:38:37 +00:00
|
|
|
skip_to_semi (cfile);
|
|
|
|
return;
|
|
|
|
}
|
1999-02-25 23:30:43 +00:00
|
|
|
break;
|
1999-03-09 23:38:37 +00:00
|
|
|
|
1999-03-25 21:45:55 +00:00
|
|
|
case OPTION:
|
2001-03-17 00:47:39 +00:00
|
|
|
token = next_token (&val, (unsigned *)0, cfile);
|
1999-04-05 15:08:13 +00:00
|
|
|
|
2001-03-17 00:47:39 +00:00
|
|
|
token = peek_token (&val, (unsigned *)0, cfile);
|
1999-04-05 15:08:13 +00:00
|
|
|
if (token == SPACE) {
|
|
|
|
if (ip) {
|
1999-10-01 03:11:20 +00:00
|
|
|
parse_warn (cfile,
|
|
|
|
"option space definitions %s",
|
1999-04-05 15:08:13 +00:00
|
|
|
" may not be scoped.");
|
|
|
|
skip_to_semi (cfile);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
parse_option_space_decl (cfile);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-06-01 20:23:18 +00:00
|
|
|
status = parse_option_name(cfile, 1, &known, &option);
|
|
|
|
if (status != ISC_R_SUCCESS || option == NULL)
|
1999-03-25 21:45:55 +00:00
|
|
|
return;
|
|
|
|
|
2001-03-17 00:47:39 +00:00
|
|
|
token = next_token (&val, (unsigned *)0, cfile);
|
1999-03-25 21:45:55 +00:00
|
|
|
if (token != CODE) {
|
1999-10-01 03:11:20 +00:00
|
|
|
parse_warn (cfile, "expecting \"code\" keyword.");
|
1999-03-25 21:45:55 +00:00
|
|
|
skip_to_semi (cfile);
|
2006-06-01 20:23:18 +00:00
|
|
|
option_dereference(&option, MDL);
|
1999-03-25 21:45:55 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (ip) {
|
1999-10-01 03:11:20 +00:00
|
|
|
parse_warn (cfile,
|
|
|
|
"option definitions may only appear in %s",
|
1999-03-25 21:45:55 +00:00
|
|
|
"the outermost scope.");
|
|
|
|
skip_to_semi (cfile);
|
2006-06-01 20:23:18 +00:00
|
|
|
option_dereference(&option, MDL);
|
1999-03-25 21:45:55 +00:00
|
|
|
return;
|
|
|
|
}
|
2006-06-01 20:23:18 +00:00
|
|
|
parse_option_code_definition(cfile, option);
|
|
|
|
option_dereference(&option, MDL);
|
1999-03-25 21:45:55 +00:00
|
|
|
return;
|
|
|
|
|
1997-02-22 08:38:32 +00:00
|
|
|
case MEDIA:
|
2001-03-17 00:47:39 +00:00
|
|
|
token = next_token (&val, (unsigned *)0, cfile);
|
1997-02-22 08:38:32 +00:00
|
|
|
parse_string_list (cfile, &config -> media, 1);
|
|
|
|
return;
|
1997-02-18 14:27:53 +00:00
|
|
|
|
|
|
|
case HARDWARE:
|
2001-03-17 00:47:39 +00:00
|
|
|
token = next_token (&val, (unsigned *)0, cfile);
|
1997-02-18 14:27:53 +00:00
|
|
|
if (ip) {
|
|
|
|
parse_hardware_param (cfile, &ip -> hw_address);
|
|
|
|
} else {
|
1999-10-01 03:11:20 +00:00
|
|
|
parse_warn (cfile, "hardware address parameter %s",
|
1997-02-18 14:27:53 +00:00
|
|
|
"not allowed here.");
|
|
|
|
skip_to_semi (cfile);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
|
2009-03-13 21:41:45 +00:00
|
|
|
case ANYCAST_MAC:
|
|
|
|
token = next_token(&val, NULL, cfile);
|
|
|
|
if (ip != NULL) {
|
|
|
|
parse_hardware_param(cfile, &ip->anycast_mac_addr);
|
|
|
|
} else {
|
|
|
|
parse_warn(cfile, "anycast mac address parameter "
|
|
|
|
"not allowed here.");
|
|
|
|
skip_to_semi (cfile);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
|
1997-02-18 14:27:53 +00:00
|
|
|
case REQUEST:
|
2001-03-17 00:47:39 +00:00
|
|
|
token = next_token (&val, (unsigned *)0, cfile);
|
1999-10-01 03:42:31 +00:00
|
|
|
if (config -> requested_options == default_requested_options)
|
2007-08-23 16:06:09 +00:00
|
|
|
config -> requested_options = NULL;
|
1998-11-05 18:43:23 +00:00
|
|
|
parse_option_list (cfile, &config -> requested_options);
|
1997-02-18 14:27:53 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
case TIMEOUT:
|
2001-03-17 00:47:39 +00:00
|
|
|
token = next_token (&val, (unsigned *)0, cfile);
|
1997-02-18 14:27:53 +00:00
|
|
|
parse_lease_time (cfile, &config -> timeout);
|
|
|
|
return;
|
|
|
|
|
|
|
|
case RETRY:
|
2001-03-17 00:47:39 +00:00
|
|
|
token = next_token (&val, (unsigned *)0, cfile);
|
1997-02-18 14:27:53 +00:00
|
|
|
parse_lease_time (cfile, &config -> retry_interval);
|
|
|
|
return;
|
|
|
|
|
|
|
|
case SELECT_TIMEOUT:
|
2001-03-17 00:47:39 +00:00
|
|
|
token = next_token (&val, (unsigned *)0, cfile);
|
1997-02-18 14:27:53 +00:00
|
|
|
parse_lease_time (cfile, &config -> select_interval);
|
|
|
|
return;
|
|
|
|
|
2000-06-24 05:53:35 +00:00
|
|
|
case OMAPI:
|
2001-04-05 20:37:55 +00:00
|
|
|
token = next_token (&val, (unsigned *)0, cfile);
|
2001-03-17 00:47:39 +00:00
|
|
|
token = next_token (&val, (unsigned *)0, cfile);
|
2000-06-24 05:53:35 +00:00
|
|
|
if (token != PORT) {
|
|
|
|
parse_warn (cfile,
|
|
|
|
"unexpected omapi subtype: %s", val);
|
|
|
|
skip_to_semi (cfile);
|
|
|
|
return;
|
|
|
|
}
|
2001-03-17 00:47:39 +00:00
|
|
|
token = next_token (&val, (unsigned *)0, cfile);
|
2000-06-24 05:53:35 +00:00
|
|
|
if (token != NUMBER) {
|
|
|
|
parse_warn (cfile, "invalid port number: `%s'", val);
|
|
|
|
skip_to_semi (cfile);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
tmp = atoi (val);
|
|
|
|
if (tmp < 0 || tmp > 65535)
|
|
|
|
parse_warn (cfile, "invalid omapi port %d.", tmp);
|
|
|
|
else if (config != &top_level_config)
|
|
|
|
parse_warn (cfile,
|
|
|
|
"omapi port only works at top level.");
|
|
|
|
else
|
|
|
|
config -> omapi_port = tmp;
|
|
|
|
parse_semi (cfile);
|
|
|
|
return;
|
|
|
|
|
2005-03-17 20:15:29 +00:00
|
|
|
case DO_FORWARD_UPDATE:
|
|
|
|
token = next_token (&val, (unsigned *)0, cfile);
|
|
|
|
token = next_token (&val, (unsigned *)0, cfile);
|
|
|
|
if (!strcasecmp (val, "on") ||
|
|
|
|
!strcasecmp (val, "true"))
|
|
|
|
config -> do_forward_update = 1;
|
|
|
|
else if (!strcasecmp (val, "off") ||
|
|
|
|
!strcasecmp (val, "false"))
|
|
|
|
config -> do_forward_update = 0;
|
|
|
|
else {
|
|
|
|
parse_warn (cfile, "expecting boolean value.");
|
|
|
|
skip_to_semi (cfile);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
parse_semi (cfile);
|
|
|
|
return;
|
|
|
|
|
1997-03-05 06:24:21 +00:00
|
|
|
case REBOOT:
|
2001-03-17 00:47:39 +00:00
|
|
|
token = next_token (&val, (unsigned *)0, cfile);
|
1997-03-05 06:24:21 +00:00
|
|
|
parse_lease_time (cfile, &config -> reboot_timeout);
|
|
|
|
return;
|
|
|
|
|
1997-03-29 01:23:17 +00:00
|
|
|
case BACKOFF_CUTOFF:
|
2001-03-17 00:47:39 +00:00
|
|
|
token = next_token (&val, (unsigned *)0, cfile);
|
1997-03-29 01:23:17 +00:00
|
|
|
parse_lease_time (cfile, &config -> backoff_cutoff);
|
|
|
|
return;
|
|
|
|
|
|
|
|
case INITIAL_INTERVAL:
|
2001-03-17 00:47:39 +00:00
|
|
|
token = next_token (&val, (unsigned *)0, cfile);
|
1997-03-29 01:23:17 +00:00
|
|
|
parse_lease_time (cfile, &config -> initial_interval);
|
|
|
|
return;
|
|
|
|
|
1997-02-18 14:27:53 +00:00
|
|
|
case SCRIPT:
|
2001-03-17 00:47:39 +00:00
|
|
|
token = next_token (&val, (unsigned *)0, cfile);
|
|
|
|
parse_string (cfile, &config -> script_name, (unsigned *)0);
|
1997-02-18 14:27:53 +00:00
|
|
|
return;
|
|
|
|
|
2000-10-10 19:44:39 +00:00
|
|
|
case VENDOR:
|
2001-03-17 00:47:39 +00:00
|
|
|
token = next_token (&val, (unsigned *)0, cfile);
|
|
|
|
token = next_token (&val, (unsigned *)0, cfile);
|
2000-10-10 19:44:39 +00:00
|
|
|
if (token != OPTION) {
|
|
|
|
parse_warn (cfile, "expecting 'vendor option space'");
|
|
|
|
skip_to_semi (cfile);
|
|
|
|
return;
|
|
|
|
}
|
2001-03-17 00:47:39 +00:00
|
|
|
token = next_token (&val, (unsigned *)0, cfile);
|
2000-10-10 19:44:39 +00:00
|
|
|
if (token != SPACE) {
|
|
|
|
parse_warn (cfile, "expecting 'vendor option space'");
|
|
|
|
skip_to_semi (cfile);
|
|
|
|
return;
|
|
|
|
}
|
2001-03-17 00:47:39 +00:00
|
|
|
token = next_token (&val, (unsigned *)0, cfile);
|
2000-11-24 03:38:18 +00:00
|
|
|
if (!is_identifier (token)) {
|
|
|
|
parse_warn (cfile, "expecting an identifier.");
|
|
|
|
skip_to_semi (cfile);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
config -> vendor_space_name = dmalloc (strlen (val) + 1, MDL);
|
|
|
|
if (!config -> vendor_space_name)
|
|
|
|
log_fatal ("no memory for vendor option space name.");
|
|
|
|
strcpy (config -> vendor_space_name, val);
|
2000-10-10 19:44:39 +00:00
|
|
|
for (i = 0; i < universe_count; i++)
|
|
|
|
if (!strcmp (universes [i] -> name,
|
|
|
|
config -> vendor_space_name))
|
|
|
|
break;
|
|
|
|
if (i == universe_count) {
|
|
|
|
log_error ("vendor option space %s not found.",
|
|
|
|
config -> vendor_space_name);
|
|
|
|
}
|
2000-11-24 03:38:18 +00:00
|
|
|
parse_semi (cfile);
|
2000-10-10 19:44:39 +00:00
|
|
|
return;
|
|
|
|
|
1997-02-18 14:27:53 +00:00
|
|
|
case INTERFACE:
|
2001-03-17 00:47:39 +00:00
|
|
|
token = next_token (&val, (unsigned *)0, cfile);
|
1997-02-18 14:27:53 +00:00
|
|
|
if (ip)
|
1999-10-01 03:11:20 +00:00
|
|
|
parse_warn (cfile, "nested interface declaration.");
|
1998-11-09 02:43:23 +00:00
|
|
|
parse_interface_declaration (cfile, config, (char *)0);
|
1997-02-18 14:27:53 +00:00
|
|
|
return;
|
|
|
|
|
1998-11-09 02:43:23 +00:00
|
|
|
case PSEUDO:
|
2001-03-17 00:47:39 +00:00
|
|
|
token = next_token (&val, (unsigned *)0, cfile);
|
|
|
|
token = next_token (&val, (unsigned *)0, cfile);
|
2000-01-25 00:58:02 +00:00
|
|
|
name = dmalloc (strlen (val) + 1, MDL);
|
1998-11-09 02:43:23 +00:00
|
|
|
if (!name)
|
1999-02-24 17:56:53 +00:00
|
|
|
log_fatal ("no memory for pseudo interface name");
|
1998-11-09 02:43:23 +00:00
|
|
|
strcpy (name, val);
|
|
|
|
parse_interface_declaration (cfile, config, name);
|
|
|
|
return;
|
|
|
|
|
1997-02-18 14:27:53 +00:00
|
|
|
case LEASE:
|
2001-03-17 00:47:39 +00:00
|
|
|
token = next_token (&val, (unsigned *)0, cfile);
|
1997-02-19 10:53:16 +00:00
|
|
|
parse_client_lease_statement (cfile, 1);
|
1997-02-18 14:27:53 +00:00
|
|
|
return;
|
|
|
|
|
1997-02-22 12:25:32 +00:00
|
|
|
case ALIAS:
|
2001-03-17 00:47:39 +00:00
|
|
|
token = next_token (&val, (unsigned *)0, cfile);
|
1997-02-22 12:25:32 +00:00
|
|
|
parse_client_lease_statement (cfile, 2);
|
|
|
|
return;
|
|
|
|
|
1997-06-02 22:34:19 +00:00
|
|
|
case REJECT:
|
2001-03-17 00:47:39 +00:00
|
|
|
token = next_token (&val, (unsigned *)0, cfile);
|
1997-06-02 22:34:19 +00:00
|
|
|
parse_reject_statement (cfile, config);
|
|
|
|
return;
|
|
|
|
|
1997-02-18 14:27:53 +00:00
|
|
|
default:
|
1998-11-06 00:10:58 +00:00
|
|
|
lose = 0;
|
1999-07-17 17:59:02 +00:00
|
|
|
stmt = (struct executable_statement *)0;
|
2000-01-08 01:26:40 +00:00
|
|
|
if (!parse_executable_statement (&stmt,
|
|
|
|
cfile, &lose, context_any)) {
|
1998-11-06 00:10:58 +00:00
|
|
|
if (!lose) {
|
1999-10-01 03:11:20 +00:00
|
|
|
parse_warn (cfile, "expecting a statement.");
|
1998-11-06 00:10:58 +00:00
|
|
|
skip_to_semi (cfile);
|
|
|
|
}
|
|
|
|
} else {
|
2001-01-25 08:17:17 +00:00
|
|
|
struct executable_statement **eptr, *sptr;
|
2001-06-27 00:31:20 +00:00
|
|
|
if (stmt &&
|
|
|
|
(stmt -> op == send_option_statement ||
|
|
|
|
(stmt -> op == on_statement &&
|
|
|
|
(stmt -> data.on.evtypes & ON_TRANSMISSION)))) {
|
2001-01-16 22:49:31 +00:00
|
|
|
eptr = &config -> on_transmission -> statements;
|
2001-01-25 08:17:17 +00:00
|
|
|
if (stmt -> op == on_statement) {
|
|
|
|
sptr = (struct executable_statement *)0;
|
|
|
|
executable_statement_reference
|
|
|
|
(&sptr,
|
|
|
|
stmt -> data.on.statements, MDL);
|
|
|
|
executable_statement_dereference (&stmt,
|
|
|
|
MDL);
|
|
|
|
executable_statement_reference (&stmt,
|
|
|
|
sptr,
|
|
|
|
MDL);
|
|
|
|
executable_statement_dereference (&sptr,
|
|
|
|
MDL);
|
|
|
|
}
|
|
|
|
} else
|
2001-01-16 22:49:31 +00:00
|
|
|
eptr = &config -> on_receipt -> statements;
|
|
|
|
|
2001-06-27 00:31:20 +00:00
|
|
|
if (stmt) {
|
|
|
|
for (; *eptr; eptr = &(*eptr) -> next)
|
|
|
|
;
|
|
|
|
executable_statement_reference (eptr,
|
|
|
|
stmt, MDL);
|
|
|
|
}
|
1998-11-06 00:10:58 +00:00
|
|
|
return;
|
|
|
|
}
|
1997-02-18 14:27:53 +00:00
|
|
|
break;
|
|
|
|
}
|
1998-11-06 00:10:58 +00:00
|
|
|
parse_semi (cfile);
|
1997-02-18 14:27:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* option-list :== option_name |
|
|
|
|
option_list COMMA option_name */
|
|
|
|
|
2007-08-23 16:06:09 +00:00
|
|
|
int
|
|
|
|
parse_option_list(struct parse *cfile, struct option ***list)
|
1997-02-18 14:27:53 +00:00
|
|
|
{
|
2005-03-17 20:15:29 +00:00
|
|
|
int ix;
|
1997-02-18 14:27:53 +00:00
|
|
|
int token;
|
1999-10-07 06:36:35 +00:00
|
|
|
const char *val;
|
2005-03-17 20:15:29 +00:00
|
|
|
pair p = (pair)0, q = (pair)0, r;
|
2006-06-01 20:23:18 +00:00
|
|
|
struct option *option = NULL;
|
|
|
|
isc_result_t status;
|
1997-02-18 14:27:53 +00:00
|
|
|
|
|
|
|
ix = 0;
|
|
|
|
do {
|
2005-03-17 20:15:29 +00:00
|
|
|
token = peek_token (&val, (unsigned *)0, cfile);
|
|
|
|
if (token == SEMI) {
|
|
|
|
token = next_token (&val, (unsigned *)0, cfile);
|
1999-11-13 23:46:46 +00:00
|
|
|
break;
|
2005-03-17 20:15:29 +00:00
|
|
|
}
|
1997-02-18 14:27:53 +00:00
|
|
|
if (!is_identifier (token)) {
|
2000-01-25 00:58:02 +00:00
|
|
|
parse_warn (cfile, "%s: expected option name.", val);
|
2005-03-17 20:15:29 +00:00
|
|
|
token = next_token (&val, (unsigned *)0, cfile);
|
1997-02-18 14:27:53 +00:00
|
|
|
skip_to_semi (cfile);
|
2007-08-23 16:06:09 +00:00
|
|
|
return 0;
|
1997-02-18 14:27:53 +00:00
|
|
|
}
|
2006-06-01 20:23:18 +00:00
|
|
|
status = parse_option_name(cfile, 0, NULL, &option);
|
|
|
|
if (status != ISC_R_SUCCESS || option == NULL) {
|
1999-10-12 16:00:34 +00:00
|
|
|
parse_warn (cfile, "%s: expected option name.", val);
|
2007-08-23 16:06:09 +00:00
|
|
|
return 0;
|
1997-02-18 14:27:53 +00:00
|
|
|
}
|
2000-01-25 00:58:02 +00:00
|
|
|
r = new_pair (MDL);
|
1998-11-05 18:43:23 +00:00
|
|
|
if (!r)
|
1999-02-24 17:56:53 +00:00
|
|
|
log_fatal ("can't allocate pair for option code.");
|
2007-08-23 16:06:09 +00:00
|
|
|
/* XXX: we should probably carry a reference across this */
|
|
|
|
r->car = (caddr_t)option;
|
2006-06-01 20:23:18 +00:00
|
|
|
option_dereference(&option, MDL);
|
1998-11-05 18:43:23 +00:00
|
|
|
r -> cdr = (pair)0;
|
|
|
|
if (p)
|
|
|
|
q -> cdr = r;
|
|
|
|
else
|
|
|
|
p = r;
|
|
|
|
q = r;
|
|
|
|
++ix;
|
2001-03-17 00:47:39 +00:00
|
|
|
token = next_token (&val, (unsigned *)0, cfile);
|
1997-02-18 14:27:53 +00:00
|
|
|
} while (token == COMMA);
|
|
|
|
if (token != SEMI) {
|
1999-10-01 03:11:20 +00:00
|
|
|
parse_warn (cfile, "expecting semicolon.");
|
1997-02-18 14:27:53 +00:00
|
|
|
skip_to_semi (cfile);
|
2007-08-23 16:06:09 +00:00
|
|
|
return 0;
|
1998-11-05 18:43:23 +00:00
|
|
|
}
|
2001-02-12 19:37:03 +00:00
|
|
|
/* XXX we can't free the list here, because we may have copied
|
|
|
|
XXX it from an outer config state. */
|
2007-08-23 16:06:09 +00:00
|
|
|
*list = NULL;
|
1999-11-13 23:46:46 +00:00
|
|
|
if (ix) {
|
2007-08-23 16:06:09 +00:00
|
|
|
*list = dmalloc ((ix + 1) * sizeof(struct option *), MDL);
|
1999-11-13 23:46:46 +00:00
|
|
|
if (!*list)
|
|
|
|
log_error ("no memory for option list.");
|
|
|
|
else {
|
|
|
|
ix = 0;
|
|
|
|
for (q = p; q; q = q -> cdr)
|
2007-08-23 16:06:09 +00:00
|
|
|
option_reference(&(*list)[ix++],
|
|
|
|
(struct option *)q->car, MDL);
|
|
|
|
(*list)[ix] = NULL;
|
1999-11-13 23:46:46 +00:00
|
|
|
}
|
|
|
|
while (p) {
|
|
|
|
q = p -> cdr;
|
2000-01-25 00:58:02 +00:00
|
|
|
free_pair (p, MDL);
|
1999-11-13 23:46:46 +00:00
|
|
|
p = q;
|
|
|
|
}
|
1997-02-18 14:27:53 +00:00
|
|
|
}
|
2007-08-23 16:06:09 +00:00
|
|
|
|
|
|
|
return ix;
|
1997-02-18 14:27:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* interface-declaration :==
|
|
|
|
INTERFACE string LBRACE client-declarations RBRACE */
|
|
|
|
|
1998-11-09 02:43:23 +00:00
|
|
|
void parse_interface_declaration (cfile, outer_config, name)
|
1999-10-01 03:11:20 +00:00
|
|
|
struct parse *cfile;
|
1997-02-18 14:27:53 +00:00
|
|
|
struct client_config *outer_config;
|
1998-11-09 02:43:23 +00:00
|
|
|
char *name;
|
1997-02-18 14:27:53 +00:00
|
|
|
{
|
|
|
|
int token;
|
1999-10-07 06:36:35 +00:00
|
|
|
const char *val;
|
1998-11-09 02:43:23 +00:00
|
|
|
struct client_state *client, **cp;
|
2000-06-12 20:08:56 +00:00
|
|
|
struct interface_info *ip = (struct interface_info *)0;
|
1997-02-18 14:27:53 +00:00
|
|
|
|
2001-03-17 00:47:39 +00:00
|
|
|
token = next_token (&val, (unsigned *)0, cfile);
|
1997-02-18 14:27:53 +00:00
|
|
|
if (token != STRING) {
|
1999-10-01 03:11:20 +00:00
|
|
|
parse_warn (cfile, "expecting interface name (in quotes).");
|
1997-02-18 14:27:53 +00:00
|
|
|
skip_to_semi (cfile);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2000-06-12 20:08:56 +00:00
|
|
|
if (!interface_or_dummy (&ip, val))
|
|
|
|
log_fatal ("Can't allocate interface %s.", val);
|
1997-02-18 14:27:53 +00:00
|
|
|
|
1998-11-09 02:43:23 +00:00
|
|
|
/* If we were given a name, this is a pseudo-interface. */
|
|
|
|
if (name) {
|
|
|
|
make_client_state (&client);
|
|
|
|
client -> name = name;
|
|
|
|
client -> interface = ip;
|
|
|
|
for (cp = &ip -> client; *cp; cp = &((*cp) -> next))
|
|
|
|
;
|
|
|
|
*cp = client;
|
|
|
|
} else {
|
|
|
|
if (!ip -> client) {
|
|
|
|
make_client_state (&ip -> client);
|
|
|
|
ip -> client -> interface = ip;
|
|
|
|
}
|
|
|
|
client = ip -> client;
|
|
|
|
}
|
1997-02-19 10:53:16 +00:00
|
|
|
|
1998-11-09 02:43:23 +00:00
|
|
|
if (!client -> config)
|
|
|
|
make_client_config (client, outer_config);
|
1997-02-18 14:27:53 +00:00
|
|
|
|
1997-09-16 18:08:32 +00:00
|
|
|
ip -> flags &= ~INTERFACE_AUTOMATIC;
|
|
|
|
interfaces_requested = 1;
|
|
|
|
|
2001-03-17 00:47:39 +00:00
|
|
|
token = next_token (&val, (unsigned *)0, cfile);
|
1997-02-18 14:27:53 +00:00
|
|
|
if (token != LBRACE) {
|
1999-10-01 03:11:20 +00:00
|
|
|
parse_warn (cfile, "expecting left brace.");
|
1997-02-18 14:27:53 +00:00
|
|
|
skip_to_semi (cfile);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
do {
|
2001-03-17 00:47:39 +00:00
|
|
|
token = peek_token (&val, (unsigned *)0, cfile);
|
2001-03-01 18:17:09 +00:00
|
|
|
if (token == END_OF_FILE) {
|
1999-10-01 03:11:20 +00:00
|
|
|
parse_warn (cfile,
|
|
|
|
"unterminated interface declaration.");
|
1997-02-18 14:27:53 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (token == RBRACE)
|
|
|
|
break;
|
1998-11-09 02:43:23 +00:00
|
|
|
parse_client_statement (cfile, ip, client -> config);
|
1997-02-18 14:27:53 +00:00
|
|
|
} while (1);
|
2001-03-17 00:47:39 +00:00
|
|
|
token = next_token (&val, (unsigned *)0, cfile);
|
1997-02-18 14:27:53 +00:00
|
|
|
}
|
|
|
|
|
2000-05-16 23:03:49 +00:00
|
|
|
int interface_or_dummy (struct interface_info **pi, const char *name)
|
1997-02-19 10:53:16 +00:00
|
|
|
{
|
2000-05-16 23:03:49 +00:00
|
|
|
struct interface_info *i;
|
|
|
|
struct interface_info *ip = (struct interface_info *)0;
|
2000-06-12 20:08:56 +00:00
|
|
|
isc_result_t status;
|
1997-02-19 10:53:16 +00:00
|
|
|
|
|
|
|
/* Find the interface (if any) that matches the name. */
|
2000-05-16 23:03:49 +00:00
|
|
|
for (i = interfaces; i; i = i -> next) {
|
|
|
|
if (!strcmp (i -> name, name)) {
|
|
|
|
interface_reference (&ip, i, MDL);
|
1997-02-19 10:53:16 +00:00
|
|
|
break;
|
2000-05-16 23:03:49 +00:00
|
|
|
}
|
1997-02-19 10:53:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* If it's not a real interface, see if it's on the dummy list. */
|
|
|
|
if (!ip) {
|
|
|
|
for (ip = dummy_interfaces; ip; ip = ip -> next) {
|
2000-05-16 23:03:49 +00:00
|
|
|
if (!strcmp (ip -> name, name)) {
|
|
|
|
interface_reference (&ip, i, MDL);
|
1997-02-19 10:53:16 +00:00
|
|
|
break;
|
2000-05-16 23:03:49 +00:00
|
|
|
}
|
1997-02-19 10:53:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If we didn't find an interface, make a dummy interface as
|
|
|
|
a placeholder. */
|
|
|
|
if (!ip) {
|
2005-03-17 20:15:29 +00:00
|
|
|
if ((status = interface_allocate (&ip, MDL)) != ISC_R_SUCCESS)
|
2000-05-16 23:03:49 +00:00
|
|
|
log_fatal ("Can't record interface %s: %s",
|
|
|
|
name, isc_result_totext (status));
|
2006-02-24 23:16:32 +00:00
|
|
|
|
|
|
|
if (strlen(name) >= sizeof(ip->name)) {
|
|
|
|
interface_dereference(&ip, MDL);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
strcpy(ip->name, name);
|
|
|
|
|
2000-05-16 23:03:49 +00:00
|
|
|
if (dummy_interfaces) {
|
|
|
|
interface_reference (&ip -> next,
|
|
|
|
dummy_interfaces, MDL);
|
|
|
|
interface_dereference (&dummy_interfaces, MDL);
|
|
|
|
}
|
|
|
|
interface_reference (&dummy_interfaces, ip, MDL);
|
1997-02-19 10:53:16 +00:00
|
|
|
}
|
2000-05-16 23:03:49 +00:00
|
|
|
if (pi)
|
2000-06-12 20:08:56 +00:00
|
|
|
status = interface_reference (pi, ip, MDL);
|
2005-03-17 20:15:29 +00:00
|
|
|
else
|
|
|
|
status = ISC_R_FAILURE;
|
2000-05-16 23:03:49 +00:00
|
|
|
interface_dereference (&ip, MDL);
|
2000-06-12 20:08:56 +00:00
|
|
|
if (status != ISC_R_SUCCESS)
|
|
|
|
return 0;
|
2000-05-16 23:03:49 +00:00
|
|
|
return 1;
|
1997-02-19 10:53:16 +00:00
|
|
|
}
|
|
|
|
|
1998-11-09 02:43:23 +00:00
|
|
|
void make_client_state (state)
|
|
|
|
struct client_state **state;
|
1997-02-19 10:53:16 +00:00
|
|
|
{
|
2000-01-25 00:58:02 +00:00
|
|
|
*state = ((struct client_state *)dmalloc (sizeof **state, MDL));
|
1998-11-09 02:43:23 +00:00
|
|
|
if (!*state)
|
1999-02-24 17:56:53 +00:00
|
|
|
log_fatal ("no memory for client state\n");
|
1998-11-09 02:43:23 +00:00
|
|
|
memset (*state, 0, sizeof **state);
|
1997-02-19 10:53:16 +00:00
|
|
|
}
|
|
|
|
|
1998-11-09 02:43:23 +00:00
|
|
|
void make_client_config (client, config)
|
|
|
|
struct client_state *client;
|
1997-02-19 10:53:16 +00:00
|
|
|
struct client_config *config;
|
|
|
|
{
|
1998-11-09 02:43:23 +00:00
|
|
|
client -> config = (((struct client_config *)
|
2000-01-25 00:58:02 +00:00
|
|
|
dmalloc (sizeof (struct client_config), MDL)));
|
1998-11-09 02:43:23 +00:00
|
|
|
if (!client -> config)
|
1999-02-24 17:56:53 +00:00
|
|
|
log_fatal ("no memory for client config\n");
|
1998-11-09 02:43:23 +00:00
|
|
|
memcpy (client -> config, config, sizeof *config);
|
2000-05-16 23:03:49 +00:00
|
|
|
if (!clone_group (&client -> config -> on_receipt,
|
|
|
|
config -> on_receipt, MDL) ||
|
|
|
|
!clone_group (&client -> config -> on_transmission,
|
|
|
|
config -> on_transmission, MDL))
|
|
|
|
log_fatal ("no memory for client state groups.");
|
1997-02-19 10:53:16 +00:00
|
|
|
}
|
|
|
|
|
1997-02-18 14:27:53 +00:00
|
|
|
/* client-lease-statement :==
|
2007-05-08 23:05:22 +00:00
|
|
|
LBRACE client-lease-declarations RBRACE
|
1997-02-18 14:27:53 +00:00
|
|
|
|
|
|
|
client-lease-declarations :==
|
|
|
|
<nil> |
|
|
|
|
client-lease-declaration |
|
|
|
|
client-lease-declarations client-lease-declaration */
|
|
|
|
|
|
|
|
|
1997-02-19 10:53:16 +00:00
|
|
|
void parse_client_lease_statement (cfile, is_static)
|
1999-10-01 03:11:20 +00:00
|
|
|
struct parse *cfile;
|
1997-02-19 10:53:16 +00:00
|
|
|
int is_static;
|
1997-02-18 14:27:53 +00:00
|
|
|
{
|
2005-03-17 20:15:29 +00:00
|
|
|
struct client_lease *lease, *lp, *pl, *next;
|
1998-11-09 02:43:23 +00:00
|
|
|
struct interface_info *ip = (struct interface_info *)0;
|
1997-02-18 14:27:53 +00:00
|
|
|
int token;
|
1999-10-07 06:36:35 +00:00
|
|
|
const char *val;
|
1998-11-09 02:43:23 +00:00
|
|
|
struct client_state *client = (struct client_state *)0;
|
1997-02-18 14:27:53 +00:00
|
|
|
|
2001-03-17 00:47:39 +00:00
|
|
|
token = next_token (&val, (unsigned *)0, cfile);
|
1997-02-18 14:27:53 +00:00
|
|
|
if (token != LBRACE) {
|
1999-10-01 03:11:20 +00:00
|
|
|
parse_warn (cfile, "expecting left brace.");
|
1997-02-18 14:27:53 +00:00
|
|
|
skip_to_semi (cfile);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2000-01-25 00:58:02 +00:00
|
|
|
lease = ((struct client_lease *)
|
|
|
|
dmalloc (sizeof (struct client_lease), MDL));
|
1997-02-18 14:27:53 +00:00
|
|
|
if (!lease)
|
1999-02-24 17:56:53 +00:00
|
|
|
log_fatal ("no memory for lease.\n");
|
1997-02-18 14:27:53 +00:00
|
|
|
memset (lease, 0, sizeof *lease);
|
1997-02-19 10:53:16 +00:00
|
|
|
lease -> is_static = is_static;
|
2000-01-25 00:58:02 +00:00
|
|
|
if (!option_state_allocate (&lease -> options, MDL))
|
1999-04-05 15:08:13 +00:00
|
|
|
log_fatal ("no memory for lease options.\n");
|
1997-02-18 14:27:53 +00:00
|
|
|
|
|
|
|
do {
|
2001-03-17 00:47:39 +00:00
|
|
|
token = peek_token (&val, (unsigned *)0, cfile);
|
2001-03-01 18:17:09 +00:00
|
|
|
if (token == END_OF_FILE) {
|
1999-10-01 03:11:20 +00:00
|
|
|
parse_warn (cfile, "unterminated lease declaration.");
|
1997-02-18 14:27:53 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (token == RBRACE)
|
|
|
|
break;
|
1998-11-09 02:43:23 +00:00
|
|
|
parse_client_lease_declaration (cfile, lease, &ip, &client);
|
1997-02-18 14:27:53 +00:00
|
|
|
} while (1);
|
2001-03-17 00:47:39 +00:00
|
|
|
token = next_token (&val, (unsigned *)0, cfile);
|
1997-02-18 14:27:53 +00:00
|
|
|
|
|
|
|
/* If the lease declaration didn't include an interface
|
|
|
|
declaration that we recognized, it's of no use to us. */
|
|
|
|
if (!ip) {
|
1998-11-05 18:43:23 +00:00
|
|
|
destroy_client_lease (lease);
|
1997-02-18 14:27:53 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1997-02-19 10:53:16 +00:00
|
|
|
/* Make sure there's a client state structure... */
|
1998-11-09 02:43:23 +00:00
|
|
|
if (!ip -> client) {
|
|
|
|
make_client_state (&ip -> client);
|
|
|
|
ip -> client -> interface = ip;
|
|
|
|
}
|
|
|
|
if (!client)
|
|
|
|
client = ip -> client;
|
1997-02-19 10:53:16 +00:00
|
|
|
|
1997-02-22 12:25:32 +00:00
|
|
|
/* If this is an alias lease, it doesn't need to be sorted in. */
|
|
|
|
if (is_static == 2) {
|
|
|
|
ip -> client -> alias = lease;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1997-03-05 06:24:21 +00:00
|
|
|
/* The new lease may supersede a lease that's not the
|
|
|
|
active lease but is still on the lease list, so scan the
|
|
|
|
lease list looking for a lease with the same address, and
|
|
|
|
if we find it, toss it. */
|
|
|
|
pl = (struct client_lease *)0;
|
2005-03-17 20:15:29 +00:00
|
|
|
for (lp = client -> leases; lp; lp = next) {
|
|
|
|
next = lp -> next;
|
1997-03-05 06:24:21 +00:00
|
|
|
if (lp -> address.len == lease -> address.len &&
|
|
|
|
!memcmp (lp -> address.iabuf, lease -> address.iabuf,
|
|
|
|
lease -> address.len)) {
|
|
|
|
if (pl)
|
2005-03-17 20:15:29 +00:00
|
|
|
pl -> next = next;
|
1997-03-05 06:24:21 +00:00
|
|
|
else
|
2005-03-17 20:15:29 +00:00
|
|
|
client -> leases = next;
|
1998-11-05 18:43:23 +00:00
|
|
|
destroy_client_lease (lp);
|
1997-03-05 06:24:21 +00:00
|
|
|
break;
|
2005-03-17 20:15:29 +00:00
|
|
|
} else
|
|
|
|
pl = lp;
|
1997-03-05 06:24:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* If this is a preloaded lease, just put it on the list of recorded
|
|
|
|
leases - don't make it the active lease. */
|
|
|
|
if (is_static) {
|
1998-11-09 02:43:23 +00:00
|
|
|
lease -> next = client -> leases;
|
|
|
|
client -> leases = lease;
|
1997-03-05 06:24:21 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1997-02-18 14:27:53 +00:00
|
|
|
/* The last lease in the lease file on a particular interface is
|
|
|
|
the active lease for that interface. Of course, we don't know
|
|
|
|
what the last lease in the file is until we've parsed the whole
|
|
|
|
file, so at this point, we assume that the lease we just parsed
|
|
|
|
is the active lease for its interface. If there's already
|
|
|
|
an active lease for the interface, and this lease is for the same
|
|
|
|
ip address, then we just toss the old active lease and replace
|
|
|
|
it with this one. If this lease is for a different address,
|
|
|
|
then if the old active lease has expired, we dump it; if not,
|
|
|
|
we put it on the list of leases for this interface which are
|
|
|
|
still valid but no longer active. */
|
1998-11-09 02:43:23 +00:00
|
|
|
if (client -> active) {
|
|
|
|
if (client -> active -> expiry < cur_time)
|
|
|
|
destroy_client_lease (client -> active);
|
|
|
|
else if (client -> active -> address.len ==
|
1997-02-18 14:27:53 +00:00
|
|
|
lease -> address.len &&
|
1998-11-09 02:43:23 +00:00
|
|
|
!memcmp (client -> active -> address.iabuf,
|
1997-02-18 14:27:53 +00:00
|
|
|
lease -> address.iabuf,
|
|
|
|
lease -> address.len))
|
1998-11-09 02:43:23 +00:00
|
|
|
destroy_client_lease (client -> active);
|
1997-02-18 14:27:53 +00:00
|
|
|
else {
|
1998-11-09 02:43:23 +00:00
|
|
|
client -> active -> next = client -> leases;
|
|
|
|
client -> leases = client -> active;
|
1997-02-18 14:27:53 +00:00
|
|
|
}
|
|
|
|
}
|
1998-11-09 02:43:23 +00:00
|
|
|
client -> active = lease;
|
1997-02-18 14:27:53 +00:00
|
|
|
|
|
|
|
/* phew. */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* client-lease-declaration :==
|
1997-05-09 07:48:34 +00:00
|
|
|
BOOTP |
|
1997-02-18 14:27:53 +00:00
|
|
|
INTERFACE string |
|
|
|
|
FIXED_ADDR ip_address |
|
|
|
|
FILENAME string |
|
|
|
|
SERVER_NAME string |
|
1997-02-22 08:38:32 +00:00
|
|
|
OPTION option-decl |
|
1997-02-18 14:27:53 +00:00
|
|
|
RENEW time-decl |
|
|
|
|
REBIND time-decl |
|
1999-03-09 23:38:37 +00:00
|
|
|
EXPIRE time-decl |
|
2000-04-06 22:31:16 +00:00
|
|
|
KEY id */
|
1997-02-18 14:27:53 +00:00
|
|
|
|
1998-11-09 02:43:23 +00:00
|
|
|
void parse_client_lease_declaration (cfile, lease, ipp, clientp)
|
1999-10-01 03:11:20 +00:00
|
|
|
struct parse *cfile;
|
1997-02-18 14:27:53 +00:00
|
|
|
struct client_lease *lease;
|
|
|
|
struct interface_info **ipp;
|
1998-11-09 02:43:23 +00:00
|
|
|
struct client_state **clientp;
|
1997-02-18 14:27:53 +00:00
|
|
|
{
|
|
|
|
int token;
|
1999-10-07 06:36:35 +00:00
|
|
|
const char *val;
|
1997-02-18 14:27:53 +00:00
|
|
|
struct interface_info *ip;
|
1998-11-05 18:43:23 +00:00
|
|
|
struct option_cache *oc;
|
1998-11-09 02:43:23 +00:00
|
|
|
struct client_state *client = (struct client_state *)0;
|
1997-02-18 14:27:53 +00:00
|
|
|
|
2001-03-17 00:47:39 +00:00
|
|
|
switch (next_token (&val, (unsigned *)0, cfile)) {
|
2000-04-06 22:31:16 +00:00
|
|
|
case KEY:
|
2001-03-17 00:47:39 +00:00
|
|
|
token = next_token (&val, (unsigned *)0, cfile);
|
2000-04-06 22:31:16 +00:00
|
|
|
if (token != STRING && !is_identifier (token)) {
|
|
|
|
parse_warn (cfile, "expecting key name.");
|
|
|
|
skip_to_semi (cfile);
|
|
|
|
break;
|
1999-03-09 23:38:37 +00:00
|
|
|
}
|
2000-08-03 21:00:41 +00:00
|
|
|
if (omapi_auth_key_lookup_name (&lease -> key, val) !=
|
|
|
|
ISC_R_SUCCESS)
|
2000-04-06 22:31:16 +00:00
|
|
|
parse_warn (cfile, "unknown key %s", val);
|
|
|
|
parse_semi (cfile);
|
1999-03-09 23:38:37 +00:00
|
|
|
break;
|
2000-06-02 21:27:21 +00:00
|
|
|
case TOKEN_BOOTP:
|
1997-05-09 07:48:34 +00:00
|
|
|
lease -> is_bootp = 1;
|
|
|
|
break;
|
|
|
|
|
1997-02-18 14:27:53 +00:00
|
|
|
case INTERFACE:
|
2001-03-17 00:47:39 +00:00
|
|
|
token = next_token (&val, (unsigned *)0, cfile);
|
1997-02-18 14:27:53 +00:00
|
|
|
if (token != STRING) {
|
1999-10-01 03:11:20 +00:00
|
|
|
parse_warn (cfile,
|
|
|
|
"expecting interface name (in quotes).");
|
1997-02-18 14:27:53 +00:00
|
|
|
skip_to_semi (cfile);
|
|
|
|
break;
|
|
|
|
}
|
2006-02-24 23:16:32 +00:00
|
|
|
if (!interface_or_dummy (ipp, val))
|
|
|
|
log_fatal ("Can't allocate interface %s.", val);
|
1997-02-18 14:27:53 +00:00
|
|
|
break;
|
|
|
|
|
1998-11-09 02:43:23 +00:00
|
|
|
case NAME:
|
2001-03-17 00:47:39 +00:00
|
|
|
token = next_token (&val, (unsigned *)0, cfile);
|
1998-11-09 02:43:23 +00:00
|
|
|
ip = *ipp;
|
|
|
|
if (!ip) {
|
1999-10-01 03:11:20 +00:00
|
|
|
parse_warn (cfile, "state name precedes interface.");
|
1998-11-09 02:43:23 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
for (client = ip -> client; client; client = client -> next)
|
1998-11-11 07:48:23 +00:00
|
|
|
if (client -> name && !strcmp (client -> name, val))
|
1998-11-09 02:43:23 +00:00
|
|
|
break;
|
|
|
|
if (!client)
|
1999-10-01 03:11:20 +00:00
|
|
|
parse_warn (cfile,
|
|
|
|
"lease specified for unknown pseudo.");
|
1998-11-09 02:43:23 +00:00
|
|
|
*clientp = client;
|
|
|
|
break;
|
|
|
|
|
1997-02-18 14:27:53 +00:00
|
|
|
case FIXED_ADDR:
|
1997-05-09 07:48:34 +00:00
|
|
|
if (!parse_ip_addr (cfile, &lease -> address))
|
|
|
|
return;
|
1997-02-18 14:27:53 +00:00
|
|
|
break;
|
|
|
|
|
1997-02-22 08:38:32 +00:00
|
|
|
case MEDIUM:
|
|
|
|
parse_string_list (cfile, &lease -> medium, 0);
|
|
|
|
return;
|
|
|
|
|
1997-02-18 14:27:53 +00:00
|
|
|
case FILENAME:
|
2001-03-17 00:47:39 +00:00
|
|
|
parse_string (cfile, &lease -> filename, (unsigned *)0);
|
1997-02-18 14:27:53 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
case SERVER_NAME:
|
2001-03-17 00:47:39 +00:00
|
|
|
parse_string (cfile, &lease -> server_name, (unsigned *)0);
|
1997-02-18 14:27:53 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
case RENEW:
|
|
|
|
lease -> renewal = parse_date (cfile);
|
|
|
|
return;
|
|
|
|
|
|
|
|
case REBIND:
|
|
|
|
lease -> rebind = parse_date (cfile);
|
|
|
|
return;
|
|
|
|
|
|
|
|
case EXPIRE:
|
|
|
|
lease -> expiry = parse_date (cfile);
|
|
|
|
return;
|
|
|
|
|
|
|
|
case OPTION:
|
1998-11-05 18:43:23 +00:00
|
|
|
oc = (struct option_cache *)0;
|
|
|
|
if (parse_option_decl (&oc, cfile)) {
|
2007-11-14 23:44:46 +00:00
|
|
|
save_option(oc->option->universe, lease->options, oc);
|
2000-01-25 00:58:02 +00:00
|
|
|
option_cache_dereference (&oc, MDL);
|
1998-11-05 18:43:23 +00:00
|
|
|
}
|
1997-02-18 14:27:53 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
default:
|
1999-10-01 03:11:20 +00:00
|
|
|
parse_warn (cfile, "expecting lease declaration.");
|
1997-02-18 14:27:53 +00:00
|
|
|
skip_to_semi (cfile);
|
|
|
|
break;
|
|
|
|
}
|
2001-03-17 00:47:39 +00:00
|
|
|
token = next_token (&val, (unsigned *)0, cfile);
|
1997-02-18 14:27:53 +00:00
|
|
|
if (token != SEMI) {
|
1999-10-01 03:11:20 +00:00
|
|
|
parse_warn (cfile, "expecting semicolon.");
|
1997-02-18 14:27:53 +00:00
|
|
|
skip_to_semi (cfile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-05-08 23:05:22 +00:00
|
|
|
/* Parse a default-duid ""; statement.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
parse_client_default_duid(struct parse *cfile)
|
|
|
|
{
|
|
|
|
struct data_string new_duid;
|
|
|
|
const char *val = NULL;
|
|
|
|
unsigned len;
|
|
|
|
int token;
|
|
|
|
|
|
|
|
memset(&new_duid, 0, sizeof(new_duid));
|
|
|
|
|
|
|
|
token = next_token(&val, &len, cfile);
|
|
|
|
if (token != STRING) {
|
|
|
|
parse_warn(cfile, "Expected DUID string.");
|
|
|
|
skip_to_semi(cfile);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (len <= 2) {
|
|
|
|
parse_warn(cfile, "Invalid DUID contents.");
|
|
|
|
skip_to_semi(cfile);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!buffer_allocate(&new_duid.buffer, len, MDL)) {
|
|
|
|
parse_warn(cfile, "Out of memory parsing default DUID.");
|
|
|
|
skip_to_semi(cfile);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
new_duid.data = new_duid.buffer->data;
|
|
|
|
new_duid.len = len;
|
|
|
|
|
|
|
|
memcpy(new_duid.buffer->data, val, len);
|
|
|
|
|
|
|
|
/* Rotate the last entry into place. */
|
|
|
|
if (default_duid.buffer != NULL)
|
|
|
|
data_string_forget(&default_duid, MDL);
|
|
|
|
data_string_copy(&default_duid, &new_duid, MDL);
|
|
|
|
data_string_forget(&new_duid, MDL);
|
|
|
|
|
|
|
|
parse_semi(cfile);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Parse a lease6 {} construct. The v6 client is a little different
|
|
|
|
* than the v4 client today, in that it only retains one lease, the
|
|
|
|
* active lease, and discards any less recent information. It may
|
|
|
|
* be useful in the future to cache additional information, but it
|
|
|
|
* is not worth the effort for the moment.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
parse_client6_lease_statement(struct parse *cfile)
|
|
|
|
{
|
2007-07-13 06:43:43 +00:00
|
|
|
#if !defined(DHCPv6)
|
|
|
|
parse_warn(cfile, "No DHCPv6 support.");
|
|
|
|
skip_to_semi(cfile);
|
|
|
|
#else /* defined(DHCPv6) */
|
2007-05-08 23:05:22 +00:00
|
|
|
struct option_cache *oc = NULL;
|
|
|
|
struct dhc6_lease *lease;
|
|
|
|
struct dhc6_ia **ia;
|
|
|
|
struct client_state *client = NULL;
|
|
|
|
struct interface_info *iface = NULL;
|
|
|
|
struct data_string ds;
|
|
|
|
const char *val;
|
|
|
|
unsigned len;
|
|
|
|
int token, has_ia, no_semi, has_name;
|
|
|
|
|
|
|
|
token = next_token(NULL, NULL, cfile);
|
|
|
|
if (token != LBRACE) {
|
|
|
|
parse_warn(cfile, "Expecting open curly brace.");
|
|
|
|
skip_to_semi(cfile);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
lease = dmalloc(sizeof(*lease), MDL);
|
|
|
|
if (lease == NULL) {
|
|
|
|
parse_warn(cfile, "Unable to allocate lease state.");
|
|
|
|
skip_to_rbrace(cfile, 1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
option_state_allocate(&lease->options, MDL);
|
|
|
|
if (lease->options == NULL) {
|
|
|
|
parse_warn(cfile, "Unable to allocate option cache.");
|
|
|
|
skip_to_rbrace(cfile, 1);
|
|
|
|
dfree(lease, MDL);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
has_ia = 0;
|
|
|
|
has_name = 0;
|
|
|
|
ia = &lease->bindings;
|
|
|
|
token = next_token(&val, NULL, cfile);
|
|
|
|
while (token != RBRACE) {
|
|
|
|
no_semi = 0;
|
|
|
|
|
|
|
|
switch(token) {
|
|
|
|
case IA_NA:
|
2008-01-02 23:47:22 +00:00
|
|
|
*ia = parse_client6_ia_na_statement(cfile);
|
|
|
|
if (*ia != NULL) {
|
|
|
|
ia = &(*ia)->next;
|
|
|
|
has_ia = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
no_semi = 1;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IA_TA:
|
|
|
|
*ia = parse_client6_ia_ta_statement(cfile);
|
|
|
|
if (*ia != NULL) {
|
|
|
|
ia = &(*ia)->next;
|
|
|
|
has_ia = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
no_semi = 1;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IA_PD:
|
|
|
|
*ia = parse_client6_ia_pd_statement(cfile);
|
2007-05-08 23:05:22 +00:00
|
|
|
if (*ia != NULL) {
|
|
|
|
ia = &(*ia)->next;
|
|
|
|
has_ia = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
no_semi = 1;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case INTERFACE:
|
|
|
|
if (iface != NULL) {
|
|
|
|
parse_warn(cfile, "Multiple interface names?");
|
|
|
|
skip_to_semi(cfile);
|
|
|
|
no_semi = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
token = next_token(&val, &len, cfile);
|
|
|
|
if (token != STRING) {
|
|
|
|
strerror:
|
|
|
|
parse_warn(cfile, "Expecting a string.");
|
|
|
|
skip_to_semi(cfile);
|
|
|
|
no_semi = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (iface = interfaces ; iface != NULL ;
|
|
|
|
iface = iface->next) {
|
|
|
|
if (strcmp(iface->name, val) == 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (iface == NULL) {
|
|
|
|
parse_warn(cfile, "Unknown interface.");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NAME:
|
|
|
|
has_name = 1;
|
|
|
|
|
|
|
|
if (client != NULL) {
|
|
|
|
parse_warn(cfile, "Multiple state names?");
|
|
|
|
skip_to_semi(cfile);
|
|
|
|
no_semi = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (iface == NULL) {
|
|
|
|
parse_warn(cfile, "Client name without "
|
|
|
|
"interface.");
|
|
|
|
skip_to_semi(cfile);
|
|
|
|
no_semi = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
token = next_token(&val, &len, cfile);
|
|
|
|
if (token != STRING)
|
|
|
|
goto strerror;
|
|
|
|
|
|
|
|
for (client = iface->client ; client != NULL ;
|
|
|
|
client = client->next) {
|
|
|
|
if ((client->name != NULL) &&
|
|
|
|
(strcmp(client->name, val) == 0))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (client == NULL) {
|
|
|
|
parse_warn(cfile, "Unknown client state %s.",
|
|
|
|
val);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OPTION:
|
|
|
|
if (parse_option_decl(&oc, cfile)) {
|
|
|
|
save_option(oc->option->universe,
|
|
|
|
lease->options, oc);
|
|
|
|
option_cache_dereference(&oc, MDL);
|
|
|
|
}
|
|
|
|
no_semi = 1;
|
|
|
|
break;
|
|
|
|
|
2008-02-20 23:20:58 +00:00
|
|
|
case TOKEN_RELEASED:
|
|
|
|
case TOKEN_ABANDONED:
|
|
|
|
lease->released = ISC_TRUE;
|
|
|
|
break;
|
|
|
|
|
2007-05-08 23:05:22 +00:00
|
|
|
default:
|
|
|
|
parse_warn(cfile, "Unexpected token, %s.", val);
|
|
|
|
no_semi = 1;
|
|
|
|
skip_to_semi(cfile);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!no_semi)
|
|
|
|
parse_semi(cfile);
|
|
|
|
|
|
|
|
token = next_token(&val, NULL, cfile);
|
|
|
|
|
|
|
|
if (token == END_OF_FILE) {
|
|
|
|
parse_warn(cfile, "Unexpected end of file.");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!has_ia) {
|
|
|
|
log_debug("Lease with no IA's discarded from lease db.");
|
2007-12-08 19:36:00 +00:00
|
|
|
dhc6_lease_destroy(&lease, MDL);
|
2007-05-08 23:05:22 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (iface == NULL)
|
|
|
|
parse_warn(cfile, "Lease has no interface designation.");
|
2008-05-23 13:22:23 +00:00
|
|
|
else if (!has_name && (client == NULL)) {
|
2007-05-08 23:05:22 +00:00
|
|
|
for (client = iface->client ; client != NULL ;
|
|
|
|
client = client->next) {
|
|
|
|
if (client->name == NULL)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (client == NULL) {
|
|
|
|
parse_warn(cfile, "No matching client state.");
|
2007-12-08 19:36:00 +00:00
|
|
|
dhc6_lease_destroy(&lease, MDL);
|
2007-05-08 23:05:22 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Fetch Preference option from option cache. */
|
|
|
|
memset(&ds, 0, sizeof(ds));
|
|
|
|
oc = lookup_option(&dhcpv6_universe, lease->options, D6O_PREFERENCE);
|
|
|
|
if ((oc != NULL) &&
|
|
|
|
evaluate_option_cache(&ds, NULL, NULL, NULL, lease->options,
|
|
|
|
NULL, &global_scope, oc, MDL)) {
|
|
|
|
if (ds.len != 1) {
|
|
|
|
log_error("Invalid length of DHCPv6 Preference option "
|
|
|
|
"(%d != 1)", ds.len);
|
|
|
|
data_string_forget(&ds, MDL);
|
2007-12-08 19:36:00 +00:00
|
|
|
dhc6_lease_destroy(&lease, MDL);
|
2007-05-08 23:05:22 +00:00
|
|
|
return;
|
|
|
|
} else
|
|
|
|
lease->pref = ds.data[0];
|
|
|
|
|
|
|
|
data_string_forget(&ds, MDL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Fetch server-id option from option cache. */
|
|
|
|
oc = lookup_option(&dhcpv6_universe, lease->options, D6O_SERVERID);
|
|
|
|
if ((oc == NULL) ||
|
|
|
|
!evaluate_option_cache(&lease->server_id, NULL, NULL, NULL,
|
|
|
|
lease->options, NULL, &global_scope, oc,
|
|
|
|
MDL) ||
|
|
|
|
(lease->server_id.len == 0)) {
|
|
|
|
/* This should be impossible... */
|
|
|
|
log_error("Invalid SERVERID option cache.");
|
2007-12-08 19:36:00 +00:00
|
|
|
dhc6_lease_destroy(&lease, MDL);
|
2007-05-08 23:05:22 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (client->active_lease != NULL)
|
2007-12-08 19:36:00 +00:00
|
|
|
dhc6_lease_destroy(&client->active_lease, MDL);
|
2007-05-08 23:05:22 +00:00
|
|
|
|
|
|
|
client->active_lease = lease;
|
2007-05-19 18:47:15 +00:00
|
|
|
#endif /* defined(DHCPv6) */
|
2007-05-08 23:05:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Parse an ia_na object from the client lease.
|
|
|
|
*/
|
2007-07-13 06:43:43 +00:00
|
|
|
#ifdef DHCPv6
|
2007-05-08 23:05:22 +00:00
|
|
|
static struct dhc6_ia *
|
2008-01-02 23:47:22 +00:00
|
|
|
parse_client6_ia_na_statement(struct parse *cfile)
|
2007-05-08 23:05:22 +00:00
|
|
|
{
|
|
|
|
struct data_string id;
|
|
|
|
struct option_cache *oc = NULL;
|
|
|
|
struct dhc6_ia *ia;
|
|
|
|
struct dhc6_addr **addr;
|
|
|
|
const char *val;
|
|
|
|
int token, no_semi;
|
|
|
|
|
|
|
|
ia = dmalloc(sizeof(*ia), MDL);
|
|
|
|
if (ia == NULL) {
|
|
|
|
parse_warn(cfile, "Out of memory allocating IA_NA state.");
|
|
|
|
skip_to_semi(cfile);
|
|
|
|
return NULL;
|
|
|
|
}
|
2008-01-02 23:47:22 +00:00
|
|
|
ia->ia_type = D6O_IA_NA;
|
2007-05-08 23:05:22 +00:00
|
|
|
|
|
|
|
/* Get IAID. */
|
|
|
|
memset(&id, 0, sizeof(id));
|
|
|
|
if (parse_cshl(&id, cfile)) {
|
|
|
|
if (id.len == 4)
|
|
|
|
memcpy(ia->iaid, id.data, 4);
|
|
|
|
else {
|
|
|
|
parse_warn(cfile, "Expecting IAID of length 4, got %d.",
|
|
|
|
id.len);
|
|
|
|
skip_to_semi(cfile);
|
|
|
|
dfree(ia, MDL);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
data_string_forget(&id, MDL);
|
|
|
|
} else {
|
|
|
|
parse_warn(cfile, "Expecting IAID.");
|
|
|
|
skip_to_semi(cfile);
|
|
|
|
dfree(ia, MDL);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
token = next_token(NULL, NULL, cfile);
|
|
|
|
if (token != LBRACE) {
|
|
|
|
parse_warn(cfile, "Expecting open curly brace.");
|
|
|
|
skip_to_semi(cfile);
|
|
|
|
dfree(ia, MDL);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
option_state_allocate(&ia->options, MDL);
|
|
|
|
if (ia->options == NULL) {
|
|
|
|
parse_warn(cfile, "Unable to allocate option state.");
|
|
|
|
skip_to_rbrace(cfile, 1);
|
|
|
|
dfree(ia, MDL);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
addr = &ia->addrs;
|
|
|
|
token = next_token(&val, NULL, cfile);
|
|
|
|
while (token != RBRACE) {
|
|
|
|
no_semi = 0;
|
|
|
|
|
|
|
|
switch (token) {
|
|
|
|
case STARTS:
|
|
|
|
token = next_token(&val, NULL, cfile);
|
|
|
|
if (token == NUMBER) {
|
|
|
|
ia->starts = atoi(val);
|
|
|
|
} else {
|
|
|
|
parse_warn(cfile, "Expecting a number.");
|
|
|
|
skip_to_semi(cfile);
|
|
|
|
no_semi = 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RENEW:
|
|
|
|
token = next_token(&val, NULL, cfile);
|
|
|
|
if (token == NUMBER) {
|
|
|
|
ia->renew = atoi(val);
|
|
|
|
} else {
|
|
|
|
parse_warn(cfile, "Expecting a number.");
|
|
|
|
skip_to_semi(cfile);
|
|
|
|
no_semi = 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case REBIND:
|
|
|
|
token = next_token(&val, NULL, cfile);
|
|
|
|
if (token == NUMBER) {
|
|
|
|
ia->rebind = atoi(val);
|
|
|
|
} else {
|
|
|
|
parse_warn(cfile, "Expecting a number.");
|
|
|
|
skip_to_semi(cfile);
|
|
|
|
no_semi = 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IAADDR:
|
|
|
|
*addr = parse_client6_iaaddr_statement(cfile);
|
|
|
|
|
|
|
|
if (*addr != NULL)
|
|
|
|
addr = &(*addr)->next;
|
|
|
|
|
|
|
|
no_semi = 1;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OPTION:
|
|
|
|
if (parse_option_decl(&oc, cfile)) {
|
|
|
|
save_option(oc->option->universe,
|
|
|
|
ia->options, oc);
|
|
|
|
option_cache_dereference(&oc, MDL);
|
|
|
|
}
|
|
|
|
no_semi = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
parse_warn(cfile, "Unexpected token.");
|
|
|
|
no_semi = 1;
|
|
|
|
skip_to_semi(cfile);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!no_semi)
|
|
|
|
parse_semi(cfile);
|
|
|
|
|
|
|
|
token = next_token(&val, NULL, cfile);
|
|
|
|
|
|
|
|
if (token == END_OF_FILE) {
|
|
|
|
parse_warn(cfile, "Unexpected end of file.");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ia;
|
|
|
|
}
|
2007-07-13 06:43:43 +00:00
|
|
|
#endif /* DHCPv6 */
|
2007-05-08 23:05:22 +00:00
|
|
|
|
2008-01-02 23:47:22 +00:00
|
|
|
/* Parse an ia_ta object from the client lease.
|
|
|
|
*/
|
|
|
|
#ifdef DHCPv6
|
|
|
|
static struct dhc6_ia *
|
|
|
|
parse_client6_ia_ta_statement(struct parse *cfile)
|
|
|
|
{
|
|
|
|
struct data_string id;
|
|
|
|
struct option_cache *oc = NULL;
|
|
|
|
struct dhc6_ia *ia;
|
|
|
|
struct dhc6_addr **addr;
|
|
|
|
const char *val;
|
|
|
|
int token, no_semi;
|
|
|
|
|
|
|
|
ia = dmalloc(sizeof(*ia), MDL);
|
|
|
|
if (ia == NULL) {
|
|
|
|
parse_warn(cfile, "Out of memory allocating IA_TA state.");
|
|
|
|
skip_to_semi(cfile);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
ia->ia_type = D6O_IA_TA;
|
|
|
|
|
|
|
|
/* Get IAID. */
|
|
|
|
memset(&id, 0, sizeof(id));
|
|
|
|
if (parse_cshl(&id, cfile)) {
|
|
|
|
if (id.len == 4)
|
|
|
|
memcpy(ia->iaid, id.data, 4);
|
|
|
|
else {
|
|
|
|
parse_warn(cfile, "Expecting IAID of length 4, got %d.",
|
|
|
|
id.len);
|
|
|
|
skip_to_semi(cfile);
|
|
|
|
dfree(ia, MDL);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
data_string_forget(&id, MDL);
|
|
|
|
} else {
|
|
|
|
parse_warn(cfile, "Expecting IAID.");
|
|
|
|
skip_to_semi(cfile);
|
|
|
|
dfree(ia, MDL);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
token = next_token(NULL, NULL, cfile);
|
|
|
|
if (token != LBRACE) {
|
|
|
|
parse_warn(cfile, "Expecting open curly brace.");
|
|
|
|
skip_to_semi(cfile);
|
|
|
|
dfree(ia, MDL);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
option_state_allocate(&ia->options, MDL);
|
|
|
|
if (ia->options == NULL) {
|
|
|
|
parse_warn(cfile, "Unable to allocate option state.");
|
|
|
|
skip_to_rbrace(cfile, 1);
|
|
|
|
dfree(ia, MDL);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
addr = &ia->addrs;
|
|
|
|
token = next_token(&val, NULL, cfile);
|
|
|
|
while (token != RBRACE) {
|
|
|
|
no_semi = 0;
|
|
|
|
|
|
|
|
switch (token) {
|
|
|
|
case STARTS:
|
|
|
|
token = next_token(&val, NULL, cfile);
|
|
|
|
if (token == NUMBER) {
|
|
|
|
ia->starts = atoi(val);
|
|
|
|
} else {
|
|
|
|
parse_warn(cfile, "Expecting a number.");
|
|
|
|
skip_to_semi(cfile);
|
|
|
|
no_semi = 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* No RENEW or REBIND */
|
|
|
|
|
|
|
|
case IAADDR:
|
|
|
|
*addr = parse_client6_iaaddr_statement(cfile);
|
|
|
|
|
|
|
|
if (*addr != NULL)
|
|
|
|
addr = &(*addr)->next;
|
|
|
|
|
|
|
|
no_semi = 1;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OPTION:
|
|
|
|
if (parse_option_decl(&oc, cfile)) {
|
|
|
|
save_option(oc->option->universe,
|
|
|
|
ia->options, oc);
|
|
|
|
option_cache_dereference(&oc, MDL);
|
|
|
|
}
|
|
|
|
no_semi = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
parse_warn(cfile, "Unexpected token.");
|
|
|
|
no_semi = 1;
|
|
|
|
skip_to_semi(cfile);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!no_semi)
|
|
|
|
parse_semi(cfile);
|
|
|
|
|
|
|
|
token = next_token(&val, NULL, cfile);
|
|
|
|
|
|
|
|
if (token == END_OF_FILE) {
|
|
|
|
parse_warn(cfile, "Unexpected end of file.");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ia;
|
|
|
|
}
|
|
|
|
#endif /* DHCPv6 */
|
|
|
|
|
|
|
|
/* Parse an ia_pd object from the client lease.
|
|
|
|
*/
|
|
|
|
#ifdef DHCPv6
|
|
|
|
static struct dhc6_ia *
|
|
|
|
parse_client6_ia_pd_statement(struct parse *cfile)
|
|
|
|
{
|
|
|
|
struct data_string id;
|
|
|
|
struct option_cache *oc = NULL;
|
|
|
|
struct dhc6_ia *ia;
|
|
|
|
struct dhc6_addr **pref;
|
|
|
|
const char *val;
|
|
|
|
int token, no_semi;
|
|
|
|
|
|
|
|
ia = dmalloc(sizeof(*ia), MDL);
|
|
|
|
if (ia == NULL) {
|
|
|
|
parse_warn(cfile, "Out of memory allocating IA_PD state.");
|
|
|
|
skip_to_semi(cfile);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
ia->ia_type = D6O_IA_PD;
|
|
|
|
|
|
|
|
/* Get IAID. */
|
|
|
|
memset(&id, 0, sizeof(id));
|
|
|
|
if (parse_cshl(&id, cfile)) {
|
|
|
|
if (id.len == 4)
|
|
|
|
memcpy(ia->iaid, id.data, 4);
|
|
|
|
else {
|
|
|
|
parse_warn(cfile, "Expecting IAID of length 4, got %d.",
|
|
|
|
id.len);
|
|
|
|
skip_to_semi(cfile);
|
|
|
|
dfree(ia, MDL);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
data_string_forget(&id, MDL);
|
|
|
|
} else {
|
|
|
|
parse_warn(cfile, "Expecting IAID.");
|
|
|
|
skip_to_semi(cfile);
|
|
|
|
dfree(ia, MDL);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
token = next_token(NULL, NULL, cfile);
|
|
|
|
if (token != LBRACE) {
|
|
|
|
parse_warn(cfile, "Expecting open curly brace.");
|
|
|
|
skip_to_semi(cfile);
|
|
|
|
dfree(ia, MDL);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
option_state_allocate(&ia->options, MDL);
|
|
|
|
if (ia->options == NULL) {
|
|
|
|
parse_warn(cfile, "Unable to allocate option state.");
|
|
|
|
skip_to_rbrace(cfile, 1);
|
|
|
|
dfree(ia, MDL);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
pref = &ia->addrs;
|
|
|
|
token = next_token(&val, NULL, cfile);
|
|
|
|
while (token != RBRACE) {
|
|
|
|
no_semi = 0;
|
|
|
|
|
|
|
|
switch (token) {
|
|
|
|
case STARTS:
|
|
|
|
token = next_token(&val, NULL, cfile);
|
|
|
|
if (token == NUMBER) {
|
|
|
|
ia->starts = atoi(val);
|
|
|
|
} else {
|
|
|
|
parse_warn(cfile, "Expecting a number.");
|
|
|
|
skip_to_semi(cfile);
|
|
|
|
no_semi = 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RENEW:
|
|
|
|
token = next_token(&val, NULL, cfile);
|
|
|
|
if (token == NUMBER) {
|
|
|
|
ia->renew = atoi(val);
|
|
|
|
} else {
|
|
|
|
parse_warn(cfile, "Expecting a number.");
|
|
|
|
skip_to_semi(cfile);
|
|
|
|
no_semi = 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case REBIND:
|
|
|
|
token = next_token(&val, NULL, cfile);
|
|
|
|
if (token == NUMBER) {
|
|
|
|
ia->rebind = atoi(val);
|
|
|
|
} else {
|
|
|
|
parse_warn(cfile, "Expecting a number.");
|
|
|
|
skip_to_semi(cfile);
|
|
|
|
no_semi = 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IAPREFIX:
|
|
|
|
*pref = parse_client6_iaprefix_statement(cfile);
|
|
|
|
|
|
|
|
if (*pref != NULL)
|
|
|
|
pref = &(*pref)->next;
|
|
|
|
|
|
|
|
no_semi = 1;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OPTION:
|
|
|
|
if (parse_option_decl(&oc, cfile)) {
|
|
|
|
save_option(oc->option->universe,
|
|
|
|
ia->options, oc);
|
|
|
|
option_cache_dereference(&oc, MDL);
|
|
|
|
}
|
|
|
|
no_semi = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
parse_warn(cfile, "Unexpected token.");
|
|
|
|
no_semi = 1;
|
|
|
|
skip_to_semi(cfile);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!no_semi)
|
|
|
|
parse_semi(cfile);
|
|
|
|
|
|
|
|
token = next_token(&val, NULL, cfile);
|
|
|
|
|
|
|
|
if (token == END_OF_FILE) {
|
|
|
|
parse_warn(cfile, "Unexpected end of file.");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ia;
|
|
|
|
}
|
|
|
|
#endif /* DHCPv6 */
|
|
|
|
|
2007-05-08 23:05:22 +00:00
|
|
|
/* Parse an iaaddr {} structure. */
|
2007-07-13 06:43:43 +00:00
|
|
|
#ifdef DHCPv6
|
2007-05-08 23:05:22 +00:00
|
|
|
static struct dhc6_addr *
|
|
|
|
parse_client6_iaaddr_statement(struct parse *cfile)
|
|
|
|
{
|
|
|
|
struct option_cache *oc = NULL;
|
|
|
|
struct dhc6_addr *addr;
|
|
|
|
const char *val;
|
|
|
|
int token, no_semi;
|
|
|
|
|
|
|
|
addr = dmalloc(sizeof(*addr), MDL);
|
|
|
|
if (addr == NULL) {
|
|
|
|
parse_warn(cfile, "Unable to allocate IAADDR state.");
|
|
|
|
skip_to_semi(cfile);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get IP address. */
|
|
|
|
if (!parse_ip6_addr(cfile, &addr->address)) {
|
|
|
|
skip_to_semi(cfile);
|
|
|
|
dfree(addr, MDL);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
token = next_token(NULL, NULL, cfile);
|
|
|
|
if (token != LBRACE) {
|
|
|
|
parse_warn(cfile, "Expecting open curly bracket.");
|
|
|
|
skip_to_semi(cfile);
|
|
|
|
dfree(addr, MDL);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
option_state_allocate(&addr->options, MDL);
|
|
|
|
if (addr->options == NULL) {
|
|
|
|
parse_warn(cfile, "Unable to allocate option state.");
|
|
|
|
skip_to_semi(cfile);
|
|
|
|
dfree(addr, MDL);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
token = next_token(&val, NULL, cfile);
|
|
|
|
while (token != RBRACE) {
|
|
|
|
no_semi = 0;
|
|
|
|
|
|
|
|
switch (token) {
|
|
|
|
case STARTS:
|
|
|
|
token = next_token(&val, NULL, cfile);
|
|
|
|
if (token == NUMBER) {
|
|
|
|
addr->starts = atoi(val);
|
|
|
|
} else {
|
|
|
|
parse_warn(cfile, "Expecting a number.");
|
|
|
|
skip_to_semi(cfile);
|
|
|
|
no_semi = 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PREFERRED_LIFE:
|
|
|
|
token = next_token(&val, NULL, cfile);
|
|
|
|
if (token == NUMBER) {
|
|
|
|
addr->preferred_life = atoi(val);
|
|
|
|
} else {
|
|
|
|
parse_warn(cfile, "Expecting a number.");
|
|
|
|
skip_to_semi(cfile);
|
|
|
|
no_semi = 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MAX_LIFE:
|
|
|
|
token = next_token(&val, NULL, cfile);
|
|
|
|
if (token == NUMBER) {
|
|
|
|
addr->max_life = atoi(val);
|
|
|
|
} else {
|
|
|
|
parse_warn(cfile, "Expecting a number.");
|
|
|
|
skip_to_semi(cfile);
|
|
|
|
no_semi = 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OPTION:
|
|
|
|
if (parse_option_decl(&oc, cfile)) {
|
|
|
|
save_option(oc->option->universe,
|
|
|
|
addr->options, oc);
|
|
|
|
option_cache_dereference(&oc, MDL);
|
|
|
|
}
|
|
|
|
no_semi = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
parse_warn(cfile, "Unexpected token.");
|
|
|
|
skip_to_rbrace(cfile, 1);
|
|
|
|
no_semi = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!no_semi)
|
|
|
|
parse_semi(cfile);
|
|
|
|
|
|
|
|
token = next_token(&val, NULL, cfile);
|
|
|
|
if (token == END_OF_FILE) {
|
|
|
|
parse_warn(cfile, "Unexpected end of file.");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return addr;
|
|
|
|
}
|
2007-07-13 06:43:43 +00:00
|
|
|
#endif /* DHCPv6 */
|
2007-05-08 23:05:22 +00:00
|
|
|
|
2008-01-02 23:47:22 +00:00
|
|
|
/* Parse an iaprefix {} structure. */
|
|
|
|
#ifdef DHCPv6
|
|
|
|
static struct dhc6_addr *
|
|
|
|
parse_client6_iaprefix_statement(struct parse *cfile)
|
|
|
|
{
|
|
|
|
struct option_cache *oc = NULL;
|
|
|
|
struct dhc6_addr *pref;
|
|
|
|
const char *val;
|
|
|
|
int token, no_semi;
|
|
|
|
|
|
|
|
pref = dmalloc(sizeof(*pref), MDL);
|
|
|
|
if (pref == NULL) {
|
|
|
|
parse_warn(cfile, "Unable to allocate IAPREFIX state.");
|
|
|
|
skip_to_semi(cfile);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get IP prefix. */
|
|
|
|
if (!parse_ip6_prefix(cfile, &pref->address, &pref->plen)) {
|
|
|
|
skip_to_semi(cfile);
|
|
|
|
dfree(pref, MDL);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
token = next_token(NULL, NULL, cfile);
|
|
|
|
if (token != LBRACE) {
|
|
|
|
parse_warn(cfile, "Expecting open curly bracket.");
|
|
|
|
skip_to_semi(cfile);
|
|
|
|
dfree(pref, MDL);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
option_state_allocate(&pref->options, MDL);
|
|
|
|
if (pref->options == NULL) {
|
|
|
|
parse_warn(cfile, "Unable to allocate option state.");
|
|
|
|
skip_to_semi(cfile);
|
|
|
|
dfree(pref, MDL);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
token = next_token(&val, NULL, cfile);
|
|
|
|
while (token != RBRACE) {
|
|
|
|
no_semi = 0;
|
|
|
|
|
|
|
|
switch (token) {
|
|
|
|
case STARTS:
|
|
|
|
token = next_token(&val, NULL, cfile);
|
|
|
|
if (token == NUMBER) {
|
|
|
|
pref->starts = atoi(val);
|
|
|
|
} else {
|
|
|
|
parse_warn(cfile, "Expecting a number.");
|
|
|
|
skip_to_semi(cfile);
|
|
|
|
no_semi = 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PREFERRED_LIFE:
|
|
|
|
token = next_token(&val, NULL, cfile);
|
|
|
|
if (token == NUMBER) {
|
|
|
|
pref->preferred_life = atoi(val);
|
|
|
|
} else {
|
|
|
|
parse_warn(cfile, "Expecting a number.");
|
|
|
|
skip_to_semi(cfile);
|
|
|
|
no_semi = 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MAX_LIFE:
|
|
|
|
token = next_token(&val, NULL, cfile);
|
|
|
|
if (token == NUMBER) {
|
|
|
|
pref->max_life = atoi(val);
|
|
|
|
} else {
|
|
|
|
parse_warn(cfile, "Expecting a number.");
|
|
|
|
skip_to_semi(cfile);
|
|
|
|
no_semi = 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OPTION:
|
|
|
|
if (parse_option_decl(&oc, cfile)) {
|
|
|
|
save_option(oc->option->universe,
|
|
|
|
pref->options, oc);
|
|
|
|
option_cache_dereference(&oc, MDL);
|
|
|
|
}
|
|
|
|
no_semi = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
parse_warn(cfile, "Unexpected token.");
|
|
|
|
skip_to_rbrace(cfile, 1);
|
|
|
|
no_semi = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!no_semi)
|
|
|
|
parse_semi(cfile);
|
|
|
|
|
|
|
|
token = next_token(&val, NULL, cfile);
|
|
|
|
if (token == END_OF_FILE) {
|
|
|
|
parse_warn(cfile, "Unexpected end of file.");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return pref;
|
|
|
|
}
|
|
|
|
#endif /* DHCPv6 */
|
|
|
|
|
1997-02-22 08:38:32 +00:00
|
|
|
void parse_string_list (cfile, lp, multiple)
|
1999-10-01 03:11:20 +00:00
|
|
|
struct parse *cfile;
|
1997-02-22 08:38:32 +00:00
|
|
|
struct string_list **lp;
|
|
|
|
int multiple;
|
|
|
|
{
|
|
|
|
int token;
|
1999-10-07 06:36:35 +00:00
|
|
|
const char *val;
|
1997-02-22 08:38:32 +00:00
|
|
|
struct string_list *cur, *tmp;
|
|
|
|
|
|
|
|
/* Find the last medium in the media list. */
|
|
|
|
if (*lp) {
|
|
|
|
for (cur = *lp; cur -> next; cur = cur -> next)
|
|
|
|
;
|
|
|
|
} else {
|
|
|
|
cur = (struct string_list *)0;
|
|
|
|
}
|
|
|
|
|
|
|
|
do {
|
2001-03-17 00:47:39 +00:00
|
|
|
token = next_token (&val, (unsigned *)0, cfile);
|
1997-02-22 08:38:32 +00:00
|
|
|
if (token != STRING) {
|
1999-10-01 03:11:20 +00:00
|
|
|
parse_warn (cfile, "Expecting media options.");
|
1997-02-22 08:38:32 +00:00
|
|
|
skip_to_semi (cfile);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2000-01-25 00:58:02 +00:00
|
|
|
tmp = ((struct string_list *)
|
2001-02-12 19:37:03 +00:00
|
|
|
dmalloc (strlen (val) + sizeof (struct string_list),
|
|
|
|
MDL));
|
1997-02-22 08:38:32 +00:00
|
|
|
if (!tmp)
|
1999-02-24 17:56:53 +00:00
|
|
|
log_fatal ("no memory for string list entry.");
|
1997-02-22 08:38:32 +00:00
|
|
|
|
|
|
|
strcpy (tmp -> string, val);
|
|
|
|
tmp -> next = (struct string_list *)0;
|
|
|
|
|
|
|
|
/* Store this medium at the end of the media list. */
|
|
|
|
if (cur)
|
|
|
|
cur -> next = tmp;
|
|
|
|
else
|
|
|
|
*lp = tmp;
|
|
|
|
cur = tmp;
|
|
|
|
|
2001-03-17 00:47:39 +00:00
|
|
|
token = next_token (&val, (unsigned *)0, cfile);
|
1997-02-22 08:38:32 +00:00
|
|
|
} while (multiple && token == COMMA);
|
|
|
|
|
|
|
|
if (token != SEMI) {
|
1999-10-01 03:11:20 +00:00
|
|
|
parse_warn (cfile, "expecting semicolon.");
|
1997-02-22 08:38:32 +00:00
|
|
|
skip_to_semi (cfile);
|
|
|
|
}
|
|
|
|
}
|
1997-06-02 22:34:19 +00:00
|
|
|
|
|
|
|
void parse_reject_statement (cfile, config)
|
1999-10-01 03:11:20 +00:00
|
|
|
struct parse *cfile;
|
1997-06-02 22:34:19 +00:00
|
|
|
struct client_config *config;
|
|
|
|
{
|
|
|
|
int token;
|
1999-10-07 06:36:35 +00:00
|
|
|
const char *val;
|
2006-05-15 15:07:50 +00:00
|
|
|
struct iaddrmatch match;
|
|
|
|
struct iaddrmatchlist *list;
|
|
|
|
int i;
|
1997-06-02 22:34:19 +00:00
|
|
|
|
|
|
|
do {
|
2006-05-15 15:07:50 +00:00
|
|
|
if (!parse_ip_addr_with_subnet (cfile, &match)) {
|
|
|
|
/* no warn: parser will have reported what's wrong */
|
1997-06-02 22:34:19 +00:00
|
|
|
skip_to_semi (cfile);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-05-15 15:07:50 +00:00
|
|
|
/* check mask is not all zeros (because that would
|
|
|
|
* reject EVERY address). This check could be
|
|
|
|
* simplified if we assume that the mask *always*
|
|
|
|
* represents a prefix .. but perhaps it might be
|
|
|
|
* useful to have a mask which is not a proper prefix
|
|
|
|
* (perhaps for ipv6?). The following is almost as
|
|
|
|
* efficient as inspection of match.mask.iabuf[0] when
|
|
|
|
* it IS a true prefix, and is more general when it is
|
|
|
|
* not.
|
|
|
|
*/
|
|
|
|
|
|
|
|
for (i=0 ; i < match.mask.len ; i++) {
|
|
|
|
if (match.mask.iabuf[i]) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i == match.mask.len) {
|
|
|
|
/* oops we found all zeros */
|
|
|
|
parse_warn(cfile, "zero-length prefix is not permitted "
|
|
|
|
"for reject statement");
|
|
|
|
skip_to_semi(cfile);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
list = dmalloc(sizeof(struct iaddrmatchlist), MDL);
|
1997-06-02 22:34:19 +00:00
|
|
|
if (!list)
|
1999-02-24 17:56:53 +00:00
|
|
|
log_fatal ("no memory for reject list!");
|
1997-06-02 22:34:19 +00:00
|
|
|
|
2006-05-15 15:07:50 +00:00
|
|
|
list->match = match;
|
|
|
|
list->next = config->reject_list;
|
|
|
|
config->reject_list = list;
|
1997-06-02 22:34:19 +00:00
|
|
|
|
2001-03-17 00:47:39 +00:00
|
|
|
token = next_token (&val, (unsigned *)0, cfile);
|
1997-06-02 22:34:19 +00:00
|
|
|
} while (token == COMMA);
|
|
|
|
|
|
|
|
if (token != SEMI) {
|
1999-10-01 03:11:20 +00:00
|
|
|
parse_warn (cfile, "expecting semicolon.");
|
1997-06-02 22:34:19 +00:00
|
|
|
skip_to_semi (cfile);
|
|
|
|
}
|
|
|
|
}
|
1999-11-13 23:46:46 +00:00
|
|
|
|
|
|
|
/* allow-deny-keyword :== BOOTP
|
|
|
|
| BOOTING
|
|
|
|
| DYNAMIC_BOOTP
|
|
|
|
| UNKNOWN_CLIENTS */
|
|
|
|
|
|
|
|
int parse_allow_deny (oc, cfile, flag)
|
|
|
|
struct option_cache **oc;
|
|
|
|
struct parse *cfile;
|
|
|
|
int flag;
|
|
|
|
{
|
|
|
|
parse_warn (cfile, "allow/deny/ignore not permitted here.");
|
|
|
|
skip_to_semi (cfile);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|