Kea  2.1.7-git
isc::dhcp::OptionSpace Class Reference

DHCP option space. More...

#include <option_space.h>

+ Inheritance diagram for isc::dhcp::OptionSpace:

Public Member Functions

 OptionSpace (const std::string &name, const bool vendor_space=false)
 Constructor. More...
 
void clearVendorSpace ()
 Mark option space as non-vendor space. More...
 
const std::string & getName () const
 Return option space name. More...
 
bool isVendorSpace () const
 Check if option space is vendor specific. More...
 
void setVendorSpace ()
 Mark option space as vendor specific. More...
 

Static Public Member Functions

static bool validateName (const std::string &name)
 Checks that the provided option space name is valid. More...
 

Detailed Description

DHCP option space.

This class represents single option space. The option spaces are used to group DHCP options having unique option codes. The special type of the option space is so called "vendor specific option space". It groups sub-options being sent within Vendor Encapsulated Options. For DHCPv4 it is the option with code 43. The option spaces are assigned to option instances represented by isc::dhcp::Option and other classes derived from it. Each particular option may belong to multiple option spaces. This class may be used to represent any DHCPv4 option space. If the option space is to group DHCPv4 Vendor Encapsulated Options then "vendor space" flag must be set using OptionSpace::setVendorSpace or the argument passed to the constructor. In theory, this class can be also used to represent non-vendor specific DHCPv6 option space but this is discouraged. For DHCPv6 option spaces the OptionSpace6 class should be used instead.

Note
this class is intended to be used to represent DHCPv4 option spaces only. However, it hasn't been called OptionSpace4 (that would suggest that it is specific to DHCPv4) because it can be also used to represent some DHCPv6 option spaces and is a base class for OptionSpace6. Thus, if one declared the container as follows:
std::vector<OptionSpace4> container;
it would suggest that the container holds DHCPv4 option spaces while it could hold both DHCPv4 and DHCPv6 option spaces as the OptionSpace6 object could be upcast to OptionSpace4. This confusion does not appear when OptionSpace is used as a name for the base class.

Definition at line 66 of file option_space.h.

Constructor & Destructor Documentation

◆ OptionSpace()

isc::dhcp::OptionSpace::OptionSpace ( const std::string &  name,
const bool  vendor_space = false 
)

Constructor.

Parameters
nameoption space name.
vendor_spaceboolean value that indicates that the object describes the vendor specific option space.
Exceptions
isc::dhcp::InvalidOptionSpaceif given option space name contains invalid characters or is empty. This constructor uses validateName function to check that the specified name is correct.

Definition at line 16 of file option_space.cc.

References isc_throw, and validateName().

+ Here is the call graph for this function:

Member Function Documentation

◆ clearVendorSpace()

void isc::dhcp::OptionSpace::clearVendorSpace ( )
inline

Mark option space as non-vendor space.

Definition at line 87 of file option_space.h.

◆ getName()

const std::string& isc::dhcp::OptionSpace::getName ( ) const
inline

Return option space name.

Returns
option space name.

Definition at line 84 of file option_space.h.

References name_.

◆ isVendorSpace()

bool isc::dhcp::OptionSpace::isVendorSpace ( ) const
inline

Check if option space is vendor specific.

Returns
boolean value that indicates if the object describes the vendor specific option space.

Definition at line 95 of file option_space.h.

◆ setVendorSpace()

void isc::dhcp::OptionSpace::setVendorSpace ( )
inline

Mark option space as vendor specific.

Definition at line 98 of file option_space.h.

References name_.

Referenced by isc::dhcp::OptionSpace6::setVendorSpace().

◆ validateName()

bool isc::dhcp::OptionSpace::validateName ( const std::string &  name)
static

Checks that the provided option space name is valid.

It is expected that option space name consists of upper or lower case letters or digits. Also, it may contain underscores or dashes. Other characters are prohibited. The empty option space names are invalid.

Parameters
nameoption space name to be validated.
Returns
true if the option space is valid, else it returns false.

Definition at line 26 of file option_space.cc.

Referenced by isc::dhcp::OptionDataParser::extractSpace(), OptionSpace(), isc::dhcp::OptionDefParser::parse(), and isc::dhcp::OptionDefinition::validate().


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