Kea  2.1.7-git
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. 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

 OptionOpaqueDataTuples (Option::Universe u, const uint16_t type)
 Constructor. More...
 
 OptionOpaqueDataTuples (Option::Universe u, const uint16_t type, 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...
 
bool hasTuple (const std::string &tuple_str) const
 Checks if the object 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, bool check=true) 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...
 
OptionCollectiongetMutableOptions ()
 Returns all encapsulated options. 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, bool check=true) const
 Store option's header in a buffer. More...
 
void packOptions (isc::util::OutputBuffer &buf, bool check=true) 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 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 36 of file option_opaque_data_tuples.h.

Member Typedef Documentation

◆ TuplesCollection

Collection of opaque data tuples carried by the option.

Definition at line 40 of file option_opaque_data_tuples.h.

Constructor & Destructor Documentation

◆ OptionOpaqueDataTuples() [1/2]

isc::dhcp::OptionOpaqueDataTuples::OptionOpaqueDataTuples ( Option::Universe  u,
const uint16_t  type 
)

Constructor.

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

Parameters
uuniverse (v4 or v6).
typeoption type

Definition at line 17 of file option_opaque_data_tuples.cc.

◆ OptionOpaqueDataTuples() [2/2]

isc::dhcp::OptionOpaqueDataTuples::OptionOpaqueDataTuples ( Option::Universe  u,
const uint16_t  type,
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)
typeoption type
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 22 of file option_opaque_data_tuples.cc.

References 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 68 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 31 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 96 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 117 of file option_opaque_data_tuples.h.

References hasTuple(), len(), isc::dhcp::OpaqueDataTuple::LENGTH_1_BYTE, isc::dhcp::OpaqueDataTuple::LENGTH_2_BYTES, toText(), isc::dhcp::Option::universe_, and isc::dhcp::Option::V6.

+ Here is the call graph for this function:

◆ getTuplesNum()

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

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

Definition at line 112 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 106 of file option_opaque_data_tuples.cc.

Referenced by getTuples().

◆ 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 119 of file option_opaque_data_tuples.cc.

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

Referenced by getTuples(), and 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.

Reimplemented from isc::dhcp::Option.

Definition at line 36 of file option_opaque_data_tuples.cc.

References 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 80 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 132 of file option_opaque_data_tuples.cc.

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

Referenced by getTuples().

+ 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 48 of file option_opaque_data_tuples.cc.

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

Referenced by OptionOpaqueDataTuples().

+ Here is the call graph for this function:

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