Kea: isc::dhcp::TokenVendorClass Class Reference

| Kea 2.2.0

Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
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:
[legend]

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

## Protected Member Functions
void | evaluate (Pkt &pkt, ValueStack &values)
| This is a method for evaluating a packet. More...
Protected Member Functions inherited from isc::dhcp::TokenVendor
virtual OptionPtr | getOption (Pkt &pkt)
| Attempts to get a suboption. 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 | index_
| Data chunk index. More...
Protected Attributes inherited from isc::dhcp::TokenVendor
FieldType | field_
| Specifies which field should be accessed. More...
Option::Universe | universe_
| Universe (V4 or V6) More...
uint32_t | vendor_id_
| Enterprise-id value. 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::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. More...

## 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 1174 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

  u | universe (V4 or V6)
  vendor_id | value of enterprise-id field (0 means any)
  repr | representation type (EXISTS or HEX)

Definition at line 1156 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

  u | universe (V4 or V6)
  vendor_id | value of enterprise-id field (0 means any)
  field | type of the field (usually DATA or ENTERPRISE)
  index | specifies which data chunk to retrieve

Definition at line 1161 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

  EvalTypeError | for 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 1171 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::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 1167 of file token.cc.

References index_.

## Member Data Documentation

## ◆ index_

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

Data chunk index.

Definition at line 1227 of file token.h.

Referenced by evaluate(), and getDataIndex().

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

- token.h
- token.cc