]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#1405] implemented separate boolean flags for reservation modes
authorRazvan Becheriu <razvan@isc.org>
Thu, 15 Oct 2020 09:52:51 +0000 (12:52 +0300)
committerRazvan Becheriu <razvan@isc.org>
Wed, 18 Nov 2020 13:55:22 +0000 (15:55 +0200)
32 files changed:
doc/examples/kea4/all-keys.json
doc/examples/kea6/all-keys.json
doc/sphinx/arm/dhcp4-srv.rst
doc/sphinx/arm/dhcp6-srv.rst
doc/sphinx/arm/hooks.rst
src/bin/dhcp4/dhcp4_lexer.ll
src/bin/dhcp4/dhcp4_parser.yy
src/bin/dhcp4/json_config_parser.cc
src/bin/dhcp4/tests/config_parser_unittest.cc
src/bin/dhcp4/tests/host_unittest.cc
src/bin/dhcp6/dhcp6_lexer.ll
src/bin/dhcp6/dhcp6_parser.yy
src/bin/dhcp6/json_config_parser.cc
src/bin/dhcp6/tests/config_parser_unittest.cc
src/bin/dhcp6/tests/host_unittest.cc
src/bin/keactrl/kea-dhcp4.conf.pre
src/lib/cc/simple_parser.cc
src/lib/dhcpsrv/network.cc
src/lib/dhcpsrv/network.h
src/lib/dhcpsrv/parsers/base_network_parser.cc
src/lib/dhcpsrv/parsers/dhcp_parsers.cc
src/lib/dhcpsrv/parsers/reservation_modes_parser.cc
src/lib/dhcpsrv/parsers/shared_network_parser.cc
src/lib/dhcpsrv/parsers/simple_parser4.cc
src/lib/dhcpsrv/parsers/simple_parser6.cc
src/lib/dhcpsrv/srv_config.cc
src/lib/dhcpsrv/tests/cfg_subnets4_unittest.cc
src/lib/dhcpsrv/tests/cfg_subnets6_unittest.cc
src/lib/dhcpsrv/tests/network_unittest.cc
src/lib/dhcpsrv/tests/reservation_modes_parser_unittest.cc
src/lib/dhcpsrv/tests/shared_network_parser_unittest.cc
src/lib/dhcpsrv/tests/shared_network_unittest.cc

index 8d4cb5fb51026a868059d8adac8f3643feda94e1..ebba0c0010bf09b373e2ca144e97c505bfb0294c 100644 (file)
 
                 // Enumeration specifying server's mode of operation when it
                 // fetches host reservations.
-                // It is deprecated by the "reservation-modes" map.
+                // It is deprecated by the "reservations-out-of-pool",
+                // reservations-in-subnet and reservations-global parameters.
                 // "reservation-mode": "all",
 
-                // Reservation modes specifying server's mode of operation when it
-                // fetches host reservations.
-                "reservation-modes": {
-                    "global": false,
-                    "in-subnet": true,
-                    "out-of-pool": true
-                },
+                // Specify if server should lookup global reservations.
+                "reservations-global": false,
+
+                // Specify if server should lookup in-subnet reservations.
+                "reservations-in-subnet": true,
+
+                // Specify if server should lookup out-of-pool reservations.
+                "reservations-out-of-pool": true,
 
                 // List of client classes which must be evaluated when this shared
                 // network is selected for client assignments.
 
                         // Enumeration specifying server's mode of operation when it
                         // fetches host reservations.
-                        // It is deprecated by the "reservation-modes" map.
+                        // It is deprecated by the "reservations-out-of-pool",
+                        // reservations-in-subnet and reservations-global parameters.
                         // "reservation-mode": "all",
 
-                        // Reservation modes specifying server's mode of operation when it
-                        // fetches host reservations.
-                        "reservation-modes": {
-                            "global": false,
-                            "in-subnet": true,
-                            "out-of-pool": true
-                        },
+                        // Specify if server should lookup global reservations.
+                        "reservations-global": false,
+
+                        // Specify if server should lookup in-subnet reservations.
+                        "reservations-in-subnet": true,
+
+                        // Specify if server should lookup out-of-pool reservations.
+                        "reservations-out-of-pool": true,
 
                         // Subnet level compute T1 and T2 timers.
                         "calculate-tee-times": true,
         },
 
         // Fetches host reservations.
-        // It is deprecated by the "reservation-modes" map.
+        // It is deprecated by the "reservations-out-of-pool",
+        // reservations-in-subnet and reservations-global parameters.
         // "reservation-mode": "all",
 
-        // Reservation modes specifying server's mode of operation when it
-        // fetches host reservations.
-        "reservation-modes": {
-            "global": false,
-            "in-subnet": true,
-            "out-of-pool": true
-        },
+        // Specify if server should lookup global reservations.
+        "reservations-global": false,
+
+        // Specify if server should lookup in-subnet reservations.
+        "reservations-in-subnet": true,
+
+        // Specify if server should lookup out-of-pool reservations.
+        "reservations-out-of-pool": true,
 
         // Global compute T1 and T2 timers.
         "calculate-tee-times": true,
index 46695e982323e5a82badb90aa9c6e2af24473ecd..9f89b9e3d35bf2fba093e4570cd40476f03287eb 100644 (file)
 
                 // Enumeration specifying server's mode of operation when it
                 // fetches host reservations.
-                // It is deprecated by the "reservation-modes" map.
+                // It is deprecated by the "reservations-out-of-pool",
+                // reservations-in-subnet and reservations-global parameters.
                 // "reservation-mode": "all",
 
-                // Reservation modes specifying server's mode of operation when it
-                // fetches host reservations.
-                "reservation-modes": {
-                    "global": false,
-                    "in-subnet": true,
-                    "out-of-pool": true
-                },
+                // Specify if server should lookup global reservations.
+                "reservations-global": false,
+
+                // Specify if server should lookup in-subnet reservations.
+                "reservations-in-subnet": true,
+
+                // Specify if server should lookup out-of-pool reservations.
+                "reservations-out-of-pool": true,
 
                 // List of client classes which must be evaluated when this shared
                 // network is selected for client assignments.
 
                         // Enumeration specifying server's mode of operation when it
                         // fetches host reservations.
-                        // It is deprecated by the "reservation-modes" map.
+                        // It is deprecated by the "reservations-out-of-pool",
+                        // reservations-in-subnet and reservations-global parameters.
                         // "reservation-mode": "all",
 
-                        // Reservation modes specifying server's mode of operation when it
-                        // fetches host reservations.
-                        "reservation-modes": {
-                            "global": false,
-                            "in-subnet": true,
-                            "out-of-pool": true
-                        },
+                        // Specify if server should lookup global reservations.
+                        "reservations-global": false,
+
+                        // Specify if server should lookup in-subnet reservations.
+                        "reservations-in-subnet": true,
+
+                        // Specify if server should lookup out-of-pool reservations.
+                        "reservations-out-of-pool": true,
 
                         // Subnet level compute T1 and T2 timers.
                         "calculate-tee-times": true,
         },
 
         // Fetches host reservations.
-        // It is deprecated by the "reservation-modes" map.
+        // It is deprecated by the "reservations-out-of-pool",
+        // reservations-in-subnet and reservations-global parameters.
         // "reservation-mode": "all",
 
-        // Reservation modes specifying server's mode of operation when it
-        // fetches host reservations.
-        "reservation-modes": {
-            "global": false,
-            "in-subnet": true,
-            "out-of-pool": true
-        },
+        // Specify if server should lookup global reservations.
+        "reservations-global": false,
+
+        // Specify if server should lookup in-subnet reservations.
+        "reservations-in-subnet": true,
+
+        // Specify if server should lookup out-of-pool reservations.
+        "reservations-out-of-pool": true,
 
         // Data directory.
         "data-directory": "/tmp",
index 17c5e09962cfc45c4028eed045782e13fc4e638c..4c972c1fcb5d16651cce9b6eba4552e7ca69cafc 100644 (file)
@@ -4623,8 +4623,8 @@ An example configuration using global reservations is shown below:
    }
 
 Since Kea 1.9.1, the ``reservation-mode`` is deprecated by the
-``reservation-modes`` map.
-The map contains ``global``, ``in-subnet`` and ``out-of-pool`` boolean flags.
+``reservations-out-of-pool``, ``reservations-in-subnet`` and
+``reservations-global`` flags.
 The flags can be activated independently and can produce various combinations,
 some of them being unsuported by the deprecated ``reservation-mode``.
 
@@ -4636,11 +4636,10 @@ The correspondence of old values are:
 
    "Dhcp4": {
 
-   "reservation-modes": {
-       "global": false,
-       "in-subnet": false,
-       "out-of-pool": false
-   }
+       "reservations-global": false,
+       "reservations-in-subnet": false,
+       "reservations-out-of-pool": false,
+       ...
    }
 
 ``global``:
@@ -4649,11 +4648,10 @@ The correspondence of old values are:
 
    "Dhcp4": {
 
-   "reservation-modes": {
-       "global": true,
-       "in-subnet": false,
-       "out-of-pool": false
-   }
+       "reservations-global": true,
+       "reservations-in-subnet": false,
+       "reservations-out-of-pool": false,
+       ...
    }
 
 ``out-of-pool``:
@@ -4662,11 +4660,10 @@ The correspondence of old values are:
 
    "Dhcp4": {
 
-   "reservation-modes": {
-       "global": false,
-       "in-subnet": false,
-       "out-of-pool": true
-   }
+       "reservations-global": false,
+       "reservations-in-subnet": false,
+       "reservations-out-of-pool": true,
+       ...
    }
 
 ``all``:
@@ -4675,11 +4672,10 @@ The correspondence of old values are:
 
    "Dhcp4": {
 
-   "reservation-modes": {
-       "global": false,
-       "in-subnet": true,
-       "out-of-pool": true
-   }
+       "reservations-global": false,
+       "reservations-in-subnet": true,
+       "reservations-out-of-pool": true,
+       ...
    }
 
 To activate both ``global`` and ``all``, the following combination can be used:
@@ -4688,11 +4684,10 @@ To activate both ``global`` and ``all``, the following combination can be used:
 
    "Dhcp4": {
 
-   "reservation-modes": {
-       "global": true,
-       "in-subnet": true,
-       "out-of-pool": true
-   }
+       "reservations-global": true,
+       "reservations-in-subnet": true,
+       "reservations-out-of-pool": true,
+       ...
    }
 
 The parameter can be specified at global, subnet, and shared-network
@@ -4706,11 +4701,9 @@ An example configuration that disables reservation looks as follows:
        "subnet4": [
        {
            "subnet": "192.0.2.0/24",
-           "reservation-modes": {
-               "global": false,
-               "in-subnet": false,
-               "out-of-pool": false
-           },
+           "reservations-global": false,
+           "reservations-in-subnet": false,
+           "reservations-out-of-pool": false,
            ...
        }
        ]
@@ -4723,12 +4716,9 @@ An example configuration using global reservations is shown below:
 
    "Dhcp4": {
 
-
-       "reservation-modes": {
-           "global": true,
-           "in-subnet": false,
-           "out-of-pool": false
-       },
+       "reservations-global": true,
+       "reservations-in-subnet": false,
+       "reservations-out-of-pool": false,
        "reservations": [
           {
            "hw-address": "01:bb:cc:dd:ee:ff",
@@ -4853,15 +4843,15 @@ following can be used:
        "valid-lifetime": 600,
        "subnet4": [ {
            "subnet": "10.0.0.0/24",
-           # It is deprecated by the "reservation-modes" map.
+           # It is deprecated by the "reservations-out-of-pool",
+           # reservations-in-subnet and reservations-global parameters.
            # "reservation-mode": "global",
-           # Reservation modes specifying server's mode of operation when it
-           # fetches host reservations.
-           "reservation-modes": {
-               "global": true,
-               "in-subnet": false,
-               "out-of-pool": false
-           },
+           # Specify if server should lookup global reservations.
+           "reservations-global": true,
+           # Specify if server should lookup in-subnet reservations.
+           "reservations-in-subnet": false,
+           # Specify if server should lookup out-of-pool reservations.
+           "reservations-out-of-pool": false,
            "pools": [ { "pool": "10.0.0.10-10.0.0.100" } ]
        } ]
    }
@@ -4964,15 +4954,15 @@ following example:
             "hw-address": "aa:bb:cc:dd:ee:fe",
             "client-classes": [ "reserved_class" ]
         }],
-        # It is deprecated by the "reservation-modes" map.
+        # It is deprecated by the "reservations-out-of-pool",
+        # reservations-in-subnet and reservations-global parameters.
         # "reservation-mode": "global",
