2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-31 05:55:28 +00:00

[5425] Extended syntax

This commit is contained in:
Francis Dupont
2017-11-19 11:25:09 +01:00
parent 29c00734a0
commit 9be04ee397
8 changed files with 93 additions and 2 deletions

View File

@@ -586,6 +586,31 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
}
}
\"known-clients\" {
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::POOLS:
return isc::dhcp::Dhcp4Parser::make_KNOWN_CLIENTS(driver.loc_);
default:
return isc::dhcp::Dhcp4Parser::make_STRING("known-clients", driver.loc_);
}
\"only\" {
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::KNOWN_CLIENTS:
return isc::dhcp::Dhcp4Parser::make_ONLY(driver.loc_);
default:
return isc::dhcp::Dhcp4Parser::make_STRING("only", driver.loc_);
}
\"never\" {
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::KNOWN_CLIENTS:
case isc::dhcp::Parser4Context::REPLACE_CLIENT_NAME:
return isc::dhcp::Dhcp4Parser::make_NEVER(driver.loc_);
default:
return isc::dhcp::Dhcp4Parser::make_STRING("never", driver.loc_);
}
\"subnet\" {
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::SUBNET4:

View File

@@ -109,6 +109,9 @@ using namespace std;
POOLS "pools"
POOL "pool"
USER_CONTEXT "user-context"
KNOWN_CLIENTS "known-clients"
ONLY "only"
NEVER "never"
SUBNET "subnet"
INTERFACE "interface"
@@ -173,7 +176,6 @@ using namespace std;
TCP "tcp"
JSON "JSON"
WHEN_PRESENT "when-present"
NEVER "never"
ALWAYS "always"
WHEN_NOT_PRESENT "when-not-present"
@@ -1331,6 +1333,7 @@ pool_param: pool_entry
| option_data_list
| client_class
| user_context
| known_clients
| unknown_map_entry
;
@@ -1349,6 +1352,18 @@ user_context: USER_CONTEXT {
ctx.leave();
};
known_clients: KNOWN_CLIENTS {
ctx.enter(ctx.KNOWN_CLIENTS);
} COLON known_clients_value {
ctx.stack_.back()->set("known-clients", $4);
ctx.leave();
}
known_clients_value:
ONLY { $$ = ElementPtr(new StringElement("only", ctx.loc2pos(@1))); }
| NEVER { $$ = ElementPtr(new StringElement("never", ctx.loc2pos(@1))); }
;
// --- end of pools definition -------------------------------
// --- reservations ------------------------------------------

View File

@@ -174,6 +174,8 @@ Parser4Context::contextName()
return ("control-socket");
case POOLS:
return ("pools");
case KNOWN_CLIENTS:
return ("known-clients");
case RESERVATIONS:
return ("reservations");
case RELAY:

View File

@@ -264,6 +264,9 @@ public:
/// Used while parsing Dhcp4/subnet4/pools structures.
POOLS,
/// Used while parsing Dhcp4/subnet4/pools/known_client structures.
KNOWN_CLIENTS,
/// Used while parsing Dhcp4/reservations structures.
RESERVATIONS,

View File

@@ -361,6 +361,15 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
return isc::dhcp::Dhcp6Parser::make_STRING(tmp, driver.loc_);
}
\"never\" {
switch(driver.ctx_) {
case isc::dhcp::Parser6Context::KNOWN_CLIENTS:
case isc::dhcp::Parser6Context::REPLACE_CLIENT_NAME:
return isc::dhcp::Dhcp6Parser::make_NEVER(driver.loc_);
default:
return isc::dhcp::Dhcp6Parser::make_STRING("never", driver.loc_);
}
(?i:\"never\") {
/* dhcp-ddns value keywords are case insensitive */
if (driver.ctx_ == isc::dhcp::Parser6Context::REPLACE_CLIENT_NAME) {
@@ -817,6 +826,22 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
}
}
\"known-clients\" {
switch(driver.ctx_) {
case isc::dhcp::Parser6Context::POOLS:
return isc::dhcp::Dhcp6Parser::make_KNOWN_CLIENTS(driver.loc_);
default:
return isc::dhcp::Dhcp6Parser::make_STRING("known-clients", driver.loc_);
}
\"only\" {
switch(driver.ctx_) {
case isc::dhcp::Parser6Context::KNOWN_CLIENTS:
return isc::dhcp::Dhcp6Parser::make_ONLY(driver.loc_);
default:
return isc::dhcp::Dhcp6Parser::make_STRING("only", driver.loc_);
}
\"subnet\" {
switch(driver.ctx_) {
case isc::dhcp::Parser6Context::SUBNET6:

View File

@@ -99,6 +99,9 @@ using namespace std;
EXCLUDED_PREFIX_LEN "excluded-prefix-len"
DELEGATED_LEN "delegated-len"
USER_CONTEXT "user-context"
KNOWN_CLIENTS "known-clients"
ONLY "only"
NEVER "never"
SUBNET "subnet"
INTERFACE "interface"
@@ -176,7 +179,6 @@ using namespace std;
TCP "TCP"
JSON "JSON"
WHEN_PRESENT "when-present"
NEVER "never"
ALWAYS "always"
WHEN_NOT_PRESENT "when-not-present"
@@ -1294,6 +1296,7 @@ pool_param: pool_entry
| option_data_list
| client_class
| user_context
| known_clients
| unknown_map_entry
;
@@ -1312,6 +1315,18 @@ user_context: USER_CONTEXT {
ctx.leave();
};
known_clients: KNOWN_CLIENTS {
ctx.enter(ctx.KNOWN_CLIENTS);
} COLON known_clients_value {
ctx.stack_.back()->set("known-clients", $4);
ctx.leave();
}
known_clients_value:
ONLY { $$ = ElementPtr(new StringElement("only", ctx.loc2pos(@1))); }
| NEVER { $$ = ElementPtr(new StringElement("never", ctx.loc2pos(@1))); }
;
// --- end of pools definition -------------------------------
// --- pd-pools ----------------------------------------------
@@ -1371,6 +1386,7 @@ pd_pool_param: pd_prefix
| excluded_prefix
| excluded_prefix_len
| user_context
| known_clients
| unknown_map_entry
;

View File

@@ -176,6 +176,8 @@ Parser6Context::contextName()
return ("pools");
case PD_POOLS:
return ("pd-pools");
case KNOWN_CLIENTS:
return ("known-clients");
case RESERVATIONS:
return ("reservations");
case RELAY:

View File

@@ -270,6 +270,9 @@ public:
/// Used while parsing Dhcp6/subnet6/pd-pools structures.
PD_POOLS,
/// Used while parsing Dhcp4/subnet6/pools/known_client structures.
KNOWN_CLIENTS,
/// Used while parsing Dhcp6/reservations structures.
RESERVATIONS,