Commit 0d97d2c0 authored by Tomek Mrugalski's avatar Tomek Mrugalski 🛰

[5036] readonly support added in hosts-database

parent c19f1840
...@@ -45,7 +45,8 @@ ...@@ -45,7 +45,8 @@
"name": "kea", "name": "kea",
"user": "kea", "user": "kea",
"password": "kea", "password": "kea",
"host": "localhost" "host": "localhost",
"readonly": true
}, },
# Define a subnet with a pool of dynamic addresses and a pool of dynamic # Define a subnet with a pool of dynamic addresses and a pool of dynamic
......
...@@ -157,7 +157,7 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence} ...@@ -157,7 +157,7 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
isc_throw(Dhcp6ParseError, "Directive not closed."); isc_throw(Dhcp6ParseError, "Directive not closed.");
} }
<DIR_EXIT>"?>" BEGIN(INITIAL); <DIR_EXIT>"?>" BEGIN(INITIAL);
<*>{blank}+ { <*>{blank}+ {
// Ok, we found a with space. Let's ignore it and update loc variable. // Ok, we found a with space. Let's ignore it and update loc variable.
...@@ -216,6 +216,15 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence} ...@@ -216,6 +216,15 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
} }
} }
\"readonly\" {
switch(driver.ctx_) {
case isc::dhcp::Parser6Context::HOSTS_DATABASE:
return isc::dhcp::Dhcp6Parser::make_READONLY(driver.loc_);
default:
return isc::dhcp::Dhcp6Parser::make_STRING("readonly", driver.loc_);
}
}
\"type\" { \"type\" {
switch(driver.ctx_) { switch(driver.ctx_) {
case isc::dhcp::Parser6Context::LEASE_DATABASE: case isc::dhcp::Parser6Context::LEASE_DATABASE:
...@@ -961,7 +970,7 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence} ...@@ -961,7 +970,7 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
// Bad string with a bad escape inside // Bad string with a bad escape inside
driver.error(driver.loc_, "Bad escape in " + std::string(yytext)); driver.error(driver.loc_, "Bad escape in " + std::string(yytext));
} }
\"{JSONStringCharacter}*\\\" { \"{JSONStringCharacter}*\\\" {
// Bad string with an open escape at the end // Bad string with an open escape at the end
driver.error(driver.loc_, "Overflow escape in " + std::string(yytext)); driver.error(driver.loc_, "Overflow escape in " + std::string(yytext));
......
...@@ -62,6 +62,7 @@ using namespace std; ...@@ -62,6 +62,7 @@ using namespace std;
HOST "host" HOST "host"
PERSIST "persist" PERSIST "persist"
LFC_INTERVAL "lfc-interval" LFC_INTERVAL "lfc-interval"
READONLY "readonly"
PREFERRED_LIFETIME "preferred-lifetime" PREFERRED_LIFETIME "preferred-lifetime"
VALID_LIFETIME "valid-lifetime" VALID_LIFETIME "valid-lifetime"
...@@ -442,6 +443,7 @@ database_map_param: type ...@@ -442,6 +443,7 @@ database_map_param: type
| name | name
| persist | persist
| lfc_interval | lfc_interval
| readonly
| unknown_map_entry | unknown_map_entry
; ;
...@@ -495,6 +497,11 @@ lfc_interval: LFC_INTERVAL COLON INTEGER { ...@@ -495,6 +497,11 @@ lfc_interval: LFC_INTERVAL COLON INTEGER {
ctx.stack_.back()->set("lfc-interval", n); ctx.stack_.back()->set("lfc-interval", n);
}; };
readonly: READONLY COLON BOOLEAN {
ElementPtr n(new BoolElement($3, ctx.loc2pos(@3)));
ctx.stack_.back()->set("readonly", n);
};
mac_sources: MAC_SOURCES { mac_sources: MAC_SOURCES {
ElementPtr l(new ListElement(ctx.loc2pos(@1))); ElementPtr l(new ListElement(ctx.loc2pos(@1)));
ctx.stack_.back()->set("mac-sources", l); ctx.stack_.back()->set("mac-sources", l);
...@@ -803,6 +810,9 @@ option_def_entry: LCURLY_BRACKET { ...@@ -803,6 +810,9 @@ option_def_entry: LCURLY_BRACKET {
ctx.stack_.pop_back(); ctx.stack_.pop_back();
}; };
// This defines the top level scope when the parser is told to parse a single
// option definition. It's almost exactly the same as option_def_entry, except
// that it does leave its value on stack.
sub_option_def: LCURLY_BRACKET { sub_option_def: LCURLY_BRACKET {
// Parse the option-def list entry map // Parse the option-def list entry map
ElementPtr m(new MapElement(ctx.loc2pos(@1))); ElementPtr m(new MapElement(ctx.loc2pos(@1)));
...@@ -893,6 +903,8 @@ option_data_list_content: %empty ...@@ -893,6 +903,8 @@ option_data_list_content: %empty
| not_empty_option_data_list | not_empty_option_data_list
; ;
// This defines the content of option-data list. It can either
// be a single value or multiple entries separated by comma.
not_empty_option_data_list: option_data_entry not_empty_option_data_list: option_data_entry
| not_empty_option_data_list COMMA option_data_entry | not_empty_option_data_list COMMA option_data_entry
; ;
...@@ -907,6 +919,9 @@ option_data_entry: LCURLY_BRACKET { ...@@ -907,6 +919,9 @@ option_data_entry: LCURLY_BRACKET {
ctx.stack_.pop_back(); ctx.stack_.pop_back();
}; };
// This defines the top level scope when the parser is told to parse a single
// option data. It's almost exactly the same as option_data_entry, except
// that it does leave its value on stack.
sub_option_data: LCURLY_BRACKET { sub_option_data: LCURLY_BRACKET {
// Parse the option-data list entry map // Parse the option-data list entry map
ElementPtr m(new MapElement(ctx.loc2pos(@1))); ElementPtr m(new MapElement(ctx.loc2pos(@1)));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment