#ifndef lint
static char copyright[] =
-"$Id: clparse.c,v 1.9 1997/03/29 10:36:24 mellon Exp $ Copyright (c) 1997 The Internet Software Consortium. All rights reserved.\n";
+"$Id: clparse.c,v 1.10 1997/05/09 07:48:34 mellon Exp $ Copyright (c) 1997 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
/* client-declaration :==
SEND option-decl |
DEFAULT option-decl |
+ SUPERCEDE option-decl |
+ PREPEND option-decl |
+ APPEND option-decl |
hardware-declaration |
REQUEST option-list |
REQUIRE option-list |
{
int token;
char *val;
+ struct option *option;
switch (next_token (&val, cfile)) {
case SEND:
return;
case DEFAULT:
- parse_option_decl (cfile, &config -> defaults [0]);
+ option = parse_option_decl (cfile, &config -> defaults [0]);
+ if (option)
+ config -> default_actions [option -> code] =
+ ACTION_DEFAULT;
+ return;
+
+ case SUPERSEDE:
+ option = parse_option_decl (cfile, &config -> defaults [0]);
+ if (option)
+ config -> default_actions [option -> code] =
+ ACTION_SUPERSEDE;
+ return;
+
+ case APPEND:
+ option = parse_option_decl (cfile, &config -> defaults [0]);
+ if (option)
+ config -> default_actions [option -> code] =
+ ACTION_APPEND;
+ return;
+
+ case PREPEND:
+ option = parse_option_decl (cfile, &config -> defaults [0]);
+ if (option)
+ config -> default_actions [option -> code] =
+ ACTION_PREPEND;
return;
case MEDIA:
}
/* client-lease-declaration :==
+ BOOTP |
INTERFACE string |
FIXED_ADDR ip_address |
FILENAME string |
struct interface_info *ip;
switch (next_token (&val, cfile)) {
+ case BOOTP:
+ lease -> is_bootp = 1;
+ break;
+
case INTERFACE:
token = next_token (&val, cfile);
if (token != STRING) {
break;
case FIXED_ADDR:
- parse_ip_addr (cfile, &lease -> address);
+ if (!parse_ip_addr (cfile, &lease -> address))
+ return;
break;
case MEDIUM:
}
}
-void parse_ip_addr (cfile, addr)
- FILE *cfile;
- struct iaddr *addr;
-{
- char *val;
- int token;
-
- addr -> len = 4;
- parse_numeric_aggregate (cfile, addr -> iabuf,
- &addr -> len, DOT, 10, 8);
-}
-
-void parse_option_decl (cfile, options)
+struct option *parse_option_decl (cfile, options)
FILE *cfile;
struct option_data *options;
{
parse_warn ("expecting identifier after option keyword.");
if (token != SEMI)
skip_to_semi (cfile);
- return;
+ return (struct option *)0;
}
vendor = malloc (strlen (val) + 1);
if (!vendor)
parse_warn ("expecting identifier after '.'");
if (token != SEMI)
skip_to_semi (cfile);
- return;
+ return (struct option *)0;
}
/* Look up the option name hash table for the specified
if (!universe) {
parse_warn ("no vendor named %s.", vendor);
skip_to_semi (cfile);
- return;
+ return (struct option *)0;
}
} else {
/* Use the default hash table, which contains all the
parse_warn ("no option named %s for vendor %s",
val, vendor);
skip_to_semi (cfile);
- return;
+ return (struct option *)0;
}
/* Free the initial identifier token. */
if (token != STRING) {
parse_warn ("expecting string.");
skip_to_semi (cfile);
- return;
+ return (struct option *)0;
}
len = strlen (val);
if (hunkix + len + 1 > sizeof hunkbuf) {
parse_warn ("option data buffer %s",
"overflow");
skip_to_semi (cfile);
- return;
+ return (struct option *)0;
}
memcpy (&hunkbuf [hunkix], val, len + 1);
nul_term = 1;
break;
case 'I': /* IP address. */
- parse_ip_addr (cfile, &ip_addr);
+ if (!parse_ip_addr (cfile, &ip_addr))
+ return (struct option *)0;
len = ip_addr.len;
dp = ip_addr.iabuf;
parse_warn ("option data buffer %s",
"overflow");
skip_to_semi (cfile);
- return;
+ return (struct option *)0;
}
memcpy (&hunkbuf [hunkix], dp, len);
hunkix += len;
parse_warn ("expecting number.");
if (token != SEMI)
skip_to_semi (cfile);
- return;
+ return (struct option *)0;
}
convert_num (buf, val, 0, 32);
len = 4;
bad_flag:
if (token != SEMI)
skip_to_semi (cfile);
- return;
+ return (struct option *)0;
}
if (!strcasecmp (val, "true")
|| !strcasecmp (val, "on"))
warn ("Bad format %c in parse_option_param.",
*fmt);
skip_to_semi (cfile);
- return;
+ return (struct option *)0;
}
}
token = next_token (&val, cfile);
if (token != SEMI) {
parse_warn ("semicolon expected.");
skip_to_semi (cfile);
- return;
+ return (struct option *)0;
}
options [option -> code].data =
error ("out of memory allocating option data.");
memcpy (options [option -> code].data, hunkbuf, hunkix + nul_term);
options [option -> code].len = hunkix;
+ return option;
}
void parse_string_list (cfile, lp, multiple)