]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[5425a] Reported some changes
authorFrancis Dupont <fdupont@isc.org>
Mon, 29 Jan 2018 16:38:08 +0000 (17:38 +0100)
committerFrancis Dupont <fdupont@isc.org>
Mon, 29 Jan 2018 16:38:08 +0000 (17:38 +0100)
doc/guide/dhcp6-srv.xml
src/lib/dhcpsrv/alloc_engine.h
src/lib/dhcpsrv/parsers/dhcp_parsers.h
src/lib/dhcpsrv/pool.cc
src/lib/dhcpsrv/pool.h
src/lib/dhcpsrv/subnet.cc

index 4b667a2a47fe76e92a0080bccd75afb981da189b..ad10322ffc38fac5257b987a9fc2de809f13b5f6 100644 (file)
@@ -1961,7 +1961,7 @@ should include options from the isc option space:
       <para>
       Client classification can also be used to restrict access to specific
       pools within a subnet. This is useful when to segregate clients belonging
-      to the same subnet into different address ranges.
+      to the same subnet into different address or prefix ranges.
       </para>
 
       <para>
index ba8d95bc0d749663fafe29f90d6e93067348b04c..382a30f520819fe2ea0435f9e63434581708870e 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2012-2017 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2012-2018 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
@@ -83,7 +83,6 @@ protected:
         ///
         /// @param subnet next address will be returned from pool of that subnet
         /// @param client_classes list of classes client belongs to
-
         /// @param duid Client's DUID
         /// @param hint client's hint
         ///
index e195cd4bad33a934fef07c21fe8efa36df84007b..12dd20cb0b44f45820ae783e11455dd808c6143b 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2017 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013-2018 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
@@ -651,8 +651,14 @@ private:
     /// A storage for pool specific option values.
     CfgOptionPtr options_;
 
+    /// @brief User context (optional, may be null)
+    ///
+    /// User context is arbitrary user data, to be used by hooks.
     isc::data::ConstElementPtr user_context_;
 
+    /// @brief Client class (a client has to belong to to use this pd-pool)
+    ///
+    /// If null, everyone is allowed.
     isc::data::ConstElementPtr client_class_;
 
 };
index dc169b0baebbc2ff42d20fa9e040a1074484e81e..5375ad105598438a0db93186cb696957ecc8921d 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2012-2017 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2012-2018 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
@@ -340,6 +340,7 @@ Pool6::toElement() const {
                 isc_throw(ToElementError, "invalid prefix range "
                           << prefix.toText() << "-" << last.toText());
             }
+            map->set("prefix-len", Element::create(prefix_len));
 
             // Set delegated-len
             uint8_t len = getLength();
@@ -354,10 +355,14 @@ Pool6::toElement() const {
                 uint8_t xlen = xopt->getExcludedPrefixLength();
                 map->set("excluded-prefix-len",
                          Element::create(static_cast<int>(xlen)));
-            } else {
-                map->set("excluded-prefix", Element::create(std::string("::")));
-                map->set("excluded-prefix-len", Element::create(0));
             }
+            // Let's not insert empty excluded-prefix values. If we ever
+            // decide to insert it after all, here's the code to do it:
+            // else {
+            //    map->set("excluded-prefix",
+            //             Element::create(std::string("::")));
+            //    map->set("excluded-prefix-len", Element::create(0));
+            /// }
 
             break;
         }
index 46423f6fa873d990b3c7955d816f3f068dd185c3..bba123cfcf214cb30ac353ee14b5a5942c9c9752 100644 (file)
@@ -100,8 +100,7 @@ public:
     /// @brief Checks whether this pool supports client that belongs to
     /// specified classes.
     ///
-    /// @todo: currently doing the same than network which
-    /// is known to be improved.
+    /// @todo: currently doing the same as network which needs improving.
     ///
     /// @param client_classes list of all classes the client belongs to
     /// @return true if client can be supported, false otherwise
@@ -204,6 +203,9 @@ protected:
 
     /// @brief Optional definition of a client class
     ///
+    /// If empty, all classes are allowed. If non-empty, only those listed
+    /// here are allowed.
+    ///
     /// @ref Network::white_list_
     ClientClasses white_list_;
 
