]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[5184] Parse authoritative flag
authorSebastian Schrader <sebastian.schrader@tu-dresden.de>
Fri, 19 Oct 2018 14:34:29 +0000 (16:34 +0200)
committerTomek Mrugalski <tomasz@isc.org>
Wed, 7 Nov 2018 16:17:45 +0000 (23:17 +0700)
14 files changed:
src/bin/dhcp4/dhcp4_lexer.ll
src/bin/dhcp4/dhcp4_parser.yy
src/bin/dhcp4/json_config_parser.cc
src/bin/dhcp4/tests/get_config_unittest.cc
src/lib/dhcpsrv/cfgmgr.h
src/lib/dhcpsrv/network.cc
src/lib/dhcpsrv/network.h
src/lib/dhcpsrv/parsers/dhcp_parsers.cc
src/lib/dhcpsrv/parsers/shared_network_parser.cc
src/lib/dhcpsrv/parsers/simple_parser4.cc
src/lib/dhcpsrv/tests/cfg_shared_networks4_unittest.cc
src/lib/dhcpsrv/tests/cfg_subnets4_unittest.cc
src/lib/dhcpsrv/tests/shared_network_parser_unittest.cc
src/lib/dhcpsrv/tests/shared_network_unittest.cc

index 2daf7dd60d757e02b8130ccc2a75dd66d240635c..e42eadd51649d66e06c0702afbd158b46259f1d7 100644 (file)
@@ -1556,6 +1556,17 @@ ControlCharacterFill            [^"\\]|\\{JSONEscapeSequence}
     }
 }
 
