version 1.1, 2012/02/21 22:30:18
|
version 1.1.1.1, 2012/10/09 09:06:54
|
Line 3
|
Line 3
|
Common parser code for dhcpd and dhclient. */ |
Common parser code for dhcpd and dhclient. */ |
|
|
/* |
/* |
* Copyright (c) 2004-2010 by Internet Systems Consortium, Inc. ("ISC") | * Copyright (c) 2004-2012 by Internet Systems Consortium, Inc. ("ISC") |
* Copyright (c) 1995-2003 by Internet Software Consortium |
* Copyright (c) 1995-2003 by Internet Software Consortium |
* |
* |
* Permission to use, copy, modify, and distribute this software for any |
* Permission to use, copy, modify, and distribute this software for any |
Line 569 parse_ip_addr_with_subnet(cfile, match)
|
Line 569 parse_ip_addr_with_subnet(cfile, match)
|
|
|
/* |
/* |
* hardware-parameter :== HARDWARE hardware-type colon-separated-hex-list SEMI |
* hardware-parameter :== HARDWARE hardware-type colon-separated-hex-list SEMI |
* hardware-type :== ETHERNET | TOKEN_RING | TOKEN_FDDI | * hardware-type :== ETHERNET | TOKEN_RING | TOKEN_FDDI | INFINIBAND |
| * Note that INFINIBAND may not be useful for some items, such as classification |
| * as the hardware address won't always be available. |
*/ |
*/ |
|
|
void parse_hardware_param (cfile, hardware) |
void parse_hardware_param (cfile, hardware) |
Line 581 void parse_hardware_param (cfile, hardware)
|
Line 583 void parse_hardware_param (cfile, hardware)
|
unsigned hlen; |
unsigned hlen; |
unsigned char *t; |
unsigned char *t; |
|
|
token = next_token (&val, (unsigned *)0, cfile); | token = next_token(&val, NULL, cfile); |
switch (token) { |
switch (token) { |
case ETHERNET: |
case ETHERNET: |
hardware -> hbuf [0] = HTYPE_ETHER; | hardware->hbuf[0] = HTYPE_ETHER; |
break; |
break; |
case TOKEN_RING: |
case TOKEN_RING: |
hardware -> hbuf [0] = HTYPE_IEEE802; | hardware->hbuf[0] = HTYPE_IEEE802; |
break; |
break; |
case TOKEN_FDDI: |
case TOKEN_FDDI: |
hardware -> hbuf [0] = HTYPE_FDDI; | hardware->hbuf[0] = HTYPE_FDDI; |
break; |
break; |
|
case TOKEN_INFINIBAND: |
|
hardware->hbuf[0] = HTYPE_INFINIBAND; |
|
break; |
default: |
default: |
if (!strncmp (val, "unknown-", 8)) { | if (!strncmp(val, "unknown-", 8)) { |
hardware -> hbuf [0] = atoi (&val [8]); | hardware->hbuf[0] = atoi(&val[8]); |
} else { |
} else { |
parse_warn (cfile, | parse_warn(cfile, |
"expecting a network hardware type"); | "expecting a network hardware type"); |
skip_to_semi (cfile); | skip_to_semi(cfile); |
|
|
return; |
return; |
} |
} |
Line 612 void parse_hardware_param (cfile, hardware)
|
Line 617 void parse_hardware_param (cfile, hardware)
|
that data in the lease file rather than simply failing on such |
that data in the lease file rather than simply failing on such |
clients. Yuck. */ |
clients. Yuck. */ |
hlen = 0; |
hlen = 0; |
token = peek_token (&val, (unsigned *)0, cfile); | token = peek_token(&val, NULL, cfile); |
if (token == SEMI) { |
if (token == SEMI) { |
hardware -> hlen = 1; | hardware->hlen = 1; |
goto out; |
goto out; |
} |
} |
t = parse_numeric_aggregate (cfile, (unsigned char *)0, &hlen, | t = parse_numeric_aggregate(cfile, NULL, &hlen, COLON, 16, 8); |
COLON, 16, 8); | if (t == NULL) { |
if (!t) { | hardware->hlen = 1; |
hardware -> hlen = 1; | |
return; |
return; |
} |
} |
if (hlen + 1 > sizeof hardware -> hbuf) { | if (hlen + 1 > sizeof(hardware->hbuf)) { |
dfree (t, MDL); | dfree(t, MDL); |
parse_warn (cfile, "hardware address too long"); | parse_warn(cfile, "hardware address too long"); |
} else { |
} else { |
hardware -> hlen = hlen + 1; | hardware->hlen = hlen + 1; |
memcpy ((unsigned char *)&hardware -> hbuf [1], t, hlen); | memcpy((unsigned char *)&hardware->hbuf[1], t, hlen); |
if (hlen + 1 < sizeof hardware -> hbuf) | if (hlen + 1 < sizeof(hardware->hbuf)) |
memset (&hardware -> hbuf [hlen + 1], 0, | memset(&hardware->hbuf[hlen + 1], 0, |
(sizeof hardware -> hbuf) - hlen - 1); | (sizeof(hardware->hbuf)) - hlen - 1); |
dfree (t, MDL); | dfree(t, MDL); |
} |
} |
|
|
out: |
out: |
token = next_token (&val, (unsigned *)0, cfile); | token = next_token(&val, NULL, cfile); |
if (token != SEMI) { |
if (token != SEMI) { |
parse_warn (cfile, "expecting semicolon."); | parse_warn(cfile, "expecting semicolon."); |
skip_to_semi (cfile); | skip_to_semi(cfile); |
} |
} |
} |
} |
|
|
Line 903 parse_date_core(cfile)
|
Line 907 parse_date_core(cfile)
|
struct parse *cfile; |
struct parse *cfile; |
{ |
{ |
int guess; |
int guess; |
int tzoff, wday, year, mon, mday, hour, min, sec; | int tzoff, year, mon, mday, hour, min, sec; |
const char *val; |
const char *val; |
enum dhcp_token token; |
enum dhcp_token token; |
static int months[11] = { 31, 59, 90, 120, 151, 181, |
static int months[11] = { 31, 59, 90, 120, 151, 181, |
Line 941 parse_date_core(cfile)
|
Line 945 parse_date_core(cfile)
|
return((TIME)0); |
return((TIME)0); |
} |
} |
token = next_token(&val, NULL, cfile); /* consume day of week */ |
token = next_token(&val, NULL, cfile); /* consume day of week */ |
wday = atoi(val); | /* we are not using this for anything */ |
|
|
/* Year... */ |
/* Year... */ |
token = peek_token(&val, NULL, cfile); |
token = peek_token(&val, NULL, cfile); |
Line 3329 int parse_boolean_expression (expr, cfile, lose)
|
Line 3333 int parse_boolean_expression (expr, cfile, lose)
|
int parse_boolean (cfile) |
int parse_boolean (cfile) |
struct parse *cfile; |
struct parse *cfile; |
{ |
{ |
enum dhcp_token token; |
|
const char *val; |
const char *val; |
int rv; |
int rv; |
|
|
token = next_token (&val, (unsigned *)0, cfile); | (void)next_token(&val, NULL, cfile); |
if (!strcasecmp (val, "true") |
if (!strcasecmp (val, "true") |
|| !strcasecmp (val, "on")) |
|| !strcasecmp (val, "on")) |
rv = 1; |
rv = 1; |
Line 5434 int parse_option_decl (oc, cfile)
|
Line 5437 int parse_option_decl (oc, cfile)
|
if (status != ISC_R_SUCCESS || option == NULL) |
if (status != ISC_R_SUCCESS || option == NULL) |
return 0; |
return 0; |
|
|
|
fmt = option->format; |
|
|
/* Parse the option data... */ |
/* Parse the option data... */ |
do { |
do { |
for (fmt = option -> format; *fmt; fmt++) { | for (; *fmt; fmt++) { |
if (*fmt == 'A') | if (*fmt == 'A') { |
| /* 'A' is an array of records, start at |
| * the beginning |
| */ |
| fmt = option->format; |
break; |
break; |
|
} |
|
|
|
if (*fmt == 'a') { |
|
/* 'a' is an array of the last field, |
|
* back up one format character |
|
*/ |
|
fmt--; |
|
break; |
|
} |
if (*fmt == 'o' && fmt != option -> format) |
if (*fmt == 'o' && fmt != option -> format) |
continue; |
continue; |
switch (*fmt) { |
switch (*fmt) { |
Line 5634 int parse_option_decl (oc, cfile)
|
Line 5652 int parse_option_decl (oc, cfile)
|
goto alloc; |
goto alloc; |
|
|
case 'Z': /* Zero-length option */ |
case 'Z': /* Zero-length option */ |
token = next_token(&val, (unsigned *)0, cfile); | token = peek_token(&val, (unsigned *)0, cfile); |
if (token != SEMI) { |
if (token != SEMI) { |
parse_warn(cfile, |
parse_warn(cfile, |
"semicolon expected."); |
"semicolon expected."); |
Line 5651 int parse_option_decl (oc, cfile)
|
Line 5669 int parse_option_decl (oc, cfile)
|
} |
} |
} |
} |
token = next_token (&val, (unsigned *)0, cfile); |
token = next_token (&val, (unsigned *)0, cfile); |
} while (*fmt == 'A' && token == COMMA); | } while (*fmt && token == COMMA); |
|
|
if (token != SEMI) { |
if (token != SEMI) { |
parse_warn (cfile, "semicolon expected."); |
parse_warn (cfile, "semicolon expected."); |