Kea  2.1.2-git
isc::dhcp::OptionCustom Class Reference

Option with defined data fields represented as buffers that can be accessed using data field index. More...

#include <option_custom.h>

+ Inheritance diagram for isc::dhcp::OptionCustom:

Public Member Functions

 OptionCustom (const OptionDefinition &def, Universe u)
 Constructor, used for options to be sent. More...
 
 OptionCustom (const OptionDefinition &def, Universe u, const OptionBuffer &data)
 Constructor, used for options to be sent. More...
 
 OptionCustom (const OptionDefinition &def, Universe u, OptionBufferConstIter first, OptionBufferConstIter last)
 Constructor, used for received options. More...
 
void addArrayDataField (const asiolink::IOAddress &address)
 Create new buffer and set its value as an IP address. More...
 
void addArrayDataField (const bool value)
 Create new buffer and store boolean value in it. More...
 
template<typename T >
void addArrayDataField (const T value)
 Create new buffer and store integer value in it. More...
 
void addArrayDataField (const std::string &value)
 Create new buffer and store tuple value in it. More...
 
void addArrayDataField (const OpaqueDataTuple &value)
 Create new buffer and store tuple value in it. More...
 
void addArrayDataField (const PrefixLen &prefix_len, const asiolink::IOAddress &prefix)
 Create new buffer and store variable length prefix in it. More...
 
void addArrayDataField (const PSIDLen &psid_len, const PSID &psid)
 Create new buffer and store PSID length / value in it. More...
 
virtual OptionPtr clone () const
 Copies this option and returns a pointer to the copy. More...
 
uint32_t getDataFieldsNum () const
 Return a number of the data fields. More...
 
void initialize (const OptionBufferConstIter first, const OptionBufferConstIter last)
 Sets content of this option from buffer. More...
 
virtual uint16_t len () const
 Returns length of the complete option (data length + DHCPv4/DHCPv6 option header) More...
 
virtual void pack (isc::util::OutputBuffer &buf) const
 Writes DHCP option in a wire format to a buffer. More...
 
asiolink::IOAddress readAddress (const uint32_t index=0) const
 Read a buffer as IP address. More...
 
const OptionBufferreadBinary (const uint32_t index=0) const
 Read a buffer as binary data. More...
 
bool readBoolean (const uint32_t index=0) const
 Read a buffer as boolean value. More...
 
std::string readFqdn (const uint32_t index=0) const
 Read a buffer as FQDN. More...
 
template<typename T >
readInteger (const uint32_t index=0) const
 Read a buffer as integer value. More...
 
PrefixTuple readPrefix (const uint32_t index=0) const
 Read a buffer as variable length prefix. More...
 
PSIDTuple readPsid (const uint32_t index=0) const
 Read a buffer as a PSID length / value tuple. More...
 
std::string readString (const uint32_t index=0) const
 Read a buffer as string value. More...
 
std::string readTuple (const uint32_t index=0) const
 Read a buffer as length and string tuple. More...
 
void readTuple (OpaqueDataTuple &tuple, const uint32_t index=0) const
 Read a buffer into a length and string tuple. More...
 
virtual std::string toText (int indent=0) const
 Returns string representation of the option. More...
 
virtual void unpack (OptionBufferConstIter begin, OptionBufferConstIter end)
 Parses received buffer. More...
 
void writeAddress (const asiolink::IOAddress &address, const uint32_t index=0)
 Write an IP address into a buffer. More...
 
void writeBinary (const OptionBuffer &buf, const uint32_t index=0)
 Write binary data into a buffer. More...
 
void writeBoolean (const bool value, const uint32_t index=0)
 Write a boolean value into a buffer. More...
 
void writeFqdn (const std::string &fqdn, const uint32_t index=0)
 Write an FQDN into a buffer. More...
 
template<typename T >
void writeInteger (const T value, const uint32_t index=0)
 Write an integer value into a buffer. More...
 
