BIND 10 master, updated. d3c5e8d90a97ce403e2e0e079094d20b43fc8030 [master] Merge branch 'trac2365'

BIND 10 source code commits bind10-changes at lists.isc.org
Thu Nov 29 09:04:11 UTC 2012


The branch, master has been updated
       via  d3c5e8d90a97ce403e2e0e079094d20b43fc8030 (commit)
       via  31b4c8a77f74ff4f417171af1ceb428c134572a3 (commit)
       via  0c58aace22046e4e58360df79299150b745994a4 (commit)
       via  69950d299b32dea11452b629fedff973108bc263 (commit)
      from  7024914e4253ce983f0dc28f623956ea6c82241e (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 d3c5e8d90a97ce403e2e0e079094d20b43fc8030
Merge: 7024914 31b4c8a
Author: Marcin Siodelski <marcin at isc.org>
Date:   Thu Nov 29 09:41:52 2012 +0100

    [master] Merge branch 'trac2365'

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

Summary of changes:
 src/lib/dhcp/option.cc         |   32 ++++++++++++++++++++++++++++++--
 src/lib/dhcp/option.h          |   29 +++++++++++++++++++++++++++++
 src/lib/dhcp/option6_ia.cc     |    4 ++--
 src/lib/dhcp/option6_iaaddr.cc |    5 +++--
 src/lib/dhcp/option6_int.h     |    4 ++--
 5 files changed, 66 insertions(+), 8 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/dhcp/option.cc b/src/lib/dhcp/option.cc
index b8ed6c2..4638025 100644
--- a/src/lib/dhcp/option.cc
+++ b/src/lib/dhcp/option.cc
@@ -114,7 +114,7 @@ Option::pack4(isc::util::OutputBuffer& buf) {
             buf.writeData(&data_[0], data_.size());
         }
 
-        LibDHCP::packOptions(buf, options_);
+        packOptions(buf);
 
     } else {
         isc_throw(BadValue, "Invalid universe type " << universe_);
@@ -131,18 +131,46 @@ void Option::pack6(isc::util::OutputBuffer& buf) {
             buf.writeData(&data_[0], data_.size());
         }
 
-        LibDHCP::packOptions6(buf, options_);
+        packOptions(buf);
     } else {
         isc_throw(BadValue, "Invalid universe type " << universe_);
     }
     return;
 }
 
+void
+Option::packOptions(isc::util::OutputBuffer& buf) {
+    switch (universe_) {
+    case V4:
+        LibDHCP::packOptions(buf, options_);
+        return;
+    case V6:
+        LibDHCP::packOptions6(buf, options_);
+        return;
+    default:
+        isc_throw(isc::BadValue, "Invalid universe type " << universe_);
+    }
+}
+
 void Option::unpack(OptionBufferConstIter begin,
                     OptionBufferConstIter end) {
     data_ = OptionBuffer(begin, end);
 }
 
