Kea 2.5.8
isc::dhcp::Option Class Reference

#include <option.h>

+ Inheritance diagram for isc::dhcp::Option:

Public Types

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

 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.
 

Static Public Member Functions

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

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

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

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

Definition at line 74 of file option.h.

Member Typedef Documentation

◆ Factory

typedef OptionPtr isc::dhcp::Option::Factory(Option::Universe u, uint16_t type, const OptionBuffer &buf)

a factory function prototype

Parameters
uoption universe (DHCPv4 or DHCPv6)
typeoption type
bufpointer to a buffer
Todo:
Passing a separate buffer for each option means that a copy was done. We can avoid it by passing 2 iterators.
Returns
a pointer to a created option object

Definition at line 96 of file option.h.

Member Enumeration Documentation

◆ Universe

defines option universe DHCPv4 or DHCPv6

Enumerator
V4 
V6 

Definition at line 83 of file option.h.

Constructor & Destructor Documentation

◆ Option() [1/4]

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

ctor, used for options constructed, usually during transmission

Parameters
uoption universe (DHCPv4 or DHCPv6)
typeoption type

Definition at line 39 of file option.cc.

References check().

+ Here is the call graph for this function:

◆ Option() [2/4]

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

Constructor, used for received options.

This constructor takes vector<uint8_t>& which is used in cases when content of the option will be copied and stored within option object. V4 Options follow that approach already.

Todo:
Migrate V6 options to that approach.
Parameters
uspecifies universe (V4 or V6)
typeoption type (0-255 for V4 and 0-65535 for V6)
datacontent of the option

Definition at line 44 of file option.cc.

References check().

+ Here is the call graph for this function:

◆ Option() [3/4]

isc::dhcp::Option::Option ( Universe  u,
uint16_t  type,
OptionBufferConstIter  first,
OptionBufferConstIter  last 
)

Constructor, used for received options.

This constructor is similar to the previous one, but it does not take the whole vector<uint8_t>, but rather subset of it.

Todo:
This can be templated to use different containers, not just vector. Prototype should look like this: template<typename InputIterator> Option(Universe u, uint16_t type, InputIterator first, InputIterator last);

vector<int8_t> myData; Example usage: new Option(V4, 123, myData.begin()+1, myData.end()-1) This will create DHCPv4 option of type 123 that contains data from trimmed (first and last byte removed) myData vector.

Parameters
uspecifies universe (V4 or V6)
typeoption type (0-255 for V4 and 0-65535 for V6)
firstiterator to the first element that should be copied
lastiterator to the next element after the last one to be copied.

Definition at line 49 of file option.cc.

References check().

+ Here is the call graph for this function:

◆ Option() [4/4]

isc::dhcp::Option::Option ( const Option source)

Copy constructor.

This constructor makes a deep copy of the option and all of the suboptions. It calls getOptionsCopy to deep copy suboptions.

Parameters
sourceOption to be copied.

Definition at line 55 of file option.cc.

References getOptionsCopy(), and options_.

+ Here is the call graph for this function:

◆ ~Option()

isc::dhcp::Option::~Option ( )
virtual

just to force that every option has virtual dtor

Definition at line 383 of file option.cc.

Member Function Documentation

◆ addOption()

void isc::dhcp::Option::addOption ( OptionPtr  opt)

Adds a sub-option.

Some DHCPv6 options can have suboptions. This method allows adding options within options.

Note: option is passed by value. That is very convenient as it allows downcasting from any derived classes, e.g. shared_ptr<Option6_IA> type can be passed directly, without any casts. That would not be possible with passing by reference. addOption() is expected to be used in many places. Requiring casting is not feasible.

Parameters
optshared pointer to a suboption that is going to be added.

Definition at line 331 of file option.cc.

References isc_throw, options_, and toText().

+ Here is the call graph for this function:

◆ check()

◆ clone()

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

◆ cloneInternal()

template<typename OptionType >
OptionPtr isc::dhcp::Option::cloneInternal ( ) const
inlineprotected

Copies this option and returns a pointer to the copy.

The deep copy of the option is performed by calling copy constructor of the option of a given type. Derived classes call this method in the implementations of clone methods to create a copy of the option of their type.

Template Parameters
OptionTypeType of the option of which a clone should be created.