void writePrefix (const PrefixLen &prefix_len, const asiolink::IOAddress &prefix, const uint32_t index=0)
 Write prefix length and value into a buffer. More...
 
void writePsid (const PSIDLen &psid_len, const PSID &psid, const uint32_t index=0)
 Write PSID length / value into a buffer. More...
 
void writeString (const std::string &text, const uint32_t index=0)
 Write a string value into a buffer. More...
 
void writeTuple (const std::string &value, const uint32_t index=0)
 Write a length and string tuple into a buffer. More...
 
void writeTuple (const OpaqueDataTuple &value, const uint32_t index=0)
 Write a length and string tuple into a buffer. 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

- 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...
 
- 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

Option with defined data fields represented as buffers that can be accessed using data field index.

This class represents an option which has defined structure: data fields of specific types and order. Those fields can be accessed using indexes, where index 0 represents first data field within an option. The last field can be accessed using index equal to 'number of fields' - 1. Internally, the option data is stored as a collection of OptionBuffer objects, each representing data for a particular data field. This data can be converted to the actual data type using methods implemented within this class. This class is used to represent those options that can't be represented by any other specialized class (this excludes the Option class which is generic and can be used to represent any option).

Definition at line 32 of file option_custom.h.

Constructor & Destructor Documentation

◆ OptionCustom() [1/3]

isc::dhcp::OptionCustom::OptionCustom ( const OptionDefinition def,
Universe  u 
)

Constructor, used for options to be sent.

This constructor creates an instance of an option with default data set for all data fields. The option buffers are allocated according to data size being stored in particular data fields. For variable size data empty buffers are created.

Parameters
defoption definition.
uspecifies universe (V4 or V6)

Definition at line 19 of file option_custom.cc.

References isc::dhcp::OptionDefinition::getEncapsulatedSpace(), and isc::dhcp::Option::setEncapsulatedSpace().

+ Here is the call graph for this function:

◆ OptionCustom() [2/3]

isc::dhcp::OptionCustom::OptionCustom ( const OptionDefinition def,
Universe  u,
const OptionBuffer data 
)

Constructor, used for options to be sent.

This constructor creates an instance of an option from the whole supplied buffer. This constructor is mainly used to create an instances of options to be stored in outgoing DHCP packets. The buffer used to create the instance of an option can be created from the option data specified in server's configuration.

Parameters
defoption definition.
uspecifies universe (V4 or V6).
datacontent of the option.
Exceptions
OutOfRangeif option buffer is truncated.
Todo:
list all exceptions thrown by ctor.

Definition at line 27 of file option_custom.cc.

References isc::dhcp::Option::getData(), isc::dhcp::OptionDefinition::getEncapsulatedSpace(), and isc::dhcp::Option::setEncapsulatedSpace().

+ Here is the call graph for this function:

◆ OptionCustom() [3/3]

isc::dhcp::OptionCustom::OptionCustom ( const OptionDefinition def,
Universe  u,
OptionBufferConstIter  first,
OptionBufferConstIter  last 
)

Constructor, used for received options.

This constructor creates an instance an option from the portion of the buffer specified by iterators. This is mainly useful when parsing received packets. Such packets are represented by a single buffer holding option data and all sub options. Methods that are parsing a packet, supply relevant portions of the packet buffer to this constructor to create option instances out of it.

Parameters
defoption definition.
uspecifies universe (V4 or V6).
firstiterator to the first element that should be copied.
lastiterator to the next element after the last one to be copied.
Exceptions
OutOfRangeif option buffer is truncated.
Todo:
list all exceptions thrown by ctor.

Definition at line 36 of file option_custom.cc.

References isc::dhcp::Option::getData(), isc::dhcp::OptionDefinition::getEncapsulatedSpace(), and isc::dhcp::Option::setEncapsulatedSpace().

+ Here is the call graph for this function:

Member Function Documentation

◆ addArrayDataField() [1/7]

