From: Francis Dupont Date: Sat, 30 Mar 2024 09:23:23 +0000 (+0100) Subject: [#2976] Extended syntax X-Git-Tag: Kea-2.5.8~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b1884326a8015eeca1aa555be9e0210af27f1786;p=thirdparty%2Fkea.git [#2976] Extended syntax --- diff --git a/doc/examples/kea4/all-keys.json b/doc/examples/kea4/all-keys.json index 0885263ecf..2558ca4274 100644 --- a/doc/examples/kea4/all-keys.json +++ b/doc/examples/kea4/all-keys.json @@ -1141,6 +1141,10 @@ // 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": [], diff --git a/src/bin/dhcp4/dhcp4_lexer.ll b/src/bin/dhcp4/dhcp4_lexer.ll index 30db220e0e..9a162f342c 100644 --- a/src/bin/dhcp4/dhcp4_lexer.ll +++ b/src/bin/dhcp4/dhcp4_lexer.ll @@ -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. diff --git a/src/bin/dhcp4/dhcp4_parser.yy b/src/bin/dhcp4/dhcp4_parser.yy index 10b5ae68b2..a6a535f347 100644 --- a/src/bin/dhcp4/dhcp4_parser.yy +++ b/src/bin/dhcp4/dhcp4_parser.yy @@ -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))); diff --git a/src/bin/dhcp4/json_config_parser.cc b/src/bin/dhcp4/json_config_parser.cc index 0b1b7e2e3b..6e203d7a6e 100644 --- a/src/bin/dhcp4/json_config_parser.cc +++ b/src/bin/dhcp4/json_config_parser.cc @@ -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; diff --git a/src/lib/dhcpsrv/cfg_globals.cc b/src/lib/dhcpsrv/cfg_globals.cc index e9e76934ab..c5f2346443 100644 --- a/src/lib/dhcpsrv/cfg_globals.cc +++ b/src/lib/dhcpsrv/cfg_globals.cc @@ -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 }, diff --git a/src/lib/dhcpsrv/cfg_globals.h b/src/lib/dhcpsrv/cfg_globals.h index 4456435af2..06e3cde10d 100644 --- a/src/lib/dhcpsrv/cfg_globals.h +++ b/src/lib/dhcpsrv/cfg_globals.h @@ -91,6 +91,7 @@ public: SERVER_HOSTNAME, BOOT_FILE_NAME, OFFER_LIFETIME, + STASH_AGENT_OPTIONS, // DHCPv6 specific parameters. DATA_DIRECTORY, diff --git a/src/lib/dhcpsrv/parsers/simple_parser4.cc b/src/lib/dhcpsrv/parsers/simple_parser4.cc index 1e4c32301f..0a079abcf6 100644 --- a/src/lib/dhcpsrv/parsers/simple_parser4.cc +++ b/src/lib/dhcpsrv/parsers/simple_parser4.cc @@ -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.