Kea  2.1.7-git
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. More...
 
virtual void evaluate (Pkt &pkt, ValueStack &values)
 This is a method for evaluating a packet. More...
 
uint16_t getSubCode () const
 Returns sub-option-code. More...
 
- 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. More...
 
uint16_t getCode () const
 Returns option-code. More...
 
RepresentationType getRepresentation () const
 Returns representation-type. More...
 
- Public Member Functions inherited from isc::dhcp::Token
virtual ~Token ()
 Virtual destructor. More...
 

Protected Member Functions

virtual OptionPtr getSubOption (const OptionPtr &parent)
 Attempts to retrieve a sub-option. More...
 
- Protected Member Functions inherited from isc::dhcp::TokenOption
virtual OptionPtr getOption (Pkt &pkt)
 Attempts to retrieve an option. More...
 
virtual std::string pushFailure (ValueStack &values)
 Auxiliary method that puts string representing a failure. More...
 

Protected Attributes

uint16_t sub_option_code_
 Code of the sub-option to be extracted. More...
 
- Protected Attributes inherited from isc::dhcp::TokenOption
uint16_t option_code_
 Code of the option to be extracted. More...
 
RepresentationType representation_type_
 Representation type. More...
 

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. More...
 

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 1246 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 
)
inline

Constructor that takes an option and sub-option codes as parameter.

Note
Does not define its own representation type: simply use the TokenOption::RepresentationTypeNote: There is no constructor that takes names.
Parameters
option_codecode of the parent option.
sub_option_codecode of the sub-option to be represented.
rep_typeToken representation type.

Definition at line 1259 of file token.h.

Member Function Documentation

◆ evaluate()

void TokenSubOption::evaluate ( Pkt pkt,
ValueStack values 
)
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.

Parameters
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 1276 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, LOG_DEBUG, and isc::util::encode::toHex().

+ Here is the call graph for this function:

◆ getSubCode()

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

Returns sub-option-code.

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

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

Definition at line 1283 of file token.h.

◆ getSubOption()

OptionPtr TokenSubOption::getSubOption ( const OptionPtr parent)
protectedvirtual

Attempts to retrieve a sub-option.

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

Definition at line 1268 of file token.cc.

Member Data Documentation

◆ sub_option_code_

uint16_t isc::dhcp::TokenSubOption::sub_option_code_
protected

Code of the sub-option to be extracted.

Definition at line 1294 of file token.h.


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