void isc::dhcp::OptionCustom::addArrayDataField ( const asiolink::IOAddress address)

Create new buffer and set its value as an IP address.

Parameters
addressIPv4 or IPv6 address to be written to a buffer being created.

Definition at line 52 of file option_custom.cc.

References isc::dhcp::OptionDefinition::getType(), isc_throw, isc::asiolink::IOAddress::isV4(), isc::asiolink::IOAddress::isV6(), isc::dhcp::OPT_IPV4_ADDRESS_TYPE, isc::dhcp::OPT_IPV6_ADDRESS_TYPE, and isc::dhcp::OptionDataTypeUtil::writeAddress().

Referenced by addArrayDataField().

+ Here is the call graph for this function:

◆ addArrayDataField() [2/7]

void isc::dhcp::OptionCustom::addArrayDataField ( const bool  value)

Create new buffer and store boolean value in it.

Parameters
valuevalue to be stored in the created buffer.

Definition at line 89 of file option_custom.cc.

References isc::dhcp::OptionDataTypeUtil::writeBool().

+ Here is the call graph for this function:

◆ addArrayDataField() [3/7]

template<typename T >
void isc::dhcp::OptionCustom::addArrayDataField ( const T  value)
inline

Create new buffer and store integer value in it.

Parameters
valuevalue to be stored in the created buffer.
Template Parameters
Tinteger type of the value being stored.

Definition at line 103 of file option_custom.h.

References addArrayDataField(), isc::dhcp::OptionDefinition::getRecordFields(), isc::dhcp::OptionDefinition::getType(), isc_throw, and isc::dhcp::OPT_RECORD_TYPE.

+ Here is the call graph for this function:

◆ addArrayDataField() [4/7]

void isc::dhcp::OptionCustom::addArrayDataField ( const std::string &  value)

Create new buffer and store tuple value in it.

Parameters
valuevalue to be stored as a tuple in the created buffer.

Definition at line 69 of file option_custom.cc.

References isc::dhcp::Option::getUniverse(), isc::dhcp::OpaqueDataTuple::LENGTH_1_BYTE, isc::dhcp::OpaqueDataTuple::LENGTH_2_BYTES, isc::dhcp::Option::V4, and isc::dhcp::OptionDataTypeUtil::writeTuple().

+ Here is the call graph for this function:

◆ addArrayDataField() [5/7]

void isc::dhcp::OptionCustom::addArrayDataField ( const OpaqueDataTuple value)

Create new buffer and store tuple value in it.

Parameters
valuevalue to be stored as a tuple in the created buffer.

Definition at line 80 of file option_custom.cc.

References isc::dhcp::OptionDataTypeUtil::writeTuple().

+ Here is the call graph for this function:

◆ addArrayDataField() [6/7]

void isc::dhcp::OptionCustom::addArrayDataField ( const PrefixLen prefix_len,
const asiolink::IOAddress prefix 
)

Create new buffer and store variable length prefix in it.

Parameters
prefix_lenPrefix length.
prefixPrefix.

Definition at line 98 of file option_custom.cc.

References isc::dhcp::OptionDefinition::getType(), isc_throw, isc::dhcp::OPT_IPV6_PREFIX_TYPE, and isc::dhcp::OptionDataTypeUtil::writePrefix().

+ Here is the call graph for this function:

◆ addArrayDataField() [7/7]

void isc::dhcp::OptionCustom::addArrayDataField ( const PSIDLen psid_len,
const PSID psid 
)

Create new buffer and store PSID length / value in it.

Parameters
psid_lenPSID length.
psidPSID.

Definition at line 113 of file option_custom.cc.

