![]() |
Kea 3.3.4
|
This parser class contains the common logic for various callouts to parse and validate the contents of the received command. More...
#include <cb_cmds_impl.h>
Public Types | |
| enum | ServerTagsParse : uint16_t { TAGS_OPTIONAL , TAGS_REQUIRED , TAGS_FORBIDDEN } |
| Server selector parsing. More... | |
| enum | SubnetsAction : uint16_t { ACTION_KEEP , ACTION_DELETE } |
| Subnets actions for shared network delete. More... | |
| enum | SubnetsInclude : uint16_t { INCLUDE_NO , INCLUDE_FULL } |
| Subnets actions for shared network get command. More... | |
Public Member Functions | |
| db::BackendSelector | getBackendSelector (const data::ConstElementPtr &args) const |
| Creates backend selector from the command's arguments. | |
| db::ServerSelector | getServerSelector (const data::ConstElementPtr &args, ServerTagsParse tags_parse) const |
| Creates server selector from the command's arguments. | |
| template<typename SubnetPtrType, typename KeyType> | |
| void | getSubnetCommon (hooks::CalloutHandle &callout_handle, const SubnetPtrType &subnet, const uint16_t address_family, const KeyType &key) |
| Common routine invoked when getting a subnet. | |
| SubnetsAction | getSubnetsAction (const data::ConstElementPtr &args) const |
| Creates subnets action from the command's arguments. | |
| SubnetsInclude | getSubnetsInclude (const data::ConstElementPtr &args) const |
Creates SubnetsInclude from the command's arguments. | |
| template<typename ParserType, typename... ParserArgs, typename ElementType> | |
| data::ConstElementPtr | parseInputListElement (hooks::CalloutHandle &callout_handle, const std::string &list_name, ParserArgs... parser_args, ElementType &parsed_element, data::Element::types sub_type=data::Element::map) const |
| Parses a command containing a list of elements (second call). | |
| template<typename ParserType, typename... ParserArgs, typename ElementType> | |
| data::ConstElementPtr | parseInputListElement (hooks::CalloutHandle &callout_handle, const std::string &list_name, ParserArgs... parser_args, ElementType &parsed_element, db::BackendSelector &backend_selector, db::ServerSelector &server_selector, ServerTagsParse tags_parse, data::Element::types sub_type=data::Element::map) const |
| Parses a command containing a list of elements. | |
| template<typename ParserType, typename... ParserArgs, typename ElementType> | |
| void | parseInputMapElement (hooks::CalloutHandle &callout_handle, const std::string &map_name, ParserArgs... parser_args, ElementType &parsed_element, db::BackendSelector &backend_selector, db::ServerSelector &server_selector, ServerTagsParse tags_parse) const |
| Parses a command containing a map of elements. | |
This parser class contains the common logic for various callouts to parse and validate the contents of the received command.
Definition at line 39 of file cb_cmds_impl.h.
| enum isc::cb::ConfigCmdsParser::ServerTagsParse : uint16_t |
Server selector parsing.
It determines the expected server tags specified for the command parsed by the parseInputListElement and parseInputMapElement.
| Enumerator | |
|---|---|
| TAGS_OPTIONAL | server-tags entry is optional |
| TAGS_REQUIRED | server-tags is required |
| TAGS_FORBIDDEN | server-tags is not allowed |
Definition at line 50 of file cb_cmds_impl.h.
| enum isc::cb::ConfigCmdsParser::SubnetsAction : uint16_t |
Subnets actions for shared network delete.
| Enumerator | |
|---|---|
| ACTION_KEEP | keep subnets (default) |
| ACTION_DELETE | delete subnets |
Definition at line 57 of file cb_cmds_impl.h.
| enum isc::cb::ConfigCmdsParser::SubnetsInclude : uint16_t |
Subnets actions for shared network get command.
| Enumerator | |
|---|---|
| INCLUDE_NO | |
| INCLUDE_FULL | |
Definition at line 63 of file cb_cmds_impl.h.
| BackendSelector isc::cb::ConfigCmdsParser::getBackendSelector | ( | const data::ConstElementPtr & | args | ) | const |
Creates backend selector from the command's arguments.
If the command arguments include "remote" parameter we will use the contents of this parameter to create backend selector. Otherwise, we will return the default selector (unspecified).
| args | Pointer to the command arguments. |
Definition at line 34 of file cb_cmds_impl.cc.
Referenced by parseInputListElement(), and parseInputMapElement().
| ServerSelector isc::cb::ConfigCmdsParser::getServerSelector | ( | const data::ConstElementPtr & | args, |
| ServerTagsParse | tags_parse ) const |
Creates server selector from the command's arguments.
If the parsing choice is TAGS_REQUIRED:
If the parsing choice is TAGS_FORBIDDEN:
If the parsing choice is TAGS_OPTIONAL:
| args | Pointer to the command arguments. |
| tags_parse | Parsing choice for server-tags entry. |
| BadValue | if server selector cannot be parsed following tags_parse. |
Definition at line 44 of file cb_cmds_impl.cc.
References isc::db::ServerSelector::ANY(), isc::data::ServerTag::get(), isc_throw, Element::list, isc::db::ServerSelector::MULTIPLE(), Element::null, isc::db::ServerSelector::ONE(), Element::string, TAGS_FORBIDDEN, TAGS_REQUIRED, and isc::db::ServerSelector::UNASSIGNED().
Referenced by parseInputListElement(), and parseInputMapElement().
|
inline |
Common routine invoked when getting a subnet.
Creates a response to the caller which includes the fetched subnet and appropriate control result.
| SubnetPtrType | Type of the pointer to the retrieved subnet. |
| KeyType | Type of the key used to fetch the subnet. |
| callout_handle | Callout handle where response will be stored. |
| subnet | Instance of the fetched subnet or null if no subnet was found. |
| address_family | Address family. |
| key | Subnet property used for locating the subnet, e.g. subnet identifier or prefix. |
Definition at line 426 of file cb_cmds_impl.h.
References isc::config::CONTROL_RESULT_EMPTY, isc::config::CONTROL_RESULT_SUCCESS, isc::data::Element::create(), isc::config::createAnswer(), isc::data::Element::createList(), isc::data::Element::createMap(), isc::db::info, and isc::hooks::CalloutHandle::setArgument().
| ConfigCmdsParser::SubnetsAction isc::cb::ConfigCmdsParser::getSubnetsAction | ( | const data::ConstElementPtr & | args | ) | const |
Creates subnets action from the command's arguments.
If the command arguments include "subnets-action" parameter we will use the contents of this parameter to create subnets action. Otherwise, we will return the default action (keep).
| args | Pointer to the command arguments. |
Definition at line 93 of file cb_cmds_impl.cc.
References ACTION_DELETE, ACTION_KEEP, isc_throw, and Element::string.
| ConfigCmdsParser::SubnetsInclude isc::cb::ConfigCmdsParser::getSubnetsInclude | ( | const data::ConstElementPtr & | args | ) | const |
Creates SubnetsInclude from the command's arguments.
If teh command arguments include "subnets-include" parameter we will use the contents of this parameter we will use it to determine whether the subnets should be included in the response to the remote-network[46]-get command.
| args | Pointer to the command arguments. |
Definition at line 114 of file cb_cmds_impl.cc.
References INCLUDE_FULL, INCLUDE_NO, isc_throw, and Element::string.
|
inline |
Parses a command containing a list of elements (second call).
This method is used for processing control commands which contain a list of maps. The map contains a configuration data structure such as subnet, shared network, global parameter, option etc. The parser to be used to parse the command arguments into the respective C++ objects is provided via the template parameters.
This is a stripped down version which is intended to be called a second time after "full" parseInputListElement.
| ParserType | Type of the parser to be used for parsing the data. |
| ParserArgs | Arguments to be passed to the parser specified via ParserType. |
| ElementType | Type of the object which holds parsed data. |
| callout_handle | Reference to the callout handle holding the command to be parsed. | |
| list_name | Name of the list within command's arguments that holds the data, e.g. "subnets", "shared-networks" etc. | |
| parser_args | Arguments to be passed to the parser. | |
| [out] | parsed_element | Reference to the object where the parsed data should be stored. |
| sub_type | type of the element of the list. |
| BadValue | if the command is malformed. |
Definition at line 233 of file cb_cmds_impl.h.
References isc::hooks::CalloutHandle::getArgument(), isc_throw, isc::data::Element::list, isc::data::Element::map, isc::config::parseCommandWithArgs(), and isc::data::Element::typeToName().
|
inline |
Parses a command containing a list of elements.
This method is used for processing control commands which contain a list of maps. The map contains a configuration data structure such as subnet, shared network, global parameter, option etc. The parser to be used to parse the command arguments into the respective C++ objects is provided via the template parameters.
The second template argument, i.e. ParserArgs, is a variadic template parameter pack which can contain no parameters, one parameter or multiple parameters. This parameter pack is passed to the configuration parser's (ParserType) constructor. For example:
The first template argument specifies that OptionDataParser must be used to parse the data. Its constructor takes two parameters:
The second and third template parameter belong to the aforementioned parameter pack and they indicate that the uint16_t and the CfgOptionDefPtr parameters must be passed to the parser's constructor. These parameters are provided as the second and third parameter in the invocation. The last template parameter ElementType is not specified in the example above, because it is inferred by the compiler from the function arguments.
Another example demonstrates how to call this method when the parser's constructor takes no arguments:
In this case, the sole template parameter is the one that specifies the parser type. Neither the parameter pack is provided nor parser specific arguments.
Currently, the number of maps allowed in the list is restricted to 1. That means that only one subnet, shared network, global parameter etc. can be sent in a single command.
| ParserType | Type of the parser to be used for parsing the data. |
| ParserArgs | Arguments to be passed to the parser specified via ParserType. |
| ElementType | Type of the object which holds parsed data. |
| callout_handle | Reference to the callout handle holding the command to be parsed. | |
| list_name | Name of the list within command's arguments that holds the data, e.g. "subnets", "shared-networks" etc. | |
| parser_args | Arguments to be passed to the parser. | |
| [out] | parsed_element | Reference to the object where the parsed data should be stored. |
| [out] | backend_selector | Reference to the backend selector retrieved from the command. |
| [out] | server_selector | Reference to the server selector retrieved from the command. |
| tags_parse | Parsing choice for server-tags entry. | |
| sub_type | type of the element of the list. |
| BadValue | if the command is malformed. |
Definition at line 151 of file cb_cmds_impl.h.
References isc::hooks::CalloutHandle::getArgument(), getBackendSelector(), getServerSelector(), isc_throw, isc::data::Element::list, isc::data::Element::map, isc::config::parseCommandWithArgs(), and isc::data::Element::typeToName().
|
inline |
Parses a command containing a map of elements.
This method is used for processing control commands which contain a non-empty map. For example, it is used to parse a map of global configuration parameters for the DHCP servers. The parser to be used to parse the command arguments into the respective C++ objects is provided via the template parameters.
The second template argument, i.e. ParserArgs, is a variadic template parameter pack which can contain no parameters, one parameter or multiple parameters. This parameter pack is passed to the configuration parser's (ParserType) constructor. For example:
The first template argument specifies that GlobalParameterParser must be used to parse the map. Its constructor takes one argument, i.e. const SimpleKeywords&.
The second template parameter belongs to the aforementioned parameter pack and it indicates that const SimpleKeywords& parameters must be passed to the parser's constructor.
The last template parameter ElementType is not specified in the example above, because it is inferred by the compiler from the function arguments.
| ParserType | Type of the parser to be used for parsing the data. |
| ParserArgs | Arguments to be passed to the parser specified via ParserType. |
| ElementType | Type of the object which holds parsed data. |
| callout_handle | Reference to the callout handle holding the command to be parsed. | |
| map_name | Name of the map within command's arguments that holds the data. | |
| parser_args | Arguments to be passed to the parser. | |
| [out] | parsed_element | Reference to the object where the parsed data should be stored. |
| [out] | backend_selector | Reference to the backend selector retrieved from the command. |
| [out] | server_selector | Reference to the server selector retrieved from the command. |
| tags_parse | Parsing choice for server-tags entry. |
Definition at line 330 of file cb_cmds_impl.h.
References isc::hooks::CalloutHandle::getArgument(), getBackendSelector(), getServerSelector(), isc_throw, isc::data::Element::map, and isc::config::parseCommandWithArgs().