]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#2266] addressed review comments
authorRazvan Becheriu <razvan@isc.org>
Thu, 23 Jun 2022 10:46:44 +0000 (13:46 +0300)
committerRazvan Becheriu <razvan@isc.org>
Fri, 24 Jun 2022 18:15:37 +0000 (18:15 +0000)
doc/sphinx/arm/hooks-subnet-cmds.rst
src/lib/cc/data.cc
src/lib/cc/data.h

index e5cb734f4bec93b4cd6cd81c7acd8ec8f328466f..30bd7f69a83fb248d5f173417fd6a84a2698eccd 100644 (file)
@@ -379,8 +379,8 @@ not be updated.
 The subnet information within this command has the same structure as the
 subnet information in the server configuration file, with the exception
 that static host reservations cannot be specified within
-``subnet4-update``. The commands described in :ref:`hooks-host-cmds` should be used
-to update, remove, and modify static reservations.
+``subnet4-update``. The commands described in :ref:`hooks-host-cmds` should be
+used to update, remove, and modify static reservations.
 
 ::
 
@@ -426,8 +426,8 @@ not be updated.
 The subnet information within this command has the same structure as the
 subnet information in the server configuration file, with the exception
 that static host reservations cannot be specified within
-``subnet6-update``. The commands described in :ref:`hooks-host-cmds` should be used
-to update, remove, and modify static reservations.
+``subnet6-update``. The commands described in :ref:`hooks-host-cmds` should be
+used to update, remove, and modify static reservations.
 
 ::
 
@@ -572,17 +572,17 @@ A successful response may look like this:
 The ``subnet4-delta-add`` Command
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-This command is used to update (overwrite) parts of a single subnet in the
-existing server configuration. This operation has no impact on other subnets.
-The subnet identifier is used to identify the subnet to update; it must be
-specified and must be unique among all subnets. The subnet prefix should
-not be updated.
+This command is used to update by adding or overwriting parts of a single subnet
+in the existing server configuration. This operation has no impact on other
+subnets. The subnet identifier is used to identify the subnet to update; it must
+be specified and must be unique among all subnets. The subnet prefix should not
+be updated.
 
 The subnet information within this command has the same structure as the
 subnet information in the server configuration file, with the exception
 that static host reservations cannot be specified within
-``subnet4-delta-add``. The commands described in :ref:`hooks-host-cmds` should be used
-to update, remove, and modify static reservations.
+``subnet4-delta-add``. The commands described in :ref:`hooks-host-cmds` should
+be used to update, remove, and modify static reservations.
 
 ::
 
