]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3609] Checkpoint: updated grammars
authorFrancis Dupont <fdupont@isc.org>
Wed, 13 Nov 2024 09:56:08 +0000 (10:56 +0100)
committerFrancis Dupont <fdupont@isc.org>
Fri, 22 Nov 2024 08:55:30 +0000 (09:55 +0100)
12 files changed:
src/bin/agent/agent_lexer.ll
src/bin/agent/agent_parser.yy
src/bin/agent/parser_context.cc
src/bin/agent/parser_context.h
src/bin/dhcp4/dhcp4_lexer.ll
src/bin/dhcp4/dhcp4_parser.yy
src/bin/dhcp4/parser_context.cc
src/bin/dhcp4/parser_context.h
src/bin/dhcp6/dhcp6_lexer.ll
src/bin/dhcp6/dhcp6_parser.yy
src/bin/dhcp6/parser_context.cc
src/bin/dhcp6/parser_context.h

index f2e6f354c4656846a9708f13283fdfab671f81af..1e649b83714c4b100acd1b03af4cc6bd6221326d 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2017-2023 Internet Systems Consortium, Inc. ("ISC")
+/* Copyright (C) 2017-2024 Internet Systems Consortium, Inc. ("ISC")
 
    This Source Code Form is subject to the terms of the Mozilla Public
    License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -202,9 +202,19 @@ ControlCharacterFill            [^"\\]|\\["\\/bfnrtu]
     }
 }
 
+\"http-headers\" {
+    switch(driver.ctx_) {
+    case ParserContext::AGENT:
+        return AgentParser::make_HTTP_HEADERS(driver.loc_);
+    default:
+        return AgentParser::make_STRING("http-headers", driver.loc_);
+    }
+}
+
 \"user-context\" {
     switch(driver.ctx_) {
     case ParserContext::AGENT:
+    case ParserContext::HTTP_HEADERS:
     case ParserContext::AUTHENTICATION:
     case ParserContext::CLIENTS:
     case ParserContext::SERVER:
@@ -218,6 +228,7 @@ ControlCharacterFill            [^"\\]|\\["\\/bfnrtu]
 \"comment\" {
     switch(driver.ctx_) {
     case ParserContext::AGENT:
+    case ParserContext::HTTP_HEADERS:
     case ParserContext::AUTHENTICATION:
     case ParserContext::CLIENTS:
     case ParserContext::SERVER:
@@ -228,6 +239,25 @@ ControlCharacterFill            [^"\\]|\\["\\/bfnrtu]
     }
 }
 
+\"name\" {
+    switch(driver.ctx_) {
+    case ParserContext::LOGGERS:
+    case ParserContext::HTTP_HEADERS:
+        return AgentParser::make_NAME(driver.loc_);
+    default:
+        return AgentParser::make_STRING("name", driver.loc_);
+    }
+}
+
+\"value\" {
+    switch(driver.ctx_) {
+    case ParserContext::HTTP_HEADERS:
+        return AgentParser::make_VALUE(driver.loc_);
+    default:
+        return AgentParser::make_STRING("value", driver.loc_);
+    }
+}
+
 \"authentication\" {
     switch(driver.ctx_) {
     case ParserContext::AGENT:
@@ -453,15 +483,6 @@ ControlCharacterFill            [^"\\]|\\["\\/bfnrtu]
     }
 }
 
-\"name\" {
-    switch(driver.ctx_) {
-    case ParserContext::LOGGERS:
-        return AgentParser::make_NAME(driver.loc_);
-    default:
-        return AgentParser::make_STRING("name", driver.loc_);
-    }
-}
-
 \"output_options\" {
     switch(driver.ctx_) {
     case ParserContext::LOGGERS:
index 8531a7fa9b5ee3cf4962ae1446796635101f2ef2..e239a58c4d323f94220db0dda71dc1b4a66d7019 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2017-2023 Internet Systems Consortium, Inc. ("ISC")
+/* Copyright (C) 2017-2024 Internet Systems Consortium, Inc. ("ISC")
 
    This Source Code Form is subject to the terms of the Mozilla Public
    License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -56,10 +56,14 @@ using namespace std;
   CONTROL_AGENT "Control-agent"
   HTTP_HOST "http-host"
   HTTP_PORT "http-port"
+  HTTP_HEADERS "http-headers"
 
   USER_CONTEXT "user-context"
   COMMENT "comment"
 
+  NAME "name"
+  VALUE "value"
+
   AUTHENTICATION "authentication"
   TYPE "type"
   BASIC "basic"
@@ -89,7 +93,6 @@ using namespace std;
   PARAMETERS "parameters"
 
   LOGGERS "loggers"
-  NAME "name"
   OUTPUT_OPTIONS "output-options"
   OUTPUT "output"
   DEBUGLEVEL "debuglevel"
@@ -291,6 +294,7 @@ global_params: global_param
 // Dhcp6.
 global_param: http_host
             | http_port
+            | http_headers
             | trust_anchor
             | cert_file
             | key_file
@@ -404,6 +408,63 @@ comment: COMMENT {
     ctx.leave();
 };
 
+http_headers: HTTP_HEADERS {
+    ctx.unique("http-headers", ctx.loc2pos(@1));
+    ElementPtr l(new ListElement(ctx.loc2pos(@1)));
+    ctx.stack_.back()->set("http-headers", l);
+    ctx.enter(ctx.HTTP_HEADERS);
+} COLON LSQUARE_BRACKET http_header_list RSQUARE_BRACKET {
+    ctx.stack_.pop_back();
+    ctx.leave();
+};
+
+http_header_list: http_header
+                | not_empty_http_header_list COMMA http_header
+                | not_empty_http_header_list COMMA {
+                    ctx.warnAboutExtraCommas(@2);
+                    }
+                ;
+
+http_header: LCURLY_BRACKET {
+    ElementPtr m(new MapElement(ctx.loc2pos(@1)));
+    ctx.stack_.back()->add(m);
+    ctx.stack_.push_back(m);
+} http_header_params RCURLY_BRACKET {
+    ctx.stack_.pop_back();
+};
+
+http_header_params: http_header_param
+                  | http_header_params COMMA http_header_param
+                  | http_header_params COMMA {
+                      ctx.warnAboutExtraCommas(@2);
+                      }
+                  ;
+
+http_header_param: name
+                 | value
+                 | user_context
+                 | comment
+                 | unknown_map_entry
+                 ;
+
+name: NAME {
+    ctx.unique("name", ctx.loc2pos(@1));
+    ctx.enter(ctx.NO_KEYWORDS);
+} COLON STRING {
+    ElementPtr name(new StringElement($4, ctx.loc2pos(@4)));
+    ctx.stack_.back()->set("name", name);
+    ctx.leave();
+};
+
+value: VALUE {
+    ctx.unique("value", ctx.loc2pos(@1));
+    ctx.enter(ctx.NO_KEYWORDS);
+} COLON STRING {
+    ElementPtr value(new StringElement($4, ctx.loc2pos(@4)));
+    ctx.stack_.back()->set("value", value);
+    ctx.leave();
+};
+
 // --- hooks-libraries ---------------------------------------------------------
 hooks_libraries: HOOKS_LIBRARIES {
     ctx.unique("hooks-libraries", ctx.loc2pos(@1));
@@ -764,15 +825,6 @@ logger_param: name
             | unknown_map_entry
             ;
 
-name: NAME {
-    ctx.unique("name", ctx.loc2pos(@1));
-    ctx.enter(ctx.NO_KEYWORDS);
-} COLON STRING {
-    ElementPtr name(new StringElement($4, ctx.loc2pos(@4)));
-    ctx.stack_.back()->set("name", name);
-    ctx.leave();
-};
-
 debuglevel: DEBUGLEVEL COLON INTEGER {
     ctx.unique("debuglevel", ctx.loc2pos(@1));
     ElementPtr dl(new IntElement($3, ctx.loc2pos(@3)));
index d8b28bb8fc3dc2ce36f684163b7c2bbc7cb1c470..07702d46be9e58da9ca25fdbd8b37277d8e9fe68 100644 (file)
@@ -162,6 +162,8 @@ ParserContext::contextName()
         return ("toplevel");
     case AGENT:
         return ("Control-agent");
+    case HTTP_HEADERS:
+        return ("http-headers");
     case AUTHENTICATION:
         return ("authentication");
     case AUTH_TYPE:
index fa637860fcdd7fe25d7f0432ab99e495408adf19..9e98a99c7cef9c96dcb980f164896484a4058b5f 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2017-2023 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2017-2024 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -203,6 +203,9 @@ public:
         ///< Used while parsing content of Agent.
         AGENT,
 
+        ///< Used while parsing HTTP headers.
+        HTTP_HEADERS,
+
         ///< Used while parsing Control-agent/Authentication.
         AUTHENTICATION,
 
index aebf54f6f45d54e76965948c75ec6245175d12d2..e5ed2de4cc606e906514ec32cfe5ee03e73f8f67 100644 (file)
@@ -968,6 +968,7 @@ ControlCharacterFill            [^"\\]|\\["\\/bfnrtu]
     case isc::dhcp::Parser4Context::OPTION_DATA:
     case isc::dhcp::Parser4Context::CLIENT_CLASSES:
     case isc::dhcp::Parser4Context::SHARED_NETWORK:
+    case isc::dhcp::Parser4Context::HTTP_HEADERS:
     case isc::dhcp::Parser4Context::LOGGERS:
         return isc::dhcp::Dhcp4Parser::make_NAME(driver.loc_);
     default:
@@ -1043,6 +1044,7 @@ ControlCharacterFill            [^"\\]|\\["\\/bfnrtu]
     case isc::dhcp::Parser4Context::CONTROL_SOCKET:
     case isc::dhcp::Parser4Context::AUTHENTICATION:
     case isc::dhcp::Parser4Context::CLIENTS:
+    case isc::dhcp::Parser4Context::HTTP_HEADERS:
     case isc::dhcp::Parser4Context::DHCP_QUEUE_CONTROL:
     case isc::dhcp::Parser4Context::DHCP_MULTI_THREADING:
     case isc::dhcp::Parser4Context::LOGGERS:
@@ -1067,6 +1069,7 @@ ControlCharacterFill            [^"\\]|\\["\\/bfnrtu]
     case isc::dhcp::Parser4Context::CONTROL_SOCKET:
     case isc::dhcp::Parser4Context::AUTHENTICATION:
     case isc::dhcp::Parser4Context::CLIENTS:
+    case isc::dhcp::Parser4Context::HTTP_HEADERS:
     case isc::dhcp::Parser4Context::DHCP_QUEUE_CONTROL:
     case isc::dhcp::Parser4Context::DHCP_MULTI_THREADING:
     case isc::dhcp::Parser4Context::LOGGERS:
@@ -1814,6 +1817,24 @@ ControlCharacterFill            [^"\\]|\\["\\/bfnrtu]
     }
 }
 
+\"http-headers\" {
+    switch(driver.ctx_) {
+    case isc::dhcp::Parser6Context::CONTROL_SOCKET:
+        return isc::dhcp::Dhcp6Parser::make_HTTP_HEADERS(driver.loc_);
+    default:
+        return isc::dhcp::Dhcp6Parser::make_STRING("http-headers", driver.loc_);
+    }
+}
+
+\"value\" {
+    switch(driver.ctx_) {
+    case isc::dhcp::Parser6Context::HTTP_HEADERS:
+        return isc::dhcp::Dhcp6Parser::make_VALUE(driver.loc_);
+    default:
+        return isc::dhcp::Dhcp6Parser::make_STRING("value", driver.loc_);
+    }
+}
+
 \"dhcp-queue-control\" {
     switch(driver.ctx_) {
     case isc::dhcp::Parser4Context::DHCP4:
index df85a44a8364c05a376d22a05573bf4dead40a0a..2d11090ab6b88db227d53f757f12ffd47459e42a 100644 (file)
@@ -236,6 +236,8 @@ using namespace std;
   USER_FILE "user-file"
   PASSWORD_FILE "password-file"
   CERT_REQUIRED "cert-required"
+  HTTP_HEADERS "http-headers"
+  VALUE "value"
 
   DHCP_QUEUE_CONTROL "dhcp-queue-control"
   ENABLE_QUEUE "enable-queue"
@@ -2599,6 +2601,7 @@ control_socket_param: control_socket_type
                     | cert_file
                     | key_file
                     | cert_required
+                    | http_headers
                     | user_context
                     | comment
                     | unknown_map_entry
@@ -2650,6 +2653,54 @@ cert_required: CERT_REQUIRED COLON BOOLEAN {
     ctx.stack_.back()->set("cert-required", req);
 };
 
+http_headers: HTTP_HEADERS {
+    ctx.unique("http-headers", ctx.loc2pos(@1));
+    ElementPtr l(new ListElement(ctx.loc2pos(@1)));
+    ctx.stack_.back()->set("http-headers", l);
+    ctx.enter(ctx.HTTP_HEADERS);
+} COLON LSQUARE_BRACKET http_header_list RSQUARE_BRACKET {
+    ctx.stack_.pop_back();
+    ctx.leave();
+};
+
+http_header_list: http_header
+                | not_empty_http_header_list COMMA http_header
+                | not_empty_http_header_list COMMA {
+                    ctx.warnAboutExtraCommas(@2);
+                    }
+                ;
+
+http_header: LCURLY_BRACKET {
+    ElementPtr m(new MapElement(ctx.loc2pos(@1)));
+    ctx.stack_.back()->add(m);
+    ctx.stack_.push_back(m);
+} http_header_params RCURLY_BRACKET {
+    ctx.stack_.pop_back();
+};
+
+http_header_params: http_header_param
+                  | http_header_params COMMA http_header_param
+                  | http_header_params COMMA {
+                      ctx.warnAboutExtraCommas(@2);
+                      }
+                  ;
+
+http_header_param: name
+                 | value
+                 | user_context
+                 | comment
+                 | unknown_map_entry
+                 ;
+
+value: VALUE {
+    ctx.unique("value", ctx.loc2pos(@1));
+    ctx.enter(ctx.NO_KEYWORD);
+} COLON STRING {
+    ElementPtr value(new StringElement($4, ctx.loc2pos(@4)));
+    ctx.stack_.back()->set("value", value);
+    ctx.leave();
+};
+
 // --- authentication ---------------------------------------------
 
 authentication: AUTHENTICATION {
index e8f4157a76d4419fe8435e391996bd041cce0f6f..01d6de10184ab6c9da1588e3b1ab33fd0385fe9a 100644 (file)
@@ -192,6 +192,8 @@ Parser4Context::contextName() {
         return ("auth-type");
     case CLIENTS:
         return ("clients");
+    case HTTP_HEADERS:
+        return ("http-headers");
     case DHCP_QUEUE_CONTROL:
         return ("dhcp-queue-control");
     case DHCP_MULTI_THREADING:
index 364cd9c0dc2ecbd3633101285a5c0a820a74198e..9a65eb1cefd1f5056b6076820b8933911c3a96c6 100644 (file)
@@ -304,6 +304,9 @@ public:
         /// structures.
         CLIENTS,
 
+        ///< Used while parsing Dhcp4/control-socket/http-headers structures.
+        HTTP_HEADERS,
+
         /// Used while parsing Dhcp4/dhcp-queue-control structures.
         DHCP_QUEUE_CONTROL,
 
index f1ab111ba4ab6db18fd3c9205396c936ed33bc8a..ee180eff8cea951772ccfde4d1d6feb1c8af545d 100644 (file)
@@ -1166,6 +1166,7 @@ ControlCharacterFill            [^"\\]|\\["\\/bfnrtu]
     case isc::dhcp::Parser6Context::CLIENT_CLASSES:
     case isc::dhcp::Parser6Context::LOGGERS:
     case isc::dhcp::Parser6Context::SHARED_NETWORK:
+    case isc::dhcp::Parser6Context::HTTP_HEADERS:
     case isc::dhcp::Parser6Context::CONFIG_DATABASE:
         return isc::dhcp::Dhcp6Parser::make_NAME(driver.loc_);
     default:
@@ -1298,6 +1299,7 @@ ControlCharacterFill            [^"\\]|\\["\\/bfnrtu]
     case isc::dhcp::Parser6Context::CONTROL_SOCKET:
     case isc::dhcp::Parser6Context::AUTHENTICATION:
     case isc::dhcp::Parser6Context::CLIENTS:
+    case isc::dhcp::Parser6Context::HTTP_HEADERS:
     case isc::dhcp::Parser6Context::DHCP_QUEUE_CONTROL:
     case isc::dhcp::Parser6Context::DHCP_MULTI_THREADING:
     case isc::dhcp::Parser6Context::LOGGERS:
@@ -1324,6 +1326,7 @@ ControlCharacterFill            [^"\\]|\\["\\/bfnrtu]
     case isc::dhcp::Parser6Context::CONTROL_SOCKET:
     case isc::dhcp::Parser6Context::AUTHENTICATION:
     case isc::dhcp::Parser6Context::CLIENTS:
+    case isc::dhcp::Parser6Context::HTTP_HEADERS:
     case isc::dhcp::Parser6Context::DHCP_QUEUE_CONTROL:
     case isc::dhcp::Parser6Context::DHCP_MULTI_THREADING:
     case isc::dhcp::Parser6Context::LOGGERS:
@@ -2175,6 +2178,15 @@ ControlCharacterFill            [^"\\]|\\["\\/bfnrtu]
     }
 }
 
+\"http-headers\" {
+    switch(driver.ctx_) {
+    case isc::dhcp::Parser4Context::CONTROL_SOCKET:
+        return isc::dhcp::Dhcp4Parser::make_HTTP_HEADERS(driver.loc_);
+    default:
+        return isc::dhcp::Dhcp4Parser::make_STRING("http-headers", driver.loc_);
+    }
+}
+
 \"dhcp-queue-control\" {
     switch(driver.ctx_) {
     case isc::dhcp::Parser6Context::DHCP6:
index 8b46d35ae7f7d1859f17950b805a44505b10ba41..05731dcc5377d532ccc3d580a270c5dddc2d0312 100644 (file)
@@ -241,6 +241,8 @@ using namespace std;
   USER_FILE "user-file"
   PASSWORD_FILE "password-file"
   CERT_REQUIRED "cert-required"
+  HTTP_HEADERS "http-headers"
+  VALUE "value"
 
   DHCP_QUEUE_CONTROL "dhcp-queue-control"
   ENABLE_QUEUE "enable-queue"
@@ -2741,6 +2743,7 @@ control_socket_param: control_socket_type
                     | cert_file
                     | key_file
                     | cert_required
+                    | http_headers
                     | user_context
                     | comment
                     | unknown_map_entry
@@ -2792,6 +2795,54 @@ cert_required: CERT_REQUIRED COLON BOOLEAN {
     ctx.stack_.back()->set("cert-required", req);
 };
 
+http_headers: HTTP_HEADERS {
+    ctx.unique("http-headers", ctx.loc2pos(@1));
+    ElementPtr l(new ListElement(ctx.loc2pos(@1)));
+    ctx.stack_.back()->set("http-headers", l);
+    ctx.enter(ctx.HTTP_HEADERS);
+} COLON LSQUARE_BRACKET http_header_list RSQUARE_BRACKET {
+    ctx.stack_.pop_back();
+    ctx.leave();
+};
+
+http_header_list: http_header
+                | not_empty_http_header_list COMMA http_header
+                | not_empty_http_header_list COMMA {
+                    ctx.warnAboutExtraCommas(@2);
+                    }
+                ;
+
+http_header: LCURLY_BRACKET {
+    ElementPtr m(new MapElement(ctx.loc2pos(@1)));
+    ctx.stack_.back()->add(m);
+    ctx.stack_.push_back(m);
+} http_header_params RCURLY_BRACKET {
+    ctx.stack_.pop_back();
+};
+
+http_header_params: http_header_param
+                  | http_header_params COMMA http_header_param
+                  | http_header_params COMMA {
+                      ctx.warnAboutExtraCommas(@2);
+                      }
+                  ;
+
+http_header_param: name
+                 | value
+                 | user_context
+                 | comment
+                 | unknown_map_entry
+                 ;
+
+value: VALUE {
+    ctx.unique("value", ctx.loc2pos(@1));
+    ctx.enter(ctx.NO_KEYWORD);
+} COLON STRING {
+    ElementPtr value(new StringElement($4, ctx.loc2pos(@4)));
+    ctx.stack_.back()->set("value", value);
+    ctx.leave();
+};
+
 // --- authentication ---------------------------------------------
 
 authentication: AUTHENTICATION {
index 52c7e8b0a865520f47f98c126327220e5c1a91dc..453c93a03e90bc68d88d60e932fd9b33fb29c069 100644 (file)
@@ -191,6 +191,8 @@ Parser6Context::contextName() {
         return ("auth-type");
     case CLIENTS:
         return ("clients");
+    case HTTP_HEADERS:
+        return ("http-headers");
     case DHCP_QUEUE_CONTROL:
         return ("dhcp-queue-control");
     case DHCP_MULTI_THREADING:
index 0411b7ba7ad0b85330a5404b456d5d13c52a752b..6534d45d9d266fde03abd0c68f7545cf05191fa3 100644 (file)
@@ -307,6 +307,9 @@ public:
         /// structures.
         CLIENTS,
 
+        ///< Used while parsing Dhcp6/control-socket/http-headers structures.
+        HTTP_HEADERS,
+
         /// Used while parsing Dhcp6/dhcp-queue-control structures.
         DHCP_QUEUE_CONTROL,