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

Represents DHCPv6 Client FQDN Option (code 39). More...

#include <option6_client_fqdn.h>

+ Inheritance diagram for isc::dhcp::Option6ClientFqdn:

Public Types

enum  DomainNameType { PARTIAL, FULL }
 Type of the domain-name: partial or full. More...
 
- Public Types inherited from isc::dhcp::Option
typedef OptionPtr Factory(Option::Universe u, uint16_t type, const OptionBuffer &buf)
 a factory function prototype More...
 
enum  Universe { V4, V6 }
 defines option universe DHCPv4 or DHCPv6 More...
 

Public Member Functions

 Option6ClientFqdn (const uint8_t flags, const std::string &domain_name, const DomainNameType domain_name_type=FULL)
 Constructor, creates option instance using flags and domain name. More...
 
 Option6ClientFqdn (const uint8_t flags)
 Constructor, creates option instance using flags. More...
 
 Option6ClientFqdn (OptionBufferConstIter first, OptionBufferConstIter last)
 Constructor, creates an option instance from part of the buffer. More...
 
 Option6ClientFqdn (const Option6ClientFqdn &source)
 Copy constructor. More...
 
virtual ~Option6ClientFqdn ()
 Destructor. More...
 
virtual OptionPtr clone () const
 Copies this option and returns a pointer to the copy. More...
 
std::string getDomainName () const
 Returns the domain-name in the text format. More...
 
DomainNameType getDomainNameType () const
 Returns enumerator value which indicates whether domain-name is partial or full. More...
 
bool getFlag (const uint8_t flag) const
 Checks if the specified flag of the DHCPv6 Client FQDN Option is set. More...
 
virtual uint16_t len () const
 Returns length of the complete option (data length + DHCPv6 option header). More...
 
Option6ClientFqdnoperator= (const Option6ClientFqdn &source)
 Assignment operator. More...
 
virtual void pack (isc::util::OutputBuffer &buf) const
 Writes option in the wire format into a buffer. More...
 
void packDomainName (isc::util::OutputBuffer &buf) const
 Writes domain-name in the wire format into a buffer. More...
 
void resetDomainName ()
 Set empty domain-name. More...
 
void resetFlags ()
 Sets the flag field value to 0. More...
 
void setDomainName (const std::string &domain_name, const DomainNameType domain_name_type)
 Set new domain-name. More...
 
void setFlag (const uint8_t flag, const bool set)
 Modifies the value of the specified DHCPv6 Client Fqdn Option flag. More...
 
virtual std::string toText (int indent=0) const
 Returns string representation of the option. More...
 
virtual void unpack (OptionBufferConstIter first, OptionBufferConstIter last)
 Parses option from the received buffer. More...
 
- Public Member Functions inherited from isc::dhcp::Option
 Option (Universe u, uint16_t type)
 ctor, used for options constructed, usually during transmission More...
 
 Option (Universe u, uint16_t type, const OptionBuffer &data)
 Constructor, used for received options. More...
 
 Option (Universe u, uint16_t type, OptionBufferConstIter first, OptionBufferConstIter last)
 Constructor, used for received options. More...
 
 Option (const Option &source)
 Copy constructor. More...
 
virtual ~Option ()
 just to force that every option has virtual dtor More...
 
void addOption (OptionPtr opt)
 Adds a sub-option. More...
 
bool delOption (uint16_t type)
 Attempts to delete first suboption of requested type. More...
 
bool equals (const OptionPtr &other) const
 Checks if options are equal. More...
 
virtual bool equals (const Option &other) const
 Checks if two options are equal. More...
 
virtual const OptionBuffergetData () const
 Returns pointer to actual data. More...
 
std::string getEncapsulatedSpace () const
 Returns the name of the option space encapsulated by this option. More...
 
virtual uint16_t getHeaderLen () const
 Returns length of header (2 for v4, 4 for v6) More...
 
OptionPtr getOption (uint16_t type) const
 Returns shared_ptr to suboption of specific type. More...
 
const OptionCollectiongetOptions () const
 Returns all encapsulated options. More...
 
void getOptionsCopy (OptionCollection &options_copy) const
 Performs deep copy of suboptions. More...
 
uint16_t getType () const
 Returns option type (0-255 for DHCPv4, 0-65535 for DHCPv6) More...
 
