Kea  1.5.0
isc::dhcp::OptionDefinition Class Reference

Base class representing a DHCP option definition. More...

#include <option_definition.h>

+ Inheritance diagram for isc::dhcp::OptionDefinition:

Public Types

typedef std::vector< OptionDataTypeRecordFieldsCollection
 List of fields within the record. More...
 
typedef std::vector< OptionDataType >::const_iterator RecordFieldsConstIter
 Const iterator for record data fields. More...
 

Public Member Functions

 OptionDefinition (const std::string &name, const uint16_t code, const OptionDataType type, const bool array_type=false)
 Constructor. More...
 
 OptionDefinition (const std::string &name, const uint16_t code, const OptionDataType type, const char *encapsulated_space)
 Constructor. More...
 
 OptionDefinition (const std::string &name, const uint16_t code, const std::string &type, const bool array_type=false)
 Constructor. More...
 
 OptionDefinition (const std::string &name, const uint16_t code, const std::string &type, const char *encapsulated_space)
 Constructor. More...
 
- Public Member Functions inherited from isc::data::StampedElement
 StampedElement ()
 Constructor. More...
 
boost::posix_time::ptime getModificationTime () const
 Returns timestamp. More...
 
void setModificationTime (const boost::posix_time::ptime &timestamp)
 Sets timestamp to the explicitly provided value. More...
 
void updateModificationTime ()
 Sets timestmp to the current time. More...
 

Comparison functions and operators.

bool equals (const OptionDefinition &other) const
 Check if option definition is equal to other. More...
 
bool operator== (const OptionDefinition &other) const
 Equality operator. More...
 
bool operator!= (const OptionDefinition &other) const
 Inequality operator. More...
 
void addRecordField (const std::string &data_type_name)
 Adds data field to the record. More...
 
void addRecordField (const OptionDataType data_type)
 Adds data field to the record. More...
 
bool getArrayType () const
 Return array type indicator. More...
 
uint16_t getCode () const
 Return option code. More...
 
std::string getEncapsulatedSpace () const
 Return name of the encapsulated option space. More...
 
std::string getName () const
 Return option name. More...
 
const RecordFieldsCollectiongetRecordFields () const
 Return list of record fields. More...
 
OptionDataType getType () const
 Return option data type. More...
 
data::ConstElementPtr getContext () const
 Returns const pointer to the user context. More...
 
void setContext (const data::ConstElementPtr &ctx)
 Sets user context. More...
 
void contextToElement (data::ElementPtr map) const
 Merge unparse a user_context object. More...
 
std::string getOptionSpaceName () const
 Returns option space name. More...
 
void setOptionSpaceName (const std::string &option_space_name)
 Sets option space name for option definition. More...
 
void validate () const
 Check if the option definition is valid. More...
 
bool haveIA6Format () const
 Check if specified format is IA_NA option format. More...
 
bool haveIAAddr6Format () const
 Check if specified format is IAADDR option format. More...
 
bool haveIAPrefix6Format () const
 Check if specified format is IAPREFIX option format. More...
 
bool haveClientFqdnFormat () const
 Check if specified format is OPTION_CLIENT_FQDN option format. More...
 
bool haveFqdn4Format () const
 Check if option has format of the DHCPv4 Client FQDN Option. More...
 
bool haveVendor4Format () const
 Check if the option has format of Vendor-Identifying Vendor Specific Options. More...
 
bool haveVendor6Format () const
 Check if option has a format of the Vendor-Specific Information Option. More...
 
bool haveVendorClass4Format () const
 Check if the option has format of DHCPv4 V-I Vendor Class option. More...
 
bool haveVendorClass6Format () const
 Check if the option has format of DHCPv6 Vendor Class option. More...
 
bool haveServiceScopeFormat () const
 Check if option has format of the SLP Service Scope Option. More...
 
bool haveStatusCodeFormat () const
 Check if the option has format of DHCPv6 Status Code option. More...
 
bool haveOpaqueDataTuplesFormat () const
 Check if the option has format of OpaqueDataTuples type options. More...
 
bool haveCompressedFqdnListFormat () const
 Check if the option has format of CompressedFqdnList options. More...
 