Definition at line 497 of file option.h.

Referenced by isc::dhcp::OptionInt< T >::clone(), and isc::dhcp::OptionIntArray< T >::clone().

◆ create() [1/2]

OptionPtr isc::dhcp::Option::create ( Universe  u,
uint16_t  type 
)
static

Factory function creating an instance of the Option.

This function should be used to create an instance of the DHCP option within a hooks library in cases when the library may be unloaded before the object is destroyed. This ensures that the ownership of the object by the Kea process is retained.

Parameters
uspecifies universe (V4 or V6)
typeoption type (0-255 for V4 and 0-65535 for V6)
Returns
Pointer to the Option instance.

Definition at line 63 of file option.cc.

◆ create() [2/2]

OptionPtr isc::dhcp::Option::create ( Universe  u,
uint16_t  type,
const OptionBuffer data 
)
static

Factory function creating an instance of the Option.

This function should be used to create an instance of the DHCP option within a hooks library in cases when the library may be unloaded before the object is destroyed. This ensures that the ownership of the object by the Kea process is retained.

Parameters
uspecifies universe (V4 or V6)
typeoption type (0-255 for V4 and 0-65535 for V6)
datacontent of the option
Returns
Pointer to the Option instance.

Definition at line 68 of file option.cc.

◆ delOption()

bool isc::dhcp::Option::delOption ( uint16_t  type)

Attempts to delete first suboption of requested type.

Parameters
typeType of option to be deleted.
Returns
true if option was deleted, false if no such option existed

Definition at line 219 of file option.cc.

References options_.

◆ equals() [1/2]

bool isc::dhcp::Option::equals ( const Option other) const
virtual

Checks if two options are equal.

Equality verifies option type and option content. Care should be taken when using this method. Implementation for derived classes should be provided when this method is expected to be used. It is safe in general, as the first check (different types) will detect differences between base Option and derived objects.

Parameters
otherInstance of the option to compare to.
Returns
true if options are equal, false otherwise.

Definition at line 378 of file option.cc.

References getData(), and getType().

+ Here is the call graph for this function:

◆ equals() [2/2]

bool isc::dhcp::Option::equals ( const OptionPtr other) const

Checks if options are equal.

This method calls a virtual equals function to compare objects. This method is not meant to be overridden in the derived classes. Instead, the other equals function must be overridden.

Parameters
otherPointer to the option to compare this option to.
Returns
true if both options are equal, false otherwise.

Definition at line 374 of file option.cc.

References equals().

Referenced by equals().

+ Here is the call graph for this function:

◆ factory() [1/2]

static OptionPtr isc::dhcp::Option::factory ( Option::Universe  u,
uint16_t  type 
)
inlinestatic

Factory function to create instance of option.

Factory method creates instance of specified option. The option to be created has to have corresponding factory function registered with LibDHCP::OptionFactoryRegister. This method creates empty OptionBuffer object. Use this factory function if it is not needed to pass custom buffer.

Parameters
uuniverse of the option (V4 or V6)
typeoption-type
Returns
instance of option.
Exceptions
isc::InvalidOperationif there is no factory function registered for specified option type.

Definition at line 131 of file option.h.

References factory().

+ Here is the call graph for this function:

◆ factory() [2/2]

OptionPtr isc::dhcp::Option::factory ( Option::Universe  u,
uint16_t  type,
const OptionBuffer buf 
)
static

Factory function to create instance of option.

Factory method creates instance of specified option. The option to be created has to have corresponding factory function registered with LibDHCP::OptionFactoryRegister.

Parameters
uuniverse of the option (V4 or V6)
typeoption-type
bufoption-buffer
Returns
instance of option.
Exceptions
isc::InvalidOperationif there is no factory function registered for specified option type.

Definition at line 33 of file option.cc.

References isc::dhcp::LibDHCP::optionFactory().

Referenced by isc::perfdhcp::TestControl::createMessageFromAck(), factory(), isc::perfdhcp::TestControl::sendDiscover4(), isc::perfdhcp::TestControl::sendRequest4(), isc::perfdhcp::TestControl::sendRequest6(), and isc::perfdhcp::TestControl::sendSolicit6().

+ Here is the call graph for this function:

◆ getData()

virtual const OptionBuffer & isc::dhcp::Option::getData ( ) const
inlinevirtual

