Kea 2.2.0
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
16namespace isc {
17namespace dhcp {
18
20class DUID;
21typedef boost::shared_ptr<DUID> DuidPtr;
22
27class 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 {
41 DUID_EN = 2,
42 DUID_LL = 3,
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
103class ClientId;
105typedef boost::shared_ptr<ClientId> ClientIdPtr;
106
111class ClientId : public DUID {
112public:
113
118 static const size_t MIN_CLIENT_ID_LEN = 2;
119
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 */
Holds Client identifier or client IPv4 address.
Definition: duid.h:111
static const size_t MAX_CLIENT_ID_LEN
Maximum size of a client ID.
Definition: duid.h:128
const std::vector< uint8_t > & getClientId() const
Returns reference to the client-id data.
Definition: duid.cc:117
bool operator==(const ClientId &other) const
Compares two client-ids for equality.
Definition: duid.cc:139
static ClientIdPtr fromText(const std::string &text)
Create client identifier from the textual format.
Definition: duid.cc:132
bool operator!=(const ClientId &other) const
Compares two client-ids for inequality.
Definition: duid.cc:144
std::string toText() const
Returns textual representation of a DUID (e.g. 00:01:02:03:ff)
Definition: duid.cc:122
ClientId(const std::vector< uint8_t > &clientid)
Constructor based on vector<uint8_t>
Definition: duid.cc:99
static const size_t MIN_CLIENT_ID_LEN
Minimum size of a client ID.
Definition: duid.h:118
Holds DUID (DHCPv6 Unique Identifier)
Definition: duid.h:27
bool operator!=(const DUID &other) const
Compares two DUIDs for inequality.
Definition: duid.cc:94
static const size_t MIN_DUID_LEN
minimum duid size The minimal DUID size specified in RFC 8415 is 1.
Definition: duid.h:35
bool operator==(const DUID &other) const
Compares two DUIDs for equality.
Definition: duid.cc:90
std::string toText() const
Returns textual representation of a DUID (e.g. 00:01:02:03:ff)
Definition: duid.cc:75
static DUID fromText(const std::string &text)
Create DUID from the textual format.
Definition: duid.cc:62
DUID(const std::vector< uint8_t > &duid)
Constructor from vector.
Definition: duid.cc:23
static const DUID & EMPTY()
Defines the constant "empty" DUID.
Definition: duid.cc:69
static const size_t MAX_DUID_LEN
maximum duid size As defined in RFC 8415, section 11.1
Definition: duid.h:31
std::vector< uint8_t > duid_
The actual content of the DUID.
Definition: duid.h:99
DUIDType
specifies DUID type
Definition: duid.h:38
@ DUID_LL
link-layer, see RFC3315, section 11.4
Definition: duid.h:42
@ DUID_LLT
link-layer + time, see RFC3315, section 11.2
Definition: duid.h:40
@ DUID_MAX
not a real type, just maximum defined value + 1
Definition: duid.h:44
@ DUID_UNKNOWN
invalid/unknown type
Definition: duid.h:39
@ DUID_EN
enterprise-id, see RFC3315, section 11.3
Definition: duid.h:41
@ DUID_UUID
UUID, see RFC3315, section 11.5.
Definition: duid.h:43
const std::vector< uint8_t > & getDuid() const
Returns a const reference to the actual DUID value.
Definition: duid.cc:46
DUIDType getType() const
Returns the DUID type.
Definition: duid.cc:49
boost::shared_ptr< DUID > DuidPtr
Definition: duid.h:20
boost::shared_ptr< ClientId > ClientIdPtr
Shared pointer to a Client ID.
Definition: duid.h:103
Defines the logger used by the top-level component of kea-lfc.