OptionPtr optionFactory (Option::Universe u, uint16_t type, OptionBufferConstIter begin, OptionBufferConstIter end) const
 Option factory. More...
 
OptionPtr optionFactory (Option::Universe u, uint16_t type, const OptionBuffer &buf=OptionBuffer()) const
 Option factory. More...
 
OptionPtr optionFactory (Option::Universe u, uint16_t type, const std::vector< std::string > &values) const
 Option factory. More...
 
static OptionPtr factoryAddrList4 (uint16_t type, OptionBufferConstIter begin, OptionBufferConstIter end)
 Factory to create option with address list. More...
 
static OptionPtr factoryAddrList6 (uint16_t type, OptionBufferConstIter begin, OptionBufferConstIter end)
 Factory to create option with address list. More...
 
static OptionPtr factoryEmpty (Option::Universe u, uint16_t type)
 Empty option factory. More...
 
static OptionPtr factoryGeneric (Option::Universe u, uint16_t type, OptionBufferConstIter begin, OptionBufferConstIter end)
 Factory to create generic option. More...
 
static OptionPtr factoryIA6 (uint16_t type, OptionBufferConstIter begin, OptionBufferConstIter end)
 Factory for IA-type of option. More...
 
static OptionPtr factoryIAAddr6 (uint16_t type, OptionBufferConstIter begin, OptionBufferConstIter end)
 Factory for IAADDR-type of option. More...
 
static OptionPtr factoryIAPrefix6 (uint16_t type, OptionBufferConstIter begin, OptionBufferConstIter end)
 Factory for IAPREFIX-type of option. More...
 
static OptionPtr factoryOpaqueDataTuples (Option::Universe u, uint16_t type, OptionBufferConstIter begin, OptionBufferConstIter end)
 Factory to create option with tuple list. More...
 
template<typename T >
static OptionPtr factoryInteger (Option::Universe u, uint16_t type, const std::string &encapsulated_space, OptionBufferConstIter begin, OptionBufferConstIter end)
 Factory function to create option with integer value. More...
 
template<typename T >
static OptionPtr factoryIntegerArray (Option::Universe u, uint16_t type, OptionBufferConstIter begin, OptionBufferConstIter end)
 Factory function to create option with array of integer values. More...
 

Detailed Description

Base class representing a DHCP option definition.

This is a base class representing a DHCP option definition, which describes the format of the option. In particular, it defines:

  • option name,
  • option code,
  • data fields order and their types,
  • sub options space that the particular option encapsulates.

