Kea 2.7.5
|
#include <option.h>
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 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) | |
virtual uint16_t | len () const |
Returns length of the complete option (data length + DHCPv4/DHCPv6 option header) | |
Option & | operator= (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) | |
typedef OptionPtr isc::dhcp::Option::Factory(Option::Universe u, uint16_t type, const OptionBuffer &buf) |
a factory function prototype
u | option universe (DHCPv4 or DHCPv6) |
type | option type |
buf | pointer to a buffer |
isc::dhcp::Option::Option | ( | Universe | u, |
uint16_t | type ) |
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.
u | specifies universe (V4 or V6) |
type | option type (0-255 for V4 and 0-65535 for V6) |
data | content of the option |
Definition at line 44 of file option.cc.
References check().
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.
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.
u | specifies universe (V4 or V6) |
type | option type (0-255 for V4 and 0-65535 for V6) |
first | iterator to the first element that should be copied |
last | iterator to the next element after the last one to be copied. |
Definition at line 49 of file option.cc.
References check().
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.
source | Option to be copied. |
Definition at line 55 of file option.cc.
References options_.
|
virtual |
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.
opt | shared pointer to a suboption that is going to be added. |
Definition at line 337 of file option.cc.
References isc_throw, options_, and toText().
|
protected |
A protected method used for option correctness.
It is used in constructors. In there are any problems detected (like specifying type > 255 for DHCPv4 option), it will throw BadValue or OutOfRange exceptions.
Definition at line 90 of file option.cc.
References isc_throw, type_, universe_, V4, and V6.
Referenced by Option(), Option(), Option(), pack(), isc::dhcp::Option4AddrLst::pack(), isc::dhcp::Option4ClientFqdn::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(), isc::dhcp::OptionClasslessStaticRoute::pack(), packHeader(), and packOptions().
|
virtual |
Copies this option and returns a pointer to the copy.
This function must be overridden in the derived classes to make a copy of the derived type. The simplest way to do it is by calling cloneInternal function with an appropriate template parameter.
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::Option4Dnr, isc::dhcp::Option6Dnr, and isc::dhcp::OptionClasslessStaticRoute.
|
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.
OptionType | Type of the option of which a clone should be created. |
Definition at line 504 of file option.h.
Referenced by isc::dhcp::OptionInt< T >::clone(), and isc::dhcp::OptionIntArray< T >::clone().
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.
u | specifies universe (V4 or V6) |
type | option type (0-255 for V4 and 0-65535 for V6) |
Option
instance.
|
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.
u | specifies universe (V4 or V6) |
type | option type (0-255 for V4 and 0-65535 for V6) |
data | content of the option |
Option
instance. bool isc::dhcp::Option::delOption | ( | uint16_t | type | ) |
|
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.
other | Instance of the option to compare to. |
Definition at line 384 of file option.cc.
References getData(), and getType().
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.
other | Pointer to the option to compare this option to. |
Definition at line 380 of file option.cc.
References equals().
Referenced by equals().
|
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.
u | universe of the option (V4 or V6) |
type | option-type |
isc::InvalidOperation | if there is no factory function registered for specified option type. |
Definition at line 138 of file option.h.
References factory().
|
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.
u | universe of the option (V4 or V6) |
type | option-type |
buf | option-buffer |
isc::InvalidOperation | if 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().
|
inlinevirtual |
Returns pointer to actual data.
Definition at line 324 of file option.h.
References data_.
Referenced by isc::dhcp::OptionCustom::OptionCustom(), isc::dhcp::OptionCustom::OptionCustom(), equals(), isc::dhcp::OptionString::getValue(), isc::dhcp::OptionCustom::initialize(), isc::dhcp::OptionString::len(), and isc::dhcp::OptionString::pack().
|
inline |
Returns the name of the option space encapsulated by this option.
Definition at line 449 of file option.h.
References encapsulated_space_.
Referenced by unpackOptions().
|
virtual |
Returns length of header (2 for v4, 4 for v6)
Definition at line 327 of file option.cc.
References OPTION4_HDR_LEN, OPTION6_HDR_LEN, universe_, V4, and V6.
Referenced by headerToText(), len(), isc::dhcp::Option4AddrLst::len(), isc::dhcp::Option4ClientFqdn::len(), isc::dhcp::Option6ClientFqdn::len(), isc::dhcp::Option6PDExclude::len(), isc::dhcp::Option6StatusCode::len(), isc::dhcp::Option4SlpServiceScope::len(), isc::dhcp::OptionCustom::len(), isc::dhcp::OptionOpaqueDataTuples::len(), isc::dhcp::OptionString::len(), isc::dhcp::OptionVendor::len(), isc::dhcp::OptionVendorClass::len(), isc::dhcp::OptionClasslessStaticRoute::len(), isc::dhcp::Option4AddrLst::pack(), isc::dhcp::Option6AddrLst::pack(), isc::dhcp::Option6IAAddr::pack(), isc::dhcp::Option6IAPrefix::pack(), packHeader(), toBinary(), isc::dhcp::OptionOpaqueDataTuples::toText(), isc::dhcp::OptionVendorClass::toText(), isc::dhcp::Option4Dnr::toText(), isc::dhcp::Option6Dnr::toText(), isc::dhcp::OptionClasslessStaticRoute::toText(), and isc::dhcp::OptionVendorClass::unpack().
|
inline |
Returns all encapsulated options.
Definition at line 364 of file option.h.
References options_.
OptionPtr isc::dhcp::Option::getOption | ( | uint16_t | type | ) | const |
|
inline |
void isc::dhcp::Option::getOptionsCopy | ( | OptionCollection & | options_copy | ) | const |
Performs deep copy of suboptions.
This method calls clone method to deep copy each option.
[out] | options_copy | Container where copied options are stored. |
Definition at line 208 of file option.cc.
References isc::data::copy(), and options_.
|
inline |
Returns option type (0-255 for DHCPv4, 0-65535 for DHCPv6)
Definition at line 300 of file option.h.
References type_.
Referenced by equals(), isc::dhcp::OptionString::setValue(), toBinary(), isc::dhcp::Option6IA::toText(), isc::dhcp::OptionOpaqueDataTuples::toText(), isc::dhcp::OptionVendorClass::toText(), isc::dhcp::OptionInt< T >::unpack(), isc::dhcp::OptionIntArray< T >::unpack(), isc::dhcp::OptionString::unpack(), and unpackOptions().
uint16_t isc::dhcp::Option::getUint16 | ( | ) | const |
Returns content of first word.
isc::OutOfRange | Thrown if the option has a length less than 2. |
Definition at line 355 of file option.cc.
References data_, and isc::util::readUint16().
uint32_t isc::dhcp::Option::getUint32 | ( | ) | const |
Returns content of first double word.
isc::OutOfRange | Thrown if the option has a length less than 4. |
Definition at line 360 of file option.cc.
References data_, and isc::util::readUint32().
uint8_t isc::dhcp::Option::getUint8 | ( | ) | const |
|
inline |
returns option universe (V4 or V6)
Definition at line 240 of file option.h.
References universe_.
Referenced by isc::dhcp::OptionCustom::addArrayDataField(), isc::dhcp::OptionVendorClass::addTuple(), headerToText(), isc::dhcp::OptionInt< T >::len(), isc::dhcp::OptionIntArray< T >::len(), isc::dhcp::OptionVendorClass::len(), isc::dhcp::OptionVendorClass::pack(), isc::dhcp::OptionCustom::readTuple(), isc::dhcp::OptionVendorClass::setTuple(), isc::dhcp::OptionVendor::toText(), isc::dhcp::OptionVendorClass::toText(), isc::dhcp::OptionVendorClass::unpack(), and isc::dhcp::OptionCustom::writeTuple().
|
protected |
Returns option header in the textual format.
This protected method should be called by the derived classes in their respective toText
implementations.
indent | Number of spaces to insert before the text. |
type_name | Option type name. If empty, the option name is omitted. |
Definition at line 294 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().
|
virtual |
Returns length of the complete option (data length + DHCPv4/DHCPv6 option header)
Reimplemented in isc::dhcp::Option4AddrLst, isc::dhcp::Option4ClientFqdn, isc::dhcp::Option6AddrLst, 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::Option4Dnr, isc::dhcp::Option6Dnr, and isc::dhcp::OptionClasslessStaticRoute.
Definition at line 171 of file option.cc.
References data_, getHeaderLen(), and options_.
Referenced by headerToText(), packHeader(), and toBinary().
Assignment operator.
The assignment operator performs a deep copy of the option and its suboptions. It calls getOptionsCopy to deep copy suboptions.
rhs | Option to be assigned. |
Definition at line 73 of file option.cc.
References data_, encapsulated_space_, options_, type_, and universe_.
Referenced by isc::dhcp::Option4ClientFqdn::operator=(), and isc::dhcp::Option6ClientFqdn::operator=().
|
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).
buf | pointer to a buffer |
check | flag which indicates if checking the option length is required (used only in V4) |
BadValue | Universe 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(), and packOptions().
Referenced by toBinary().
|
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.
[out] | buf | output buffer. |
check | if 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_, and V4.
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().
|
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.
[out] | buf | output buffer. |
check | if set to false, allows options larger than 255 for v4 |
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().
|
inline |
Sets content of this option from buffer.
Option will be resized to length of buffer.
first | iterator pointing to beginning of buffer to copy. |
last | iterator pointing to end of buffer to copy. |
InputIterator | type of the iterator representing the limits of the buffer to be assigned to a data_ buffer. |
Definition at line 434 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().
|
inline |
Sets the name of the option space encapsulated by this option.
encapsulated_space | name of the option space encapsulated by this option. |
Definition at line 442 of file option.h.
References encapsulated_space_.
Referenced by isc::dhcp::Option6IA::Option6IA(), isc::dhcp::Option6IA::Option6IA(), isc::dhcp::Option6IAAddr::Option6IAAddr(), isc::dhcp::Option6IAAddr::Option6IAAddr(), isc::dhcp::Option6IAPrefix::Option6IAPrefix(), isc::dhcp::Option6IAPrefix::Option6IAPrefix(), isc::dhcp::OptionCustom::OptionCustom(), isc::dhcp::OptionCustom::OptionCustom(), isc::dhcp::OptionCustom::OptionCustom(), isc::dhcp::OptionInt< T >::OptionInt(), and isc::dhcp::OptionInt< T >::OptionInt().
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).
value | value to be set |
Definition at line 370 of file option.cc.
References data_, and isc::util::writeUint16().
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).
value | value to be set |
Definition at line 375 of file option.cc.
References data_, and isc::util::writeUint32().
void isc::dhcp::Option::setUint8 | ( | uint8_t | value | ) |
|
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.
indent | Number of spaces to insert before the text. |
Definition at line 313 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().
|
virtual |
Returns binary representation of the option.
include_header | Boolean flag which indicates if the output should also contain header fields. The default is that it shouldn't include header fields. |
Definition at line 259 of file option.cc.
References getHeaderLen(), getType(), isc_throw, len(), and pack().
Referenced by toHexString().
|
virtual |
Returns string containing hexadecimal representation of option.
include_header | Boolean flag which indicates if the output should also contain header fields. The default is that it shouldn't include header fields. |
Definition at line 280 of file option.cc.
References isc::util::encode::encodeHex(), and toBinary().
|
virtual |
Returns string representation of the value.
This is terse representation used in cases where client classification refers to a specific option.
Reimplemented in isc::dhcp::OptionString.
Definition at line 253 of file option.cc.
References toText().
|
virtual |
Returns string representation of the option.
indent | number of spaces before printing text |
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::Option4Dnr, isc::dhcp::Option6Dnr, and isc::dhcp::OptionClasslessStaticRoute.
Definition at line 228 of file option.cc.
References data_, headerToText(), isc::util::str::isPrintable(), and suboptionsToText().
Referenced by addOption(), and toString().
|
virtual |
Parses received buffer.
begin | iterator to first byte of option data |
end | iterator to end of option data (first byte after option end) |
Reimplemented in isc::dhcp::Option6AddrLst, isc::dhcp::Option6Auth, 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::Option4Dnr, isc::dhcp::Option6Dnr, isc::dhcp::OptionClasslessStaticRoute, isc::dhcp::Option4ClientFqdn, and isc::dhcp::Option6ClientFqdn.
Definition at line 149 of file option.cc.
References setData().
|
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.
buf | buffer to be parsed. |
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().
|
virtual |
returns if option is valid (e.g.
option may be truncated)
Reimplemented in isc::perfdhcp::LocalizedOption.
Definition at line 190 of file option.cc.
References universe_, V4, and V6.
Referenced by isc::dhcp::Option6IAAddr::setValid().
|
protected |
contains content of this data
Definition at line 600 of file option.h.
Referenced by isc::perfdhcp::LocalizedOption::LocalizedOption(), getData(), getUint16(), getUint32(), getUint8(), len(), operator=(), pack(), setData(), setUint16(), setUint32(), setUint8(), and toText().
|
protected |
Name of the option space being encapsulated by this option.
Definition at line 606 of file option.h.
Referenced by getEncapsulatedSpace(), operator=(), and setEncapsulatedSpace().
|
static |
Governs whether options should be parsed less strictly.
Populated on configuration commit.
When enabled:
Definition at line 490 of file option.h.
Referenced by isc::dhcp::SrvConfig::configureLowerLevelLibraries(), isc::dhcp::Option4ClientFqdnImpl::parseWireData(), isc::dhcp::Option6ClientFqdnImpl::parseWireData(), and isc::dhcp::OpaqueDataTuple::unpack().
|
static |
length of the usual DHCPv4 option header (there are exceptions)
Definition at line 84 of file option.h.
Referenced by getHeaderLen(), isc::dhcp::OptionInt< T >::len(), isc::dhcp::OptionIntArray< T >::len(), isc::dhcp::Option4Dnr::len(), and isc::dhcp::Dhcpv4Srv::recoverStashedAgentOption().
|
static |
length of any DHCPv6 option header
Definition at line 87 of file option.h.
Referenced by getHeaderLen(), isc::dhcp::Pkt6::getRelayOverhead(), isc::dhcp::Option6AddrLst::len(), isc::dhcp::Option6IA::len(), isc::dhcp::Option6IAAddr::len(), isc::dhcp::Option6IAPrefix::len(), isc::dhcp::OptionInt< T >::len(), isc::dhcp::OptionIntArray< T >::len(), isc::dhcp::Option6Dnr::len(), and isc::dhcp::Option6IA::pack().
|
protected |
collection for storing suboptions
Definition at line 603 of file option.h.
Referenced by Option(), addOption(), delOption(), getMutableOptions(), getOption(), getOptions(), getOptionsCopy(), len(), isc::dhcp::Option6IA::len(), isc::dhcp::Option6IAAddr::len(), isc::dhcp::Option6IAPrefix::len(), isc::dhcp::OptionCustom::len(), isc::dhcp::OptionInt< T >::len(), isc::dhcp::OptionIntArray< T >::len(), isc::dhcp::OptionVendor::len(), operator=(), isc::dhcp::OptionVendor::pack(), packOptions(), suboptionsToText(), isc::dhcp::OptionVendor::toText(), isc::dhcp::OptionVendor::unpack(), and unpackOptions().
|
protected |
option type (0-255 for DHCPv4, 0-65535 for DHCPv6)
Definition at line 597 of file option.h.
Referenced by isc::perfdhcp::LocalizedOption::LocalizedOption(), isc::dhcp::Option4AddrLst::Option4AddrLst(), check(), getType(), getUint8(), headerToText(), operator=(), isc::dhcp::Option4AddrLst::pack(), isc::dhcp::Option6AddrLst::pack(), isc::dhcp::Option6Auth::pack(), isc::dhcp::Option6IA::pack(), isc::dhcp::Option6IAAddr::pack(), isc::dhcp::Option6IAPrefix::pack(), isc::dhcp::Option6Auth::packHashInput(), packHeader(), isc::dhcp::Option4ClientFqdn::toText(), isc::dhcp::Option6ClientFqdn::toText(), isc::dhcp::Option4Dnr::toText(), isc::dhcp::Option6Dnr::toText(), isc::dhcp::OptionClasslessStaticRoute::toText(), isc::dhcp::Option6AddrLst::unpack(), isc::dhcp::Option6Auth::unpack(), isc::dhcp::Option6IA::unpack(), isc::dhcp::Option6IAAddr::unpack(), isc::dhcp::Option6IAPrefix::unpack(), and isc::dhcp::OptionClasslessStaticRoute::unpack().
|
protected |
option universe (V4 or V6)
Definition at line 594 of file option.h.
Referenced by isc::perfdhcp::LocalizedOption::LocalizedOption(), check(), getHeaderLen(), getUniverse(), isc::dhcp::OptionVendor::len(), operator=(), isc::dhcp::OptionVendor::pack(), packHeader(), packOptions(), isc::dhcp::OptionVendor::unpack(), unpackOptions(), and valid().