2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-31 22:15:23 +00:00

[5033] Various fixes mostly cosmetic

This commit is contained in:
Francis Dupont
2017-01-12 23:09:16 +01:00
parent ee50101f97
commit fe611daf4f
7 changed files with 30 additions and 32 deletions

View File

@@ -39,8 +39,9 @@
"subnet": "2001:db8:1::/64", "subnet": "2001:db8:1::/64",
"interface": "ethX" "interface": "ethX"
} }
] ],
# Enable dynamic DNS updates
"dhcp-ddns" : { "dhcp-ddns" : {
"enable-updates" : true, "enable-updates" : true,
"server-ip" : "3001::1", "server-ip" : "3001::1",
@@ -56,7 +57,7 @@
"replace-client-name" : "when-present", "replace-client-name" : "when-present",
"generated-prefix" : "test.prefix", "generated-prefix" : "test.prefix",
"qualifying-suffix" : "test.suffix." "qualifying-suffix" : "test.suffix."
}, }
}, },

View File

@@ -1335,7 +1335,7 @@ D2ClientConfigParser::parse(isc::data::ConstElementPtr client_config) {
qualifying_suffix = getString(client_config, current_param); qualifying_suffix = getString(client_config, current_param);
} catch (const std::exception& ex) { } catch (const std::exception& ex) {
isc_throw(D2ClientError, "D2ClientConfig error: " << ex.what() 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 // 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. // emit meaningful parameter position info in the error.
if (ncr_format != dhcp_ddns::FMT_JSON) { if (ncr_format != dhcp_ddns::FMT_JSON) {
isc_throw(D2ClientError, "D2ClientConfig error: NCR Format: " isc_throw(D2ClientError, "D2ClientConfig error: NCR Format: "
<< dhcp_ddns::ncrFormatToString(ncr_format) << dhcp_ddns::ncrFormatToString(ncr_format)
<< " is not supported." << " is not supported. ("
<< " " << getPosition("ncr-format", client_config)); << getPosition("ncr-format", client_config) << ")");
} }
if (ncr_protocol != dhcp_ddns::NCR_UDP) { if (ncr_protocol != dhcp_ddns::NCR_UDP) {
isc_throw(D2ClientError, "D2ClientConfig error: NCR Protocol: " isc_throw(D2ClientError, "D2ClientConfig error: NCR Protocol: "
<< dhcp_ddns::ncrProtocolToString(ncr_protocol) << dhcp_ddns::ncrProtocolToString(ncr_protocol)
<< " is not supported." << " is not supported. ("
<< " " << getPosition("ncr-protocol", client_config)); << getPosition("ncr-protocol", client_config) << ")");
} }
if (sender_ip.getFamily() != server_ip.getFamily()) { if (sender_ip.getFamily() != server_ip.getFamily()) {
@@ -1361,14 +1361,14 @@ D2ClientConfigParser::parse(isc::data::ConstElementPtr client_config) {
<< " is: " << (server_ip.isV4() ? "IPv4" : "IPv6") << " is: " << (server_ip.isV4() ? "IPv4" : "IPv6")
<< " while sender-ip: " << sender_ip.toText() << " while sender-ip: " << sender_ip.toText()
<< " is: " << (sender_ip.isV4() ? "IPv4" : "IPv6") << " 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) { if (server_ip == sender_ip && server_port == sender_port) {
isc_throw(D2ClientError, "D2ClientConfig error: server and sender cannot" isc_throw(D2ClientError, "D2ClientConfig error: server and sender cannot"
" share the exact same IP address/port: " " share the exact same IP address/port: "
<< server_ip.toText() << "/" << server_port << server_ip.toText() << "/" << server_port
<< " " << getPosition("sender-ip", client_config)); << " (" << getPosition("sender-ip", client_config) << ")");
} }
try { try {

View File

@@ -1024,16 +1024,10 @@ protected:
/// @brief Parser for D2ClientConfig /// @brief Parser for D2ClientConfig
/// ///
/// This class parses the configuration element "dhcp-ddns" common to the /// 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. /// D2ClientConfig.
class D2ClientConfigParser : public isc::data::SimpleParser { class D2ClientConfigParser : public isc::data::SimpleParser {
public: public:
/// @brief Constructor
///
D2ClientConfigParser(){};
/// @brief Destructor
virtual ~D2ClientConfigParser(){};
/// @brief Parses a given dhcp-ddns element into D2ClientConfig. /// @brief Parses a given dhcp-ddns element into D2ClientConfig.
/// ///
@@ -1045,9 +1039,11 @@ public:
/// -# qualifying-suffix /// -# qualifying-suffix
/// -# server-ip /// -# server-ip
/// -# server-port /// -# server-port
/// -# sender-ip
/// -# sender-port
/// -# max-queue-size
/// -# ncr-protocol /// -# ncr-protocol
/// -# ncr-format /// -# ncr-format
/// -# remove-on-renew
/// -# always-include-fqdn /// -# always-include-fqdn
/// -# allow-client-update /// -# allow-client-update
/// -# override-no-update /// -# override-no-update

View File

@@ -482,7 +482,7 @@ public:
/// @brief Returns DHCP4o6 IPC port /// @brief Returns DHCP4o6 IPC port
/// ///
/// See @ref setDhcp4o6Port or brief discussion. /// See @ref setDhcp4o6Port for brief discussion.
/// @return value of DHCP4o6 IPC port /// @return value of DHCP4o6 IPC port
uint32_t getDhcp4o6Port() { uint32_t getDhcp4o6Port() {
return (dhcp4o6_port_); return (dhcp4o6_port_);

View File

@@ -458,17 +458,10 @@ public:
ConstElementPtr d2_client = global->get("dhcp-ddns"); ConstElementPtr d2_client = global->get("dhcp-ddns");
/// @todo - what if it's not in global? should we add it? /// @todo - what if it's not in global? should we add it?
if (d2_client) { if (d2_client) {
// Because "dhcp-ddns" is a MapElement and global->get() // Get the mutable form of d2 client config
// returns a ConstElementPtr, then we get a map we can't ElementPtr mutable_d2 =
// change. So go thru gyrations to create a non-const boost::const_pointer_cast<Element>(d2_client);
// map, update it with default values and then replace cnt += SimpleParser::setDefaults(mutable_d2, d2_client_defaults);
// the one in global with the new one. Ick.
std::map<std::string, ConstElementPtr> 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);
} }

View File

@@ -141,7 +141,9 @@ SrvConfigTest::addSubnet6(const unsigned int index) {
void void
SrvConfigTest::enableDDNS(const bool enable) { 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 // Check that by default there are no logging entries

View File

@@ -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 // 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 // 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; ++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. // All checks passed.
return (true); return (true);
} }