]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#1635] Addressed review comments
authorThomas Markwalder <tmark@isc.org>
Fri, 19 Feb 2021 13:42:38 +0000 (08:42 -0500)
committerThomas Markwalder <tmark@isc.org>
Fri, 19 Feb 2021 18:21:59 +0000 (13:21 -0500)
Changes were cosmetic, no fucntional changes required.

Modified:
doc/sphinx/arm/dhcp4-srv.rst
src/bin/dhcp4/tests/config_parser_unittest.cc
src/lib/cc/simple_parser.h
src/lib/dhcpsrv/alloc_engine.cc
src/lib/dhcpsrv/alloc_engine.h
src/lib/dhcpsrv/client_class_def.cc
src/lib/dhcpsrv/client_class_def.h
src/lib/dhcpsrv/parsers/shared_network_parser.cc
src/lib/dhcpsrv/tests/alloc_engine4_unittest.cc
src/lib/dhcpsrv/tests/client_class_def_parser_unittest.cc

doc/sphinx/arm/dhcp4-srv.rst
src/bin/dhcp4/tests/config_parser_unittest.cc
src/lib/cc/simple_parser.h
src/lib/dhcpsrv/alloc_engine.cc
src/lib/dhcpsrv/alloc_engine.h
src/lib/dhcpsrv/client_class_def.cc
src/lib/dhcpsrv/client_class_def.h
src/lib/dhcpsrv/parsers/shared_network_parser.cc
src/lib/dhcpsrv/tests/alloc_engine4_unittest.cc
src/lib/dhcpsrv/tests/client_class_def_parser_unittest.cc

index 42dbd048c9e7b14427a9d23d26f61cc7d82cb3cc..b8c3396ed44f02c45c07f445badcf934815e76d3 100644 (file)
@@ -182,33 +182,33 @@ client will begin the renewal and rebind procedures.
 
 .. note::
 
-    Beginning with Kea 1.6.0 the lease valid lifetime is extended from a
-    single value to a triplet with minimum, default and maximum values using
-    ``min-valid-lifetime``, ``valid-lifetime`` and ``max-valid-lifetime``.
-    As of Kea 1.9.5, these values may be specified in client classes. The recipe
-    the server uses to select which lifetime value to use is as follows:
-
-    If the client query is a BOOTP query, the server will always use the
-    infinite lease time (e.g.0xffffffff). Otherwise the server must next
-    determine which configured triplet to use by first searching all
-    classes assigned to the query, and then the subnet selected for
-    the query.
-
-    Classes are searched in the order they were assigned to the query. The
-    server will use the triplet from the first class that specifies it.
-    If no classes specify the triplet then the server will use the triplet
-    specified by the subnet selected for the client. If the subnet does not
-    explicitly specify it the server will look next at the subnet's
-    shared-network (if one), then for a global specification, and
-    finally the global default.
-
-    If the client requested a lifetime value via DHCP option 51, then the
-    lifetime value used will be the requested value bounded by the configured
-    triplet.  In other words, If the requested lifetime is less than the
-    configured minimum the configured minimum will be used; if it is more
-    than the configured maximum the configured maximum will be used.  If
-    the client did not provide a requested value, the lifetime value used
-    is the simple be the triplet default value.
+   Beginning with Kea 1.6.0 the lease valid lifetime is extended from a
+   single value to a triplet with minimum, default and maximum values using
+   ``min-valid-lifetime``, ``valid-lifetime`` and ``max-valid-lifetime``.
+   As of Kea 1.9.5, these values may be specified in client classes. The recipe
+   the server uses to select which lifetime value to use is as follows:
+
+   If the client query is a BOOTP query, the server will always use the
+   infinite lease time (e.g. 0xffffffff). Otherwise the server must next
+   determine which configured triplet to use by first searching all
+   classes assigned to the query, and then the subnet selected for
+   the query.
+
+   Classes are searched in the order they were assigned to the query. The
+   server will use the triplet from the first class that specifies it.
+   If no classes specify the triplet then the server will use the triplet
+   specified by the subnet selected for the client. If the subnet does not
+   explicitly specify it the server will look next at the subnet's
+   shared-network (if one), then for a global specification, and
+   finally the global default.
+
+   If the client requested a lifetime value via DHCP option 51, then the
+   lifetime value used will be the requested value bounded by the configured
+   triplet.  In other words, if the requested lifetime is less than the
+   configured minimum the configured minimum will be used; if it is more
+   than the configured maximum the configured maximum will be used.  If
+   the client did not provide a requested value, the lifetime value used
+   will be the triplet default value.
 
 .. note::
 