The option type specifies the data type(s) which an option conveys. If this is a single value the option type points to the data type of the value. For example, DHCPv6 option 8 comprises a two-byte option code, a two-byte option length and two-byte field that carries a uint16 value (RFC 8415 - http://ietf.org/rfc/rfc8415.txt). In such a case, the option type is defined as "uint16". Length and string tuples are a length on one (DHCPv4) or two (DHCPv6) bytes followed by a string of the given length.

When the option has a more complex structure, the option type may be defined as "array", "record" or even "array of records".

Array types should be used when the option contains multiple contiguous data values of the same type laid. For example, DHCPv6 option 6 includes multiple fields holding uint16 codes of requested DHCPv6 options (RFC 8415). Such an option can be represented with this class by setting the option type to "uint16" and the array indicator (array_type) to true. The number of elements in the array is effectively unlimited (although it is actually limited by the maximal DHCPv6 option length).

Should the option comprise data fields of different types, the "record" option type is used. In such cases the data field types within the record are specified using OptionDefinition::addRecordField.

When the OptionDefinition object has been successfully created, it can be queried to return the appropriate option factory function for the specified specified option format. There are a number of "standard" factory functions that cover well known (common) formats. If the particular format does not match any common format the generic factory function is returned.

The following data type strings are supported:

  • "empty" (option does not contain data fields)
  • "boolean"
  • "int8"
  • "int16"
  • "int32"
  • "uint8"
  • "uint16"
  • "uint32"
  • "ipv4-address" (IPv4 Address)
  • "ipv6-address" (IPv6 Address)
  • "ipv6-prefix" (IPv6 variable length prefix)
  • "psid" (PSID length / value)
  • "string"
  • "fqdn" (fully qualified name)
  • "tuple" (length and string)
  • "record" (set of data fields of different types)

    Todo:

    Extend the comment to describe "generic factories".

    Extend this class to use custom namespaces.

    Extend this class with more factory functions.

    Derive from UserContext without breaking the multi index.

Definition at line 137 of file option_definition.h.

Member Typedef Documentation

◆ RecordFieldsCollection

List of fields within the record.

Definition at line 141 of file option_definition.h.

◆ RecordFieldsConstIter

Const iterator for record data fields.

Definition at line 143 of file option_definition.h.

Constructor & Destructor Documentation

◆ OptionDefinition() [1/4]

isc::dhcp::OptionDefinition::OptionDefinition ( const std::string &  name,
const uint16_t  code,
const std::string &  type,
const bool  array_type = false 
)
explicit

Constructor.

Parameters
nameoption name.
codeoption code.
typeoption data type as string.
array_typearray indicator, if true it indicates that the option fields are the array.

Definition at line 43 of file option_definition.cc.

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

+ Here is the call graph for this function:

◆ OptionDefinition() [2/4]

isc::dhcp::OptionDefinition::OptionDefinition ( const std::string &  name,
const uint16_t  code,
const OptionDataType  type,
const bool  array_type = false 
)
explicit

Constructor.

Parameters
nameoption name.
codeoption code.
typeoption data type.
array_typearray indicator, if true it indicates that the option fields are the array.

Definition at line 61 of file option_definition.cc.

◆ OptionDefinition() [3/4]

isc::dhcp::OptionDefinition::OptionDefinition ( const std::string &  name,
const uint16_t  code,
const std::string &  type,
const char *  encapsulated_space 
)
explicit

Constructor.

This constructor sets the name of the option space that is encapsulated by this option. The encapsulated option space identifies sub-options that are carried within this option. This constructor does not allow to set array indicator because options comprising an array of data fields must not be used with sub-options.

Parameters
nameoption name.
codeoption code.
typeoption data type given as string.
encapsulated_spacename of the option space being encapsulated by this option.

Definition at line 72 of file option_definition.cc.

◆ OptionDefinition() [4/4]

isc::dhcp::OptionDefinition::OptionDefinition ( const std::string &  name,
const uint16_t  code,
const OptionDataType  type,
const char *  encapsulated_space 
)
explicit

Constructor.

This constructor sets the name of the option space that is encapsulated by this option. The encapsulated option space identifies sub-options that are carried within this option. This constructor does not allow to set array indicator because options comprising an array of data fields must not be used with sub-options.

Parameters
nameoption name.
codeoption code.
typeoption data type.
encapsulated_spacename of the option space being encapsulated by this option.

Definition at line 89 of file option_definition.cc.

Member Function Documentation

◆ addRecordField() [1/2]

void isc::dhcp::OptionDefinition::addRecordField ( const OptionDataType  data_type)

Adds data field to the record.

Parameters
data_typedata type for the field.
Exceptions
isc::InvalidOperationif option type is not set to RECORD_TYPE.
isc::BadValueif specified invalid data type.

Definition at line 121 of file option_definition.cc.

References isc_throw, isc::dhcp::OPT_ANY_ADDRESS_TYPE, isc::dhcp::OPT_EMPTY_TYPE, and isc::dhcp::OPT_RECORD_TYPE.

◆ addRecordField() [2/2]

void isc::dhcp::OptionDefinition::addRecordField ( const std::string &  data_type_name)

Adds data field to the record.

Parameters
data_type_namename of the data type for the field.
Exceptions
isc::InvalidOperationif option type is not set to RECORD_TYPE.
isc::BadValueif specified invalid data type.

Definition at line 115 of file option_definition.cc.

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

+ Here is the call graph for this function:

◆ contextToElement()

void isc::dhcp::OptionDefinition::contextToElement ( data::ElementPtr  map) const
inline

Merge unparse a user_context object.

Add user-context to map, but only if defined. Omit if it was not. Extract comment so it will be pretty-printed first.

Parameters
mapA pointer to map where the user context will be unparsed.

Definition at line 307 of file option_definition.h.

References isc::data::UserContext::contextToElement().

+ Here is the call graph for this function:

◆ equals()

bool isc::dhcp::OptionDefinition::equals ( const OptionDefinition other) const

Check if option definition is equal to other.

Parameters
otherOption definition to compare to.
Returns
true if two option definitions are equal, false otherwise.

Definition at line 104 of file option_definition.cc.

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

◆ factoryAddrList4()

OptionPtr isc::dhcp::OptionDefinition::factoryAddrList4 ( uint16_t  type,
OptionBufferConstIter  begin,
OptionBufferConstIter  end 
)
static

Factory to create option with address list.

Parameters
typeoption type.
beginiterator pointing to the beginning of the buffer with a list of IPv4 addresses.
enditerator pointing to the end of the buffer with a list of IPv4 addresses.
Exceptions
isc::OutOfRangeif length of the provided option buffer is not multiple of IPV4 address length.

Definition at line 741 of file option_definition.cc.

Referenced by optionFactory().

◆ factoryAddrList6()

OptionPtr isc::dhcp::OptionDefinition::factoryAddrList6 ( uint16_t  type,
OptionBufferConstIter  begin,
OptionBufferConstIter  end 
)
static

Factory to create option with address list.

Parameters
typeoption type.
beginiterator pointing to the beginning of the buffer with a list of IPv6 addresses.
enditerator pointing to the end of the buffer with a list of IPv6 addresses.
Exceptions
isc::OutOfaRangeif length of provided option buffer is not multiple of IPV6 address length.

Definition at line 750 of file option_definition.cc.

Referenced by optionFactory().

◆ factoryEmpty()

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

Empty option factory.

Parameters
uuniverse (V6 or V4).
typeoption type.

Definition at line 760 of file option_definition.cc.

Referenced by optionFactory().

◆ factoryGeneric()

OptionPtr isc::dhcp::OptionDefinition::factoryGeneric ( Option::Universe  u,
uint16_t  type,
OptionBufferConstIter  begin,
OptionBufferConstIter  end 
)
static

Factory to create generic option.

Parameters
uuniverse (V6 or V4).
typeoption type.
beginiterator pointing to the beginning of the buffer.
enditerator pointing to the end of the buffer.

Definition at line 766 of file option_definition.cc.

Referenced by optionFactory().

◆ factoryIA6()

OptionPtr isc::dhcp::OptionDefinition::factoryIA6 ( uint16_t  type,
OptionBufferConstIter  begin,
OptionBufferConstIter  end 
)
static

Factory for IA-type of option.

Parameters
typeoption type.
beginiterator pointing to the beginning of the buffer.
enditerator pointing to the end of the buffer.
Exceptions
isc::OutOfRangeif provided option buffer is too short or too long. Expected size is 12 bytes.

Definition at line 774 of file option_definition.cc.

References isc_throw, and isc::dhcp::Option6IA::OPTION6_IA_LEN.

◆ factoryIAAddr6()

OptionPtr isc::dhcp::OptionDefinition::factoryIAAddr6 ( uint16_t  type,
OptionBufferConstIter  begin,
OptionBufferConstIter  end 
)
static

Factory for IAADDR-type of option.

Parameters
typeoption type.
beginiterator pointing to the beginning of the buffer.
enditerator pointing to the end of the buffer.
Exceptions
isc::OutOfRangeif provided option buffer is too short or too long. Expected size is 24 bytes.

Definition at line 787 of file option_definition.cc.

References isc_throw, and isc::dhcp::Option6IAAddr::OPTION6_IAADDR_LEN.

◆ factoryIAPrefix6()

OptionPtr isc::dhcp::OptionDefinition::factoryIAPrefix6 ( uint16_t  type,
OptionBufferConstIter  begin,
OptionBufferConstIter  end 
)
static

Factory for IAPREFIX-type of option.

Parameters
typeoption type.
beginiterator pointing to the beginning of the buffer.
enditerator pointing to the end of the buffer.
Exceptions
isc::OutOfRangeif provided option buffer is too short. Expected minimum size is 25 bytes.

Definition at line 801 of file option_definition.cc.

References isc_throw, and isc::dhcp::Option6IAPrefix::OPTION6_IAPREFIX_LEN.

◆ factoryInteger()

template<typename T >
static OptionPtr isc::dhcp::OptionDefinition::factoryInteger ( Option::Universe  u,
uint16_t  type,
const std::string &  encapsulated_space,
OptionBufferConstIter  begin,
OptionBufferConstIter  end 
)
inlinestatic

Factory function to create option with integer value.

Parameters
uuniverse (V4 or V6).
typeoption type.
encapsulated_spaceAn option space being encapsulated by the options created by this factory function. The options which belong to encapsulated option space are sub options of this option.
beginiterator pointing to the beginning of the buffer.
enditerator pointing to the end of the buffer.
Template Parameters
Ttype of the data field (must be one of the uintX_t or intX_t).
Exceptions
isc::OutOfRangeif provided option buffer length is invalid.

Definition at line 614 of file option_definition.h.

◆ factoryIntegerArray()

template<typename T >
static OptionPtr isc::dhcp::OptionDefinition::factoryIntegerArray ( Option::Universe  u,
uint16_t  type,
OptionBufferConstIter  begin,
OptionBufferConstIter  end 
)
inlinestatic

Factory function to create option with array of integer values.

Parameters
uuniverse (V4 or V6).
typeoption type.
beginiterator pointing to the beginning of the buffer.
enditerator pointing to the end of the buffer.
Template Parameters
Ttype of the data field (must be one of the uintX_t or intX_t).
Exceptions
isc::OutOfRangeif provided option buffer length is invalid.

Definition at line 634 of file option_definition.h.

◆ factoryOpaqueDataTuples()

OptionPtr isc::dhcp::OptionDefinition::factoryOpaqueDataTuples ( Option::Universe  u,
uint16_t  type,
OptionBufferConstIter  begin,
OptionBufferConstIter  end 
)
static

Factory to create option with tuple list.

Parameters
uoption universe (V4 or V6).
typeoption type.
beginiterator pointing to the beginning of the buffer with a list of tuples.
enditerator pointing to the end of the buffer with a list of tuples.
Returns
instance of the DHCP option.

Definition at line 815 of file option_definition.cc.

Referenced by optionFactory().

◆ getArrayType()

bool isc::dhcp::OptionDefinition::getArrayType ( ) const
inline

Return array type indicator.

The method returns the bool value to indicate whether the option is a a single value or an array of values.

Returns
true if option comprises an array of values.

Definition at line 259 of file option_definition.h.

Referenced by haveClientFqdnFormat(), haveCompressedFqdnListFormat(), haveFqdn4Format(), haveIAPrefix6Format(), haveOpaqueDataTuplesFormat(), and isc::dhcp::OptionCustom::toText().

◆ getCode()

uint16_t isc::dhcp::OptionDefinition::getCode ( ) const
inline

Return option code.

Returns
option code.

Definition at line 264 of file option_definition.h.

Referenced by optionFactory().

◆ getContext()

data::ConstElementPtr isc::dhcp::OptionDefinition::getContext ( ) const
inline

Returns const pointer to the user context.

Definition at line 291 of file option_definition.h.

References isc::data::UserContext::getContext().

+ Here is the call graph for this function:

◆ getEncapsulatedSpace()

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

Return name of the encapsulated option space.

Returns
name of the encapsulated option space.

Definition at line 269 of file option_definition.h.

Referenced by haveVendor6Format(), isc::dhcp::OptionCustom::OptionCustom(), and optionFactory().

◆ getName()

std::string isc::dhcp::OptionDefinition::getName ( ) const
inline

Return option name.

Returns
option name.

Definition at line 276 of file option_definition.h.

◆ getOptionSpaceName()

std::string isc::dhcp::OptionDefinition::getOptionSpaceName ( ) const
inline

Returns option space name.

Option definitions are associated with option spaces. Typically, such association is made when the option definition is put into the CfgOptionDef structure. However, in some cases it is also required to associate option definition with the particular option space outside of that structure. In particular, when the option definition is fetched from a database. The database configuration backend will set option space upon return of the option definition. In other cases this value won't be set.

Returns
Option space name or empty string if option space name is not set.

Definition at line 324 of file option_definition.h.

◆ getRecordFields()

const RecordFieldsCollection& isc::dhcp::OptionDefinition::getRecordFields ( ) const
inline

Return list of record fields.

Returns
list of record fields.

Definition at line 281 of file option_definition.h.

Referenced by isc::dhcp::OptionCustom::addArrayDataField(), optionFactory(), isc::dhcp::OptionCustom::toText(), and validate().

◆ getType()

OptionDataType isc::dhcp::OptionDefinition::getType ( ) const
inline

Return option data type.

Returns
option data type.

Definition at line 288 of file option_definition.h.

Referenced by isc::dhcp::OptionCustom::addArrayDataField(), haveVendor6Format(), and isc::dhcp::OptionCustom::toText().

◆ haveClientFqdnFormat()

bool isc::dhcp::OptionDefinition::haveClientFqdnFormat ( ) const

Check if specified format is OPTION_CLIENT_FQDN option format.

Returns
true of specified format is OPTION_CLIENT_FQDN option format, false otherwise.

Definition at line 437 of file option_definition.cc.

References getArrayType(), isc::dhcp::OPT_FQDN_TYPE, isc::dhcp::OPT_RECORD_TYPE, and isc::dhcp::OPT_UINT8_TYPE.

+ Here is the call graph for this function:

◆ haveCompressedFqdnListFormat()

bool isc::dhcp::OptionDefinition::haveCompressedFqdnListFormat ( ) const

Check if the option has format of CompressedFqdnList options.

Definition at line 493 of file option_definition.cc.

References getArrayType(), and isc::dhcp::OPT_FQDN_TYPE.

+ Here is the call graph for this function:

◆ haveFqdn4Format()

bool isc::dhcp::OptionDefinition::haveFqdn4Format ( ) const

Check if option has format of the DHCPv4 Client FQDN Option.

The encoding of the domain-name carried by the FQDN option is conditional and is specified in the flags field of the option. The domain-name can be encoded in the ASCII format or canonical wire format. The ASCII format is deprecated, therefore canonical format is selected for the FQDN option definition and this function returns true if the option definition comprises the domain-name field encoded in canonical format.

Returns
true if option has the format of DHCPv4 Client FQDN Option.

Definition at line 426 of file option_definition.cc.

References getArrayType(), isc::dhcp::OPT_FQDN_TYPE, isc::dhcp::OPT_RECORD_TYPE, and isc::dhcp::OPT_UINT8_TYPE.

+ Here is the call graph for this function:

◆ haveIA6Format()

bool isc::dhcp::OptionDefinition::haveIA6Format ( ) const

Check if specified format is IA_NA option format.

Returns
true if specified format is IA_NA option format.

Definition at line 399 of file option_definition.cc.

References isc::dhcp::OPT_UINT32_TYPE.

◆ haveIAAddr6Format()

bool isc::dhcp::OptionDefinition::haveIAAddr6Format ( ) const

Check if specified format is IAADDR option format.

Returns
true if specified format is IAADDR option format.

Definition at line 410 of file option_definition.cc.

References isc::dhcp::OPT_IPV6_ADDRESS_TYPE.

◆ haveIAPrefix6Format()

bool isc::dhcp::OptionDefinition::haveIAPrefix6Format ( ) const

Check if specified format is IAPREFIX option format.

Returns
true if specified format is IAPREFIX option format.

Definition at line 415 of file option_definition.cc.

References getArrayType(), isc::dhcp::OPT_IPV6_ADDRESS_TYPE, isc::dhcp::OPT_RECORD_TYPE, isc::dhcp::OPT_UINT32_TYPE, and isc::dhcp::OPT_UINT8_TYPE.

+ Here is the call graph for this function:

◆ haveOpaqueDataTuplesFormat()

bool isc::dhcp::OptionDefinition::haveOpaqueDataTuplesFormat ( ) const

Check if the option has format of OpaqueDataTuples type options.

Returns
true if option has the format of OpaqueDataTuples type options.

Definition at line 488 of file option_definition.cc.

References getArrayType(), and isc::dhcp::OPT_TUPLE_TYPE.

+ Here is the call graph for this function:

◆ haveServiceScopeFormat()

bool isc::dhcp::OptionDefinition::haveServiceScopeFormat ( ) const

Check if option has format of the SLP Service Scope Option.

The scope list in the SLP Service Scope option is optional (i.e., as the error message in the DHCPv6 Status code option).

Returns
true if option has the format of SLP Service Scope Option.

Definition at line 480 of file option_definition.cc.

References isc::dhcp::OPT_BOOLEAN_TYPE, isc::dhcp::OPT_RECORD_TYPE, and isc::dhcp::OPT_STRING_TYPE.

◆ haveStatusCodeFormat()

bool isc::dhcp::OptionDefinition::haveStatusCodeFormat ( ) const

Check if the option has format of DHCPv6 Status Code option.

Returns
true if option has the format of DHCPv6 Status code option.

Definition at line 472 of file option_definition.cc.

References isc::dhcp::OPT_RECORD_TYPE, isc::dhcp::OPT_STRING_TYPE, and isc::dhcp::OPT_UINT16_TYPE.

◆ haveVendor4Format()

bool isc::dhcp::OptionDefinition::haveVendor4Format ( ) const

Check if the option has format of Vendor-Identifying Vendor Specific Options.

Returns
Always true.
Todo:
The Vendor-Identifying Vendor-Specific Option has a complex format which we do not support here. Therefore it is not really possible to check that the current definition is valid. We may need to add support for such option format or simply do not check the format for certain options, e.g. vendor options, IA_NA, IAADDR and always return objects of the certain type.

Definition at line 446 of file option_definition.cc.

◆ haveVendor6Format()

bool isc::dhcp::OptionDefinition::haveVendor6Format ( ) const

Check if option has a format of the Vendor-Specific Information Option.

The Vendor-Specific Information Option comprises 32-bit enterprise id and the suboptions.

Returns
true if option definition conforms to the format of the Vendor-Specific Information Option.

Definition at line 451 of file option_definition.cc.

References getEncapsulatedSpace(), getType(), and isc::dhcp::OPT_UINT32_TYPE.

+ Here is the call graph for this function:

◆ haveVendorClass4Format()

bool isc::dhcp::OptionDefinition::haveVendorClass4Format ( ) const

Check if the option has format of DHCPv4 V-I Vendor Class option.

Returns
true if the option has the format of DHCPv4 Vendor Class option.

Definition at line 456 of file option_definition.cc.

References isc::dhcp::OPT_BINARY_TYPE, isc::dhcp::OPT_RECORD_TYPE, and isc::dhcp::OPT_UINT32_TYPE.

◆ haveVendorClass6Format()

bool isc::dhcp::OptionDefinition::haveVendorClass6Format ( ) const

Check if the option has format of DHCPv6 Vendor Class option.

Returns
true if option has the format of DHCPv6 Vendor Class option.

Definition at line 464 of file option_definition.cc.

References isc::dhcp::OPT_BINARY_TYPE, isc::dhcp::OPT_RECORD_TYPE, and isc::dhcp::OPT_UINT32_TYPE.

◆ operator!=()

bool isc::dhcp::OptionDefinition::operator!= ( const OptionDefinition other) const
inline

Inequality operator.

Parameters
otherOption definition to compare to.
Returns
true if option definitions are not equal, false otherwise.

Definition at line 232 of file option_definition.h.

References equals().

+ Here is the call graph for this function:

◆ operator==()

bool isc::dhcp::OptionDefinition::operator== ( const OptionDefinition other) const
inline

Equality operator.

Parameters
otherOption definition to compare to.
Returns
true if two option definitions are equal, false otherwise.

Definition at line 223 of file option_definition.h.

References equals().

+ Here is the call graph for this function:

◆ optionFactory() [1/3]

OptionPtr isc::dhcp::OptionDefinition::optionFactory ( Option::Universe  u,
uint16_t  type,
const OptionBuffer buf = OptionBuffer() 
) const

Option factory.

This function creates an instance of DHCP option using whole provided buffer. This function may be used to create option which is to be sent in the outgoing packet.

Warning
calling this function on invalid option definition yields undefined behavior. Use validate to test that the option definition is valid.
Parameters
uoption universe (V4 or V6).
typeoption type.
bufoption buffer.
Returns
instance of the DHCP option.
Exceptions
InvalidOptionValueif data for the option is invalid.

Definition at line 243 of file option_definition.cc.

References optionFactory().

+ Here is the call graph for this function:

◆ optionFactory() [2/3]

OptionPtr isc::dhcp::OptionDefinition::optionFactory ( Option::Universe  u,
uint16_t  type,
const std::vector< std::string > &  values 
) const

Option factory.

This function creates an instance of DHCP option using the vector of strings which carry data values for option data fields. The order of values in the vector corresponds to the order of data fields in the option. The supplied string values are cast to their actual data types which are determined based on the option definition. If cast fails due to type mismatch, an exception is thrown. This factory function can be used to create option instance when user specified option value in the comma separated values format in the configuration database. Provided string must be tokenized into the vector of string values and this vector can be supplied to this function.

Warning
calling this function on invalid option definition yields undefined behavior. Use validate to test that the option definition is valid.
Parameters
uoption universe (V4 or V6).
typeoption type.
valuesa vector of values to be used to set data for an option.
Returns
instance of the DHCP option.
Exceptions
InvalidOptionValueif data for the option is invalid.

Definition at line 249 of file option_definition.cc.

References getCode(), getRecordFields(), isc_throw, isc::dhcp::OPT_EMPTY_TYPE, isc::dhcp::OPT_RECORD_TYPE, optionFactory(), and isc::util::str::trim().

+ Here is the call graph for this function:

◆ optionFactory() [3/3]

OptionPtr isc::dhcp::OptionDefinition::optionFactory ( Option::Universe  u,
uint16_t  type,
OptionBufferConstIter  begin,
OptionBufferConstIter  end 
) const

Option factory.

This function creates an instance of DHCP option using provided chunk of buffer. This function may be used to create option which is to be sent in the outgoing packet.

Warning
calling this function on invalid option definition yields undefined behavior. Use validate to test that the option definition is valid.
Parameters
uoption universe (V4 or V6).
typeoption type.
beginbeginning of the option buffer.
endend of the option buffer.
Returns
instance of the DHCP option.
Exceptions
InvalidOptionValueif data for the option is invalid.

Definition at line 136 of file option_definition.cc.

References factoryAddrList4(), factoryAddrList6(), factoryEmpty(), factoryGeneric(), factoryOpaqueDataTuples(), getEncapsulatedSpace(), isc_throw, isc::dhcp::OPT_BINARY_TYPE, isc::dhcp::OPT_EMPTY_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_STRING_TYPE, isc::dhcp::OPT_TUPLE_TYPE, isc::dhcp::OPT_UINT16_TYPE, isc::dhcp::OPT_UINT32_TYPE, isc::dhcp::OPT_UINT8_TYPE, and isc::Exception::what().

Referenced by optionFactory().

+ Here is the call graph for this function:

◆ setContext()

void isc::dhcp::OptionDefinition::setContext ( const data::ConstElementPtr ctx)
inline

Sets user context.

Parameters
ctxuser context to be stored.

Definition at line 297 of file option_definition.h.

References isc::data::UserContext::setContext().

+ Here is the call graph for this function:

◆ setOptionSpaceName()

void isc::dhcp::OptionDefinition::setOptionSpaceName ( const std::string &  option_space_name)
inline

Sets option space name for option definition.

See getOptionSpaceName to learn when option space name is set.

Parameters
option_space_nameNew option space name.

Definition at line 333 of file option_definition.h.

◆ validate()

void isc::dhcp::OptionDefinition::validate ( ) const

Check if the option definition is valid.

Note that it is a responsibility of the code that created the OptionDefinition object to validate that it is valid. This function will not be called internally anywhere in this class to verify that the option definition is valid. Using invalid option definition to create an instance of the DHCP option leads to undefined behavior.

Exceptions
MalformedOptionDefinitionoption definition is invalid.

Empty type is not allowed within a record.

Definition at line 285 of file option_definition.cc.

References getRecordFields(), isc_throw, name_, isc::dhcp::OPT_BINARY_TYPE, isc::dhcp::OPT_EMPTY_TYPE, isc::dhcp::OPT_RECORD_TYPE, isc::dhcp::OPT_STRING_TYPE, isc::dhcp::OPT_UNKNOWN_TYPE, and isc::dhcp::OptionSpace::validateName().

+ Here is the call graph for this function:

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