Kea 2.5.9
isc::dhcp::TokenVendorClass Class Reference

Token that represents vendor class options in DHCPv4 and DHCPv6. More...

#include <token.h>

+ Inheritance diagram for isc::dhcp::TokenVendorClass:

Public Member Functions

 TokenVendorClass (Option::Universe u, uint32_t vendor_id, FieldType field, uint16_t index=0)
 This constructor is used to access data chunks.
 
 TokenVendorClass (Option::Universe u, uint32_t vendor_id, RepresentationType repr)
 This constructor is used to access fields.
 
uint16_t getDataIndex () const
 Returns data index.
 
- Public Member Functions inherited from isc::dhcp::TokenVendor
 TokenVendor (Option::Universe u, uint32_t vendor_id, FieldType field)
 Constructor used for accessing a field.
 
 TokenVendor (Option::Universe u, uint32_t vendor_id, RepresentationType repr, uint16_t option_code=0)
 Constructor used for accessing an option.
 
virtual void evaluate (Pkt &pkt, ValueStack &values)
 This is a method for evaluating a packet.
 
FieldType getField () const
 Returns field.
 
uint32_t getVendorId () const
 Returns enterprise-id.
 
- 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

void evaluate (Pkt &pkt, ValueStack &values)
 This is a method for evaluating a packet.
 
- Protected Member Functions inherited from isc::dhcp::TokenVendor
virtual OptionPtr getOption (Pkt &pkt)
 Attempts to get a suboption.
 
- 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 index_
 Data chunk index.
 
- Protected Attributes inherited from isc::dhcp::TokenVendor
FieldType field_
 Specifies which field should be accessed.
 
Option::Universe universe_
 Universe (V4 or V6)
 
uint32_t vendor_id_
 Enterprise-id value.
 
- 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::TokenVendor
enum  FieldType { SUBOPTION , ENTERPRISE_ID , EXISTS , DATA }
 Specifies a field of the vendor option. More...
 
- 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 vendor class options in DHCPv4 and DHCPv6.

It covers vendor independent vendor information option (124, DHCPv4) and vendor option (16, DHCPv6). Contrary to vendor options, vendor class options don't have suboptions, but have data chunks (tuples) instead. Therefore they're not referenced by option codes, but by indexes. The first data chunk is data[0], the second is data[1] etc.

This class is derived from OptionVendor to take advantage of the enterprise handling field and field type.

It can represent the following expressions: vendor-class[4491].exists vendor-class[*].exists vendor-class[*].enterprise vendor-class[4491].data - content of the opaque-data of the first tuple vendor-class[4491].data[3] - content of the opaque-data of the 4th tuple

Definition at line 1203 of file token.h.

Constructor & Destructor Documentation

◆ TokenVendorClass() [1/2]

TokenVendorClass::TokenVendorClass ( Option::Universe  u,
uint32_t  vendor_id,
RepresentationType  repr 
)

This constructor is used to access fields.

Parameters
uuniverse (V4 or V6)
vendor_idvalue of enterprise-id field (0 means any)
reprrepresentation type (EXISTS or HEX)

Definition at line 1225 of file token.cc.

◆ TokenVendorClass() [2/2]

TokenVendorClass::TokenVendorClass ( Option::Universe  u,
uint32_t  vendor_id,
FieldType  field,
uint16_t  index = 0 
)

This constructor is used to access data chunks.

Parameters
uuniverse (V4 or V6)
vendor_idvalue of enterprise-id field (0 means any)
fieldtype of the field (usually DATA or ENTERPRISE)
indexspecifies which data chunk to retrieve

Definition at line 1230 of file token.cc.

References isc::dhcp::TokenVendor::field_.

Member Function Documentation

◆ evaluate()

void TokenVendorClass::evaluate ( Pkt pkt,
ValueStack values 
)
protectedvirtual

This is a method for evaluating a packet.

Depending on the value of vendor_id, field type, representation and option code, it will attempt to return specified characteristic of the vendor option

If vendor-id is specified, check only option with that particular enterprise-id. If vendor-id is 0, check any vendor option, regardless of its enterprise-id value.

If FieldType is ENTERPRISE_ID, return value of the enterprise-id field or "" if there's no vendor option.

If FieldType is DATA, get specified data chunk represented by index_.

If FieldType is EXISTS, return true if vendor-id matches.

Exceptions
EvalTypeErrorfor any other FieldType values.

The parameters passed are:

Parameters
pkt- vendor options will be searched for here.
values- the evaluated value will be pushed here.

Reimplemented from isc::dhcp::TokenVendor.

Definition at line 1240 of file token.cc.

References D6O_VENDOR_CLASS, isc::dhcp::TokenVendor::DATA, isc::dhcp::DHO_VIVCO_SUBOPTIONS, isc::util::encode::encodeHex(), isc::dhcp::TokenVendor::ENTERPRISE_ID, isc::dhcp::EVAL_DBG_STACK, isc::dhcp::EVAL_DEBUG_VENDOR_CLASS_DATA, isc::dhcp::EVAL_DEBUG_VENDOR_CLASS_DATA_NOT_FOUND, isc::dhcp::EVAL_DEBUG_VENDOR_CLASS_ENTERPRISE_ID, isc::dhcp::EVAL_DEBUG_VENDOR_CLASS_ENTERPRISE_ID_MISMATCH, isc::dhcp::EVAL_DEBUG_VENDOR_CLASS_EXISTS, isc::dhcp::EVAL_DEBUG_VENDOR_CLASS_NO_OPTION, isc::dhcp::eval_logger, isc::dhcp::TokenVendor::EXISTS, isc::dhcp::TokenVendor::field_, isc::dhcp::OpaqueDataTuple::getData(), isc::dhcp::Pkt::getLabel(), isc::dhcp::Pkt::getOption(), index_, isc_throw, LOG_DEBUG, isc::dhcp::TokenOption::pushFailure(), isc::dhcp::TokenVendor::SUBOPTION, isc::dhcp::TokenVendor::universe_, isc::dhcp::Option::V4, isc::dhcp::Option::V6, and isc::dhcp::TokenVendor::vendor_id_.

+ Here is the call graph for this function:

◆ getDataIndex()

uint16_t TokenVendorClass::getDataIndex ( ) const

Returns data index.

Used in testing.

Returns
data index (specifies which data chunk to retrieve)

Definition at line 1236 of file token.cc.

References index_.

Member Data Documentation

◆ index_

uint16_t isc::dhcp::TokenVendorClass::index_
protected

Data chunk index.

Definition at line 1256 of file token.h.

Referenced by evaluate(), and getDataIndex().


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