index 22180d968300d803e006d5829ab2569d946522c0..bbbb976361e44f796e86e80fd6987ed13fc37f14 100644 (file)
@@ -6088,7 +6088,6 @@ TEST_F(Dhcp4ParserTest, clientClassValidLifetime) {
     class_def = dictionary->findClass("two");
     ASSERT_TRUE(class_def);
     EXPECT_TRUE(class_def->getValid().unspecified());
-
 }
 
 
index 5bed826345e473a4edb5ac1ecf6b459891118e45..ce1865073560725ef1805b3f06346c5adb6f8aa3 100644 (file)
@@ -321,16 +321,16 @@ public:
 
     /// @brief Parses a integer triplet
     ///
-    /// Parse an integer triplet parameter of the form:
+    /// Parses an integer triplet parameter of the form:
     ///
     ///    min-<name>, <name>, max-<name>
     ///
-    /// @param scope Data element holding e.g.  shared network configuration
+    /// @param scope Data element holding e.g. shared network configuration
     /// to be parsed.
     /// @param name Base name of the parameter.
     /// @return A triplet with the parsed value.
     const dhcp::Triplet<uint32_t> parseIntTriplet(const data::ConstElementPtr& scope,
-                                          const std::string& name);
+                                                  const std::string& name);
 };
 
 };
index 61e93e1bb5b3dfde7a21bab6b036869f69030f9d..251133427d1732f288a2045ef09aa919ae03349f 100644 (file)
@@ -3845,7 +3845,7 @@ AllocEngine::getValidLft(const ClientContext4& ctx) {
 
     // If it's BOOTP, use infinite valid lifetime.
     if (ctx.query_->inClass("BOOTP")) {
-        return(Lease::INFINITY_LFT);
+        return (Lease::INFINITY_LFT);
     }
 
     // Use the dhcp-lease-time content from the client if it's there.
@@ -3858,10 +3858,9 @@ AllocEngine::getValidLft(const ClientContext4& ctx) {
         }
     }
 
-
     // If the triplet is specified in one of our classes use it.
     // We use the first one we find.
-    Triplet<uint32_t>candidate_lft;
+    Triplet<uint32_t> candidate_lft;
     const ClientClasses classes = ctx.query_->getClasses();
     if (!classes.empty()) {
         // Let's get class definitions
@@ -3887,7 +3886,7 @@ AllocEngine::getValidLft(const ClientContext4& ctx) {
     // If client requested a value, use the value bounded by
     // the candidate triplet.
     if (requested_lft > 0) {
-        return(candidate_lft.get(requested_lft));
+        return (candidate_lft.get(requested_lft));
     }
 
     // Use the candidate's default value.
index 8973b6e4be78dc5b50a6d9c85f5a3d440af7366c..d0b7a06d93cbe0ce789dbe8124ea2365cad96cdd 100644 (file)
@@ -1640,7 +1640,7 @@ public:
     /// it simply returns the candidate triplet's default value.
     ///
     /// @param ctx Client context holding various information about the client.
-    /// @return unsigned integer value of the valid lifetime to use
+    /// @return unsigned integer value of the valid lifetime to use.
     static uint32_t getValidLft(const ClientContext4& ctx);
 
 private:
index 1a0e02a5fea842e53dd2c483e5dacf54a729e921..d038a016db0081d8e11ef60f1f5f787fc4b60731 100644 (file)
@@ -197,14 +197,16 @@ ClientClassDef:: toElement() const {
     // Set valid-lifetime
     if (!valid_.unspecified()) {
         result->set("valid-lifetime",
-                 Element::create(static_cast<long long>(valid_.get())));
+                    Element::create(static_cast<long long>(valid_.get())));
+
         if (valid_.getMin() < valid_.get()) {
             result->set("min-valid-lifetime",
-                     Element::create(static_cast<long long>(valid_.getMin())));
+                        Element::create(static_cast<long long>(valid_.getMin())));
         }
+
         if (valid_.getMax() > valid_.get()) {
             result->set("max-valid-lifetime",
-                     Element::create(static_cast<long long>(valid_.getMax())));
+                        Element::create(static_cast<long long>(valid_.getMax())));
         }
     }
 
@@ -282,7 +284,7 @@ ClientClassDictionary::findClass(const std::string& name) const {
         return (*it).second;
     }
 
-    return(ClientClassDefPtr());
+    return (ClientClassDefPtr());
 }
 
 void
index 990a16d750363d6fa0bdd6d531e5f94f576f8b46..e5eb160755832f93924b19f83f3d05d1eb22fbd7 100644 (file)
@@ -192,6 +192,7 @@ public:
     }
 
     /// @brief Return valid-lifetime value
+    /// @return a triplet containing the valid lifetime.
     Triplet<uint32_t> getValid() const {
         return(valid_);
     }