+\"authoritative\" {
+    switch(driver.ctx_) {
+    case isc::dhcp::Parser4Context::DHCP4:
+    case isc::dhcp::Parser4Context::SUBNET4:
+    case isc::dhcp::Parser4Context::SHARED_NETWORK:
+        return isc::dhcp::Dhcp4Parser::make_AUTHORITATIVE(driver.loc_);
+    default:
+        return isc::dhcp::Dhcp4Parser::make_STRING("authoritative", driver.loc_);
+    }
+}
+
 \"next-server\" {
     switch(driver.ctx_) {
     case isc::dhcp::Parser4Context::DHCP4:
index 1ec2c8a8239a0e08e293095bb157043d83d9edd7..1a90aeb79337395a88a18fecd36182123844df0a 100644 (file)
@@ -67,6 +67,7 @@ using namespace std;
 
   ECHO_CLIENT_ID "echo-client-id"
   MATCH_CLIENT_ID "match-client-id"
+  AUTHORITATIVE "authoritative"
   NEXT_SERVER "next-server"
   SERVER_HOSTNAME "server-hostname"
   BOOT_FILE_NAME "boot-file-name"
@@ -451,6 +452,7 @@ global_param: valid_lifetime
             | dhcp_ddns
             | echo_client_id
             | match_client_id
+            | authoritative
             | next_server
             | server_hostname
             | boot_file_name
@@ -501,6 +503,11 @@ match_client_id: MATCH_CLIENT_ID COLON BOOLEAN {
     ctx.stack_.back()->set("match-client-id", match);
 };
 
+authoritative: AUTHORITATIVE COLON BOOLEAN {
+    ElementPtr prf(new BoolElement($3, ctx.loc2pos(@3)));
+    ctx.stack_.back()->set("authoritative", prf);
+};
+
 
 interfaces_config: INTERFACES_CONFIG {
     ElementPtr i(new MapElement(ctx.loc2pos(@1)));
@@ -1041,6 +1048,7 @@ subnet4_param: valid_lifetime
              | reservation_mode
              | relay
              | match_client_id
+             | authoritative
              | next_server
              | server_hostname
              | boot_file_name
@@ -1169,6 +1177,7 @@ shared_network_param: name
                     | rebind_timer
                     | option_data_list
                     | match_client_id
+                    | authoritative
                     | next_server
                     | server_hostname
                     | boot_file_name
index 2b8ad3cdbfff9e207368f2570e4fe02b3d6a26b3..efa04ffd1282e981ace2ae36a7dea4a30756ac7b 100644 (file)
@@ -515,7 +515,8 @@ configureDhcp4Server(Dhcpv4Srv& server, isc::data::ConstElementPtr config_set,
             // decline-probation-period, dhcp4o6-port, echo-client-id,
             // user-context are handled in global_parser.parse() which
             // sets global parameters.
-            // match-client-id is derived to subnet scope level.
+            // match-client-id and authoritative are derived to subnet scope
+            // level.
             if ( (config_pair.first == "renew-timer") ||
                  (config_pair.first == "rebind-timer") ||
                  (config_pair.first == "valid-lifetime") ||
@@ -524,6 +525,7 @@ configureDhcp4Server(Dhcpv4Srv& server, isc::data::ConstElementPtr config_set,
                  (config_pair.first == "echo-client-id") ||
                  (config_pair.first == "user-context") ||
                  (config_pair.first == "match-client-id") ||
+                 (config_pair.first == "authoritative") ||
                  (config_pair.first == "next-server") ||
                  (config_pair.first == "server-hostname") ||
                  (config_pair.first == "boot-file-name") ||
index c92cee901a95540b3fb4346567989d5b9c4d771e..91b50c37d0ed4626c0c0c4d9658508e36342da36 100644 (file)
@@ -2049,6 +2049,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 1,\n"
 "                \"match-client-id\": true,\n"
@@ -2125,6 +2126,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 1,\n"
 "                \"match-client-id\": true,\n"
@@ -2202,6 +2204,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 1,\n"
 "                \"match-client-id\": true,\n"
@@ -2280,6 +2283,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 1,\n"
 "                \"match-client-id\": true,\n"
@@ -2306,6 +2310,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 2,\n"
 "                \"match-client-id\": true,\n"
@@ -2332,6 +2337,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 3,\n"
 "                \"match-client-id\": true,\n"
@@ -2358,6 +2364,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 4,\n"
 "                \"match-client-id\": true,\n"
@@ -2436,6 +2443,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 1024,\n"
 "                \"match-client-id\": true,\n"
@@ -2462,6 +2470,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 100,\n"
 "                \"match-client-id\": true,\n"
@@ -2488,6 +2497,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 1,\n"
 "                \"match-client-id\": true,\n"
@@ -2514,6 +2524,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 34,\n"
 "                \"match-client-id\": true,\n"
@@ -2595,6 +2606,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"bar\",\n"
 "                \"id\": 1,\n"
 "                \"match-client-id\": true,\n"
@@ -2673,6 +2685,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"bar\",\n"
 "                \"id\": 1,\n"
 "                \"match-client-id\": true,\n"
@@ -2754,6 +2767,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"bootfile.efi\",\n"
 "                \"id\": 1,\n"
 "                \"match-client-id\": true,\n"
@@ -2832,6 +2846,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 1,\n"
 "                \"match-client-id\": true,\n"
@@ -2910,6 +2925,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 1,\n"
 "                \"match-client-id\": true,\n"
@@ -2988,6 +3004,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 1,\n"
 "                \"match-client-id\": true,\n"
@@ -3014,6 +3031,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 2,\n"
 "                \"match-client-id\": false,\n"
@@ -3093,6 +3111,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 1,\n"
 "                \"match-client-id\": false,\n"
@@ -3119,6 +3138,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 2,\n"
 "                \"match-client-id\": true,\n"
@@ -3197,6 +3217,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 1,\n"
 "                \"match-client-id\": true,\n"
@@ -3275,6 +3296,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 1,\n"
 "                \"match-client-id\": true,\n"
@@ -3305,6 +3327,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 2,\n"
 "                \"match-client-id\": true,\n"
@@ -3387,6 +3410,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 1,\n"
 "                \"match-client-id\": true,\n"
@@ -3897,6 +3921,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 1,\n"
 "                \"match-client-id\": true,\n"
@@ -3975,6 +4000,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 1,\n"
 "                \"match-client-id\": true,\n"
@@ -4097,6 +4123,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 1,\n"
 "                \"match-client-id\": true,\n"
@@ -4315,6 +4342,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 1,\n"
 "                \"match-client-id\": true,\n"
@@ -4402,6 +4430,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 1,\n"
 "                \"match-client-id\": true,\n"
@@ -4497,6 +4526,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 1,\n"
 "                \"match-client-id\": true,\n"
@@ -4532,6 +4562,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 2,\n"
 "                \"match-client-id\": true,\n"
@@ -4619,6 +4650,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 1,\n"
 "                \"match-client-id\": true,\n"
@@ -4714,6 +4746,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 1,\n"
 "                \"match-client-id\": true,\n"
@@ -4831,6 +4864,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 1,\n"
 "                \"match-client-id\": true,\n"
@@ -5040,6 +5074,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 1,\n"
 "                \"match-client-id\": true,\n"
@@ -5133,6 +5168,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 1,\n"
 "                \"match-client-id\": true,\n"
@@ -5230,6 +5266,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 1,\n"
 "                \"match-client-id\": true,\n"
@@ -5410,6 +5447,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 1,\n"
 "                \"match-client-id\": true,\n"
@@ -5488,6 +5526,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 1,\n"
 "                \"match-client-id\": true,\n"
@@ -5566,6 +5605,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 1,\n"
 "                \"match-client-id\": true,\n"
@@ -5644,6 +5684,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"client-class\": \"alpha\",\n"
 "                \"id\": 1,\n"
@@ -5803,6 +5844,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 1,\n"
 "                \"match-client-id\": true,\n"
@@ -5896,6 +5938,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 123,\n"
 "                \"match-client-id\": true,\n"
@@ -5922,6 +5965,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 234,\n"
 "                \"match-client-id\": true,\n"
@@ -6003,6 +6047,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 542,\n"
 "                \"match-client-id\": true,\n"
@@ -6139,6 +6184,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 234,\n"
 "                \"match-client-id\": true,\n"
@@ -6237,6 +6283,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 1,\n"
 "                \"match-client-id\": true,\n"
@@ -6263,6 +6310,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 2,\n"
 "                \"match-client-id\": true,\n"
@@ -6289,6 +6337,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 3,\n"
 "                \"match-client-id\": true,\n"
@@ -6315,6 +6364,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 4,\n"
 "                \"match-client-id\": true,\n"
@@ -6585,6 +6635,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 1,\n"
 "                \"match-client-id\": true,\n"
@@ -6663,6 +6714,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"2001:db8::123/45\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 1,\n"
 "                \"match-client-id\": true,\n"
@@ -6741,6 +6793,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"ethX\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 1,\n"
 "                \"match-client-id\": true,\n"
@@ -6819,6 +6872,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"ethX\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"2001:db8::543/21\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 1,\n"
 "                \"match-client-id\": true,\n"
@@ -6897,6 +6951,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"vlan123\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 1,\n"
 "                \"match-client-id\": true,\n"
@@ -7001,6 +7056,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 1,\n"
 "                \"match-client-id\": true,\n"
@@ -7079,6 +7135,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 1,\n"
 "                \"match-client-id\": true,\n"
@@ -7157,6 +7214,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 1,\n"
 "                \"match-client-id\": true,\n"
@@ -7236,6 +7294,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 1,\n"
 "                \"match-client-id\": true,\n"
@@ -7319,6 +7378,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 1,\n"
 "                \"match-client-id\": true,\n"
@@ -7523,6 +7583,7 @@ const char* UNPARSED_CONFIGS[] = {
 "        \"shared-networks\": [\n"
 "            {\n"
 "                \"comment\": \"A shared network\",\n"
+"                \"authoritative\": false,\n"
 "                \"match-client-id\": true,\n"
 "                \"name\": \"foo\",\n"
 "                \"option-data\": [ ],\n"
@@ -7536,6 +7597,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                        \"4o6-interface\": \"\",\n"
 "                        \"4o6-interface-id\": \"\",\n"
 "                        \"4o6-subnet\": \"\",\n"
+"                        \"authoritative\": false,\n"
 "                        \"boot-file-name\": \"\",\n"
 "                        \"id\": 100,\n"
 "                        \"match-client-id\": true,\n"
@@ -7691,6 +7753,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 123,\n"
 "                \"match-client-id\": true,\n"
@@ -7717,6 +7780,7 @@ const char* UNPARSED_CONFIGS[] = {
 "                \"4o6-interface\": \"\",\n"
 "                \"4o6-interface-id\": \"\",\n"
 "                \"4o6-subnet\": \"\",\n"
+"                \"authoritative\": false,\n"
 "                \"boot-file-name\": \"\",\n"
 "                \"id\": 542,\n"
 "                \"match-client-id\": true,\n"
index d03988ac56d1a4263ceab149453a4d7cc6f1d4c7..1d01fc690ba25bc6983b3d506efacb2a350c9da2 100644 (file)
@@ -92,6 +92,19 @@ public:
     /// @param datadir New data directory.
     void setDataDir(const std::string& datadir);
 
+    /// @brief Sets whether server should NAK unknown clients in DHCPv4
+    ///
+    /// @param echo should unknown clients be rejected or not
+    void authoritative(const bool enabled) {
+        authoritative_ = enabled;
+    }
+
+    /// @brief Returns whether server should NAK requests for unknown leases
+    /// @return true if requests for unknown leases should be NAKed, false otherwise
+    bool authoritative() const {
+        return (authoritative_);
+    }
+
     /// @brief Updates the DHCP-DDNS client configuration to the given value.
     ///
     /// Passes the new configuration to the D2ClientMgr instance,
@@ -270,6 +283,9 @@ private:
     /// @brief directory where data files (e.g. server-id) are stored
     std::string datadir_;
 
+    /// Indicates whether v4 server should NAK requests for unknown addresses
+    bool authoritative_;
+
     /// @brief Manages the DHCP-DDNS client and its configuration.
     D2ClientMgr d2_client_mgr_;
 
index 376e2568d82d8fabf0bce0b0acffbf4a43085145..f07725be66679d3a85dbf0c20f0062fd03b562db 100644 (file)
@@ -195,6 +195,9 @@ Network4::toElement() const {
     // Set match-client-id
     map->set("match-client-id", Element::create(getMatchClientId()));
 
+    // Set authoritative
+    map->set("authoritative", Element::create(getAuthoritative()));
+
     return (map);
 }
 
index 4f1d0fa7362378df6e1358c16539799d9894861c..3ce6cac48102b7de53dc8e7368bd03f7536a37e7 100644 (file)
@@ -368,7 +368,7 @@ public:
 
     /// @brief Constructor.
     Network4()
-        : Network(), match_client_id_(true) {
+        : Network(), match_client_id_(true), authoritative_(false) {
     }
 
     /// @brief Returns the flag indicating if the client identifiers should
@@ -388,6 +388,24 @@ public:
         match_client_id_ = match;
     }
 
+    /// @brief Returns the flag indicating if requests for unknown IP addresses
+    /// should be rejected with DHCPNAK instead of ignored.
+    ///
+    /// @return true if requests for unknown IP addresses should be rejected,
+    /// false otherwise.
+    bool getAuthoritative() const {
+        return (authoritative_);
+    }
+
+    /// @brief Sets the flag indicating if requests for unknown IP addresses
+    /// should be rejected with DHCPNAK instead of ignored.
+    ///
+    /// @param match If this value is true, the requests for unknown IP
+    /// addresses will be rejected with DHCPNAK messages
+    void setAuthoritative(const bool authoritative) {
+        authoritative_ = authoritative;
+    }
+
     /// @brief Unparses network object.
     ///
     /// @return A pointer to unparsed network configuration.
@@ -404,6 +422,9 @@ private:
     /// @brief Should server use client identifiers for client lease
     /// lookup.
     bool match_client_id_;
+
+    /// @brief Should requests for unknown IP addresses be rejected.
+    bool authoritative_;
 };
 
 /// @brief Specialization of the @ref Network object for DHCPv6 case.
index c763c983391576d81b7759b621cc983ed0037da6..0b124fc7ee85ab05d44dd5c0264e940f35f43f38 100644 (file)
@@ -712,6 +712,12 @@ Subnet4ConfigParser::initSubnet(data::ConstElementPtr params,
     bool match_client_id = getBoolean(params, "match-client-id");
     subnet4->setMatchClientId(match_client_id);
 
+    // Set the authoritative value for the subnet. It is always present.
+    // If not explicitly specified, the default value was filled in when
+    // SimpleParser4::setAllDefaults was called.
+    bool authoritative = getBoolean(params, "authoritative");
+    subnet4->setAuthoritative(authoritative);
+
     // Set next-server. The default value is 0.0.0.0. Nevertheless, the
     // user could have messed that up by specifying incorrect value.
     // To avoid using 0.0.0.0, user can specify "".
index 2e77490f9a7c4b0f60dfc33a3ce5c95c51bfd2b7..640e341eea50f764fdabbbb72a525fbff0200ce7 100644 (file)
@@ -65,6 +65,11 @@ SharedNetwork4Parser::parse(const data::ConstElementPtr& shared_network_data) {
                                                         "match-client-id"));
         }
 
+        if (shared_network_data->contains("authoritative")) {
+            shared_network->setAuthoritative(getBoolean(shared_network_data,
+                                                        "authoritative"));
+        }
+
         if (shared_network_data->contains("client-class")) {
             std::string client_class = getString(shared_network_data, "client-class");
             if (!client_class.empty()) {
index 78895feff87fe85298ccc5b34916410a0138c113..b6a356397a755dd8e2b899d8bb2d54a9a616bbf4 100644 (file)
@@ -63,6 +63,7 @@ const SimpleDefaults SimpleParser4::GLOBAL4_DEFAULTS = {
     { "dhcp4o6-port",             Element::integer, "0" },
     { "echo-client-id",           Element::boolean, "true" },
     { "match-client-id",          Element::boolean, "true" },
+    { "authoritative",            Element::boolean, "false" },
     { "next-server",              Element::string,  "0.0.0.0" },
     { "server-hostname",          Element::string,  "" },
     { "boot-file-name",           Element::string,  "" },
@@ -125,6 +126,7 @@ const ParamsList SimpleParser4::INHERIT_TO_SUBNET4 = {
     "client-class",
     "interface",
     "match-client-id",
+    "authoritative",
     "next-server",
     "rebind-timer",
     "relay",
index eb72937a4232f5a21233800516c0077d90916ce7..13deb658c2cf5bee7dcefc2052d56dc359809429 100644 (file)
@@ -125,6 +125,7 @@ TEST(CfgSharedNetworks4Test, unparse) {
     std::string expected =
         "[\n"
         "  {\n"
+        "    \"authoritative\": false,\n"
         "    \"interface\": \"eth1\",\n"
         "    \"match-client-id\": true,\n"
         "    \"name\": \"dog\",\n"
@@ -137,6 +138,7 @@ TEST(CfgSharedNetworks4Test, unparse) {
         "    \"valid-lifetime\": 300\n"
         "  },\n"
         "  {\n"
+        "    \"authoritative\": false,\n"
         "    \"interface\": \"eth0\",\n"
         "    \"match-client-id\": true,\n"
         "    \"name\": \"frog\",\n"
index c02b4f52474f0b0aad7f637e7055c8e91a75493c..f622d441d50ebb754b0149079a7bec59ae5a900b 100644 (file)
@@ -769,6 +769,7 @@ TEST(CfgSubnets4Test, unparseSubnet) {
         "    \"4o6-interface\": \"\",\n"
         "    \"4o6-interface-id\": \"\",\n"
         "    \"4o6-subnet\": \"\",\n"
+        "    \"authoritative\": false,\n"
         "    \"reservation-mode\": \"all\",\n"
         "    \"option-data\": [ ],\n"
         "    \"pools\": [ ]\n"
@@ -787,6 +788,7 @@ TEST(CfgSubnets4Test, unparseSubnet) {
         "    \"4o6-interface\": \"\",\n"
         "    \"4o6-interface-id\": \"\",\n"
         "    \"4o6-subnet\": \"\",\n"
+        "    \"authoritative\": false,\n"
         "    \"reservation-mode\": \"all\",\n"
         "    \"user-context\": {},\n"
         "    \"option-data\": [ ],\n"
@@ -806,6 +808,7 @@ TEST(CfgSubnets4Test, unparseSubnet) {
         "    \"4o6-interface\": \"\",\n"
         "    \"4o6-interface-id\": \"\",\n"
         "    \"4o6-subnet\": \"\",\n"
+        "    \"authoritative\": false,\n"
         "    \"reservation-mode\": \"all\",\n"
         "    \"option-data\": [ ],\n"
         "    \"pools\": [ ]\n,"
@@ -851,6 +854,7 @@ TEST(CfgSubnets4Test, unparsePool) {
         "    \"4o6-interface\": \"\",\n"
         "    \"4o6-interface-id\": \"\",\n"
         "    \"4o6-subnet\": \"\",\n"
+        "    \"authoritative\": false,\n"
         "    \"reservation-mode\": \"all\",\n"
         "    \"option-data\": [],\n"
         "    \"pools\": [\n"
index 4842fbd37dc95870cfa6cc9eb9b9a11e2011d72c..c7578ed9379dacbd89354f102e5757f1a41fcfac 100644 (file)
@@ -131,6 +131,7 @@ public:
                 "            \"rebind-timer\": 200,"
                 "            \"valid-lifetime\": 300,"
                 "            \"match-client-id\": false,"
+                "            \"authoritative\": false,"
                 "            \"next-server\": \"\","
                 "            \"server-hostname\": \"\","
                 "            \"boot-file-name\": \"\","
@@ -152,6 +153,7 @@ public:
                 "            \"rebind-timer\": 20,"
                 "            \"valid-lifetime\": 30,"
                 "            \"match-client-id\": false,"
+                "            \"authoritative\": false,"
                 "            \"next-server\": \"\","
                 "            \"server-hostname\": \"\","
                 "            \"boot-file-name\": \"\","
index 77159241a6e044ca6c1d89775e87243b409df1ad..cbbc01e51c60acb1de04e20d6ad80caf9fdb6859 100644 (file)
@@ -316,6 +316,7 @@ TEST(SharedNetwork4Test, unparse) {
 
     std::string expected = "{\n"
         "    \"comment\": \"bar\",\n"
+        "    \"authoritative\": false,\n"
         "    \"interface\": \"eth1\",\n"
         "    \"match-client-id\": false,\n"
         "    \"name\": \"frog\",\n"
@@ -332,6 +333,7 @@ TEST(SharedNetwork4Test, unparse) {
         "        \"4o6-interface\": \"\",\n"
         "        \"4o6-interface-id\": \"\",\n"
         "        \"4o6-subnet\": \"\",\n"
+        "        \"authoritative\": false,\n"
         "        \"id\": 1,\n"
         "        \"match-client-id\": true,\n"
         "        \"next-server\": \"0.0.0.0\",\n"
@@ -352,6 +354,7 @@ TEST(SharedNetwork4Test, unparse) {
         "        \"4o6-interface\": \"\",\n"
         "        \"4o6-interface-id\": \"\",\n"
         "        \"4o6-subnet\": \"\",\n"
+        "        \"authoritative\": false,\n"
         "        \"id\": 2,\n"
         "        \"match-client-id\": true,\n"
         "        \"next-server\": \"0.0.0.0\",\n"