BIND 10 trac2490, updated. c84d8a4bcf3058d49c88962744102cb3efa7aa2c [2490] Removed redundant parameters.

BIND 10 source code commits bind10-changes at lists.isc.org
Wed Nov 21 16:33:54 UTC 2012


The branch, trac2490 has been updated
       via  c84d8a4bcf3058d49c88962744102cb3efa7aa2c (commit)
      from  9f48afa5e955391ea42332f2b6cc0d8f4757b438 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit c84d8a4bcf3058d49c88962744102cb3efa7aa2c
Author: Marcin Siodelski <marcin at isc.org>
Date:   Wed Nov 21 17:32:49 2012 +0100

    [2490] Removed redundant parameters.

-----------------------------------------------------------------------

Summary of changes:
 src/lib/dhcp/option_definition.cc                |   38 ++++++++--------
 src/lib/dhcp/option_definition.h                 |   52 ++++++++++++----------
 src/lib/dhcp/tests/option_definition_unittest.cc |   16 -------
 3 files changed, 46 insertions(+), 60 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/dhcp/option_definition.cc b/src/lib/dhcp/option_definition.cc
index cd060d6..72f1677 100644
--- a/src/lib/dhcp/option_definition.cc
+++ b/src/lib/dhcp/option_definition.cc
@@ -289,15 +289,19 @@ OptionDefinition::optionFactory(Option::Universe u, uint16_t type,
         if (type_ == OPT_BINARY_TYPE) {
             return (factoryGeneric(u, type, begin, end));
         } else if (type_ == OPT_IPV6_ADDRESS_TYPE && array_type_) {
-            return (factoryAddrList6(u, type, begin, end));
+            return (factoryAddrList6(type, begin, end));
         } else if (type_ == OPT_IPV4_ADDRESS_TYPE && array_type_) {
-            return (factoryAddrList4(u, type, begin, end));
+            return (factoryAddrList4(type, begin, end));
         } else if (type_ == OPT_EMPTY_TYPE) {
-            return (factoryEmpty(u, type, begin, end));
-        } else if (code_ == D6O_IA_NA && haveIA6Format()) {
-            return (factoryIA6(u, type, begin, end));
-        } else if (code_ == D6O_IAADDR && haveIAAddr6Format()) {
-            return (factoryIAAddr6(u, type, begin, end));
+            return (factoryEmpty(u, type));
+        } else if (u == Option::V6 &&
+                   code_ == D6O_IA_NA &&
+                   haveIA6Format()) {
+            return (factoryIA6(type, begin, end));
+        } else if (u == Option::V6 &&
+                   code_ == D6O_IAADDR &&
+                   haveIAAddr6Format()) {
+            return (factoryIAAddr6(type, begin, end));
         } else if (type_ == OPT_UINT8_TYPE) {
             if (array_type_) {
                 return (factoryGeneric(u, type, begin, end));
@@ -306,13 +310,13 @@ OptionDefinition::optionFactory(Option::Universe u, uint16_t type,
             }
         } else if (type_ == OPT_UINT16_TYPE) {
             if (array_type_) {
-                return (factoryIntegerArray<uint16_t>(u, type, begin, end));
+                return (factoryIntegerArray<uint16_t>(type, begin, end));
             } else {
                 return (factoryInteger<uint16_t>(u, type, begin, end));
             }
         } else if (type_ == OPT_UINT32_TYPE) {
             if (array_type_) {
-                return (factoryIntegerArray<uint32_t>(u, type, begin, end));
+                return (factoryIntegerArray<uint32_t>(type, begin, end));
             } else {
                 return (factoryInteger<uint32_t>(u, type, begin, end));
             }
@@ -442,28 +446,24 @@ OptionDefinition::haveIAAddr6Format() const {
 }
 
 OptionPtr
-OptionDefinition::factoryAddrList4(Option::Universe u, uint16_t type,
+OptionDefinition::factoryAddrList4(uint16_t type,
                                   OptionBufferConstIter begin,
                                   OptionBufferConstIter end) {
-    sanityCheckUniverse(u, Option::V4);
     boost::shared_ptr<Option4AddrLst> option(new Option4AddrLst(type, begin, end));
     return (option);
 }
 
 OptionPtr
-OptionDefinition::factoryAddrList6(Option::Universe u, uint16_t type,
+OptionDefinition::factoryAddrList6(uint16_t type,
                                    OptionBufferConstIter begin,
                                    OptionBufferConstIter end) {
-    sanityCheckUniverse(u, Option::V6);
     boost::shared_ptr<Option6AddrLst> option(new Option6AddrLst(type, begin, end));
     return (option);
 }
 
 
 OptionPtr
-OptionDefinition::factoryEmpty(Option::Universe u, uint16_t type,
-                               OptionBufferConstIter,
-                               OptionBufferConstIter) {
+OptionDefinition::factoryEmpty(Option::Universe u, uint16_t type) {
     OptionPtr option(new Option(u, type));
     return (option);
 }
@@ -477,10 +477,9 @@ OptionDefinition::factoryGeneric(Option::Universe u, uint16_t type,
 }
 
 OptionPtr
-OptionDefinition::factoryIA6(Option::Universe u, uint16_t type,
+OptionDefinition::factoryIA6(uint16_t type,
                              OptionBufferConstIter begin,
                              OptionBufferConstIter end) {
-    sanityCheckUniverse(u, Option::V6);
     if (std::distance(begin, end) < Option6IA::OPTION6_IA_LEN) {
         isc_throw(isc::OutOfRange, "input option buffer has invalid size, expected "
                   "at least " << Option6IA::OPTION6_IA_LEN << " bytes");
@@ -490,10 +489,9 @@ OptionDefinition::factoryIA6(Option::Universe u, uint16_t type,
 }
 
 OptionPtr
-OptionDefinition::factoryIAAddr6(Option::Universe u, uint16_t type,
+OptionDefinition::factoryIAAddr6(uint16_t type,
                                  OptionBufferConstIter begin,
                                  OptionBufferConstIter end) {
-    sanityCheckUniverse(u, Option::V6);
     if (std::distance(begin, end) < Option6IAAddr::OPTION6_IAADDR_LEN) {
         isc_throw(isc::OutOfRange, "input option buffer has invalid size, expected "
                   " at least " << Option6IAAddr::OPTION6_IAADDR_LEN << " bytes");
diff --git a/src/lib/dhcp/option_definition.h b/src/lib/dhcp/option_definition.h
index ec7fc9c..18f79d2 100644
--- a/src/lib/dhcp/option_definition.h
+++ b/src/lib/dhcp/option_definition.h
@@ -97,7 +97,7 @@ class Option6IntArray;
 ///
 /// Should the option comprise data fields of different types, the "record"
 /// option type is used. In such cases the data field types within the record
-/// are specified using \ref OptioDefinition::addRecordField.
+/// are specified using \ref OptionDefinition::addRecordField.
 ///
 /// When the OptionDefinition object has been sucessfully created, it can be
 /// queried to return the appropriate option factory function for the specified
@@ -297,7 +297,7 @@ public:
     /// provided chunk of buffer. This function may be used to
     /// create option which is to be sent in the outgoing packet.
     ///
-    /// @param universe option universe (V4 or V6).
+    /// @param u option universe (V4 or V6).
     /// @param type option type.
     /// @param begin beginning of the option buffer.
     /// @param end end of the option buffer.
@@ -315,7 +315,7 @@ public:
     /// whole provided buffer. This function may be used to
     /// create option which is to be sent in the outgoing packet.
     ///
-    /// @param universe option universe (V4 or V6).
+    /// @param u option universe (V4 or V6).
     /// @param type option type.
     /// @param buf option buffer.
     ///
@@ -339,7 +339,7 @@ public:
     /// must be tokenized into the vector of string values and this vector
     /// can be supplied to this function.
     ///
-    /// @param universe option universe (V4 or V6).
+    /// @param u option universe (V4 or V6).
     /// @param type option type.
     /// @param values a vector of values to be used to set data for an option.
     ///
@@ -351,25 +351,29 @@ public:
 
     /// @brief Factory to create option with address list.
     ///
-    /// @param u universe (must be V4).
     /// @param type option type.
-    /// @param buf option buffer with a list of IPv4 addresses.
+    /// @param begin iterator pointing to the beginning of the buffer
+    /// with a list of IPv4 addresses.
+    /// @param end iterator pointing to the end of the buffer with
+    /// a list of IPv4 addresses.
     ///
     /// @throw isc::OutOfRange if length of the provided option buffer
     /// is not multiple of IPV4 address length.
-    static OptionPtr factoryAddrList4(Option::Universe u, uint16_t type,
+    static OptionPtr factoryAddrList4(uint16_t type,
                                       OptionBufferConstIter begin,
                                       OptionBufferConstIter end);
 
     /// @brief Factory to create option with address list.
     ///
-    /// @param u universe (must be V6).
     /// @param type option type.
-    /// @param buf option buffer with a list of IPv6 addresses.
+    /// @param begin iterator pointing to the beginning of the buffer
+    /// with a list of IPv6 addresses.
+    /// @param end iterator pointing to the end of the buffer with
+    /// a list of IPv6 addresses.
     ///
     /// @throw isc::OutOfaRange if length of provided option buffer
     /// is not multiple of IPV6 address length.
-    static OptionPtr factoryAddrList6(Option::Universe u, uint16_t type,
+    static OptionPtr factoryAddrList6(uint16_t type,
                                       OptionBufferConstIter begin,
                                       OptionBufferConstIter end);
 
@@ -377,50 +381,49 @@ public:
     ///
     /// @param u universe (V6 or V4).
     /// @param type option type.
-    /// @param buf option buffer (must be empty).
-    static OptionPtr factoryEmpty(Option::Universe u, uint16_t type,
-                                  OptionBufferConstIter begin,
-                                  OptionBufferConstIter end);
+    static OptionPtr factoryEmpty(Option::Universe u, uint16_t type);
 
     /// @brief Factory to create generic option.
     ///
     /// @param u universe (V6 or V4).
     /// @param type option type.
-    /// @param buf option buffer.
+    /// @param begin iterator pointing to the beginning of the buffer.
+    /// @param end iterator pointing to the end of the buffer.
     static OptionPtr factoryGeneric(Option::Universe u, uint16_t type,
                                     OptionBufferConstIter begin,
                                     OptionBufferConstIter end);
 
     /// @brief Factory for IA-type of option.
     ///
-    /// @param u universe (must be V6).
     /// @param type option type.
-    /// @param buf option buffer.
+    /// @param begin iterator pointing to the beginning of the buffer.
+    /// @param end iterator pointing to the end of the buffer.
     ///
     /// @throw isc::OutOfRange if provided option buffer is too short or
     /// too long. Expected size is 12 bytes.
     /// @throw isc::BadValue if specified universe value is not V6.
-    static OptionPtr factoryIA6(Option::Universe u, uint16_t type,
+    static OptionPtr factoryIA6(uint16_t type,
                                 OptionBufferConstIter begin,
                                 OptionBufferConstIter end);
 
     /// @brief Factory for IAADDR-type of option.
     ///
-    /// @param u universe (must be V6).
     /// @param type option type.
-    /// @param buf option buffer.
+    /// @param begin iterator pointing to the beginning of the buffer.
+    /// @param end iterator pointing to the end of the buffer.
     ///
     /// @throw isc::OutOfRange if provided option buffer is too short or
     /// too long. Expected size is 24 bytes.
     /// @throw isc::BadValue if specified universe value is not V6.
-    static OptionPtr factoryIAAddr6(Option::Universe u, uint16_t type,
+    static OptionPtr factoryIAAddr6(uint16_t type,
                                     OptionBufferConstIter begin,
                                     OptionBufferConstIter end);
 
     /// @brief Factory function to create option with integer value.
     ///
     /// @param type option type.
-    /// @param buf option buffer.
+    /// @param begin iterator pointing to the beginning of the buffer.
+    /// @param end iterator pointing to the end of the buffer.
     /// @tparam T type of the data field (must be one of the uintX_t or intX_t).
     ///
     /// @throw isc::OutOfRange if provided option buffer length is invalid.
@@ -435,12 +438,13 @@ public:
     /// @brief Factory function to create option with array of integer values.
     ///
     /// @param type option type.
-    /// @param buf option buffer.
+    /// @param begin iterator pointing to the beginning of the buffer.
+    /// @param end iterator pointing to the end of the buffer.
     /// @tparam T type of the data field (must be one of the uintX_t or intX_t).
     ///
     /// @throw isc::OutOfRange if provided option buffer length is invalid.
     template<typename T>
-    static OptionPtr factoryIntegerArray(Option::Universe, uint16_t type,
+    static OptionPtr factoryIntegerArray(uint16_t type,
                                          OptionBufferConstIter begin,
                                          OptionBufferConstIter end) {
         OptionPtr option(new Option6IntArray<T>(type, begin, end));
diff --git a/src/lib/dhcp/tests/option_definition_unittest.cc b/src/lib/dhcp/tests/option_definition_unittest.cc
index 9e94a22..9fa39c4 100644
--- a/src/lib/dhcp/tests/option_definition_unittest.cc
+++ b/src/lib/dhcp/tests/option_definition_unittest.cc
@@ -536,11 +536,6 @@ TEST_F(OptionDefinitionTest, recordIA6) {
     EXPECT_EQ(0x04050607, option_cast_v6->getT1());
     EXPECT_EQ(0x08090A0B, option_cast_v6->getT2());
 
-    // This should work for DHCPv6 only, try passing invalid universe value.
-    EXPECT_THROW(
-        opt_def.optionFactory(Option::V4, D6O_IA_NA, OptionBuffer(option6_ia_len)),
-        InvalidOptionValue
-    );
     // The length of the buffer must be at least 12 bytes.
     // Check too short buffer.
     EXPECT_THROW(
@@ -583,11 +578,6 @@ TEST_F(OptionDefinitionTest, recordIAAddr6) {
     EXPECT_EQ(0x00010203, option_cast_v6->getPreferred());
     EXPECT_EQ(0x04050607, option_cast_v6->getValid());
 
-    // This should work for DHCPv6 only, try passing invalid universe value.
-    EXPECT_THROW(
-        opt_def.optionFactory(Option::V4, D6O_IAADDR, OptionBuffer(option6_iaaddr_len)),
-        InvalidOptionValue
-    );
     // The length of the buffer must be at least 12 bytes.
     // Check too short buffer.
     EXPECT_THROW(
@@ -624,12 +614,6 @@ TEST_F(OptionDefinitionTest, recordIAAddr6Tokenized) {
     EXPECT_EQ("2001:db8::ff00:42:8329", option_cast_v6->getAddress().toText());
     EXPECT_EQ(1234, option_cast_v6->getPreferred());
     EXPECT_EQ(5678, option_cast_v6->getValid());
-
-    // This should work for DHCPv6 only, try passing in\valid universe value.
-    EXPECT_THROW(
-        opt_def.optionFactory(Option::V4, D6O_IAADDR, data_field_values),
-        InvalidOptionValue
-    );
 }
 
 // The purpose of this test is to verify that definition for option that



More information about the bind10-changes mailing list