index 3b27412280167372c7c8bdc1514b46b4962b5b64..86b05f16099da2ed820340a89ba8f75500088660 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2012-2017 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2012-2018 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
@@ -709,94 +709,16 @@ Subnet6::toElement() const {
     ElementPtr pool_list = Element::createList();
     for (PoolCollection::const_iterator pool = pools.cbegin();
          pool != pools.cend(); ++pool) {
-        // Prepare the map for a pool (@todo move this code to pool.cc)
-        ElementPtr pool_map = Element::createMap();
-        // Set user-context
-        (*pool)->contextToElement(pool_map);
-        // Set pool
-        const IOAddress& first = (*pool)->getFirstAddress();
-        const IOAddress& last = (*pool)->getLastAddress();
-        std::string range = first.toText() + "-" + last.toText();
-        // Try to output a prefix (vs a range)
-        int prefix_len = prefixLengthFromRange(first, last);
-        if (prefix_len >= 0) {
-            std::ostringstream oss;
-            oss << first.toText() << "/" << prefix_len;
-            range = oss.str();
-        }
-        pool_map->set("pool", Element::create(range));
-        // Set pool options
-        ConstCfgOptionPtr opts = (*pool)->getCfgOption();
-        pool_map->set("option-data", opts->toElement());
-        // Set client-class
-        const ClientClasses& cclasses = (*pool)->getClientClasses();
-        if (cclasses.size() > 1) {
-            isc_throw(ToElementError, "client-class has too many items: "
-                      << cclasses.size());
-        } else if (!cclasses.empty()) {
-            pool_map->set("client-class", Element::create(*cclasses.cbegin()));
-        }
-        // Push on the pool list
-        pool_list->add(pool_map);
+       pool_list->add((*pool)->toElement());
     }
     map->set("pools", pool_list);
+
     // Set pd-pools
     const PoolCollection& pdpools = getPools(Lease::TYPE_PD);
     ElementPtr pdpool_list = Element::createList();
     for (PoolCollection::const_iterator pool = pdpools.cbegin();
          pool != pdpools.cend(); ++pool) {
-        // Get it as a Pool6 (@todo move this code to pool.cc)
-        const Pool6* pdpool = dynamic_cast<Pool6*>(pool->get());
-        if (!pdpool) {
-            isc_throw(ToElementError, "invalid pd-pool pointer");
-        }
-        // Prepare the map for a pd-pool
-        ElementPtr pool_map = Element::createMap();
-        // Set user-context
-        pdpool->contextToElement(pool_map);
-        // Set prefix
-        const IOAddress& prefix = pdpool->getFirstAddress();
-        pool_map->set("prefix", Element::create(prefix.toText()));
-        // Set prefix-len (get it from min - max)
-        const IOAddress& last = pdpool->getLastAddress();
-        int prefix_len = prefixLengthFromRange(prefix, last);
-        if (prefix_len < 0) {
-            // The pool is bad: give up
-            isc_throw(ToElementError, "invalid prefix range "
-                      << prefix.toText() << "-" << last.toText());
-        }
-        pool_map->set("prefix-len", Element::create(prefix_len));
-        // Set delegated-len
-        uint8_t len = pdpool->getLength();
-        pool_map->set("delegated-len",
-                      Element::create(static_cast<int>(len)));
-
-        // Set excluded prefix
-        const Option6PDExcludePtr& xopt =
-            pdpool->getPrefixExcludeOption();
-        if (xopt) {
-            const IOAddress& xprefix =
-                xopt->getExcludedPrefix(prefix, len);
-            pool_map->set("excluded-prefix",
-                          Element::create(xprefix.toText()));
-            uint8_t xlen = xopt->getExcludedPrefixLength();
-            pool_map->set("excluded-prefix-len",
-                          Element::create(static_cast<int>(xlen)));
-        }
-
-        // Set pool options
-        ConstCfgOptionPtr opts = pdpool->getCfgOption();
-        pool_map->set("option-data", opts->toElement());
-        // Set client-class
-        const ClientClasses& cclasses = pdpool->getClientClasses();
-        if (cclasses.size() > 1) {
-            isc_throw(ToElementError, "client-class has too many items: "
-                      << cclasses.size());
-        } else if (!cclasses.empty()) {
-            pool_map->set("client-class", Element::create(*cclasses.cbegin()));
-        }
-        // Push on the pool list
-        pdpool_list->add(pool_map);
+        pdpool_list->add((*pool)->toElement());
     }
     map->set("pd-pools", pdpool_list);