]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#2474] added unittests which load and validate example files
authorRazvan Becheriu <razvan@isc.org>
Tue, 19 Jul 2022 20:04:46 +0000 (23:04 +0300)
committerRazvan Becheriu <razvan@isc.org>
Fri, 22 Jul 2022 19:05:50 +0000 (22:05 +0300)
63 files changed:
doc/examples/kea4/advanced.json
doc/examples/kea4/all-keys-netconf.json
doc/examples/kea4/all-keys.json
doc/examples/kea4/all-options.json
doc/examples/kea4/backends.json
doc/examples/kea4/classify.json
doc/examples/kea4/classify2.json
doc/examples/kea4/config-backend.json
doc/examples/kea4/dhcpv4-over-dhcpv6.json
doc/examples/kea4/global-reservations.json
doc/examples/kea4/ha-load-balancing-primary.json
doc/examples/kea4/hooks-radius.json
doc/examples/kea4/hooks.json
doc/examples/kea4/leases-expiration.json
doc/examples/kea4/multiple-options.json
doc/examples/kea4/mysql-reservations.json
doc/examples/kea4/pgsql-reservations.json
doc/examples/kea4/reservations.json
doc/examples/kea4/several-subnets.json
doc/examples/kea4/shared-network.json
doc/examples/kea4/single-subnet.json
doc/examples/kea4/vendor-specific.json
doc/examples/kea4/vivso.json
doc/examples/kea4/with-ddns.json
doc/examples/kea6/advanced.json
doc/examples/kea6/all-keys-netconf.json
doc/examples/kea6/all-keys.json
doc/examples/kea6/backends.json
doc/examples/kea6/classify.json
doc/examples/kea6/classify2.json
doc/examples/kea6/config-backend.json
doc/examples/kea6/dhcpv4-over-dhcpv6.json
doc/examples/kea6/duid.json
doc/examples/kea6/global-reservations.json
doc/examples/kea6/ha-hot-standby.json
doc/examples/kea6/hooks.json
doc/examples/kea6/iPXE.json
doc/examples/kea6/leases-expiration.json
doc/examples/kea6/multiple-options.json
doc/examples/kea6/mysql-reservations.json
doc/examples/kea6/pgsql-reservations.json
doc/examples/kea6/reservations.json
doc/examples/kea6/several-subnets.json
doc/examples/kea6/shared-network.json
doc/examples/kea6/simple.json
doc/examples/kea6/softwire46.json
doc/examples/kea6/stateless.json
doc/examples/kea6/tee-times.json
doc/examples/kea6/with-ddns.json
src/bin/dhcp4/ctrl_dhcp4_srv.cc
src/bin/dhcp4/dhcp4_lexer.ll
src/bin/dhcp4/json_config_parser.cc
src/bin/dhcp4/tests/dhcp4_srv_unittest.cc
src/bin/dhcp4/tests/dhcp4_test_utils.cc
src/bin/dhcp4/tests/dhcp4_test_utils.h
src/bin/dhcp6/ctrl_dhcp6_srv.cc
src/bin/dhcp6/dhcp6_lexer.ll
src/bin/dhcp6/json_config_parser.cc
src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
src/bin/dhcp6/tests/dhcp6_test_utils.cc
src/bin/dhcp6/tests/dhcp6_test_utils.h
src/bin/dhcp6/tests/shared_network_unittest.cc
src/share/api/lease6-del.json