@@ -590,19 +590,31 @@ to update, remove, and modify static reservations.
        "command": "subnet4-delta-add",
        "arguments": {
            "subnet4": [ {
-               ...
+               "valid-lifetime": 120,
                "id": 123,
                "subnet": "10.20.30.0/24",
                "option-data": [
-                   ...
+                   {
+                       "always-send": false,
+                       "code": 3,
+                       "csv-format": true,
+                       "data": "192.0.3.1",
+                       "name": "routers",
+                       "space": "dhcp4"
+                   }
                ],
                "pools": [
-                   ...
                    {
-                       ...
                        "pool": "10.20.30.1-10.20.30.10",
                        "option-data": [
-                           ...
+                           {
+                               "always-send": false,
+                               "code": 4,
+                               "csv-format": true,
+                               "data": "192.0.4.1",
+                               "name": "time-servers",
+                               "space": "dhcp4"
+                           }
                        ]
                    }
                ]
@@ -627,22 +639,27 @@ The response to this command has the following structure:
        }
    }
 
+The command updates subnet "10.20.30.0/24" with id 123 by changing the valid
+lifetime, adding or changing the subnet level option 3 ("routers"), by adding
+or changing the pool "10.20.30.1-10.20.30.10" and by adding or changing the pool
+level option 4 ("time-servers").
+
 .. _command-subnet6-delta-add:
 
 The ``subnet6-delta-add`` Command
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-This command is used to update (overwrite) parts of a single subnet in the
-existing server configuration. This operation has no impact on other subnets.
-The subnet identifier is used to identify the subnet to update; it must be
-specified and must be unique among all subnets. The subnet prefix should
-not be updated.
+This command is used to update by adding or overwriting parts of a single subnet
+in the existing server configuration. This operation has no impact on other
+subnets. The subnet identifier is used to identify the subnet to update; it must
+be specified and must be unique among all subnets. The subnet prefix should not
+be updated.
 
 The subnet information within this command has the same structure as the
 subnet information in the server configuration file, with the exception
 that static host reservations cannot be specified within
-``subnet6-delta-add``. The commands described in :ref:`hooks-host-cmds` should be used
-to update, remove, and modify static reservations.
+``subnet6-delta-add``. The commands described in :ref:`hooks-host-cmds` should
+be used to update, remove, and modify static reservations.
 
 ::
 
@@ -650,31 +667,48 @@ to update, remove, and modify static reservations.
        "command": "subnet6-delta-add",
        "arguments": {
            "subnet6": [ {
-               ...
+               "valid-lifetime": 120,
                "id": 243,
                "subnet": "2001:db8:1::/64",
                "option-data": [
-                   ...
+                   {
+                       "always-send": false,
+                       "code": 23,
+                       "csv-format": true,
+                       "data": "3000::3:1",
+                       "name": "dns-servers",
+                       "space": "dhcp6"
+                   }
                ],
                "pd-pools": [
-                   ...
                    {
-                       ...
                        "prefix": "2001:db8:2::",
                        "prefix-len": 48,
                        "delegated-len": 64,
                        "option-data": [
-                           ...
+                           {
+                               "always-send": false,
+                               "code": 22,
+                               "csv-format": true,
+                               "data": "3000::4:1",
+                               "name": "sip-server-addr",
+                               "space": "dhcp6"
+                           }
                        ]
                    }
                ],
                "pools": [
-                   ...
                    {
-                       ...
                        "pool": "2001:db8:1::1-2001:db8:1::10",
                        "option-data": [
-                           ...
+                           {
+                               "always-send": false,
+                               "code": 31,
+                               "csv-format": true,
+                               "data": "3000::5:1",
+                               "name": "sntp-servers",
+                               "space": "dhcp6"
+                           }
                        ]
                    }
                ]
@@ -699,22 +733,29 @@ The response to this command has the following structure:
        }
    }
 
+The command updates subnet "2001:db8:1::/64" with id 243 by changing the valid
+lifetime, adding or changing the subnet level option 23 ("dns-servers"), by
+adding or changing the pool "2001:db8:1::1-2001:db8:1::10", by adding or
+changing the pool level option 31 ("sntp-servers"), by adding or changing the
+pd-pool "2001:db8:2::" with prefix-len 48 and by adding or changing the pd-pool
+level option 22 ("sip-server-addr").
+
 .. _command-subnet4-delta-del:
 
 The ``subnet4-delta-del`` Command
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-This command is used to update (overwrite) parts of a single subnet in the
+This command is used to update by removing parts of a single subnet in the
 existing server configuration. This operation has no impact on other subnets.
 The subnet identifier is used to identify the subnet to update; it must be
-specified and must be unique among all subnets. The subnet prefix should
-not be updated.
+specified and must be unique among all subnets. The subnet prefix should not be
+updated.
 
 The subnet information within this command has the same structure as the
 subnet information in the server configuration file, with the exception
 that static host reservations cannot be specified within
-``subnet4-delta-del``. The commands described in :ref:`hooks-host-cmds` should be used
-to update, remove, and modify static reservations.
+``subnet4-delta-del``. The commands described in :ref:`hooks-host-cmds` should
+be used to update, remove, and modify static reservations.
 
 The command is flexible and can delete the part of the subnet by either
 specifying the entire object that needs to be deleted, or just the keys
@@ -729,22 +770,16 @@ to the default 'dhcp4' space.
        "command": "subnet4-delta-del",
        "arguments": {
            "subnet4": [ {
-               ...
+               "valid-lifetime": 120,
                "id": 123,
                "subnet": "10.20.30.0/24",
                "option-data" [
-                   ...
-                   { "code": 23 },
-                   { "code": 31 }
+                   { "name": "routers" }
                ]
                "pools": [
-                   ...
                    {
-                       ...
                        "option-data": [
-                           ...
-                           { "code": 23 },
-                           { "code": 31 }
+                           { "code": 4 }
                        ]
                        "pool": "10.20.30.11-10.20.30.20"
                    },
@@ -773,22 +808,27 @@ The response to this command has the following structure:
        }
    }
 
+The command updates subnet "10.20.30.0/24" with id 123 by removing the valid
+lifetime, removing the subnet level option 3 ("routers"), by removing the pool
+"10.20.30.21-10.20.30.30" and by removing the pool level option 4
+("time-servers") in pool "10.20.30.11-10.20.30.20".
+
 .. _command-subnet6-delta-del:
 
 The ``subnet6-delta-del`` Command
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-This command is used to update (overwrite) parts of a single subnet in the
+This command is used to update by removing parts of a single subnet in the
 existing server configuration. This operation has no impact on other subnets.
 The subnet identifier is used to identify the subnet to update; it must be
-specified and must be unique among all subnets. The subnet prefix should
-not be updated.
+specified and must be unique among all subnets. The subnet prefix should not be
+updated.
 
 The subnet information within this command has the same structure as the
 subnet information in the server configuration file, with the exception
 that static host reservations cannot be specified within
-``subnet6-delta-del``. The commands described in :ref:`hooks-host-cmds` should be used
-to update, remove, and modify static reservations.
+``subnet6-delta-del``. The commands described in :ref:`hooks-host-cmds` should
+be used to update, remove, and modify static reservations.
 
 The command is flexible and can delete the part of the subnet by either
 specifying the entire object that needs to be deleted, or just the keys
@@ -804,25 +844,19 @@ option belongs to the default 'dhcp6' space.
        "command": "subnet6-delta-del",
        "arguments": {
            "subnet6": [ {
-               ...
+               "valid-lifetime": 120,
                "id": 234,
                "subnet": "2001:db8:1::/64",
                "option-data" [
-                   ...
-                   { "code": 23 },
-                   { "code": 31 }
+                   { "name": "dns-servers" }
                ]
                "pd-pools": [
-                   ...
                    {
-                       ...
                        "prefix": "2001:db8:3::",
                        "prefix-len": 48,
                        "delegated-len": 64,
                        "option-data": [
-                           ...
-                           { "code": 23 },
-                           { "code": 31 }
+                           { "code": 22 }
                        ]
                    },
                    {
@@ -832,12 +866,8 @@ option belongs to the default 'dhcp6' space.
                    }
                ],
                "pools": [
-                   ...
                    {
-                       ...
                        "option-data": [
-                           ...
-                           { "code": 23 },
                            { "code": 31 }
                        ]
                        "pool": "2001:db8:1::11-2001:db8:1::20"
@@ -867,6 +897,13 @@ The response to this command has the following structure:
        }
    }
 
+The command updates subnet "2001:db8:1::/64" with id 243 by removing the valid
+lifetime, removing the subnet level option 23 ("dns-servers"), by removing the
+pool "2001:db8:1::21-2001:db8:1::30", by removing the pool level option 31
+("sntp-servers") in pool "2001:db8:1::11-2001:db8:1::20", by removing the
+pd-pool "2001:db8:4::" with prefix-len 48, by removing the pd-pool level option
+22 ("sip-server-addr") in pd-pool "2001:db8:3::" with prefix-len 48.
+
 .. _command-network4-list:
 
 .. _command-network6-list:
index f7c44b8ce3d3cb142d3ed0648e040fb4ddb55910..d87f61e3abc7e9c783df5221e7b78abe7d8e7e4f 100644 (file)
@@ -1165,9 +1165,9 @@ mergeDiffAdd(ElementPtr& element, ElementPtr& other,
             auto f = hierarchy[idx].find(key);
             if (f != hierarchy[idx].end()) {
                 bool found = false;
+                ElementPtr mutable_right = boost::const_pointer_cast<Element>(right);
                 for (auto& left : element->listValue()) {
                     ElementPtr mutable_left = boost::const_pointer_cast<Element>(left);
-                    ElementPtr mutable_right = boost::const_pointer_cast<Element>(right);
                     // Check if the elements refer to the same configuration
                     // entity.
                     if (f->second.match_(mutable_left, mutable_right)) {
@@ -1313,9 +1313,9 @@ extend(const std::string& container, const std::string& extension,
             // hierarchy.
             auto f = hierarchy[idx].find(key);
             if (f != hierarchy[idx].end()) {
+                ElementPtr mutable_right = boost::const_pointer_cast<Element>(right);
                 for (auto& left : element->listValue()) {
                     ElementPtr mutable_left = boost::const_pointer_cast<Element>(left);
-                    ElementPtr mutable_right = boost::const_pointer_cast<Element>(right);
                     if (container == key) {
                         alter = true;
                     }
index 029d6c1604474523bcc93eafea04038e1e9a5c6e..45c8cfe67c5d153fca6fb26243b2ba9e12ed9b7a 100644 (file)
@@ -799,17 +799,13 @@ void removeIdentical(ElementPtr a, ConstElementPtr b);
 /// Raises a TypeError if a or b are not MapElements
 ConstElementPtr removeIdentical(ConstElementPtr a, ConstElementPtr b);
 
-/// @brief Merges the data from other into element.
-/// (on the first level). Both elements must be
-/// MapElements.
-/// Every string,value pair in other is copied into element
-/// (the ElementPtr of value is copied, this is not a new object)
-/// Unless the value is a NullElement, in which case the
-/// key is removed from element, rather than setting the value to
-/// the given NullElement.
-/// This way, we can remove values from for instance maps with
-/// configuration data (which would then result in reverting back
-/// to the default).
+/// @brief Merges the data from other into element. (on the first level). Both
+/// elements must be MapElements. Every string, value pair in other is copied
+/// into element (the ElementPtr of value is copied, this is not a new object)
+/// Unless the value is a NullElement, in which case the key is removed from
+/// element, rather than setting the value to the given NullElement.
+/// This way, we can remove values from for instance maps with configuration
+/// data (which would then result in reverting back to the default).
 /// Raises a TypeError if either ElementPtr is not a MapElement
 void merge(ElementPtr element, ConstElementPtr other);
 
@@ -844,7 +840,7 @@ struct HierarchyTraversalTest {
 typedef std::map<std::string, HierarchyTraversalTest> FunctionMap;
 
 /// @brief Hierarchy descriptor of the containers in a specific Element
-/// hierarchy tree. The position inside the vector indicates the level on which
+/// hierarchy tree. The position inside the vector indicates the level at which
 /// the respective containers are located.
 ///
 /// e.g.
@@ -859,7 +855,7 @@ typedef std::map<std::string, HierarchyTraversalTest> FunctionMap;
 typedef std::vector<FunctionMap> HierarchyDescriptor;
 
 /// @brief Merges the diff data by adding the missing elements from 'other'
-/// to 'element' (recursively). Both elements must be same Element type.
+/// to 'element' (recursively). Both elements must be the same Element type.
 /// Raises a TypeError if elements are not the same Element type.
 /// @note
 /// for non map and list elements the values are updated with the new values
@@ -880,8 +876,8 @@ void mergeDiffAdd(ElementPtr& element, ElementPtr& other,
                   HierarchyDescriptor& hierarchy, std::string key,
                   size_t idx = 0);
 
-/// @brief Merges the diff data by removing the existing elements from 'other'
-/// to 'element' (recursively). Both elements must be same Element type.
+/// @brief Merges the diff data by removing the data present in 'other' from
+/// 'element' (recursively). Both elements must be the same Element type.
 /// Raises a TypeError if elements are not the same Element type.
 /// for non map and list elements the values are set to NullElement
 /// for maps:
@@ -903,7 +899,7 @@ void mergeDiffDel(ElementPtr& element, ElementPtr& other,
 
 /// @brief Extends data by adding the specified 'extension' elements from
 /// 'other' inside the 'container' element (recursively). Both elements must be
-/// same Element type.
+/// the same Element type.
 /// Raises a TypeError if elements are not the same Element type.
 ///
 /// @param container The container holding the data that must be extended.