]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#2536] Add new option skeleton
authorPiotrek Zadroga <piotrek@isc.org>
Wed, 29 Mar 2023 15:16:02 +0000 (17:16 +0200)
committerPiotrek Zadroga <piotrek@isc.org>
Thu, 4 May 2023 21:17:18 +0000 (23:17 +0200)
src/lib/dhcp/Makefile.am
src/lib/dhcp/option_dnr.cc [new file with mode: 0644]
src/lib/dhcp/option_dnr.h [new file with mode: 0644]
src/lib/dhcp/std_option_defs.h

index a83d20d9ede58c9abb82a32776c72542dedcc5c9..1a2c5b418138bff330e90e5fe26431afcf7cdf3f 100644 (file)
@@ -35,6 +35,7 @@ libkea_dhcp___la_SOURCES += option.cc option.h
 libkea_dhcp___la_SOURCES += option_custom.cc option_custom.h
 libkea_dhcp___la_SOURCES += option_data_types.cc option_data_types.h
 libkea_dhcp___la_SOURCES += option_definition.cc option_definition.h
+libkea_dhcp___la_SOURCES += option_dnr.cc option_dnr.h
 libkea_dhcp___la_SOURCES += option_int.h
 libkea_dhcp___la_SOURCES += option_int_array.h
 libkea_dhcp___la_SOURCES += option_opaque_data_tuples.cc option_opaque_data_tuples.h
