Kea 2.5.9
duid.cc
Go to the documentation of this file.
1// Copyright (C) 2012-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#include <config.h>
8
9#include <dhcp/duid.h>
11#include <iomanip>
12#include <cctype>
13#include <sstream>
14#include <vector>
15
16#include <stdint.h>
17
18namespace isc {
19namespace dhcp {
20
22}
23
24constexpr size_t DUID::MIN_DUID_LEN;
25constexpr size_t DUID::MAX_DUID_LEN;
26
27DUID::DUID(const std::vector<uint8_t>& data) : IdentifierType<3, 130>(data) {
28}
29
30DUID::DUID(const uint8_t* data, size_t len) : IdentifierType<3, 130>(data, len) {
31}
32
33const std::vector<uint8_t>& DUID::getDuid() const {
34 return (data_);
35}
36
38 if (data_.size() < 2) {
39 return (DUID_UNKNOWN);
40 }
41 uint16_t type = (data_[0] << 8) + data_[1];
42 if (type < DUID_MAX) {
43 return (static_cast<DUID::DUIDType>(type));
44 } else {
45 return (DUID_UNKNOWN);
46 }
47}
48
49DUID
50DUID::fromText(const std::string& text) {
51 return (DUID(IdentifierType::fromText(text)));
52}
53
54const DUID&
56 static DUID empty({0, 0, 0});
57 return (empty);
58}
59
60constexpr size_t ClientId::MIN_CLIENT_ID_LEN;
61constexpr size_t ClientId::MAX_CLIENT_ID_LEN;
62
63ClientId::ClientId(const std::vector<uint8_t>& data) : IdentifierType<2, 255>(data) {
64}
65
66ClientId::ClientId(const uint8_t *data, size_t len) : IdentifierType<2, 255>(data, len) {
67}
68
69const std::vector<uint8_t>& ClientId::getClientId() const {
70 return (data_);
71}
72
73ClientIdPtr ClientId::fromText(const std::string& text) {
75}
76
77} // namespace dhcp
78} // namespace isc
Holds Client identifier or client IPv4 address.
Definition: duid.h:222
static constexpr size_t MAX_CLIENT_ID_LEN
Maximum size of a client ID.
Definition: duid.h:235
const std::vector< uint8_t > & getClientId() const
Returns reference to the client-id data.
Definition: duid.cc:69
ClientId(const std::vector< uint8_t > &data)
Constructor based on vector<uint8_t>
Definition: duid.cc:63
static ClientIdPtr fromText(const std::string &text)
Create client identifier from the textual format.
Definition: duid.cc:73
static constexpr size_t MIN_CLIENT_ID_LEN
Minimum size of a client ID.
Definition: duid.h:229
Holds DUID (DHCPv6 Unique Identifier)
Definition: duid.h:142
static constexpr size_t MIN_DUID_LEN
minimum duid size
Definition: duid.h:149
static DUID fromText(const std::string &text)
Create DUID from the textual format.
Definition: duid.cc:50
static const DUID & EMPTY()
Defines the constant "empty" DUID.
Definition: duid.cc:55
static constexpr size_t MAX_DUID_LEN
maximum duid size
Definition: duid.h:155
DUIDType
specifies DUID type
Definition: duid.h:158
@ DUID_MAX
not a real type, just maximum defined value + 1
Definition: duid.h:164
@ DUID_UNKNOWN
invalid/unknown type
Definition: duid.h:159
const std::vector< uint8_t > & getDuid() const
Returns a const reference to the actual DUID value.
Definition: duid.cc:33
DUIDType getType() const
Returns the DUID type.
Definition: duid.cc:37
DUID(const std::vector< uint8_t > &data)
Constructor from vector.
Definition: duid.cc:27
virtual ~IdentifierBaseType()=0
Pure virtual destructor.
Definition: duid.cc:21
std::vector< uint8_t > data_
The actual content of the Identifier.
Definition: duid.h:131
static std::vector< uint8_t > fromText(const std::string &text)
This static function parses an Identifier specified in the textual format.
Definition: duid.h:108
boost::shared_ptr< ClientId > ClientIdPtr
Shared pointer to a Client ID.
Definition: duid.h:216
Defines the logger used by the top-level component of kea-lfc.