Kea 2.7.4
|
This class encapsulates DHCPv6 Vendor Class and DHCPv4 V-I Vendor Class options. More...
#include <option_vendor_class.h>
Public Types | |
typedef std::vector< OpaqueDataTuple > | TuplesCollection |
Collection of opaque data tuples carried by the option. | |
Public Types inherited from isc::dhcp::Option | |
typedef OptionPtr | Factory(Option::Universe u, uint16_t type, const OptionBuffer &buf) |
a factory function prototype | |
enum | Universe { V4 , V6 } |
defines option universe DHCPv4 or DHCPv6 More... | |
Public Member Functions | |
OptionVendorClass (Option::Universe u, const uint32_t vendor_id) | |
Constructor. | |
OptionVendorClass (Option::Universe u, OptionBufferConstIter begin, OptionBufferConstIter end) | |
Constructor. | |
void | addTuple (const OpaqueDataTuple &tuple) |
Adds a new opaque data tuple to the option. | |
OptionPtr | clone () const |
Copies this option and returns a pointer to the copy. | |
OpaqueDataTuple | getTuple (const size_t at) const |
Returns opaque data tuple at the specified position. | |
const TuplesCollection & | getTuples () const |
Returns collection of opaque data tuples carried in the option. | |
size_t | getTuplesNum () const |
Returns the number of opaque data tuples added to the option. | |
uint32_t | getVendorId () const |
Returns enterprise id. | |
bool | hasTuple (const std::string &tuple_str) const |
Checks if the Vendor Class holds the opaque data tuple with the specified string. | |
virtual uint16_t | len () const |
Returns the full length of the option, including option header. | |
virtual void | pack (isc::util::OutputBuffer &buf, bool check=true) const |
Renders option into the buffer in the wire format. | |
void | setTuple (const size_t at, const OpaqueDataTuple &tuple) |
Replaces tuple at the specified index with a new tuple. | |
virtual std::string | toText (int indent=0) const |
Returns text representation of the option. | |
virtual void | unpack (OptionBufferConstIter begin, OptionBufferConstIter end) |
Parses buffer holding an option. | |
Public Member Functions inherited from isc::dhcp::Option | |
Option (const Option &source) | |
Copy constructor. | |
Option (Universe u, uint16_t type) | |
ctor, used for options constructed, usually during transmission | |
Option (Universe u, uint16_t type, const OptionBuffer &data) | |
Constructor, used for received options. | |
Option (Universe u, uint16_t type, OptionBufferConstIter first, OptionBufferConstIter last) | |
Constructor, used for received options. | |
virtual | ~Option () |
just to force that every option has virtual dtor | |
void | addOption (OptionPtr opt) |
Adds a sub-option. | |
bool | delOption (uint16_t type) |
Attempts to delete first suboption of requested type. | |
virtual bool | equals (const Option &other) const |
Checks if two options are equal. | |
bool | equals (const OptionPtr &other) const |
Checks if options are equal. | |
virtual const OptionBuffer & | getData () const |
Returns pointer to actual data. | |
std::string | getEncapsulatedSpace () const |
Returns the name of the option space encapsulated by this option. | |
virtual uint16_t | getHeaderLen () const |
Returns length of header (2 for v4, 4 for v6) | |
OptionCollection & | getMutableOptions () |
Returns all encapsulated options. | |
OptionPtr | getOption (uint16_t type) const |
Returns shared_ptr to suboption of specific type. | |
const OptionCollection & | getOptions () const |
Returns all encapsulated options. | |
void | getOptionsCopy (OptionCollection &options_copy) const |
Performs deep copy of suboptions. | |
uint16_t | getType () const |
Returns option type (0-255 for DHCPv4, 0-65535 for DHCPv6) | |
uint16_t | getUint16 () const |
Returns content of first word. | |
uint32_t | getUint32 () const |
Returns content of first double word. | |
uint8_t | getUint8 () const |
Returns content of first byte. | |
Universe | getUniverse () const |
returns option universe (V4 or V6) | |
Option & | operator= (const Option &rhs) |
Assignment operator. | |
template<typename InputIterator > | |
void | setData (InputIterator first, InputIterator last) |
Sets content of this option from buffer. | |
void | setEncapsulatedSpace (const std::string &encapsulated_space) |
Sets the name of the option space encapsulated by this option. | |
void | setUint16 (uint16_t value) |
Sets content of this option to a single uint16 value. | |
void | setUint32 (uint32_t value) |
Sets content of this option to a single uint32 value. | |
void | setUint8 (uint8_t value) |
Sets content of this option to a single uint8 value. | |
virtual std::vector< uint8_t > | toBinary (const bool include_header=false) const |
Returns binary representation of the option. | |
virtual std::string | toHexString (const bool include_header=false) const |
Returns string containing hexadecimal representation of option. | |
virtual std::string | toString () const |
Returns string representation of the value. | |
virtual bool | valid () const |
returns if option is valid (e.g. | |
Additional Inherited Members | |
Static Public Member Functions inherited from isc::dhcp::Option | |
static OptionPtr | create (Universe u, uint16_t type) |
Factory function creating an instance of the Option . | |
static OptionPtr | create (Universe u, uint16_t type, const OptionBuffer &data) |
Factory function creating an instance of the Option . | |
static OptionPtr | factory (Option::Universe u, uint16_t type) |
Factory function to create instance of option. | |
static OptionPtr | factory (Option::Universe u, uint16_t type, const OptionBuffer &buf) |
Factory function to create instance of option. | |
Static Public Attributes inherited from isc::dhcp::Option | |
static bool | lenient_parsing_ |
Governs whether options should be parsed less strictly. | |
static const size_t | OPTION4_HDR_LEN = 2 |
length of the usual DHCPv4 option header (there are exceptions) | |
static const size_t | OPTION6_HDR_LEN = 4 |
length of any DHCPv6 option header | |
Protected Member Functions inherited from isc::dhcp::Option | |
void | check () const |
A protected method used for option correctness. | |
template<typename OptionType > | |
OptionPtr | cloneInternal () const |
Copies this option and returns a pointer to the copy. | |
std::string | headerToText (const int indent=0, const std::string &type_name="") const |
Returns option header in the textual format. | |
void | packHeader (isc::util::OutputBuffer &buf, bool check=true) const |
Store option's header in a buffer. | |
void | packOptions (isc::util::OutputBuffer &buf, bool check=true) const |
Store sub options in a buffer. | |
std::string | suboptionsToText (const int indent=0) const |
Returns collection of suboptions in the textual format. | |
void | unpackOptions (const OptionBuffer &buf) |
Builds a collection of sub options from the buffer. | |
Protected Attributes inherited from isc::dhcp::Option | |
OptionBuffer | data_ |
contains content of this data | |
std::string | encapsulated_space_ |
Name of the option space being encapsulated by this option. | |
OptionCollection | options_ |
collection for storing suboptions | |
uint16_t | type_ |
option type (0-255 for DHCPv4, 0-65535 for DHCPv6) | |
Universe | universe_ |
option universe (V4 or V6) | |
This class encapsulates DHCPv6 Vendor Class and DHCPv4 V-I Vendor Class options.
The format of DHCPv6 Vendor Class option (16) is described in section 21.16 of RFC 8415 and the format of the DHCPv4 V-I Vendor Class option (124) is described in section 3 of RFC3925. Each of these options carries enterprise id followed by the collection of tuples carrying opaque data. A single tuple consists of the field holding opaque data length and the actual data. In case of the DHCPv4 V-I Vendor Class each tuple is preceded by the 4-byte long enterprise id. Also, the field which carries the length of the tuple is 1-byte long for DHCPv4 V-I Vendor Class and 2-bytes long for the DHCPv6 Vendor Class option.
Whether the encapsulated format is DHCPv4 V-I Vendor Class or DHCPv6 Vendor Class option is controlled by the u
(universe) parameter passed to the constructor.
Currently, the enterprise id field is set to a value of the first enterprise id occurrence in the parsed option. This assumes that all tuples in the same option are for the same vendor.
Definition at line 42 of file option_vendor_class.h.
typedef std::vector<OpaqueDataTuple> isc::dhcp::OptionVendorClass::TuplesCollection |
Collection of opaque data tuples carried by the option.
Definition at line 46 of file option_vendor_class.h.
isc::dhcp::OptionVendorClass::OptionVendorClass | ( | Option::Universe | u, |
const uint32_t | vendor_id ) |
Constructor.
This constructor instance of the DHCPv4 V-I Vendor Class option (124) or DHCPv6 Vendor Class option (16), depending on universe specified. If the universe is v4, the constructor adds one empty tuple to the option, as per RFC3925, section 3. the complete option must hold at least one data-len field for opaque data. If the specified universe is v6, the constructor adds no tuples.
u | universe (v4 or v6). |
vendor_id | vendor enterprise id (unique 32-bit integer). |
Definition at line 19 of file option_vendor_class.cc.
References addTuple(), isc::dhcp::OpaqueDataTuple::LENGTH_1_BYTE, and isc::dhcp::Option::V4.
isc::dhcp::OptionVendorClass::OptionVendorClass | ( | Option::Universe | u, |
OptionBufferConstIter | begin, | ||
OptionBufferConstIter | end ) |
Constructor.
This constructor creates an instance of the option using a buffer with on-wire data. It may throw an exception if the unpack
method throws.
u | universe (v4 or v6) |
begin | Iterator pointing to the beginning of the buffer holding an option. |
end | Iterator pointing to the end of the buffer holding an option. |
Definition at line 27 of file option_vendor_class.cc.
References unpack().
void isc::dhcp::OptionVendorClass::addTuple | ( | const OpaqueDataTuple & | tuple | ) |
Adds a new opaque data tuple to the option.
tuple | Tuple to be added. |
isc::BadValue | if the type of the tuple doesn't match the universe this option belongs to. |
Definition at line 111 of file option_vendor_class.cc.
References isc::dhcp::OptionDataTypeUtil::getTupleLenFieldType(), isc::dhcp::Option::getUniverse(), and isc_throw.
Referenced by OptionVendorClass(), and unpack().
|
virtual |
Copies this option and returns a pointer to the copy.
Reimplemented from isc::dhcp::Option.
Definition at line 35 of file option_vendor_class.cc.
OpaqueDataTuple isc::dhcp::OptionVendorClass::getTuple | ( | const size_t | at | ) | const |
Returns opaque data tuple at the specified position.
If the specified position is out of range an exception is thrown.
at | Index for which tuple to get. |
isc::OutOfRange | if the tuple position is out of range. |
Definition at line 139 of file option_vendor_class.cc.
References getTuplesNum(), and isc_throw.
Referenced by toText().
|
inline |
Returns collection of opaque data tuples carried in the option.
Definition at line 131 of file option_vendor_class.h.
|
inline |
Returns the number of opaque data tuples added to the option.
Definition at line 126 of file option_vendor_class.h.
Referenced by getTuple(), setTuple(), and toText().
|
inline |
Returns enterprise id.
Definition at line 93 of file option_vendor_class.h.
bool isc::dhcp::OptionVendorClass::hasTuple | ( | const std::string & | tuple_str | ) | const |
Checks if the Vendor Class holds the opaque data tuple with the specified string.
tuple_str | String representation of the tuple being searched. |
Definition at line 149 of file option_vendor_class.cc.
|
virtual |
Returns the full length of the option, including option header.
Reimplemented from isc::dhcp::Option.
Definition at line 162 of file option_vendor_class.cc.
References isc::dhcp::Option::getHeaderLen(), isc::dhcp::Option::getUniverse(), and isc::dhcp::Option::V4.
Referenced by toText().
|
virtual |
Renders option into the buffer in the wire format.
[out] | buf | Buffer to which the option is rendered. |
check | if set to false, allows options larger than 255 for v4 |
Reimplemented from isc::dhcp::Option.
Definition at line 40 of file option_vendor_class.cc.
References isc::dhcp::Option::check(), isc::dhcp::Option::getUniverse(), getVendorId(), isc::dhcp::Option::packHeader(), and isc::dhcp::Option::V4.
void isc::dhcp::OptionVendorClass::setTuple | ( | const size_t | at, |
const OpaqueDataTuple & | tuple ) |
Replaces tuple at the specified index with a new tuple.
This function replaces an opaque data tuple at the specified position with the new tuple. If the specified index is out of range an exception is thrown.
at | Index at which the tuple should be replaced. |
tuple | Tuple to be set. |
isc::OutOfRange | if the tuple position is out of range. |
isc::BadValue | if the type of the tuple doesn't match the universe this option belongs to. |
Definition at line 123 of file option_vendor_class.cc.
References isc::dhcp::OptionDataTypeUtil::getTupleLenFieldType(), getTuplesNum(), isc::dhcp::Option::getUniverse(), and isc_throw.
|
virtual |
Returns text representation of the option.
indent | Number of space characters before text. |
Reimplemented from isc::dhcp::Option.
Definition at line 182 of file option_vendor_class.cc.
References isc::dhcp::Option::getHeaderLen(), isc::dhcp::OpaqueDataTuple::getLength(), getTuple(), getTuplesNum(), isc::dhcp::Option::getType(), isc::dhcp::Option::getUniverse(), getVendorId(), len(), and isc::dhcp::Option::V4.
|
virtual |
Parses buffer holding an option.
This function parses the buffer holding an option and initializes option properties: enterprise ids and the collection of tuples.
begin | Iterator pointing to the beginning of the buffer holding an option. |
end | Iterator pointing to the end of the buffer holding an option. |
Reimplemented from isc::dhcp::Option.
Definition at line 61 of file option_vendor_class.cc.
References addTuple(), isc::dhcp::Option::getHeaderLen(), isc::dhcp::OptionDataTypeUtil::getTupleLenFieldType(), isc::dhcp::Option::getUniverse(), isc_throw, isc::util::readUint32(), and isc::dhcp::Option::V4.
Referenced by OptionVendorClass().