From: Francis Dupont Date: Thu, 12 Jan 2017 22:09:16 +0000 (+0100) Subject: [5033] Various fixes mostly cosmetic X-Git-Tag: trac5112_base~6^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fe611daf4f21d31f9e5dd73b19adc1af5657826a;p=thirdparty%2Fkea.git [5033] Various fixes mostly cosmetic --- diff --git a/doc/examples/kea6/with-ddns.json b/doc/examples/kea6/with-ddns.json index 5bb53cb4b8..1c98f1bb93 100644 --- a/doc/examples/kea6/with-ddns.json +++ b/doc/examples/kea6/with-ddns.json @@ -39,8 +39,9 @@ "subnet": "2001:db8:1::/64", "interface": "ethX" } - ] + ], +# Enable dynamic DNS updates "dhcp-ddns" : { "enable-updates" : true, "server-ip" : "3001::1", @@ -56,7 +57,7 @@ "replace-client-name" : "when-present", "generated-prefix" : "test.prefix", "qualifying-suffix" : "test.suffix." - }, + } }, diff --git a/src/lib/dhcpsrv/parsers/dhcp_parsers.cc b/src/lib/dhcpsrv/parsers/dhcp_parsers.cc index dd8579446e..a3b7ae8ab1 100644 --- a/src/lib/dhcpsrv/parsers/dhcp_parsers.cc +++ b/src/lib/dhcpsrv/parsers/dhcp_parsers.cc @@ -1335,7 +1335,7 @@ D2ClientConfigParser::parse(isc::data::ConstElementPtr client_config) { qualifying_suffix = getString(client_config, current_param); } catch (const std::exception& ex) { isc_throw(D2ClientError, "D2ClientConfig error: " << ex.what() - << " " << getPosition(current_param, client_config)); + << " (" << getPosition(current_param, client_config) << ")"); } // Now we check for logical errors. This repeats what is done in @@ -1343,16 +1343,16 @@ D2ClientConfigParser::parse(isc::data::ConstElementPtr client_config) { // emit meaningful parameter position info in the error. if (ncr_format != dhcp_ddns::FMT_JSON) { isc_throw(D2ClientError, "D2ClientConfig error: NCR Format: " - << dhcp_ddns::ncrFormatToString(ncr_format) - << " is not supported." - << " " << getPosition("ncr-format", client_config)); + << dhcp_ddns::ncrFormatToString(ncr_format) + << " is not supported. (" + << getPosition("ncr-format", client_config) << ")"); } if (ncr_protocol != dhcp_ddns::NCR_UDP) { isc_throw(D2ClientError, "D2ClientConfig error: NCR Protocol: " << dhcp_ddns::ncrProtocolToString(ncr_protocol) - << " is not supported." - << " " << getPosition("ncr-protocol", client_config)); + << " is not supported. (" + << getPosition("ncr-protocol", client_config) << ")"); } if (sender_ip.getFamily() != server_ip.getFamily()) { @@ -1361,14 +1361,14 @@ D2ClientConfigParser::parse(isc::data::ConstElementPtr client_config) { << " is: " << (server_ip.isV4() ? "IPv4" : "IPv6") << " while sender-ip: " << sender_ip.toText() << " is: " << (sender_ip.isV4() ? "IPv4" : "IPv6") - << " " << getPosition("sender-ip", client_config)); + << " (" << getPosition("sender-ip", client_config) << ")"); } if (server_ip == sender_ip && server_port == sender_port) { isc_throw(D2ClientError, "D2ClientConfig error: server and sender cannot" " share the exact same IP address/port: " << server_ip.toText() << "/" << server_port - << " " << getPosition("sender-ip", client_config)); + << " (" << getPosition("sender-ip", client_config) << ")"); } try { diff --git a/src/lib/dhcpsrv/parsers/dhcp_parsers.h b/src/lib/dhcpsrv/parsers/dhcp_parsers.h index 5f7e2d4125..e283fd840a 100644 --- a/src/lib/dhcpsrv/parsers/dhcp_parsers.h +++ b/src/lib/dhcpsrv/parsers/dhcp_parsers.h @@ -1024,16 +1024,10 @@ protected: /// @brief Parser for D2ClientConfig /// /// This class parses the configuration element "dhcp-ddns" common to the -/// spec files for both dhcp4 and dhcp6. It creates an instance of a +/// config files for both dhcp4 and dhcp6. It creates an instance of a /// D2ClientConfig. class D2ClientConfigParser : public isc::data::SimpleParser { public: - /// @brief Constructor - /// - D2ClientConfigParser(){}; - - /// @brief Destructor - virtual ~D2ClientConfigParser(){}; /// @brief Parses a given dhcp-ddns element into D2ClientConfig. /// @@ -1045,9 +1039,11 @@ public: /// -# qualifying-suffix /// -# server-ip /// -# server-port + /// -# sender-ip + /// -# sender-port + /// -# max-queue-size /// -# ncr-protocol /// -# ncr-format - /// -# remove-on-renew /// -# always-include-fqdn /// -# allow-client-update /// -# override-no-update diff --git a/src/lib/dhcpsrv/srv_config.h b/src/lib/dhcpsrv/srv_config.h index 63ecf39831..5554cb6c71 100644 --- a/src/lib/dhcpsrv/srv_config.h +++ b/src/lib/dhcpsrv/srv_config.h @@ -482,7 +482,7 @@ public: /// @brief Returns DHCP4o6 IPC port /// - /// See @ref setDhcp4o6Port or brief discussion. + /// See @ref setDhcp4o6Port for brief discussion. /// @return value of DHCP4o6 IPC port uint32_t getDhcp4o6Port() { return (dhcp4o6_port_); diff --git a/src/lib/dhcpsrv/tests/dhcp_parsers_unittest.cc b/src/lib/dhcpsrv/tests/dhcp_parsers_unittest.cc index c458d83d35..9ebfa37192 100644 --- a/src/lib/dhcpsrv/tests/dhcp_parsers_unittest.cc +++ b/src/lib/dhcpsrv/tests/dhcp_parsers_unittest.cc @@ -458,17 +458,10 @@ public: ConstElementPtr d2_client = global->get("dhcp-ddns"); /// @todo - what if it's not in global? should we add it? if (d2_client) { - // Because "dhcp-ddns" is a MapElement and global->get() - // returns a ConstElementPtr, then we get a map we can't - // change. So go thru gyrations to create a non-const - // map, update it with default values and then replace - // the one in global with the new one. Ick. - std::map d2_map; - d2_client->getValue(d2_map); - ElementPtr new_map(new MapElement()); - new_map->setValue(d2_map); - cnt += SimpleParser::setDefaults(new_map, d2_client_defaults); - global->set("dhcp-ddns", new_map); + // Get the mutable form of d2 client config + ElementPtr mutable_d2 = + boost::const_pointer_cast(d2_client); + cnt += SimpleParser::setDefaults(mutable_d2, d2_client_defaults); } diff --git a/src/lib/dhcpsrv/tests/srv_config_unittest.cc b/src/lib/dhcpsrv/tests/srv_config_unittest.cc index 6ddc6b4e0f..86f48b4357 100644 --- a/src/lib/dhcpsrv/tests/srv_config_unittest.cc +++ b/src/lib/dhcpsrv/tests/srv_config_unittest.cc @@ -141,7 +141,9 @@ SrvConfigTest::addSubnet6(const unsigned int index) { void SrvConfigTest::enableDDNS(const bool enable) { - conf_.getD2ClientConfig()->enableUpdates(enable); + const D2ClientConfigPtr& d2_config = conf_.getD2ClientConfig(); + ASSERT_TRUE(d2_config); + d2_config->enableUpdates(enable); } // Check that by default there are no logging entries diff --git a/src/lib/dhcpsrv/testutils/config_result_check.cc b/src/lib/dhcpsrv/testutils/config_result_check.cc index 36a4c83292..e36aac7cce 100644 --- a/src/lib/dhcpsrv/testutils/config_result_check.cc +++ b/src/lib/dhcpsrv/testutils/config_result_check.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2014-2015 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -67,6 +67,12 @@ bool errorContainsPosition(ConstElementPtr error_element, ++i; } + // Make sure that there has been at least one digit and that the + // position is followed by the paren. + if ((i == 0) || (split_pos[2][i] != ')')) { + return (false); + } + // All checks passed. return (true); }