Browse Source

[3194] Use OptionDefinition::optionFactory to create DHCPv6 vendor options.

Marcin Siodelski 11 years ago
parent
commit
1a0dd0c77a

+ 0 - 16
src/bin/dhcp6/dhcp6_srv.cc

@@ -2356,22 +2356,6 @@ Dhcpv6Srv::unpackOptions(const OptionBuffer& buf,
             continue;
         }
 
-        if (opt_type == D6O_VENDOR_OPTS) {
-            if (offset + 4 > length) {
-                // Truncated vendor-option. There is expected at least 4 bytes
-                // long enterprise-id field
-                return (offset);
-            }
-
-            // Parse this as vendor option
-            OptionPtr vendor_opt(new OptionVendor(Option::V6, buf.begin() + offset,
-                                                  buf.begin() + offset + opt_len));
-            options.insert(std::make_pair(opt_type, vendor_opt));
-
-            offset += opt_len;
-            continue;
-        }
-
         // Get all definitions with the particular option code. Note that option
         // code is non-unique within this container however at this point we
         // expect to get one option definition with the particular code. If more

+ 4 - 0
src/lib/dhcp/option_definition.cc

@@ -581,6 +581,10 @@ OptionDefinition::factorySpecialFormatOption(Option::Universe u,
             // FQDN option requires special processing. Thus, there is
             // a specialized class to handle it.
             return (OptionPtr(new Option6ClientFqdn(begin, end)));
+
+        } else if (getCode() == D6O_VENDOR_OPTS) {
+            return (OptionPtr(new OptionVendor(Option::V6, begin, end)));
+
         }
     } else {
         if ((getCode() == DHO_FQDN) && haveFqdn4Format()) {

+ 1 - 1
src/lib/dhcp/tests/libdhcp++_unittest.cc

@@ -845,7 +845,7 @@ TEST_F(LibDhcpTest, stdOptionDefs6) {
                                     typeid(OptionCustom));
 
     LibDhcpTest::testStdOptionDefs6(D6O_VENDOR_OPTS, begin, end,
-                                    typeid(OptionInt<uint32_t>),
+                                    typeid(OptionVendor),
                                     "vendor-opts-space");
 
     LibDhcpTest::testStdOptionDefs6(D6O_INTERFACE_ID, begin, end,