References isc::util::encode::encodeHex(), isc::dhcp::OptionDefinition::getArrayType(), isc::dhcp::OptionDataTypeUtil::getDataTypeLen(), isc::dhcp::OptionDataTypeUtil::getDataTypeName(), isc::dhcp::Option::getEncapsulatedSpace(), isc::dhcp::OptionDefinition::getRecordFields(), isc::dhcp::OptionDefinition::getType(), isc::dhcp::Option::getUniverse(), isc::asiolink::IOAddress::IPV6_ZERO_ADDRESS(), isc_throw, isc_throw_assert, isc::dhcp::OpaqueDataTuple::LENGTH_1_BYTE, isc::dhcp::OpaqueDataTuple::LENGTH_2_BYTES, isc::dhcp::OPT_BINARY_TYPE, isc::dhcp::OPT_BOOLEAN_TYPE, isc::dhcp::OPT_EMPTY_TYPE, isc::dhcp::OPT_FQDN_TYPE, isc::dhcp::OPT_INT16_TYPE, isc::dhcp::OPT_INT32_TYPE, isc::dhcp::OPT_INT8_TYPE, isc::dhcp::OPT_IPV4_ADDRESS_TYPE, isc::dhcp::OPT_IPV6_ADDRESS_TYPE, isc::dhcp::OPT_IPV6_PREFIX_TYPE, isc::dhcp::OPT_PSID_TYPE, isc::dhcp::OPT_RECORD_TYPE, isc::dhcp::OPT_STRING_TYPE, isc::dhcp::OPT_TUPLE_TYPE, isc::dhcp::OPT_UINT16_TYPE, isc::dhcp::OPT_UINT32_TYPE, isc::dhcp::OPT_UINT8_TYPE, readAddress(), readBinary(), readBoolean(), readFqdn(), isc::dhcp::OptionDataTypeUtil::readFqdn(), isc::dhcp::OptionDataTypeUtil::readPrefix(), readPsid(), readString(), readTuple(), isc::dhcp::OptionDataTypeUtil::readTuple(), isc::dhcp::Option::unpackOptions(), isc::dhcp::Option::V4, isc::dhcp::OptionDefinition::validate(), isc::dhcp::OptionDataTypeUtil::writeFqdn(), isc::dhcp::OptionDataTypeUtil::writePrefix(), and isc::dhcp::OptionDataTypeUtil::writePsid().

+ Here is the call graph for this function:

◆ clone()

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

Copies this option and returns a pointer to the copy.

Reimplemented from isc::dhcp::Option.

Definition at line 47 of file option_custom.cc.

◆ getDataFieldsNum()

uint32_t isc::dhcp::OptionCustom::getDataFieldsNum ( ) const
inline

Return a number of the data fields.

Returns
number of data fields held by the option.

Definition at line 147 of file option_custom.h.

References readAddress(), readBinary(), readBoolean(), readFqdn(), readTuple(), writeAddress(), writeBinary(), writeBoolean(), writeFqdn(), and writeTuple().

Referenced by toText().

+ Here is the call graph for this function:

◆ initialize()

void isc::dhcp::OptionCustom::initialize ( const OptionBufferConstIter  first,
const OptionBufferConstIter  last 
)

Sets content of this option from buffer.

Option will be resized to length of buffer.

Parameters
firstiterator pointing to beginning of buffer to copy.
lastiterator pointing to end of buffer to copy.

Definition at line 685 of file option_custom.cc.

References isc::dhcp::Option::getData(), and isc::dhcp::Option::setData().

Referenced by unpack(), and writeInteger().

+ Here is the call graph for this function:

◆ len()

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

Returns length of the complete option (data length + DHCPv4/DHCPv6 option header)

Returns
length of the option

Reimplemented from isc::dhcp::Option.

Definition at line 665 of file option_custom.cc.

References isc::dhcp::Option::getHeaderLen(), and isc::dhcp::Option::options_.

Referenced by writeInteger().

+ Here is the call graph for this function:

◆ pack()

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

Writes DHCP option in a wire format to a buffer.

Parameters
bufoutput buffer (option will be stored there).

Reimplemented from isc::dhcp::Option.

Definition at line 458 of file option_custom.cc.

