Kea 2.7.5
|
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. | |
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.
user_chk::UserId::UserId | ( | UserIdType | id_type, |
const std::vector< uint8_t > & | id ) |
Constructor.
Constructs a UserId from an id type and id vector.
id_type | The type of user id contained in vector |
id | a vector of unsigned bytes containing the id |
isc::BadValue | if 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.
id_type | The 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_str | string of hex digits representing the user's id |
isc::BadValue | if 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.
const std::vector< uint8_t > & user_chk::UserId::getId | ( | ) | const |
UserId::UserIdType user_chk::UserId::getType | ( | ) | const |
|
static |
Returns the id type for a given text label.
type_str | The text label for which the id value is desired |
isc::BadValue | if 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().
|
static |
Returns the text label for a given id type.
type | The id type value for which the label is desired |
isc::BadValue | if 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<<().
bool user_chk::UserId::operator!= | ( | const UserId & | other | ) | const |
bool user_chk::UserId::operator< | ( | const UserId & | other | ) | const |
bool user_chk::UserId::operator== | ( | const UserId & | other | ) | const |
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"
delim_char | The delimiter to place in between "bytes". It defaults to none. (e.g. 00010203ff) |
|
static |
Define the text label DUID id type.
Definition at line 42 of file user.h.
Referenced by lookupType(), lookupTypeStr(), and pkt6_send().
|
static |
Defines the text label hardware address id type.
Definition at line 40 of file user.h.
Referenced by lookupType(), lookupTypeStr(), and pkt4_send().