Kea 2.7.5
|
This class encapsulates a collection of data tuples and could be used by multiple options. More...
#include <option_opaque_data_tuples.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 | |
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 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. | |
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. | |
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 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.
Definition at line 37 of file option_opaque_data_tuples.h.
typedef std::vector<OpaqueDataTuple> isc::dhcp::OptionOpaqueDataTuples::TuplesCollection |
Collection of opaque data tuples carried by the option.
Definition at line 41 of file option_opaque_data_tuples.h.
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).
u | universe (v4 or v6). |
type | option type |
length_field_type | Indicates 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.
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.
u | universe (v4 or v6) |
type | option type |
begin | Iterator pointing to the beginning of the buffer holding an option. |
end | Iterator pointing to the end of the buffer holding an option. |
length_field_type | Indicates 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().
void isc::dhcp::OptionOpaqueDataTuples::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 74 of file option_opaque_data_tuples.cc.
References isc_throw.
Referenced by unpack().
|
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.
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.
at | Index for which tuple to get. |
isc::OutOfRange | if 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().
|
inline |
Returns collection of opaque data tuples carried in the option.
Definition at line 129 of file option_opaque_data_tuples.h.
|
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().
bool isc::dhcp::OptionOpaqueDataTuples::hasTuple | ( | const std::string & | tuple_str | ) | const |
Checks if the object holds the opaque data tuple with the specified string.
tuple_str | String representation of the tuple being searched. |
Definition at line 112 of file option_opaque_data_tuples.cc.
|
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().
|
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 44 of file option_opaque_data_tuples.cc.
References isc::dhcp::Option::check(), and isc::dhcp::Option::packHeader().
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.
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 86 of file option_opaque_data_tuples.cc.
References getTuplesNum(), 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 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().
|
virtual |
Parses buffer holding an option.
This function parses the buffer holding an option and initializes option properties: 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 55 of file option_opaque_data_tuples.cc.
References addTuple().
Referenced by OptionOpaqueDataTuples().