References isc::dhcp::Option::packHeader(), isc::dhcp::Option::packOptions(), and isc::util::OutputBuffer::writeData().

Referenced by writeInteger().

+ Here is the call graph for this function:

◆ readAddress()

IOAddress isc::dhcp::OptionCustom::readAddress ( const uint32_t  index = 0) const

Read a buffer as IP address.

Parameters
indexbuffer index.
Returns
IP address read from a buffer.
Exceptions
isc::OutOfRangeif index is out of range.

Definition at line 480 of file option_custom.cc.

References isc_throw, and isc::dhcp::OptionDataTypeUtil::readAddress().

Referenced by addArrayDataField(), and getDataFieldsNum().

+ Here is the call graph for this function:

◆ readBinary()

const OptionBuffer & isc::dhcp::OptionCustom::readBinary ( const uint32_t  index = 0) const

Read a buffer as binary data.

Parameters
indexbuffer index.
Exceptions
isc::OutOfRangeif index is out of range.
Returns
read buffer holding binary data.

Definition at line 516 of file option_custom.cc.

Referenced by addArrayDataField(), and getDataFieldsNum().

◆ readBoolean()

bool isc::dhcp::OptionCustom::readBoolean ( const uint32_t  index = 0) const

Read a buffer as boolean value.

Parameters
indexbuffer index.
Exceptions
isc::OutOfRangeif index is out of range.
Returns
read boolean value.

Definition at line 562 of file option_custom.cc.

References isc::dhcp::OptionDataTypeUtil::readBool().

Referenced by addArrayDataField(), and getDataFieldsNum().

+ Here is the call graph for this function:

◆ readFqdn()

std::string isc::dhcp::OptionCustom::readFqdn ( const uint32_t  index = 0) const

Read a buffer as FQDN.

Parameters
indexbuffer index.
Exceptions
isc::OutOfRangeif buffer index is out of range.
isc::dhcp::BadDataTypeCastif a buffer being read does not hold a valid FQDN.
Returns
string representation if FQDN.

Definition at line 576 of file option_custom.cc.

References isc::dhcp::OptionDataTypeUtil::readFqdn().

Referenced by addArrayDataField(), and getDataFieldsNum().

+ Here is the call graph for this function:

◆ readInteger()

template<typename T >
T isc::dhcp::OptionCustom::readInteger ( const uint32_t  index = 0) const
inline

Read a buffer as integer value.

Parameters
indexbuffer index.
Template Parameters
integertype of a value being returned.
Exceptions
isc::OutOfRangeif index is out of range.
isc::dhcp::InvalidDataTypeif T is invalid.
Returns
read integer value.

Definition at line 252 of file option_custom.h.

References isc_throw_assert.

Referenced by checkIAStatus().

◆ readPrefix()

PrefixTuple isc::dhcp::OptionCustom::readPrefix ( const uint32_t  index = 0) const

Read a buffer as variable length prefix.

Parameters
indexbuffer index.
Returns
Prefix length / value tuple.
Exceptions
isc::OutOfRangeof index is out of range.

Definition at line 599 of file option_custom.cc.

References isc::dhcp::OptionDataTypeUtil::readPrefix().

Referenced by writeInteger().

+ Here is the call graph for this function:

◆ readPsid()

PSIDTuple isc::dhcp::OptionCustom::readPsid ( const uint32_t  index = 0) const

Read a buffer as a PSID length / value tuple.

Parameters
indexbuffer index.
Returns
PSID length / value tuple.
Exceptions
isc::OutOfRangeof index is out of range.

Definition at line 619 of file option_custom.cc.

References isc::dhcp::OptionDataTypeUtil::readPsid().

Referenced by addArrayDataField(), and writeInteger().

+ Here is the call graph for this function:

◆ readString()

std::string isc::dhcp::OptionCustom::readString ( const uint32_t  index = 0) const

Read a buffer as string value.

Parameters
indexbuffer index.
Returns
string value read from buffer.
Exceptions
isc::OutOfRangeif index is out of range.

