Kea 2.5.8
hwaddr.h
Go to the documentation of this file.
1// Copyright (C) 2013-2015 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
20struct 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
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
154typedef boost::shared_ptr<HWAddr> HWAddrPtr;
155
156}; // end of isc::dhcp namespace
157}; // end of isc namespace
158
159#endif // HWADDR_H
static const uint32_t HWADDR_SOURCE_UNKNOWN
Used when actual origin is not known, e.g.
Definition: hwaddr.h:41
static const uint32_t HWADDR_SOURCE_RAW
Obtained first hand from raw socket (100% reliable).
Definition: hwaddr.h:44
static const uint32_t HWADDR_SOURCE_REMOTE_ID
A relay can insert remote-id.
Definition: hwaddr.h:63
static const uint32_t HWADDR_SOURCE_CLIENT_ADDR_RELAY_OPTION
Get it from RFC6939 option.
Definition: hwaddr.h:59
static const uint32_t HWADDR_SOURCE_IPV6_LINK_LOCAL
Extracted from IPv6 link-local address.
Definition: hwaddr.h:53
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
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
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
static const uint32_t HWADDR_SOURCE_SUBSCRIBER_ID
A relay can insert a subscriber-id option.
Definition: hwaddr.h:67
static const uint32_t HWADDR_SOURCE_ANY
Not really a type, only used in getMAC() calls.
Definition: hwaddr.h:37
boost::shared_ptr< HWAddr > HWAddrPtr
Shared pointer to a hardware address structure.
Definition: hwaddr.h:154
@ HTYPE_ETHER
Ethernet 10Mbps.
Definition: dhcp4.h:56
Defines the logger used by the top-level component of kea-lfc.
Hardware type that represents information from DHCPv4 packet.
Definition: hwaddr.h:20
bool operator==(const HWAddr &other) const
Compares two hardware addresses for equality.
Definition: hwaddr.cc:75
static const size_t MAX_HWADDR_LEN
Maximum size of a hardware address.
Definition: hwaddr.h:27
static const size_t ETHERNET_HWADDR_LEN
Size of an ethernet hardware address.
Definition: hwaddr.h:24
uint16_t htype_
Hardware type.
Definition: hwaddr.h:105
HWAddr()
default constructor
Definition: hwaddr.cc:32
bool operator!=(const HWAddr &other) const
Compares two hardware addresses for inequality.
Definition: hwaddr.cc:80
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
std::vector< uint8_t > hwaddr_
Definition: hwaddr.h:98
uint32_t source_
Hardware address source.
Definition: hwaddr.h:113
std::string toText(bool include_htype=true) const
Returns textual representation of a hardware address (e.g.
Definition: hwaddr.cc:51