Kea 2.5.8
isc::dhcp::OptionOpaqueDataTuples Class Reference

This class encapsulates a collection of data tuples and could be used by multiple options. More...

#include <option_opaque_data_tuples.h>

+ Inheritance diagram for isc::dhcp::OptionOpaqueDataTuples:

Public Types

typedef std::vector< OpaqueDataTupleTuplesCollection
 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

 OptionOpaqueDataTuples (Option::Universe u, const uint16_t type, OpaqueDataTuple::LengthFieldType length_field_type=OpaqueDataTuple::LENGTH_EMPTY)
 Constructor.
 
 OptionOpaqueDataTuples (Option::Universe u, const uint16_t type, OptionBufferConstIter begin, OptionBufferConstIter end, OpaqueDataTuple::LengthFieldType length_field_type=OpaqueDataTuple::LENGTH_EMPTY)
 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 TuplesCollectiongetTuples () 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.
 
bool hasTuple (const std::string &tuple_str) const
 Checks if the object 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.
 
virtual OptionPtr clone () const
 Copies this option and returns a pointer to the copy.
 
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 OptionBuffergetData () 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)
 
OptionCollectiongetMutableOptions ()
 Returns all encapsulated options.
 
OptionPtr getOption (uint16_t type) const
 Returns shared_ptr to suboption of specific type.
 
const OptionCollectiongetOptions () 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)
 
virtual uint16_t len () const
 Returns length of the complete option (data length + DHCPv4/DHCPv6 option header)
 
Optionoperator= (const Option &rhs)
 Assignment operator.
 
virtual void pack (isc::util::OutputBuffer &buf, bool check=true) const
 Writes option in wire-format to a buffer.
 
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 std::string toText (int indent=0) const
 Returns string representation of the option.
 
virtual void unpack (OptionBufferConstIter begin, OptionBufferConstIter end)
 Parses received buffer.
 
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)
 

Detailed Description

This class encapsulates a collection of data tuples and could be used by multiple options.

It is tailored for use with the DHCPv6 Bootfile-param option (option 60).

The format of the option is described in section 3.2 of RFC5970. This option may carry an arbitrary number of tuples carrying opaque data. Each tuple consists of a field holding the length of the opaque data followed by a string containing the data itself. For option 60 each length field is 2 bytes long and the data is a UTF-8 string that is not null terminated.

Todo:
The class is similar to the class used by the DHCPv6 Vendor Class (16) and DHCPv4 V-I Vendor Class (124) options, though they include an enterprise (or vendor) ID in the option. In the future it may make sense to rewrite the OptionVendorClass to derive from this class.

Definition at line 37 of file option_opaque_data_tuples.h.

Member Typedef Documentation

◆ TuplesCollection

Collection of opaque data tuples carried by the option.

Definition at line 41 of file option_opaque_data_tuples.h.

Constructor & Destructor Documentation

◆ OptionOpaqueDataTuples() [1/2]

isc::dhcp::OptionOpaqueDataTuples::OptionOpaqueDataTuples ( Option::Universe  u,
const uint16_t  type,
OpaqueDataTuple::LengthFieldType  length_field_type = OpaqueDataTuple::LENGTH_EMPTY 
)

Constructor.

This constructor creates an instance of an OptionOpaqueDataTuples that can be used for an option such as DHCPv6 Bootfile Parameters (60).

Parameters
uuniverse (v4 or v6).
typeoption type
length_field_typeIndicates a length of the field which holds the size of the tuple. If not provided explicitly, it is evaluated basing on Option's v4/v6 universe.

Definition at line 17 of file option_opaque_data_tuples.cc.

References isc::dhcp::OptionDataTypeUtil::getTupleLenFieldType(), and isc::dhcp::OpaqueDataTuple::LENGTH_EMPTY.

+ Here is the call graph for this function:

◆ OptionOpaqueDataTuples() [2/2]