Returns pointer to actual data.

Returns
pointer to actual data (or reference to an empty vector if there is no data)

Definition at line 317 of file option.h.

References data_.

Referenced by isc::dhcp::OptionCustom::OptionCustom(), equals(), isc::dhcp::OptionString::getValue(), isc::dhcp::OptionCustom::initialize(), isc::dhcp::OptionString::len(), and isc::dhcp::OptionString::pack().

◆ getEncapsulatedSpace()

std::string isc::dhcp::Option::getEncapsulatedSpace ( ) const
inline

Returns the name of the option space encapsulated by this option.

Returns
name of the option space encapsulated by this option.

Definition at line 442 of file option.h.

References encapsulated_space_.

Referenced by unpackOptions().

◆ getHeaderLen()

◆ getMutableOptions()

OptionCollection & isc::dhcp::Option::getMutableOptions ( )
inline

Returns all encapsulated options.

Warning
This function returns a reference to the container holding encapsulated options, which is valid as long as the object which returned it exists. Any changes to the container will be reflected in the option content.

Definition at line 357 of file option.h.

References options_.

◆ getOption()

OptionPtr isc::dhcp::Option::getOption ( uint16_t  type) const

Returns shared_ptr to suboption of specific type.

Parameters
typetype of requested suboption
Returns
shared_ptr to requested suboption

Definition at line 199 of file option.cc.

References options_.

◆ getOptions()

const OptionCollection & isc::dhcp::Option::getOptions ( ) const
inline

Returns all encapsulated options.

Warning
This function returns a reference to the container holding encapsulated options, which is valid as long as the object which returned it exists.

Definition at line 347 of file option.h.

References options_.

Referenced by isc::dhcp::Dhcpv6Srv::processConfirm().

◆ getOptionsCopy()

void isc::dhcp::Option::getOptionsCopy ( OptionCollection options_copy) const

Performs deep copy of suboptions.

This method calls clone method to deep copy each option.

Parameters
[out]options_copyContainer where copied options are stored.

Definition at line 208 of file option.cc.

References isc::data::copy(), and options_.

Referenced by Option(), and operator=().

+ Here is the call graph for this function:

◆ getType()

◆ getUint16()

uint16_t isc::dhcp::Option::getUint16 ( ) const

Returns content of first word.

Exceptions
isc::OutOfRangeThrown if the option has a length less than 2.
Returns
uint16_t value stored on first two bytes

Definition at line 349 of file option.cc.

References data_, and isc::util::readUint16().

+ Here is the call graph for this function:

◆ getUint32()

uint32_t isc::dhcp::Option::getUint32 ( ) const

Returns content of first double word.

Exceptions
isc::OutOfRangeThrown if the option has a length less than 4.
Returns
uint32_t value stored on first four bytes

Definition at line 354 of file option.cc.

References data_, and isc::util::readUint32().

+ Here is the call graph for this function:

◆ getUint8()

uint8_t isc::dhcp::Option::getUint8 ( ) const

Returns content of first byte.

Exceptions
isc::OutOfRangeThrown if the option has a length of 0.
Returns
value of the first byte

Definition at line 341 of file option.cc.

References data_, isc_throw, and type_.

◆ getUniverse()

◆ headerToText()

std::string isc::dhcp::Option::headerToText ( const int  indent = 0,
const std::string &  type_name = "" 
) const
protected

Returns option header in the textual format.

This protected method should be called by the derived classes in their respective toText implementations.

Parameters
indentNumber of spaces to insert before the text.
type_nameOption type name. If empty, the option name is omitted.
Returns
Option header in the textual format.

Definition at line 288 of file option.cc.

References getHeaderLen(), getUniverse(), len(), type_, and V4.

Referenced by toText(), isc::dhcp::Option4AddrLst::toText(), isc::dhcp::Option6AddrLst::toText(), isc::dhcp::Option6IA::toText(), isc::dhcp::Option6IAAddr::toText(), isc::dhcp::Option6IAPrefix::toText(), isc::dhcp::Option6PDExclude::toText(), isc::dhcp::Option6StatusCode::toText(), isc::dhcp::Option4SlpServiceScope::toText(), isc::dhcp::OptionCustom::toText(), isc::dhcp::OptionInt< T >::toText(), isc::dhcp::OptionIntArray< T >::toText(), isc::dhcp::OptionString::toText(), and isc::dhcp::OptionVendor::toText().

