Kea  1.9.9-git
isc::dhcp::OptionVendorClass Class Reference

This class encapsulates DHCPv6 Vendor Class and DHCPv4 V-I Vendor Class options. More...

#include <option_vendor_class.h>

+ Inheritance diagram for isc::dhcp::OptionVendorClass:

Public Types

typedef std::vector< OpaqueDataTupleTuplesCollection
 Collection of opaque data tuples carried by the option. More...
 
- Public Types inherited from isc::dhcp::Option
typedef OptionPtr Factory(Option::Universe u, uint16_t type, const OptionBuffer &buf)
 a factory function prototype More...
 
enum  Universe { V4, V6 }
 defines option universe DHCPv4 or DHCPv6 More...
 

Public Member Functions

 OptionVendorClass (Option::Universe u, const uint32_t vendor_id)
 Constructor. More...
 
 OptionVendorClass (Option::Universe u, OptionBufferConstIter begin, OptionBufferConstIter end)
 Constructor. More...
 
void addTuple (const OpaqueDataTuple &tuple)
 Adds a new opaque data tuple to the option. More...
 
OptionPtr clone () const
 Copies this option and returns a pointer to the copy. More...
 
OpaqueDataTuple getTuple (const size_t at) const
 Returns opaque data tuple at the specified position. More...
 
const TuplesCollectiongetTuples () const
 Returns collection of opaque data tuples carried in the option. More...
 
size_t getTuplesNum () const
 Returns the number of opaque data tuples added to the option. More...
 
uint32_t getVendorId () const
 Returns enterprise id. More...
 
bool hasTuple (const std::string &tuple_str) const
 Checks if the Vendor Class holds the opaque data tuple with the specified string. More...
 
virtual uint16_t len () const
 Returns the full length of the option, including option header. More...
 
virtual void pack (isc::util::OutputBuffer &buf) const
 Renders option into the buffer in the wire format. More...
 
void setTuple (const size_t at, const OpaqueDataTuple &tuple)
 Replaces tuple at the specified index with a new tuple. More...
 
virtual std::string toText (int indent=0) const
 Returns text representation of the option. More...
 
virtual void unpack (OptionBufferConstIter begin, OptionBufferConstIter end)
 Parses buffer holding an option. More...
 
- Public Member Functions inherited from isc::dhcp::Option
 Option (Universe u, uint16_t type)
 ctor, used for options constructed, usually during transmission More...
 
 Option (Universe u, uint16_t type, const OptionBuffer &data)
 Constructor, used for received options. More...
 
 Option (Universe u, uint16_t type, OptionBufferConstIter first, OptionBufferConstIter last)
 Constructor, used for received options. More...
 
 Option (const Option &source)
 Copy constructor. More...
 
virtual ~Option ()
 just to force that every option has virtual dtor More...
 
void addOption (OptionPtr opt)
 Adds a sub-option. More...
 
bool delOption (uint16_t type)
 Attempts to delete first suboption of requested type. More...
 
bool equals (const OptionPtr &other) const
 Checks if options are equal. More...
 
virtual bool equals (const Option &other) const
 Checks if two options are equal. More...
 
virtual const OptionBuffergetData () const
 Returns pointer to actual data. More...
 
std::string getEncapsulatedSpace () const
 Returns the name of the option space encapsulated by this option. More...
 
virtual uint16_t getHeaderLen () const
 Returns length of header (2 for v4, 4 for v6) More...
 
OptionPtr getOption (uint16_t type) const
 Returns shared_ptr to suboption of specific type. More...
 
const OptionCollectiongetOptions () const
 Returns all encapsulated options. More...
 
void getOptionsCopy (OptionCollection &options_copy) const
 Performs deep copy of suboptions. More...
 
uint16_t getType () const
 Returns option type (0-255 for DHCPv4, 0-65535 for DHCPv6) More...
 
uint16_t getUint16 () const
 Returns content of first word. More...
 
uint32_t getUint32 () const
 Returns content of first double word. More...
 
uint8_t getUint8 () const
 Returns content of first byte. More...
 
Universe getUniverse () const
 returns option universe (V4 or V6) More...
 
Optionoperator= (const Option &rhs)
 Assignment operator. More...
 
