Parcourir la source

[2304] Applied changes suggested in the second code review.

Marcin Siodelski il y a 12 ans
Parent
commit
b617d1a26e

+ 11 - 1
src/lib/dhcp/option6_int.h

@@ -44,6 +44,9 @@ public:
     ///
     /// @param type option type.
     /// @param value option value.
+    ///
+    /// @throw isc::dhcp::InvalidDataType if data field type provided
+    /// as template parameter is not a supported integer type.
     Option6Int(uint16_t type, T value)
         : Option(Option::V6, type), value_(value) {
         if (!OptionDataTypes<T>::valid) {
@@ -62,6 +65,8 @@ public:
     /// @param end iterator to end of option data (first byte after option end).
     ///
     /// @throw isc::OutOfRange if provided buffer is shorter than data size.
+    /// @throw isc::dhcp::InvalidDataType if data field type provided
+    /// as template parameter is not a supported integer type.
     Option6Int(uint16_t type, OptionBufferConstIter begin,
                OptionBufferConstIter end)
         : Option(Option::V6, type) {
@@ -76,7 +81,9 @@ public:
     ///
     /// @param [out] buf buffer (option will be stored here)
     ///
-    /// @throw isc::BadValue if invalid option type has been provided.
+    /// @throw isc::dhcp::InvalidDataType if size of a data field type is not
+    /// equal to 1, 2 or 4 bytes. The data type is not checked in this function
+    /// because it is checked in a constructor.
     void pack(isc::util::OutputBuffer& buf) {
         buf.writeUint16(type_);
         buf.writeUint16(len() - OPTION6_HDR_LEN);
@@ -110,6 +117,9 @@ public:
     /// @param end iterator to end of option data (first byte after option end)
     ///
     /// @throw isc::OutOfRange if provided buffer is shorter than data size.
+    /// @throw isc::dhcp::InvalidDataType if size of a data field type is not
+    /// equal to 1, 2 or 4 bytes. The data type is not checked in this function
+    /// because it is checked in a constructor.
     virtual void unpack(OptionBufferConstIter begin, OptionBufferConstIter end) {
         if (distance(begin, end) < sizeof(T)) {
             isc_throw(OutOfRange, "Option " << getType() << " truncated");

+ 14 - 1
src/lib/dhcp/option6_int_array.h

@@ -53,6 +53,9 @@ public:
     /// Creates option with empty values vector.
     ///
     /// @param type option type.
+    ///
+    /// @throw isc::dhcp::InvalidDataType if data field type provided
+    /// as template parameter is not a supported integer type.
     Option6IntArray(uint16_t type)
         : Option(Option::V6, type),
           values_(0) {
@@ -68,6 +71,8 @@ public:
     ///
     /// @throw isc::OutOfRange if provided buffer is empty or its length
     /// is not multiple of size of the data type in bytes.
+    /// @throw isc::dhcp::InvalidDataType if data field type provided
+    /// as template parameter is not a supported integer type.
     Option6IntArray(uint16_t type, const OptionBuffer& buf)
         : Option(Option::V6, type) {
         if (!OptionDataTypes<T>::valid) {
@@ -88,6 +93,8 @@ public:
     ///
     /// @throw isc::OutOfRange if provided buffer is empty or its length
     /// is not multiple of size of the data type in bytes.
+    /// @throw isc::dhcp::InvalidDataType if data field type provided
+    /// as template parameter is not a supported integer type.
     Option6IntArray(uint16_t type, OptionBufferConstIter begin,
                     OptionBufferConstIter end)
         : Option(Option::V6, type) {
@@ -102,7 +109,9 @@ public:
     ///
     /// @param [out] buf buffer (option will be stored here)
     ///
-    /// @throw isc::BadValue if invalid option type has been provided.
+    /// @throw isc::dhcp::InvalidDataType if size of a data fields type is not
+    /// equal to 1, 2 or 4 bytes. The data type is not checked in this function
+    /// because it is checked in a constructor.
     void pack(isc::util::OutputBuffer& buf) {
         buf.writeUint16(type_);
         buf.writeUint16(len() - OPTION6_HDR_LEN);
@@ -138,6 +147,10 @@ public:
     ///
     /// @param begin iterator to first byte of option data
     /// @param end iterator to end of option data (first byte after option end)
+    ///
+    /// @throw isc::dhcp::InvalidDataType if size of a data fields type is not
+    /// equal to 1, 2 or 4 bytes. The data type is not checked in this function
+    /// because it is checked in a constructor.
     virtual void unpack(OptionBufferConstIter begin, OptionBufferConstIter end) {
         if (distance(begin, end) == 0) {
             isc_throw(OutOfRange, "option " << getType() << " empty");

+ 6 - 6
src/lib/dhcp/option_definition.cc

@@ -165,12 +165,6 @@ OptionDefinition::validate() const {
 
 bool
 OptionDefinition::haveIAx6Format(OptionDefinition::DataType first_type) const {
-    // Expect that IA_NA option format is defined as record.
-    // Although it consists of 3 elements of the same (uint32)
-    // type it can't be defined as array of uint32 elements because
-    // arrays do not impose limitations on number of elements in
-    // the array while this limitation is needed for IA_NA - need
-    // exactly 3 elements.
    return (haveType(RECORD_TYPE) &&
            record_fields_.size() == 3 &&
            record_fields_[0] == first_type &&
@@ -180,6 +174,12 @@ OptionDefinition::haveIAx6Format(OptionDefinition::DataType first_type) const {
 
 bool
 OptionDefinition::haveIA6Format() const {
+    // Expect that IA_NA option format is defined as record.
+    // Although it consists of 3 elements of the same (uint32)
+    // type it can't be defined as array of uint32 elements because
+    // arrays do not impose limitations on number of elements in
+    // the array while this limitation is needed for IA_NA - need
+    // exactly 3 elements.
     return (haveIAx6Format(UINT32_TYPE));
 }