+ Here is the call graph for this function:

◆ len()

◆ operator=()

Option & isc::dhcp::Option::operator= ( const Option rhs)

Assignment operator.

The assignment operator performs a deep copy of the option and its suboptions. It calls getOptionsCopy to deep copy suboptions.

Parameters
rhsOption to be assigned.

Definition at line 73 of file option.cc.

References data_, encapsulated_space_, getOptionsCopy(), options_, type_, and universe_.

Referenced by isc::dhcp::Option4ClientFqdn::operator=(), and isc::dhcp::Option6ClientFqdn::operator=().

+ Here is the call graph for this function:

◆ pack()

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

Writes option in wire-format to a buffer.

Writes option in wire-format to buffer, returns pointer to first unused byte after stored option (that is useful for writing options one after another).

Parameters
bufpointer to a buffer
checkflag which indicates if checking the option length is required (used only in V4)
Exceptions
BadValueUniverse of the option is neither V4 nor V6.

Reimplemented in isc::dhcp::Option4AddrLst, isc::dhcp::Option4ClientFqdn, isc::dhcp::Option6AddrLst, isc::dhcp::Option6Auth, isc::dhcp::Option6ClientFqdn, isc::dhcp::Option6IA, isc::dhcp::Option6IAAddr, isc::dhcp::Option6IAPrefix, isc::dhcp::Option6PDExclude, isc::dhcp::Option6StatusCode, isc::dhcp::Option4SlpServiceScope, isc::dhcp::OptionCustom, isc::dhcp::OptionInt< T >, isc::dhcp::OptionIntArray< T >, isc::dhcp::OptionOpaqueDataTuples, isc::dhcp::OptionString, isc::dhcp::OptionVendor, isc::dhcp::OptionVendorClass, isc::dhcp::Option6Dnr, isc::dhcp::Option4Dnr, and isc::dhcp::OptionClasslessStaticRoute.

Definition at line 107 of file option.cc.

References check(), data_, packHeader(), packOptions(), and isc::util::OutputBuffer::writeData().

Referenced by toBinary().

+ Here is the call graph for this function:

◆ packHeader()

void isc::dhcp::Option::packHeader ( isc::util::OutputBuffer buf,
bool  check = true 
) const
protected

Store option's header in a buffer.

This method writes option's header into a buffer in the on-wire format. The universe set for the particular option is used to determine whether option code and length are stored as 2-byte (for DHCPv6) or single-byte (for DHCPv4) values. For DHCPv4 options, this method checks if the length does not exceed 255 bytes and throws exception if it does. This method is used by derived classes to pack option's header into a buffer. This method should not be called directly by other classes.

Parameters
[out]bufoutput buffer.
checkif set to false, allows options larger than 255 for v4

Definition at line 119 of file option.cc.

References check(), getHeaderLen(), isc_throw, len(), type_, universe_, V4, isc::util::OutputBuffer::writeUint16(), and isc::util::OutputBuffer::writeUint8().

Referenced by pack(), isc::dhcp::Option4ClientFqdn::pack(), isc::dhcp::Option6ClientFqdn::pack(), isc::dhcp::Option6PDExclude::pack(), isc::dhcp::Option6StatusCode::pack(), isc::dhcp::Option4SlpServiceScope::pack(), isc::dhcp::OptionCustom::pack(), isc::dhcp::OptionInt< T >::pack(), isc::dhcp::OptionIntArray< T >::pack(), isc::dhcp::OptionOpaqueDataTuples::pack(), isc::dhcp::OptionString::pack(), isc::dhcp::OptionVendor::pack(), isc::dhcp::OptionVendorClass::pack(), isc::dhcp::Option6Dnr::pack(), isc::dhcp::Option4Dnr::pack(), and isc::dhcp::OptionClasslessStaticRoute::pack().

+ Here is the call graph for this function:

◆ packOptions()

void isc::dhcp::Option::packOptions ( isc::util::OutputBuffer buf,
bool  check = true 
) const
protected

Store sub options in a buffer.

This method stores all sub-options defined for a particular option in a on-wire format in output buffer provided. This function is called by pack function in this class or derived classes that override pack.