+void
+Option::unpackOptions(const OptionBuffer& buf) {
+    switch (universe_) {
+    case V4:
+        LibDHCP::unpackOptions4(buf, options_);
+        return;
+    case V6:
+        LibDHCP::unpackOptions6(buf, options_);
+        return;
+    default:
+        isc_throw(isc::BadValue, "Invalid universe type " << universe_);
+    }
+}
+
 uint16_t Option::len() {
     // Returns length of the complete option (data length + DHCPv4/DHCPv6
     // option header)
diff --git a/src/lib/dhcp/option.h b/src/lib/dhcp/option.h
index d6d5f2d..a6b0622 100644
--- a/src/lib/dhcp/option.h
+++ b/src/lib/dhcp/option.h
@@ -312,6 +312,35 @@ protected:
     /// @throw BadValue Universe is not V6.
     virtual void pack6(isc::util::OutputBuffer& buf);
 
+    /// @brief Store sub options in a buffer.
+    ///
+    /// This method stores all sub-options defined for a particular
+    /// option in a on-wire format in output buffer provided.
+    /// This function is called by pack function in this class or
+    /// derived classes that override pack.
+    ///
+    /// @param [out] buf output buffer.
+    ///
+    /// @todo The set of exceptions thrown by this function depend on
+    /// exceptions thrown by pack methods invoked on objects
+    /// representing sub options. We should consider whether to aggregate
+    /// those into one exception which can be documented here.
+    void packOptions(isc::util::OutputBuffer& buf);
+
+    /// @brief Builds a collection of sub options from the buffer.
+    ///
+    /// This method parses the provided buffer and builds a collection
+    /// of objects representing sub options. This function may throw
+    /// different exceptions when option assembly fails.
+    ///
+    /// @param buf buffer to be parsed.
+    ///
+    /// @todo The set of exceptions thrown by this function depend on
+    /// exceptions thrown by unpack methods invoked on objects
+    /// representing sub options. We should consider whether to aggregate
+    /// those into one exception which can be documented here.
+    void unpackOptions(const OptionBuffer& buf);
+
     /// @brief A private method used for option correctness.
     ///
     /// It is used in constructors. In there are any problems detected
diff --git a/src/lib/dhcp/option6_ia.cc b/src/lib/dhcp/option6_ia.cc
index 9e4e01e..64c2936 100644
--- a/src/lib/dhcp/option6_ia.cc
+++ b/src/lib/dhcp/option6_ia.cc
@@ -44,7 +44,7 @@ void Option6IA::pack(isc::util::OutputBuffer& buf) {
     buf.writeUint32(t1_);
     buf.writeUint32(t2_);
 
-    LibDHCP::packOptions6(buf, options_);
+    packOptions(buf);
 }
 
 void Option6IA::unpack(OptionBufferConstIter begin,
@@ -62,7 +62,7 @@ void Option6IA::unpack(OptionBufferConstIter begin,
     t2_ = readUint32( &(*begin) );
     begin += sizeof(uint32_t);
 
-    LibDHCP::unpackOptions6(OptionBuffer(begin, end), options_);
+    unpackOptions(OptionBuffer(begin, end));
 }
 
 std::string Option6IA::toText(int indent /* = 0*/) {
diff --git a/src/lib/dhcp/option6_iaaddr.cc b/src/lib/dhcp/option6_iaaddr.cc
index b503a91..8db5047 100644
--- a/src/lib/dhcp/option6_iaaddr.cc
+++ b/src/lib/dhcp/option6_iaaddr.cc
@@ -59,7 +59,7 @@ void Option6IAAddr::pack(isc::util::OutputBuffer& buf) {
     buf.writeUint32(valid_);
 
     // parse suboption (there shouldn't be any for IAADDR)
-    LibDHCP::packOptions6(buf, options_);
+    packOptions(buf);
 }
 
 void Option6IAAddr::unpack(OptionBuffer::const_iterator begin,
@@ -77,7 +77,8 @@ void Option6IAAddr::unpack(OptionBuffer::const_iterator begin,
 
     valid_ = readUint32( &(*begin) );
     begin += sizeof(uint32_t);
-    LibDHCP::unpackOptions6(OptionBuffer(begin, end), options_);
+
+    unpackOptions(OptionBuffer(begin, end));
 }
 
 std::string Option6IAAddr::toText(int indent /* =0 */) {
diff --git a/src/lib/dhcp/option6_int.h b/src/lib/dhcp/option6_int.h
index 9b116e0..0dfa4dd 100644
--- a/src/lib/dhcp/option6_int.h
+++ b/src/lib/dhcp/option6_int.h
@@ -104,7 +104,7 @@ public:
         default:
             isc_throw(dhcp::InvalidDataType, "non-integer type");
         }
-        LibDHCP::packOptions6(buf, options_);
+        packOptions(buf);
     }
 
     /// @brief Parses received buffer
@@ -149,7 +149,7 @@ public:
         // of clang complain about unresolved reference to
         // OptionDataTypeTraits structure during linking.
         begin += data_size_len;
-        LibDHCP::unpackOptions6(OptionBuffer(begin, end), options_);
+        unpackOptions(OptionBuffer(begin, end));
     }
 
     /// @brief Set option value.



More information about the bind10-changes mailing list