index 652acddafde7c81987474fc659f46221e5f9c5a8..4b25f46ceebb939c79144db631177661668c3d92 100644 (file)
@@ -18,9 +18,9 @@
 { "Dhcp4":
 
 {
-    // Kea is told to listen on ethX interface only.
+    // Kea is told to listen on eth0 interface only.
     "interfaces-config": {
-        "interfaces": [ "ethX" ],
+        "interfaces": [ "eth0" ],
 
         // This specifies what type of socket Kea uses. Currently supported
         // are 'raw' (which is the default) and 'udp'. Raw has the benefit
index a754256e99f21b6264ccf123144536234c99a9d3..baa1594c22d4ff7663ff7b799c65a9a4ecdf9679 100644 (file)
         "hosts-databases": [
             {
                 // Name of the database to connect to.
-                "name": "kea",
+                "name": "keatest",
 
                 // Host on which the database resides.
                 "host": "localhost",
 
                 // Database password.
-                "password": "kea",
+                "password": "keatest",
 
                 // Port on which the database is available.
                 "port": 3306,
                 "type": "mysql",
 
                 // User name to be used to access the database.
-                "user": "kea",
+                "user": "keatest",
 
                 // Read only mode.
                 "readonly": false,
             },
             {
                 // Name of the database to connect to.
-                "name": "kea",
+                "name": "keatest",
 
                 // Host on which the database resides.
                 "host": "localhost",
 
                 // Database password.
-                "password": "kea",
+                "password": "keatest",
 
                 // Port on which the database is available.
                 "port": 5432,
                 "type": "postgresql",
 
                 // User name to be used to access the database.
-                "user": "kea",
+                "user": "keatest",
 
                 // Connection reconnect wait time.
                 // This parameter governs how long Kea waits before attempting
             // Specifies a list of interfaces on which the Kea DHCPv4
             // server should listen to the DHCP requests.
             "interfaces": [
-                "ethX"
+                "eth0"
             ],
 
             // Enumeration which indicates what interface should be used
 
                 // Specifies that this shared network is selected for the
                 // requests received on the particular interface.
-                "interface": "ethX",
+                "interface": "eth0",
 
                 // Shared network level flag specifying whether the client
                 // identifier should be used for identifying clients.
                         "4o6-subnet": "2001:db8:1:1::/64",
 
                         // Subnet level authoritative flag.
-                        "authoritative": true,
+                        "authoritative": false,
 
                         // Subnet level bootfile name, set in 'file' field.
                         "boot-file-name": "",
 
                         // Specifies that this subnet is selected for the requests
                         // received on the particular interface.
-                        "interface": "ethX",
+                        "interface": "eth0",
 
                         // Subnet level flag specifying whether the client identifier
                         // should be used for identifying clients.
index 40c0f3a2fb5b12245317029b91bab9e45d888d71..3b3b722b4ea089ad7892ae2d16506d06b0f089fa 100644 (file)
         "hosts-databases": [
             {
                 // Name of the database to connect to.
-                "name": "kea",
+                "name": "keatest",
 
                 // Host on which the database resides.
                 "host": "localhost",
 
                 // Database password.
-                "password": "kea",
+                "password": "keatest",
 
                 // Port on which the database is available.
                 "port": 3306,
                 "type": "mysql",
 
                 // User name to be used to access the database.
-                "user": "kea",
+                "user": "keatest",
 
                 // Read only mode.
                 "readonly": false,
             },
             {
                 // Name of the database to connect to.
-                "name": "kea",
+                "name": "keatest",
 
                 // Host on which the database resides.
                 "host": "localhost",
 
                 // Database password.
-                "password": "kea",
+                "password": "keatest",
 
                 // Port on which the database is available.
                 "port": 5432,
                 "type": "postgresql",
 
                 // User name to be used to access the database.
-                "user": "kea"
+                "user": "keatest"
             },
             {
+                // Name of the database to connect to.
+                "name": "keatest",
+
                 // Database password.
-                "password": "kea",
+                "password": "keatest",
 
                 // Port on which the database is available.
                 "port": 9042,
                 "type": "mysql",
 
                 // User name to be used to access the database.
-                "user": "kea",
+                "user": "keatest",
 
                 // Connection reconnect wait time.
                 // This parameter governs how long Kea waits before attempting
             // Specifies a list of interfaces on which the Kea DHCPv4
             // server should listen to the DHCP requests.
             "interfaces": [
-                "ethX"
+                "eth0"
             ],
 
             // Enumeration which indicates what interface should be used
 
                 // Specifies that this shared network is selected for the
                 // requests received on the particular interface.
-                "interface": "ethX",
+                "interface": "eth0",
 
                 // Shared network level flag specifying whether the client
                 // identifier should be used for identifying clients.
                         "4o6-subnet": "2001:db8:1:1::/64",
 
                         // Subnet level authoritative flag.
-                        "authoritative": true,
+                        "authoritative": false,
 
                         // Subnet level bootfile name, set in 'file' field.
                         "boot-file-name": "",
 
                         // Specifies that this subnet is selected for the requests
                         // received on the particular interface.
-                        "interface": "ethX",
+                        "interface": "eth0",
 
                         // Subnet level flag specifying whether the client identifier
                         // should be used for identifying clients.
index e0ec867b8561a6f818610732a653eb9eaf54ae39..49dbbf9fad93137f93b3daa3713b136b30904bf3 100644 (file)
       {
         "code": 114,
         "data": "https://default.example.org",
-        "name": "default-url"
+        "name": "v4-captive-portal"
       },
 
       // Option code 115 is unassigned.
         "name": "v4-portparams"
       },
 
-      // Type: string
-      {
-        "code": 160,
-        "data": "portal",
-        "name": "v4-captive-portal"
-      },
-
       // Option codes 161-209 are unassigned.
 
       /*
index 84ef38bbda3708794cbad22bd815054eee8bb297..40e0c39d7f55e3ff40c3c563f3e4429ecc9190cf 100644 (file)
@@ -8,9 +8,9 @@
 { "Dhcp4":
 
 {
-// Kea is told to listen on ethX interface only.
+// Kea is told to listen on eth0 interface only.
   "interfaces-config": {
-    "interfaces": [ "ethX" ]
+    "interfaces": [ "eth0" ]
   },
 
 // We need to specify lease type. Exactly one lease-database section
@@ -81,7 +81,7 @@
     {
        "pools": [ { "pool":  "192.0.2.1 - 192.0.2.200" } ],
        "subnet": "192.0.2.0/24",
-       "interface": "ethX"
+       "interface": "eth0"
     }
   ],
 
index 5a623b718f870f820a4e6ca7b54168d4396ec461..3f68c123a0ea6322227e631a05c47b1c33cc4fb8 100644 (file)
@@ -3,9 +3,9 @@
 
 { "Dhcp4": {
 
-// Kea is told to listen on ethX interface only.
+// Kea is told to listen on eth0 interface only.
   "interfaces-config": {
-      "interfaces": [ "ethX" ]
+      "interfaces": [ "eth0" ]
   },
 
 // Let's use the simplest backend: memfile and use some reasonable values
@@ -81,7 +81,7 @@
         "pools": [ { "pool":  "192.0.2.1 - 192.0.2.200" } ],
         "subnet": "192.0.2.0/24",
         "client-class": "VoIP",
-        "interface": "ethX"
+        "interface": "eth0"
     },
 
     // This one doesn't have any client-class specified, so everyone
@@ -97,7 +97,7 @@
             "hw-address": "1a:1b:1c:1d:1e:1f",
             "client-classes": [ "VoIP" ]
         } ],
-        "interface": "ethX"
+        "interface": "eth0"
     },
 
     // The following list defines a subnet with pools. For some pools
            } ],
 
         "subnet": "192.0.4.0/23",
-        "interface": "ethY"
+        "interface": "eth1"
     }
   ],
 
index e9d82ac7bd887198e6d12a48e0642e0e9a2e5851..955e6bde353134db085f250e54328fe65a21a9f9 100644 (file)
@@ -4,9 +4,9 @@
 
 { "Dhcp4": {
 
-// Kea is told to listen on ethX interface only.
+// Kea is told to listen on eth0 interface only.
   "interfaces-config": {
-      "interfaces": [ "ethX" ]
+      "interfaces": [ "eth0" ]
   },
 
 // Let's use the simplest backend: memfile and use some reasonable values
@@ -89,7 +89,7 @@
         "pools": [ { "pool":  "192.0.2.1 - 192.0.2.200" } ],
         "subnet": "192.0.2.0/24",
         "client-class": "VoIP",
-        "interface": "ethX"
+        "interface": "eth0"
     },
 // This one doesn't have any client-class specified, so everyone
 // is allowed in. The normal subnet selection rules still apply,
             "hw-address": "1a:1b:1c:1d:1e:1f",
             "client-classes": [ "VoIP" ]
         } ],
-        "interface": "ethX",
+        "interface": "eth0",
         "require-client-classes": [ "second_subnet" ]
     },
 
                "pool":  "192.0.5.1 - 192.0.5.200"
            } ],
            "subnet": "192.0.4.0/23",
-           "interface": "ethY"
+           "interface": "eth1"
         },
 // This subnet is divided in two pools for unknown and known
 // (i.e. which have a reservation) clients. The built-in KNOWN and
 // UNKNOWN classes are set or not at host reservation lookup (KNOWN if
 // this returns something, UNKNOWN if this finds nothing) and client
-//classes depending on it are evaluated.
+// classes depending on it are evaluated.
 // This happens after subnet selection and before address allocation
-//from pools.
+// from pools.
         {
            "pools": [
                 {
index adcfd8eed68a242d0d3139d53467d936bb8d321d..aae0f344369b176c8907d6037453ad4af4e85360 100644 (file)
@@ -11,9 +11,9 @@
     // either "all" or "server1" will be used by this instance.
     "server-tag": "server1",
 
-    // Kea is told to listen on ethX interface only.
+    // Kea is told to listen on eth0 interface only.
     "interfaces-config": {
-        "interfaces": [ "ethX" ]
+        "interfaces": [ "eth0" ]
     },
 
     // Use memfile lease database backend.
index 779041b172a8a93a51e740382c9447423b95a2ce..52cdc1c1acb3021e303cfa88cc83f5517ff772e4 100644 (file)
@@ -7,7 +7,7 @@
 "Dhcp4":
 {
   "interfaces-config": {
-    "interfaces": [ "eno33554984" ]
+    "interfaces": [ "eth0" ]
   },
 
   "lease-database": {
@@ -21,7 +21,7 @@
   "subnet4": [
    {    "subnet": "10.10.10.0/24",
 // Don't forget the "4o6-" before "interface" here!
-        "4o6-interface": "eno33554984",
+        "4o6-interface": "eth0",
         "4o6-subnet": "2001:db8:1:1::/64",
         "pools": [ { "pool": "10.10.10.100 - 10.10.10.199" } ] }
   ],
index 3c579df317d0b6ed2f80139a15e0586a53de4b9a..d25200c38e865d9363e5d728d8ba1e4ad6dfb340 100644 (file)
@@ -9,9 +9,9 @@
 { "Dhcp4":
 
 {
-// Kea is told to listen on ethX interface only.
+// Kea is told to listen on eth0 interface only.
   "interfaces-config": {
-    "interfaces": [ "ethX" ]
+    "interfaces": [ "eth0" ]
   },
 
 // We need to specify the database used to store leases. As of June
 // Note: flexible identifier requires flex_id hook library to be
 // loaded to work.
     {
-        "flex-id": "s0mEVaLue",
+        "flex-id": "'s0mEVaLue'",
         "ip-address": "192.0.2.206"
     }
   ],
index e5cb40f1e1484142d331afc4ed2a9ffce0e38c1f..ae730e59263fd3657b78efb720632d549f3cfac1 100644 (file)
@@ -14,7 +14,7 @@
     // Add names of your network interfaces to listen on.
     "interfaces-config": {
         // The DHCPv4 server listens on this interface.
-        "interfaces": [ "ethX" ]
+        "interfaces": [ "eth0" ]
     },
 
     // Control socket is required for communication between the Control
index 14ffefe10bdd4a2dfe90ecdb1447dc6ce28bb403..f00190e1e9875a13348e1d1bea59e8fdb124cd4c 100644 (file)
@@ -69,8 +69,8 @@
 {
   // Kea is told to listen on specific interfaces only.
   "interfaces-config": {
-    // You should probably list your network interfaces here (e.g. "en0")
-    "interfaces": [ "en0" ]
+    // You should probably list your network interfaces here (e.g. "eth1961")
+    "interfaces": [ "eth1961" ]
   },
 
   // Set up the storage for leases.
       // Set the subnet ID (aka RADIUS NAS port).
       "id": 14,
       "subnet": "192.0.2.0/24",
-      "interface": "en0",
+      "interface": "eth1961",
       "pools": [
          {
             // Red pool (10-19 are for reservations)
index 9006c7661ee70d57ddb58e5fb91ab4c68e0267c6..0d6e29bbec14159e1ecfe95a0abe9a5455869c8c 100644 (file)
@@ -5,9 +5,9 @@
 {"Dhcp4":
 
 {
-// Kea is told to listen on the ethX interface only.
+// Kea is told to listen on the eth0 interface only.
   "interfaces-config": {
-    "interfaces": [ "ethX" ]
+    "interfaces": [ "eth0" ]
   },
 
 // Set up the storage for leases.
@@ -22,7 +22,7 @@
     {
       "pools": [ { "pool": "192.0.2.1 - 192.0.2.200" } ],
       "subnet": "192.0.2.0/24",
-      "interface": "ethX"
+      "interface": "eth0"
     }
   ],
 
index ca4b3db05b187a20a589dba31cbb335fbdb87e79..c40dd5d546f49eb827c5b88e8ec59b8d2fb7fb73 100644 (file)
@@ -5,9 +5,9 @@
 { "Dhcp4":
 
 {
-// Kea is told to listen on ethX interface only.
+// Kea is told to listen on eth0 interface only.
   "interfaces-config": {
-    "interfaces": [ "ethX" ]
+    "interfaces": [ "eth0" ]
   },
 
 // We need to specify the database used to store leases. As of
@@ -49,7 +49,7 @@
     {
        "pools": [ { "pool":  "192.0.2.1 - 192.0.2.200" } ],
        "subnet": "192.0.2.0/24",
-       "interface": "ethX"
+       "interface": "eth0"
     }
   ],
 
index 925ef3bbd2e011789538b290157cf7d163dab79d..949889127f91e08d3bf2552e4715722f979cf185 100644 (file)
@@ -4,9 +4,9 @@
 { "Dhcp4":
 
 {
-// Kea is told to listen on ethX interface only.
+// Kea is told to listen on eth0 interface only.
   "interfaces-config": {
-    "interfaces": [ "ethX" ]
+    "interfaces": [ "eth0" ]
   },
 
 // We need to specify the database used to store leases. As of
index 86a7accbcb6635d4afbd08a446b3eda0a961209d..57429857bef896ff3576fb98393f978649ce4b06 100644 (file)
@@ -5,9 +5,9 @@
 { "Dhcp4":
 
 {
-// Kea is told to listen on ethX interface only.
+// Kea is told to listen on eth0 interface only.
   "interfaces-config": {
-    "interfaces": [ "ethX" ]
+    "interfaces": [ "eth0" ]
 
   },
 
@@ -59,9 +59,9 @@
     "type": "mysql",
     "reconnect-wait-time": 3000, // expressed in ms
     "max-reconnect-tries": 3,
-    "name": "kea",
-    "user": "kea",
-    "password": "kea",
+    "name": "keatest",
+    "user": "keatest",
+    "password": "keatest",
     "host": "localhost",
     "port": 3306,
     "trust-anchor": "my-ca",
@@ -79,7 +79,7 @@
     {
        "pools": [ { "pool":  "192.0.2.10 - 192.0.2.200" } ],
        "subnet": "192.0.2.0/24",
-       "interface": "ethX",
+       "interface": "eth0",
        "id": 1
     }
   ],
index ebd101b3f0cae0dd6628582324155db35d7bfbd9..9f6d30141ef5899f5e3f2fb177460cdd95d42e45 100644 (file)
@@ -5,9 +5,9 @@
 { "Dhcp4":
 
 {
-// Kea is told to listen on ethX interface only.
+// Kea is told to listen on eth0 interface only.
   "interfaces-config": {
-    "interfaces": [ "ethX" ]
+    "interfaces": [ "eth0" ]
   },
 
 
@@ -61,9 +61,9 @@
        "type": "postgresql",
        "reconnect-wait-time": 3000, // expressed in ms
        "max-reconnect-tries": 3,
-       "name": "kea",
-       "user": "kea",
-       "password": "kea",
+       "name": "keatest",
+       "user": "keatest",
+       "password": "keatest",
        "host": "localhost"
     }
   ],
@@ -77,7 +77,7 @@
     {
        "pools": [ { "pool":  "192.0.2.10 - 192.0.2.200" } ],
        "subnet": "192.0.2.0/24",
-       "interface": "ethX",
+       "interface": "eth0",
        "id": 1
     }
   ],
index 2e25c51c4ea40f0f0f15554ed241d701c02c26d3..c00a8e9c0c3742956ad392ea971b303a1dce4e28 100644 (file)
@@ -4,9 +4,9 @@
 { "Dhcp4":
 
 {
-// Kea is told to listen on ethX interface only.
+// Kea is told to listen on eth0 interface only.
   "interfaces-config": {
-    "interfaces": [ "ethX" ]
+    "interfaces": [ "eth0" ]
   },
 
 // We need to specify the database used to store leases. As of April
 // Note: flexible identifier requires flex_id hook library to be
 // loaded to work.
         {
-            "flex-id": "s0mEVaLue",
+            "flex-id": "'s0mEVaLue'",
             "ip-address": "192.0.2.206"
         }
 
index bfa58e4e47f00c93230b63255b8810e52d0e018b..5fb05112649437fcf88cb08bdfae867032e827bf 100644 (file)
@@ -5,9 +5,9 @@
 { "Dhcp4":
 
 {
-// Kea is told to listen on ethX interface only.
+// Kea is told to listen on eth0 interface only.
   "interfaces-config": {
-    "interfaces": [ "ethX" ]
+    "interfaces": [ "eth0" ]
   },
 
 // We need to specify the database used to store leases. As of
index a8272623201ac48ae2eebb1d9d1a0f2547096cec..9f38ee8c87f07da868e30d56ab37e4765042d4d1 100644 (file)
@@ -11,7 +11,7 @@
         // As with any other configuration, you need to tell Kea the interface
         // names, so it would listen to incoming traffic.
         "interfaces-config": {
-            "interfaces": [ "ethX" ]
+            "interfaces": [ "eth0" ]
         },
 
         // You also need to tell where to store lease information.
index 65a6e6c14986c2041e28a06e945826383f85a39c..3fa6dfb1ee151edc0a535c797fbb33f94dbeb89b 100644 (file)
@@ -5,9 +5,9 @@
 { "Dhcp4":
 
 {
-// Kea is told to listen on ethX interface only.
+// Kea is told to listen on eth0 interface only.
   "interfaces-config": {
-    "interfaces": [ "ethX" ]
+    "interfaces": [ "eth0" ]
   },
 
 // We need to specify the database used to store leases. As of
@@ -35,7 +35,7 @@
     {
        "pools": [ { "pool":  "192.0.2.1 - 192.0.2.200" } ],
        "subnet": "192.0.2.0/24",
-       "interface": "ethX"
+       "interface": "eth0"
     }
   ],
 
index 64b23b50a311fc53490dafa12b68968da09bedc4..431c04ec292a64e5a0c411b9be4014b4522dfcd5 100644 (file)
@@ -70,9 +70,9 @@
                 ]
             }
         ],
-// Kea is told to listen on ethX interface only.
+// Kea is told to listen on eth0 interface only.
         "interfaces-config": {
-            "interfaces": ["ethX"]
+            "interfaces": ["eth0"]
         },
 // We need to specify the database used to store leases.
         "lease-database": {
@@ -82,7 +82,7 @@
 // here. We tell Kea that it is directly available over local interface.
         "subnet4": [
             {
-                "interface": "ethX",
+                "interface": "eth0",
                 "pools": [
                     {
                         "pool": "192.0.2.50-192.0.2.50"
index 12adc95b25023476e271e75bfa32fa9327e93fa3..fe1ccec2f5ba6c391963a8dbf54d1bbf259fd114 100644 (file)
                 ]
             }
         ],
-// Kea is told to listen on ethX interface only.
+// Kea is told to listen on eth0 interface only.
         "interfaces-config": {
             "interfaces": [
-                "ethX"
+                "eth0"
             ]
         },
 // We need to specify the database used to store leases.
@@ -76,7 +76,7 @@
 // here. We tell Kea that it is directly available over local interface.
         "subnet4": [
             {
-                "interface": "ethX",
+                "interface": "eth0",
                 "pools": [
                     {
                         "pool": "192.0.2.50-192.0.2.50"
index 5460d6f5b0d6fed4b0f80c71193e4054bf6c3a18..ee47c6270484f254a537d70bcb74565e4bcdd4b5 100644 (file)
@@ -5,9 +5,9 @@
 { "Dhcp4":
 
 {
-// Kea is told to listen on ethX interface only.
+// Kea is told to listen on eth0 interface only.
   "interfaces-config": {
-    "interfaces": [ "ethX" ]
+    "interfaces": [ "eth0" ]
   },
 
 // We need to specify the database used to store leases. As of
@@ -35,7 +35,7 @@
     {
        "pools": [ { "pool":  "192.0.2.1 - 192.0.2.200" } ],
        "subnet": "192.0.2.0/24",
-       "interface": "ethX"
+       "interface": "eth0"
     }
   ],
 
index 5d85adf41cf8006d2d6ee31614dcc5457dd6f550..7704f8df2b4fb3dfd14be75acc05cab33938dc05 100644 (file)
@@ -2,7 +2,7 @@
 // It attempts to showcase some of the more advanced features.
 // Topology wise, it's a basic scenario with one IPv6 subnet configured.
 // It is assumed that one subnet (2001:db8:1::/64) is available directly
-// over ethX interface.
+// over eth0 interface.
 //
 // The following features are currently showcased here:
 // 1. Configuration of MAC/hardware address sources in DHCPv6
@@ -14,9 +14,9 @@
 { "Dhcp6":
 
 {
-    // Kea is told to listen on ethX network interface only.
+    // Kea is told to listen on eth0 network interface only.
     "interfaces-config": {
-        "interfaces": [ "ethX" ],
+        "interfaces": [ "eth0" ],
 
         // This makes interfaces to be re-detected at each (re-)configuration.
         // By default it is true.
             "prefix": "2001:db8:abcd::",
             "prefix-len": 48,
             "delegated-len": 64,
-            "excluded-prefix": "2001:db8:abcd:1234::",
-            "excluded-prefix-len": 72,
+            "excluded-prefix": "2001:db8:abcd:0:1234::",
+            "excluded-prefix-len": 80,
 
             // Another user-context for this PD pool. Again, you can put
             // anything you want in there as long as it's valid JSON and
         ], // end of pools
 
         "subnet": "2001:db8:1::/64",
-        "interface": "ethX",
+        "interface": "eth0",
 
         // Sometimes the relay may use an odd IPv6 address that's not matching
         // the subnet. This is discouraged, but there are valid cases when it
index 6712be2e1106f2242800ac0cd0a1169bb20529da..cce7e8ec37458e827ebb25094ebd73554466547d 100644 (file)
         "hosts-databases": [
             {
                 // Name of the database to connect to.
-                "name": "kea",
+                "name": "keatest",
 
                 // Host on which the database resides.
                 "host": "localhost",
 
                 // Database password.
-                "password": "kea",
+                "password": "keatest",
 
                 // Port on which the database is available.
                 "port": 3306,
                 "type": "mysql",
 
                 // User name to be used to access the database.
-                "user": "kea",
+                "user": "keatest",
 
                 // Read only mode.
                 "readonly": false,
             },
             {
                 // Name of the database to connect to.
-                "name": "kea",
+                "name": "keatest",
 
                 // Host on which the database resides.
                 "host": "localhost",
 
                 // Database password.
-                "password": "kea",
+                "password": "keatest",
 
                 // Port on which the database is available.
                 "port": 5432,
                 "type": "postgresql",
 
                 // User name to be used to access the database.
-                "user": "kea",
+                "user": "keatest",
 
                 // Connection reconnect wait time.
                 // This parameter governs how long Kea waits before attempting
             // Specifies a list of interfaces on which the Kea DHCPv6
             // server should listen to the DHCP requests.
             "interfaces": [
-                "ethX"
+                "eth0"
             ],
 
             // Boolean flag indicating if the available interfaces should
 
                 // Specifies that this shared network is selected for the
                 // requests received on the particular interface.
-                "interface": "ethX",
+                "interface": "eth0",
 
                 // Specifies the content of the interface-id option used
                 // by relays to identify the interface on the relay to
 
                         // Specifies that this subnet is selected for the requests
                         // received on the particular interface.
-                        "interface": "ethX",
+                        "interface": "eth0",
 
                         // Specifies the content of the interface-id option used
                         // by relays to identify the interface on the relay to
index c3437d04249b2d6968783bfea4c52cbbe66586a6..c9e251210d7da08493ba381a3795b9378625cf22 100644 (file)
         "hosts-databases": [
             {
                 // Name of the database to connect to.
-                "name": "kea",
+                "name": "keatest",
 
                 // Host on which the database resides.
                 "host": "localhost",
 
                 // Database password.
-                "password": "kea",
+                "password": "keatest",
 
                 // Port on which the database is available.
                 "port": 3306,
                 "type": "mysql",
 
                 // User name to be used to access the database.
-                "user": "kea",
+                "user": "keatest",
 
                 // Read only mode.
                 "readonly": false,
             },
             {
                 // Name of the database to connect to.
-                "name": "kea",
+                "name": "keatest",
 
                 // Host on which the database resides.
                 "host": "localhost",
 
                 // Database password.
-                "password": "kea",
+                "password": "keatest",
 
                 // Port on which the database is available.
                 "port": 5432,
                 "type": "postgresql",
 
                 // User name to be used to access the database.
-                "user": "kea"
+                "user": "keatest"
             },
             {
+                // Name of the database to connect to.
+                "name": "keatest",
+
                 // Database password.
-                "password": "kea",
+                "password": "keatest",
 
                 // Port on which the database is available.
                 "port": 9042,
                 "type": "mysql",
 
                 // User name to be used to access the database.
-                "user": "kea",
+                "user": "keatest",
 
                 // Connection reconnect wait time.
                 // This parameter governs how long Kea waits before attempting
             // Specifies a list of interfaces on which the Kea DHCPv6
             // server should listen to the DHCP requests.
             "interfaces": [
-                "ethX"
+                "eth0"
             ],
 
             // Boolean flag indicating if the available interfaces should
 
                 // Specifies that this shared network is selected for the
                 // requests received on the particular interface.
-                "interface": "ethX",
+                "interface": "eth0",
 
                 // Specifies the content of the interface-id option used
                 // by relays to identify the interface on the relay to
 
                         // Specifies that this subnet is selected for the requests
                         // received on the particular interface.
-                        "interface": "ethX",
+                        "interface": "eth0",
 
                         // Specifies the content of the interface-id option used
                         // by relays to identify the interface on the relay to
index 148a5834a4e3142e798df3a0f1c79dc525f09845..7e16244877fb48da081f21196fa94b824e122527 100644 (file)
@@ -8,9 +8,9 @@
 { "Dhcp6":
 
 {
-// Kea is told to listen on ethX interface only.
+// Kea is told to listen on eth0 interface only.
   "interfaces-config": {
-    "interfaces": [ "ethX" ]
+    "interfaces": [ "eth0" ]
   },
 
 // We need to specify lease type. Exactly one lease-database section
@@ -82,7 +82,7 @@
     {
       "pools": [ { "pool": "2001:db8:1::/80" } ],
       "subnet": "2001:db8:1::/64",
-      "interface": "ethX"
+      "interface": "eth0"
     }
   ],
 
index 47e1e37ee855d2bfde98dfdc699e83490367865f..a5fc2e98a0166996caab96d63d0d400c89f8eb7a 100644 (file)
@@ -4,9 +4,9 @@
 { "Dhcp6":
 
 {
-// Kea is told to listen on ethX interface only.
+// Kea is told to listen on eth0 interface only.
   "interfaces-config": {
-    "interfaces": [ "ethX" ]
+    "interfaces": [ "eth0" ]
   },
 
 // Let's use the simplest backend: memfile and use some reasonable values
 // One packet can belong to zero or more classes.
   "client-classes": [
 
-// The first class attempts to match all packets coming in on ethX interface.
+// The first class attempts to match all packets coming in on eth0 interface.
   {
       "name": "lab",
-      "test": "pkt.iface == 'ethX'",
+      "test": "pkt.iface == 'eth0'",
       "option-data": [{
           "name": "dns-servers",
           "data": "2001:db8::1"
@@ -59,7 +59,7 @@
         "pools": [ { "pool": "2001:db8:1::/80" } ],
         "subnet": "2001:db8:1::/64",
         "client-class": "cable-modems",
-        "interface": "ethX"
+        "interface": "eth0"
     },
 
     // The following subnet contains a class reservation for a client using
@@ -73,7 +73,7 @@
             "duid": "01:02:03:04:05:0A:0B:0C:0D:0E",
             "client-classes": [ "cable-modems" ]
         } ],
-        "interface": "ethX"
+        "interface": "eth0"
     },
 
     // The following subnet contains a pool with a class constraint: only
     {
         "pools": [
            {
-               "pool": "2001:db8:3::/80",
+               "pool": "2001:db8:4::/80",
                "client-class": "cable-modems"
            } ],
          "subnet": "2001:db8:4::/64",
-         "interface": "ethY"
+         "interface": "eth1"
     }
 
   ],
index be3a071afdf7427f7f02b7d687c5178c1f37e2ea..474c3932b1cf65a88ab6a7b749093575b8734265 100644 (file)
@@ -4,9 +4,9 @@
 { "Dhcp6":
 
 {
-// Kea is told to listen on ethX interface only.
+// Kea is told to listen on eth0 interface only.
   "interfaces-config": {
-    "interfaces": [ "ethX" ]
+    "interfaces": [ "eth0" ]
   },
 
 // Let's use the simplest backend: memfile and use some reasonable values
@@ -70,7 +70,7 @@
         "pools": [ { "pool": "2001:db8:1::/80" } ],
         "subnet": "2001:db8:1::/64",
         "client-class": "cable-modems",
-        "interface": "ethX"
+        "interface": "eth0"
     },
 // The following subnet contains a class reservation for a client using
 // DUID 01:02:03:04:05:0A:0B:0C:0D:0E. This client will always be assigned
@@ -83,7 +83,7 @@
             "duid": "01:02:03:04:05:0A:0B:0C:0D:0E",
             "client-classes": [ "cable-modems" ]
         } ],
-        "interface": "ethX",
+        "interface": "eth0",
         "require-client-classes": [ "second_subnet" ]
     },
 // The following subnet contains a pool with a class constraint: only
     {
         "pools": [
            {
-               "pool": "2001:db8:3::/80",
+               "pool": "2001:db8:4::/80",
                "client-class": "cable-modems"
            } ],
          "subnet": "2001:db8:4::/64",
-         "interface": "ethY"
+         "interface": "eth1"
     },
 // This subnet is divided in two pools for unknown and known
 // (i.e. which have a reservation) clients. The built-in KNOWN and
 // UNKNOWN classes are set or not at host reservation lookup (KNOWN if
 // this returns something, UNKNOWN if this finds nothing) and client
-//classes depending on it are evaluated.
+// classes depending on it are evaluated.
 // This happens after subnet selection and before address allocation
-//from pools.
+// from pools.
     {
         "pools": [
             {
index 815fe582f77eb6e3cd57a9e658929ece76bbd415..eca306d924a9dac8e0c2501f3ba907d3318d7f64 100644 (file)
@@ -11,9 +11,9 @@
     // either "all" or "server2" will be used by this instance.
     "server-tag": "server2",
 
-    // Kea is told to listen on ethX interface only.
+    // Kea is told to listen on eth0 interface only.
     "interfaces-config": {
-        "interfaces": [ "ethX" ]
+        "interfaces": [ "eth0" ]
     },
 
     // Use memfile lease database backend.
index c2e6ad3dfbb31f11f0e26aed3a7292c142d7372b..68d567532377ab4b39c283a58a15c294b01e0cc0 100644 (file)
@@ -8,7 +8,7 @@
 {
   "interfaces-config": {
 // Enable unicast
-    "interfaces": [ "eno33554984/2001:db8:1:1::1" ]
+    "interfaces": [ "eth0/2001:db8:1::1" ]
   },
 
   "lease-database": {
@@ -23,7 +23,7 @@
 
   "subnet6": [
    {   "subnet": "2001:db8:1:1::/64",
-       "interface": "eno33554984",
+       "interface": "eth0",
        "pools": [ { "pool": "2001:db8:1:1::1:0/112" } ] }
    ],
 
index 5265606a4234073cfe582f717aa7349da2b79b9c..0c00c74e94b0cca22921f7f8b424918e1a19b9eb 100644 (file)
@@ -25,9 +25,9 @@
     "htype": 1
   },
 
-// Kea is told to listen on ethX interface only.
+// Kea is told to listen on eth0 interface only.
   "interfaces-config": {
-    "interfaces": [ "ethX" ]
+    "interfaces": [ "eth0" ]
   },
 
 // We need to specify the database used to store leases. As of
@@ -56,7 +56,7 @@
     {
       "pools": [ { "pool": "2001:db8:1::/80" } ],
       "subnet": "2001:db8:1::/64",
-      "interface": "ethX"
+      "interface": "eth0"
     }
   ],
 
index db99beb48e0431092fb98ec4440604e4b4691004..872a0e2ce5cff69dae8e161d29c94c4757f32b6b 100644 (file)
@@ -9,9 +9,9 @@
 { "Dhcp6":
 
 {
-// Kea is told to listen on ethX interface only.
+// Kea is told to listen on eth0 interface only.
   "interfaces-config": {
-    "interfaces": [ "ethX" ]
+    "interfaces": [ "eth0" ]
   },
 
 // We need to specify the database used to store leases. As of
                     "delegated-len": 64
                 }
             ],
-            "interface": "ethX"
+            "interface": "eth0"
         }
     ],
 
index 9675e6f7d5d356a6f7e329083c01a54e33134a73..a0752d5e4d6da39cedf7c4cf5b431899e3ded4b8 100644 (file)
@@ -10,9 +10,9 @@
 { "Dhcp6":
 
 {
-// Kea is told to listen on ethX interface only.
+// Kea is told to listen on eth0 interface only.
     "interfaces-config": {
-        "interfaces": [ "ethX" ]
+        "interfaces": [ "eth0" ]
     },
 
     // Control socket is required for communication between the Control
                 }
              ],
 
-             "interface": "ethX"
+             "interface": "eth0"
     }
   ],
 
index a930e2e9ba98f06671c4d3858904651f12facd54..60fc89823546e29edc7b206b6c383a5ca376e92f 100644 (file)
@@ -5,9 +5,9 @@
 {"Dhcp6":
 
 {
-// Kea is told to listen on the ethX interface only.
+// Kea is told to listen on the eth0 interface only.
   "interfaces-config": {
-    "interfaces": [ "ethX" ]
+    "interfaces": [ "eth0" ]
   },
 
 // Set up the storage for leases.
@@ -30,7 +30,7 @@
           "user-context": { "charging": true }
         } ],
       "subnet": "2001:db8:1::/64",
-      "interface": "ethX"
+      "interface": "eth0"
     }
   ],
 
index 9d38c4c4e0690dc1d2e88b9673f27c08c55ac502..601ad6f82462eaf1918e1641ecffe5b18bc2be17 100644 (file)
@@ -5,7 +5,7 @@
    // Mandatory part of the config that list interfaces on which
    // Kea will listen for incoming traffic.
       "interfaces-config": {
-         "interfaces": [ "ethX" ]
+         "interfaces": [ "eth0" ]
       },
 
 // Two classes are migrated form ISC-DHCP example:
index a20d5e126f4d4fb2ba32427f307c94c85074dabe..5a3eeb4290c7be4a0465b2ebfa25aa2967c46cef 100644 (file)
@@ -5,9 +5,9 @@
 { "Dhcp6":
 
 {
-// Kea is told to listen on ethX interface only.
+// Kea is told to listen on eth0 interface only.
   "interfaces-config": {
-    "interfaces": [ "ethX" ]
+    "interfaces": [ "eth0" ]
   },
 
 // We need to specify the database used to store leases. As of
@@ -57,7 +57,7 @@
     {
       "pools": [ { "pool": "2001:db8:1::/80" } ],
       "subnet": "2001:db8:1::/64",
-      "interface": "ethX"
+      "interface": "eth0"
     }
   ],
 
index a22559e67fe623c80e920d3a67a7f1ea75f58be5..b6d8be857cdbfdb64e891b1a566e9200ae6f16b7 100644 (file)
@@ -4,9 +4,9 @@
 { "Dhcp6":
 
 {
-// Kea is told to listen on ethX interface only.
+// Kea is told to listen on eth0 interface only.
   "interfaces-config": {
-    "interfaces": [ "ethX" ]
+    "interfaces": [ "eth0" ]
   },
 
 // We need to specify the database used to store leases. As of
          }
       ],
       "subnet": "2001:db8:1::/64",
-      "interface": "ethX"
+      "interface": "eth0"
     }
   ],
 
index 0553dad2e5d1a28c955c2b2c5522e4e4470d01f6..769c111a71d40c2a56c7215a06552d041eb3d0c1 100644 (file)
@@ -5,9 +5,9 @@
 { "Dhcp6":
 
 {
-// Kea is told to listen on ethX interface only.
+// Kea is told to listen on eth0 interface only.
   "interfaces-config": {
-    "interfaces": [ "ethX" ]
+    "interfaces": [ "eth0" ]
   },
 
 // We need to specify the database used to store leases. As of
@@ -46,9 +46,9 @@
     "type": "mysql",
     "reconnect-wait-time": 3000, // expressed in ms
     "max-reconnect-tries": 3,
-    "name": "kea",
-    "user": "kea",
-    "password": "kea",
+    "name": "keatest",
+    "user": "keatest",
+    "password": "keatest",
     "host": "localhost",
     "port": 3306,
     "readonly": true,
@@ -76,7 +76,7 @@
               "delegated-len": 64
           }
       ],
-      "interface": "ethX",
+      "interface": "eth0",
       "id": 1
     }
   ],
index e27d4d5157a9529c50191e33e40dedc3455e3d87..c7e204c3901c37b675e0d5c7e8471877a0f0ed35 100644 (file)
@@ -5,9 +5,9 @@
 { "Dhcp6":
 
 {
-// Kea is told to listen on ethX interface only.
+// Kea is told to listen on eth0 interface only.
   "interfaces-config": {
-    "interfaces": [ "ethX" ]
+    "interfaces": [ "eth0" ]
   },
 
 // We need to specify the database used to store leases. As of
@@ -48,9 +48,9 @@
        "type": "postgresql",
        "reconnect-wait-time": 3000, // expressed in ms
        "max-reconnect-tries": 3,
-       "name": "kea",
-       "user": "kea",
-       "password": "kea",
+       "name": "keatest",
+       "user": "keatest",
+       "password": "keatest",
        "host": "localhost"
     }
   ],
@@ -73,7 +73,7 @@
               "delegated-len": 64
           }
       ],
-      "interface": "ethX",
+      "interface": "eth0",
       "id": 1
     }
   ],
index 252b5410b5d5edaa335a2912076f9646cb8a5e7b..f18ba62961eacb5af9cac4602e9c7a7c4969e643 100644 (file)
@@ -1,15 +1,15 @@
 // This is an example configuration file for DHCPv6 server in Kea
 // that showcases how to do host reservations. It is
 // assumed that one subnet (2001:db8:1::/64) is available directly
-// over ethX interface. A number of hosts have various combinations
+// over eth0 interface. A number of hosts have various combinations
 // of addresses and prefixes reserved for them.
 
 { "Dhcp6":
 
 {
-// Kea is told to listen on ethX interface only.
+// Kea is told to listen on eth0 interface only.
   "interfaces-config": {
-    "interfaces": [ "ethX" ]
+    "interfaces": [ "eth0" ]
   },
 
 // We need to specify the database used to store leases. As of
@@ -74,7 +74,7 @@
               "delegated-len": 64
           }
         ],
-        "interface": "ethX",
+        "interface": "eth0",
 
 // Host reservations. Define several reservations, note that
 // they are all within the range of the pool of the dynamically
index 5891836f351a372593dd082d28e953d3a806480c..78bb066b807403de03452c69109c869770206241 100644 (file)
@@ -5,9 +5,9 @@
 { "Dhcp6":
 
 {
-// Kea is told to listen on ethX interface only.
+// Kea is told to listen on eth0 interface only.
   "interfaces-config": {
-    "interfaces": [ "ethX" ]
+    "interfaces": [ "eth0" ]
   },
 
 // We need to specify the database used to store leases. As of
index 0dd5edc593a3c1f186f269ca940a8f94ce098c09..5666e014a537db76c3c78fd6e0df7d8ddd991cdf 100644 (file)
@@ -8,9 +8,9 @@
 // initial proposal was not best and way to migrate to something else.
 {
     "Dhcp6": {
-        // Kea is told to listen on ethX interface only.
+        // Kea is told to listen on eth0 interface only.
         "interfaces-config": {
-            "interfaces": [ "ethX" ]
+            "interfaces": [ "eth0" ]
         },
 
         // You also need to tell where to store lease information.
@@ -29,7 +29,7 @@
             {
                 "pools": [ { "pool": "2001:db8:2::/80" } ],
                 "subnet": "2001:db8:2::/64",
-                "interface": "ethX"
+                "interface": "eth0"
             }
         ],
 
                     // Ignored when reservations-in-subnet is false.
                     "reservations-out-of-pool": false,
                     "subnet": "2001:db8:1::/64",
-                    "pools": [ { "pool": "2001:db8:1:abcd::/64" } ],
+                    "pools": [ { "pool": "2001:db8:1:0:abcd::/80" } ],
                     "valid-lifetime": 40
                 },
 
index 83953a112d35247ce001dba3fda9b72442952ade..acd3499b653e1368cda43d5041dca114216100ae 100644 (file)
@@ -1,14 +1,14 @@
 // This is an example configuration file for DHCPv6 server in Kea.
 // It's a basic scenario with one IPv6 subnet configured. It is
 // assumed that one subnet (2001:db8:1::/64 is available directly
-// over ethX interface.
+// over eth0 interface.
 
 { "Dhcp6":
 
 {
-// Kea is told to listen on ethX interface only.
+// Kea is told to listen on eth0 interface only.
   "interfaces-config": {
-    "interfaces": [ "ethX" ]
+    "interfaces": [ "eth0" ]
   },
 
 // We need to specify the database used to store leases. As of
@@ -37,7 +37,7 @@
     {
       "pools": [ { "pool": "2001:db8:1::/80" } ],
       "subnet": "2001:db8:1::/64",
-      "interface": "ethX"
+      "interface": "eth0"
     }
   ],
 
index 4881b845d87b4aea6b111369fdf8ee0e2a217746..85d1d0cdde826a3648788f957c9744dc070978f0 100644 (file)
@@ -5,9 +5,9 @@
 { "Dhcp6":
 
 {
-// Kea is told to listen on ethX interface only.
+// Kea is told to listen on eth0 interface only.
   "interfaces-config": {
-    "interfaces": [ "ethX" ]
+    "interfaces": [ "eth0" ]
   },
 
 // Let's use a Memfile backend to store leases.
@@ -32,7 +32,7 @@
     {
       "pools": [ { "pool": "2001:db8:1::/80" } ],
       "subnet": "2001:db8:1::/64",
-      "interface": "ethX",
+      "interface": "eth0",
 // Include MAP-E Container option for hosts connected to this subnet.
       "option-data": [
         {
index c71546d6a02c29960bd897369a9a47f45952f641..bbe1a84de4c6b2abb054718c1f70403249b3bcfa 100644 (file)
@@ -8,7 +8,7 @@
 {
 "Dhcp6": {
     "interfaces-config": {
-        "interfaces": [ "ethX" ]
+        "interfaces": [ "eth0" ]
     },
 
 // This is the list of options that will be granted to all clients that ask.
index d3b969adc786d71dac1b33a4fda2cbaae8998596..e6a21af256b5e3d88bd2bbad0cb5d34d607b4a35 100644 (file)
@@ -5,9 +5,9 @@
 { "Dhcp6":
 
 {
-// Kea is told to listen on ethX interface only.
+// Kea is told to listen on eth0 interface only.
   "interfaces-config": {
-    "interfaces": [ "ethX" ]
+    "interfaces": [ "eth0" ]
   },
 
 // We need to specify the database used to store leases. As of
index e611d5112396a48364b63a6755194cc555f2c398..04efb7d313a580798871b2e56946db70ab80c364 100644 (file)
@@ -1,14 +1,14 @@
 // This is an example configuration file for DHCPv6 server in Kea.
 // It's a basic scenario with one IPv6 subnet configured. It is
 // assumed that one subnet (2001:db8:1::/64 is available directly
-// over ethX interface.
+// over eth0 interface.
 
 { "Dhcp6":
 
 {
-// Kea is told to listen on ethX interface only.
+// Kea is told to listen on eth0 interface only.
   "interfaces-config": {
-    "interfaces": [ "ethX" ]
+    "interfaces": [ "eth0" ]
   },
 
 // We need to specify the database used to store leases. As of
@@ -37,7 +37,7 @@
     {
       "pools": [ { "pool": "2001:db8:1::/80" } ],
       "subnet": "2001:db8:1::/64",
-      "interface": "ethX"
+      "interface": "eth0"
     }
   ],
 
index 6b62f0af02d3992440cc27a2538555b0bb62189d..bddf8ae9a5df7f4022da8b9974c3ac6b03120a7d 100644 (file)
@@ -198,7 +198,7 @@ ConstElementPtr
 ControlledDhcpv4Srv::commandShutdownHandler(const string&, ConstElementPtr args) {
     if (!ControlledDhcpv4Srv::getInstance()) {
         LOG_WARN(dhcp4_logger, DHCP4_NOT_RUNNING);
-        return(createAnswer(CONTROL_RESULT_ERROR, "Shutdown failure."));
+        return (createAnswer(CONTROL_RESULT_ERROR, "Shutdown failure."));
     }
 
     int exit_value = 0;
index 688947f526c090bc3f036e444d2e7c071deee359..a2d9da3547b31094a98dbe3f6256f5849fd54edc 100644 (file)
@@ -566,7 +566,7 @@ ControlCharacterFill            [^"\\]|\\["\\/bfnrtu]
     case isc::dhcp::Parser4Context::LEASE_DATABASE:
         return isc::dhcp::Dhcp4Parser::make_MAX_ROW_ERRORS(driver.loc_);
     default:
-        return isc::dhcp::Dhcp4Parser::make_STRING("max_row_errors", driver.loc_);
+        return isc::dhcp::Dhcp4Parser::make_STRING("max-row-errors", driver.loc_);
     }
 }
 
index 03e34025c2f5e01dc6cd0caed6cef8f358552cc2..4816fccc4ada74656c4bc54b0018354ab325f461 100644 (file)
@@ -538,8 +538,8 @@ configureDhcp4Server(Dhcpv4Srv& server, isc::data::ConstElementPtr config_set,
         if (hosts_databases) {
             parameter_name = "hosts-databases";
             CfgDbAccessPtr cfg_db_access = srv_config->getCfgDbAccess();
-            db::DbAccessParser parser;
             for (auto it : hosts_databases->listValue()) {
+                db::DbAccessParser parser;
                 std::string access_string;
                 parser.parse(access_string, it);
                 cfg_db_access->setHostDbAccessString(access_string);
index b5e0924714550d357896f4f4337077a4af4b59eb..0497e5edf056a5fc04caf968885041f9ee82ae61 100644 (file)
@@ -10,6 +10,7 @@
 #include <asiolink/io_address.h>
 #include <cc/command_interpreter.h>
 #include <config/command_mgr.h>
+#include <config_backend/base_config_backend.h>
 #include <dhcp4/tests/dhcp4_test_utils.h>
 #include <dhcp4/tests/dhcp4_client.h>
 #include <dhcp/tests/pkt_captures.h>
@@ -39,6 +40,7 @@
 
 #include <iostream>
 #include <cstdlib>
+#include <dirent.h>
 
 #include <arpa/inet.h>
 
@@ -47,6 +49,7 @@ using namespace isc;
 using namespace isc::dhcp;
 using namespace isc::data;
 using namespace isc::asiolink;
+using namespace isc::cb;
 using namespace isc::config;
 using namespace isc::dhcp::test;
 using namespace isc::util;
@@ -145,7 +148,6 @@ void checkStringInBuffer( const std::string& exp_string, const OptionBuffer& buf
     EXPECT_EQ(exp_string, std::string(buffer_string.c_str()));
 }
 
-
 // This test verifies that the destination address of the response
 // message is set to giaddr, when giaddr is set to non-zero address
 // in the received message.
@@ -354,7 +356,6 @@ TEST_F(Dhcpv4SrvTest, adjustIfaceDataUseRouting) {
     // The local port is always DHCPv4 server port 67.
     EXPECT_EQ(DHCP4_SERVER_PORT, resp->getLocalPort());
 
-
     // No specific interface is selected as outbound interface and no specific
     // local address is provided. The IfaceMgr will figure out which interface to use.
     EXPECT_TRUE(resp->getLocalAddr().isV4Zero());
@@ -759,7 +760,6 @@ TEST_F(Dhcpv4SrvTest, adjustIfaceDataBroadcast) {
     // query has been received.
     EXPECT_EQ("eth1", resp->getIface());
     EXPECT_EQ(ETH1_INDEX, resp->getIndex());
-
 }
 
 // This test verifies that the destination address of the response message
@@ -1066,7 +1066,6 @@ TEST_F(Dhcpv4SrvTest, sanityCheckDecline) {
                     "Mandatory 'Requested IP address' option missing in DHCPDECLINE"
                     " sent from [hwtype=1 00:fe:fe:fe:fe:fe], cid=[no info], tid=0x4d2");
 
-
     // Now let's add a requested address. This should not throw.
     OptionDefinitionPtr req_addr_def = LibDHCP::getOptionDef(DHCP4_OPTION_SPACE,
                                                              DHO_DHCP_REQUESTED_ADDRESS);
@@ -1437,7 +1436,6 @@ TEST_F(Dhcpv4SrvTest, DiscoverTimers) {
                                (*test).exp_t1_, (*test).exp_t2_);
         }
     }
-
 }
 
 // Check that option 58 and 59 are included when calculate-tee-times
@@ -1579,7 +1577,6 @@ TEST_F(Dhcpv4SrvTest, calculateTeeTimers) {
     }
 }
 
-
 // This test verifies that incoming DISCOVER can be handled properly, that an
 // OFFER is generated, that the response has an address and that address
 // really belongs to the configured pool.
@@ -1898,7 +1895,6 @@ TEST_F(Dhcpv4SrvTest, requestEchoClientId) {
     checkClientId(ack, clientid);
 }
 
-
 // This test verifies that incoming (positive) REQUEST/Renewing can be handled properly, that a
 // REPLY is generated, that the response has an address and that address
 // really belongs to the configured pool and that lease is actually renewed.
@@ -2776,6 +2772,106 @@ Dhcpv4SrvTest::portsServerPort() {
     EXPECT_EQ(srv.server_port_, offer->getLocalPort());
 }
 
+void
+Dhcpv4SrvTest::loadConfigFile(const string& path) {
+    CfgMgr::instance().clear();
+
+    LibDHCP::clearRuntimeOptionDefs();
+
+    IfaceMgrTestConfig test_config(true);
+
+    // Do not use DHCP4_SERVER_PORT here as 0 means don't open sockets.
+    NakedDhcpv4Srv srv(0);
+    EXPECT_EQ(0, srv.server_port_);
+
+    ConfigBackendDHCPv4Mgr::instance().registerBackendFactory("mysql",
+            [](const db::DatabaseConnection::ParameterMap&) -> ConfigBackendDHCPv4Ptr {
+                return (ConfigBackendDHCPv4Ptr());
+            });
+
+    ConfigBackendDHCPv4Mgr::instance().registerBackendFactory("postgresql",
+            [](const db::DatabaseConnection::ParameterMap&) -> ConfigBackendDHCPv4Ptr {
+                return (ConfigBackendDHCPv4Ptr());
+            });
+
+    // TimerMgr uses IO service to run asynchronous timers.
+    TimerMgr::instance()->setIOService(srv.getIOService());
+
+    // CommandMgr uses IO service to run asynchronous socket operations.
+    CommandMgr::instance().setIOService(srv.getIOService());
+
+    // LeaseMgr uses IO service to run asynchronous timers.
+    LeaseMgr::setIOService(srv.getIOService());
+
+    // HostMgr uses IO service to run asynchronous timers.
+    HostMgr::setIOService(srv.getIOService());
+
+    Parser4Context parser;
+    ConstElementPtr json;
+    ASSERT_NO_THROW(json = parser.parseFile(path, Parser4Context::PARSER_DHCP4));
+    ASSERT_TRUE(json);
+
+    // Check the logic next.
+    ConstElementPtr dhcp4 = json->get("Dhcp4");
+    ASSERT_TRUE(dhcp4);
+    ElementPtr mutable_config = boost::const_pointer_cast<Element>(dhcp4);
+    mutable_config->set(string("hooks-libraries"), Element::createList());
+    ASSERT_NO_THROW(Dhcpv4SrvTest::configure(dhcp4->str(), true, true, true, true));
+
+    LeaseMgrFactory::destroy();
+    HostMgr::create();
+
+    TimerMgr::instance()->unregisterTimers();
+
+    // Close the command socket (if it exists).
+    CommandMgr::instance().closeCommandSocket();
+
+    // CommandMgr uses IO service to run asynchronous socket operations.
+    CommandMgr::instance().setIOService(IOServicePtr());
+
+    // LeaseMgr uses IO service to run asynchronous timers.
+    LeaseMgr::setIOService(IOServicePtr());
+
+    // HostMgr uses IO service to run asynchronous timers.
+    HostMgr::setIOService(IOServicePtr());
+}
+
+void
+Dhcpv4SrvTest::checkConfigFiles() {
+    IfaceMgrTestConfig test_config(true);
+    string path = CFG_EXAMPLES;
+
+    DIR* dir = opendir(path.c_str());
+    if (!dir) {
+        return;
+    }
+
+    // Set of sorted files by name.
+    std::set<std::string> files;
+
+    for (struct dirent* dent = readdir(dir); dent; dent = readdir(dir)) {
+        std::string name(dent->d_name);
+        // Skip current and parent directory and files with no extension.
+        if (name.size() < (sizeof(".json") - 1)) {
+            continue;
+        }
+
+        // Skip non .json files.
+        if (name.substr(name.size() - (sizeof(".json") - 1)) != ".json") {
+            continue;
+        }
+        name = path + "/" + name;
+        files.emplace(name);
+    }
+
+    for (const auto& file: files) {
+        string label("Checking configuration from file: ");
+        label += file;
+        SCOPED_TRACE(label);
+        loadConfigFile(file);
+    }
+}
+
 } // end of isc::dhcp::test namespace
 } // end of isc::dhcp namespace
 } // end of isc namespace
@@ -2822,13 +2918,16 @@ TEST_F(Dhcpv4SrvTest, portsServerPortMultiTHreading) {
     portsServerPort();
 }
 
+TEST_F(Dhcpv4SrvTest, checkConfigFiles) {
+    checkConfigFiles();
+}
+
 /// @todo Implement tests for subnetSelect See tests in dhcp6_srv_unittest.cc:
 /// selectSubnetAddr, selectSubnetIface, selectSubnetRelayLinkaddr,
 /// selectSubnetRelayInterfaceId. Note that the concept of interface-id is not
 /// present in the DHCPv4, so not everything is applicable directly.
 /// See ticket #3057
 
-
 // Checks whether the server uses default (0.0.0.0) siaddr value, unless
 // explicitly specified
 TEST_F(Dhcpv4SrvTest, siaddrDefault) {
@@ -3823,7 +3922,6 @@ TEST_F(Dhcpv4SrvTest, privateOption) {
     query->addOption(opt2);
     query->getDeferredOptions().push_back(245);
 
-
     // Create and add a PRL option to the query
     OptionUint8ArrayPtr prl(new OptionUint8Array(Option::V4,
                                                  DHO_DHCP_PARAMETER_REQUEST_LIST));
@@ -3859,7 +3957,6 @@ TEST_F(Dhcpv4SrvTest, privateOption) {
     EXPECT_EQ(12345678, opt32->getValue());
 }
 
-
 // Checks effect of persistency (aka always-true) flag on the PRL
 TEST_F(Dhcpv4SrvTest, prlPersistency) {
     IfaceMgrTestConfig test_config(true);
index 1f0a0b571417ff3fc16782935b4a67ebdf71e06a..6916da5e780e4588be44c3f4faacd10c5c0cfbc7 100644 (file)
@@ -87,7 +87,6 @@ Dhcpv4SrvTest::Dhcpv4SrvTest()
 }
 
 Dhcpv4SrvTest::~Dhcpv4SrvTest() {
-
     // Make sure that we revert to default value
     CfgMgr::instance().clear();
 
@@ -301,8 +300,8 @@ Dhcpv4SrvTest::basicOptionsPresent(const Pkt4Ptr& pkt) {
                                             "dhcp-lease-time " << errmsg.str()));
 
     }
-    return (::testing::AssertionSuccess());
 
+    return (::testing::AssertionSuccess());
 }
 
 ::testing::AssertionResult
@@ -801,15 +800,19 @@ Dhcpv4SrvTest::buildCfgOptionTest(IOAddress expected_server_id,
 void
 Dhcpv4SrvTest::configure(const std::string& config,
                          const bool commit,
-                         const bool open_sockets) {
-    configure(config, srv_, commit, open_sockets);
+                         const bool open_sockets,
+                         const bool create_managers,
+                         const bool test) {
+    configure(config, srv_, commit, open_sockets, create_managers, test);
 }
 
 void
 Dhcpv4SrvTest::configure(const std::string& config,
                          NakedDhcpv4Srv& srv,
                          const bool commit,
-                         const bool open_sockets) {
+                         const bool open_sockets,
+                         const bool create_managers,
+                         const bool test) {
     setenv("KEA_LFC_EXECUTABLE", KEA_LFC_EXECUTABLE, 1);
     MultiThreadingCriticalSection cs;
     ConstElementPtr json;
@@ -818,8 +821,8 @@ Dhcpv4SrvTest::configure(const std::string& config,
     } catch (const std::exception& ex){
         // Fatal failure on parsing error
         FAIL() << "parsing failure:"
-                << "config:" << config << std::endl
-                << "error: " << ex.what();
+               << "config:" << config << std::endl
+               << "error: " << ex.what();
     }
 
     ConstElementPtr status;
@@ -831,18 +834,21 @@ Dhcpv4SrvTest::configure(const std::string& config,
     configureMultiThreading(multi_threading_, json);
 
     // Configure the server and make sure the config is accepted
-    EXPECT_NO_THROW(status = configureDhcp4Server(srv, json));
+    EXPECT_NO_THROW(status = configureDhcp4Server(srv, json, test));
     ASSERT_TRUE(status);
     int rcode;
     ConstElementPtr comment = config::parseAnswer(rcode, status);
-    ASSERT_EQ(0, rcode) << comment->stringValue();
+    ASSERT_EQ(0, rcode) << "configuration failed, test is broken: "
+        << comment->str();
 
     // Use specified lease database backend.
-    ASSERT_NO_THROW( {
-        CfgDbAccessPtr cfg_db = CfgMgr::instance().getStagingCfg()->getCfgDbAccess();
-        cfg_db->setAppendedParameters("universe=4");
-        cfg_db->createManagers();
-    } );
+    if (create_managers) {
+        ASSERT_NO_THROW( {
+            CfgDbAccessPtr cfg_db = CfgMgr::instance().getStagingCfg()->getCfgDbAccess();
+            cfg_db->setAppendedParameters("universe=4");
+            cfg_db->createManagers();
+        } );
+    }
 
     try {
         CfgMultiThreading::apply(CfgMgr::instance().getStagingCfg()->getDHCPMultiThreading());
index cb36bd8aebe182bcf3f229ec613b80f11f0566a1..fc20cb066efd1f05bc59a685343b19d24587c9c3 100644 (file)
@@ -6,7 +6,7 @@
 
 /// @file   dhcp4_test_utils.h
 ///
-/// @brief  This file contains utility classes used for DHCPv4 server testing
+/// @brief This file contains utility classes used for DHCPv4 server testing
 
 #ifndef DHCP4_TEST_UTILS_H
 #define DHCP4_TEST_UTILS_H
@@ -554,11 +554,16 @@ public:
     /// @param config String holding server configuration in JSON format.
     /// @param commit A boolean flag indicating if the new configuration
     /// should be committed (if true), or not (if false).
-    /// @param open_sockets  A boolean flag indicating if sockets should
+    /// @param open_sockets A boolean flag indicating if sockets should
     /// be opened (if true), or not (if false).
+    /// @param create_managers A boolean flag indicating if managers should be
+    /// recreated.
+    /// @param test A boolean flag which indicates if only testing config.
     void configure(const std::string& config,
                    const bool commit = true,
-                   const bool open_sockets = true);
+                   const bool open_sockets = true,
+                   const bool create_managers = true,
+                   const bool test = false);
 
     /// @brief Configure specified DHCP server using JSON string.
     ///
@@ -566,12 +571,17 @@ public:
     /// @param srv Instance of the server to be configured.
     /// @param commit A boolean flag indicating if the new configuration
     /// should be committed (if true), or not (if false).
-    /// @param open_sockets  A boolean flag indicating if sockets should
+    /// @param open_sockets A boolean flag indicating if sockets should
     /// be opened (if true), or not (if false).
+    /// @param create_managers A boolean flag indicating if managers should be
+    /// recreated.
+    /// @param test A boolean flag which indicates if only testing config.
     void configure(const std::string& config,
                    NakedDhcpv4Srv& srv,
                    const bool commit = true,
-                   const bool open_sockets = true);
+                   const bool open_sockets = true,
+                   const bool create_managers = true,
+                   const bool test = false);
 
     /// @brief Configure specified DHCP server using JSON string.
     ///
@@ -637,9 +647,17 @@ public:
     /// @brief Checks if client port can be overridden in packets being sent.
     void portsClientPort();
 
-    /// @brief  Checks if server port can be overridden in packets being sent.
+    /// @brief Checks if server port can be overridden in packets being sent.
     void portsServerPort();
 
+    /// @breif Check if example files contain valid configuration.
+    void checkConfigFiles();
+
+    /// @brief Check if the server configuration stored in file is valid.
+    ///
+    /// @param path The path to the configuration file.
+    void loadConfigFile(const std::string& path);
+
     /// @brief This function cleans up after the test.
     virtual void TearDown();
 
index 28c59ec21e498b1e33bcb88c4e4d55d427d061ac..f144f37a3b9562b7568dd2f3b174fadd78bd5ded 100644 (file)
@@ -201,7 +201,7 @@ ConstElementPtr
 ControlledDhcpv6Srv::commandShutdownHandler(const string&, ConstElementPtr args) {
     if (!ControlledDhcpv6Srv::getInstance()) {
         LOG_WARN(dhcp6_logger, DHCP6_NOT_RUNNING);
-        return(createAnswer(CONTROL_RESULT_ERROR, "Shutdown failure."));
+        return (createAnswer(CONTROL_RESULT_ERROR, "Shutdown failure."));
     }
 
     int exit_value = 0;
index d9128c3a4010a76b68336cf9a7e528730f696a50..48408aade1715ce832609f50bbf51acb3debeab5 100644 (file)
@@ -764,7 +764,7 @@ ControlCharacterFill            [^"\\]|\\["\\/bfnrtu]
     case isc::dhcp::Parser6Context::LEASE_DATABASE:
         return isc::dhcp::Dhcp6Parser::make_MAX_ROW_ERRORS(driver.loc_);
     default:
-        return isc::dhcp::Dhcp6Parser::make_STRING("max_row_errors", driver.loc_);
+        return isc::dhcp::Dhcp6Parser::make_STRING("max-row-errors", driver.loc_);
     }
 }
 
index 778c9a8e1039269519d8b24950fd5ee5fbd05d4f..07c975d4b1e52da47f194b321ea236dd4b837c85 100644 (file)
@@ -664,8 +664,8 @@ configureDhcp6Server(Dhcpv6Srv& server, isc::data::ConstElementPtr config_set,
         if (hosts_databases) {
             parameter_name = "hosts-databases";
             CfgDbAccessPtr cfg_db_access = srv_config->getCfgDbAccess();
-            db::DbAccessParser parser;
             for (auto it : hosts_databases->listValue()) {
+                db::DbAccessParser parser;
                 std::string access_string;
                 parser.parse(access_string, it);
                 cfg_db_access->setHostDbAccessString(access_string);
index f6d0eeef8165563731ca5a8022569f79b91381a9..5c9c3e48c0572ac4475c6070fe5bea53a0d56ee3 100644 (file)
@@ -7,6 +7,9 @@
 #include <config.h>
 
 #include <asiolink/io_address.h>
+#include <cc/command_interpreter.h>
+#include <config/command_mgr.h>
+#include <config_backend/base_config_backend.h>
 #include <dhcp/dhcp6.h>
 #include <dhcp/duid.h>
 #include <dhcp/option.h>
@@ -17,7 +20,6 @@
 #include <dhcp/option_int_array.h>
 #include <dhcp/option_string.h>
 #include <dhcp/iface_mgr.h>
-#include <dhcp6/json_config_parser.h>
 #include <dhcp/docsis3_option_defs.h>
 #include <dhcp/tests/iface_mgr_test_config.h>
 #include <dhcpsrv/cfgmgr.h>
@@ -25,6 +27,7 @@
 #include <dhcpsrv/lease_mgr_factory.h>
 #include <dhcpsrv/host_mgr.h>
 #include <dhcpsrv/utils.h>
+#include <dhcp6/json_config_parser.h>
 #include <util/buffer.h>
 #include <util/range_utilities.h>
 #include <util/encode/hex.h>
@@ -32,7 +35,6 @@
 #include <dhcp6/tests/dhcp6_test_utils.h>
 #include <dhcp6/tests/dhcp6_client.h>
 #include <dhcp/tests/pkt_captures.h>
-#include <cc/command_interpreter.h>
 
 #include <boost/pointer_cast.hpp>
 #include <boost/scoped_ptr.hpp>
 #include <fstream>
 #include <iostream>
 #include <sstream>
+#include <dirent.h>
 
 using namespace isc;
-using namespace isc::data;
 using namespace isc::asiolink;
+using namespace isc::cb;
+using namespace isc::config;
+using namespace isc::data;
 using namespace isc::dhcp;
 using namespace isc::dhcp::test;
 using namespace isc::util;
@@ -145,6 +150,118 @@ const char* CONFIGS[] = {
     "}"
 };
 
+} // namespace
+
+namespace isc {
+namespace dhcp {
+namespace test {
+
+void
+Dhcpv6SrvTest::loadConfigFile(const string& path) {
+    CfgMgr::instance().clear();
+
+    LibDHCP::clearRuntimeOptionDefs();
+
+    IfaceMgrTestConfig test_config(true);
+
+    // Do not use DHCP6_SERVER_PORT here as 0 means don't open sockets.
+    NakedDhcpv6Srv srv(0);
+    EXPECT_EQ(0, srv.server_port_);
+
+    ConfigBackendDHCPv6Mgr::instance().registerBackendFactory("mysql",
+            [](const db::DatabaseConnection::ParameterMap&) -> ConfigBackendDHCPv6Ptr {
+                return (ConfigBackendDHCPv6Ptr());
+            });
+
+    ConfigBackendDHCPv6Mgr::instance().registerBackendFactory("postgresql",
+            [](const db::DatabaseConnection::ParameterMap&) -> ConfigBackendDHCPv6Ptr {
+                return (ConfigBackendDHCPv6Ptr());
+            });
+
+    // TimerMgr uses IO service to run asynchronous timers.
+    TimerMgr::instance()->setIOService(srv.getIOService());
+
+    // CommandMgr uses IO service to run asynchronous socket operations.
+    CommandMgr::instance().setIOService(srv.getIOService());
+
+    // LeaseMgr uses IO service to run asynchronous timers.
+    LeaseMgr::setIOService(srv.getIOService());
+
+    // HostMgr uses IO service to run asynchronous timers.
+    HostMgr::setIOService(srv.getIOService());
+
+    Parser6Context parser;
+    ConstElementPtr json;
+    ASSERT_NO_THROW(json = parser.parseFile(path, Parser6Context::PARSER_DHCP6));
+    ASSERT_TRUE(json);
+
+    // Check the logic next.
+    ConstElementPtr dhcp6 = json->get("Dhcp6");
+    ASSERT_TRUE(dhcp6);
+    ElementPtr mutable_config = boost::const_pointer_cast<Element>(dhcp6);
+    mutable_config->set(string("hooks-libraries"), Element::createList());
+    ASSERT_NO_THROW(Dhcpv6SrvTest::configure(dhcp6->str(), true, true, true, true));
+
+    LeaseMgrFactory::destroy();
+    HostMgr::create();
+
+    TimerMgr::instance()->unregisterTimers();
+
+    // Close the command socket (if it exists).
+    CommandMgr::instance().closeCommandSocket();
+
+    // CommandMgr uses IO service to run asynchronous socket operations.
+    CommandMgr::instance().setIOService(IOServicePtr());
+
+    // LeaseMgr uses IO service to run asynchronous timers.
+    LeaseMgr::setIOService(IOServicePtr());
+
+    // HostMgr uses IO service to run asynchronous timers.
+    HostMgr::setIOService(IOServicePtr());
+}
+
+void
+Dhcpv6SrvTest::checkConfigFiles() {
+    IfaceMgrTestConfig test_config(true);
+    string path = CFG_EXAMPLES;
+
+    DIR* dir = opendir(path.c_str());
+    if (!dir) {
+        return;
+    }
+
+    // Set of sorted files by name.
+    std::set<std::string> files;
+
+    for (struct dirent* dent = readdir(dir); dent; dent = readdir(dir)) {
+        std::string name(dent->d_name);
+        // Skip current and parent directory and files with no extension.
+        if (name.size() < (sizeof(".json") - 1)) {
+            continue;
+        }
+
+        // Skip non .json files.
+        if (name.substr(name.size() - (sizeof(".json") - 1)) != ".json") {
+            continue;
+        }
+        name = path + "/" + name;
+        files.emplace(name);
+    }
+
+    for (const auto& file: files) {
+        string label("Checking configuration from file: ");
+        label += file;
+        SCOPED_TRACE(label);
+        loadConfigFile(file);
+    }
+}
+
+} // end of isc::dhcp::test namespace
+} // end of isc::dhcp namespace
+} // end of isc namespace
+
+namespace {
+
 // This test verifies that incoming SOLICIT can be handled properly when
 // there are no subnets configured.
 //
@@ -454,7 +571,6 @@ TEST_F(Dhcpv6SrvTest, advertiseOptions) {
     // more checks to be implemented
 }
 
-
 // There are no dedicated tests for Dhcpv6Srv::handleIA_NA and Dhcpv6Srv::assignLeases
 // as they are indirectly tested in Solicit and Request tests.
 
@@ -522,7 +638,6 @@ TEST_F(Dhcpv6SrvTest, SolicitBasic) {
 // - server-id
 // - IA that includes IAPREFIX
 TEST_F(Dhcpv6SrvTest, pdSolicitBasic) {
-
     NakedDhcpv6Srv srv(0);
 
     Pkt6Ptr sol = Pkt6Ptr(new Pkt6(DHCPV6_SOLICIT, 1234));
@@ -1241,7 +1356,6 @@ TEST_F(Dhcpv6SrvTest, RequestBasic) {
 // - server-id
 // - IA that includes IAPREFIX
 TEST_F(Dhcpv6SrvTest, pdRequestBasic) {
-
     NakedDhcpv6Srv srv(0);
 
     // Let's create a REQUEST
@@ -2017,9 +2131,9 @@ TEST_F(Dhcpv6SrvTest, sanityCheckServerId) {
 // Check that the server is testing if server identifier received in the
 // query, matches server identifier used by the server.
 TEST_F(Dhcpv6SrvTest, testServerID) {
-        NakedDhcpv6Srv srv(0);
+    NakedDhcpv6Srv srv(0);
 
-        Pkt6Ptr req = Pkt6Ptr(new Pkt6(DHCPV6_REQUEST, 1234));
+    Pkt6Ptr req = Pkt6Ptr(new Pkt6(DHCPV6_REQUEST, 1234));
     std::vector<uint8_t> bin;
 
     // duid_llt constructed with: time = 0, macaddress = 00:00:00:00:00:00
@@ -2093,8 +2207,6 @@ TEST_F(Dhcpv6SrvTest, testUnicast) {
             << static_cast<int>(allowed_unicast[i])
             << "being sent to unicast address";
     }
-
-
 }
 
 // This test verifies if selectSubnet() selects proper subnet for a given
@@ -2413,7 +2525,6 @@ TEST_F(Dhcpv6SrvTest, selectSubnetRelayInterfaceId) {
 
 // Checks if server responses are sent to the proper port.
 TEST_F(Dhcpv6SrvTest, portsClientPort) {
-
     NakedDhcpv6Srv srv(0);
 
     // Enforce a specific client port value.
@@ -2442,7 +2553,6 @@ TEST_F(Dhcpv6SrvTest, portsClientPort) {
 
 // Checks if server responses are sent to the proper port.
 TEST_F(Dhcpv6SrvTest, portsServerPort) {
-
     // Create the test server in test mode.
     NakedDhcpv6Srv srv(0);
 
@@ -2472,7 +2582,6 @@ TEST_F(Dhcpv6SrvTest, portsServerPort) {
 
 // Checks if server responses are sent to the proper port.
 TEST_F(Dhcpv6SrvTest, portsDirectTraffic) {
-
     NakedDhcpv6Srv srv(0);
 
     // Let's create a simple SOLICIT
@@ -2497,7 +2606,6 @@ TEST_F(Dhcpv6SrvTest, portsDirectTraffic) {
 
 // Checks if server responses are sent to the proper port.
 TEST_F(Dhcpv6SrvTest, portsRelayedTraffic) {
-
     NakedDhcpv6Srv srv(0);
 
     // Let's create a simple SOLICIT
@@ -2522,7 +2630,6 @@ TEST_F(Dhcpv6SrvTest, portsRelayedTraffic) {
 
 // Test that the server processes relay-source-port option correctly.
 TEST_F(Dhcpv6SrvTest, relaySourcePort) {
-
     NakedDhcpv6Srv srv(0);
 
     string config =
@@ -2700,7 +2807,6 @@ TEST_F(Dhcpv6SrvTest, prlPersistency) {
 // @todo Uncomment this test as part of #3180 work.
 // Kea code currently fails to handle docsis traffic.
 TEST_F(Dhcpv6SrvTest, docsisTraffic) {
-
     NakedDhcpv6Srv srv(0);
 
     // Let's get a traffic capture from DOCSIS3.0 modem
@@ -2720,7 +2826,6 @@ TEST_F(Dhcpv6SrvTest, docsisTraffic) {
     ASSERT_TRUE(adv);
 }
 
-
 // Checks if relay IP address specified in the relay-info structure in
 // subnet6 is being used properly.
 TEST_F(Dhcpv6SrvTest, relayOverride) {
@@ -3261,7 +3366,6 @@ TEST_F(Dhcpv6SrvTest, tooLongServerId) {
 
 // Checks if user-contexts are parsed properly.
 TEST_F(Dhcpv6SrvTest, userContext) {
-
     IfaceMgrTestConfig test_config(true);
 
     NakedDhcpv6Srv srv(0);
@@ -3474,6 +3578,10 @@ TEST_F(Dhcpv6SrvTest, calculateTeeTimers) {
     }
 }
 
+TEST_F(Dhcpv6SrvTest, checkConfigFiles) {
+    checkConfigFiles();
+}
+
 /// @todo: Add more negative tests for processX(), e.g. extend sanityCheck() test
 /// to call processX() methods.
 
index 670a65edbb7afa2d89606e3082d14772b33b9a47..ce8dcf02ea8cda9a1a0cb4f8096fa32395557c81 100644 (file)
@@ -8,13 +8,13 @@
 #include <gtest/gtest.h>
 #include <cc/command_interpreter.h>
 #include <dhcp/option6_status_code.h>
+#include <dhcp/tests/pkt_captures.h>
+#include <dhcpsrv/cfg_multi_threading.h>
 #include <dhcp6/tests/dhcp6_test_utils.h>
 #include <dhcp6/json_config_parser.h>
-#include <dhcp/tests/pkt_captures.h>
 #include <log/logger_support.h>
-#include <dhcpsrv/cfg_multi_threading.h>
-#include <util/pointer_util.h>
 #include <stats/stats_mgr.h>
+#include <util/pointer_util.h>
 #include <cstdio>
 #include <sstream>
 #include <string.h>
@@ -211,7 +211,6 @@ Dhcpv6SrvTest::checkPdLease(const DuidPtr& duid, const OptionPtr& ia_pd,
     return (lease);
 }
 
-
 Pkt6Ptr
 Dhcpv6SrvTest::createMessage(uint8_t message_type, Lease::Type lease_type,
                              const IOAddress& addr, const uint8_t prefix_len,
@@ -812,12 +811,21 @@ Dhcpv6SrvTest::testReceiveStats(uint8_t pkt_type, const std::string& stat_name)
 }
 
 void
-Dhcpv6SrvTest::configure(const std::string& config) {
-    configure(config, srv_);
+Dhcpv6SrvTest::configure(const std::string& config,
+                         const bool commit,
+                         const bool open_sockets,
+                         const bool create_managers,
+                         const bool test) {
+    configure(config, srv_, commit, open_sockets, create_managers, test);
 }
 
 void
-Dhcpv6SrvTest::configure(const std::string& config, NakedDhcpv6Srv& srv) {
+Dhcpv6SrvTest::configure(const std::string& config,
+                         NakedDhcpv6Srv& srv,
+                         const bool commit,
+                         const bool open_sockets,
+                         const bool create_managers,
+                         const bool test) {
     setenv("KEA_LFC_EXECUTABLE", KEA_LFC_EXECUTABLE, 1);
     MultiThreadingCriticalSection cs;
     ConstElementPtr json;
@@ -825,7 +833,9 @@ Dhcpv6SrvTest::configure(const std::string& config, NakedDhcpv6Srv& srv) {
         json = parseJSON(config);
     } catch (const std::exception& ex) {
         // Fatal failure on parsing error
-        FAIL() << "config parsing failed, test is broken: " << ex.what();
+        FAIL() << "parsing failure:"
+               << "config:" << config << std::endl
+               << "error: " << ex.what();
     }
 
     ConstElementPtr status;
@@ -837,13 +847,22 @@ Dhcpv6SrvTest::configure(const std::string& config, NakedDhcpv6Srv& srv) {
     configureMultiThreading(multi_threading_, json);
 
     // Configure the server and make sure the config is accepted
-    EXPECT_NO_THROW(status = configureDhcp6Server(srv, json));
+    EXPECT_NO_THROW(status = configureDhcp6Server(srv, json, test));
     ASSERT_TRUE(status);
     int rcode;
     ConstElementPtr comment = isc::config::parseAnswer(rcode, status);
     ASSERT_EQ(0, rcode) << "configuration failed, test is broken: "
         << comment->str();
 
+    // Use specified lease database backend.
+    if (create_managers) {
+        ASSERT_NO_THROW( {
+            CfgDbAccessPtr cfg_db = CfgMgr::instance().getStagingCfg()->getCfgDbAccess();
+            cfg_db->setAppendedParameters("universe=6");
+            cfg_db->createManagers();
+        } );
+    }
+
     try {
         CfgMultiThreading::apply(CfgMgr::instance().getStagingCfg()->getDHCPMultiThreading());
     } catch (const std::exception& ex) {
@@ -851,7 +870,14 @@ Dhcpv6SrvTest::configure(const std::string& config, NakedDhcpv6Srv& srv) {
             << ex.what();
     }
 
-    CfgMgr::instance().commit();
+    if (commit) {
+        CfgMgr::instance().commit();
+    }
+
+    // Opening sockets.
+    if (open_sockets) {
+        IfaceMgr::instance().openSockets6();
+    }
 }
 
 NakedDhcpv6SrvTest::NakedDhcpv6SrvTest()
index 69a7021c0e90fdb910eb7ade38d91f84717aa84c..65481fef543f2d42173d9413b86f79f8181397d1 100644 (file)
@@ -6,13 +6,15 @@
 
 /// @file   dhcp6_test_utils.h
 ///
-/// @brief  This file contains utility classes used for DHCPv6 server testing
+/// @brief This file contains utility classes used for DHCPv6 server testing
 
 #ifndef DHCP6_TEST_UTILS_H
 #define DHCP6_TEST_UTILS_H
 
 #include <gtest/gtest.h>
 
+#include <dhcp6/dhcp6_srv.h>
+#include <dhcp6/parser_context.h>
 #include <dhcp/pkt6.h>
 #include <dhcp/option6_ia.h>
 #include <dhcp/option6_iaaddr.h>
@@ -26,8 +28,6 @@
 #include <dhcpsrv/cfgmgr.h>
 #include <dhcpsrv/lease_mgr.h>
 #include <dhcpsrv/lease_mgr_factory.h>
-#include <dhcp6/dhcp6_srv.h>
-#include <dhcp6/parser_context.h>
 #include <hooks/hooks_manager.h>
 #include <util/multi_threading_mgr.h>
 
@@ -68,7 +68,6 @@ struct SpecializedTypeWrapper {
     ValueType value_;
 };
 
-
 /// @brief Class representing strongly typed IAID.
 struct IAID : public SpecializedTypeWrapper<uint32_t> {
     /// @brief Constructor
@@ -80,7 +79,7 @@ struct IAID : public SpecializedTypeWrapper<uint32_t> {
 
 /// @brief Class representing strongly typed value for strict IAID checks.
 ///
-/// Strict IAID checks are used to verify that  the particular address has been
+/// Strict IAID checks are used to verify that the particular address has been
 /// assign to a specific IA. In many cases we don't check that because it may
 /// not be possible to predict to which IA the specific lease will be assigned.
 struct StrictIAIDChecking : public SpecializedTypeWrapper<bool> {
@@ -106,7 +105,6 @@ struct StrictIAIDChecking : public SpecializedTypeWrapper<bool> {
     }
 };
 
-
 /// @brief Base class for DHCPv6 server testing.
 ///
 /// Currently it configures the test data path directory in
@@ -128,7 +126,6 @@ private:
 
     /// @brief Holds the original data directory.
     std::string original_datadir_;
-
 };
 
 /// @brief "naked" Dhcpv6Srv class that exposes internal members
@@ -360,7 +357,7 @@ public:
     /// @brief Generate binary data option
     ///
     /// Creates an Option in the V6 space with the given type and binary data
-    /// of the given number of bytes.  The data is initialized to the values
+    /// of the given number of bytes. The data is initialized to the values
     /// 100 to 100 + n, where n is the desired number of bytes.
     ///
     /// @param type option type for the new option
@@ -567,13 +564,36 @@ public:
     /// @brief Runs DHCPv6 configuration from the JSON string.
     ///
     /// @param config String holding server configuration in JSON format.
-    void configure(const std::string& config);
+    /// @param commit A boolean flag indicating if the new configuration
+    /// should be committed (if true), or not (if false).
+    /// @param open_sockets A boolean flag indicating if sockets should
+    /// be opened (if true), or not (if false).
+    /// @param create_managers A boolean flag indicating if managers should be
+    /// recreated.
+    /// @param test A boolean flag which indicates if only testing config.
+    void configure(const std::string& config,
+                   const bool commit = true,
+                   const bool open_sockets = false,
+                   const bool create_managers = true,
+                   const bool test = false);
 
     /// @brief Configure the DHCPv6 server using the JSON string.
     ///
     /// @param config String holding server configuration in JSON format.
     /// @param srv Server to be configured.
-    void configure(const std::string& config, NakedDhcpv6Srv& srv);
+    /// @param commit A boolean flag indicating if the new configuration
+    /// should be committed (if true), or not (if false).
+    /// @param open_sockets A boolean flag indicating if sockets should
+    /// be opened (if true), or not (if false).
+    /// @param create_managers A boolean flag indicating if managers should be
+    /// recreated.
+    /// @param test A boolean flag which indicates if only testing config.
+    void configure(const std::string& config,
+                   NakedDhcpv6Srv& srv,
+                   const bool commit = true,
+                   const bool open_sockets = false,
+                   const bool create_managers = true,
+                   const bool test = false);
 
     /// @brief Checks that server response (ADVERTISE or REPLY) contains proper
     ///        IA_NA option
@@ -599,7 +619,6 @@ public:
     checkIA_PD(const isc::dhcp::Pkt6Ptr& rsp, uint32_t expected_iaid,
                uint32_t expected_t1, uint32_t expected_t2);
 
-
     // Check that generated IAADDR option contains expected address
     // and lifetime values match the configured subnet
     /// @param expected_pref check that lease preferedlifetime has the not-zero
@@ -612,7 +631,6 @@ public:
                      uint32_t expected_pref = 0,
                      uint32_t expected_valid = 0) {
 
-
         // Check that the assigned address is indeed from the configured pool.
         // Note that when comparing addresses, we compare the textual
         // representation. IOAddress does not support being streamed to
@@ -800,7 +818,7 @@ public:
     /// @brief Performs negative RELEASE test
     ///
     /// See releaseReject and pdReleaseReject tests for detailed
-    /// explanation.  In essence the test attempts to perform couple
+    /// explanation. In essence the test attempts to perform couple
     /// failed RELEASE scenarios.
     ///
     /// This method does not throw, but uses gtest macros to signify failures.
@@ -822,6 +840,14 @@ public:
         multi_threading_ = enabled;
     }
 
+    /// @breif Check if example files contain valid configuration.
+    void checkConfigFiles();
+
+    /// @brief Check if the server configuration stored in file is valid.
+    ///
+    /// @param path The path to the configuration file.
+    void loadConfigFile(const std::string& path);
+
     /// A subnet used in most tests.
     isc::dhcp::Subnet6Ptr subnet_;
 
index c93464ab78c00904c9bb1330e51ce51503e2dde7..714102f44b603cde343fdacc8fc3a2e46e570728 100644 (file)
@@ -1754,7 +1754,7 @@ TEST_F(Dhcpv6SharedNetworkTest, reservationInSharedNetwork) {
 
     // Reconfigure the server. Now, the first client get's second client's
     // reservation and vice versa.
-    ASSERT_NO_FATAL_FAILURE(configure(NETWORKS_CONFIG[5], *client1.getServer()));
+    ASSERT_NO_FATAL_FAILURE(configure(NETWORKS_CONFIG[5], *client1.getServer(), true, true, false));
 
     // The first client is trying to renew the lease but should get a different lease
     // because its lease is now reserved for some other client. The client won't be
index 0fdf425fb5548c42d8bb59e694549f3dfec131cf..8164aa52acc75e1f6f389ecba992fdd8f2f42951 100644 (file)
@@ -11,7 +11,7 @@
         "{",
         "    \"command\": \"lease6-del\",",
         "    \"arguments\": {",
-        "        \"ip-address\": \"192.0.2.202\"",
+        "        \"ip-address\": \"2001:db8::3\"",
         "    }",
         "}"
     ],