Kea 2.7.5
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 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.
 

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 1324 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::RepresentationType\iline 1330

Note: 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 1337 of file token.h.

Member Function Documentation

◆ evaluate()

unsigned 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 "")
Returns
0 which means evaluate next token if any.

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.

+ 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 1362 of file token.h.

References sub_option_code_.

◆ 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 1408 of file token.cc.

References sub_option_code_.

Referenced by evaluate().

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 1373 of file token.h.

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


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