Definition at line 638 of file option_custom.cc.

References isc::dhcp::OptionDataTypeUtil::readString().

Referenced by addArrayDataField(), and writeInteger().

+ Here is the call graph for this function:

◆ readTuple() [1/2]

std::string isc::dhcp::OptionCustom::readTuple ( const uint32_t  index = 0) const

Read a buffer as length and string tuple.

Parameters
indexbuffer index.
Exceptions
isc::OutOfRangeif index is out of range.
Returns
string read from a buffer.

Definition at line 529 of file option_custom.cc.

References isc::dhcp::Option::getUniverse(), isc::dhcp::OpaqueDataTuple::LENGTH_1_BYTE, isc::dhcp::OpaqueDataTuple::LENGTH_2_BYTES, isc::dhcp::OptionDataTypeUtil::readTuple(), and isc::dhcp::Option::V4.

Referenced by addArrayDataField(), and getDataFieldsNum().

+ Here is the call graph for this function:

◆ readTuple() [2/2]

void isc::dhcp::OptionCustom::readTuple ( OpaqueDataTuple tuple,
const uint32_t  index = 0 
) const

Read a buffer into a length and string tuple.

Parameters
tupletuple to fill.
indexbuffer index.
Exceptions
isc::OutOfRangeif index is out of range.

Definition at line 537 of file option_custom.cc.

References isc::dhcp::OptionDataTypeUtil::readTuple().

+ Here is the call graph for this function:

◆ toText()

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

Returns string representation of the option.

Parameters
indentnumber of spaces before printed text.
Returns
string with text representation.

Reimplemented from isc::dhcp::Option.

Definition at line 694 of file option_custom.cc.

References isc::dhcp::OptionDefinition::getArrayType(), getDataFieldsNum(), isc::dhcp::OptionDefinition::getRecordFields(), isc::dhcp::OptionDefinition::getType(), isc::dhcp::Option::headerToText(), isc::dhcp::OPT_RECORD_TYPE, and isc::dhcp::Option::suboptionsToText().

Referenced by writeInteger().

+ Here is the call graph for this function:

◆ unpack()

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

Parses received buffer.

Parameters
beginiterator to first byte of option data
enditerator to end of option data (first byte after option end)

Reimplemented from isc::dhcp::Option.

Definition at line 659 of file option_custom.cc.

References initialize().

Referenced by writeInteger().

+ Here is the call graph for this function:

◆ writeAddress()

void isc::dhcp::OptionCustom::writeAddress ( const asiolink::IOAddress address,
const uint32_t  index = 0 
)

Write an IP address into a buffer.

Parameters
addressIP address being written.
indexbuffer index.
Exceptions
isc::OutOfRangeif index is out of range.
isc::dhcp::BadDataTypeCastif IP address is invalid.

Definition at line 498 of file option_custom.cc.

References isc::asiolink::IOAddress::isV4().

Referenced by getDataFieldsNum().

+ Here is the call graph for this function:

◆ writeBinary()

void isc::dhcp::OptionCustom::writeBinary ( const OptionBuffer buf,
const uint32_t  index = 0 
)

Write binary data into a buffer.

Parameters
bufbuffer holding binary data to be written.
indexbuffer index.

Definition at line 522 of file option_custom.cc.

Referenced by getDataFieldsNum().

◆ writeBoolean()

void isc::dhcp::OptionCustom::writeBoolean ( const bool  value,
const uint32_t  index = 0 
)

Write a boolean value into a buffer.

Parameters
valueboolean value to be written.
indexbuffer index.
Exceptions
isc::OutOfRangeif index is out of range.

Definition at line 568 of file option_custom.cc.

References isc::dhcp::OptionDataTypeUtil::writeBool().

Referenced by getDataFieldsNum().

+ Here is the call graph for this function:

◆ writeFqdn()

void isc::dhcp::OptionCustom::writeFqdn ( const std::string &  fqdn,
const uint32_t  index = 0 
)