diff --git a/src/lib/dhcp/option_dnr.cc b/src/lib/dhcp/option_dnr.cc
new file mode 100644 (file)
index 0000000..7a336e7
--- /dev/null
@@ -0,0 +1,83 @@
+// Copyright (C) 2018-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/option_dnr.h>
+
+namespace isc {
+namespace dhcp {
+
+OptionDNR6::OptionDNR6(const uint16_t type) : Option(Universe::V6, type) {
+}
+
+OptionDNR6::OptionDNR6(const uint16_t type,
+                       OptionBufferConstIter begin,
+                       OptionBufferConstIter end) : Option(Universe::V6, type)  {
+    unpack(begin, end);
+}
+
+OptionPtr
+OptionDNR6::clone() const {
+    return Option::clone();
+}
+
+void
+OptionDNR6::pack(util::OutputBuffer& buf, bool check) const {
+    Option::pack(buf, check);
+}
+
+void
+OptionDNR6::unpack(OptionBufferConstIter begin, OptionBufferConstIter end) {
+    Option::unpack(begin, end);
+}
+
+std::string
+OptionDNR6::toText(int indent) const {
+    return Option::toText(indent);
+}
+
+uint16_t
+OptionDNR6::len() const {
+    return Option::len();
+}
+
+OptionDNR4::OptionDNR4(const uint16_t type) : Option(V4, type) {
+}
+
+OptionDNR4::OptionDNR4(const uint16_t type,
+                       OptionBufferConstIter begin,
+                       OptionBufferConstIter end) : Option(V4, type) {
+    unpack(begin, end);
+}
+
+OptionPtr
+OptionDNR4::clone() const {
+    return Option::clone();
+}
+
+void
+OptionDNR4::pack(util::OutputBuffer& buf, bool check) const {
+    Option::pack(buf, check);
+}
+
+void
+OptionDNR4::unpack(OptionBufferConstIter begin, OptionBufferConstIter end) {
+    Option::unpack(begin, end);
+}
+
+std::string
+OptionDNR4::toText(int indent) const {
+    return Option::toText(indent);
+}
+
+uint16_t
+OptionDNR4::len() const {
+    return Option::len();
+}
+
+}  // namespace dhcp
+}  // namespace isc
diff --git a/src/lib/dhcp/option_dnr.h b/src/lib/dhcp/option_dnr.h
new file mode 100644 (file)
index 0000000..3bf9eef
--- /dev/null
@@ -0,0 +1,44 @@
+// Copyright (C) 2018-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/.
+
+#ifndef OPTION_DNR_H
+#define OPTION_DNR_H
+
+#include <dhcp/option.h>
+
+namespace isc {
+namespace dhcp {
+
+class OptionDNR6 : public Option {
+    OptionDNR6(const uint16_t type);
+
+    OptionDNR6(const uint16_t type, OptionBufferConstIter begin, OptionBufferConstIter end);
+
+public:
+    virtual OptionPtr clone() const;
+    virtual void pack(util::OutputBuffer& buf, bool check) const;
+    virtual void unpack(OptionBufferConstIter begin, OptionBufferConstIter end);
+    virtual std::string toText(int indent) const;
+    virtual uint16_t len() const;
+};
+
+class OptionDNR4 : public Option {
+    OptionDNR4(const uint16_t type);
+
+    OptionDNR4(const uint16_t type, OptionBufferConstIter begin, OptionBufferConstIter end);
+
+public:
+    virtual OptionPtr clone() const;
+    virtual void pack(util::OutputBuffer& buf, bool check) const;
+    virtual void unpack(OptionBufferConstIter begin, OptionBufferConstIter end);
+    virtual std::string toText(int indent) const;
+    virtual uint16_t len() const;
+};
+
+}  // namespace dhcp
+}  // namespace isc
+
+#endif  // OPTION_DNR_H
index abe28a7f984caa29e5fb6390c18f1e17932bf0d2..1a14abe6f2edb28d0623449a6b35e0cbc1d1d1be 100644 (file)
@@ -111,8 +111,8 @@ RECORD_DECL(OPT_6RD_RECORDS, OPT_UINT8_TYPE, OPT_UINT8_TYPE,
 //
 // DNR Instance Data Length (2 octets), Service Priority (2 octets), ADN Length (1 octet),
 // authentication-domain-name FQDN(s), Addr Length (1 octet), IPv4 address(es), SvcParams
-RECORD_DECL(V4_DNR_RECORDS, OPT_UINT16_TYPE, OPT_UINT16_TYPE, OPT_UINT8_TYPE, OPT_FQDN_TYPE,
-            OPT_UINT8_TYPE, OPT_IPV4_ADDRESS_TYPE, OPT_BINARY_TYPE);
+//RECORD_DECL(V4_DNR_RECORDS, OPT_UINT16_TYPE, OPT_UINT16_TYPE, OPT_UINT8_TYPE, OPT_FQDN_TYPE,
+//            OPT_UINT8_TYPE, OPT_IPV4_ADDRESS_TYPE, OPT_BINARY_TYPE);
 
 /// @brief Definitions of standard DHCPv4 options.
 const OptionDefParams STANDARD_V4_OPTION_DEFINITIONS[] = {
@@ -373,8 +373,8 @@ const OptionDefParams STANDARD_V4_OPTION_DEFINITIONS[] = {
       OPT_UINT8_TYPE, false, NO_RECORD_DEF, "" },
     { "v4-portparams", DHO_V4_PORTPARAMS, DHCP4_OPTION_SPACE, OPT_RECORD_TYPE,
       false, RECORD_DEF(V4_PORTPARAMS_RECORDS), "" },
-    { "v4-dnr", DHO_V4_DNR, DHCP4_OPTION_SPACE, OPT_RECORD_TYPE,
-     true, RECORD_DEF(V4_DNR_RECORDS), "" },
+    { "v4-dnr", DHO_V4_DNR, DHCP4_OPTION_SPACE, OPT_TUPLE_TYPE,
+     true, NO_RECORD_DEF, "" },
     { "option-6rd", DHO_6RD, DHCP4_OPTION_SPACE, OPT_RECORD_TYPE, true,
       RECORD_DEF(OPT_6RD_RECORDS), "" },
     { "v4-access-domain", DHO_V4_ACCESS_DOMAIN, DHCP4_OPTION_SPACE,