template<typename InputIterator >
void setData (InputIterator first, InputIterator last)
 Sets content of this option from buffer. More...
 
void setEncapsulatedSpace (const std::string &encapsulated_space)
 Sets the name of the option space encapsulated by this option. More...
 
void setUint16 (uint16_t value)
 Sets content of this option to a single uint16 value. More...
 
void setUint32 (uint32_t value)
 Sets content of this option to a single uint32 value. More...
 
void setUint8 (uint8_t value)
 Sets content of this option to a single uint8 value. More...
 
virtual std::vector< uint8_t > toBinary (const bool include_header=false) const
 Returns binary representation of the option. More...
 
virtual std::string toHexString (const bool include_header=false) const
 Returns string containing hexadecimal representation of option. More...
 
virtual std::string toString () const
 Returns string representation of the value. More...
 
virtual bool valid () const
 returns if option is valid (e.g. More...
 

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. More...
 
static OptionPtr create (Universe u, uint16_t type, const OptionBuffer &data)
 Factory function creating an instance of the Option. More...
 
static OptionPtr factory (Option::Universe u, uint16_t type, const OptionBuffer &buf)
 Factory function to create instance of option. More...
 
static OptionPtr factory (Option::Universe u, uint16_t type)
 Factory function to create instance of option. More...
 
- Static Public Attributes inherited from isc::dhcp::Option
static bool lenient_parsing_
 Governs whether options should be parsed less strictly. More...
 
static const size_t OPTION4_HDR_LEN = 2
 length of the usual DHCPv4 option header (there are exceptions) More...
 
static const size_t OPTION6_HDR_LEN = 4
 length of any DHCPv6 option header More...
 
- Protected Member Functions inherited from isc::dhcp::Option
void check () const
 A protected method used for option correctness. More...
 
template<typename OptionType >
OptionPtr cloneInternal () const
 Copies this option and returns a pointer to the copy. More...
 
std::string headerToText (const int indent=0, const std::string &type_name="") const
 Returns option header in the textual format. More...
 
void packHeader (isc::util::OutputBuffer &buf) const
 Store option's header in a buffer. More...
 
void packOptions (isc::util::OutputBuffer &buf) const
 Store sub options in a buffer. More...
 
std::string suboptionsToText (const int indent=0) const
 Returns collection of suboptions in the textual format. More...
 
void unpackOptions (const OptionBuffer &buf)
 Builds a collection of sub options from the buffer. More...
 
- Protected Attributes inherited from isc::dhcp::Option
OptionBuffer data_
 contains content of this data More...
 
std::string encapsulated_space_
 Name of the option space being encapsulated by this option. More...
 
OptionCollection options_
 collection for storing suboptions More...
 
uint16_t type_
 option type (0-255 for DHCPv4, 0-65535 for DHCPv6) More...
 
Universe universe_
 option universe (V4 or V6) More...
 

Detailed Description

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.

Todo:
Currently, the enterprise id field is set to a value of the first enterprise id occurrence in the parsed option. At some point we should be able to differentiate between enterprise ids.

Definition at line 41 of file option_vendor_class.h.

Member Typedef Documentation

Collection of opaque data tuples carried by the option.

Definition at line 45 of file option_vendor_class.h.

Constructor & Destructor Documentation

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.

Parameters
uuniverse (v4 or v6).
vendor_idvendor enterprise id (unique 32-bit integer).

Definition at line 17 of file option_vendor_class.cc.

References addTuple(), isc::dhcp::OpaqueDataTuple::LENGTH_1_BYTE, and isc::dhcp::Option::V4.

+ Here is the call graph for this function:

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.

Parameters
uuniverse (v4 or v6)
beginIterator pointing to the beginning of the buffer holding an option.
endIterator pointing to the end of the buffer holding an option.

Definition at line 25 of file option_vendor_class.cc.

References unpack().

+ Here is the call graph for this function:

Member Function Documentation

void isc::dhcp::OptionVendorClass::addTuple ( const OpaqueDataTuple tuple)

Adds a new opaque data tuple to the option.

Parameters
tupleTuple to be added.
Exceptions
isc::BadValueif the type of the tuple doesn't match the universe this option belongs to.

Definition at line 96 of file option_vendor_class.cc.

References isc::dhcp::OpaqueDataTuple::getDataFieldSize(), isc::dhcp::OpaqueDataTuple::getLengthFieldType(), and isc_throw.

Referenced by OptionVendorClass(), and unpack().

+ Here is the call graph for this function:

OptionPtr isc::dhcp::OptionVendorClass::clone ( ) const
virtual

Copies this option and returns a pointer to the copy.

Reimplemented from isc::dhcp::Option.

Definition at line 33 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.

Parameters
atIndex for which tuple to get.
Exceptions
isc::OutOfRangeif the tuple position is out of range.

Definition at line 124 of file option_vendor_class.cc.

References getTuplesNum(), and isc_throw.

Referenced by toText().

+ Here is the call graph for this function:

const TuplesCollection& isc::dhcp::OptionVendorClass::getTuples ( ) const
inline

Returns collection of opaque data tuples carried in the option.

Definition at line 129 of file option_vendor_class.h.

size_t isc::dhcp::OptionVendorClass::getTuplesNum ( ) const
inline

Returns the number of opaque data tuples added to the option.

Definition at line 124 of file option_vendor_class.h.

Referenced by getTuple(), setTuple(), and toText().

uint32_t isc::dhcp::OptionVendorClass::getVendorId ( ) const
inline

Returns enterprise id.

Definition at line 91 of file option_vendor_class.h.

Referenced by pack(), and toText().

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.

Parameters
tuple_strString representation of the tuple being searched.
Returns
true if the specified tuple exists for this option.

Definition at line 134 of file option_vendor_class.cc.

uint16_t isc::dhcp::OptionVendorClass::len ( ) const
virtual

Returns the full length of the option, including option header.

Reimplemented from isc::dhcp::Option.

Definition at line 148 of file option_vendor_class.cc.

References isc::dhcp::Option::getHeaderLen(), isc::dhcp::Option::getUniverse(), and isc::dhcp::Option::V4.

Referenced by toText().

+ Here is the call graph for this function:

void isc::dhcp::OptionVendorClass::pack ( isc::util::OutputBuffer buf) const
virtual

Renders option into the buffer in the wire format.

Parameters
[out]bufBuffer to which the option is rendered.

Reimplemented from isc::dhcp::Option.

Definition at line 38 of file option_vendor_class.cc.

References isc::dhcp::Option::getUniverse(), getVendorId(), isc::dhcp::Option::packHeader(), isc::dhcp::Option::V4, and isc::util::OutputBuffer::writeUint32().

+ Here is the call graph for this function:

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.

Parameters
atIndex at which the tuple should be replaced.
tupleTuple to be set.
Exceptions
isc::OutOfRangeif the tuple position is out of range.
isc::BadValueif the type of the tuple doesn't match the universe this option belongs to.

Definition at line 108 of file option_vendor_class.cc.

References isc::dhcp::OpaqueDataTuple::getDataFieldSize(), isc::dhcp::OpaqueDataTuple::getLengthFieldType(), getTuplesNum(), and isc_throw.

+ Here is the call graph for this function:

std::string isc::dhcp::OptionVendorClass::toText ( int  indent = 0) const
virtual

Returns text representation of the option.

Parameters
indentNumber of space characters before text.
Returns
Text representation of the option.

Reimplemented from isc::dhcp::Option.

Definition at line 167 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.

+ Here is the call graph for this function:

void isc::dhcp::OptionVendorClass::unpack ( OptionBufferConstIter  begin,
OptionBufferConstIter  end 
)
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.

Parameters
beginIterator pointing to the beginning of the buffer holding an option.
endIterator pointing to the end of the buffer holding an option.

Reimplemented from isc::dhcp::Option.

Definition at line 57 of file option_vendor_class.cc.

References addTuple(), isc::dhcp::Option::getHeaderLen(), isc::dhcp::OpaqueDataTuple::getTotalLength(), isc::dhcp::Option::getUniverse(), isc_throw, isc::util::readUint32(), and isc::dhcp::Option::V4.

Referenced by OptionVendorClass().

+ Here is the call graph for this function:


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