index ca75264d785be710d85ce53368a9dc373a8eda3c..1eb7c8710216d0eec2ab0f2336f6350d349085b7 100644 (file)
@@ -244,7 +244,7 @@ SharedNetwork6Parser::parse(const data::ConstElementPtr& shared_network_data) {
 
         // preferred-lifetime
         shared_network->setPreferred(parseIntTriplet(shared_network_data,
-                                                   "preferred-lifetime"));
+                                                     "preferred-lifetime"));
 
         // Get interface-id option content. For now we support string
         // representation only
index 44805fbe1e4d6a890b99133d1c5a5fc44ca62029..7d434a241b61912e91a620afeaa75675f5f8c948 100644 (file)
@@ -4291,7 +4291,7 @@ TEST_F(AllocEngine4Test, getValidLft4) {
     ClientClassDictionaryPtr dictionary = CfgMgr::instance().getStagingCfg()->getClientClassDictionary();
 
     ClientClassDefPtr class_def(new ClientClassDef("valid_one", ExpressionPtr()));
-    Triplet<uint32_t>valid_one(50,100,150);
+    Triplet<uint32_t> valid_one(50, 100, 150);
     class_def->setValid(valid_one);
     dictionary->addClass(class_def);
 
@@ -4307,7 +4307,7 @@ TEST_F(AllocEngine4Test, getValidLft4) {
     CfgMgr::instance().commit();
 
     // Update the subnet's triplet to something more useful.
-    subnet_->setValid(Triplet<uint32_t>(500,1000,1500));
+    subnet_->setValid(Triplet<uint32_t>(500, 1000, 1500));
 
     // Describes a test scenario.
     struct Scenario {
@@ -4321,7 +4321,7 @@ TEST_F(AllocEngine4Test, getValidLft4) {
     std::vector<Scenario> scenarios = {
         {
             "BOOTP",
-            {"BOOTP"},
+            { "BOOTP" },
             0,
             Lease::INFINITY_LFT
         },
@@ -4369,19 +4369,19 @@ TEST_F(AllocEngine4Test, getValidLft4) {
         },
         {
             "class plus option",
-            {"valid_one"},
+            { "valid_one" },
             valid_one.getMin() + 25,
             valid_one.getMin() + 25
         },
         {
             "class plus option too small",
-            {"valid_one"},
+            { "valid_one" },
             valid_one.getMin() - 25,
             valid_one.getMin()
         },
         {
             "class plus option too big",
-            {"valid_one"},
+            { "valid_one" },
             valid_one.getMax() + 25,
             valid_one.getMax()
         }
index 0e786c50015c389a6331581bb13d885112a6525d..f1a87aabceb7fe271c492b9bee181f1e40831c81 100644 (file)
@@ -1303,29 +1303,29 @@ TEST_F(ClientClassDefParserTest, validLifetimeTests) {
 
     std::vector<Scenario> scenarios = {
         {
-        "unspecified",
-        "",
-        Triplet<uint32_t>()
+            "unspecified",
+            "",
+            Triplet<uint32_t>()
         },
         {
-        "valid only",
-        "\"valid-lifetime\": 100",
-        Triplet<uint32_t>(100)
+            "valid only",
+            "\"valid-lifetime\": 100",
+            Triplet<uint32_t>(100)
         },
         {
-        "min only",
-        "\"min-valid-lifetime\": 50",
-        Triplet<uint32_t>(50, 50, 50)
+            "min only",
+            "\"min-valid-lifetime\": 50",
+            Triplet<uint32_t>(50, 50, 50)
         },
         {
-        "max only",
-        "\"max-valid-lifetime\": 75",
-        Triplet<uint32_t>(75, 75, 75)
+            "max only",
+            "\"max-valid-lifetime\": 75",
+            Triplet<uint32_t>(75, 75, 75)
         },
         {
-        "all three",
-        "\"min-valid-lifetime\": 25, \"valid-lifetime\": 50, \"max-valid-lifetime\": 75",
-        Triplet<uint32_t>(25, 50, 75)
+            "all three",
+            "\"min-valid-lifetime\": 25, \"valid-lifetime\": 50, \"max-valid-lifetime\": 75",
+            Triplet<uint32_t>(25, 50, 75)
         }
     };
 
@@ -1336,7 +1336,7 @@ TEST_F(ClientClassDefParserTest, validLifetimeTests) {
             if (!scenario.cfg_txt_.empty()) {
                 oss << ",\n" << scenario.cfg_txt_;
             }
-            oss <<  "\n}\n";
+            oss << "\n}\n";
 
             ClientClassDefPtr class_def;
             ASSERT_NO_THROW_LOG(class_def = parseClientClassDef(oss.str(), AF_INET));