Parameters
[out]bufoutput buffer.
checkif set to false, allows options larger than 255 for v4
Todo:
The set of exceptions thrown by this function depend on exceptions thrown by pack methods invoked on objects representing sub options. We should consider whether to aggregate those into one exception which can be documented here.

Definition at line 136 of file option.cc.

References check(), isc_throw, options_, isc::dhcp::LibDHCP::packOptions4(), isc::dhcp::LibDHCP::packOptions6(), universe_, V4, and V6.

Referenced by pack(), isc::dhcp::Option6IA::pack(), isc::dhcp::Option6IAAddr::pack(), isc::dhcp::Option6IAPrefix::pack(), isc::dhcp::OptionCustom::pack(), isc::dhcp::OptionInt< T >::pack(), and isc::dhcp::OptionVendor::pack().

+ Here is the call graph for this function:

◆ setData()

template<typename InputIterator >
void isc::dhcp::Option::setData ( InputIterator  first,
InputIterator  last 
)
inline

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.
Template Parameters
InputIteratortype of the iterator representing the limits of the buffer to be assigned to a data_ buffer.

Definition at line 427 of file option.h.

References data_.

Referenced by isc::dhcp::OptionString::setValue(), unpack(), isc::dhcp::OptionString::unpack(), isc::dhcp::Option4Dnr::unpack(), isc::dhcp::Option6Dnr::unpack(), isc::dhcp::Option4ClientFqdn::unpack(), and isc::dhcp::Option6ClientFqdn::unpack().

◆ setEncapsulatedSpace()

void isc::dhcp::Option::setEncapsulatedSpace ( const std::string &  encapsulated_space)
inline

Sets the name of the option space encapsulated by this option.

Parameters
encapsulated_spacename of the option space encapsulated by this option.

Definition at line 435 of file option.h.

References encapsulated_space_.

Referenced by isc::dhcp::Option6IA::Option6IA(), isc::dhcp::Option6IAAddr::Option6IAAddr(), isc::dhcp::Option6IAPrefix::Option6IAPrefix(), isc::dhcp::OptionCustom::OptionCustom(), and isc::dhcp::OptionInt< T >::OptionInt().

◆ setUint16()

void isc::dhcp::Option::setUint16 ( uint16_t  value)

Sets content of this option to a single uint16 value.

Option it resized appropriately (to length of 2 octets).

Parameters
valuevalue to be set

Definition at line 364 of file option.cc.

References data_, and isc::util::writeUint16().

+ Here is the call graph for this function:

◆ setUint32()

void isc::dhcp::Option::setUint32 ( uint32_t  value)

Sets content of this option to a single uint32 value.

Option it resized appropriately (to length of 4 octets).

Parameters
valuevalue to be set

Definition at line 369 of file option.cc.

References data_, and isc::util::writeUint32().

+ Here is the call graph for this function:

◆ setUint8()

void isc::dhcp::Option::setUint8 ( uint8_t  value)

Sets content of this option to a single uint8 value.

Option it resized appropriately (to length of 1 octet).

Parameters
valuevalue to be set

Definition at line 359 of file option.cc.

References data_.

◆ suboptionsToText()

std::string isc::dhcp::Option::suboptionsToText ( const int  indent = 0) const
protected

Returns collection of suboptions in the textual format.

This protected method should be called by the derived classes in their respective toText implementations to append the suboptions held by this option. Note that there are some option types which don't have suboptions because they contain variable length fields. For such options this method is not called.

Parameters
indentNumber of spaces to insert before the text.

Definition at line 307 of file option.cc.

References options_.

Referenced by toText(), isc::dhcp::Option6IA::toText(), isc::dhcp::Option6IAAddr::toText(), isc::dhcp::Option6IAPrefix::toText(), isc::dhcp::OptionCustom::toText(), isc::dhcp::OptionInt< T >::toText(), and isc::dhcp::OptionVendor::toText().

◆ toBinary()

std::vector< uint8_t > isc::dhcp::Option::toBinary ( const bool  include_header = false) const
virtual

Returns binary representation of the option.

Parameters
include_headerBoolean flag which indicates if the output should also contain header fields. The default is that it shouldn't include header fields.
Returns
Vector holding binary representation of the option.

