Embodies a named expression, whose output when evaluated can be stored in a lease's user-context. More...
#include <binding_variables.h>
Public Types | |
enum | Source { QUERY , RESPONSE } |
Specifies the packet that the expression should be evaluated against. More... | |
Public Member Functions | |
BindingVariable (const std::string &name, const std::string &expression_str, const Source &source, uint32_t family) | |
Constructor. | |
virtual | ~BindingVariable ()=default |
Destructor. | |
std::string | evaluate (dhcp::PktPtr packet) const |
Evaluate the variable against the given packet. | |
dhcp::ExpressionPtr | getExpression () const |
Fetches the variable's parsed expression. | |
std::string | getExpressionStr () const |
Fetches the variable's pre-parsed expression string. | |
uint32_t | getFamily () const |
Fetches the variable's protocol family. | |
std::string | getName () const |
Fetches the variable's name. | |
Source | getSource () const |
Fetches the variable's packet source. | |
virtual data::ElementPtr | toElement () const |
Creates an Element tree for the variable's configurable members. | |
![]() | |
virtual | ~CfgToElement () |
Destructor. | |
Static Public Member Functions | |
static BindingVariablePtr | parse (data::ConstElementPtr config, uint16_t family) |
Parses configuration elements into a BindingVarable instance. | |
Static Public Attributes | |
static const data::SimpleKeywords | CONFIG_KEYWORDS |
List of valid configurable parameters for a BindingVariable. | |
Embodies a named expression, whose output when evaluated can be stored in a lease's user-context.
Definition at line 37 of file binding_variables.h.
Specifies the packet that the expression should be evaluated against.
Enumerator | |
---|---|
QUERY | |
RESPONSE |
Definition at line 41 of file binding_variables.h.
isc::lease_cmds::BindingVariable::BindingVariable | ( | const std::string & | name, |
const std::string & | expression_str, | ||
const Source & | source, | ||
uint32_t | family ) |
Constructor.
name | name of the variable, must be unique. Used both as the key and as the label for the value in the output. |
expression_str | Evaluation expression text. |
source | Source packet the expression should be evaluated against, either QUERY or RESPONSE. |
family | Protocol family of the expression, either AF_INET or AF_INET6. |
During construction the expression string is parsed for the protocol family.
BadValue | if name if empty, or expression string fails to parse. |
Definition at line 23 of file binding_variables.cc.
References isc::eval::EvalContext::expression_, if(), isc_throw, isc::eval::EvalContext::PARSER_STRING, isc::eval::EvalContext::parseString(), isc::dhcp::Option::V4, and isc::dhcp::Option::V6.
Referenced by parse().
|
virtualdefault |
Destructor.
std::string isc::lease_cmds::BindingVariable::evaluate | ( | dhcp::PktPtr | packet | ) | const |
Evaluate the variable against the given packet.
packet | Pointer to the target packet. |
BadValue | if an evaluation error occurs. |
Definition at line 92 of file binding_variables.cc.
References isc::dhcp::evaluateString(), and isc_throw.
|
inline |
Fetches the variable's parsed expression.
Definition at line 103 of file binding_variables.h.
|
inline |
Fetches the variable's pre-parsed expression string.
Definition at line 96 of file binding_variables.h.
|
inline |
Fetches the variable's protocol family.
Definition at line 117 of file binding_variables.h.
|
inline |
Fetches the variable's name.
Definition at line 89 of file binding_variables.h.
|
inline |
Fetches the variable's packet source.
Definition at line 110 of file binding_variables.h.
|
static |
Parses configuration elements into a BindingVarable instance.
config | Map Element containing parameters for a single binding variable. |
family | Protocol family of the variable, either AF_INET or AF_INET6. |
DhcpConfigError | if configuration parameters are invalid. |
Definition at line 64 of file binding_variables.cc.
References BindingVariable(), isc::data::SimpleParser::checkKeywords(), CONFIG_KEYWORDS, isc::data::SimpleParser::getString(), isc_throw, QUERY, and RESPONSE.
Referenced by isc::lease_cmds::BindingVariableMgr::configure().
|
virtual |
Creates an Element tree for the variable's configurable members.
Implements isc::data::CfgToElement.
Definition at line 102 of file binding_variables.cc.
References isc::data::Element::create(), isc::data::Element::createMap(), and QUERY.
|
static |
List of valid configurable parameters for a BindingVariable.
Definition at line 47 of file binding_variables.h.
Referenced by parse().