From: Evan Hunt Date: Tue, 22 Jan 2008 18:48:04 +0000 (+0000) Subject: Exit with warning when DHCPv6 config is used but -6 isn't specified [rt17334] X-Git-Tag: v4_1_0a1~14 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=771484ac0449ca6c0e3b4263c69f84dc1b5b00f2;p=thirdparty%2Fdhcp.git Exit with warning when DHCPv6 config is used but -6 isn't specified [rt17334] --- diff --git a/RELNOTES b/RELNOTES index e397a0284..20547e665 100644 --- a/RELNOTES +++ b/RELNOTES @@ -55,6 +55,9 @@ suggested fixes to . Changes since 4.0.0 +- Exit with warning when DHCPv6-specific statements are used in the + config file but -6 is not specified. + - It's now possible to update the "ends" field of a lease with OMAPI. This is useful if you want not only to release a lease, but also make it available for reuse right away. Hat tip to Christof Chen. diff --git a/common/parse.c b/common/parse.c index 984eab789..f6bfa1316 100644 --- a/common/parse.c +++ b/common/parse.c @@ -373,6 +373,13 @@ parse_ip6_addr(struct parse *cfile, struct iaddr *addr) { char v6[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")]; int v6_len; + if (local_family != AF_INET6) { + parse_warn(cfile, "IPv6 addresses are only available " + "in DHCPv6 mode."); + skip_to_semi(cfile); + return 0; + } + /* * First token is non-raw. This way we eat any whitespace before * our IPv6 address begins, like one would expect. diff --git a/server/confpars.c b/server/confpars.c index ad97ffef9..13b10548f 100644 --- a/server/confpars.c +++ b/server/confpars.c @@ -2571,6 +2571,13 @@ parse_subnet6_declaration(struct parse *cfile, struct shared_network *share) { 0xF0, 0xF8, 0xFC, 0xFE }; struct iaddr iaddr; + if (local_family != AF_INET6) { + parse_warn(cfile, "subnet6 statement is only supported " + "in DHCPv6 mode."); + skip_to_semi(cfile); + return; + } + subnet = NULL; status = subnet_allocate(&subnet, MDL); if (status != ISC_R_SUCCESS) { @@ -3667,6 +3674,13 @@ parse_address_range6(struct parse *cfile, struct group *group) { struct iaddrcidrnetlist *nets; struct iaddrcidrnetlist *p; + if (local_family != AF_INET6) { + parse_warn(cfile, "range6 statement is only supported " + "in DHCPv6 mode."); + skip_to_semi(cfile); + return; + } + /* * We'll use the shared_network from our group. */ @@ -3841,6 +3855,12 @@ parse_ia_na_declaration(struct parse *cfile) { struct binding *bnd; struct binding_value *nv=NULL; + if (local_family != AF_INET6) { + parse_warn(cfile, "IA_NA is only supported in DHCPv6 mode."); + skip_to_semi(cfile); + return; + } + token = next_token(&val, &len, cfile); if (token != STRING) { parse_warn(cfile, "corrupt lease file; " @@ -4129,6 +4149,12 @@ parse_ia_ta_declaration(struct parse *cfile) { struct binding *bnd; struct binding_value *nv=NULL; + if (local_family != AF_INET6) { + parse_warn(cfile, "IA_TA is only supported in DHCPv6 mode."); + skip_to_semi(cfile); + return; + } + token = next_token(&val, &len, cfile); if (token != STRING) { parse_warn(cfile, "corrupt lease file; " @@ -4418,6 +4444,12 @@ parse_ia_pd_declaration(struct parse *cfile) { struct binding *bnd; struct binding_value *nv=NULL; + if (local_family != AF_INET6) { + parse_warn(cfile, "IA_PD is only supported in DHCPv6 mode."); + skip_to_semi(cfile); + return; + } + token = next_token(&val, &len, cfile); if (token != STRING) { parse_warn(cfile, "corrupt lease file; "