]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[5033] Various fixes mostly cosmetic
authorFrancis Dupont <fdupont@isc.org>
Thu, 12 Jan 2017 22:09:16 +0000 (23:09 +0100)
committerFrancis Dupont <fdupont@isc.org>
Thu, 12 Jan 2017 22:09:16 +0000 (23:09 +0100)
doc/examples/kea6/with-ddns.json
src/lib/dhcpsrv/parsers/dhcp_parsers.cc
src/lib/dhcpsrv/parsers/dhcp_parsers.h
src/lib/dhcpsrv/srv_config.h
src/lib/dhcpsrv/tests/dhcp_parsers_unittest.cc
src/lib/dhcpsrv/tests/srv_config_unittest.cc
src/lib/dhcpsrv/testutils/config_result_check.cc

index 5bb53cb4b8bc669455b76fb725a0d97c99579840..1c98f1bb934e998f1c8ad9d4ec065b6e2a7c3af9 100644 (file)
@@ -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."
-  },
+  }
 
 },
 
index dd8579446e9396635cb923d8afec995a60a9baa1..a3b7ae8ab10d8d6509ed261e308953b695dbd861 100644 (file)
@@ -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 {
index 5f7e2d4125d503790b164cffa66a35244d034233..e283fd840a60bf87ac973dd8dee827b31d011d9a 100644 (file)
@@ -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
index 63ecf3983107885a3663aded3cd1f01b8a1d7bd5..5554cb6c71ca505156b53188c1764a094fd77255 100644 (file)
@@ -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_);
index c458d83d3575becc6bba8fe0cd9e98769392ae60..9ebfa37192744600841911ea84e2f8c9361bb50b 100644 (file)
@@ -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<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);
+            // Get the mutable form of d2 client config
+            ElementPtr mutable_d2 =
+                boost::const_pointer_cast<Element>(d2_client);
+            cnt += SimpleParser::setDefaults(mutable_d2, d2_client_defaults);
         }
 
 
index 6ddc6b4e0f70acc9896779be1b0c4f75344a828c..86f48b4357db2eb068de8fd1f5626678925887ee 100644 (file)
@@ -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
index 36a4c83292e5869a14d327b734ab5e2a5fba2540..e36aac7cce63e86a1e6c490d3697030100698a94 100644 (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
 // 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);
             }