-        # Reservation modes specifying server's mode of operation when it
-        # fetches host reservations.
-        "reservation-modes": {
-            "global": true,
-            "in-subnet": false,
-            "out-of-pool": false
-        },
+        # Specify if server should lookup global reservations.
+        "reservations-global": true,
+        # Specify if server should lookup in-subnet reservations.
+        "reservations-in-subnet": false,
+        # Specify if server should lookup out-of-pool reservations.
+        "reservations-out-of-pool": false,
         "shared-networks": [{
             "subnet4": [
                 {
@@ -5005,8 +4995,8 @@ will be assigned an address from the subnet 192.0.3.0/24. Clients having
 a reservation for the ``reserved_class`` will be assigned an address from
 the subnet 192.0.2.0/24. The subnets must belong to the same shared network.
 In addition, the reservation for the client class must be specified at the
-global scope (global reservation) and the ``reservation-modes`` must
-set ``global`` to true.
+global scope (global reservation) and the ``reservations-global`` must be
+set to true.
 
 In the example above the ``client-class`` could also be specified at the
 subnet level rather than pool level yielding the same effect.
@@ -6737,7 +6727,11 @@ used by all servers connecting to the configuration database.
    +-----------------------------+----------------------------+-------------+-------------+-------------+
    | reservation-mode            | yes                        | yes         | yes         | n/a         |
    +-----------------------------+----------------------------+-------------+-------------+-------------+
-   | reservation-modes           | yes                        | yes         | yes         | n/a         |
+   | reservations-out-of-pool    | yes                        | yes         | yes         | n/a         |
+   +-----------------------------+----------------------------+-------------+-------------+-------------+
+   | reservations-in-subnet      | yes                        | yes         | yes         | n/a         |
+   +-----------------------------+----------------------------+-------------+-------------+-------------+
+   | reservations-global         | yes                        | yes         | yes         | n/a         |
    +-----------------------------+----------------------------+-------------+-------------+-------------+
    | t1-percent                  | yes                        | yes         | yes         | n/a         |
    +-----------------------------+----------------------------+-------------+-------------+-------------+
index f5370603784f26c8684c44a5ec1841dcce4515de..41d5f6cd9222866b3e05cf28eda4fdecb0f15b2c 100644 (file)
@@ -4068,8 +4068,8 @@ An example configuration using global reservations is shown below:
    }
 
 Since Kea 1.9.1, the ``reservation-mode`` is deprecated by the
-``reservation-modes`` map.
-The map contains ``global``, ``in-subnet`` and ``out-of-pool`` boolean flags.
+``reservations-out-of-pool``, ``reservations-in-subnet`` and
+``reservations-global`` flags.
 The flags can be activated independently and can produce various combinations,
 some of them being unsuported by the deprecated ``reservation-mode``.
 
@@ -4081,11 +4081,10 @@ The correspondence of old values are:
 
    "Dhcp6": {
 
-   "reservation-modes": {
-       "global": false,
-       "in-subnet": false,
-       "out-of-pool": false
-   }
+       "reservations-global": false,
+       "reservations-in-subnet": false,
+       "reservations-out-of-pool": false,
+       ...
    }
 
 ``global``:
@@ -4094,11 +4093,10 @@ The correspondence of old values are:
 
    "Dhcp6": {
 
-   "reservation-modes": {
-       "global": true,
-       "in-subnet": false,
-       "out-of-pool": false
-   }
+       "reservations-global": true,
+       "reservations-in-subnet": false,
+       "reservations-out-of-pool": false,
+       ...
    }
 
 ``out-of-pool``:
@@ -4107,11 +4105,10 @@ The correspondence of old values are:
 
    "Dhcp6": {
 
-   "reservation-modes": {
-       "global": false,
-       "in-subnet": false,
-       "out-of-pool": true
-   }
+       "reservations-global": false,
+       "reservations-in-subnet": false,
+       "reservations-out-of-pool": true,
+       ...
    }
 
 ``all``:
@@ -4120,11 +4117,10 @@ The correspondence of old values are:
 
    "Dhcp6": {
 
-   "reservation-modes": {
-       "global": false,
-       "in-subnet": true,
-       "out-of-pool": true
-   }
+       "reservations-global": false,
+       "reservations-in-subnet": true,
+       "reservations-out-of-pool": true,
+       ...
    }
 
 To activate both ``global`` and ``all``, the following combination can be used:
@@ -4133,11 +4129,10 @@ To activate both ``global`` and ``all``, the following combination can be used:
 
    "Dhcp6": {
 
-   "reservation-modes": {
-       "global": true,
-       "in-subnet": true,
-       "out-of-pool": true
-   }
+       "reservations-global": true,
+       "reservations-in-subnet": true,
+       "reservations-out-of-pool": true,
+       ...
    }
 
 The parameter can be specified at global, subnet, and shared-network
@@ -4151,11 +4146,9 @@ An example configuration that disables reservation looks as follows:
        "subnet6": [
            {
            "subnet": "2001:db8:1::/64",
-           "reservation-modes": {
-               "global": false,
-               "in-subnet": false,
-               "out-of-pool": false
-           },
+           "reservations-global": false,
+           "reservations-in-subnet": false,
+           "reservations-out-of-pool": false,
            ...
            }
        ]
@@ -4168,12 +4161,9 @@ An example configuration using global reservations is shown below:
 
    "Dhcp6": {
 
-
-       "reservation-modes": {
-           "global": true,
-           "in-subnet": false,
-           "out-of-pool": false
-       },
+       "reservations-global": true,
+       "reservations-in-subnet": false,
+       "reservations-out-of-pool": false,
        "reservations": [
           {
            "duid": "00:03:00:01:11:22:33:44:55:66",
@@ -4294,15 +4284,15 @@ following can be used:
        "valid-lifetime": 600,
        "subnet4": [ {
            "subnet": "2001:db8:1::/64",
-           # It is deprecated by the "reservation-modes" map.
+           # It is deprecated by the "reservations-out-of-pool",
+           # reservations-in-subnet and reservations-global parameters.
            # "reservation-mode": "global",
-           # Reservation modes specifying server's mode of operation when it
-           # fetches host reservations.
-           "reservation-modes": {
-               "global": true,
-               "in-subnet": false,
-               "out-of-pool": false
-           },
+           # Specify if server should lookup global reservations.
+           "reservations-global": true,
+           # Specify if server should lookup in-subnet reservations.
+           "reservations-in-subnet": false,
+           # Specify if server should lookup out-of-pool reservations.
+           "reservations-out-of-pool": false,
            "pools": [ { "pool": "2001:db8:1::-2001:db8:1::100" } ]
        } ]
    }
@@ -4405,15 +4395,15 @@ following example:
             "hw-address": "aa:bb:cc:dd:ee:fe",
             "client-classes": [ "reserved_class" ]
         }],
-        # It is deprecated by the "reservation-modes" map.
+        # It is deprecated by the "reservations-out-of-pool",
+        # reservations-in-subnet and reservations-global parameters.
         # "reservation-mode": "global",
-        # Reservation modes specifying server's mode of operation when it
-        # fetches host reservations.
-        "reservation-modes": {
-            "global": true,
-            "in-subnet": false,
-            "out-of-pool": false
-        },
+        # Specify if server should lookup global reservations.
+        "reservations-global": true,
+        # Specify if server should lookup in-subnet reservations.
+        "reservations-in-subnet": false,
+        # Specify if server should lookup out-of-pool reservations.
+        "reservations-out-of-pool": false,
         "shared-networks": [{
             "subnet6": [
                 {
@@ -4446,8 +4436,8 @@ will be assigned an address from the subnet 2001:db8:2::/64. Clients having
 a reservation for the ``reserved_class`` will be assigned an address from
 the subnet 2001:db8:1::/64. The subnets must belong to the same shared network.
 In addition, the reservation for the client class must be specified at the
-global scope (global reservation) and the ``reservation-modes`` must
-set ``global`` to true.
+global scope (global reservation) and the ``reservations-global`` must be
+set to true.
 
 In the example above the ``client-class`` could also be specified at the
 subnet level rather than pool level yielding the same effect.
@@ -6739,7 +6729,11 @@ the global DHCPv6 options (``option-data``) are modified using
    +-----------------------------+----------------------------+-----------+-----------+-----------+------------+
    | reservation-mode            | yes                        | yes       | yes       | n/a       | n/a        |
    +-----------------------------+----------------------------+-----------+-----------+-----------+------------+
-   | reservation-modes           | yes                        | yes       | yes       | n/a       | n/a        |
+   | reservations-out-of-pool    | yes                        | yes       | yes       | n/a       | n/a        |
+   +-----------------------------+----------------------------+-----------+-----------+-----------+------------+
+   | reservations-in-subnet      | yes                        | yes       | yes       | n/a       | n/a        |
+   +-----------------------------+----------------------------+-----------+-----------+-----------+------------+
+   | reservations-global         | yes                        | yes       | yes       | n/a       | n/a        |
    +-----------------------------+----------------------------+-----------+-----------+-----------+------------+
    | t1-percent                  | yes                        | yes       | yes       | n/a       | n/a        |
    +-----------------------------+----------------------------+-----------+-----------+-----------+------------+
index 453c590f46d2919e2002f7b2be9e1f60ad767d62..e4421df6a5da532f269b8403586a92f230b008b4 100644 (file)
@@ -2655,15 +2655,15 @@ An example response could look as follows:
                    "ip-address": "0.0.0.0"
                },
                "renew-timer": 60,
-               # It is deprecated by the "reservation-modes" map.
+               # It is deprecated by the "reservations-out-of-pool",
+               # reservations-in-subnet and reservations-global parameters.
                # "reservation-mode": "all",
-               # Reservation modes specifying server's mode of operation when it
-               # fetches host reservations.
-               "reservation-modes": {
-                   "global": false,
-                   "in-subnet": true,
-                   "out-of-pool": true
-               },
+               # Specify if server should lookup global reservations.
+               "reservations-global": false,
+               # Specify if server should lookup in-subnet reservations.
+               "reservations-in-subnet": true,
+               # Specify if server should lookup out-of-pool reservations.
+               "reservations-out-of-pool": true,
                "subnet4": [
                    {
                        "subnet": "192.0.2.0/24",
index 9a5c6c14c173df886cb7e56f2e0b9c0b4209aa4f..3083980b5faeaa422f9015d86f98dd5c5346d89b 100644 (file)
@@ -136,8 +136,6 @@ ControlCharacterFill            [^"\\]|\\["\\/bfnrtu]
             return isc::dhcp::Dhcp4Parser::make_SUB_HOOKS_LIBRARY(driver.loc_);
         case Parser4Context::PARSER_DHCP_DDNS:
             return isc::dhcp::Dhcp4Parser::make_SUB_DHCP_DDNS(driver.loc_);
-        case Parser4Context::PARSER_RESERVATION_MODES:
-            return isc::dhcp::Dhcp4Parser::make_SUB_RESERVATION_MODES(driver.loc_);
         case Parser4Context::PARSER_CONFIG_CONTROL:
             return isc::dhcp::Dhcp4Parser::make_SUB_CONFIG_CONTROL(driver.loc_);
         }
@@ -950,14 +948,36 @@ ControlCharacterFill            [^"\\]|\\["\\/bfnrtu]
     }
 }
 
-\"reservation-modes\" {
+\"reservations-out-of-pool\" {
     switch(driver.ctx_) {
     case isc::dhcp::Parser4Context::DHCP4:
     case isc::dhcp::Parser4Context::SUBNET4:
     case isc::dhcp::Parser4Context::SHARED_NETWORK:
-        return isc::dhcp::Dhcp4Parser::make_RESERVATION_MODES(driver.loc_);
+        return isc::dhcp::Dhcp4Parser::make_RESERVATIONS_OUT_OF_POOL(driver.loc_);
     default:
-        return isc::dhcp::Dhcp4Parser::make_STRING("reservation-modes", driver.loc_);
+        return isc::dhcp::Dhcp4Parser::make_STRING("reservations-out-of-pool", driver.loc_);
+    }
+}
+
+\"reservations-in-subnet\" {
+    switch(driver.ctx_) {
+    case isc::dhcp::Parser4Context::DHCP4:
+    case isc::dhcp::Parser4Context::SUBNET4:
+    case isc::dhcp::Parser4Context::SHARED_NETWORK:
+        return isc::dhcp::Dhcp4Parser::make_RESERVATIONS_IN_SUBNET(driver.loc_);
+    default:
+        return isc::dhcp::Dhcp4Parser::make_STRING("reservations-in-subnet", driver.loc_);
+    }
+}
+
+\"reservations-global\" {
+    switch(driver.ctx_) {
+    case isc::dhcp::Parser4Context::DHCP4:
+    case isc::dhcp::Parser4Context::SUBNET4:
+    case isc::dhcp::Parser4Context::SHARED_NETWORK:
+        return isc::dhcp::Dhcp4Parser::make_RESERVATIONS_GLOBAL(driver.loc_);
+    default:
+        return isc::dhcp::Dhcp4Parser::make_STRING("reservations-global", driver.loc_);
     }
 }
 
@@ -993,7 +1013,6 @@ ControlCharacterFill            [^"\\]|\\["\\/bfnrtu]
 \"out-of-pool\" {
     switch(driver.ctx_) {
     case isc::dhcp::Parser4Context::RESERVATION_MODE:
-    case isc::dhcp::Parser4Context::RESERVATION_MODES:
         return isc::dhcp::Dhcp4Parser::make_OUT_OF_POOL(driver.loc_);
     default:
         return isc::dhcp::Dhcp4Parser::make_STRING("out-of-pool", driver.loc_);
@@ -1003,7 +1022,6 @@ ControlCharacterFill            [^"\\]|\\["\\/bfnrtu]
 \"global\" {
     switch(driver.ctx_) {
     case isc::dhcp::Parser4Context::RESERVATION_MODE:
-    case isc::dhcp::Parser4Context::RESERVATION_MODES:
         return isc::dhcp::Dhcp4Parser::make_GLOBAL(driver.loc_);
     default:
         return isc::dhcp::Dhcp4Parser::make_STRING("global", driver.loc_);
@@ -1019,15 +1037,6 @@ ControlCharacterFill            [^"\\]|\\["\\/bfnrtu]
     }
 }
 
-\"in-subnet\" {
-    switch(driver.ctx_) {
-    case isc::dhcp::Parser4Context::RESERVATION_MODES:
-        return isc::dhcp::Dhcp4Parser::make_IN_SUBNET(driver.loc_);
-    default:
-        return isc::dhcp::Dhcp4Parser::make_STRING("in-subnet", driver.loc_);
-    }
-}
-
 \"code\" {
     switch(driver.ctx_) {
     case isc::dhcp::Parser4Context::OPTION_DEF:
index cd6f897dc55e21c88d4b65975952161c811fc302..8b9624bfadaeb73cfc930c3d1f6a4d7d7b2596be 100644 (file)
@@ -152,10 +152,11 @@ using namespace std;
   INTERFACE "interface"
   ID "id"
   RESERVATION_MODE "reservation-mode"
-  RESERVATION_MODES "reservation-modes"
+  RESERVATIONS_OUT_OF_POOL "reservations-out-of-pool"
+  RESERVATIONS_IN_SUBNET "reservations-in-subnet"
+  RESERVATIONS_GLOBAL "reservations-global"
   DISABLED "disabled"
   OUT_OF_POOL "out-of-pool"
-  IN_SUBNET "in-subnet"
   GLOBAL "global"
   ALL "all"
 
@@ -255,7 +256,6 @@ using namespace std;
   SUB_OPTION_DATA
   SUB_HOOKS_LIBRARY
   SUB_DHCP_DDNS
-  SUB_RESERVATION_MODES
   SUB_CONFIG_CONTROL
 ;
 
@@ -294,7 +294,6 @@ start: TOPLEVEL_JSON { ctx.ctx_ = ctx.NO_KEYWORD; } sub_json
      | SUB_OPTION_DATA { ctx.ctx_ = ctx.OPTION_DATA; } sub_option_data
      | SUB_HOOKS_LIBRARY { ctx.ctx_ = ctx.HOOKS_LIBRARIES; } sub_hooks_library
      | SUB_DHCP_DDNS { ctx.ctx_ = ctx.DHCP_DDNS; } sub_dhcp_ddns
-     | SUB_RESERVATION_MODES { ctx.ctx_ = ctx.RESERVATION_MODES; } sub_reservation_modes
      | SUB_CONFIG_CONTROL { ctx.ctx_ = ctx.CONFIG_CONTROL; } sub_config_control
      ;
 
@@ -487,7 +486,9 @@ global_param: valid_lifetime
             | config_control
             | server_tag
             | reservation_mode
-            | reservation_modes
+            | reservations_out_of_pool
+            | reservations_in_subnet
+            | reservations_global
             | calculate_tee_times
             | t1_percent
             | t2_percent
@@ -1082,8 +1083,8 @@ host_reservation_identifiers: HOST_RESERVATION_IDENTIFIERS {
 };
 
 host_reservation_identifiers_list: host_reservation_identifier
-    | host_reservation_identifiers_list COMMA host_reservation_identifier
-    ;
+                                 | host_reservation_identifiers_list COMMA host_reservation_identifier
+                                 ;
 
 host_reservation_identifier: duid_id
                            | hw_address_id
@@ -1092,22 +1093,22 @@ host_reservation_identifier: duid_id
                            | flex_id
                            ;
 
-duid_id : DUID {
+duid_id: DUID {
     ElementPtr duid(new StringElement("duid", ctx.loc2pos(@1)));
     ctx.stack_.back()->add(duid);
 };
 
-hw_address_id : HW_ADDRESS {
+hw_address_id: HW_ADDRESS {
     ElementPtr hwaddr(new StringElement("hw-address", ctx.loc2pos(@1)));
     ctx.stack_.back()->add(hwaddr);
 };
 
-circuit_id : CIRCUIT_ID {
+circuit_id: CIRCUIT_ID {
     ElementPtr circuit(new StringElement("circuit-id", ctx.loc2pos(@1)));
     ctx.stack_.back()->add(circuit);
 };
 
-client_id : CLIENT_ID {
+client_id: CLIENT_ID {
     ElementPtr client(new StringElement("client-id", ctx.loc2pos(@1)));
     ctx.stack_.back()->add(client);
 };
@@ -1178,8 +1179,8 @@ hooks_libraries_list: %empty
                     ;
 
 not_empty_hooks_libraries_list: hooks_library
-    | not_empty_hooks_libraries_list COMMA hooks_library
-    ;
+                              | not_empty_hooks_libraries_list COMMA hooks_library
+                              ;
 
 hooks_library: LCURLY_BRACKET {
     ElementPtr m(new MapElement(ctx.loc2pos(@1)));
@@ -1373,7 +1374,9 @@ subnet4_param: valid_lifetime
              | require_client_classes
              | reservations
              | reservation_mode
-             | reservation_modes
+             | reservations_out_of_pool
+             | reservations_in_subnet
+             | reservations_global
              | relay
              | match_client_id
              | authoritative
@@ -1469,51 +1472,22 @@ require_client_classes: REQUIRE_CLIENT_CLASSES {
     ctx.leave();
 };
 
-reservation_modes: RESERVATION_MODES {
-    ctx.unique("reservation-modes", ctx.loc2pos(@1));
-    ElementPtr m(new MapElement(ctx.loc2pos(@1)));
-    ctx.stack_.back()->set("reservation-modes", m);
-    ctx.stack_.push_back(m);
-    ctx.enter(ctx.RESERVATION_MODES);
-} COLON LCURLY_BRACKET reservation_modes_params RCURLY_BRACKET {
-    ctx.stack_.pop_back();
-    ctx.leave();
-};
-
-sub_reservation_modes: LCURLY_BRACKET {
-    // Parse the reservation-modes map
-    ElementPtr m(new MapElement(ctx.loc2pos(@1)));
-    ctx.stack_.push_back(m);
-} reservation_modes_params RCURLY_BRACKET {
-    // No reservation_modes params are required
-    // parsing completed
-};
-
-reservation_modes_params: reservation_modes_param
-                        | reservation_modes_params COMMA reservation_modes_param
-                        ;
-
-reservation_modes_param: hr_global
-                       | hr_in_subnet
-                       | hr_out_of_pool
-                       ;
-
-hr_global: GLOBAL COLON BOOLEAN {
-    ctx.unique("global", ctx.loc2pos(@1));
+reservations_out_of_pool: RESERVATIONS_OUT_OF_POOL COLON BOOLEAN {
+    ctx.unique("reservations-out-of-pool", ctx.loc2pos(@1));
     ElementPtr b(new BoolElement($3, ctx.loc2pos(@3)));
-    ctx.stack_.back()->set("global", b);
+    ctx.stack_.back()->set("reservations-out-of-pool", b);
 };
 
-hr_in_subnet: IN_SUBNET COLON BOOLEAN {
-    ctx.unique("in-subnet", ctx.loc2pos(@1));
+reservations_in_subnet: RESERVATIONS_IN_SUBNET COLON BOOLEAN {
+    ctx.unique("reservations-in-subnet", ctx.loc2pos(@1));
     ElementPtr b(new BoolElement($3, ctx.loc2pos(@3)));
-    ctx.stack_.back()->set("in-subnet", b);
+    ctx.stack_.back()->set("reservations-in-subnet", b);
 };
 
-hr_out_of_pool: OUT_OF_POOL COLON BOOLEAN {
-    ctx.unique("out-of-pool", ctx.loc2pos(@1));
+reservations_global: RESERVATIONS_GLOBAL COLON BOOLEAN {
+    ctx.unique("reservations-global", ctx.loc2pos(@1));
     ElementPtr b(new BoolElement($3, ctx.loc2pos(@3)));
-    ctx.stack_.back()->set("out-of-pool", b);
+    ctx.stack_.back()->set("reservations-global", b);
 };
 
 reservation_mode: RESERVATION_MODE {
@@ -1584,7 +1558,9 @@ shared_network_param: name
                     | boot_file_name
                     | relay
                     | reservation_mode
-                    | reservation_modes
+                    | reservations_out_of_pool
+                    | reservations_in_subnet
+                    | reservations_global
                     | client_class
                     | require_client_classes
                     | valid_lifetime
@@ -1811,8 +1787,8 @@ option_data_params: %empty
 // Those parameters can either be a single parameter or
 // a list of parameters separated by comma.
 not_empty_option_data_params: option_data_param
-    | not_empty_option_data_params COMMA option_data_param
-    ;
+                            | not_empty_option_data_params COMMA option_data_param
+                            ;
 
 // Each single option-data parameter can be one of the following
 // expressions.
@@ -2017,8 +1993,8 @@ reservation_params: %empty
                   ;
 
 not_empty_reservation_params: reservation_param
-    | not_empty_reservation_params COMMA reservation_param
-    ;
+                            | not_empty_reservation_params COMMA reservation_param
+                            ;
 
 /// @todo probably need to add mac-address as well here
 reservation_param: duid
@@ -2201,8 +2177,8 @@ client_class_params: %empty
                    ;
 
 not_empty_client_class_params: client_class_param
-    | not_empty_client_class_params COMMA client_class_param
-    ;
+                             | not_empty_client_class_params COMMA client_class_param
+                             ;
 
 client_class_param: client_class_name
                   | client_class_test
index 519804b81144fa3f37297785007e718f46a61f47..c11a96953e88b1efdc12c75f60a78e5913141d54 100644 (file)
@@ -370,10 +370,24 @@ configureDhcp4Server(Dhcpv4Srv& server, isc::data::ConstElementPtr config_set,
         ConstElementPtr reservation_mode = mutable_cfg->get("reservation-mode");
         if (reservation_mode) {
             // log warning for deprecated option
-            reservation_mode = mutable_cfg->get("reservation-modes");
+            bool found = false;
+            reservation_mode = mutable_cfg->get("reservations-out-of-pool");
             if (reservation_mode) {
+                found = true;
+            }
+            reservation_mode = mutable_cfg->get("reservations-in-subnet");
+            if (reservation_mode) {
+                found = true;
+            }
+            reservation_mode = mutable_cfg->get("reservations-global");
+            if (reservation_mode) {
+                found = true;
+            }
+            if (found) {
                 isc_throw(DhcpConfigError, "invalid use of both 'reservation-mode'"
-                                           " and 'reservation-modes' parameters");
+                                           " and one of 'reservations-out-of-pool'"
+                                           " , 'reservations-in-subnet' or"
+                                           " 'reservations-global' parameters");
             }
         }
 
@@ -639,7 +653,9 @@ configureDhcp4Server(Dhcpv4Srv& server, isc::data::ConstElementPtr config_set,
                  (config_pair.first == "boot-file-name") ||
                  (config_pair.first == "server-tag") ||
                  (config_pair.first == "reservation-mode") ||
-                 (config_pair.first == "reservation-modes") ||
+                 (config_pair.first == "reservations-out-of-pool") ||
+                 (config_pair.first == "reservations-in-subnet") ||
+                 (config_pair.first == "reservations-global") ||
                  (config_pair.first == "calculate-tee-times") ||
                  (config_pair.first == "t1-percent") ||
                  (config_pair.first == "t2-percent") ||
index bc28c06114a879328d474e365ccc701cfbff9071..84f064e329ad54d9140cfbd4e4976627c183b37a 100644 (file)
@@ -5386,32 +5386,27 @@ TEST_F(Dhcp4ParserTest, hostReservationModesPerSubnet) {
         "\"subnet4\": [ { "
         "    \"pools\": [ { \"pool\": \"192.0.1.0/24\" } ],"
         "    \"subnet\": \"192.0.1.0/24\", "
-        "    \"reservation-modes\": {"
-        "        \"in-subnet\": true,"
-        "        \"out-of-pool\": true"
-        "     }"
+        "    \"reservations-out-of-pool\": true,"
+        "    \"reservations-in-subnet\": true"
         " },"
         " {"
         "    \"pools\": [ { \"pool\": \"192.0.2.0/24\" } ],"
         "    \"subnet\": \"192.0.2.0/24\", "
-        "    \"reservation-modes\": {"
-        "        \"out-of-pool\": true"
+        "    \"reservations-out-of-pool\": true"
         "     }"
         " },"
         " {"
         "    \"pools\": [ { \"pool\": \"192.0.3.0/24\" } ],"
         "    \"subnet\": \"192.0.3.0/24\", "
-        "    \"reservation-modes\": {"
-        "        \"in-subnet\": false,"
-        "        \"out-of-pool\": false,"
-        "        \"global\": false"
+        "    \"reservations-out-of-pool\": false,"
+        "    \"reservations-in-subnet\": false,"
+        "    \"reservations-global\": false"
         "     }"
         " },"
         " {"
         "    \"pools\": [ { \"pool\": \"192.0.4.0/24\" } ],"
         "    \"subnet\": \"192.0.4.0/24\", "
-        "    \"reservation-modes\": {"
-        "        \"global\": true"
+        "    \"reservations-global\": true"
         "     }"
         " },"
         " {"
@@ -5421,11 +5416,9 @@ TEST_F(Dhcp4ParserTest, hostReservationModesPerSubnet) {
         " {"
         "    \"pools\": [ { \"pool\": \"192.0.6.0/24\" } ],"
         "    \"subnet\": \"192.0.6.0/24\", "
-        "    \"reservation-modes\": {"
-        "        \"in-subnet\": true,"
-        "        \"out-of-pool\": true,"
-        "        \"global\": true"
-        "     }"
+        "    \"reservations-out-of-pool\": true,"
+        "    \"reservations-in-subnet\": true,"
+        "    \"reservations-global\": true"
         " } ],"
         "\"valid-lifetime\": 4000 }";
 
@@ -5553,16 +5546,12 @@ TEST_F(Dhcp4ParserTest, hostReservationModesGlobal) {
         "{ "
         "\"rebind-timer\": 2000, "
         "\"renew-timer\": 1000, "
-        "\"reservation-modes\": {"
-        "    \"out-of-pool\": true"
-        " },"
+        "\"reservations-out-of-pool\": true,"
         "\"subnet4\": [ { "
         "    \"pools\": [ { \"pool\": \"192.0.2.0/24\" } ],"
         "    \"subnet\": \"192.0.2.0/24\", "
-        "    \"reservation-modes\": {"
-        "        \"in-subnet\": true,"
-        "        \"out-of-pool\": true"
-        "     }"
+        "    \"reservations-out-of-pool\": true,"
+        "    \"reservations-in-subnet\": true"
         " },"
         " {"
         "    \"pools\": [ { \"pool\": \"192.0.3.0/24\" } ],"
@@ -6461,9 +6450,7 @@ TEST_F(Dhcp4ParserTest, sharedNetworksDerive) {
         "    \"relay\": {\n"
         "        \"ip-address\": \"5.6.7.8\"\n"
         "    },\n"
-        "    \"reservation-modes\": {"
-        "        \"out-of-pool\": true"
-        "     },\n"
+        "    \"reservations-out-of-pool\": true,"
         "    \"renew-timer\": 10,\n"
         "    \"rebind-timer\": 20,\n"
         "    \"valid-lifetime\": 40,\n"
@@ -6489,9 +6476,7 @@ TEST_F(Dhcp4ParserTest, sharedNetworksDerive) {
         "        \"relay\": {\n"
         "            \"ip-address\": \"55.66.77.88\"\n"
         "        },\n"
-        "        \"reservation-modes\": {"
-        "            \"global\": false"
-        "         }"
+        "        \"reservations-global\": false"
         "    }\n"
         "    ]\n"
         " },\n"
index ddef3d2023fb7694cb655b9499ae8c34acebf7c4..42273631f3bb434bffc492228e9273660abcea9c 100644 (file)
@@ -67,7 +67,7 @@ const char* CONFIGS[] = {
         "\"valid-lifetime\": 600,\n"
         "\"subnet4\": [ { \n"
         "    \"subnet\": \"10.0.0.0/24\", \n"
-        "    \"reservation-modes\": { \"global\": true },"
+        "    \"reservations-global\": true,\n"
         "    \"pools\": [ { \"pool\": \"10.0.0.10-10.0.0.100\" } ]\n"
         "} ]\n"
     "}\n"
@@ -102,7 +102,7 @@ const char* CONFIGS[] = {
         "        \"id\": 20,"
         "        \"pools\": [ { \"pool\": \"192.0.2.10-192.0.2.63\" } ],\n"
         "        \"interface\": \"eth1\",\n"
-        "        \"reservation-modes\": { \"global\": true },"
+        "        \"reservations-global\": true,\n"
         "        \"reservations\": [ \n"
         "        {\n"
         "           \"hw-address\": \"aa:bb:cc:dd:ee:ff\",\n"
@@ -129,7 +129,7 @@ const char* CONFIGS[] = {
         "        \"id\": 10,"
         "        \"pools\": [ { \"pool\": \"10.0.0.10-10.0.0.100\" } ],\n"
         "        \"interface\": \"eth0\",\n"
-        "        \"reservation-modes\": { \"out-of-pool\": true },"
+        "        \"reservations-out-of-pool\": true,\n"
         "        \"reservations\": [ \n"
         "        {\n"
         "           \"hw-address\": \"aa:bb:cc:dd:ee:ff\",\n"
@@ -157,7 +157,8 @@ const char* CONFIGS[] = {
         "        \"id\": 10,"
         "        \"pools\": [ { \"pool\": \"10.0.0.10-10.0.0.100\" } ],\n"
         "        \"interface\": \"eth0\",\n"
-        "        \"reservation-modes\": { \"in-subnet\": true, \"out-of-pool\": true },"
+        "        \"reservations-out-of-pool\": true,\n"
+        "        \"reservations-in-subnet\": true,\n"
         "        \"reservations\": [ \n"
         "        {\n"
         "           \"hw-address\": \"aa:bb:cc:dd:ee:ff\",\n"
@@ -183,7 +184,7 @@ const char* CONFIGS[] = {
         "     \"test\": \"not member('reserved_class')\""
         "}"
         "],\n"
-        "\"reservation-modes\": { \"global\": true },"
+        "\"reservations-global\": true,\n"
         "\"valid-lifetime\": 600,\n"
         "\"reservations\": [ \n"
         "{\n"
@@ -234,7 +235,7 @@ const char* CONFIGS[] = {
         "     \"test\": \"not member('reserved_class')\""
         "}"
         "],\n"
-        "\"reservation-modes\": { \"global\": true },"
+        "\"reservations-global\": true,\n"
         "\"valid-lifetime\": 600,\n"
         "\"reservations\": [ \n"
         "{\n"
index 6064436c6cae6f2dd3dceca1980cfa7001956017..8a2ec54a9dadaaa3497be9b08898934be99193ff 100644 (file)
@@ -138,8 +138,6 @@ ControlCharacterFill            [^"\\]|\\["\\/bfnrtu]
             return isc::dhcp::Dhcp6Parser::make_SUB_HOOKS_LIBRARY(driver.loc_);
         case Parser6Context::PARSER_DHCP_DDNS:
             return isc::dhcp::Dhcp6Parser::make_SUB_DHCP_DDNS(driver.loc_);
-        case Parser6Context::PARSER_RESERVATION_MODES:
-            return isc::dhcp::Dhcp6Parser::make_SUB_RESERVATION_MODES(driver.loc_);
         case Parser6Context::PARSER_CONFIG_CONTROL:
             return isc::dhcp::Dhcp6Parser::make_SUB_CONFIG_CONTROL(driver.loc_);
         }
@@ -430,7 +428,7 @@ ControlCharacterFill            [^"\\]|\\["\\/bfnrtu]
     return isc::dhcp::Dhcp6Parser::make_STRING(tmp, driver.loc_);
 }
 
-\"Dhcp6\"  {
+\"Dhcp6\" {
     switch(driver.ctx_) {
     case isc::dhcp::Parser6Context::CONFIG:
         return isc::dhcp::Dhcp6Parser::make_DHCP6(driver.loc_);
@@ -1260,14 +1258,36 @@ ControlCharacterFill            [^"\\]|\\["\\/bfnrtu]
     }
 }
 
-\"reservation-modes\" {
+\"reservations-out-of-pool\" {
     switch(driver.ctx_) {
     case isc::dhcp::Parser6Context::DHCP6:
     case isc::dhcp::Parser6Context::SUBNET6:
     case isc::dhcp::Parser6Context::SHARED_NETWORK:
-        return isc::dhcp::Dhcp6Parser::make_RESERVATION_MODES(driver.loc_);
+        return isc::dhcp::Dhcp6Parser::make_RESERVATIONS_OUT_OF_POOL(driver.loc_);
     default:
-        return isc::dhcp::Dhcp6Parser::make_STRING("reservation-modes", driver.loc_);
+        return isc::dhcp::Dhcp6Parser::make_STRING("reservations-out-of-pool", driver.loc_);
+    }
+}
+
+\"reservations-in-subnet\" {
+    switch(driver.ctx_) {
+    case isc::dhcp::Parser6Context::DHCP6:
+    case isc::dhcp::Parser6Context::SUBNET6:
+    case isc::dhcp::Parser6Context::SHARED_NETWORK:
+        return isc::dhcp::Dhcp6Parser::make_RESERVATIONS_IN_SUBNET(driver.loc_);
+    default:
+        return isc::dhcp::Dhcp6Parser::make_STRING("reservations-in-subnet", driver.loc_);
+    }
+}
+
+\"reservations-global\" {
+    switch(driver.ctx_) {
+    case isc::dhcp::Parser6Context::DHCP6:
+    case isc::dhcp::Parser6Context::SUBNET6:
+    case isc::dhcp::Parser6Context::SHARED_NETWORK:
+        return isc::dhcp::Dhcp6Parser::make_RESERVATIONS_GLOBAL(driver.loc_);
+    default:
+        return isc::dhcp::Dhcp6Parser::make_STRING("reservations-global", driver.loc_);
     }
 }
 
@@ -1303,7 +1323,6 @@ ControlCharacterFill            [^"\\]|\\["\\/bfnrtu]
 \"out-of-pool\" {
     switch(driver.ctx_) {
     case isc::dhcp::Parser6Context::RESERVATION_MODE:
-    case isc::dhcp::Parser6Context::RESERVATION_MODES:
         return isc::dhcp::Dhcp6Parser::make_OUT_OF_POOL(driver.loc_);
     default:
         return isc::dhcp::Dhcp6Parser::make_STRING("out-of-pool", driver.loc_);
@@ -1313,7 +1332,6 @@ ControlCharacterFill            [^"\\]|\\["\\/bfnrtu]
 \"global\" {
     switch(driver.ctx_) {
     case isc::dhcp::Parser6Context::RESERVATION_MODE:
-    case isc::dhcp::Parser6Context::RESERVATION_MODES:
         return isc::dhcp::Dhcp6Parser::make_GLOBAL(driver.loc_);
     default:
         return isc::dhcp::Dhcp6Parser::make_STRING("global", driver.loc_);
@@ -1329,15 +1347,6 @@ ControlCharacterFill            [^"\\]|\\["\\/bfnrtu]
     }
 }
 
-\"in-subnet\" {
-    switch(driver.ctx_) {
-    case isc::dhcp::Parser6Context::RESERVATION_MODES:
-        return isc::dhcp::Dhcp6Parser::make_IN_SUBNET(driver.loc_);
-    default:
-        return isc::dhcp::Dhcp6Parser::make_STRING("in-subnet", driver.loc_);
-    }
-}
-
 \"code\" {
     switch(driver.ctx_) {
     case isc::dhcp::Parser6Context::OPTION_DEF:
index b2abdc25c36debd7d73a58f95b1fc8c5003b1a22..b99ce9a4d92727c9ab5e3679d0568d77d427646b 100644 (file)
@@ -145,10 +145,11 @@ using namespace std;
   ID "id"
   RAPID_COMMIT "rapid-commit"
   RESERVATION_MODE "reservation-mode"
-  RESERVATION_MODES "reservation-modes"
+  RESERVATIONS_OUT_OF_POOL "reservations-out-of-pool"
+  RESERVATIONS_IN_SUBNET "reservations-in-subnet"
+  RESERVATIONS_GLOBAL "reservations-global"
   DISABLED "disabled"
   OUT_OF_POOL "out-of-pool"
-  IN_SUBNET "in-subnet"
   GLOBAL "global"
   ALL "all"
 
@@ -263,7 +264,6 @@ using namespace std;
   SUB_OPTION_DATA
   SUB_HOOKS_LIBRARY
   SUB_DHCP_DDNS
-  SUB_RESERVATION_MODES
   SUB_CONFIG_CONTROL
 ;
 
@@ -302,7 +302,6 @@ start: TOPLEVEL_JSON { ctx.ctx_ = ctx.NO_KEYWORD; } sub_json
      | SUB_OPTION_DATA { ctx.ctx_ = ctx.OPTION_DATA; } sub_option_data
      | SUB_HOOKS_LIBRARY { ctx.ctx_ = ctx.HOOKS_LIBRARIES; } sub_hooks_library
      | SUB_DHCP_DDNS { ctx.ctx_ = ctx.DHCP_DDNS; } sub_dhcp_ddns
-     | SUB_RESERVATION_MODES { ctx.ctx_ = ctx.RESERVATION_MODES; } sub_reservation_modes
      | SUB_CONFIG_CONTROL { ctx.ctx_ = ctx.CONFIG_CONTROL; } sub_config_control
      ;
 
@@ -496,7 +495,9 @@ global_param: data_directory
             | config_control
             | server_tag
             | reservation_mode
-            | reservation_modes
+            | reservations_out_of_pool
+            | reservations_in_subnet
+            | reservations_global
             | calculate_tee_times
             | t1_percent
             | t2_percent
@@ -1099,8 +1100,8 @@ host_reservation_identifiers: HOST_RESERVATION_IDENTIFIERS {
 };
 
 host_reservation_identifiers_list: host_reservation_identifier
-    | host_reservation_identifiers_list COMMA host_reservation_identifier
-    ;
+                                 | host_reservation_identifiers_list COMMA host_reservation_identifier
+                                 ;
 
 host_reservation_identifier: duid_id
                            | hw_address_id
@@ -1191,8 +1192,8 @@ hooks_libraries_list: %empty
                     ;
 
 not_empty_hooks_libraries_list: hooks_library
-    | not_empty_hooks_libraries_list COMMA hooks_library
-    ;
+                              | not_empty_hooks_libraries_list COMMA hooks_library
+                              ;
 
 hooks_library: LCURLY_BRACKET {
     ElementPtr m(new MapElement(ctx.loc2pos(@1)));
@@ -1392,7 +1393,9 @@ subnet6_param: preferred_lifetime
              | require_client_classes
              | reservations
              | reservation_mode
-             | reservation_modes
+             | reservations_out_of_pool
+             | reservations_in_subnet
+             | reservations_global
              | relay
              | user_context
              | comment
@@ -1462,6 +1465,24 @@ require_client_classes: REQUIRE_CLIENT_CLASSES {
     ctx.leave();
 };
 
+reservations_out_of_pool: RESERVATIONS_OUT_OF_POOL COLON BOOLEAN {
+    ctx.unique("reservations-out-of-pool", ctx.loc2pos(@1));
+    ElementPtr b(new BoolElement($3, ctx.loc2pos(@3)));
+    ctx.stack_.back()->set("reservations-out-of-pool", b);
+};
+
+reservations_in_subnet: RESERVATIONS_IN_SUBNET COLON BOOLEAN {
+    ctx.unique("reservations-in-subnet", ctx.loc2pos(@1));
+    ElementPtr b(new BoolElement($3, ctx.loc2pos(@3)));
+    ctx.stack_.back()->set("reservations-in-subnet", b);
+};
+
+reservations_global: RESERVATIONS_GLOBAL COLON BOOLEAN {
+    ctx.unique("reservations-global", ctx.loc2pos(@1));
+    ElementPtr b(new BoolElement($3, ctx.loc2pos(@3)));
+    ctx.stack_.back()->set("reservations-global", b);
+};
+
 reservation_mode: RESERVATION_MODE {
     ctx.unique("reservation-mode", ctx.loc2pos(@1));
     ctx.enter(ctx.RESERVATION_MODE);
@@ -1476,53 +1497,6 @@ hr_mode: DISABLED { $$ = ElementPtr(new StringElement("disabled", ctx.loc2pos(@1
        | ALL { $$ = ElementPtr(new StringElement("all", ctx.loc2pos(@1))); }
        ;
 
-reservation_modes: RESERVATION_MODES {
-    ctx.unique("reservation-modes", ctx.loc2pos(@1));
-    ElementPtr m(new MapElement(ctx.loc2pos(@1)));
-    ctx.stack_.back()->set("reservation-modes", m);
-    ctx.stack_.push_back(m);
-    ctx.enter(ctx.RESERVATION_MODES);
-} COLON LCURLY_BRACKET reservation_modes_params RCURLY_BRACKET {
-    ctx.stack_.pop_back();
-    ctx.leave();
-};
-
-sub_reservation_modes: LCURLY_BRACKET {
-    // Parse the reservation-modes map
-    ElementPtr m(new MapElement(ctx.loc2pos(@1)));
-    ctx.stack_.push_back(m);
-} reservation_modes_params RCURLY_BRACKET {
-    // No reservation_modes params are required
-    // parsing completed
-};
-
-reservation_modes_params: reservation_modes_param
-                        | reservation_modes_params COMMA reservation_modes_param
-                        ;
-
-reservation_modes_param: hr_global
-                       | hr_in_subnet
-                       | hr_out_of_pool
-                       ;
-
-hr_global: GLOBAL COLON BOOLEAN {
-    ctx.unique("global", ctx.loc2pos(@1));
-    ElementPtr b(new BoolElement($3, ctx.loc2pos(@3)));
-    ctx.stack_.back()->set("global", b);
-};
-
-hr_in_subnet: IN_SUBNET COLON BOOLEAN {
-    ctx.unique("in-subnet", ctx.loc2pos(@1));
-    ElementPtr b(new BoolElement($3, ctx.loc2pos(@3)));
-    ctx.stack_.back()->set("in-subnet", b);
-};
-
-hr_out_of_pool: OUT_OF_POOL COLON BOOLEAN {
-    ctx.unique("out-of-pool", ctx.loc2pos(@1));
-    ElementPtr b(new BoolElement($3, ctx.loc2pos(@3)));
-    ctx.stack_.back()->set("out-of-pool", b);
-};
-
 id: ID COLON INTEGER {
     ctx.unique("id", ctx.loc2pos(@1));
     ElementPtr id(new IntElement($3, ctx.loc2pos(@3)));
@@ -1550,8 +1524,8 @@ shared_networks: SHARED_NETWORKS {
 
 // This allows 0 or more shared network definitions.
 shared_networks_content: %empty
-                    | shared_networks_list
-                    ;
+                       | shared_networks_list
+                       ;
 
 // This allows 1 or more shared network definitions.
 shared_networks_list: shared_network
@@ -1579,7 +1553,9 @@ shared_network_param: name
                     | option_data_list
                     | relay
                     | reservation_mode
-                    | reservation_modes
+                    | reservations_out_of_pool
+                    | reservations_in_subnet
+                    | reservations_global
                     | client_class
                     | require_client_classes
                     | preferred_lifetime
@@ -1810,8 +1786,8 @@ option_data_params: %empty
 // Those parameters can either be a single parameter or
 // a list of parameters separated by comma.
 not_empty_option_data_params: option_data_param
-    | not_empty_option_data_params COMMA option_data_param
-    ;
+                            | not_empty_option_data_params COMMA option_data_param
+                            ;
 
 // Each single option-data parameter can be one of the following
 // expressions.
@@ -2117,8 +2093,8 @@ reservation_params: %empty
                   ;
 
 not_empty_reservation_params: reservation_param
-    | not_empty_reservation_params COMMA reservation_param
-    ;
+                            | not_empty_reservation_params COMMA reservation_param
+                            ;
 
 /// @todo probably need to add mac-address as well here
 reservation_param: duid
@@ -2263,8 +2239,8 @@ client_class_params: %empty
                    ;
 
 not_empty_client_class_params: client_class_param
-    | not_empty_client_class_params COMMA client_class_param
-    ;
+                             | not_empty_client_class_params COMMA client_class_param
+                             ;
 
 client_class_param: client_class_name
                   | client_class_test
index a0293e2333101b2d16b4d163f8e5f726f0c0072e..641a8b614541df2f667ff26396491af8ef97858c 100644 (file)
@@ -471,10 +471,24 @@ configureDhcp6Server(Dhcpv6Srv& server, isc::data::ConstElementPtr config_set,
         ConstElementPtr reservation_mode = mutable_cfg->get("reservation-mode");
         if (reservation_mode) {
             // log warning for deprecated option
-            reservation_mode = mutable_cfg->get("reservation-modes");
+            bool found = false;
+            reservation_mode = mutable_cfg->get("reservations-out-of-pool");
             if (reservation_mode) {
+                found = true;
+            }
+            reservation_mode = mutable_cfg->get("reservations-in-subnet");
+            if (reservation_mode) {
+                found = true;
+            }
+            reservation_mode = mutable_cfg->get("reservations-global");
+            if (reservation_mode) {
+                found = true;
+            }
+            if (found) {
                 isc_throw(DhcpConfigError, "invalid use of both 'reservation-mode'"
-                                           " and 'reservation-modes' parameters");
+                                           " and one of 'reservations-out-of-pool'"
+                                           " , 'reservations-in-subnet' or"
+                                           " 'reservations-global' parameters");
             }
         }
 
@@ -771,7 +785,9 @@ configureDhcp6Server(Dhcpv6Srv& server, isc::data::ConstElementPtr config_set,
                  (config_pair.first == "dhcp4o6-port") ||
                  (config_pair.first == "server-tag") ||
                  (config_pair.first == "reservation-mode") ||
-                 (config_pair.first == "reservation-modes") ||
+                 (config_pair.first == "reservations-out-of-pool") ||
+                 (config_pair.first == "reservations-in-subnet") ||
+                 (config_pair.first == "reservations-global") ||
                  (config_pair.first == "calculate-tee-times") ||
                  (config_pair.first == "t1-percent") ||
                  (config_pair.first == "t2-percent") ||
index 23ae8b543626724e4115206a6f53ac8d81b4d0fb..958c9fc0378f1650cdf2750a342a9b0ea9549f1b 100644 (file)
@@ -5759,33 +5759,26 @@ TEST_F(Dhcp6ParserTest, hostReservationModesPerSubnet) {
         "\"subnet6\": [ { "
         "    \"pools\": [ { \"pool\": \"2001:db8:1::/64\" } ],"
         "    \"subnet\": \"2001:db8:1::/48\", "
-        "    \"reservation-modes\": {"
-        "        \"in-subnet\": true,"
-        "        \"out-of-pool\": true"
-        "     }"
+        "    \"reservations-out-of-pool\": true,"
+        "    \"reservations-in-subnet\": true"
         " },"
         " {"
         "    \"pools\": [ { \"pool\": \"2001:db8:2::/64\" } ],"
         "    \"subnet\": \"2001:db8:2::/48\", "
-        "    \"reservation-modes\": {"
-        "        \"out-of-pool\": true"
+        "    \"reservations-out-of-pool\": true"
         "     }"
         " },"
         " {"
         "    \"pools\": [ { \"pool\": \"2001:db8:3::/64\" } ],"
         "    \"subnet\": \"2001:db8:3::/48\", "
-        "    \"reservation-modes\": {"
-        "        \"in-subnet\": false,"
-        "        \"out-of-pool\": false,"
-        "        \"global\": false"
-        "     }"
+        "    \"reservations-out-of-pool\": false,"
+        "    \"reservations-in-subnet\": false,"
+        "    \"reservations-global\": false"
         " },"
         " {"
         "    \"pools\": [ { \"pool\": \"2001:db8:4::/64\" } ],"
         "    \"subnet\": \"2001:db8:4::/48\", "
-        "    \"reservation-modes\": {"
-        "        \"global\": true"
-        "     }"
+        "    \"reservations-global\": true"
         " },"
         " {"
         "    \"pools\": [ { \"pool\": \"2001:db8:5::/64\" } ],"
@@ -5794,11 +5787,9 @@ TEST_F(Dhcp6ParserTest, hostReservationModesPerSubnet) {
         " {"
         "    \"pools\": [ { \"pool\": \"2001:db8:6::/64\" } ],"
         "    \"subnet\": \"2001:db8:6::/48\", "
-        "    \"reservation-modes\": {"
-        "        \"in-subnet\": true,"
-        "        \"out-of-pool\": true,"
-        "        \"global\": true"
-        "     }"
+        "    \"reservations-out-of-pool\": true,"
+        "    \"reservations-in-subnet\": true,"
+        "    \"reservations-global\": true"
         " } ],"
         "\"valid-lifetime\": 4000 }";
 
@@ -5924,16 +5915,12 @@ TEST_F(Dhcp6ParserTest, hostReservationModesGlobal) {
         "\"preferred-lifetime\": 3000,"
         "\"rebind-timer\": 2000, "
         "\"renew-timer\": 1000, "
-        "\"reservation-modes\": {"
-        "    \"out-of-pool\": true"
-        " },"
+        "\"reservations-out-of-pool\": true,"
         "\"subnet6\": [ { "
         "    \"pools\": [ { \"pool\": \"2001:db8:1::/64\" } ],"
         "    \"subnet\": \"2001:db8:1::/48\", "
-        "    \"reservation-modes\": {"
-        "        \"in-subnet\": true,"
-        "        \"out-of-pool\": true"
-        "     }"
+        "    \"reservations-out-of-pool\": true,"
+        "    \"reservations-in-subnet\": true"
         " },"
         " {"
         "    \"pools\": [ { \"pool\": \"2001:db8:2::/64\" } ],"
@@ -6891,9 +6878,7 @@ TEST_F(Dhcp6ParserTest, sharedNetworksDerive) {
         "        \"ip-address\": \"1111::1\"\n"
         "    },\n"
         "    \"rapid-commit\": true,\n"
-        "    \"reservation-modes\": {"
-        "        \"global\": false"
-        "     },\n"
+        "    \"reservations-global\": false,"
         "    \"subnet6\": [\n"
         "    { \n"
         "        \"subnet\": \"2001:db1::/48\",\n"
@@ -6915,9 +6900,7 @@ TEST_F(Dhcp6ParserTest, sharedNetworksDerive) {
         "        \"max-valid-lifetime\": 500, \n"
         "        \"interface-id\": \"twotwo\",\n"
         "        \"rapid-commit\": true,\n"
-        "        \"reservation-modes\": {"
-        "            \"out-of-pool\": true"
-        "         }"
+        "        \"reservations-out-of-pool\": true"
         "    }\n"
         "    ]\n"
         " },\n"
index c17525620d5776cacc7399e7a2f1dfd731cfb73d..4dd97beb4039c59417df36153eaef83058c71ac5 100644 (file)
@@ -353,7 +353,7 @@ const char* CONFIGS[] = {
         "    \"subnet\": \"2001:db8:1::/48\",  \n"
         "    \"pools\": [ { \"pool\": \"2001:db8:1::/64\" } ], \n"
         "    \"interface\" : \"eth0\", \n"
-        "    \"reservation-modes\": { \"global\": true } \n"
+        "    \"reservations-global\": true\n"
         " },"
         " {  \n"
         "    \"subnet\": \"2001:db8:2::/48\",  \n"
@@ -394,7 +394,7 @@ const char* CONFIGS[] = {
         " {  \n"
         "    \"subnet\": \"2001:db8:1::/48\",  \n"
         "    \"interface\" : \"eth0\", \n"
-        "    \"reservation-modes\": { \"global\": true },"
+        "    \"reservations-global\": true,\n"
         "    \"pd-pools\": [ \n"
         "    { \n"
         "       \"prefix\": \"3000::\", \n"
@@ -435,7 +435,7 @@ const char* CONFIGS[] = {
         "     \"test\": \"not member('reserved_class')\""
         "}"
         "],\n"
-        "\"reservation-modes\": { \"global\": true },"
+        "\"reservations-global\": true,\n"
         "\"valid-lifetime\": 4000,\n"
         "\"reservations\": [ \n"
         "{\n"
@@ -487,7 +487,7 @@ const char* CONFIGS[] = {
         "     \"test\": \"not member('reserved_class')\""
         "}"
         "],\n"
-        "\"reservation-modes\": { \"global\": true },"
+        "\"reservations-global\": true,\n"
         "\"valid-lifetime\": 4000,\n"
         "\"reservations\": [ \n"
         "{\n"
index 8bc88167617a27f60a85af00718e41be961b12ca..b96a2f7d38eeb94d841525d3f1c903061198927a 100644 (file)
                 // specific options.
                 //
                 // When using reservations, it is useful to configure
-                // reservation-modes (subnet specific parameter) and
+                // reservations-out-of-pool, reservations-in-subnet,
+                // reservations-global (subnet specific parameters) and
                 // host-reservation-identifiers (global parameter).
                 {
                     "client-id": "01:12:23:34:45:56:67",
index bb3c822f2458fc956ccbf0fc8bd2f0ccbe390f2b..de2d30818929a77b9c688541e6cdcff2b08f28b1 100644 (file)
@@ -224,26 +224,6 @@ size_t SimpleParser::setDefaults(ElementPtr scope,
             x.reset(new DoubleElement(dbl_value, pos));
             break;
         }
-        case Element::map: {
-            auto data = Element::fromJSON(def_value.value_);
-            if (data->getType() != Element::map) {
-                isc_throw(BadValue,
-                          "Internal error. Incorrect map value type for "
-                          << def_value.name_ << " : " << def_value.value_);
-            }
-            x = data;
-            break;
-        }
-        case Element::list: {
-            auto data = Element::fromJSON(def_value.value_);
-            if (data->getType() != Element::list) {
-                isc_throw(BadValue,
-                          "Internal error. Incorrect list value type for "
-                          << def_value.name_ << " : " << def_value.value_);
-            }
-            x = data;
-            break;
-        }
         default:
             // No default values for null, list or map
             isc_throw(DhcpConfigError,
index 01aceb5d17b9309a366f2aa013464461d015d5ba..b7ba2ba0cd24cd90ddba0510f9f9847d1d19da9c 100644 (file)
@@ -216,24 +216,21 @@ Network::toElement() const {
         if (hrmode & Network::HR_OUT_OF_POOL) {
             hr_out_of_pool = true;
         }
-        ElementPtr reservation_modes = Element::createMap();
         if (hrmode == Network::HR_DISABLED) {
-            reservation_modes->set("global", Element::create(false));
-            reservation_modes->set("in-subnet", Element::create(false));
-            reservation_modes->set("out-of-pool", Element::create(false));
+            map->set("reservations-global", Element::create(false));
+            map->set("reservations-in-subnet", Element::create(false));
+            map->set("reservations-out-of-pool", Element::create(false));
         } else {
             if (hr_global) {
-                reservation_modes->set("global", Element::create(true));
+                map->set("reservations-global", Element::create(true));
             }
             if (hr_in_subnet) {
-                reservation_modes->set("in-subnet", Element::create(true));
+                map->set("reservations-in-subnet", Element::create(true));
             }
             if (hr_out_of_pool) {
-                reservation_modes->set("out-of-pool", Element::create(true));
+                map->set("reservations-out-of-pool", Element::create(true));
             }
         }
-
-        map->set("reservation-modes", reservation_modes);
     }
 
     // Set options
index 3990522addae5715274edac2b553e4997322e43c..857bab6c91c0c91061c0b56506a897c6e3d6346e 100644 (file)
@@ -155,33 +155,30 @@ public:
 
     /// @brief Specifies allowed host reservation mode.
     ///
-    typedef enum : uint8_t {
-
-        /// None - host reservation is disabled. No reservation types
-        /// are allowed.
-        HR_DISABLED = 0,
-
-        /// Only out-of-pool reservations is allowed. This mode
-        /// allows AllocEngine to skip reservation checks when
-        /// dealing with with addresses that are in pool.
-        /// When HR_IN_SUBNET is set, this is always enabled as well.
-        HR_OUT_OF_POOL = 1 << 0,
-
-        /// The in-pool reservations is allowed. This mode actually
-        /// behaves as if out-of-pool reservations are active as well.
-        HR_IN_SUBNET = 1 << 1,
-
-        /// Only global reservations are allowed. This mode
-        /// instructs AllocEngine to only look at global reservations.
-        HR_GLOBAL = 1 << 2,
-
-        /// Both out-of-pool and in-pool reservations are allowed. This is the
-        /// most flexible mode, where sysadmin have biggest liberty. However,
-        /// there is a non-trivial performance penalty for it, as the
-        /// AllocEngine code has to check whether there are reservations, even
-        /// when dealing with reservations from within the dynamic pools.
-        HR_ALL = HR_IN_SUBNET | HR_OUT_OF_POOL
-    } HRModeFlag;
+    /// None - host reservation is disabled. No reservation types
+    /// are allowed.
+    const uint8_t HR_DISABLED = 0;
+
+    /// Only out-of-pool reservations is allowed. This mode
+    /// allows AllocEngine to skip reservation checks when
+    /// dealing with with addresses that are in pool.
+    /// When HR_IN_SUBNET is set, this is always enabled as well.
+    const uint8_t HR_OUT_OF_POOL = 1 << 0;
+
+    /// The in-pool reservations is allowed. This mode actually
+    /// behaves as if out-of-pool reservations are active as well.
+    const uint8_t HR_IN_SUBNET = 1 << 1;
+
+    /// Only global reservations are allowed. This mode
+    /// instructs AllocEngine to only look at global reservations.
+    const uint8_t HR_GLOBAL = 1 << 2;
+
+    /// Both out-of-pool and in-pool reservations are allowed. This is the
+    /// most flexible mode, where sysadmin have biggest liberty. However,
+    /// there is a non-trivial performance penalty for it, as the
+    /// AllocEngine code has to check whether there are reservations, even
+    /// when dealing with reservations from within the dynamic pools.
+    const uint8_t HR_ALL = HR_IN_SUBNET | HR_OUT_OF_POOL;
 
     /// @brief Bitset used to store @ref HRModeFlag flags.
     typedef uint8_t HRMode;
@@ -450,7 +447,7 @@ public:
                 uint8_t flags = 0;
                 util::Optional<bool> hr_mode_global;
                 hr_mode_global = getGlobalProperty(hr_mode_global,
-                                                   "reservation-modes.global");
+                                                   "reservations-global");
                 if (!hr_mode_global.unspecified()) {
                     if (hr_mode_global.get()) {
                         flags |= Network::HR_GLOBAL;
@@ -459,7 +456,7 @@ public:
                 }
                 util::Optional<bool> hr_mode_in_subnet;
                 hr_mode_in_subnet = getGlobalProperty(hr_mode_in_subnet,
-                                                      "reservation-modes.in-subnet");
+                                                      "reservations-in-subnet");
                 if (!hr_mode_in_subnet.unspecified()) {
                     if (hr_mode_in_subnet.get()) {
                         flags |= Network::HR_IN_SUBNET;
@@ -468,7 +465,7 @@ public:
                 }
                 util::Optional<bool> hr_mode_out_of_pool;
                 hr_mode_out_of_pool = getGlobalProperty(hr_mode_out_of_pool,
-                                                        "reservation-modes.out-of-pool");
+                                                        "reservations-out-of-pool");
                 if (!hr_mode_out_of_pool.unspecified()) {
                     if (hr_mode_out_of_pool.get()) {
                         flags |= Network::HR_OUT_OF_POOL;
@@ -849,39 +846,14 @@ protected:
     template<typename ReturnType>
     ReturnType getGlobalProperty(ReturnType property,
                                  const std::string& global_name) const {
-        std::string member_name;
-        std::string search_name = global_name;
-        auto found = global_name.find('.');
-        if (found != std::string::npos) {
-            if (std::count(global_name.begin(), global_name.end(), '.') > 1) {
-                isc_throw(BadValue, "more than one level of indirection found in: "
-                          << global_name);
-            }
-            member_name = global_name.substr(found + 1, global_name.length() - found - 1);
-            search_name = global_name.substr(0, found);
-        }
-        if (!search_name.empty() && fetch_globals_fn_) {
+        if (!global_name.empty() && fetch_globals_fn_) {
             data::ConstElementPtr globals = fetch_globals_fn_();
             if (globals && (globals->getType() == data::Element::map)) {
-                data::ConstElementPtr global_param = globals->get(search_name);
+                data::ConstElementPtr global_param = globals->get(global_name);
                 if (global_param) {
-                    if (!member_name.empty()) {
-                        if (global_param->getType() != data::Element::map) {
-                            isc_throw(BadValue, "the parameter: " << global_name
-                                                 << " must be a map");
-                        }
-                        auto member_element = global_param->get(member_name);
-                        if (member_element) {
-                            // If there is a global parameter with the specified
-                            // member, convert the member to the optional value
-                            // of the given type and return.
-                            return (data::ElementValue<typename ReturnType::ValueType>()(member_element));
-                        }
-                    } else {
-                        // If there is a global parameter, convert it to the
-                        // optional value of the given type and return.
-                        return (data::ElementValue<typename ReturnType::ValueType>()(global_param));
-                    }
+                    // If there is a global parameter, convert it to the
+                    // optional value of the given type and return.
+                    return (data::ElementValue<typename ReturnType::ValueType>()(global_param));
                 }
             }
         }
index 316cd2bbe2d2d267d46a277bc2f656279036a287..eb4b0e70205aff0d52549323b43f32323d370c6b 100644 (file)
@@ -202,9 +202,21 @@ void
 BaseNetworkParser::parseHostReservationMode(const data::ConstElementPtr& network_data,
                                             NetworkPtr& network) {
     if (network_data->contains("reservation-mode")) {
-        if (network_data->contains("reservation-modes")) {
+        bool found = false;
+        if (network_data->contains("reservations-out-of-pool")) {
+            found = true
+        }
+        if (network_data->contains("reservations-in-subnet")) {
+            found = true
+        }
+        if (network_data->contains("reservations-global")) {
+            found = true
+        }
+        if (found)
             isc_throw(DhcpConfigError, "invalid use of both 'reservation-mode'"
-                                       " and 'reservation-modes' parameters");
+                                       " and one of 'reservations-out-of-pool'"
+                                       " , 'reservations-in-subnet' or"
+                                       " 'reservations-global' parameters");
         }
         try {
             std::string hr_mode = getString(network_data, "reservation-mode");
@@ -221,19 +233,28 @@ void
 BaseNetworkParser::parseHostReservationModes(const data::ConstElementPtr& network_data,
                                              NetworkPtr& network) {
     if (network_data->contains("reservation-modes")) {
-        if (network_data->contains("reservation-mode")) {
+        bool found = false;
+        if (network_data->contains("reservations-out-of-pool")) {
+            found = true
+        }
+        if (network_data->contains("reservations-in-subnet")) {
+            found = true
+        }
+        if (network_data->contains("reservations-global")) {
+            found = true
+        }
+        if (found)
             isc_throw(DhcpConfigError, "invalid use of both 'reservation-mode'"
-                                       " and 'reservation-modes' parameters");
+                                       " and one of 'reservations-out-of-pool'"
+                                       " , 'reservations-in-subnet' or"
+                                       " 'reservations-global' parameters");
         }
         try {
-            auto reservation_modes = network_data->get("reservation-modes");
             HostReservationModesParser parser;
-            Network::HRMode flags = parser.parse(reservation_modes);
+            Network::HRMode flags = parser.parse(network_data);
             network->setHostReservationMode(flags);
         } catch (const BadValue& ex) {
-            isc_throw(DhcpConfigError, "invalid reservation-modes parameter: "
-                      << ex.what() << " (" << getPosition("reservation-modes",
-                                                          network_data) << ")");
+            isc_throw(DhcpConfigError, "invalid parameter: " << ex.what());
         }
     }
 }
index 6044e3059f693afb03b4d83b0ad27a7068cd48bb..2ce25deaefd691f27da1226c2b272323f5129c73 100644 (file)
@@ -859,7 +859,7 @@ Subnet4ConfigParser::initSubnet(data::ConstElementPtr params,
         }
     }
 
-    // reservation-modes
+    // reservation modes
     parseHostReservationModes(params, network);
 
     // Let's set host reservation mode. If not specified, the default value of
@@ -1334,7 +1334,7 @@ Subnet6ConfigParser::initSubnet(data::ConstElementPtr params,
         subnet6->setIface(iface);
     }
 
-    // reservation-modes
+    // reservation modes
     parseHostReservationModes(params, network);
 
     // Let's set host reservation mode. If not specified, the default value of
index cf14ff407fec4a3e1a28cb09006d1051b573ed96..36c3aa532d764c6240e857bb006bb232c37fd297 100644 (file)
@@ -20,16 +20,16 @@ namespace isc {
 namespace dhcp {
 
 Network::HRMode
-HostReservationModesParser::parse(const ConstElementPtr& control_elem) {
-    if (control_elem->getType() != Element::map) {
-        isc_throw(DhcpConfigError, "reservation-modes must be a map");
+HostReservationModesParser::parse(const ConstElementPtr& config_elem) {
+    if (config_elem->getType() != Element::map) {
+        isc_throw(DhcpConfigError, "configuration must be a map");
     }
 
     ConstElementPtr elem;
     uint8_t flags = 0;
 
     try {
-        elem  = control_elem->get("global");
+        elem  = config_elem->get("reservations-global");
         if (elem) {
             bool value = elem->boolValue();
             if (value) {
@@ -37,7 +37,7 @@ HostReservationModesParser::parse(const ConstElementPtr& control_elem) {
             }
         }
 
-        elem  = control_elem->get("in-subnet");
+        elem  = config_elem->get("reservations-in-subnet");
         if (elem) {
             bool value = elem->boolValue();
             if (value) {
@@ -45,7 +45,7 @@ HostReservationModesParser::parse(const ConstElementPtr& control_elem) {
             }
         }
 
-        elem  = control_elem->get("out-of-pool");
+        elem  = config_elem->get("reservations-out-of-pool");
         if (elem) {
             bool value = elem->boolValue();
             if (value) {
index 0bc95ba69a343e88c3a3ba099942b709ce86867a..3248ede01f3ba60dcc27efa49633a940d371faf2 100644 (file)
@@ -185,7 +185,7 @@ SharedNetwork4Parser::parse(const data::ConstElementPtr& shared_network_data) {
             }
         }
 
-        // reservation-modes
+        // reservation modes
         parseHostReservationModes(shared_network_data, network);
 
         // reservation-mode
@@ -354,7 +354,7 @@ SharedNetwork6Parser::parse(const data::ConstElementPtr& shared_network_data) {
             }
         }
 
-        // reservation-modes
+        // reservation modes
         parseHostReservationModes(shared_network_data, network);
 
         // reservation-mode
index 7207824f97d81ef94f0d244da7f429968df17250..dfd3345c3c2dba40af384cd5897ee846c8619d2c 100644 (file)
@@ -71,7 +71,9 @@ const SimpleKeywords SimpleParser4::GLOBAL4_PARAMETERS = {
     { "config-control",                 Element::map },
     { "server-tag",                     Element::string },
     { "reservation-mode",               Element::string },
-    { "reservation-modes",              Element::map },
+    { "reservations-out-of-pool",       Element::boolean },
+    { "reservations-in-subnet",         Element::boolean },
+    { "reservations-global",            Element::boolean },
     { "calculate-tee-times",            Element::boolean },
     { "t1-percent",                     Element::real },
     { "t2-percent",                     Element::real },
@@ -111,7 +113,9 @@ const SimpleDefaults SimpleParser4::GLOBAL4_DEFAULTS = {
     { "server-hostname",                Element::string,  "" },
     { "boot-file-name",                 Element::string,  "" },
     { "server-tag",                     Element::string,  "" },
-    { "reservation-modes",              Element::map,     "{\"in-subnet\": true, \"out-of-pool\": true}" },
+    { "reservations-out-of-pool",       Element::boolean, "true" },
+    { "reservations-in-subnet",         Element::boolean, "true" },
+    { "reservations-global",            Element::boolean, "false" },
     { "calculate-tee-times",            Element::boolean, "false" },
     { "t1-percent",                     Element::real,    ".50" },
     { "t2-percent",                     Element::real,    ".875" },
@@ -208,7 +212,9 @@ const SimpleKeywords SimpleParser4::SUBNET4_PARAMETERS = {
     { "require-client-classes",         Element::list },
     { "reservations",                   Element::list },
     { "reservation-mode",               Element::string },
-    { "reservation-modes",              Element::map, },
+    { "reservations-out-of-pool",       Element::boolean },
+    { "reservations-in-subnet",         Element::boolean },
+    { "reservations-global",            Element::boolean },
     { "relay",                          Element::map },
     { "match-client-id",                Element::boolean },
     { "authoritative",                  Element::boolean },
@@ -326,7 +332,9 @@ const SimpleKeywords SimpleParser4::SHARED_NETWORK4_PARAMETERS = {
     { "boot-file-name",                 Element::string },
     { "relay",                          Element::map },
     { "reservation-mode",               Element::string },
-    { "reservation-modes",              Element::map },
+    { "reservations-out-of-pool",       Element::boolean },
+    { "reservations-in-subnet",         Element::boolean },
+    { "reservations-global",            Element::boolean },
     { "client-class",                   Element::string },
     { "require-client-classes",         Element::list },
     { "valid-lifetime",                 Element::integer },
index 4ae14d22e08e85fdc9939855621774216b2caa84..7a75b1bc19c51fd680c95defc1fc74cfddd98dc5 100644 (file)
@@ -72,7 +72,9 @@ const SimpleKeywords SimpleParser6::GLOBAL6_PARAMETERS = {
     { "config-control",                 Element::map },
     { "server-tag",                     Element::string },
     { "reservation-mode",               Element::string },
-    { "reservation-modes",              Element::map },
+    { "reservations-out-of-pool",       Element::boolean },
+    { "reservations-in-subnet",         Element::boolean },
+    { "reservations-global",            Element::boolean },
     { "calculate-tee-times",            Element::boolean },
     { "t1-percent",                     Element::real },
     { "t2-percent",                     Element::real },
@@ -107,7 +109,9 @@ const SimpleDefaults SimpleParser6::GLOBAL6_DEFAULTS = {
     { "decline-probation-period",       Element::integer, "86400" }, // 24h
     { "dhcp4o6-port",                   Element::integer, "0" },
     { "server-tag",                     Element::string,  "" },
-    { "reservation-modes",              Element::map,     "{\"in-subnet\": true, \"out-of-pool\": true}" },
+    { "reservations-out-of-pool",       Element::boolean, "true" },
+    { "reservations-in-subnet",         Element::boolean, "true" },
+    { "reservations-global",            Element::boolean, "false" },
     { "calculate-tee-times",            Element::boolean, "true" },
     { "t1-percent",                     Element::real,    ".50" },
     { "t2-percent",                     Element::real,    ".80" },
@@ -210,7 +214,9 @@ const SimpleKeywords SimpleParser6::SUBNET6_PARAMETERS = {
     { "require-client-classes",         Element::list },
     { "reservations",                   Element::list },
     { "reservation-mode",               Element::string },
-    { "reservation-modes",              Element::map },
+    { "reservations-out-of-pool",       Element::boolean },
+    { "reservations-in-subnet",         Element::boolean },
+    { "reservations-global",            Element::boolean },
     { "relay",                          Element::map },
     { "user-context",                   Element::map },
     { "comment",                        Element::string },
@@ -335,7 +341,9 @@ const SimpleKeywords SimpleParser6::SHARED_NETWORK6_PARAMETERS = {
     { "option-data",                    Element::list },
     { "relay",                          Element::map },
     { "reservation-mode",               Element::string },
-    { "reservation-modes",              Element::map },
+    { "reservations-out-of-pool",       Element::boolean },
+    { "reservations-in-subnet",         Element::boolean },
+    { "reservations-global",            Element::boolean },
     { "client-class",                   Element::string },
     { "require-client-classes",         Element::list },
     { "preferred-lifetime",             Element::integer },
index 814909bce5c8d40e40bbe95a5c6c0eca6d7cbd35..d0c2646a7c1c079a3820308c59a7c3fb1f9c7a7b 100644 (file)
@@ -375,28 +375,8 @@ SrvConfig::applyDefaultsConfiguredGlobals(const SimpleDefaults& defaults) {
             x.reset(new DoubleElement(dbl_value, pos));
             break;
         }
-        case Element::map: {
-            auto data = Element::fromJSON(def_value.value_);
-            if (data->getType() != Element::map) {
-                isc_throw(BadValue,
-                          "Internal error. Incorrect map value type for "
-                          << def_value.name_ << " : " << def_value.value_);
-            }
-            x = data;
-            break;
-        }
-        case Element::list: {
-            auto data = Element::fromJSON(def_value.value_);
-            if (data->getType() != Element::list) {
-                isc_throw(BadValue,
-                          "Internal error. Incorrect list value type for "
-                          << def_value.name_ << " : " << def_value.value_);
-            }
-            x = data;
-            break;
-        }
         default:
-            // No default values for null
+            // No default values for null, list or map
             isc_throw(BadValue,
                       "Internal error. Incorrect default value type for "
                       << def_value.name_);
index 944160f91a27f65ce6a71805d0981b6b7656909e..4eb5b55884f7e82bd42d3673c8787fcb37ac55bd 100644 (file)
@@ -1115,7 +1115,8 @@ TEST(CfgSubnets4Test, unparseSubnet) {
         "    \"4o6-interface-id\": \"\",\n"
         "    \"4o6-subnet\": \"\",\n"
         "    \"authoritative\": false,\n"
-        "    \"reservation-modes\": {\"in-subnet\": true, \"out-of-pool\": true},\n"
+        "    \"reservations-in-subnet\": true,\n"
+        "    \"reservations-out-of-pool\": true,\n"
         "    \"option-data\": [ ],\n"
         "    \"pools\": [ ]\n,"
         "    \"require-client-classes\": [ \"foo\", \"bar\" ],\n"
@@ -1282,7 +1283,8 @@ TEST(CfgSubnets4Test, teeTimePercentValidation) {
         "            \"boot-file-name\": \"\", \n"
         "            \"client-class\": \"\", \n"
         "            \"require-client-classes\": [] \n,"
-        "            \"reservation-modes\": {\"in-subnet\": true, \"out-of-pool\": true},\n"
+        "            \"reservations-in-subnet\": true,\n"
+        "            \"reservations-out-of-pool\": true,\n"
         "            \"4o6-interface\": \"\", \n"
         "            \"4o6-interface-id\": \"\", \n"
         "            \"4o6-subnet\": \"\" \n"
@@ -1349,7 +1351,8 @@ TEST(CfgSubnets4Test, validLifetimeValidation) {
         "            \"boot-file-name\": \"\", \n"
         "            \"client-class\": \"\", \n"
         "            \"require-client-classes\": [] \n,"
-        "            \"reservation-modes\": {\"in-subnet\": true, \"out-of-pool\": true},\n"
+        "            \"reservations-in-subnet\": true,\n"
+        "            \"reservations-out-of-pool\": true,\n"
         "            \"4o6-interface\": \"\", \n"
         "            \"4o6-interface-id\": \"\", \n"
         "            \"4o6-subnet\": \"\" \n"
@@ -1591,7 +1594,8 @@ TEST(CfgSubnets4Test, hostnameSanitizierValidation) {
         "            \"boot-file-name\": \"\", \n"
         "            \"client-class\": \"\", \n"
         "            \"require-client-classes\": [] \n,"
-        "           \"reservation-modes\": {\"in-subnet\": true, \"out-of-pool\": true},\n"
+        "            \"reservations-in-subnet\": true,\n"
+        "            \"reservations-out-of-pool\": true,\n"
         "            \"4o6-interface\": \"\", \n"
         "            \"4o6-interface-id\": \"\", \n"
         "            \"4o6-subnet\": \"\" \n"
@@ -1669,7 +1673,8 @@ TEST(CfgSubnets4Test, cacheParamValidation) {
         "            \"boot-file-name\": \"\", \n"
         "            \"client-class\": \"\", \n"
         "            \"require-client-classes\": [] \n,"
-        "            \"reservation-modes\": {\"in-subnet\": true, \"out-of-pool\": true},\n"
+        "            \"reservations-in-subnet\": true,\n"
+        "            \"reservations-out-of-pool\": true,\n"
         "            \"4o6-interface\": \"\", \n"
         "            \"4o6-interface-id\": \"\", \n"
         "            \"4o6-subnet\": \"\" \n"
index add98d9e8521606574d061785a41ec4f9951af31..e1c98d4c7b67309462c11c8f78d7fb3ba6bb8faf 100644 (file)
@@ -710,7 +710,8 @@ TEST(CfgSubnets6Test, unparseSubnet) {
         "    \"min-valid-lifetime\": 100,\n"
         "    \"max-valid-lifetime\": 300,\n"
         "    \"rapid-commit\": false,\n"
-        "    \"reservation-modes\": {\"in-subnet\": true, \"out-of-pool\": true},\n"
+        "    \"reservations-in-subnet\": true,\n"
+        "    \"reservations-out-of-pool\": true,\n"
         "    \"pools\": [ ],\n"
         "    \"pd-pools\": [ ],\n"
         "    \"option-data\": [ ],\n"
@@ -1079,7 +1080,8 @@ TEST(CfgSubnets6Test, teeTimePercentValidation) {
         "            \"valid-lifetime\": 300, \n"
         "            \"client-class\": \"\", \n"
         "            \"require-client-classes\": [] \n,"
-        "            \"reservation-modes\": {\"in-subnet\": true, \"out-of-pool\": true}\n"
+        "            \"reservations-in-subnet\": true,\n"
+        "            \"reservations-out-of-pool\": true\n"
         "        }";
 
 
@@ -1142,7 +1144,8 @@ TEST(CfgSubnets6Test, preferredLifetimeValidation) {
         "            \"valid-lifetime\": 300, \n"
         "            \"client-class\": \"\", \n"
         "            \"require-client-classes\": [] \n,"
-        "            \"reservation-modes\": {\"in-subnet\": true, \"out-of-pool\": true}\n"
+        "            \"reservations-in-subnet\": true,\n"
+        "            \"reservations-out-of-pool\": true\n"
         "        }";
 
 
@@ -1377,7 +1380,8 @@ TEST(CfgSubnets6Test, hostnameSanitizierValidation) {
         "            \"valid-lifetime\": 300, \n"
         "            \"client-class\": \"\", \n"
         "            \"require-client-classes\": [] \n,"
-        "            \"reservation-modes\": {\"in-subnet\": true, \"out-of-pool\": true}\n"
+        "            \"reservations-in-subnet\": true,\n"
+        "            \"reservations-out-of-pool\": true\n"
         "        }";
 
     data::ElementPtr elems;
@@ -1447,7 +1451,8 @@ TEST(CfgSubnets6Test, cacheParamValidation) {
         "            \"valid-lifetime\": 300, \n"
         "            \"client-class\": \"\", \n"
         "            \"require-client-classes\": [] \n,"
-        "            \"reservation-modes\": {\"in-subnet\": true, \"out-of-pool\": true}\n"
+        "            \"reservations-in-subnet\": true,\n"
+        "            \"reservations-out-of-pool\": true\n"
         "        }";
 
     data::ElementPtr elems;
index c94f30f3d7b58d8402a6b0926434686da819fd6a..7c88e21145d20b8526ff201403d6c165a0fc91f9 100644 (file)
@@ -185,11 +185,9 @@ TEST_F(NetworkTest, inheritanceSupport4) {
     globals_->set("cache-max-age", Element::create(20));
     globals_->set("ddns-update-on-renew", Element::create(true));
     globals_->set("ddns-use-conflict-resolution", Element::create(true));
-    auto reservation_modes = Element::createMap();
-    reservation_modes->set("global", Element::create(false));
-    reservation_modes->set("in-subnet", Element::create(false));
-    reservation_modes->set("out-of-pool", Element::create(false));
-    globals_->set("reservation-modes", reservation_modes);
+    globals_->set("reservations-out-of-pool", Element::create(false));
+    globals_->set("reservations-in-subnet", Element::create(false));
+    globals_->set("reservations-global", Element::create(false));
 
     // For each parameter for which inheritance is supported run
     // the test that checks if the values are inherited properly.
@@ -223,7 +221,7 @@ TEST_F(NetworkTest, inheritanceSupport4) {
                                             Network::HR_DISABLED);
     }
     {
-        SCOPED_TRACE("reservation-modes");
+        SCOPED_TRACE("reservations-global");
         testNetworkInheritance<TestNetwork>(&Network::getHostReservationMode,
                                             &Network::setHostReservationMode,
                                             Network::HR_OUT_OF_POOL,
index d72a556f942f1c730fc0f3e11d8103087a734295..d176ef558f04b98b472e272bbc4fab8ea426d485 100644 (file)
@@ -58,117 +58,117 @@ TEST_F(HostReservationModesParserTest, validContent) {
         {
         "reservation modes disabled",
         "{ \n"
-        "   \"global\": false, \n"
-        "   \"in-subnet\": false, \n"
-        "   \"out-of-pool\": false \n"
+        "   \"reservations-global\": false, \n"
+        "   \"reservations-in-subnet\": false, \n"
+        "   \"reservations-out-of-pool\": false \n"
         "} \n",
         Network::HR_DISABLED
         },
         {
         "reservation modes global enabled",
         "{ \n"
-        "   \"global\": true, \n"
-        "   \"in-subnet\": false, \n"
-        "   \"out-of-pool\": false \n"
+        "   \"reservations-global\": true, \n"
+        "   \"reservations-in-subnet\": false, \n"
+        "   \"reservations-out-of-pool\": false \n"
         "} \n",
         Network::HR_GLOBAL
         },
         {
         "reservation modes in-subnet enabled",
         "{ \n"
-        "   \"global\": false, \n"
-        "   \"in-subnet\": true, \n"
-        "   \"out-of-pool\": false \n"
+        "   \"reservations-global\": false, \n"
+        "   \"reservations-in-subnet\": true, \n"
+        "   \"reservations-out-of-pool\": false \n"
         "} \n",
         Network::HR_IN_SUBNET
         },
         {
         "reservation modes global and in-subnet enabled",
         "{ \n"
-        "   \"global\": true, \n"
-        "   \"in-subnet\": true, \n"
-        "   \"out-of-pool\": false \n"
+        "   \"reservations-global\": true, \n"
+        "   \"reservations-in-subnet\": true, \n"
+        "   \"reservations-out-of-pool\": false \n"
         "} \n",
         Network::HR_GLOBAL|Network::HR_IN_SUBNET
         },
         {
         "reservation modes out-of-pool enabled",
         "{ \n"
-        "   \"global\": false, \n"
-        "   \"in-subnet\": false, \n"
-        "   \"out-of-pool\": true \n"
+        "   \"reservations-global\": false, \n"
+        "   \"reservations-in-subnet\": false, \n"
+        "   \"reservations-out-of-pool\": true \n"
         "} \n",
         Network::HR_OUT_OF_POOL
         },
         {
         "reservation modes global and out-of-pool enabled",
         "{ \n"
-        "   \"global\": true, \n"
-        "   \"in-subnet\": false, \n"
-        "   \"out-of-pool\": true \n"
+        "   \"reservations-global\": true, \n"
+        "   \"reservations-in-subnet\": false, \n"
+        "   \"reservations-out-of-pool\": true \n"
         "} \n",
         Network::HR_GLOBAL|Network::HR_OUT_OF_POOL
         },
         {
         "reservation modes in-subnet and out-of-pool enabled",
         "{ \n"
-        "   \"global\": false, \n"
-        "   \"in-subnet\": true, \n"
-        "   \"out-of-pool\": true \n"
+        "   \"reservations-global\": false, \n"
+        "   \"reservations-in-subnet\": true, \n"
+        "   \"reservations-out-of-pool\": true \n"
         "} \n",
         Network::HR_IN_SUBNET|Network::HR_OUT_OF_POOL
         },
         {
         "reservation modes global, in-subnet and out-of-pool enabled",
         "{ \n"
-        "   \"global\": true, \n"
-        "   \"in-subnet\": true, \n"
-        "   \"out-of-pool\": true \n"
+        "   \"reservations-global\": true, \n"
+        "   \"reservations-in-subnet\": true, \n"
+        "   \"reservations-out-of-pool\": true \n"
         "} \n",
         Network::HR_GLOBAL|Network::HR_IN_SUBNET|Network::HR_OUT_OF_POOL
         },
         {
         "only global",
         "{ \n"
-        "   \"global\": true \n"
+        "   \"reservations-global\": true \n"
         "} \n",
         Network::HR_GLOBAL
         },
         {
         "only in-subnet",
         "{ \n"
-        "   \"in-subnet\": true \n"
+        "   \"reservations-in-subnet\": true \n"
         "} \n",
         Network::HR_IN_SUBNET
         },
         {
         "only out-of-pool",
         "{ \n"
-        "   \"out-of-pool\": true \n"
+        "   \"reservations-out-of-pool\": true \n"
         "} \n",
         Network::HR_OUT_OF_POOL
         },
         {
         "only global and in-subnet",
         "{ \n"
-        "   \"global\": true, \n"
-        "   \"in-subnet\": true \n"
+        "   \"reservations-global\": true, \n"
+        "   \"reservations-in-subnet\": true \n"
         "} \n",
         Network::HR_GLOBAL|Network::HR_IN_SUBNET
         },
         {
         "only global and out-of-pool",
         "{ \n"
-        "   \"global\": true, \n"
-        "   \"out-of-pool\": true \n"
+        "   \"reservations-global\": true, \n"
+        "   \"reservations-out-of-pool\": true \n"
         "} \n",
         Network::HR_GLOBAL|Network::HR_OUT_OF_POOL
         },
         {
         "only in-subnet and out-of-pool",
         "{ \n"
-        "   \"in-subnet\": true, \n"
-        "   \"out-of-pool\": true \n"
+        "   \"reservations-in-subnet\": true, \n"
+        "   \"reservations-out-of-pool\": true \n"
         "} \n",
         Network::HR_IN_SUBNET|Network::HR_OUT_OF_POOL
         },
@@ -210,19 +210,19 @@ TEST_F(HostReservationModesParserTest, invalidContent) {
         {
         "global not boolean",
         "{ \n"
-        "   \"global\": \"always\" \n"
+        "   \"reservations-global\": \"always\" \n"
         "} \n"
         },
         {
         "in-subnet not boolean",
         "{ \n"
-        "   \"in-subnet\": \"always\" \n"
+        "   \"reservations-in-subnet\": \"always\" \n"
         "} \n"
         },
         {
         "out-of-pool not boolean",
         "{ \n"
-        "   \"out-of-pool\": \"always\" \n"
+        "   \"reservations-out-of-pool\": \"always\" \n"
         "} \n"
         }
     };
index 3ef856ea5bc54c7f5828cc89788666e3ee04dccb..ad01f34fe26874a4351a28b6c08a3e2d27e1a168 100644 (file)
@@ -128,7 +128,7 @@ public:
                 "    \"rebind-timer\": 199,"
                 "    \"relay\": { \"ip-addresses\": [ \"10.1.1.1\" ] },"
                 "    \"renew-timer\": 99,"
-                "    \"reservation-modes\": {\"out-of-pool\": true},"
+                "    \"reservations-out-of-pool\": true,"
                 "    \"server-hostname\": \"example.org\","
                 "    \"require-client-classes\": [ \"runner\" ],"
                 "    \"user-context\": { \"comment\": \"example\" },"
@@ -173,7 +173,8 @@ public:
                 "            \"boot-file-name\": \"\","
                 "            \"client-class\": \"\","
                 "            \"require-client-classes\": []\n,"
-                "            \"reservation-modes\": {\"in-subnet\": true, \"out-of-pool\": true},"
+                "            \"reservations-in-subnet\": true,"
+                "            \"reservations-out-of-pool\": true,"
                 "            \"4o6-interface\": \"\","
                 "            \"4o6-interface-id\": \"\","
                 "            \"4o6-subnet\": \"\","
@@ -198,7 +199,8 @@ public:
                 "            \"boot-file-name\": \"\","
                 "            \"client-class\": \"\","
                 "            \"require-client-classes\": []\n,"
-                "            \"reservation-modes\": {\"in-subnet\": true, \"out-of-pool\": true},"
+                "            \"reservations-in-subnet\": true,"
+                "            \"reservations-out-of-pool\": true,"
                 "            \"4o6-interface\": \"\","
                 "            \"4o6-interface-id\": \"\","
                 "            \"4o6-subnet\": \"\","
@@ -547,7 +549,7 @@ public:
                 "    \"relay\": { \"ip-addresses\": [ \"2001:db8:1::1\" ] },"
                 "    \"renew-timer\": 99,"
                 "    \"require-client-classes\": [ \"runner\" ],"
-                "    \"reservation-modes\": {\"out-of-pool\": true},"
+                "    \"reservations-out-of-pool\": true,"
                 "    \"user-context\": { },"
                 "    \"valid-lifetime\": 399,"
                 "    \"min-valid-lifetime\": 299,"
@@ -589,7 +591,8 @@ public:
                 "            \"max-valid-lifetime\": 500,"
                 "            \"client-class\": \"\","
                 "            \"require-client-classes\": []\n,"
-                "            \"reservation-modes\": {\"in-subnet\": true, \"out-of-pool\": true},"
+                "            \"reservations-in-subnet\": true,"
+                "            \"reservations-out-of-pool\": true,"
                 "            \"rapid-commit\": false,"
                 "            \"hostname-char-set\": \"\""
                 "        },"
@@ -604,7 +607,8 @@ public:
                 "            \"valid-lifetime\": 40,"
                 "            \"client-class\": \"\","
                 "            \"require-client-classes\": []\n,"
-                "            \"reservation-modes\": {\"in-subnet\": true, \"out-of-pool\": true},"
+                "            \"reservations-in-subnet\": true,"
+                "            \"reservations-out-of-pool\": true,"
                 "            \"rapid-commit\": false"
                 "        }"
                 "    ]"
index 985edafd176bf10627ce310f340556862832a93d..4b1e8cd3d6002df020af6d365fdce85c878c8f26 100644 (file)
@@ -640,7 +640,8 @@ TEST(SharedNetwork4Test, unparse) {
         "    },\n"
         "    \"renew-timer\": 100,\n"
         "    \"require-client-classes\": [ \"foo\" ],\n"
-        "    \"reservation-modes\": {\"in-subnet\": true, \"out-of-pool\": true},"
+        "    \"reservations-in-subnet\": true,\n"
+        "    \"reservations-out-of-pool\": true,\n"
         "    \"subnet4\": [\n"
         "      {\n"
         "        \"4o6-interface\": \"\",\n"
@@ -1331,7 +1332,8 @@ TEST(SharedNetwork6Test, unparse) {
         "    },\n"
         "    \"renew-timer\": 100,\n"
         "    \"require-client-classes\": [ \"foo\" ],\n"
-        "    \"reservation-modes\": {\"in-subnet\": true, \"out-of-pool\": true},"
+        "    \"reservations-in-subnet\": true,\n"
+        "    \"reservations-out-of-pool\": true,\n"
         "    \"subnet6\": [\n"
         "      {\n"
         "        \"id\": 1,\n"