Write an FQDN into a buffer.

Parameters
fqdntext representation of FQDN.
indexbuffer index.
Exceptions
isc::OutOfRangeif index is out of range.

Definition at line 582 of file option_custom.cc.

References isc::dhcp::OptionDataTypeUtil::writeFqdn().

Referenced by getDataFieldsNum().

+ Here is the call graph for this function:

◆ writeInteger()

template<typename T >
void isc::dhcp::OptionCustom::writeInteger ( const T  value,
const uint32_t  index = 0 
)
inline

Write an integer value into a buffer.

Parameters
valueinteger value to be written.
indexbuffer index.
Template Parameters
Tinteger type of a value being written.
Exceptions
isc::OutOfRangeif index is out of range.
isc::dhcp::InvalidDataTypeif T is invalid.

Definition at line 274 of file option_custom.h.

References isc::dhcp::OptionDefinition::getArrayType(), initialize(), isc_throw, len(), pack(), readPrefix(), readPsid(), readString(), isc::dhcp::Option::setData(), toText(), unpack(), writePrefix(), writePsid(), and writeString().

+ Here is the call graph for this function:

◆ writePrefix()

void isc::dhcp::OptionCustom::writePrefix ( const PrefixLen prefix_len,
const asiolink::IOAddress prefix,
const uint32_t  index = 0 
)

Write prefix length and value into a buffer.

Parameters
prefix_lenPrefix length.
prefixPrefix value.
indexBuffer index.
Exceptions
isc::OutOfRangeif index is out of range.

Definition at line 605 of file option_custom.cc.

References isc::dhcp::OptionDataTypeUtil::writePrefix().

Referenced by writeInteger().

+ Here is the call graph for this function:

◆ writePsid()

void isc::dhcp::OptionCustom::writePsid ( const PSIDLen psid_len,
const PSID psid,
const uint32_t  index = 0 
)

Write PSID length / value into a buffer.

Parameters
psid_lenPSID length value.
psidPSID value in the range of 0 .. 2^(PSID length).
indexbuffer index.
Exceptions
isc::dhcp::BadDataTypeCastif PSID length or value is invalid.
isc::OutOfRangeif index is out of range.

Definition at line 625 of file option_custom.cc.

References isc::dhcp::OptionDataTypeUtil::writePsid().

Referenced by writeInteger().

+ Here is the call graph for this function:

◆ writeString()

void isc::dhcp::OptionCustom::writeString ( const std::string &  text,
const uint32_t  index = 0 
)

Write a string value into a buffer.

Parameters
textthe string value to be written.
indexbuffer index.

Definition at line 644 of file option_custom.cc.

References isc::dhcp::OptionDataTypeUtil::writeString().

Referenced by writeInteger().

+ Here is the call graph for this function:

◆ writeTuple() [1/2]

void isc::dhcp::OptionCustom::writeTuple ( const std::string &  value,
const uint32_t  index = 0 
)

Write a length and string tuple into a buffer.

Parameters
valuevalue to be written.
indexbuffer index.

Definition at line 544 of file option_custom.cc.

References isc::dhcp::Option::getUniverse(), isc::dhcp::OpaqueDataTuple::LENGTH_1_BYTE, isc::dhcp::OpaqueDataTuple::LENGTH_2_BYTES, isc::dhcp::Option::V4, and isc::dhcp::OptionDataTypeUtil::writeTuple().

Referenced by getDataFieldsNum().

+ Here is the call graph for this function:

◆ writeTuple() [2/2]

void isc::dhcp::OptionCustom::writeTuple ( const OpaqueDataTuple value,
const uint32_t  index = 0 
)

Write a length and string tuple into a buffer.

Parameters
valuevalue to be written.
indexbuffer index.

Definition at line 554 of file option_custom.cc.

References isc::dhcp::OptionDataTypeUtil::writeTuple().

+ Here is the call graph for this function:

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