BIND 10 master, updated. a1f129606c6dc70e512e86a12cf6bdef8b0d2dd5 [2364] Merge branch 'master' into trac2364

BIND 10 source code commits bind10-changes at lists.isc.org
Tue Nov 27 11:37:14 UTC 2012


The branch, master has been updated
       via  a1f129606c6dc70e512e86a12cf6bdef8b0d2dd5 (commit)
       via  4a1003b53e1a2e5ae8291bf74e2cdb74af36f9ea (commit)
       via  a8cc78f205ee37f2c26a4bca3e82c6f74c22b9cb (commit)
       via  877c06b9535bded5ad197086df8383fdc0bd8101 (commit)
       via  b6203bf733422707388f45bc0bece9b3fe40e49d (commit)
      from  0811abc7c8bc7ad8eb4aa4edb565724dcb4352bb (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 a1f129606c6dc70e512e86a12cf6bdef8b0d2dd5
Merge: 4a1003b 0811abc
Author: Stephen Morris <stephen at isc.org>
Date:   Tue Nov 27 11:09:00 2012 +0000

    [2364] Merge branch 'master' into trac2364

commit 4a1003b53e1a2e5ae8291bf74e2cdb74af36f9ea
Author: Stephen Morris <stephen at isc.org>
Date:   Tue Nov 27 11:06:30 2012 +0000

    [2364] Correct typos in header comments

commit a8cc78f205ee37f2c26a4bca3e82c6f74c22b9cb
Author: Stephen Morris <stephen at isc.org>
Date:   Mon Nov 26 13:28:40 2012 +0000

    [2364] More changes in response to review
    
    Also change type of exception thrown by packX() if universe is incorrect.

commit 877c06b9535bded5ad197086df8383fdc0bd8101
Author: Stephen Morris <stephen at isc.org>
Date:   Mon Nov 26 12:43:39 2012 +0000

    [2364] Minor changes to exception text after review.

commit b6203bf733422707388f45bc0bece9b3fe40e49d
Author: Stephen Morris <stephen at isc.org>
Date:   Mon Nov 19 15:04:51 2012 +0000

    [2364] Remove V6 code from Option::pack4()

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

Summary of changes:
 src/lib/dhcp/option.cc |   50 ++++++++++++++++++++++++------------------------
 src/lib/dhcp/option.h  |   17 +++++++++++-----
 2 files changed, 37 insertions(+), 30 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/dhcp/option.cc b/src/lib/dhcp/option.cc
index d2be1d2..b8ed6c2 100644
--- a/src/lib/dhcp/option.cc
+++ b/src/lib/dhcp/option.cc
@@ -62,14 +62,14 @@ Option::Option(Universe u, uint16_t type, OptionBufferConstIter first,
 void
 Option::check() {
     if ( (universe_ != V4) && (universe_ != V6) ) {
-        isc_throw(BadValue, "Invalid universe type specified."
+        isc_throw(BadValue, "Invalid universe type specified. "
                   << "Only V4 and V6 are allowed.");
     }
 
     if (universe_ == V4) {
 
         if (type_ > 255) {
-            isc_throw(OutOfRange, "DHCPv4 Option type " << type_ << " is too big."
+            isc_throw(OutOfRange, "DHCPv4 Option type " << type_ << " is too big. "
                       << "For DHCPv4 allowed type range is 0..255");
         } else if (data_.size() > 255) {
             isc_throw(OutOfRange, "DHCPv4 Option " << type_ << " is too big.");
@@ -87,20 +87,21 @@ void Option::pack(isc::util::OutputBuffer& buf) {
     switch (universe_) {
     case V6:
         return (pack6(buf));
+
     case V4:
         return (pack4(buf));
+
     default:
-        isc_throw(BadValue, "Failed to pack " << type_ << " option. Do not "
-                  << "use this method for options other than DHCPv6.");
+        isc_throw(BadValue, "Failed to pack " << type_ << " option as the "
+                  << "universe type is unknown.");
     }
 }
 
 void
 Option::pack4(isc::util::OutputBuffer& buf) {
-    switch (universe_) {
-    case V4: {
+    if (universe_ == V4) {
         if (len() > 255) {
-            isc_throw(OutOfRange, "DHCPv4 Option " << type_ << " is too big."
+            isc_throw(OutOfRange, "DHCPv4 Option " << type_ << " is too big. "
                       << "At most 255 bytes are supported.");
             /// TODO Larger options can be stored as separate instances
             /// of DHCPv4 options. Clients MUST concatenate them.
@@ -109,33 +110,32 @@ Option::pack4(isc::util::OutputBuffer& buf) {
 
         buf.writeUint8(type_);
         buf.writeUint8(len() - getHeaderLen());
-
-        buf.writeData(&data_[0], data_.size());
+        if (!data_.empty()) {
+            buf.writeData(&data_[0], data_.size());
+        }
 
         LibDHCP::packOptions(buf, options_);
-        return;
-    }
-    case V6:
-        /// TODO: Do we need a sanity check for option size here?
-        buf.writeUint16(type_);
-        buf.writeUint16(len() - getHeaderLen());
 
-        LibDHCP::packOptions(buf, options_);
-        return;
-    default:
-        isc_throw(OutOfRange, "Invalid universe type" << universe_);
+    } else {
+        isc_throw(BadValue, "Invalid universe type " << universe_);
     }
+
+    return;
 }
 
 void Option::pack6(isc::util::OutputBuffer& buf) {
-    buf.writeUint16(type_);
-    buf.writeUint16(len() - getHeaderLen());
+    if (universe_ == V6) {
+        buf.writeUint16(type_);
+        buf.writeUint16(len() - getHeaderLen());
+        if (!data_.empty()) {
+            buf.writeData(&data_[0], data_.size());
+        }
 
-    if (! data_.empty()) {
-        buf.writeData(&data_[0], data_.size());
+        LibDHCP::packOptions6(buf, options_);
+    } else {
+        isc_throw(BadValue, "Invalid universe type " << universe_);
     }
-
-    return LibDHCP::packOptions6(buf, options_);
+    return;
 }
 
 void Option::unpack(OptionBufferConstIter begin,
diff --git a/src/lib/dhcp/option.h b/src/lib/dhcp/option.h
index 920ef13..d6d5f2d 100644
--- a/src/lib/dhcp/option.h
+++ b/src/lib/dhcp/option.h
@@ -119,7 +119,7 @@ public:
     /// This constructor takes vector<uint8_t>& which is used in cases
     /// when content of the option will be copied and stored within
     /// option object. V4 Options follow that approach already.
-    /// TODO Migrate V6 options to that approach.
+    /// @todo Migrate V6 options to that approach.
     ///
     /// @param u specifies universe (V4 or V6)
     /// @param type option type (0-255 for V4 and 0-65535 for V6)
@@ -131,7 +131,7 @@ public:
     /// This contructor is similar to the previous one, but it does not take
     /// the whole vector<uint8_t>, but rather subset of it.
     ///
-    /// TODO: This can be templated to use different containers, not just
+    /// @todo This can be templated to use different containers, not just
     /// vector. Prototype should look like this:
     /// template<typename InputIterator> Option(Universe u, uint16_t type,
     /// InputIterator first, InputIterator last);
@@ -160,19 +160,24 @@ public:
     /// byte after stored option (that is useful for writing options one after
     /// another). Used in DHCPv6 options.
     ///
-    /// TODO: Migrate DHCPv6 code to pack(OutputBuffer& buf) version
+    /// @todo Migrate DHCPv6 code to pack(OutputBuffer& buf) version
     ///
     /// @param buf pointer to a buffer
+    ///
+    /// @throw BadValue Universe of the option is neither V4 nor V6.
     virtual void pack(isc::util::OutputBuffer& buf);
 
     /// @brief Writes option in a wire-format to a buffer.
     ///
     /// Method will throw if option storing fails for some reason.
     ///
-    /// TODO Once old (DHCPv6) implementation is rewritten,
+    /// @todo Once old (DHCPv6) implementation is rewritten,
     /// unify pack4() and pack6() and rename them to just pack().
     ///
     /// @param buf output buffer (option will be stored there)
+    ///
+    /// @throw OutOfRange Option type is greater than 255.
+    /// @throw BadValue Universe is not V4.
     virtual void pack4(isc::util::OutputBuffer& buf);
 
     /// @brief Parses received buffer.
@@ -303,6 +308,8 @@ protected:
     /// defined suboptions. Version for building DHCPv4 options.
     ///
     /// @param buf output buffer (built options will be stored here)
+    ///
+    /// @throw BadValue Universe is not V6.
     virtual void pack6(isc::util::OutputBuffer& buf);
 
     /// @brief A private method used for option correctness.
@@ -324,7 +331,7 @@ protected:
     /// collection for storing suboptions
     OptionCollection options_;
 
-    /// TODO: probably 2 different containers have to be used for v4 (unique
+    /// @todo probably 2 different containers have to be used for v4 (unique
     /// options) and v6 (options with the same type can repeat)
 };
 



More information about the bind10-changes mailing list