Kea  2.1.6-git
isc::dhcp::DUID Class Reference

Holds DUID (DHCPv6 Unique Identifier) More...

#include <duid.h>

+ Inheritance diagram for isc::dhcp::DUID:

Public Types

enum  DUIDType {
 specifies DUID type More...

Public Member Functions

 DUID (const std::vector< uint8_t > &duid)
 Constructor from vector. More...
 DUID (const uint8_t *duid, size_t len)
 Constructor from array and array size. More...
const std::vector< uint8_t > & getDuid () const
 Returns a const reference to the actual DUID value. More...
DUIDType getType () const
 Returns the DUID type. More...
bool operator!= (const DUID &other) const
 Compares two DUIDs for inequality. More...
bool operator== (const DUID &other) const
 Compares two DUIDs for equality. More...
std::string toText () const
 Returns textual representation of a DUID (e.g. 00:01:02:03:ff) More...

Static Public Member Functions

static const DUIDEMPTY ()
 Defines the constant "empty" DUID. More...
static DUID fromText (const std::string &text)
 Create DUID from the textual format. More...

Static Public Attributes

static const size_t MAX_DUID_LEN = 128
 maximum duid size As defined in RFC 8415, section 11.1 More...
static const size_t MIN_DUID_LEN = 1
 minimum duid size The minimal DUID size specified in RFC 8415 is 1. More...

Protected Attributes

std::vector< uint8_t > duid_
 The actual content of the DUID. More...

Detailed Description

Holds DUID (DHCPv6 Unique Identifier)

This class holds DUID, that is used in client-id, server-id and several other options. It is used to identify DHCPv6 entity.

Definition at line 27 of file duid.h.

Member Enumeration Documentation

◆ DUIDType

specifies DUID type


invalid/unknown type


link-layer + time, see RFC3315, section 11.2


enterprise-id, see RFC3315, section 11.3


link-layer, see RFC3315, section 11.4


UUID, see RFC3315, section 11.5.


not a real type, just maximum defined value + 1

Definition at line 38 of file duid.h.

Constructor & Destructor Documentation

◆ DUID() [1/2]

isc::dhcp::DUID::DUID ( const std::vector< uint8_t > &  duid)

Constructor from vector.

Definition at line 23 of file

References duid_, isc_throw, and MAX_DUID_LEN.

Referenced by fromText().

◆ DUID() [2/2]

isc::dhcp::DUID::DUID ( const uint8_t *  duid,
size_t  len 

Constructor from array and array size.

Definition at line 34 of file

References duid_, isc_throw, and MAX_DUID_LEN.

Member Function Documentation


const DUID & isc::dhcp::DUID::EMPTY ( )

Defines the constant "empty" DUID.

In general, empty DUID is not allowed. The only case where it is really valid is to designate declined IPv6 Leases. We have a broad assumption that the Lease->duid_ must always be set. However, declined lease doesn't have any DUID associated with it. Hence we need a way to indicate that fact.

reference to the static constant empty DUID

Definition at line 69 of file

Referenced by isc::dhcp::CSVLeaseFile6::append(), isc::dhcp::Lease6::decline(), and isc::dhcp::CSVLeaseFile6::next().

◆ fromText()

DUID isc::dhcp::DUID::fromText ( const std::string &  text)

Create DUID from the textual format.

This static function parses a DUID specified in the textual format.

textDUID in the hexadecimal format with digits representing individual bytes separated by colons.
isc::BadValueif parsing the DUID failed.

Definition at line 62 of file

References isc::util::str::decodeFormattedHexString(), and DUID().

Referenced by isc::dhcp::Lease6::fromElement(), isc::dhcp::DUIDFactory::get(), isc::lease_cmds::LeaseCmdsImpl::getParameters(), isc::lease_cmds::LeaseCmdsImpl::leaseGetByDuidHandler(), and isc::dhcp::CSVLeaseFile6::next().

+ Here is the call graph for this function:

◆ getDuid()

const std::vector< uint8_t > & isc::dhcp::DUID::getDuid ( ) const

Returns a const reference to the actual DUID value.

Since this function returns a reference to the vector (not a copy) the returned object must be used with caution because it remains valid only for the time period when the object which returned it is valid.
A reference to a vector holding a DUID.

Definition at line 46 of file

References duid_.

Referenced by user_chk::UserRegistry::findUser(), isc::dhcp_ddns::D2Dhcid::fromDUID(), isc::dhcp::Lease6::fromElement(), isc::dhcp::Memfile_LeaseMgr::getLease6(), isc::dhcp::Memfile_LeaseMgr::getLeases6(), isc::dhcp::PgSqlLeaseMgr::getLeases6(), and isc::dhcp::MySqlLeaseMgr::getLeases6().

◆ getType()

DUID::DUIDType isc::dhcp::DUID::getType ( ) const

Returns the DUID type.

Definition at line 49 of file

References duid_, DUID_MAX, and DUID_UNKNOWN.

◆ operator!=()

bool isc::dhcp::DUID::operator!= ( const DUID other) const

Compares two DUIDs for inequality.

Definition at line 94 of file

References duid_.

◆ operator==()

bool isc::dhcp::DUID::operator== ( const DUID other) const

Compares two DUIDs for equality.

Definition at line 90 of file

References duid_.

◆ toText()

std::string isc::dhcp::DUID::toText ( ) const

Member Data Documentation

◆ duid_

std::vector<uint8_t> isc::dhcp::DUID::duid_


const size_t isc::dhcp::DUID::MAX_DUID_LEN = 128

maximum duid size As defined in RFC 8415, section 11.1

Definition at line 31 of file duid.h.

Referenced by DUID(), and isc::dhcp::Dhcpv6Srv::sanityCheckDUID().


const size_t isc::dhcp::DUID::MIN_DUID_LEN = 1

minimum duid size The minimal DUID size specified in RFC 8415 is 1.

Definition at line 35 of file duid.h.

Referenced by isc::dhcp::DUIDFactory::createLL().

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