]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#2976] Extended syntax
authorFrancis Dupont <fdupont@isc.org>
Sat, 30 Mar 2024 09:23:23 +0000 (10:23 +0100)
committerRazvan Becheriu <razvan@isc.org>
Fri, 26 Apr 2024 15:25:06 +0000 (18:25 +0300)
doc/examples/kea4/all-keys.json
src/bin/dhcp4/dhcp4_lexer.ll
src/bin/dhcp4/dhcp4_parser.yy
src/bin/dhcp4/json_config_parser.cc
src/lib/dhcpsrv/cfg_globals.cc
src/lib/dhcpsrv/cfg_globals.h
src/lib/dhcpsrv/parsers/simple_parser4.cc

index 0885263ecf5fbe991703f8740ffa59e1d46a62e2..2558ca42740de67e1fb7caed063bf5840eddd1f7 100644 (file)
         // Global server hostname set in the 'sname' field.
         "server-hostname": "",
 
+        // Stash agent options (aka RAI) to make direct queries to come
+        // through a relay.
+        "stash-agent-options": false,
+
         // List of IPv4 subnets which don't belong to any shared network.
         "subnet4": [],
 
index 30db220e0eafbb461d525d271c70bc069872428f..9a162f342c1398ff381cd81ac665479749a55135 100644 (file)
@@ -2203,6 +2203,15 @@ ControlCharacterFill            [^"\\]|\\["\\/bfnrtu]
     }
 }
 
+\"stash-agent-options\" {
+    switch(driver.ctx_) {
+    case isc::dhcp::Parser4Context::DHCP4:
+        return isc::dhcp::Dhcp4Parser::make_STASH_AGENT_OPTIONS(driver.loc_);
+    default:
+        return isc::dhcp::Dhcp4Parser::make_STRING("stash-agent-options", driver.loc_);
+    }
+}
+
 {JSONString} {
     /* A string has been matched. It contains the actual string and single quotes.
        We need to get those quotes out of the way and just use its content, e.g.
index 10b5ae68b207ad9f64af921a2ae65a54b11f3238..a6a535f3473c06833924b19a138a66b4ed24739c 100644 (file)
@@ -84,6 +84,7 @@ using namespace std;
   SERVER_HOSTNAME "server-hostname"
   BOOT_FILE_NAME "boot-file-name"
   OFFER_LFT "offer-lifetime"
+  STASH_AGENT_OPTIONS "stash-agent-options"
 
   LEASE_DATABASE "lease-database"
   HOSTS_DATABASE "hosts-database"
@@ -571,6 +572,7 @@ global_param: valid_lifetime
             | parked_packet_limit
             | allocator
             | offer_lifetime
+            | stash_agent_options
             | unknown_map_entry
             ;
 
@@ -853,6 +855,12 @@ offer_lifetime: OFFER_LFT COLON INTEGER {
     ctx.stack_.back()->set("offer-lifetime", offer_lifetime);
 };
 
+stash_agent_options: STASH_AGENT_OPTIONS COLON BOOLEAN {
+    ctx.unique("stash-agent-options", ctx.loc2pos(@1));
+    ElementPtr stash(new BoolElement($3, ctx.loc2pos(@3)));
+    ctx.stack_.back()->set("stash-agent-options", stash);
+};
+
 interfaces_config: INTERFACES_CONFIG {
     ctx.unique("interfaces-config", ctx.loc2pos(@1));
     ElementPtr i(new MapElement(ctx.loc2pos(@1)));
index 0b1b7e2e3b26726f12b70050d8bb7aa5cda7e797..6e203d7a6ed1987f3e361cfd8980ea47b8aa96ce 100644 (file)
@@ -666,7 +666,8 @@ processDhcp4Config(isc::data::ConstElementPtr config_set) {
                  (config_pair.first == "reservations-lookup-first") ||
                  (config_pair.first == "parked-packet-limit") ||
                  (config_pair.first == "allocator") ||
-                 (config_pair.first == "offer-lifetime") ) {
+                 (config_pair.first == "offer-lifetime") ||
+                 (config_pair.first == "stash-agent-options") ) {
                 CfgMgr::instance().getStagingCfg()->addConfiguredGlobal(config_pair.first,
                                                                         config_pair.second);
                 continue;
index e9e76934ab9649e4d376030ac39aab81fa0fe17e..c5f23464438ad989f09f7a7ff175fa44d5121457 100644 (file)
@@ -68,6 +68,7 @@ CfgGlobals::nameToIndex = {
     { "server-hostname", SERVER_HOSTNAME },
     { "boot-file-name", BOOT_FILE_NAME },
     { "offer-lifetime", OFFER_LIFETIME },
+    { "stash-agent-options", STASH_AGENT_OPTIONS },
 
     // DHCPv6 specific parameters.
     { "data-directory", DATA_DIRECTORY },
index 4456435af2f21a7e0ea4ab172bc5e3831c77e11f..06e3cde10d295e98ba5a3427806bc8a3564375ab 100644 (file)
@@ -91,6 +91,7 @@ public:
         SERVER_HOSTNAME,
         BOOT_FILE_NAME,
         OFFER_LIFETIME,
+        STASH_AGENT_OPTIONS,
 
         // DHCPv6 specific parameters.
         DATA_DIRECTORY,
index 1e4c32301f1440adaa62330768a94991500023cd..0a079abcf6d289027c67705f59a72f6698d4bf91 100644 (file)
@@ -101,6 +101,7 @@ const SimpleKeywords SimpleParser4::GLOBAL4_PARAMETERS = {
     { "offer-lifetime",                   Element::integer },
     { "ddns-ttl-percent",                 Element::real },
     { "ddns-conflict-resolution-mode",    Element::string },
+    { "stash-agent-options",              Element::boolean },
 };
 
 /// @brief This table defines default global values for DHCPv4
@@ -143,6 +144,7 @@ const SimpleDefaults SimpleParser4::GLOBAL4_DEFAULTS = {
     { "parked-packet-limit",              Element::integer, "256" },
     { "allocator",                        Element::string,  "iterative" },
     { "ddns-conflict-resolution-mode",    Element::string,  "check-with-dhcid" },
+    { "stash-agent-options",              Element::boolean, "false" },
 };
 
 /// @brief This table defines all option definition parameters.