uint16_t getUint16 () const
 Returns content of first word. More...
 
uint32_t getUint32 () const
 Returns content of first double word. More...
 
uint8_t getUint8 () const
 Returns content of first byte. More...
 
Universe getUniverse () const
 returns option universe (V4 or V6) More...
 
Optionoperator= (const Option &rhs)
 Assignment operator. More...
 
template<typename InputIterator >
void setData (InputIterator first, InputIterator last)
 Sets content of this option from buffer. More...
 
void setEncapsulatedSpace (const std::string &encapsulated_space)
 Sets the name of the option space encapsulated by this option. More...
 
void setUint16 (uint16_t value)
 Sets content of this option to a single uint16 value. More...
 
void setUint32 (uint32_t value)
 Sets content of this option to a single uint32 value. More...
 
void setUint8 (uint8_t value)
 Sets content of this option to a single uint8 value. More...
 
virtual std::vector< uint8_t > toBinary (const bool include_header=false) const
 Returns binary representation of the option. More...
 
virtual std::string toHexString (const bool include_header=false) const
 Returns string containing hexadecimal representation of option. More...
 
virtual std::string toString () const
 Returns string representation of the value. More...
 
virtual bool valid () const
 returns if option is valid (e.g. More...
 

Static Public Attributes

static const uint16_t FLAG_FIELD_LEN = 1
 The length of the flag field within DHCPv6 Client Fqdn Option. More...
 
static const uint8_t FLAG_MASK = 0x7
 Mask which zeroes MBZ flag bits. More...
 
A set of constants setting respective bits in 'flags' field
static const uint8_t FLAG_S = 0x01
 S bit. More...
 
static const uint8_t FLAG_O = 0x02
 O bit. More...
 
static const uint8_t FLAG_N = 0x04
 N bit. More...
 
- Static Public Attributes inherited from isc::dhcp::Option
static bool lenient_parsing_
 Governs whether options should be parsed less strictly. More...
 
static const size_t OPTION4_HDR_LEN = 2
 length of the usual DHCPv4 option header (there are exceptions) More...
 
static const size_t OPTION6_HDR_LEN = 4
 length of any DHCPv6 option header More...
 

Additional Inherited Members

- Static Public Member Functions inherited from isc::dhcp::Option
static OptionPtr create (Universe u, uint16_t type)
 Factory function creating an instance of the Option. More...
 
static OptionPtr create (Universe u, uint16_t type, const OptionBuffer &data)
 Factory function creating an instance of the Option. More...
 
static OptionPtr factory (Option::Universe u, uint16_t type, const OptionBuffer &buf)
 Factory function to create instance of option. More...
 
static OptionPtr factory (Option::Universe u, uint16_t type)
 Factory function to create instance of option. More...
 
- Protected Member Functions inherited from isc::dhcp::Option
void check () const
 A protected method used for option correctness. More...
 
template<typename OptionType >
OptionPtr cloneInternal () const
 Copies this option and returns a pointer to the copy. More...
 
std::string headerToText (const int indent=0, const std::string &type_name="") const
 Returns option header in the textual format. More...
 
void packHeader (isc::util::OutputBuffer &buf) const
 Store option's header in a buffer. More...
 
void packOptions (isc::util::OutputBuffer &buf) const
 Store sub options in a buffer. More...
 
std::string suboptionsToText (const int indent=0) const
 Returns collection of suboptions in the textual format. More...
 
void unpackOptions (const OptionBuffer &buf)
 Builds a collection of sub options from the buffer. More...
 
- Protected Attributes inherited from isc::dhcp::Option
OptionBuffer data_
 contains content of this data More...
 
std::string encapsulated_space_
 Name of the option space being encapsulated by this option. More...
 
OptionCollection options_
 collection for storing suboptions More...
 
uint16_t type_
 option type (0-255 for DHCPv4, 0-65535 for DHCPv6) More...
 
Universe universe_
 option universe (V4 or V6) More...
 

Detailed Description

Represents DHCPv6 Client FQDN Option (code 39).

This option has been defined in the RFC 4704 and it has a following structure:

  • option-code = 39 (2 octets)
  • option-len (2 octets)
  • flags (1 octet)
  • domain-name - variable length field comprising partial or fully qualified domain name.

The flags field has the following structure:

0 1 2 3 4 5 6 7
+-+-+-+-+-+-+-+-+
| MBZ |N|O|S|
+-+-+-+-+-+-+-+-+

where:

  • N flag specifies whether server should (0) or should not (1) perform DNS Update,
  • O flag is set by the server to indicate that it has overridden client's preference set with the S bit.
  • S flag specifies whether server should (1) or should not (0) perform forward (FQDN-to-address) updates.

This class exposes a set of functions to modify flags and check their correctness.

Domain names being carried by DHCPv6 Client Fqdn Option can be fully qualified or partial. Partial domain names are encoded similar to the fully qualified domain names, except that they lack terminating zero at the end of their wire representation. It is also accepted to create an instance of this option which has empty domain-name. Clients use empty domain-names to indicate that server should generate complete fully qualified domain-name.

Since domain names are case insensitive (see RFC 4343), this class converts them to lower case format regardless if they are received over the wire or created from strings.

Design choice: This class uses pimpl idiom to separate the interface from implementation specifics. Implementations may use different approaches to handle domain names (mostly validation of the domain-names). The existing isc::dns::Name class is a natural (and the simplest) choice to handle domain-names. Use of this class however, implies that libdhcp must be linked with libdns. At some point these libraries may need to be separated, i.e. to support compilation and use of standalone DHCP server. This will require that the part of implementation which deals with domain-names is modified to not use classes from libdns. These changes will be transparent for this interface.

Definition at line 87 of file option6_client_fqdn.h.

Member Enumeration Documentation

◆ DomainNameType

Type of the domain-name: partial or full.

Enumerator
PARTIAL 
FULL 

Definition at line 105 of file option6_client_fqdn.h.

Constructor & Destructor Documentation

◆ Option6ClientFqdn() [1/4]

isc::dhcp::Option6ClientFqdn::Option6ClientFqdn ( const uint8_t  flags,
const std::string &  domain_name,
const DomainNameType  domain_name_type = FULL 
)
explicit

Constructor, creates option instance using flags and domain name.

This constructor is used to create instance of the option which will be included in outgoing messages.

Parameters
flagsa combination of flag bits to be stored in flags field.
domain_namea name to be stored in the domain-name field.
domain_name_typeindicates if the domain name is partial or full.

Definition at line 276 of file option6_client_fqdn.cc.

◆ Option6ClientFqdn() [2/4]

isc::dhcp::Option6ClientFqdn::Option6ClientFqdn ( const uint8_t  flags)

Constructor, creates option instance using flags.

This constructor creates an instance of the option with empty domain-name. This domain-name is marked partial.

Parameters
flagsA combination of flag bits to be stored in flags field.

Definition at line 271 of file option6_client_fqdn.cc.

◆ Option6ClientFqdn() [3/4]

isc::dhcp::Option6ClientFqdn::Option6ClientFqdn ( OptionBufferConstIter  first,
OptionBufferConstIter  last 
)
explicit

Constructor, creates an option instance from part of the buffer.

This constructor is mainly used to parse options in the received messages. Function parameters specify buffer bounds from which the option should be created. The size of the buffer chunk, specified by the constructor's parameters should be equal or larger than the size of the option. Otherwise, constructor will throw an exception.

Parameters
firstthe lower bound of the buffer to create option from.
lastthe upper bound of the buffer to create option from.

Definition at line 283 of file option6_client_fqdn.cc.

◆ Option6ClientFqdn() [4/4]

isc::dhcp::Option6ClientFqdn::Option6ClientFqdn ( const Option6ClientFqdn source)

Copy constructor.

Definition at line 293 of file option6_client_fqdn.cc.

◆ ~Option6ClientFqdn()

isc::dhcp::Option6ClientFqdn::~Option6ClientFqdn ( )
virtual

Destructor.

Definition at line 289 of file option6_client_fqdn.cc.

Member Function Documentation

◆ clone()

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

Copies this option and returns a pointer to the copy.

Reimplemented from isc::dhcp::Option.

Definition at line 299 of file option6_client_fqdn.cc.

◆ getDomainName()

std::string isc::dhcp::Option6ClientFqdn::getDomainName ( ) const

Returns the domain-name in the text format.

If domain-name is partial, it lacks the dot at the end (e.g. myhost). If domain-name is fully qualified, it has the dot at the end (e.g. myhost.example.com.).

Returns
domain-name in the text format.

Definition at line 360 of file option6_client_fqdn.cc.

References isc::dhcp::Option6ClientFqdnImpl::domain_name_, isc::dhcp::Option6ClientFqdnImpl::domain_name_type_, and PARTIAL.

Referenced by isc::dhcp::Dhcpv6Srv::processClientFqdn(), isc::dhcp::Dhcpv6Srv::requiredClassify(), and toText().

◆ getDomainNameType()

Option6ClientFqdn::DomainNameType isc::dhcp::Option6ClientFqdn::getDomainNameType ( ) const

Returns enumerator value which indicates whether domain-name is partial or full.

Returns
An enumerator value indicating whether domain-name is partial or full.

Definition at line 401 of file option6_client_fqdn.cc.

References isc::dhcp::Option6ClientFqdnImpl::domain_name_type_.

Referenced by toText().

◆ getFlag()

bool isc::dhcp::Option6ClientFqdn::getFlag ( const uint8_t  flag) const

Checks if the specified flag of the DHCPv6 Client FQDN Option is set.

This method checks the single bit of flags field. Therefore, a caller should use one of the: FLAG_S, FLAG_N, FLAG_O constants as an argument of the function. Attempt to use any other value (including combinations of these constants) will result in exception.

Parameters
flagA value specifying the flags bit to be checked. It can be one of the following: FLAG_S, FLAG_N, FLAG_O.
Returns
true if the bit of the specified flag is set, false otherwise.

Definition at line 316 of file option6_client_fqdn.cc.

References FLAG_N, FLAG_O, FLAG_S, isc::dhcp::Option6ClientFqdnImpl::flags_, and isc_throw.

Referenced by toText().

◆ len()

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

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

Returns
length of the option.

Reimplemented from isc::dhcp::Option.

Definition at line 443 of file option6_client_fqdn.cc.

References isc::dhcp::Option6ClientFqdnImpl::domain_name_, isc::dhcp::Option6ClientFqdnImpl::domain_name_type_, FLAG_FIELD_LEN, FULL, and isc::dhcp::Option::getHeaderLen().

+ Here is the call graph for this function:

◆ operator=()

Option6ClientFqdn & isc::dhcp::Option6ClientFqdn::operator= ( const Option6ClientFqdn source)

Assignment operator.

Definition at line 307 of file option6_client_fqdn.cc.

References isc::dhcp::Option::operator=().

+ Here is the call graph for this function:

◆ pack()

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

Writes option in the wire format into a buffer.

Parameters
[out]bufoutput buffer where option data will be stored.

Reimplemented from isc::dhcp::Option.

Definition at line 406 of file option6_client_fqdn.cc.

References isc::dhcp::Option6ClientFqdnImpl::flags_, packDomainName(), isc::dhcp::Option::packHeader(), and isc::util::OutputBuffer::writeUint8().

+ Here is the call graph for this function:

◆ packDomainName()

void isc::dhcp::Option6ClientFqdn::packDomainName ( isc::util::OutputBuffer buf) const

Writes domain-name in the wire format into a buffer.

The data being written are appended at the end of the buffer.

Parameters
[out]bufbuffer where domain-name will be written.

Definition at line 371 of file option6_client_fqdn.cc.

References isc::dhcp::Option6ClientFqdnImpl::domain_name_, isc::dhcp::Option6ClientFqdnImpl::domain_name_type_, isc::dns::LabelSequence::getData(), isc::dns::LabelSequence::getDataLength(), PARTIAL, and isc::util::OutputBuffer::writeData().

Referenced by pack().

+ Here is the call graph for this function:

◆ resetDomainName()

void isc::dhcp::Option6ClientFqdn::resetDomainName ( )

Set empty domain-name.

This function is equivalent to Option6ClientFqdn::setDomainName with empty partial domain-name. It is exception safe.

Definition at line 396 of file option6_client_fqdn.cc.

References PARTIAL, and setDomainName().

+ Here is the call graph for this function:

◆ resetFlags()

void isc::dhcp::Option6ClientFqdn::resetFlags ( )

Sets the flag field value to 0.

Definition at line 355 of file option6_client_fqdn.cc.

References isc::dhcp::Option6ClientFqdnImpl::flags_.

◆ setDomainName()

void isc::dhcp::Option6ClientFqdn::setDomainName ( const std::string &  domain_name,
const DomainNameType  domain_name_type 
)

Set new domain-name.

Parameters
domain_namedomain name field value in the text format.
domain_name_typetype of the domain name: partial or fully qualified.

Definition at line 390 of file option6_client_fqdn.cc.

References isc::dhcp::Option6ClientFqdnImpl::setDomainName().

Referenced by isc::dhcp::Dhcpv6Srv::processClientFqdn(), and resetDomainName().

+ Here is the call graph for this function:

◆ setFlag()

void isc::dhcp::Option6ClientFqdn::setFlag ( const uint8_t  flag,
const bool  set 
)

Modifies the value of the specified DHCPv6 Client Fqdn Option flag.

This method sets the single bit of flags field. Therefore, a caller should use one of the: FLAG_S, FLAG_N, FLAG_O constants as an argument of the function. Attempt to use any other value (including combinations of these constants) will result in exception.

Parameters
flagA value specifying the flags bit to be modified. It can be one of the following: FLAG_S, FLAG_N, FLAG_O.
seta boolean value which indicates whether flag should be set (true), or cleared (false).

Definition at line 328 of file option6_client_fqdn.cc.

References isc::dhcp::Option6ClientFqdnImpl::checkFlags(), FLAG_MASK, isc::dhcp::Option6ClientFqdnImpl::flags_, and isc_throw.

+ Here is the call graph for this function:

◆ toText()

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

Returns string representation of the option.

The string returned by the method comprises the bit value of each option flag and the domain-name.

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

Reimplemented from isc::dhcp::Option.

Definition at line 427 of file option6_client_fqdn.cc.

References FLAG_N, FLAG_O, FLAG_S, getDomainName(), getDomainNameType(), getFlag(), PARTIAL, and isc::dhcp::Option::type_.

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

+ Here is the call graph for this function:

◆ unpack()

void isc::dhcp::Option6ClientFqdn::unpack ( OptionBufferConstIter  first,
OptionBufferConstIter  last 
)
virtual

Parses option from the received buffer.

Method creates an instance of the DHCPv6 Client FQDN Option from the wire format. Parameters specify the bounds of the buffer to read option data from. The size of the buffer limited by the specified parameters should be equal or larger than size of the option (including its header). Otherwise exception will be thrown.

Parameters
firstlower bound of the buffer to parse option from.
lastupper bound of the buffer to parse option from.

Reimplemented from isc::dhcp::Option.

Definition at line 416 of file option6_client_fqdn.cc.

References isc::dhcp::Option6ClientFqdnImpl::checkFlags(), isc::dhcp::Option6ClientFqdnImpl::flags_, isc::dhcp::Option6ClientFqdnImpl::parseWireData(), and isc::dhcp::Option::setData().

+ Here is the call graph for this function:

Member Data Documentation

◆ FLAG_FIELD_LEN

const uint16_t isc::dhcp::Option6ClientFqdn::FLAG_FIELD_LEN = 1
static

The length of the flag field within DHCPv6 Client Fqdn Option.

Definition at line 102 of file option6_client_fqdn.h.

Referenced by len(), and isc::dhcp::Option6ClientFqdnImpl::parseWireData().

◆ FLAG_MASK

const uint8_t isc::dhcp::Option6ClientFqdn::FLAG_MASK = 0x7
static

Mask which zeroes MBZ flag bits.

Definition at line 99 of file option6_client_fqdn.h.

Referenced by isc::dhcp::Option6ClientFqdnImpl::checkFlags(), and setFlag().

◆ FLAG_N

const uint8_t isc::dhcp::Option6ClientFqdn::FLAG_N = 0x04
static

N bit.

Definition at line 95 of file option6_client_fqdn.h.

Referenced by isc::dhcp::Option6ClientFqdnImpl::checkFlags(), getFlag(), and toText().

◆ FLAG_O

const uint8_t isc::dhcp::Option6ClientFqdn::FLAG_O = 0x02
static

O bit.

Definition at line 94 of file option6_client_fqdn.h.

Referenced by getFlag(), and toText().

◆ FLAG_S

const uint8_t isc::dhcp::Option6ClientFqdn::FLAG_S = 0x01
static

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