diff options
Diffstat (limited to 'sbin/dhclient')
-rw-r--r-- | sbin/dhclient/clparse.c | 122 | ||||
-rw-r--r-- | sbin/dhclient/conflex.c | 271 | ||||
-rw-r--r-- | sbin/dhclient/dhctoken.h | 135 | ||||
-rw-r--r-- | sbin/dhclient/parse.c | 74 |
4 files changed, 196 insertions, 406 deletions
diff --git a/sbin/dhclient/clparse.c b/sbin/dhclient/clparse.c index 78ae2f16457..a6a926ca934 100644 --- a/sbin/dhclient/clparse.c +++ b/sbin/dhclient/clparse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: clparse.c,v 1.26 2005/08/02 02:34:03 krw Exp $ */ +/* $OpenBSD: clparse.c,v 1.27 2006/04/18 19:17:54 deraadt Exp $ */ /* Parser for dhclient config and lease files... */ @@ -123,7 +123,7 @@ read_client_leases(void) token = next_token(&val, cfile); if (token == EOF) break; - if (token != LEASE) { + if (token != TOK_LEASE) { warning("Corrupt lease file - possible data loss!"); skip_to_semi(cfile); break; @@ -161,75 +161,75 @@ parse_client_statement(FILE *cfile) int token, code; switch (next_token(&val, cfile)) { - case SEND: + case TOK_SEND: parse_option_decl(cfile, &config->send_options[0]); return; - case DEFAULT: + case TOK_DEFAULT: code = parse_option_decl(cfile, &config->defaults[0]); if (code != -1) config->default_actions[code] = ACTION_DEFAULT; return; - case SUPERSEDE: + case TOK_SUPERSEDE: code = parse_option_decl(cfile, &config->defaults[0]); if (code != -1) config->default_actions[code] = ACTION_SUPERSEDE; return; - case APPEND: + case TOK_APPEND: code = parse_option_decl(cfile, &config->defaults[0]); if (code != -1) config->default_actions[code] = ACTION_APPEND; return; - case PREPEND: + case TOK_PREPEND: code = parse_option_decl(cfile, &config->defaults[0]); if (code != -1) config->default_actions[code] = ACTION_PREPEND; return; - case MEDIA: + case TOK_MEDIA: parse_string_list(cfile, &config->media, 1); return; - case HARDWARE: + case TOK_HARDWARE: parse_hardware_param(cfile, &ifi->hw_address); return; - case REQUEST: + case TOK_REQUEST: config->requested_option_count = parse_option_list(cfile, config->requested_options); return; - case REQUIRE: + case TOK_REQUIRE: memset(config->required_options, 0, sizeof(config->required_options)); parse_option_list(cfile, config->required_options); return; - case TIMEOUT: + case TOK_TIMEOUT: parse_lease_time(cfile, &config->timeout); return; - case RETRY: + case TOK_RETRY: parse_lease_time(cfile, &config->retry_interval); return; - case SELECT_TIMEOUT: + case TOK_SELECT_TIMEOUT: parse_lease_time(cfile, &config->select_interval); return; - case REBOOT: + case TOK_REBOOT: parse_lease_time(cfile, &config->reboot_timeout); return; - case BACKOFF_CUTOFF: + case TOK_BACKOFF_CUTOFF: parse_lease_time(cfile, &config->backoff_cutoff); return; - case INITIAL_INTERVAL: + case TOK_INITIAL_INTERVAL: parse_lease_time(cfile, &config->initial_interval); return; - case SCRIPT: + case TOK_SCRIPT: config->script_name = parse_string(cfile); return; - case INTERFACE: + case TOK_INTERFACE: parse_interface_declaration(cfile); return; - case LEASE: + case TOK_LEASE: parse_client_lease_statement(cfile, 1); return; - case ALIAS: + case TOK_ALIAS: parse_client_lease_statement(cfile, 2); return; - case REJECT: + case TOK_REJECT: parse_reject_statement(cfile); return; default: @@ -238,7 +238,7 @@ parse_client_statement(FILE *cfile) break; } token = next_token(&val, cfile); - if (token != SEMI) { + if (token != ';') { parse_warn("semicolon expected."); skip_to_semi(cfile); } @@ -252,11 +252,11 @@ parse_X(FILE *cfile, u_int8_t *buf, int max) int len; token = peek_token(&val, cfile); - if (token == NUMBER_OR_NAME || token == NUMBER) { + if (token == TOK_NUMBER_OR_NAME || token == TOK_NUMBER) { len = 0; do { token = next_token(&val, cfile); - if (token != NUMBER && token != NUMBER_OR_NAME) { + if (token != TOK_NUMBER && token != TOK_NUMBER_OR_NAME) { parse_warn("expecting hexadecimal constant."); skip_to_semi(cfile); return (0); @@ -268,11 +268,11 @@ parse_X(FILE *cfile, u_int8_t *buf, int max) return (0); } token = peek_token(&val, cfile); - if (token == COLON) + if (token == ':') token = next_token(&val, cfile); - } while (token == COLON); + } while (token == ':'); val = (char *)buf; - } else if (token == STRING) { + } else if (token == TOK_STRING) { token = next_token(&val, cfile); len = strlen(val); if (len + 1 > max) { @@ -324,8 +324,8 @@ parse_option_list(FILE *cfile, u_int8_t *list) return (0); } token = next_token(&val, cfile); - } while (token == COMMA); - if (token != SEMI) { + } while (token == ','); + if (token != ';') { parse_warn("expecting semicolon."); skip_to_semi(cfile); return (0); @@ -344,7 +344,7 @@ parse_interface_declaration(FILE *cfile) int token; token = next_token(&val, cfile); - if (token != STRING) { + if (token != TOK_STRING) { parse_warn("expecting interface name (in quotes)."); skip_to_semi(cfile); return; @@ -356,7 +356,7 @@ parse_interface_declaration(FILE *cfile) } token = next_token(&val, cfile); - if (token != LBRACE) { + if (token != '{') { parse_warn("expecting left brace."); skip_to_semi(cfile); return; @@ -368,7 +368,7 @@ parse_interface_declaration(FILE *cfile) parse_warn("unterminated interface declaration."); return; } - if (token == RBRACE) + if (token == '}') break; parse_client_statement(cfile); } while (1); @@ -393,7 +393,7 @@ parse_client_lease_statement(FILE *cfile, int is_static) char *val; token = next_token(&val, cfile); - if (token != LBRACE) { + if (token != '{') { parse_warn("expecting left brace."); skip_to_semi(cfile); return; @@ -411,7 +411,7 @@ parse_client_lease_statement(FILE *cfile, int is_static) parse_warn("unterminated lease declaration."); return; } - if (token == RBRACE) + if (token == '}') break; parse_client_lease_declaration(cfile, lease, &ip); } while (1); @@ -513,12 +513,12 @@ parse_client_lease_declaration(FILE *cfile, struct client_lease *lease, int token; switch (next_token(&val, cfile)) { - case BOOTP: + case TOK_BOOTP: lease->is_bootp = 1; break; - case INTERFACE: + case TOK_INTERFACE: token = next_token(&val, cfile); - if (token != STRING) { + if (token != TOK_STRING) { parse_warn("expecting interface name (in quotes)."); skip_to_semi(cfile); break; @@ -531,29 +531,29 @@ parse_client_lease_declaration(FILE *cfile, struct client_lease *lease, } *ipp = ifi; break; - case FIXED_ADDR: + case TOK_FIXED_ADDR: if (!parse_ip_addr(cfile, &lease->address)) return; break; - case MEDIUM: + case TOK_MEDIUM: parse_string_list(cfile, &lease->medium, 0); return; - case FILENAME: + case TOK_FILENAME: lease->filename = parse_string(cfile); return; - case SERVER_NAME: + case TOK_SERVER_NAME: lease->server_name = parse_string(cfile); return; - case RENEW: + case TOK_RENEW: lease->renewal = parse_date(cfile); return; - case REBIND: + case TOK_REBIND: lease->rebind = parse_date(cfile); return; - case EXPIRE: + case TOK_EXPIRE: lease->expiry = parse_date(cfile); return; - case OPTION: + case TOK_OPTION: parse_option_decl(cfile, lease->options); return; default: @@ -562,7 +562,7 @@ parse_client_lease_declaration(FILE *cfile, struct client_lease *lease, break; } token = next_token(&val, cfile); - if (token != SEMI) { + if (token != ';') { parse_warn("expecting semicolon."); skip_to_semi(cfile); } @@ -585,7 +585,7 @@ parse_option_decl(FILE *cfile, struct option_data *options) token = next_token(&val, cfile); if (!is_identifier(token)) { parse_warn("expecting identifier after option keyword."); - if (token != SEMI) + if (token != ';') skip_to_semi(cfile); return (-1); } @@ -615,7 +615,7 @@ parse_option_decl(FILE *cfile, struct option_data *options) break; case 't': /* Text string... */ token = next_token(&val, cfile); - if (token != STRING) { + if (token != TOK_STRING) { parse_warn("expecting string."); skip_to_semi(cfile); return (-1); @@ -649,10 +649,10 @@ alloc: case 'L': /* Unsigned 32-bit integer... */ case 'l': /* Signed 32-bit integer... */ token = next_token(&val, cfile); - if (token != NUMBER) { + if (token != TOK_NUMBER) { need_number: parse_warn("expecting number."); - if (token != SEMI) + if (token != ';') skip_to_semi(cfile); return (-1); } @@ -663,7 +663,7 @@ need_number: case 's': /* Signed 16-bit integer. */ case 'S': /* Unsigned 16-bit integer. */ token = next_token(&val, cfile); - if (token != NUMBER) + if (token != TOK_NUMBER) goto need_number; convert_num(buf, val, 0, 16); len = 2; @@ -672,7 +672,7 @@ need_number: case 'b': /* Signed 8-bit integer. */ case 'B': /* Unsigned 8-bit integer. */ token = next_token(&val, cfile); - if (token != NUMBER) + if (token != TOK_NUMBER) goto need_number; convert_num(buf, val, 0, 8); len = 1; @@ -683,7 +683,7 @@ need_number: if (!is_identifier(token)) { parse_warn("expecting identifier."); bad_flag: - if (token != SEMI) + if (token != ';') skip_to_semi(cfile); return (-1); } @@ -708,9 +708,9 @@ bad_flag: } } token = next_token(&val, cfile); - } while (*fmt == 'A' && token == COMMA); + } while (*fmt == 'A' && token == ','); - if (token != SEMI) { + if (token != ';') { parse_warn("semicolon expected."); skip_to_semi(cfile); return (-1); @@ -740,7 +740,7 @@ parse_string_list(FILE *cfile, struct string_list **lp, int multiple) do { token = next_token(&val, cfile); - if (token != STRING) { + if (token != TOK_STRING) { parse_warn("Expecting media options."); skip_to_semi(cfile); return; @@ -760,9 +760,9 @@ parse_string_list(FILE *cfile, struct string_list **lp, int multiple) cur = tmp; token = next_token(&val, cfile); - } while (multiple && token == COMMA); + } while (multiple && token == ','); - if (token != SEMI) { + if (token != ';') { parse_warn("expecting semicolon."); skip_to_semi(cfile); } @@ -793,9 +793,9 @@ parse_reject_statement(FILE *cfile) config->reject_list = list; token = next_token(&val, cfile); - } while (token == COMMA); + } while (token == ','); - if (token != SEMI) { + if (token != ';') { parse_warn("expecting semicolon."); skip_to_semi(cfile); } diff --git a/sbin/dhclient/conflex.c b/sbin/dhclient/conflex.c index 5e601cc8490..72a091a2112 100644 --- a/sbin/dhclient/conflex.c +++ b/sbin/dhclient/conflex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conflex.c,v 1.10 2005/08/02 18:26:49 moritz Exp $ */ +/* $OpenBSD: conflex.c,v 1.11 2006/04/18 19:17:54 deraadt Exp $ */ /* Lexical scanner for dhcpd config file... */ @@ -250,13 +250,13 @@ read_string(FILE *cfile) } tokbuf[i] = 0; tval = tokbuf; - return (STRING); + return (TOK_STRING); } static int read_number(int c, FILE *cfile) { - int seenx = 0, i = 0, token = NUMBER; + int seenx = 0, i = 0, token = TOK_NUMBER; tokbuf[i++] = c; for (; i < sizeof(tokbuf); i++) { @@ -284,7 +284,7 @@ static int read_num_or_name(int c, FILE *cfile) { int i = 0; - int rv = NUMBER_OR_NAME; + int rv = TOK_NUMBER_OR_NAME; tokbuf[i++] = c; for (; i < sizeof(tokbuf); i++) { @@ -295,7 +295,7 @@ read_num_or_name(int c, FILE *cfile) break; } if (!isxdigit(c)) - rv = NAME; + rv = TOK_NAME; tokbuf[i] = c; } if (i == sizeof(tokbuf)) { @@ -308,218 +308,59 @@ read_num_or_name(int c, FILE *cfile) return (intern(tval, rv)); } +static const struct keywords { + const char *k_name; + int k_val; +} keywords[] = { + { "alias", TOK_ALIAS }, + { "append", TOK_APPEND }, + { "backoff-cutoff", TOK_BACKOFF_CUTOFF }, + { "bootp", TOK_BOOTP }, + { "default", TOK_DEFAULT }, + { "deny", TOK_DENY }, + { "ethernet", TOK_ETHERNET }, + { "expire", TOK_EXPIRE }, + { "fddi", TOK_FDDI }, + { "filename", TOK_FILENAME }, + { "fixed-address", TOK_FIXED_ADDR }, + { "hardware", TOK_HARDWARE }, + { "initial-interval", TOK_INITIAL_INTERVAL }, + { "interface", TOK_INTERFACE }, + { "lease", TOK_LEASE }, + { "media", TOK_MEDIA }, + { "medium", TOK_MEDIUM }, + { "option", TOK_OPTION }, + { "prepend", TOK_PREPEND }, + { "rebind", TOK_REBIND }, + { "reboot", TOK_REBOOT }, + { "reject", TOK_REJECT }, + { "renew", TOK_RENEW }, + { "request", TOK_REQUEST }, + { "require", TOK_REQUIRE }, + { "retry", TOK_RETRY }, + { "script", TOK_SCRIPT }, + { "select-timeout", TOK_SELECT_TIMEOUT }, + { "send", TOK_SEND }, + { "server-name", TOK_SERVER_NAME }, + { "supersede", TOK_SUPERSEDE }, + { "timeout", TOK_TIMEOUT }, + { "token-ring", TOK_TOKEN_RING } +}; + +int +kw_cmp(const void *k, const void *e) +{ + return (strcasecmp(k, ((const struct keywords *)e)->k_name)); +} + static int intern(char *atom, int dfv) { - if (!isascii(atom[0])) - return (dfv); - - switch (tolower(atom[0])) { - case 'a': - if (!strcasecmp(atom + 1, "lways-reply-rfc1048")) - return (ALWAYS_REPLY_RFC1048); - if (!strcasecmp(atom + 1, "ppend")) - return (APPEND); - if (!strcasecmp(atom + 1, "llow")) - return (ALLOW); - if (!strcasecmp(atom + 1, "lias")) - return (ALIAS); - if (!strcasecmp(atom + 1, "bandoned")) - return (ABANDONED); - if (!strcasecmp(atom + 1, "uthoritative")) - return (AUTHORITATIVE); - break; - case 'b': - if (!strcasecmp(atom + 1, "ackoff-cutoff")) - return (BACKOFF_CUTOFF); - if (!strcasecmp(atom + 1, "ootp")) - return (BOOTP); - if (!strcasecmp(atom + 1, "ooting")) - return (BOOTING); - if (!strcasecmp(atom + 1, "oot-unknown-clients")) - return (BOOT_UNKNOWN_CLIENTS); - break; - case 'c': - if (!strcasecmp(atom + 1, "lass")) - return (CLASS); - if (!strcasecmp(atom + 1, "iaddr")) - return (CIADDR); - if (!strcasecmp(atom + 1, "lient-identifier")) - return (CLIENT_IDENTIFIER); - if (!strcasecmp(atom + 1, "lient-hostname")) - return (CLIENT_HOSTNAME); - break; - case 'd': - if (!strcasecmp(atom + 1, "omain")) - return (DOMAIN); - if (!strcasecmp(atom + 1, "eny")) - return (DENY); - if (!strncasecmp(atom + 1, "efault", 6)) { - if (!atom[7]) - return (DEFAULT); - if (!strcasecmp(atom + 7, "-lease-time")) - return (DEFAULT_LEASE_TIME); - break; - } - if (!strncasecmp(atom + 1, "ynamic-bootp", 12)) { - if (!atom[13]) - return (DYNAMIC_BOOTP); - if (!strcasecmp(atom + 13, "-lease-cutoff")) - return (DYNAMIC_BOOTP_LEASE_CUTOFF); - if (!strcasecmp(atom + 13, "-lease-length")) - return (DYNAMIC_BOOTP_LEASE_LENGTH); - break; - } - break; - case 'e': - if (!strcasecmp(atom + 1, "thernet")) - return (ETHERNET); - if (!strcasecmp(atom + 1, "nds")) - return (ENDS); - if (!strcasecmp(atom + 1, "xpire")) - return (EXPIRE); - break; - case 'f': - if (!strcasecmp(atom + 1, "ilename")) - return (FILENAME); - if (!strcasecmp(atom + 1, "ixed-address")) - return (FIXED_ADDR); - if (!strcasecmp(atom + 1, "ddi")) - return (FDDI); - break; - case 'g': - if (!strcasecmp(atom + 1, "iaddr")) - return (GIADDR); - if (!strcasecmp(atom + 1, "roup")) - return (GROUP); - if (!strcasecmp(atom + 1, "et-lease-hostnames")) - return (GET_LEASE_HOSTNAMES); - break; - case 'h': - if (!strcasecmp(atom + 1, "ost")) - return (HOST); - if (!strcasecmp(atom + 1, "ardware")) - return (HARDWARE); - if (!strcasecmp(atom + 1, "ostname")) - return (HOSTNAME); - break; - case 'i': - if (!strcasecmp(atom + 1, "nitial-interval")) - return (INITIAL_INTERVAL); - if (!strcasecmp(atom + 1, "nterface")) - return (INTERFACE); - break; - case 'l': - if (!strcasecmp(atom + 1, "ease")) - return (LEASE); - break; - case 'm': - if (!strcasecmp(atom + 1, "ax-lease-time")) - return (MAX_LEASE_TIME); - if (!strncasecmp(atom + 1, "edi", 3)) { - if (!strcasecmp(atom + 4, "a")) - return (MEDIA); - if (!strcasecmp(atom + 4, "um")) - return (MEDIUM); - break; - } - break; - case 'n': - if (!strcasecmp(atom + 1, "ameserver")) - return (NAMESERVER); - if (!strcasecmp(atom + 1, "etmask")) - return (NETMASK); - if (!strcasecmp(atom + 1, "ext-server")) - return (NEXT_SERVER); - if (!strcasecmp(atom + 1, "ot")) - return (TOKEN_NOT); - break; - case 'o': - if (!strcasecmp(atom + 1, "ption")) - return (OPTION); - if (!strcasecmp(atom + 1, "ne-lease-per-client")) - return (ONE_LEASE_PER_CLIENT); - break; - case 'p': - if (!strcasecmp(atom + 1, "repend")) - return (PREPEND); - if (!strcasecmp(atom + 1, "acket")) - return (PACKET); - break; - case 'r': - if (!strcasecmp(atom + 1, "ange")) - return (RANGE); - if (!strcasecmp(atom + 1, "equest")) - return (REQUEST); - if (!strcasecmp(atom + 1, "equire")) - return (REQUIRE); - if (!strcasecmp(atom + 1, "etry")) - return (RETRY); - if (!strcasecmp(atom + 1, "enew")) - return (RENEW); - if (!strcasecmp(atom + 1, "ebind")) - return (REBIND); - if (!strcasecmp(atom + 1, "eboot")) - return (REBOOT); - if (!strcasecmp(atom + 1, "eject")) - return (REJECT); - break; - case 's': - if (!strcasecmp(atom + 1, "earch")) - return (SEARCH); - if (!strcasecmp(atom + 1, "tarts")) - return (STARTS); - if (!strcasecmp(atom + 1, "iaddr")) - return (SIADDR); - if (!strcasecmp(atom + 1, "ubnet")) - return (SUBNET); - if (!strcasecmp(atom + 1, "hared-network")) - return (SHARED_NETWORK); - if (!strcasecmp(atom + 1, "erver-name")) - return (SERVER_NAME); - if (!strcasecmp(atom + 1, "erver-identifier")) - return (SERVER_IDENTIFIER); - if (!strcasecmp(atom + 1, "elect-timeout")) - return (SELECT_TIMEOUT); - if (!strcasecmp(atom + 1, "end")) - return (SEND); - if (!strcasecmp(atom + 1, "cript")) - return (SCRIPT); - if (!strcasecmp(atom + 1, "upersede")) - return (SUPERSEDE); - break; - case 't': - if (!strcasecmp(atom + 1, "imestamp")) - return (TIMESTAMP); - if (!strcasecmp(atom + 1, "imeout")) - return (TIMEOUT); - if (!strcasecmp(atom + 1, "oken-ring")) - return (TOKEN_RING); - break; - case 'u': - if (!strncasecmp(atom + 1, "se", 2)) { - if (!strcasecmp(atom + 3, "r-class")) - return (USER_CLASS); - if (!strcasecmp(atom + 3, "-host-decl-names")) - return (USE_HOST_DECL_NAMES); - if (!strcasecmp(atom + 3, - "-lease-addr-for-default-route")) - return (USE_LEASE_ADDR_FOR_DEFAULT_ROUTE); - break; - } - if (!strcasecmp(atom + 1, "id")) - return (UID); - if (!strcasecmp(atom + 1, "nknown-clients")) - return (UNKNOWN_CLIENTS); - break; - case 'v': - if (!strcasecmp(atom + 1, "endor-class")) - return (VENDOR_CLASS); - break; - case 'y': - if (!strcasecmp(atom + 1, "iaddr")) - return (YIADDR); - break; - } + const struct keywords *p; + + p = bsearch(atom, keywords, sizeof(keywords)/sizeof(keywords[0]), + sizeof(keywords[0]), kw_cmp); + if (p) + return (p->k_val); return (dfv); } diff --git a/sbin/dhclient/dhctoken.h b/sbin/dhclient/dhctoken.h index 7b23242fbac..8b62480e95d 100644 --- a/sbin/dhclient/dhctoken.h +++ b/sbin/dhclient/dhctoken.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dhctoken.h,v 1.2 2004/02/04 12:16:56 henning Exp $ */ +/* $OpenBSD: dhctoken.h,v 1.3 2006/04/18 19:17:54 deraadt Exp $ */ /* Tokens for config file lexer and parser. */ @@ -40,97 +40,46 @@ * Enterprises, see ``http://www.vix.com''. */ -#define SEMI ';' -#define DOT '.' -#define COLON ':' -#define COMMA ',' -#define SLASH '/' -#define LBRACE '{' -#define RBRACE '}' +#define TOK_FIRST_TOKEN TOK_HARDWARE +#define TOK_HARDWARE 257 +#define TOK_FILENAME 258 +#define TOK_FIXED_ADDR 259 +#define TOK_OPTION 260 +#define TOK_ETHERNET 261 +#define TOK_STRING 262 +#define TOK_NUMBER 263 +#define TOK_NUMBER_OR_NAME 264 +#define TOK_NAME 265 +#define TOK_LEASE 266 +#define TOK_SERVER_NAME 267 +#define TOK_TOKEN_RING 268 +#define TOK_SEND 269 +#define TOK_REQUEST 270 +#define TOK_REQUIRE 271 +#define TOK_TIMEOUT 272 +#define TOK_RETRY 273 +#define TOK_SELECT_TIMEOUT 274 +#define TOK_SCRIPT 275 +#define TOK_INTERFACE 276 +#define TOK_RENEW 277 +#define TOK_REBIND 278 +#define TOK_EXPIRE 279 +#define TOK_BOOTP 280 +#define TOK_DENY 281 +#define TOK_DEFAULT 282 +#define TOK_MEDIA 283 +#define TOK_MEDIUM 284 +#define TOK_ALIAS 285 +#define TOK_REBOOT 286 +#define TOK_BACKOFF_CUTOFF 287 +#define TOK_INITIAL_INTERVAL 288 +#define TOK_SUPERSEDE 289 +#define TOK_APPEND 290 +#define TOK_PREPEND 291 +#define TOK_REJECT 292 +#define TOK_FDDI 293 -#define FIRST_TOKEN HOST -#define HOST 256 -#define HARDWARE 257 -#define FILENAME 258 -#define FIXED_ADDR 259 -#define OPTION 260 -#define ETHERNET 261 -#define STRING 262 -#define NUMBER 263 -#define NUMBER_OR_NAME 264 -#define NAME 265 -#define TIMESTAMP 266 -#define STARTS 267 -#define ENDS 268 -#define UID 269 -#define CLASS 270 -#define LEASE 271 -#define RANGE 272 -#define PACKET 273 -#define CIADDR 274 -#define YIADDR 275 -#define SIADDR 276 -#define GIADDR 277 -#define SUBNET 278 -#define NETMASK 279 -#define DEFAULT_LEASE_TIME 280 -#define MAX_LEASE_TIME 281 -#define VENDOR_CLASS 282 -#define USER_CLASS 283 -#define SHARED_NETWORK 284 -#define SERVER_NAME 285 -#define DYNAMIC_BOOTP 286 -#define SERVER_IDENTIFIER 287 -#define DYNAMIC_BOOTP_LEASE_CUTOFF 288 -#define DYNAMIC_BOOTP_LEASE_LENGTH 289 -#define BOOT_UNKNOWN_CLIENTS 290 -#define NEXT_SERVER 291 -#define TOKEN_RING 292 -#define GROUP 293 -#define ONE_LEASE_PER_CLIENT 294 -#define GET_LEASE_HOSTNAMES 295 -#define USE_HOST_DECL_NAMES 296 -#define SEND 297 -#define CLIENT_IDENTIFIER 298 -#define REQUEST 299 -#define REQUIRE 300 -#define TIMEOUT 301 -#define RETRY 302 -#define SELECT_TIMEOUT 303 -#define SCRIPT 304 -#define INTERFACE 305 -#define RENEW 306 -#define REBIND 307 -#define EXPIRE 308 -#define UNKNOWN_CLIENTS 309 -#define ALLOW 310 -#define BOOTP 311 -#define DENY 312 -#define BOOTING 313 -#define DEFAULT 314 -#define MEDIA 315 -#define MEDIUM 316 -#define ALIAS 317 -#define REBOOT 318 -#define ABANDONED 319 -#define BACKOFF_CUTOFF 320 -#define INITIAL_INTERVAL 321 -#define NAMESERVER 322 -#define DOMAIN 323 -#define SEARCH 324 -#define SUPERSEDE 325 -#define APPEND 326 -#define PREPEND 327 -#define HOSTNAME 328 -#define CLIENT_HOSTNAME 329 -#define REJECT 330 -#define FDDI 331 -#define USE_LEASE_ADDR_FOR_DEFAULT_ROUTE 332 -#define AUTHORITATIVE 333 -#define TOKEN_NOT 334 -#define ALWAYS_REPLY_RFC1048 335 - -#define is_identifier(x) ((x) >= FIRST_TOKEN && \ - (x) != STRING && \ - (x) != NUMBER && \ +#define is_identifier(x) ((x) >= TOK_FIRST_TOKEN && \ + (x) != TOK_STRING && \ + (x) != TOK_NUMBER && \ (x) != EOF) diff --git a/sbin/dhclient/parse.c b/sbin/dhclient/parse.c index fb88f307fcc..c17c76da67f 100644 --- a/sbin/dhclient/parse.c +++ b/sbin/dhclient/parse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.c,v 1.13 2005/07/17 19:33:55 krw Exp $ */ +/* $OpenBSD: parse.c,v 1.14 2006/04/18 19:17:54 deraadt Exp $ */ /* Common parser code for dhcpd and dhclient. */ @@ -65,16 +65,16 @@ skip_to_semi(FILE *cfile) do { token = peek_token(&val, cfile); - if (token == RBRACE) { + if (token == '}') { if (brace_count) { token = next_token(&val, cfile); if (!--brace_count) return; } else return; - } else if (token == LBRACE) { + } else if (token == '{') { brace_count++; - } else if (token == SEMI && !brace_count) { + } else if (token == ';' && !brace_count) { token = next_token(&val, cfile); return; } else if (token == '\n') { @@ -98,7 +98,7 @@ parse_semi(FILE *cfile) char *val; token = next_token(&val, cfile); - if (token != SEMI) { + if (token != ';') { parse_warn("semicolon expected."); skip_to_semi(cfile); return (0); @@ -116,7 +116,7 @@ parse_string(FILE *cfile) int token; token = next_token(&val, cfile); - if (token != STRING) { + if (token != TOK_STRING) { parse_warn("filename must be a string"); skip_to_semi(cfile); return (NULL); @@ -135,7 +135,7 @@ int parse_ip_addr(FILE *cfile, struct iaddr *addr) { addr->len = 4; - return (parse_numeric_aggregate(cfile, addr->iabuf, addr->len, DOT, + return (parse_numeric_aggregate(cfile, addr->iabuf, addr->len, '.', 10)); } @@ -151,15 +151,15 @@ parse_hardware_param(FILE *cfile, struct hardware *hardware) token = next_token(&val, cfile); switch (token) { - case ETHERNET: + case TOK_ETHERNET: hardware->htype = HTYPE_ETHER; hardware->hlen = 6; break; - case TOKEN_RING: + case TOK_TOKEN_RING: hardware->htype = HTYPE_IEEE802; hardware->hlen = 6; break; - case FDDI: + case TOK_FDDI: hardware->htype = HTYPE_FDDI; hardware->hlen = 6; break; @@ -170,11 +170,11 @@ parse_hardware_param(FILE *cfile, struct hardware *hardware) } if (parse_numeric_aggregate(cfile, hardware->haddr, hardware->hlen, - COLON, 16) == 0) + ':', 16) == 0) return; token = next_token(&val, cfile); - if (token != SEMI) { + if (token != ';') { parse_warn("expecting semicolon."); skip_to_semi(cfile); } @@ -190,7 +190,7 @@ parse_lease_time(FILE *cfile, time_t *timep) int token; token = next_token(&val, cfile); - if (token != NUMBER) { + if (token != TOK_NUMBER) { parse_warn("Expecting numeric lease time"); skip_to_semi(cfile); return; @@ -222,7 +222,7 @@ parse_numeric_aggregate(FILE *cfile, unsigned char *buf, int max, int separator, token = next_token(&val, cfile); - if (token == NUMBER || (base == 16 && token == NUMBER_OR_NAME)) + if (token == TOK_NUMBER || (base == 16 && token == TOK_NUMBER_OR_NAME)) /* XXX Need to check if conversion was successful. */ convert_num(buf, val, base, 8); else @@ -357,9 +357,9 @@ parse_date(FILE *cfile) /* Day of week... */ token = next_token(&val, cfile); - if (token != NUMBER) { + if (token != TOK_NUMBER) { parse_warn("numeric day of week expected."); - if (token != SEMI) + if (token != ';') skip_to_semi(cfile); return (0); } @@ -367,9 +367,9 @@ parse_date(FILE *cfile) /* Year... */ token = next_token(&val, cfile); - if (token != NUMBER) { + if (token != TOK_NUMBER) { parse_warn("numeric year expected."); - if (token != SEMI) + if (token != ';') skip_to_semi(cfile); return (0); } @@ -379,18 +379,18 @@ parse_date(FILE *cfile) /* Slash separating year from month... */ token = next_token(&val, cfile); - if (token != SLASH) { + if (token != '/') { parse_warn("expected slash separating year from month."); - if (token != SEMI) + if (token != ';') skip_to_semi(cfile); return (0); } /* Month... */ token = next_token(&val, cfile); - if (token != NUMBER) { + if (token != TOK_NUMBER) { parse_warn("numeric month expected."); - if (token != SEMI) + if (token != ';') skip_to_semi(cfile); return (0); } @@ -398,18 +398,18 @@ parse_date(FILE *cfile) /* Slash separating month from day... */ token = next_token(&val, cfile); - if (token != SLASH) { + if (token != '/') { parse_warn("expected slash separating month from day."); - if (token != SEMI) + if (token != ';') skip_to_semi(cfile); return (0); } /* Month... */ token = next_token(&val, cfile); - if (token != NUMBER) { + if (token != TOK_NUMBER) { parse_warn("numeric day of month expected."); - if (token != SEMI) + if (token != ';') skip_to_semi(cfile); return (0); } @@ -417,9 +417,9 @@ parse_date(FILE *cfile) /* Hour... */ token = next_token(&val, cfile); - if (token != NUMBER) { + if (token != TOK_NUMBER) { parse_warn("numeric hour expected."); - if (token != SEMI) + if (token != ';') skip_to_semi(cfile); return (0); } @@ -427,18 +427,18 @@ parse_date(FILE *cfile) /* Colon separating hour from minute... */ token = next_token(&val, cfile); - if (token != COLON) { + if (token != ':') { parse_warn("expected colon separating hour from minute."); - if (token != SEMI) + if (token != ';') skip_to_semi(cfile); return (0); } /* Minute... */ token = next_token(&val, cfile); - if (token != NUMBER) { + if (token != TOK_NUMBER) { parse_warn("numeric minute expected."); - if (token != SEMI) + if (token != ';') skip_to_semi(cfile); return (0); } @@ -446,18 +446,18 @@ parse_date(FILE *cfile) /* Colon separating minute from second... */ token = next_token(&val, cfile); - if (token != COLON) { + if (token != ':') { parse_warn("expected colon separating hour from minute."); - if (token != SEMI) + if (token != ';') skip_to_semi(cfile); return (0); } /* Minute... */ token = next_token(&val, cfile); - if (token != NUMBER) { + if (token != TOK_NUMBER) { parse_warn("numeric minute expected."); - if (token != SEMI) + if (token != ';') skip_to_semi(cfile); return (0); } @@ -469,7 +469,7 @@ parse_date(FILE *cfile) /* Make sure the date ends in a semicolon... */ token = next_token(&val, cfile); - if (token != SEMI) { + if (token != ';') { parse_warn("semicolon expected."); skip_to_semi(cfile); return (0); |