Kea 2.7.8
isc::lease_cmds::BindingVariableMgr Class Reference

Singleton which warehouses the configured binding variables, and evaluation of variables for a given lease and packet pair. More...

#include <binding_variables.h>

Public Member Functions

 BindingVariableMgr (uint32_t family)
 Constructor.
 
 ~BindingVariableMgr ()=default
 Destructor;.
 
void configure (data::ConstElementPtr config)
 Configures the manager based on the given configuration.
 
bool evaluateVariables (dhcp::PktPtr query, dhcp::PktPtr response, dhcp::LeasePtr lease)
 Evaluates the binding variables for a given lease and packet pair.
 
BindingVariableCachePtr getCache ()
 Fetches the current variables cache.
 

Detailed Description

Singleton which warehouses the configured binding variables, and evaluation of variables for a given lease and packet pair.

Definition at line 254 of file binding_variables.h.

Constructor & Destructor Documentation

◆ BindingVariableMgr()

isc::lease_cmds::BindingVariableMgr::BindingVariableMgr ( uint32_t family)
explicit

Constructor.

Parameters
familyProtocol family of the expression, either AF_INET or AF_INET6.

Definition at line 182 of file binding_variables.cc.

References isc_throw.

◆ ~BindingVariableMgr()

isc::lease_cmds::BindingVariableMgr::~BindingVariableMgr ( )
default

Destructor;.

Member Function Documentation

◆ configure()

void isc::lease_cmds::BindingVariableMgr::configure ( data::ConstElementPtr config)

Configures the manager based on the given configuration.

This will clear the binding variable cache and then repopulate it by parsing the configuration. It expects to see a list of one or more binding variable maps similar to the following:

"binding-variables": [{
"name": "domain-name",
"expression": "option[15].text",
"source": "response"
},{
"name": "opt-222",
"expression": "hexstring(option[222].hex, ':')"
"source": "query"
..
}]
Parameters
configJSON element tree containing the binding-variable list.
Exceptions
DhcpConfigErrorif the configuration is invalid.

Definition at line 192 of file binding_variables.cc.

References isc_throw, isc::data::Element::list, and isc::lease_cmds::BindingVariable::parse().

+ Here is the call graph for this function:

◆ evaluateVariables()

bool isc::lease_cmds::BindingVariableMgr::evaluateVariables ( dhcp::PktPtr query,
dhcp::PktPtr response,
dhcp::LeasePtr lease )

Evaluates the binding variables for a given lease and packet pair.

Iterates over the variables in the cache evaluating each on and added its name and value to the context.

Parameters
queryClient packet which produced the lease. Variables whose source is "query" will be evaluated against this packet.
responseServer response conveying the lease. Variables whose source is "response" will be evaluated against this packet.
leaseLease whose use-context will be updated with the evaluation results. If the results of the evaluation are identical the the lease's existing binding-variables value, the lease is not altered. This allows a subsequent lease store update to only occur when needed.
Returns
True if the lease's user-context was udpated, false otherwise.
Todo
If the lease has binding-variables in its context from a prior update, but config changed and now there are none defined, should we removed them from the lease? For now, we'll leave them.

Definition at line 219 of file binding_variables.cc.

References isc::data::Element::create(), isc::data::Element::createMap(), isc::dhcp::evaluateString(), isc_throw, and isc::lease_cmds::BindingVariable::QUERY.

+ Here is the call graph for this function:

◆ getCache()

BindingVariableCachePtr isc::lease_cmds::BindingVariableMgr::getCache ( )
inline

Fetches the current variables cache.

Returns
Pointer to BindingVariableCache.

Definition at line 308 of file binding_variables.h.


The documentation for this class was generated from the following files: