Kea 2.5.9
isc::dhcp::TokenSubOption Class Reference

Token that represents sub-options in DHCPv4 and DHCPv6. More...

#include <token.h>

+ Inheritance diagram for isc::dhcp::TokenSubOption:

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 void 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.
void evaluate (Pkt &pkt, ValueStack &values)
 Evaluates the values of the option.
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 void evaluate (Pkt &pkt, ValueStack &values)=0
 This is a generic method for evaluating a packet.

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.

Detailed Description

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

Definition at line 1275 of file token.h.

Constructor & Destructor Documentation

◆ TokenSubOption()

isc::dhcp::TokenSubOption::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.

Does not define its own representation type: simply use the TokenOption::RepresentationType\iline 1281

Note: There is no constructor that takes names.

option_codecode of the parent option.
sub_option_codecode of the sub-option to be represented.
rep_typeToken representation type.

Definition at line 1288 of file token.h.

Member Function Documentation

◆ evaluate()

void TokenSubOption::evaluate ( Pkt pkt,
ValueStack values 

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.

pktspecified parent option will be extracted from this packet
valuesvalue of the sub-option will be pushed here (or "")

Reimplemented from isc::dhcp::TokenOption.

Definition at line 1351 of file

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::Pkt::getLabel(), 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.

+ Here is the call graph for this function:

◆ getSubCode()

uint16_t isc::dhcp::TokenSubOption::getSubCode ( ) const

Returns sub-option-code.

This method is used in testing to determine if the parser had instantiated TokenSubOption with correct parameters.

option-code of the sub-option this token expects to extract.

Definition at line 1312 of file token.h.

References sub_option_code_.

◆ getSubOption()

OptionPtr TokenSubOption::getSubOption ( const OptionPtr parent)

Attempts to retrieve a sub-option.

parentthe sub-option will be retrieved from here
sub-option instance (or NULL if not found)

Definition at line 1343 of file

References sub_option_code_.

Referenced by evaluate().

Member Data Documentation

◆ sub_option_code_

uint16_t isc::dhcp::TokenSubOption::sub_option_code_

Code of the sub-option to be extracted.

Definition at line 1323 of file token.h.

Referenced by evaluate(), getSubCode(), and getSubOption().

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