summaryrefslogtreecommitdiffstats
path: root/src/lib/dhcp/duid.cc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 12:15:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 12:15:43 +0000
commitf5f56e1a1c4d9e9496fcb9d81131066a964ccd23 (patch)
tree49e44c6f87febed37efb953ab5485aa49f6481a7 /src/lib/dhcp/duid.cc
parentInitial commit. (diff)
downloadisc-kea-f5f56e1a1c4d9e9496fcb9d81131066a964ccd23.tar.xz
isc-kea-f5f56e1a1c4d9e9496fcb9d81131066a964ccd23.zip
Adding upstream version 2.4.1.upstream/2.4.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/lib/dhcp/duid.cc')
-rw-r--r--src/lib/dhcp/duid.cc79
1 files changed, 79 insertions, 0 deletions
diff --git a/src/lib/dhcp/duid.cc b/src/lib/dhcp/duid.cc
new file mode 100644
index 0000000..2338118
--- /dev/null
+++ b/src/lib/dhcp/duid.cc
@@ -0,0 +1,79 @@
+// Copyright (C) 2012-2023 Internet Systems Consortium, Inc. ("ISC")
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+#include <config.h>
+
+#include <dhcp/duid.h>
+#include <exceptions/exceptions.h>
+#include <util/io_utilities.h>
+#include <iomanip>
+#include <cctype>
+#include <sstream>
+#include <vector>
+
+#include <stdint.h>
+
+namespace isc {
+namespace dhcp {
+
+IdentifierBaseType::~IdentifierBaseType() {
+}
+
+constexpr size_t DUID::MIN_DUID_LEN;
+constexpr size_t DUID::MAX_DUID_LEN;
+
+DUID::DUID(const std::vector<uint8_t>& data) : IdentifierType<3, 130>(data) {
+}
+
+DUID::DUID(const uint8_t* data, size_t len) : IdentifierType<3, 130>(data, len) {
+}
+
+const std::vector<uint8_t>& DUID::getDuid() const {
+ return (data_);
+}
+
+DUID::DUIDType DUID::getType() const {
+ if (data_.size() < 2) {
+ return (DUID_UNKNOWN);
+ }
+ uint16_t type = (data_[0] << 8) + data_[1];
+ if (type < DUID_MAX) {
+ return (static_cast<DUID::DUIDType>(type));
+ } else {
+ return (DUID_UNKNOWN);
+ }
+}
+
+DUID
+DUID::fromText(const std::string& text) {
+ return (DUID(IdentifierType::fromText(text)));
+}
+
+const DUID&
+DUID::EMPTY() {
+ static DUID empty({0, 0, 0});
+ return (empty);
+}
+
+constexpr size_t ClientId::MIN_CLIENT_ID_LEN;
+constexpr size_t ClientId::MAX_CLIENT_ID_LEN;
+
+ClientId::ClientId(const std::vector<uint8_t>& data) : IdentifierType<2, 255>(data) {
+}
+
+ClientId::ClientId(const uint8_t *data, size_t len) : IdentifierType<2, 255>(data, len) {
+}
+
+const std::vector<uint8_t>& ClientId::getClientId() const {
+ return (data_);
+}
+
+ClientIdPtr ClientId::fromText(const std::string& text) {
+ return (ClientIdPtr(new ClientId(IdentifierType::fromText(text))));
+}
+
+} // namespace dhcp
+} // namespace isc