Kea 2.7.5
|
Token that represents vendor options in DHCPv4 and DHCPv6. More...
#include <token.h>
Public Types | |
enum | FieldType : int { 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... | |
Public Member Functions | |
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 unsigned | 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. | |
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 | getOption (Pkt &pkt) |
Attempts to get a suboption. | |
Protected Member Functions inherited from isc::dhcp::TokenOption | |
virtual std::string | pushFailure (ValueStack &values) |
Auxiliary method that puts string representing a failure. | |
Protected Attributes | |
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 | |
Static Public Member Functions inherited from isc::dhcp::Token | |
static bool | toBool (std::string value) |
Coverts a (string) value to a boolean. | |
Token that represents vendor options in DHCPv4 and DHCPv6.
It covers vendor independent vendor information option (125, DHCPv4) and vendor option (17, DHCPv6). Since both of those options may have suboptions, this class is derived from TokenOption and leverages its ability to operate on sub-options. It also adds additional capabilities. In particular, it allows retrieving enterprise-id.
It can represent the following expressions: vendor[4491].exists - if vendor option with enterprise-id = 4491 exists vendor[*].exists - if any vendor option exists vendor.enterprise - returns enterprise-id from vendor option vendor[4491].option[1].exists - check if suboption 1 exists for vendor 4491 vendor[4491].option[1].hex - return content of suboption 1 for vendor 4491
enum isc::dhcp::TokenVendor::FieldType : int |
TokenVendor::TokenVendor | ( | Option::Universe | u, |
uint32_t | vendor_id, | ||
FieldType | field ) |
Constructor used for accessing a field.
u | universe (either V4 or V6) |
vendor_id | specifies enterprise-id (0 means any) |
field | specifies which field should be returned |
Definition at line 1171 of file token.cc.
References isc::dhcp::TokenOption::EXISTS, EXISTS, field_, and isc::dhcp::TokenOption::representation_type_.
TokenVendor::TokenVendor | ( | Option::Universe | u, |
uint32_t | vendor_id, | ||
RepresentationType | repr, | ||
uint16_t | option_code = 0 ) |
Constructor used for accessing an option.
This constructor is used for accessing suboptions. In general option_code is mandatory, except when repr is EXISTS. For option_code = 0 and repr = EXISTS, the token will return true if the whole option exists, not suboptions.
u | universe (either V4 or V6) |
vendor_id | specifies enterprise-id (0 means any) |
repr | representation type (hex or exists) |
option_code | sub-option code |
|
virtual |
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 NONE, get specified suboption represented by option_code and represent it as specified by repr.
If FieldType is ENTERPRISE_ID, return value of the enterprise-id field or "" if there's no vendor option.
EvalTypeError | for any other FieldType values. |
The parameters passed are:
pkt | - vendor options will be searched for here. |
values | - the evaluated value will be pushed here. |
This is vendor[X].option[Y].exists, let's try to extract the option
Reimplemented from isc::dhcp::TokenOption.
Reimplemented in isc::dhcp::TokenVendorClass.
Definition at line 1190 of file token.cc.
References D6O_VENDOR_OPTS, DATA, isc::dhcp::DHO_VIVSO_SUBOPTIONS, isc::util::encode::encodeHex(), ENTERPRISE_ID, isc::dhcp::EVAL_DBG_STACK, isc::dhcp::EVAL_DEBUG_VENDOR_ENTERPRISE_ID, isc::dhcp::EVAL_DEBUG_VENDOR_ENTERPRISE_ID_MISMATCH, isc::dhcp::EVAL_DEBUG_VENDOR_EXISTS, isc::dhcp::EVAL_DEBUG_VENDOR_NO_OPTION, isc::dhcp::eval_logger, isc::dhcp::TokenOption::evaluate(), EXISTS, field_, isc_throw, LOG_DEBUG, isc::dhcp::TokenOption::pushFailure(), SUBOPTION, universe_, isc::dhcp::Option::V4, isc::dhcp::Option::V6, and vendor_id_.
TokenVendor::FieldType TokenVendor::getField | ( | ) | const |
Attempts to get a suboption.
This method overrides behavior of TokenOption method. It attempts to retrieve the sub-option of the vendor option. Using derived method allows usage of TokenOption routines.
pkt | vendor option will be searched here. |
Reimplemented from isc::dhcp::TokenOption.
Definition at line 1264 of file token.cc.
References D6O_VENDOR_OPTS, isc::dhcp::DHO_VIVSO_SUBOPTIONS, isc::dhcp::TokenOption::option_code_, universe_, isc::dhcp::Option::V4, and isc::dhcp::Option::V6.
uint32_t TokenVendor::getVendorId | ( | ) | const |
Returns enterprise-id.
Used in tests only.
Definition at line 1180 of file token.cc.
References vendor_id_.
|
protected |
Specifies which field should be accessed.
Definition at line 1231 of file token.h.
Referenced by TokenVendor(), isc::dhcp::TokenVendorClass::TokenVendorClass(), evaluate(), isc::dhcp::TokenVendorClass::evaluate(), and getField().
|
protected |
Universe (V4 or V6)
We need to remember it, because depending on the universe, the code needs to retrieve either option 125 (DHCPv4) or 17 (DHCPv6).
Definition at line 1222 of file token.h.
Referenced by evaluate(), isc::dhcp::TokenVendorClass::evaluate(), and getOption().
|
protected |
Enterprise-id value.
Yeah, I know it technically should be called enterprise-id, but that's too long and everyone calls it vendor-id.
Definition at line 1228 of file token.h.
Referenced by evaluate(), isc::dhcp::TokenVendorClass::evaluate(), and getVendorId().