Definition at line 253 of file option.cc.

References isc::util::OutputBuffer::getData(), getHeaderLen(), isc::util::OutputBuffer::getLength(), getType(), isc_throw, len(), and pack().

Referenced by toHexString().

+ Here is the call graph for this function:

◆ toHexString()

std::string isc::dhcp::Option::toHexString ( const bool  include_header = false) const
virtual

Returns string containing hexadecimal representation of option.

Parameters
include_headerBoolean flag which indicates if the output should also contain header fields. The default is that it shouldn't include header fields.
Returns
String containing hexadecimal representation of the option.

Definition at line 274 of file option.cc.

References isc::util::encode::encodeHex(), and toBinary().

+ Here is the call graph for this function:

◆ toString()

std::string isc::dhcp::Option::toString ( ) const
virtual

Returns string representation of the value.

This is terse representation used in cases where client classification refers to a specific option.

Returns
string that represents the value of the option.
Todo:
: Implement actual conversion in derived classes.

Reimplemented in isc::dhcp::OptionString.

Definition at line 247 of file option.cc.

References toText().

+ Here is the call graph for this function:

◆ toText()

◆ unpack()

◆ unpackOptions()

void isc::dhcp::Option::unpackOptions ( const OptionBuffer buf)
protected

Builds a collection of sub options from the buffer.

This method parses the provided buffer and builds a collection of objects representing sub options. This function may throw different exceptions when option assembly fails.

Parameters
bufbuffer to be parsed.
Todo:
The set of exceptions thrown by this function depend on exceptions thrown by unpack methods invoked on objects representing sub options. We should consider whether to aggregate those into one exception which can be documented here.

Definition at line 155 of file option.cc.

References isc::dhcp::DHO_VENDOR_ENCAPSULATED_OPTIONS, getEncapsulatedSpace(), getType(), isc_throw, options_, universe_, isc::dhcp::LibDHCP::unpackOptions4(), isc::dhcp::LibDHCP::unpackOptions6(), V4, and V6.

Referenced by isc::dhcp::Option6IA::unpack(), isc::dhcp::Option6IAAddr::unpack(), isc::dhcp::Option6IAPrefix::unpack(), and isc::dhcp::OptionInt< T >::unpack().

+ Here is the call graph for this function:

◆ valid()

bool isc::dhcp::Option::valid ( ) const
virtual

returns if option is valid (e.g.

option may be truncated)

Returns
true, if option is valid

Reimplemented in isc::perfdhcp::LocalizedOption.

Definition at line 190 of file option.cc.

References universe_, V4, and V6.

Referenced by isc::dhcp::Option6IAAddr::setValid().

Member Data Documentation

◆ data_

OptionBuffer isc::dhcp::Option::data_
protected

◆ encapsulated_space_

std::string isc::dhcp::Option::encapsulated_space_
protected

Name of the option space being encapsulated by this option.

Definition at line 599 of file option.h.

Referenced by getEncapsulatedSpace(), operator=(), and setEncapsulatedSpace().

◆ lenient_parsing_

bool isc::dhcp::Option::lenient_parsing_
static

Governs whether options should be parsed less strictly.

Populated on configuration commit.

When enabled:

  • Tuples are parsed as length-value pairs as usual, but if a length surpasses the total option length, the rest of the option buffer is parsed as the next value. This more commonly affects DHCPv6's vendor class option (16), but it also affects custom options that are defined with tuple fields.

Definition at line 483 of file option.h.

Referenced by isc::dhcp::SrvConfig::configureLowerLevelLibraries(), isc::dhcp::Option4ClientFqdnImpl::parseWireData(), isc::dhcp::Option6ClientFqdnImpl::parseWireData(), and isc::dhcp::OpaqueDataTuple::unpack().

◆ OPTION4_HDR_LEN

const size_t isc::dhcp::Option::OPTION4_HDR_LEN = 2
static

length of the usual DHCPv4 option header (there are exceptions)

Definition at line 77 of file option.h.

Referenced by getHeaderLen(), isc::dhcp::OptionInt< T >::len(), isc::dhcp::OptionIntArray< T >::len(), and isc::dhcp::Option4Dnr::len().

◆ OPTION6_HDR_LEN

◆ options_

◆ type_

◆ universe_


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