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

Static Public Member Functions

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

Static Public Attributes

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

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

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

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.

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:

user_chk::UserId::~UserId ( )

Destructor.

Definition at line 70 of file user.cc.

Member Function Documentation

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.

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<<().

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 137 of file user.cc.

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

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

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 119 of file user.cc.

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

Referenced by user_chk::operator<<().

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

Compares two UserIds for inequality.

Definition at line 108 of file user.cc.

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

Performs less than comparison of two UserIds.

Definition at line 113 of file user.cc.

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

Compares two UserIds for equality.

Definition at line 103 of file user.cc.

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

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(), and lookupTypeStr().

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(), and lookupTypeStr().


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