From: Piotrek Zadroga Date: Wed, 29 Mar 2023 15:16:02 +0000 (+0200) Subject: [#2536] Add new option skeleton X-Git-Tag: Kea-2.3.8~188 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=777ef398e4ae20db28e581b3599b21d16f415d80;p=thirdparty%2Fkea.git [#2536] Add new option skeleton --- diff --git a/src/lib/dhcp/Makefile.am b/src/lib/dhcp/Makefile.am index a83d20d9ed..1a2c5b4181 100644 --- a/src/lib/dhcp/Makefile.am +++ b/src/lib/dhcp/Makefile.am @@ -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 index 0000000000..7a336e741e --- /dev/null +++ b/src/lib/dhcp/option_dnr.cc @@ -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 + +#include + +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 index 0000000000..3bf9eefada --- /dev/null +++ b/src/lib/dhcp/option_dnr.h @@ -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 + +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 diff --git a/src/lib/dhcp/std_option_defs.h b/src/lib/dhcp/std_option_defs.h index abe28a7f98..1a14abe6f2 100644 --- a/src/lib/dhcp/std_option_defs.h +++ b/src/lib/dhcp/std_option_defs.h @@ -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,