37 :hwaddr_(hwaddr, hwaddr + len), htype_(htype), source_(0) {
44 :hwaddr_(hwaddr), htype_(htype), source_(0) {
47 "address vector size exceeds MAX_HWADDR_LEN");
52 std::stringstream tmp;
54 tmp <<
"hwtype=" <<
static_cast<unsigned int>(
htype_) <<
" ";
58 for (
auto const& it :
hwaddr_) {
62 tmp << std::setw(2) << std::setfill('0') << static_cast<unsigned int>(it);
70 std::vector<uint8_t> binary;
72 return (
HWAddr(binary, htype));
77 (this->hwaddr_ == other.hwaddr_));
81 return !(*
this == other);
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
static const uint32_t HWADDR_SOURCE_UNKNOWN
Used when actual origin is not known, e.g.
static const uint32_t HWADDR_SOURCE_RAW
Obtained first hand from raw socket (100% reliable).
static const uint32_t HWADDR_SOURCE_REMOTE_ID
A relay can insert remote-id.
static const uint32_t HWADDR_SOURCE_CLIENT_ADDR_RELAY_OPTION
Get it from RFC6939 option.
static const uint32_t HWADDR_SOURCE_IPV6_LINK_LOCAL
Extracted from IPv6 link-local address.
static const uint32_t HWADDR_SOURCE_DOCSIS_MODEM
A cable modem (acting as DHCP client) that supports DOCSIS standard can insert DOCSIS options that co...
static const uint32_t HWADDR_SOURCE_DUID
Extracted from DUID-LL or DUID-LLT (not 100% reliable as the client can send fake DUID).
static const uint32_t HWADDR_SOURCE_DOCSIS_CMTS
A CMTS (acting as DHCP relay agent) that supports DOCSIS standard can insert DOCSIS options that cont...
static const uint32_t HWADDR_SOURCE_SUBSCRIBER_ID
A relay can insert a subscriber-id option.
static const uint32_t HWADDR_SOURCE_ANY
Not really a type, only used in getMAC() calls.
@ HTYPE_ETHER
Ethernet 10Mbps.
void decodeColonSeparatedHexString(const string &hex_string, vector< uint8_t > &binary)
Converts a string of hexadecimal digits with colons into a vector.
Defines the logger used by the top-level component of kea-lfc.
Hardware type that represents information from DHCPv4 packet.
bool operator==(const HWAddr &other) const
Compares two hardware addresses for equality.
static const size_t MAX_HWADDR_LEN
Maximum size of a hardware address.
uint16_t htype_
Hardware type.
HWAddr()
default constructor
bool operator!=(const HWAddr &other) const
Compares two hardware addresses for inequality.
static HWAddr fromText(const std::string &text, const uint16_t htype=HTYPE_ETHER)
Creates instance of the hardware address from textual format.
std::vector< uint8_t > hwaddr_
std::string toText(bool include_htype=true) const
Returns textual representation of a hardware address (e.g.