Kea: hwaddr.h Source File

| Kea 3.0.2-git

hwaddr.h
Go to the documentation of this file.
1// Copyright (C) 2013-2024 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#ifndef HWADDR_H
8#define HWADDR_H
9
10#include <vector>
11#include <stdint.h>
12#include <stddef.h>
13#include <dhcp/dhcp4.h>
14#include <boost/shared_ptr.hpp>
15
16namespace isc {
17namespace dhcp {
18
20 struct HWAddr {
21public:
22
24 static const size_t ETHERNET_HWADDR_LEN = 6;
25
27 static const size_t MAX_HWADDR_LEN = 20;
28
35
37 static const uint32_t HWADDR_SOURCE_ANY;
38
41 static const uint32_t HWADDR_SOURCE_UNKNOWN;
42
44 static const uint32_t HWADDR_SOURCE_RAW;
45
48 static const uint32_t HWADDR_SOURCE_DUID;
49
53 static const uint32_t HWADDR_SOURCE_IPV6_LINK_LOCAL;
54
59 static const uint32_t HWADDR_SOURCE_CLIENT_ADDR_RELAY_OPTION;
60
63 static const uint32_t HWADDR_SOURCE_REMOTE_ID;
64
67 static const uint32_t HWADDR_SOURCE_SUBSCRIBER_ID;
68
73 static const uint32_t HWADDR_SOURCE_DOCSIS_CMTS;
74
79 static const uint32_t HWADDR_SOURCE_DOCSIS_MODEM;
80
82
84 HWAddr();
85
90 HWAddr(const uint8_t* hwaddr, size_t len, uint16_t htype);
91
95 HWAddr(const std::vector<uint8_t>& hwaddr, uint16_t htype);
96
97 // Vector that keeps the actual hardware address
98 std::vector<uint8_t> hwaddr_;
99
105 uint16_t htype_;
106
113 uint32_t source_;
114
122 std::string toText(bool include_htype = true) const;
123
143 static HWAddr fromText(const std::string& text,
144 const uint16_t htype = HTYPE_ETHER);
145
147 bool operator==(const HWAddr& other) const;
148
150 bool operator!=(const HWAddr& other) const;
151};
152
154 typedef boost::shared_ptr<HWAddr> HWAddrPtr;
155
156} // namespace dhcp
157} // namespace isc
158
159#endif // HWADDR_H
dhcp4.h
isc::dhcp::HWAddr::HWADDR_SOURCE_UNKNOWN
static const uint32_t HWADDR_SOURCE_UNKNOWN
Used when actual origin is not known, e.g.
Definition hwaddr.h:41
isc::dhcp::HWAddr::HWADDR_SOURCE_RAW
static const uint32_t HWADDR_SOURCE_RAW
Obtained first hand from raw socket (100% reliable).
Definition hwaddr.h:44
isc::dhcp::HWAddr::HWADDR_SOURCE_REMOTE_ID
static const uint32_t HWADDR_SOURCE_REMOTE_ID
A relay can insert remote-id.
Definition hwaddr.h:63
isc::dhcp::HWAddr::HWADDR_SOURCE_CLIENT_ADDR_RELAY_OPTION
static const uint32_t HWADDR_SOURCE_CLIENT_ADDR_RELAY_OPTION
Get it from RFC6939 option.
Definition hwaddr.h:59
isc::dhcp::HWAddr::HWADDR_SOURCE_IPV6_LINK_LOCAL
static const uint32_t HWADDR_SOURCE_IPV6_LINK_LOCAL
Extracted from IPv6 link-local address.
Definition hwaddr.h:53
isc::dhcp::HWAddr::HWADDR_SOURCE_DOCSIS_MODEM
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...
Definition hwaddr.h:79
isc::dhcp::HWAddr::HWADDR_SOURCE_DUID
static const uint32_t HWADDR_SOURCE_DUID
Extracted from DUID-LL or DUID-LLT (not 100% reliable as the client can send fake DUID).
Definition hwaddr.h:48
isc::dhcp::HWAddr::HWADDR_SOURCE_DOCSIS_CMTS
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...
Definition hwaddr.h:73
isc::dhcp::HWAddr::HWADDR_SOURCE_SUBSCRIBER_ID
static const uint32_t HWADDR_SOURCE_SUBSCRIBER_ID
A relay can insert a subscriber-id option.
Definition hwaddr.h:67
isc::dhcp::HWAddr::HWADDR_SOURCE_ANY
static const uint32_t HWADDR_SOURCE_ANY
Not really a type, only used in getMAC() calls.
Definition hwaddr.h:37
isc::dhcp
Definition dhcp4/client_handler.cc:20
isc::dhcp::HWAddrPtr
boost::shared_ptr< HWAddr > HWAddrPtr
Shared pointer to a hardware address structure.
Definition hwaddr.h:154
isc::dhcp::HTYPE_ETHER
@ HTYPE_ETHER
Ethernet 10Mbps.
Definition dhcp4.h:56
isc
Defines the logger used by the top-level component of kea-lfc.
Definition agent_parser.cc:148
isc::dhcp::HWAddr::operator==
bool operator==(const HWAddr &other) const
Compares two hardware addresses for equality.
Definition hwaddr.cc:75
isc::dhcp::HWAddr::MAX_HWADDR_LEN
static const size_t MAX_HWADDR_LEN
Maximum size of a hardware address.
Definition hwaddr.h:27
isc::dhcp::HWAddr::ETHERNET_HWADDR_LEN
static const size_t ETHERNET_HWADDR_LEN
Size of an ethernet hardware address.
Definition hwaddr.h:24
isc::dhcp::HWAddr::htype_
uint16_t htype_
Hardware type.
Definition hwaddr.h:105
isc::dhcp::HWAddr::HWAddr
HWAddr()
default constructor
Definition hwaddr.cc:32
isc::dhcp::HWAddr::operator!=
bool operator!=(const HWAddr &other) const
Compares two hardware addresses for inequality.
Definition hwaddr.cc:80
isc::dhcp::HWAddr::fromText
static HWAddr fromText(const std::string &text, const uint16_t htype=HTYPE_ETHER)
Creates instance of the hardware address from textual format.
Definition hwaddr.cc:69
isc::dhcp::HWAddr::hwaddr_
std::vector< uint8_t > hwaddr_
Definition hwaddr.h:98
isc::dhcp::HWAddr::source_
uint32_t source_
Hardware address source.
Definition hwaddr.h:113
isc::dhcp::HWAddr::toText
std::string toText(bool include_htype=true) const
Returns textual representation of a hardware address (e.g.
Definition hwaddr.cc:51