-/* $OpenBSD: clparse.c,v 1.162 2018/01/04 02:27:55 krw Exp $ */
+/* $OpenBSD: clparse.c,v 1.163 2018/01/04 03:02:05 krw Exp $ */
/* Parser for dhclient config and lease files. */
uint8_t list[DHO_COUNT];
char *val;
int i, count, token;
+ uint32_t t;
token = next_token(NULL, cfile);
}
break;
case TOK_BACKOFF_CUTOFF:
- if (parse_lease_time(cfile, &config->backoff_cutoff) == 1)
+ if (parse_number(cfile, (unsigned char *)&t, 'L') == 1) {
+ config->backoff_cutoff = ntohl(t);
parse_semi(cfile);
+ }
break;
case TOK_DEFAULT:
if (parse_option_decl(cfile, &i, config->defaults) == 1) {
}
break;
case TOK_INITIAL_INTERVAL:
- if (parse_lease_time(cfile, &config->initial_interval) == 1)
+ if (parse_number(cfile, (unsigned char *)&t, 'L') == 1) {
+ config->initial_interval = ntohl(t);
parse_semi(cfile);
+ }
break;
case TOK_INTERFACE:
if (parse_interface_declaration(cfile, name) == 1)
skip_to_semi(cfile);
break;
case TOK_LINK_TIMEOUT:
- if (parse_lease_time(cfile, &config->link_timeout) == 1)
+ if (parse_number(cfile, (unsigned char *)&t, 'L') == 1) {
+ config->link_timeout = ntohl(t);
parse_semi(cfile);
+ }
break;
case TOK_NEXT_SERVER:
if (parse_ip_addr(cfile, &config->next_server) == 1)
}
break;
case TOK_REBOOT:
- if (parse_lease_time(cfile, &config->reboot_timeout) == 1)
+ if (parse_number(cfile, (unsigned char *)&t, 'L') == 1) {
+ config->reboot_timeout = ntohl(t);
parse_semi(cfile);
+ }
break;
case TOK_REJECT:
if (parse_reject_statement(cfile) == 1)
parse_semi(cfile);
break;
case TOK_RETRY:
- if (parse_lease_time(cfile, &config->retry_interval) == 1)
+ if (parse_number(cfile, (unsigned char *)&t, 'L') == 1) {
+ config->retry_interval = ntohl(t);
parse_semi(cfile);
+ }
break;
case TOK_SELECT_TIMEOUT:
- if (parse_lease_time(cfile, &config->select_interval) == 1)
+ if (parse_number(cfile, (unsigned char *)&t, 'L') == 1) {
+ config->select_interval = ntohl(t);
parse_semi(cfile);
+ }
break;
case TOK_SEND:
if (parse_option_decl(cfile, &i, config->send_options) == 1)
}
break;
case TOK_TIMEOUT:
- if (parse_lease_time(cfile, &config->timeout) == 1)
+ if (parse_number(cfile, (unsigned char *)&t, 'L') == 1) {
+ config->timeout = ntohl(t);
parse_semi(cfile);
+ }
break;
default:
parse_warn("expecting statement.");
-/* $OpenBSD: dhcpd.h,v 1.244 2018/01/04 02:27:55 krw Exp $ */
+/* $OpenBSD: dhcpd.h,v 1.245 2018/01/04 03:02:05 krw Exp $ */
/*
* Copyright (c) 2004 Henning Brauer <henning@openbsd.org>
int parse_string(FILE *, unsigned int *, char **);
int parse_ip_addr(FILE *, struct in_addr *);
int parse_cidr(FILE *, unsigned char *);
-int parse_lease_time(FILE *, time_t *);
int parse_number(FILE *, unsigned char *, char);
int parse_boolean(FILE *, unsigned char *);
void parse_warn(char *);
-/* $OpenBSD: parse.c,v 1.78 2018/01/04 02:27:55 krw Exp $ */
+/* $OpenBSD: parse.c,v 1.79 2018/01/04 03:02:05 krw Exp $ */
/* Common parser code for dhcpd and dhclient. */
return 0;
}
-/*
- * lease-time :== NUMBER SEMI
- */
-int
-parse_lease_time(FILE *cfile, time_t *timep)
-{
- const char *errstr;
- char *val;
- long long numval;
- int token;
-
- token = next_token(&val, cfile);
- numval = strtonum(val, 0, UINT32_MAX, &errstr);
- if (errstr == NULL) {
- *timep = numval;
- return 1;
- }
-
- parse_warn("expecting integer between 0 and 4294967295.");
- if (token != ';')
- skip_to_semi(cfile);
-
- return 0;
-}
-
int
parse_boolean(FILE *cfile, unsigned char *buf)
{