isc::dhcp::OptionOpaqueDataTuples::OptionOpaqueDataTuples ( Option::Universe  u,
const uint16_t  type,
OptionBufferConstIter  begin,
OptionBufferConstIter  end,
OpaqueDataTuple::LengthFieldType  length_field_type = OpaqueDataTuple::LENGTH_EMPTY 
)

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)
typeoption type
beginIterator pointing to the beginning of the buffer holding an option.
endIterator pointing to the end of the buffer holding an option.
length_field_typeIndicates a length of the field which holds the size of the tuple. If not provided explicitly, it is evaluated basing on Option's v4/v6 universe.

Definition at line 26 of file option_opaque_data_tuples.cc.

References isc::dhcp::OptionDataTypeUtil::getTupleLenFieldType(), isc::dhcp::OpaqueDataTuple::LENGTH_EMPTY, and unpack().

+ Here is the call graph for this function:

Member Function Documentation

◆ addTuple()

void isc::dhcp::OptionOpaqueDataTuples::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 74 of file option_opaque_data_tuples.cc.

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

Referenced by unpack().

+ Here is the call graph for this function:

◆ clone()

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

Copies this option and returns a pointer to the copy.

Reimplemented from isc::dhcp::Option.

Definition at line 39 of file option_opaque_data_tuples.cc.

◆ getTuple()

OpaqueDataTuple isc::dhcp::OptionOpaqueDataTuples::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 102 of file option_opaque_data_tuples.cc.

References getTuplesNum(), and isc_throw.

Referenced by toText().

+ Here is the call graph for this function:

◆ getTuples()

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

Returns collection of opaque data tuples carried in the option.

Definition at line 129 of file option_opaque_data_tuples.h.

◆ getTuplesNum()

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

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

Definition at line 124 of file option_opaque_data_tuples.h.

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

◆ hasTuple()

bool isc::dhcp::OptionOpaqueDataTuples::hasTuple ( const std::string &  tuple_str) const

Checks if the object 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 112 of file option_opaque_data_tuples.cc.

◆ len()

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

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

Reimplemented from isc::dhcp::Option.

Definition at line 124 of file option_opaque_data_tuples.cc.

References isc::dhcp::Option::getHeaderLen().

Referenced by toText().

+ Here is the call graph for this function:

◆ pack()

void isc::dhcp::OptionOpaqueDataTuples::pack ( isc::util::OutputBuffer buf,
bool  check = true 
) const
virtual

Renders option into the buffer in the wire format.

Parameters
[out]bufBuffer to which the option is rendered.
checkif set to false, allows options larger than 255 for v4

Reimplemented from isc::dhcp::Option.

Definition at line 44 of file option_opaque_data_tuples.cc.

References isc::dhcp::Option::check(), and isc::dhcp::Option::packHeader().

+ Here is the call graph for this function:

◆ setTuple()

void isc::dhcp::OptionOpaqueDataTuples::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 86 of file option_opaque_data_tuples.cc.

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

+ Here is the call graph for this function:

◆ toText()

std::string isc::dhcp::OptionOpaqueDataTuples::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 136 of file option_opaque_data_tuples.cc.

References isc::dhcp::Option::getHeaderLen(), isc::dhcp::OpaqueDataTuple::getLength(), getTuple(), getTuplesNum(), isc::dhcp::Option::getType(), and len().

+ Here is the call graph for this function:

◆ unpack()

void isc::dhcp::OptionOpaqueDataTuples::unpack ( OptionBufferConstIter  begin,
OptionBufferConstIter  end 
)
virtual

Parses buffer holding an option.

This function parses the buffer holding an option and initializes option properties: 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 55 of file option_opaque_data_tuples.cc.

References addTuple(), and isc::dhcp::OpaqueDataTuple::getTotalLength().

Referenced by OptionOpaqueDataTuples().

+ Here is the call graph for this function:

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