Kea  2.1.7-git
duid.h
Go to the documentation of this file.
1 // Copyright (C) 2012-2018 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 DUID_H
8 #define DUID_H
9 
10 #include <asiolink/io_address.h>
11 #include <boost/shared_ptr.hpp>
12 #include <vector>
13 #include <stdint.h>
14 #include <unistd.h>
15 
16 namespace isc {
17 namespace dhcp {
18 
20 class DUID;
21 typedef boost::shared_ptr<DUID> DuidPtr;
22 
27 class DUID {
28  public:
31  static const size_t MAX_DUID_LEN = 128;
32 
35  static const size_t MIN_DUID_LEN = 1;
36 
38  typedef enum {
40  DUID_LLT = 1,
41  DUID_EN = 2,
42  DUID_LL = 3,
43  DUID_UUID = 4,
45  } DUIDType;
46 
48  DUID(const std::vector<uint8_t>& duid);
49 
51  DUID(const uint8_t* duid, size_t len);
52 
61  const std::vector<uint8_t>& getDuid() const;
62 
70  //
72  static const DUID& EMPTY();
73 
75  DUIDType getType() const;
76 
85  static DUID fromText(const std::string& text);
86 
88  std::string toText() const;
89 
91  bool operator==(const DUID& other) const;
92 
94  bool operator!=(const DUID& other) const;
95 
96  protected:
97 
99  std::vector<uint8_t> duid_;
100 };
101 
103 class ClientId;
105 typedef boost::shared_ptr<ClientId> ClientIdPtr;
106 
111 class ClientId : public DUID {
112 public:
113 
118  static const size_t MIN_CLIENT_ID_LEN = 2;
119 
128  static const size_t MAX_CLIENT_ID_LEN = DUID::MAX_DUID_LEN;
129 
131  ClientId(const std::vector<uint8_t>& clientid);
132 
134  ClientId(const uint8_t* clientid, size_t len);
135 
144  const std::vector<uint8_t>& getClientId() const;
145 
147  std::string toText() const;
148 
160  static ClientIdPtr fromText(const std::string& text);
161 
163  bool operator==(const ClientId& other) const;
164 
166  bool operator!=(const ClientId& other) const;
167 };
168 
169 }; // end of isc::dhcp namespace
170 }; // end of isc namespace
171 
172 #endif /* DUID_H */
boost::shared_ptr< DUID > DuidPtr
Definition: duid.h:20
link-layer + time, see RFC3315, section 11.2
Definition: duid.h:40
static const DUID & EMPTY()
Defines the constant "empty" DUID.
Definition: duid.cc:69
UUID, see RFC3315, section 11.5.
Definition: duid.h:43
bool operator==(const DUID &other) const
Compares two DUIDs for equality.
Definition: duid.cc:90
static DUID fromText(const std::string &text)
Create DUID from the textual format.
Definition: duid.cc:62
DUIDType getType() const
Returns the DUID type.
Definition: duid.cc:49
static const size_t MIN_DUID_LEN
minimum duid size The minimal DUID size specified in RFC 8415 is 1.
Definition: duid.h:35
Holds DUID (DHCPv6 Unique Identifier)
Definition: duid.h:27
DUIDType
specifies DUID type
Definition: duid.h:38
std::vector< uint8_t > duid_
The actual content of the DUID.
Definition: duid.h:99
not a real type, just maximum defined value + 1
Definition: duid.h:44
boost::shared_ptr< ClientId > ClientIdPtr
Shared pointer to a Client ID.
Definition: duid.h:103
link-layer, see RFC3315, section 11.4
Definition: duid.h:42
const std::vector< uint8_t > & getDuid() const
Returns a const reference to the actual DUID value.
Definition: duid.cc:46
Defines the logger used by the top-level component of kea-lfc.
static const size_t MAX_DUID_LEN
maximum duid size As defined in RFC 8415, section 11.1
Definition: duid.h:31
Holds Client identifier or client IPv4 address.
Definition: duid.h:111
enterprise-id, see RFC3315, section 11.3
Definition: duid.h:41
std::string toText() const
Returns textual representation of a DUID (e.g. 00:01:02:03:ff)
Definition: duid.cc:75
DUID(const std::vector< uint8_t > &duid)
Constructor from vector.
Definition: duid.cc:23
bool operator!=(const DUID &other) const
Compares two DUIDs for inequality.
Definition: duid.cc:94
invalid/unknown type
Definition: duid.h:39