diff options
author | Thomas Markwalder <tmark@isc.org> | 2016-03-04 14:16:29 -0500 |
---|---|---|
committer | Thomas Markwalder <tmark@isc.org> | 2016-03-04 14:16:29 -0500 |
commit | cc1bd34e09bad3313a16d89f7ad491ff16754dc7 (patch) | |
tree | aefafa2e9b960601a4071c684b1dc58905be90d3 /client/clparse.c | |
parent | 7f4e6f97789799a76aa0b8b5ffab39042bcbff5e (diff) | |
download | isc-dhcp-cc1bd34e09bad3313a16d89f7ad491ff16754dc7.tar.gz |
[master] Added lease-id-format to server and client
Merges in rt26378
Diffstat (limited to 'client/clparse.c')
-rw-r--r-- | client/clparse.c | 69 |
1 files changed, 56 insertions, 13 deletions
diff --git a/client/clparse.c b/client/clparse.c index 643b3fae..03190c33 100644 --- a/client/clparse.c +++ b/client/clparse.c @@ -3,7 +3,7 @@ Parser for dhclient config and lease files... */ /* - * Copyright (c) 2004-2014,2016 by Internet Systems Consortium, Inc. ("ISC") + * Copyright (c) 2004-2016 by Internet Systems Consortium, Inc. ("ISC") * Copyright (c) 1996-2003 by Internet Software Consortium * * Permission to use, copy, modify, and distribute this software for any @@ -45,6 +45,8 @@ static struct dhc6_addr *parse_client6_iaaddr_statement(struct parse *cfile); static struct dhc6_addr *parse_client6_iaprefix_statement(struct parse *cfile); #endif /* DHCPv6 */ +static void parse_lease_id_format (struct parse *cfile); + /* client-conf-file :== client-declarations END_OF_FILE client-declarations :== <nil> | client-declaration @@ -168,6 +170,7 @@ isc_result_t read_client_conf () top_level_config.retry_interval = 300; top_level_config.backoff_cutoff = 15; top_level_config.initial_interval = 3; + top_level_config.lease_id_format = TOKEN_OCTAL; /* * RFC 2131, section 4.4.1 specifies that the client SHOULD wait a @@ -809,6 +812,12 @@ void parse_client_statement (cfile, ip, config) parse_reject_statement (cfile, config); return; + case LEASE_ID_FORMAT: + skip_token(&val, (unsigned *)0, cfile); + parse_lease_id_format(cfile); + break; + + default: lose = 0; stmt = (struct executable_statement *)0; @@ -1324,25 +1333,17 @@ static void parse_client_default_duid(struct parse *cfile) { struct data_string new_duid; - const char *val = NULL; + u_int8_t buf[128]; 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; - } + len = parse_X(cfile, buf, sizeof(buf)); if (len <= 2) { parse_warn(cfile, "Invalid DUID contents."); skip_to_semi(cfile); return; } + memset(&new_duid, 0, sizeof(new_duid)); if (!buffer_allocate(&new_duid.buffer, len, MDL)) { parse_warn(cfile, "Out of memory parsing default DUID."); skip_to_semi(cfile); @@ -1351,7 +1352,7 @@ parse_client_default_duid(struct parse *cfile) new_duid.data = new_duid.buffer->data; new_duid.len = len; - memcpy(new_duid.buffer->data, val, len); + memcpy(new_duid.buffer->data, buf, len); /* Rotate the last entry into place. */ if (default_duid.buffer != NULL) @@ -2310,3 +2311,45 @@ int parse_allow_deny (oc, cfile, flag) skip_to_semi (cfile); return 0; } + + + +/*! + * \brief Parses an lease-id-format statement + * + * A valid statement looks like this: + * + * lease-id-format :== + * LEASE_ID_FORMAT TOKEN_OCTAL | TOKEN_HEX ; + * + * This function is used to parse the lease-id-format statement. It sets + * top_level_config.lease_id_format. + * + * \param cfile the current parse file + * +*/ +void parse_lease_id_format (struct parse *cfile) +{ + enum dhcp_token token; + const char *val; + + token = next_token(&val, NULL, cfile); + switch(token) { + case TOKEN_OCTAL: + top_level_config.lease_id_format = TOKEN_OCTAL; + break; + case TOKEN_HEX: + top_level_config.lease_id_format = TOKEN_HEX; + break; + default: + parse_warn(cfile, "lease-id-format is invalid: " + " it must be octal or hex."); + skip_to_semi(cfile); + return; + } + + log_debug("lease_id_format is: %s", + (top_level_config.lease_id_format == TOKEN_OCTAL + ? "octal" : "hex")); + +} |