2
0
mirror of https://gitlab.isc.org/isc-projects/dhcp synced 2025-09-01 14:55:30 +00:00

[master] Added lease-id-format to server and client

Merges in rt26378
This commit is contained in:
Thomas Markwalder
2016-03-04 14:16:29 -05:00
parent 7f4e6f9778
commit cc1bd34e09
13 changed files with 413 additions and 131 deletions

View File

@@ -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"));
}