summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrei Pavel <andrei@isc.org>2021-05-14 13:39:30 +0200
committerAndrei Pavel <andrei@isc.org>2021-05-19 14:59:02 +0200
commit2872ae70f9b581c895f4b94d7927b112add1175a (patch)
tree4612c50d77c69f7181aa9b550f58fb6b50532b7e /src
parent[#1818] added more checks in unittests (diff)
downloadkea-2872ae70f9b581c895f4b94d7927b112add1175a.tar.xz
kea-2872ae70f9b581c895f4b94d7927b112add1175a.zip
[#1860] add "compatibility" parameter to parsers
and "lenient-option-parsing"
Diffstat (limited to 'src')
-rw-r--r--src/bin/dhcp4/dhcp4_lexer.ll18
-rw-r--r--src/bin/dhcp4/dhcp4_parser.yy29
-rw-r--r--src/bin/dhcp4/json_config_parser.cc3
-rw-r--r--src/bin/dhcp4/parser_context.cc2
-rw-r--r--src/bin/dhcp4/parser_context.h5
-rw-r--r--src/bin/dhcp6/dhcp6_lexer.ll18
-rw-r--r--src/bin/dhcp6/dhcp6_parser.yy29
-rw-r--r--src/bin/dhcp6/json_config_parser.cc3
-rw-r--r--src/bin/dhcp6/parser_context.cc2
-rw-r--r--src/bin/dhcp6/parser_context.h5
10 files changed, 110 insertions, 4 deletions
diff --git a/src/bin/dhcp4/dhcp4_lexer.ll b/src/bin/dhcp4/dhcp4_lexer.ll
index 436d22b129..d107b0ec3d 100644
--- a/src/bin/dhcp4/dhcp4_lexer.ll
+++ b/src/bin/dhcp4/dhcp4_lexer.ll
@@ -1974,6 +1974,24 @@ ControlCharacterFill [^"\\]|\\["\\/bfnrtu]
}
}
+\"compatibility\" {
+ switch(driver.ctx_) {
+ case isc::dhcp::Parser4Context::DHCP4:
+ return isc::dhcp::Dhcp4Parser::make_COMPATIBILITY(driver.loc_);
+ default:
+ return isc::dhcp::Dhcp4Parser::make_STRING("compatibility", driver.loc_);
+ }
+}
+
+\"lenient-option-parsing\" {
+ switch(driver.ctx_) {
+ case isc::dhcp::Parser4Context::COMPATIBILITY:
+ return isc::dhcp::Dhcp4Parser::make_LENIENT_OPTION_PARSING(driver.loc_);
+ default:
+ return isc::dhcp::Dhcp4Parser::make_STRING("lenient-option-parsing", 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 88e371575b..6b5b3ef741 100644
--- a/src/bin/dhcp4/dhcp4_parser.yy
+++ b/src/bin/dhcp4/dhcp4_parser.yy
@@ -246,6 +246,9 @@ using namespace std;
MAXVER "maxver"
PATTERN "pattern"
+ COMPATIBILITY "compatibility"
+ LENIENT_OPTION_PARSING "lenient-option-parsing"
+
// Not real tokens, just a way to signal what the parser is expected to
// parse.
TOPLEVEL_JSON
@@ -515,6 +518,7 @@ global_param: valid_lifetime
| statistic_default_sample_age
| dhcp_multi_threading
| ip_reservations_unique
+ | compatibility
| unknown_map_entry
;
@@ -2692,6 +2696,31 @@ pattern: PATTERN {
ctx.leave();
};
+compatibility: COMPATIBILITY {
+ ctx.unique("compatibility", ctx.loc2pos(@1));
+ ElementPtr i(new MapElement(ctx.loc2pos(@1)));
+ ctx.stack_.back()->set("compatibility", i);
+ ctx.stack_.push_back(i);
+ ctx.enter(ctx.COMPATIBILITY);
+} COLON LCURLY_BRACKET compatibility_params RCURLY_BRACKET {
+ ctx.stack_.pop_back();
+ ctx.leave();
+};
+
+compatibility_params: compatibility_param
+ | compatibility_params COMMA compatibility_param
+ ;
+
+compatibility_param: lenient_option_parsing
+ | unknown_map_entry
+ ;
+
+lenient_option_parsing: LENIENT_OPTION_PARSING COLON BOOLEAN {
+ ctx.unique("lenient-option-parsing", ctx.loc2pos(@1));
+ ElementPtr b(new BoolElement($3, ctx.loc2pos(@3)));
+ ctx.stack_.back()->set("lenient-option-parsing", b);
+};
+
%%
void
diff --git a/src/bin/dhcp4/json_config_parser.cc b/src/bin/dhcp4/json_config_parser.cc
index 849fdb9312..a8ea78fd59 100644
--- a/src/bin/dhcp4/json_config_parser.cc
+++ b/src/bin/dhcp4/json_config_parser.cc
@@ -606,7 +606,8 @@ configureDhcp4Server(Dhcpv4Srv& server, isc::data::ConstElementPtr config_set,
(config_pair.first == "subnet4") ||
(config_pair.first == "shared-networks") ||
(config_pair.first == "reservations") ||
- (config_pair.first == "config-control")) {
+ (config_pair.first == "config-control") ||
+ (config_pair.first == "compatibility")) {
continue;
}
diff --git a/src/bin/dhcp4/parser_context.cc b/src/bin/dhcp4/parser_context.cc
index 418a0b52d1..df8e7f681f 100644
--- a/src/bin/dhcp4/parser_context.cc
+++ b/src/bin/dhcp4/parser_context.cc
@@ -228,6 +228,8 @@ Parser4Context::contextName()
return ("config-control");
case CONFIG_DATABASE:
return ("config-database");
+ case COMPATIBILITY:
+ return ("compatibility");
default:
return ("__unknown__");
}
diff --git a/src/bin/dhcp4/parser_context.h b/src/bin/dhcp4/parser_context.h
index f432d330fc..79aa7fa3fa 100644
--- a/src/bin/dhcp4/parser_context.h
+++ b/src/bin/dhcp4/parser_context.h
@@ -318,7 +318,10 @@ public:
CONFIG_CONTROL,
/// Used while parsing config-control/config-databases
- CONFIG_DATABASE
+ CONFIG_DATABASE,
+
+ /// Used while parsing compatibility parmaeters
+ COMPATIBILITY,
} ParserContext;
diff --git a/src/bin/dhcp6/dhcp6_lexer.ll b/src/bin/dhcp6/dhcp6_lexer.ll
index 992a3da63e..a7f933d301 100644
--- a/src/bin/dhcp6/dhcp6_lexer.ll
+++ b/src/bin/dhcp6/dhcp6_lexer.ll
@@ -2033,6 +2033,24 @@ ControlCharacterFill [^"\\]|\\["\\/bfnrtu]
}
}
+\"compatibility\" {
+ switch(driver.ctx_) {
+ case isc::dhcp::Parser6Context::DHCP6:
+ return isc::dhcp::Dhcp6Parser::make_COMPATIBILITY(driver.loc_);
+ default:
+ return isc::dhcp::Dhcp6Parser::make_STRING("compatibility", driver.loc_);
+ }
+}
+
+\"lenient-option-parsing\" {
+ switch(driver.ctx_) {
+ case isc::dhcp::Parser6Context::COMPATIBILITY:
+ return isc::dhcp::Dhcp6Parser::make_LENIENT_OPTION_PARSING(driver.loc_);
+ default:
+ return isc::dhcp::Dhcp6Parser::make_STRING("lenient-option-parsing", 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/dhcp6/dhcp6_parser.yy b/src/bin/dhcp6/dhcp6_parser.yy
index 18cfc9b343..555eed87e7 100644
--- a/src/bin/dhcp6/dhcp6_parser.yy
+++ b/src/bin/dhcp6/dhcp6_parser.yy
@@ -253,6 +253,9 @@ using namespace std;
MAXVER "maxver"
PATTERN "pattern"
+ COMPATIBILITY "compatibility"
+ LENIENT_OPTION_PARSING "lenient-option-parsing"
+
// Not real tokens, just a way to signal what the parser is expected to
// parse.
TOPLEVEL_JSON
@@ -524,6 +527,7 @@ global_param: data_directory
| statistic_default_sample_age
| dhcp_multi_threading
| ip_reservations_unique
+ | compatibility
| unknown_map_entry
;
@@ -2818,6 +2822,31 @@ pattern: PATTERN {
ctx.leave();
};
+compatibility: COMPATIBILITY {
+ ctx.unique("compatibility", ctx.loc2pos(@1));
+ ElementPtr i(new MapElement(ctx.loc2pos(@1)));
+ ctx.stack_.back()->set("compatibility", i);
+ ctx.stack_.push_back(i);
+ ctx.enter(ctx.COMPATIBILITY);
+} COLON LCURLY_BRACKET compatibility_params RCURLY_BRACKET {
+ ctx.stack_.pop_back();
+ ctx.leave();
+};
+
+compatibility_params: compatibility_param
+ | compatibility_params COMMA compatibility_param
+ ;
+
+compatibility_param: lenient_option_parsing
+ | unknown_map_entry
+ ;
+
+lenient_option_parsing: LENIENT_OPTION_PARSING COLON BOOLEAN {
+ ctx.unique("lenient-option-parsing", ctx.loc2pos(@1));
+ ElementPtr b(new BoolElement($3, ctx.loc2pos(@3)));
+ ctx.stack_.back()->set("lenient-option-parsing", b);
+};
+
%%
void
diff --git a/src/bin/dhcp6/json_config_parser.cc b/src/bin/dhcp6/json_config_parser.cc
index 33ade09d9b..c6a31a8a63 100644
--- a/src/bin/dhcp6/json_config_parser.cc
+++ b/src/bin/dhcp6/json_config_parser.cc
@@ -743,7 +743,8 @@ configureDhcp6Server(Dhcpv6Srv& server, isc::data::ConstElementPtr config_set,
(config_pair.first == "shared-networks") ||
(config_pair.first == "reservations") ||
(config_pair.first == "config-control") ||
- (config_pair.first == "relay-supplied-options")) {
+ (config_pair.first == "relay-supplied-options") ||
+ (config_pair.first == "compatibility")) {
continue;
}
diff --git a/src/bin/dhcp6/parser_context.cc b/src/bin/dhcp6/parser_context.cc
index f0ecc27e44..1577320e1d 100644
--- a/src/bin/dhcp6/parser_context.cc
+++ b/src/bin/dhcp6/parser_context.cc
@@ -229,6 +229,8 @@ Parser6Context::contextName()
return ("config-control");
case CONFIG_DATABASE:
return ("config-database");
+ case COMPATIBILITY:
+ return ("compatibility");
default:
return ("__unknown__");
}
diff --git a/src/bin/dhcp6/parser_context.h b/src/bin/dhcp6/parser_context.h
index 4122d0dd4c..3ab6ee4a89 100644
--- a/src/bin/dhcp6/parser_context.h
+++ b/src/bin/dhcp6/parser_context.h
@@ -324,7 +324,10 @@ public:
CONFIG_CONTROL,
/// Used while parsing config-control/config-databases
- CONFIG_DATABASE
+ CONFIG_DATABASE,
+
+ /// Used while parsing compatibility parmaeters
+ COMPATIBILITY,
} ParserContext;