Kea 2.7.5
|
Hardware type that represents information from DHCPv4 packet. More...
#include <hwaddr.h>
Public Member Functions | |
HWAddr () | |
default constructor | |
HWAddr (const std::vector< uint8_t > &hwaddr, uint16_t htype) | |
constructor, based on C++ vector<uint8_t> | |
HWAddr (const uint8_t *hwaddr, size_t len, uint16_t htype) | |
constructor, based on C-style pointer and length | |
bool | operator!= (const HWAddr &other) const |
Compares two hardware addresses for inequality. | |
bool | operator== (const HWAddr &other) const |
Compares two hardware addresses for equality. | |
std::string | toText (bool include_htype=true) const |
Returns textual representation of a hardware address (e.g. | |
Static Public Member Functions | |
static HWAddr | fromText (const std::string &text, const uint16_t htype=HTYPE_ETHER) |
Creates instance of the hardware address from textual format. | |
Public Attributes | |
uint16_t | htype_ |
Hardware type. | |
std::vector< uint8_t > | hwaddr_ |
uint32_t | source_ |
Hardware address source. | |
Static Public Attributes | |
static const size_t | ETHERNET_HWADDR_LEN = 6 |
Size of an ethernet hardware address. | |
static const uint32_t | HWADDR_SOURCE_ANY = 0xffffffff |
Not really a type, only used in getMAC() calls. | |
static const uint32_t | HWADDR_SOURCE_CLIENT_ADDR_RELAY_OPTION = 0x00000008 |
Get it from RFC6939 option. | |
static const uint32_t | HWADDR_SOURCE_DOCSIS_CMTS = 0x00000040 |
A CMTS (acting as DHCP relay agent) that supports DOCSIS standard can insert DOCSIS options that contain client's MAC address. | |
static const uint32_t | HWADDR_SOURCE_DOCSIS_MODEM = 0x00000080 |
A cable modem (acting as DHCP client) that supports DOCSIS standard can insert DOCSIS options that contain client's MAC address. | |
static const uint32_t | HWADDR_SOURCE_DUID = 0x00000002 |
Extracted from DUID-LL or DUID-LLT (not 100% reliable as the client can send fake DUID). | |
static const uint32_t | HWADDR_SOURCE_IPV6_LINK_LOCAL = 0x00000004 |
Extracted from IPv6 link-local address. | |
static const uint32_t | HWADDR_SOURCE_RAW = 0x00000001 |
Obtained first hand from raw socket (100% reliable). | |
static const uint32_t | HWADDR_SOURCE_REMOTE_ID = 0x00000010 |
A relay can insert remote-id. | |
static const uint32_t | HWADDR_SOURCE_SUBSCRIBER_ID = 0x00000020 |
A relay can insert a subscriber-id option. | |
static const uint32_t | HWADDR_SOURCE_UNKNOWN = 0x00000000 |
Used when actual origin is not known, e.g. | |
static const size_t | MAX_HWADDR_LEN = 20 |
Maximum size of a hardware address. | |
Hardware type that represents information from DHCPv4 packet.
isc::dhcp::HWAddr::HWAddr | ( | ) |
isc::dhcp::HWAddr::HWAddr | ( | const uint8_t * | hwaddr, |
size_t | len, | ||
uint16_t | htype ) |
constructor, based on C-style pointer and length
hwaddr | pointer to hardware address |
len | length of the address pointed by hwaddr |
htype | hardware type |
Definition at line 36 of file hwaddr.cc.
References isc_throw, and MAX_HWADDR_LEN.
isc::dhcp::HWAddr::HWAddr | ( | const std::vector< uint8_t > & | hwaddr, |
uint16_t | htype ) |
constructor, based on C++ vector<uint8_t>
hwaddr | const reference to hardware address |
htype | hardware type |
Definition at line 43 of file hwaddr.cc.
References isc_throw, and MAX_HWADDR_LEN.
|
static |
Creates instance of the hardware address from textual format.
This function parses HW address specified as text and creates the corresponding HWAddr
instance. The hexadecimal digits representing individual bytes of the hardware address should be separated with colons. Typically, two digits per byte are used. However, this function allows for 1 digit per HW address byte. In this case, the digit is prepended with '0' during conversion to binary value.
This function can be used to perform a reverse operation to the HWAddr::toText(false)
.
The instance created by this function sets HTYPE_ETHER as a hardware type.
text | HW address in the textual format. |
htype | Hardware type. |
Definition at line 69 of file hwaddr.cc.
References HWAddr(), and isc::util::str::decodeColonSeparatedHexString().
Referenced by isc::dhcp::Lease::fromElementCommon(), isc::lease_cmds::LeaseCmdsImpl::getParameters(), isc::lease_cmds::LeaseCmdsImpl::leaseGetByHwAddressHandler(), isc::lease_cmds::Lease4Parser::parse(), and isc::lease_cmds::Lease6Parser::parse().
bool isc::dhcp::HWAddr::operator!= | ( | const HWAddr & | other | ) | const |
bool isc::dhcp::HWAddr::operator== | ( | const HWAddr & | other | ) | const |
std::string isc::dhcp::HWAddr::toText | ( | bool | include_htype = true | ) | const |
Returns textual representation of a hardware address (e.g.
00:01:02:03:04:05)
include_htype | Boolean value which controls whether the hardware type is included in the returned string (true), or not (false). |
Definition at line 51 of file hwaddr.cc.
References htype_, and hwaddr_.
Referenced by isc::dhcp::Memfile_LeaseMgr::getLease4(), and isc::dhcp::Memfile_LeaseMgr::getLease4().
|
static |
Size of an ethernet hardware address.
Definition at line 24 of file hwaddr.h.
Referenced by isc::dhcp::decodeEthernetHeader(), and isc::dhcp::writeEthernetHeader().
uint16_t isc::dhcp::HWAddr::htype_ |
Hardware type.
Definition at line 105 of file hwaddr.h.
Referenced by operator==(), and toText().
std::vector<uint8_t> isc::dhcp::HWAddr::hwaddr_ |
Definition at line 98 of file hwaddr.h.
Referenced by user_chk::UserRegistry::findUser(), isc::dhcp::CSVLeaseFile4::next(), and toText().
|
static |
Maximum size of a hardware address.
Definition at line 27 of file hwaddr.h.
Referenced by HWAddr(), HWAddr(), isc::dhcp::Host::getIdentifierMaxLength(), and isc::dhcp::Pkt6::getMACFromRemoteIdRelayOption().
uint32_t isc::dhcp::HWAddr::source_ |