![]() |
Kea 3.3.1
|
Token that represents a value of an option. More...
#include <token.h>
Public Types | |
| enum | RepresentationType { TEXTUAL , HEXADECIMAL , EXISTS } |
| Token representation type. More... | |
Public Member Functions | |
| TokenOption (const std::vector< uint16_t > &option_codes, const RepresentationType &rep_type) | |
| Constructor that takes an option code as a parameter. | |
| virtual unsigned | evaluate (Pkt &pkt, ValueStack &values) |
| Evaluates the values of the option. | |
| std::vector< uint16_t > | getOptions () const |
| Returns option-code. | |
| RepresentationType | getRepresentation () const |
| Returns representation-type. | |
| Public Member Functions inherited from isc::dhcp::Token | |
| virtual | ~Token () |
| Virtual destructor. | |
| virtual unsigned | getLabel () const |
| Return the label of this token. | |
Protected Member Functions | |
| virtual OptionPtr | getOption (Pkt &pkt) |
| Attempts to retrieve an option. | |
| virtual std::string | pushFailure (ValueStack &values) |
| Auxiliary method that puts string representing a failure. | |
Protected Attributes | |
| std::vector< uint16_t > | option_path_ |
| The options hierarchy. | |
| RepresentationType | representation_type_ |
| The representation type. | |
Additional Inherited Members | |
| Static Public Member Functions inherited from isc::dhcp::Token | |
| static bool | toBool (std::string value) |
| Coverts a (string) value to a boolean. | |
Token that represents a value of an option.
This represents a reference to a given option, e.g. in the expression option[vendor-class].text == "MSFT", it represents option[vendor-class].text
During the evaluation it tries to extract the value of the specified option. If the option is not found, an empty string ("") is returned (or "false" when the representation is EXISTS).
It can represent the following expressions: option[149].exists - check if option 149 exists option[149].hex - return content of option 149
Token representation type.
There are many possible ways in which option can be presented. Currently the textual, hexadecimal and exists representations are supported. The type of representation is specified in the constructor and it affects the value generated by the TokenOption::evaluate function.
| Enumerator | |
|---|---|
| TEXTUAL | |
| HEXADECIMAL | |
| EXISTS | |
|
inline |
Constructor that takes an option code as a parameter.
Note: There is no constructor that takes option_name, as it would introduce complex dependency of the libkea-eval on libdhcpsrv.
| option_codes | option hierarchy of the option to be represented. |
| rep_type | Token representation type. |
Definition at line 430 of file token.h.
References option_path_, and representation_type_.
Referenced by isc::dhcp::TokenFilterIA_NA::TokenFilterIA_NA(), isc::dhcp::TokenFilterIA_PD::TokenFilterIA_PD(), isc::dhcp::TokenLeaseIA_NA::TokenLeaseIA_NA(), isc::dhcp::TokenLeaseIA_PD::TokenLeaseIA_PD(), isc::dhcp::TokenRelay4Option::TokenRelay4Option(), isc::dhcp::TokenRelay6Option::TokenRelay6Option(), isc::dhcp::TokenVendor::TokenVendor(), and isc::dhcp::TokenVendor::TokenVendor().
|
virtual |
Evaluates the values of the option.
This token represents a value of the option, so this method attempts to extract the option from the packet and put its value on the stack. If the option is not there, an empty string ("") is put on the stack.
| pkt | specified option will be extracted from this packet (if present) |
| values | value of the option will be pushed here (or "") |
Implements isc::dhcp::Token.
Reimplemented in isc::dhcp::TokenFilterIA_NASuboption, isc::dhcp::TokenFilterIA_PDSuboption, isc::dhcp::TokenLeaseIA_NASuboption, isc::dhcp::TokenLeaseIA_PDSuboption, isc::dhcp::TokenVendor, and isc::dhcp::TokenVendorClass.
Definition at line 418 of file token.cc.
References isc::dhcp::EVAL_DBG_STACK, isc::dhcp::EVAL_DEBUG_OPTION, isc::dhcp::eval_logger, EXISTS, isc::dhcp::Pkt::getLabel(), getOption(), HEXADECIMAL, LOG_DEBUG, option_path_, representation_type_, TEXTUAL, and toHex().
Referenced by isc::dhcp::TokenFilterIA_NASuboption::evaluate(), isc::dhcp::TokenFilterIA_PDSuboption::evaluate(), isc::dhcp::TokenLeaseIA_NASuboption::evaluate(), isc::dhcp::TokenLeaseIA_PDSuboption::evaluate(), and isc::dhcp::TokenVendor::evaluate().
Attempts to retrieve an option.
For this class it simply attempts to retrieve the option from the packet, but there may be derived classes that would attempt to extract it from other places (e.g. relay option, or as a suboption of other specific option).
| pkt | the option will be retrieved from here |
Reimplemented in isc::dhcp::TokenFilterIA_NA, isc::dhcp::TokenFilterIA_NASuboption, isc::dhcp::TokenFilterIA_PD, isc::dhcp::TokenFilterIA_PDSuboption, isc::dhcp::TokenLeaseIA_NA, isc::dhcp::TokenLeaseIA_NASuboption, isc::dhcp::TokenLeaseIA_PD, isc::dhcp::TokenLeaseIA_PDSuboption, isc::dhcp::TokenRelay4Option, isc::dhcp::TokenRelay6Option, and isc::dhcp::TokenVendor.
Definition at line 399 of file token.cc.
References isc::dhcp::Pkt::getOption(), and option_path_.
Referenced by evaluate().
|
inline |
Returns option-code.
This method is used in testing to determine if the parser had instantiated TokenOption with correct parameters.
Definition at line 450 of file token.h.
References option_path_.
|
inline |
Returns representation-type.
This method is used in testing to determine if the parser had instantiated TokenOption with correct parameters.
Definition at line 460 of file token.h.
References representation_type_.
|
protectedvirtual |
Auxiliary method that puts string representing a failure.
Depending on the representation type, this is either "" or "false".
| values | a string representing failure will be pushed here. |
Definition at line 472 of file token.cc.
References EXISTS, and representation_type_.
Referenced by isc::dhcp::TokenVendor::evaluate(), and isc::dhcp::TokenVendorClass::evaluate().
|
protected |
The options hierarchy.
Definition at line 484 of file token.h.
Referenced by TokenOption(), evaluate(), getOption(), isc::dhcp::TokenRelay4Option::getOption(), isc::dhcp::TokenRelay6Option::getOption(), isc::dhcp::TokenVendor::getOption(), and getOptions().
|
protected |
The representation type.
Definition at line 487 of file token.h.
Referenced by TokenOption(), evaluate(), getRepresentation(), and pushFailure().