Kea 2.5.8
user_chk::UserId Class Reference

Encapsulates a unique identifier for a DHCP client. More...

#include <user.h>

Public Types

enum  UserIdType { HW_ADDRESS = 0 , DUID = 1 }
 Defines the supported types of user ids. More...
 

Public Member Functions

 UserId (UserIdType id_type, const std::string &id_str)
 Constructor.
 
 UserId (UserIdType id_type, const std::vector< uint8_t > &id)
 Constructor.
 
 ~UserId ()
 Destructor.
 
const std::vector< uint8_t > & getId () const
 Returns a const reference to the actual id value.
 
UserIdType getType () const
 Returns the user id type.
 
bool operator!= (const UserId &other) const
 Compares two UserIds for inequality.
 
bool operator< (const UserId &other) const
 Performs less than comparison of two UserIds.
 
bool operator== (const UserId &other) const
 Compares two UserIds for equality.
 
std::string toText (char delim_char=0x0) const
 Returns textual representation of the id.
 

Static Public Member Functions

static UserIdType lookupType (const std::string &type_str)
 Returns the id type for a given text label.
 
static std::string lookupTypeStr (UserIdType type)
 Returns the text label for a given id type.
 

Static Public Attributes

static const char * DUID_STR = "DUID"
 Define the text label DUID id type.
 
static const char * HW_ADDRESS_STR = "HW_ADDR"
 Defines the text label hardware address id type.
 

Detailed Description

Encapsulates a unique identifier for a DHCP client.

This class provides a generic wrapper around the information used to uniquely identify the requester in a DHCP request packet. It provides the necessary operators such that it can be used as a key within STL containers such as maps. It supports both IPv4 and IPv6 clients.

Definition at line 27 of file user.h.

Member Enumeration Documentation

◆ UserIdType

Defines the supported types of user ids.

Enumerator
HW_ADDRESS 

Hardware addresses (MAC) are used for IPv4 clients.

DUID 

DUIDs are used for IPv6 clients.

Definition at line 32 of file user.h.

Constructor & Destructor Documentation

◆ UserId() [1/2]

user_chk::UserId::UserId ( UserIdType  id_type,
const std::vector< uint8_t > &  id 
)

Constructor.

Constructs a UserId from an id type and id vector.

Parameters
id_typeThe type of user id contained in vector
ida vector of unsigned bytes containing the id
Exceptions
isc::BadValueif the vector is empty.

Definition at line 26 of file user.cc.

References isc_throw.

◆ UserId() [2/2]

user_chk::UserId::UserId ( UserIdType  id_type,
const std::string &  id_str 
)

Constructor.

Constructs a UserId from an id type and id string.

Parameters
id_typeThe type of user id contained in string. The string is expected to contain an even number of hex digits with or without colon (':') as a delimiter.
id_strstring of hex digits representing the user's id
Exceptions
isc::BadValueif the string is empty, contains non valid hex digits, or an odd number of hex digits.

Definition at line 33 of file user.cc.

References isc::util::encode::decodeHex(), DUID, isc::dhcp::HTYPE_ETHER, HW_ADDRESS, and isc_throw.

+ Here is the call graph for this function:

◆ ~UserId()

user_chk::UserId::~UserId ( )

Destructor.

Definition at line 70 of file user.cc.

Member Function Documentation

◆ getId()

const std::vector< uint8_t > & user_chk::UserId::getId ( ) const

Returns a const reference to the actual id value.

Definition at line 74 of file user.cc.

◆ getType()

UserId::UserIdType user_chk::UserId::getType ( ) const

Returns the user id type.

Definition at line 79 of file user.cc.

Referenced by user_chk::operator<<().

◆ lookupType()

UserId::UserIdType user_chk::UserId::lookupType ( const std::string &  type_str)
static

Returns the id type for a given text label.

Parameters
type_strThe text label for which the id value is desired
Exceptions
isc::BadValueif type_str is not a valid text label.

Definition at line 136 of file user.cc.

References DUID, DUID_STR, HW_ADDRESS, HW_ADDRESS_STR, and isc_throw.

Referenced by user_chk::UserFile::makeUser().

◆ lookupTypeStr()

std::string user_chk::UserId::lookupTypeStr ( UserIdType  type)
static

Returns the text label for a given id type.

Parameters
typeThe id type value for which the label is desired
Exceptions
isc::BadValueif type is not valid.

Definition at line 118 of file user.cc.

References DUID, DUID_STR, HW_ADDRESS, HW_ADDRESS_STR, and isc_throw.

Referenced by user_chk::operator<<().

◆ operator!=()

bool user_chk::UserId::operator!= ( const UserId other) const

Compares two UserIds for inequality.

Definition at line 107 of file user.cc.

◆ operator<()

bool user_chk::UserId::operator< ( const UserId other) const

Performs less than comparison of two UserIds.

Definition at line 111 of file user.cc.

◆ operator==()

bool user_chk::UserId::operator== ( const UserId other) const

Compares two UserIds for equality.

Definition at line 102 of file user.cc.

◆ toText()

std::string user_chk::UserId::toText ( char  delim_char = 0x0) const

Returns textual representation of the id.

Outputs a string of hex digits representing the id with an optional delimiter between digit pairs (i.e. bytes).

Without a delimiter: "0c220F"

with colon as a delimiter: "0c:22:0F"

Parameters
delim_charThe delimiter to place in between "bytes". It defaults to none. (e.g. 00010203ff)

Definition at line 84 of file user.cc.

Referenced by user_chk::operator<<().

Member Data Documentation

◆ DUID_STR

const char * user_chk::UserId::DUID_STR = "DUID"
static

Define the text label DUID id type.

Definition at line 42 of file user.h.

Referenced by lookupType(), lookupTypeStr(), and pkt6_send().

◆ HW_ADDRESS_STR

const char * user_chk::UserId::HW_ADDRESS_STR = "HW_ADDR"
static

Defines the text label hardware address id type.

Definition at line 40 of file user.h.

Referenced by lookupType(), lookupTypeStr(), and pkt4_send().


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