]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3141] make dnr options type internal
authorPiotrek Zadroga <piotrek@isc.org>
Mon, 12 Feb 2024 13:14:44 +0000 (14:14 +0100)
committerPiotrek Zadroga <piotrek@isc.org>
Fri, 23 Feb 2024 16:14:05 +0000 (17:14 +0100)
src/lib/dhcp/option4_dnr.cc
src/lib/dhcp/option4_dnr.h
src/lib/dhcp/option6_dnr.cc
src/lib/dhcp/option6_dnr.h
src/lib/dhcp/option_definition.cc
src/lib/dhcp/std_option_defs.h

index 794572f873ed119ba8eb67fe96a3bc13d7ac6452..a848d92d92be57943de1524e1d87119e7bb30611 100644 (file)
@@ -16,8 +16,10 @@ using namespace isc::util;
 namespace isc {
 namespace dhcp {
 
-Option4Dnr::Option4Dnr(OptionBufferConstIter begin, OptionBufferConstIter end)
-    : Option(V4, DHO_V4_DNR) {
+Option4Dnr::Option4Dnr(OptionBufferConstIter begin,
+                       OptionBufferConstIter end,
+                       bool convenient_notation)
+    : Option(V4, DHO_V4_DNR), convenient_notation_(convenient_notation) {
     unpack(begin, end);
 }
 
index f8434cec17b1d3e138bca2de5281954a70773164..221a5ee8ccfc07d6be0203560f547fb639904568 100644 (file)
@@ -464,12 +464,17 @@ public:
     /// @param begin Iterator pointing to the beginning of the buffer holding an
     /// option.
     /// @param end Iterator pointing to the end of the buffer holding an option.
+    /// @param convenient_notation Flag stating whether data in buffer is a convenient
+    ///                            notation string that needs custom parsing or binary
+    ///                            data. Defaults to @c false.
     ///
     /// @throw OutOfRange Thrown in case of truncated data. May be also thrown when
     /// @c DnrInstance::unpackDnrInstanceDataLength(begin,end) throws.
     /// @throw BadValue Thrown when @c DnrInstance::unpackAdn(begin,end) throws.
     /// @throw InvalidOptionDnrDomainName Thrown when @c DnrInstance::unpackAdn(begin,end) throws.
-    Option4Dnr(OptionBufferConstIter begin, OptionBufferConstIter end);
+    Option4Dnr(OptionBufferConstIter begin,
+               OptionBufferConstIter end,
+               bool convenient_notation = false);
 
     /// @brief Constructor of the empty %Option.
     ///
@@ -536,6 +541,11 @@ public:
 protected:
     /// @brief Container holding DNR Instances.
     DnrInstanceContainer dnr_instances_;
+
+private:
+    /// @brief Flag stating whether the %Option was constructed with a convenient notation string,
+    /// that needs custom parsing, or binary data.
+    bool convenient_notation_;
 };
 
 /// A pointer to the @c OptionDnr4 object.
index 1358ee5afb06878eca8bfc6296ffade4aed1d769..389c3adeb276a409e0e93522fa703b01a823d4b9 100644 (file)
@@ -13,8 +13,10 @@ using namespace isc::asiolink;
 namespace isc {
 namespace dhcp {
 
-Option6Dnr::Option6Dnr(OptionBufferConstIter begin, OptionBufferConstIter end)
-    : Option(V6, D6O_V6_DNR), DnrInstance(V6) {
+Option6Dnr::Option6Dnr(OptionBufferConstIter begin,
+                       OptionBufferConstIter end,
+                       bool convenient_notation)
+    : Option(V6, D6O_V6_DNR), DnrInstance(V6), convenient_notation_(convenient_notation) {
     unpack(begin, end);
 }
 
index 6cf38e579ab1539038505f044e099ef77d7eca6d..f7fbeaa4d45c96b78011be92645589e55b06339d 100644 (file)
@@ -34,11 +34,16 @@ public:
     /// @param begin Iterator pointing to the beginning of the buffer holding an
     /// option.
     /// @param end Iterator pointing to the end of the buffer holding an option.
+    /// @param convenient_notation Flag stating whether data in buffer is a convenient
+    ///                            notation string that needs custom parsing or binary
+    ///                            data. Defaults to @c false.
     ///
     /// @throw OutOfRange Thrown in case of truncated data.
     /// @throw BadValue Thrown when @c DnrInstance::unpackAdn(begin,end) throws.
     /// @throw InvalidOptionDnrDomainName Thrown when @c DnrInstance::unpackAdn(begin,end) throws.
-    Option6Dnr(OptionBufferConstIter begin, OptionBufferConstIter end);
+    Option6Dnr(OptionBufferConstIter begin,
+               OptionBufferConstIter end,
+               bool convenient_notation = false);
 
     /// @brief Constructor of the %Option with all fields from params.
     ///
@@ -136,6 +141,11 @@ public:
     /// @throw OutOfRange Thrown in case of malformed data detected during parsing e.g.
     /// Addr Len not divisible by 16, Addr Len is 0, addresses data truncated etc.
     void unpackAddresses(OptionBufferConstIter& begin, OptionBufferConstIter end) override;
+
+private:
+    /// @brief Flag stating whether the %Option was constructed with a convenient notation string,
+    /// that needs custom parsing, or binary data.
+    bool convenient_notation_;
 };
 
 /// A pointer to the @c Option6Dnr object.
index d07d61da71d9f6e0b0489fca0df27a9d48a5f7b8..1a0f0d7da42657cc50c71242e37c46dd3e2db312 100644 (file)
@@ -893,7 +893,7 @@ OptionDefinition::factorySpecialFormatOption(Option::Universe u,
             return (OptionPtr(new Option6PDExclude(begin, end)));
 
         case D6O_V6_DNR:
-            return (OptionPtr(new Option6Dnr(begin, end)));
+            return (OptionPtr(new Option6Dnr(begin, end, convenient_notation)));
 
         default:
             break;
@@ -927,7 +927,7 @@ OptionDefinition::factorySpecialFormatOption(Option::Universe u,
             return (factoryOpaqueDataTuples(Option::V4, getCode(), begin, end, OpaqueDataTuple::LENGTH_2_BYTES));
 
         case DHO_V4_DNR:
-            return (OptionPtr(new Option4Dnr(begin, end)));
+            return (OptionPtr(new Option4Dnr(begin, end, convenient_notation)));
 
         default:
             break;
index c2c5de914814227dd549915b3ec4dd2331ec86a3..145784549911a3478a80a7bc35405be73b472867 100644 (file)
@@ -107,16 +107,6 @@ RECORD_DECL(V4_PORTPARAMS_RECORDS, OPT_UINT8_TYPE, OPT_PSID_TYPE);
 RECORD_DECL(OPT_6RD_RECORDS, OPT_UINT8_TYPE, OPT_UINT8_TYPE,
             OPT_IPV6_ADDRESS_TYPE, OPT_IPV4_ADDRESS_TYPE);
 
-// RFC-draft-ietf-add-dnr DHCPv4 DNR option.
-//
-// DNR Instance Data Length (2 octets), Service Priority (2 octets),
-// ADN Length (1 octet), ADN FQDN.
-// Opaque data is represented here by the binary data field.
-// It may contain Addr Length (1 octet), IPv4 address(es), SvcParams,
-// and next DNR instances as binary data.
-RECORD_DECL(V4_DNR_RECORDS, OPT_UINT16_TYPE, OPT_UINT16_TYPE, OPT_UINT8_TYPE,
-            OPT_FQDN_TYPE, OPT_BINARY_TYPE);
-
 /// @brief Definitions of standard DHCPv4 options.
 const OptionDefParams STANDARD_V4_OPTION_DEFINITIONS[] = {
     { "subnet-mask", DHO_SUBNET_MASK, DHCP4_OPTION_SPACE,
@@ -378,8 +368,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,
-     false, RECORD_DEF(V4_DNR_RECORDS), "" },
+    { "v4-dnr", DHO_V4_DNR, DHCP4_OPTION_SPACE, OPT_INTERNAL_TYPE,
+     false, 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,
@@ -501,13 +491,6 @@ RECORD_DECL(SIGNATURE_RECORDS, OPT_UINT8_TYPE, OPT_UINT8_TYPE,
 // Three 1 byte fileds to describe a network interface: type, major and minor
 RECORD_DECL(CLIENT_NII_RECORDS, OPT_UINT8_TYPE, OPT_UINT8_TYPE, OPT_UINT8_TYPE);
 
-// RFC-draft-ietf-add-dnr DHCPv6 DNR option.
-//
-// Service Priority (2 octets), ADN Length (2 octets), ADN FQDN.
-// Opaque data is represented here by the binary data field.
-// It may contain Addr Length (2 octets), IPv6 address(es), SvcParams.
-RECORD_DECL(V6_DNR_RECORDS, OPT_UINT16_TYPE, OPT_UINT16_TYPE, OPT_FQDN_TYPE, OPT_BINARY_TYPE);
-
 /// Standard DHCPv6 option definitions.
 ///
 /// @warning in this array, the initializers are provided for all
@@ -671,8 +654,8 @@ const OptionDefParams STANDARD_V6_OPTION_DEFINITIONS[] = {
       false, NO_RECORD_DEF, MAPT_V6_OPTION_SPACE },
     { "s46-cont-lw", D6O_S46_CONT_LW, DHCP6_OPTION_SPACE, OPT_EMPTY_TYPE,
       false, NO_RECORD_DEF, LW_V6_OPTION_SPACE },
-    { "v6-dnr", D6O_V6_DNR, DHCP6_OPTION_SPACE, OPT_RECORD_TYPE,
-     false, RECORD_DEF(V6_DNR_RECORDS), "" }
+    { "v6-dnr", D6O_V6_DNR, DHCP6_OPTION_SPACE, OPT_INTERNAL_TYPE,
+     false, NO_RECORD_DEF, "" }
 
     // @todo There is still a bunch of options for which we have to provide
     // definitions but we don't do it because they are not really