Kea 2.7.5
|
Token that represents sub-options in DHCPv4 and DHCPv6. More...
#include <token.h>
Public Member Functions | |
TokenSubOption (const uint16_t option_code, const uint16_t sub_option_code, const RepresentationType &rep_type) | |
Constructor that takes an option and sub-option codes as parameter. | |
virtual unsigned | evaluate (Pkt &pkt, ValueStack &values) |
This is a method for evaluating a packet. | |
uint16_t | getSubCode () const |
Returns sub-option-code. | |
Public Member Functions inherited from isc::dhcp::TokenOption | |
TokenOption (const uint16_t option_code, const RepresentationType &rep_type) | |
Constructor that takes an option code as a parameter. | |
uint16_t | getCode () 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 | getSubOption (const OptionPtr &parent) |
Attempts to retrieve a sub-option. | |
Protected Member Functions inherited from isc::dhcp::TokenOption | |
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 | |
uint16_t | sub_option_code_ |
Code of the sub-option to be extracted. | |
Protected Attributes inherited from isc::dhcp::TokenOption | |
uint16_t | option_code_ |
Code of the option to be extracted. | |
RepresentationType | representation_type_ |
Representation type. | |
Additional Inherited Members | |
Public Types inherited from isc::dhcp::TokenOption | |
enum | RepresentationType { TEXTUAL , HEXADECIMAL , EXISTS } |
Token representation type. More... | |
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 sub-options in DHCPv4 and DHCPv6.
It covers any options which encapsulate sub-options, for instance dhcp-agent-options (82, DHCPv4) or rsoo (66, DHCPv6). This class is derived from TokenOption and leverages its ability to operate on sub-options. It also adds additional capabilities.
Note: TokenSubOption
virtually derives TokenOption
because both classes are inherited together in more complex classes in other parts of the code. This makes the base class TokenOption
to exist only once in such complex classes.
It can represent the following expressions: option[149].exists - check if option 149 exists option[149].option[1].exists - check if suboption 1 exists in the option 149 option[149].option[1].hex - return content of suboption 1 for option 149
|
inline |
Constructor that takes an option and sub-option codes as parameter.
TokenOption::RepresentationType\iline
1330Note: There is no constructor that takes names.
option_code | code of the parent option. |
sub_option_code | code of the sub-option to be represented. |
rep_type | Token representation type. |
|
virtual |
This is a method for evaluating a packet.
This token represents a value of the sub-option, so this method attempts to extract the parent option from the packet and when it succeeds to extract the sub-option from the option and its value on the stack. If the parent option or the sub-option is not there, an empty string ("") is put on the stack.
pkt | specified parent option will be extracted from this packet |
values | value of the sub-option will be pushed here (or "") |
Reimplemented from isc::dhcp::TokenOption.
Definition at line 1416 of file token.cc.
References isc::dhcp::EVAL_DBG_STACK, isc::dhcp::EVAL_DEBUG_SUB_OPTION, isc::dhcp::EVAL_DEBUG_SUB_OPTION_NO_OPTION, isc::dhcp::eval_logger, isc::dhcp::TokenOption::EXISTS, isc::dhcp::TokenOption::getOption(), getSubOption(), isc::dhcp::TokenOption::HEXADECIMAL, LOG_DEBUG, isc::dhcp::TokenOption::option_code_, isc::dhcp::TokenOption::representation_type_, sub_option_code_, and isc::dhcp::TokenOption::TEXTUAL.
|
inline |
Returns sub-option-code.
This method is used in testing to determine if the parser had instantiated TokenSubOption with correct parameters.
Definition at line 1362 of file token.h.
References sub_option_code_.
Attempts to retrieve a sub-option.
parent | the sub-option will be retrieved from here |
Definition at line 1408 of file token.cc.
References sub_option_code_.
Referenced by evaluate().
|
protected |
Code of the sub-option to be extracted.
Definition at line 1373 of file token.h.
Referenced by evaluate(), getSubCode(), and getSubOption().