]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
refactor initialization of options definitions
authorRazvan Becheriu <razvan@isc.org>
Wed, 10 Apr 2019 09:21:52 +0000 (12:21 +0300)
committerRazvan Becheriu <razvan@isc.org>
Fri, 12 Apr 2019 12:10:41 +0000 (15:10 +0300)
src/lib/dhcp/docsis3_option_defs.h
src/lib/dhcp/libdhcp++.cc
src/lib/dhcp/libdhcp++.h
src/lib/dhcp/option_definition.cc
src/lib/dhcp/option_space.h
src/lib/dhcp/std_option_defs.h
src/lib/dhcp/tests/libdhcp++_unittest.cc

index 879ffd56eccd5da9c5f75ddbaf35ba794dd433aa..fe66d04ebd78fd53edd57824f35b2793e7ff1865 100644 (file)
@@ -25,7 +25,8 @@ const OptionDefParams DOCSIS3_V4_DEFS[] = {
 };
 
 /// Number of option definitions defined.
-const int DOCSIS3_V4_DEFS_SIZE  = sizeof(DOCSIS3_V4_DEFS) / sizeof(OptionDefParams);
+const int DOCSIS3_V4_DEFS_SIZE =
+    sizeof(DOCSIS3_V4_DEFS) / sizeof(DOCSIS3_V4_DEFS[0]);
 
 /// @todo define remaining docsis3 v6 codes
 #define DOCSIS3_V6_ORO 1
@@ -65,7 +66,7 @@ const int DOCSIS3_V6_DEFS_SIZE =
 extern const char* DOCSIS3_CLASS_EROUTER;
 extern const char* DOCSIS3_CLASS_MODEM;
 
-}; // isc::dhcp namespace
-}; // isc namespace
+}  // namespace dhcp
+}  // namespace isc
 
 #endif // DOCSIS3_OPTION_DEFS_H
index 4572270de71b77f866dca379d31b399e86c9f046..38649497e80d25d4ac8ecdcf1c1937985019c818 100644 (file)
@@ -15,7 +15,6 @@
 #include <dhcp/option6_iaaddr.h>
 #include <dhcp/option_definition.h>
 #include <dhcp/option_int_array.h>
-#include <dhcp/option_space.h>
 #include <dhcp/std_option_defs.h>
 #include <dhcp/docsis3_option_defs.h>
 #include <exceptions/exceptions.h>
@@ -33,30 +32,40 @@ using namespace std;
 using namespace isc::dhcp;
 using namespace isc::util;
 
+namespace isc {
+namespace dhcp {
+
+namespace {
+
+const OptionDefParamsEncapsulation OPTION_DEF_PARAMS[] = {
+    { STANDARD_V4_OPTION_DEFINITIONS,       STANDARD_V4_OPTION_DEFINITIONS_SIZE,     DHCP4_OPTION_SPACE          },
+    { STANDARD_V6_OPTION_DEFINITIONS,       STANDARD_V6_OPTION_DEFINITIONS_SIZE,     DHCP6_OPTION_SPACE          },
+    { DOCSIS3_V4_DEFS,                      DOCSIS3_V4_DEFS_SIZE,                    DOCSIS3_V4_OPTION_SPACE     },
+    { DOCSIS3_V6_DEFS,                      DOCSIS3_V6_DEFS_SIZE,                    DOCSIS3_V6_OPTION_SPACE     },
+    { ISC_V6_OPTION_DEFINITIONS,            ISC_V6_OPTION_DEFINITIONS_SIZE,          ISC_V6_OPTION_SPACE         },
+    { MAPE_V6_OPTION_DEFINITIONS,           MAPE_V6_OPTION_DEFINITIONS_SIZE,         MAPE_V6_OPTION_SPACE        },
+    { MAPT_V6_OPTION_DEFINITIONS,           MAPT_V6_OPTION_DEFINITIONS_SIZE,         MAPT_V6_OPTION_SPACE        },
+    { LW_V6_OPTION_DEFINITIONS,             LW_V6_OPTION_DEFINITIONS_SIZE,           LW_V6_OPTION_SPACE          },
+    { V4V6_RULE_OPTION_DEFINITIONS,         V4V6_RULE_OPTION_DEFINITIONS_SIZE,       V4V6_RULE_OPTION_SPACE      },
+    { V4V6_BIND_OPTION_DEFINITIONS,         V4V6_BIND_OPTION_DEFINITIONS_SIZE,       V4V6_BIND_OPTION_SPACE      },
+    { LAST_RESORT_V4_OPTION_DEFINITIONS,    LAST_RESORT_V4_OPTION_DEFINITIONS_SIZE,  LAST_RESORT_V4_OPTION_SPACE },
+    { NULL,                                 0,                                       ""                          }
+};
+
+}  // namespace
+
+}  // namespace dhcp
+}  // namespace isc
+
 // static array with factories for options
 std::map<unsigned short, Option::Factory*> LibDHCP::v4factories_;
 
 // static array with factories for options
 std::map<unsigned short, Option::Factory*> LibDHCP::v6factories_;
 
-// Static container with DHCPv4 option definitions.
-OptionDefContainerPtr LibDHCP::v4option_defs_(new OptionDefContainer());
-
-// Static container with DHCPv6 option definitions.
-OptionDefContainerPtr LibDHCP::v6option_defs_(new OptionDefContainer());
-
 // Static container with option definitions grouped by option space.
 OptionDefContainers LibDHCP::option_defs_;
 
-// Static container with vendor option definitions for DHCPv4.
-VendorOptionDefContainers LibDHCP::vendor4_defs_;
-
-// Static container with vendor option definitions for DHCPv6.
-VendorOptionDefContainers LibDHCP::vendor6_defs_;
-
-// Static container with last resort option definitions for DHCPv4.
-OptionDefContainerPtr LibDHCP::lastresort_defs_(new OptionDefContainer());
-
 // Static container with option definitions created in runtime.
 StagedValue<OptionDefSpaceContainer> LibDHCP::runtime_option_defs_;
 
@@ -81,19 +90,8 @@ const OptionDefContainerPtr&
 LibDHCP::getOptionDefs(const std::string& space) {
     // If any of the containers is not initialized, it means that we haven't
     // initialized option definitions at all.
-    if (v4option_defs_->empty()) {
-        initStdOptionDefs4();
-        initVendorOptsDocsis4();
-        initStdOptionDefs6();
-        initVendorOptsDocsis6();
-        initLastResortOptionDefs();
-    }
-
-    if (space == DHCP4_OPTION_SPACE) {
-        return (v4option_defs_);
-
-    } else if (space == DHCP6_OPTION_SPACE) {
-        return (v6option_defs_);
+    if (option_defs_.end() == option_defs_.find(space)) {
+        initStdOptionDefs(space);
     }
 
     OptionDefContainers::const_iterator container = option_defs_.find(space);
@@ -103,41 +101,20 @@ LibDHCP::getOptionDefs(const std::string& space) {
     return (null_option_def_container_);
 }
 
-const OptionDefContainerPtr&
-LibDHCP::getVendorOption4Defs(const uint32_t vendor_id) {
-
-    if (vendor_id == VENDOR_ID_CABLE_LABS &&
-        vendor4_defs_.find(VENDOR_ID_CABLE_LABS) == vendor4_defs_.end()) {
-        initVendorOptsDocsis4();
-    }
-
-    VendorOptionDefContainers::const_iterator def = vendor4_defs_.find(vendor_id);
-    if (def == vendor4_defs_.end()) {
-        // No such vendor-id space
-        return (null_option_def_container_);
-    }
-    return (def->second);
-}
-
-const OptionDefContainerPtr&
-LibDHCP::getVendorOption6Defs(const uint32_t vendor_id) {
-
-    if (vendor_id == VENDOR_ID_CABLE_LABS &&
-        vendor6_defs_.find(VENDOR_ID_CABLE_LABS) == vendor6_defs_.end()) {
-        initVendorOptsDocsis6();
-    }
-
-    if (vendor_id == ENTERPRISE_ID_ISC &&
-        vendor6_defs_.find(ENTERPRISE_ID_ISC) == vendor6_defs_.end()) {
-        initVendorOptsIsc6();
-    }
-
-    VendorOptionDefContainers::const_iterator def = vendor6_defs_.find(vendor_id);
-    if (def == vendor6_defs_.end()) {
-        // No such vendor-id space
-        return (null_option_def_container_);
+const OptionDefContainerPtr
+LibDHCP::getVendorOptionDefs(const Option::Universe u, const uint32_t vendor_id) {
+    if (Option::V4 == u) {
+        if (VENDOR_ID_CABLE_LABS == vendor_id) {
+            return getOptionDefs(DOCSIS3_V4_OPTION_SPACE);
+        }
+    } else if (Option::V6 == u) {
+        if (VENDOR_ID_CABLE_LABS == vendor_id) {
+            return getOptionDefs(DOCSIS3_V6_OPTION_SPACE);
+        } else if (ENTERPRISE_ID_ISC == vendor_id) {
+            return getOptionDefs(ISC_V6_OPTION_SPACE);
+        }
     }
-    return (def->second);
+    return (null_option_def_container_);
 }
 
 OptionDefinitionPtr
@@ -165,14 +142,13 @@ LibDHCP::getOptionDef(const std::string& space, const std::string& name) {
 OptionDefinitionPtr
 LibDHCP::getVendorOptionDef(const Option::Universe u, const uint32_t vendor_id,
                             const std::string& name) {
-    OptionDefContainerPtr defs = (u == Option::V4 ? getVendorOption4Defs(vendor_id) :
-                                  getVendorOption6Defs(vendor_id));
+    const OptionDefContainerPtr option_defs_ptr = getVendorOptionDefs(u, vendor_id);
 
-    if (!defs) {
+    if (!option_defs_ptr) {
         return (OptionDefinitionPtr());
     }
 
-    const OptionDefContainerNameIndex& idx = defs->get<2>();
+    const OptionDefContainerNameIndex& idx = option_defs_ptr->get<2>();
     const OptionDefContainerNameRange& range = idx.equal_range(name);
     if (range.first != range.second) {
         return (*range.first);
@@ -183,17 +159,16 @@ LibDHCP::getVendorOptionDef(const Option::Universe u, const uint32_t vendor_id,
 OptionDefinitionPtr
 LibDHCP::getVendorOptionDef(const Option::Universe u, const uint32_t vendor_id,
                             const uint16_t code) {
-    OptionDefContainerPtr defs = (u == Option::V4 ? getVendorOption4Defs(vendor_id) :
-                                  getVendorOption6Defs(vendor_id));
+    const OptionDefContainerPtr option_defs_ptr = getVendorOptionDefs(u, vendor_id);
 
-    if (!defs) {
+    if (!option_defs_ptr) {
         // Weird universe or unknown vendor_id. We don't care. No definitions
         // one way or another
         // What is it anyway?
         return (OptionDefinitionPtr());
     }
 
-    const OptionDefContainerTypeIndex& idx = defs->get<1>();
+    const OptionDefContainerTypeIndex& idx = option_defs_ptr->get<1>();
     const OptionDefContainerTypeRange& range = idx.equal_range(code);
     if (range.first != range.second) {
         return (*range.first);
@@ -288,7 +263,7 @@ LibDHCP::getLastResortOptionDef(const std::string& space, const std::string& nam
 OptionDefContainerPtr
 LibDHCP::getLastResortOptionDefs(const std::string& space) {
     if (space == DHCP4_OPTION_SPACE) {
-        return (lastresort_defs_);
+        return getOptionDefs(LAST_RESORT_V4_OPTION_SPACE);
     }
     return (null_option_def_container_);
 }
@@ -602,14 +577,15 @@ size_t LibDHCP::unpackVendorOptions6(const uint32_t vendor_id,
     size_t length = buf.size();
 
     // Get the list of option definitions for this particular vendor-id
-    const OptionDefContainerPtr& option_defs = LibDHCP::getVendorOption6Defs(vendor_id);
+    const OptionDefContainerPtr option_defs_ptr =
+        LibDHCP::getVendorOptionDefs(Option::V6, vendor_id);
 
     // Get the search index #1. It allows to search for option definitions
     // using option code. If there's no such vendor-id space, we're out of luck
     // anyway.
     const OptionDefContainerTypeIndex* idx = NULL;
-    if (option_defs) {
-        idx = &(option_defs->get<1>());
+    if (option_defs_ptr) {
+        idx = &(option_defs_ptr->get<1>());
     }
 
     // The buffer being read comprises a set of options, each starting with
@@ -695,12 +671,13 @@ size_t LibDHCP::unpackVendorOptions4(const uint32_t vendor_id, const OptionBuffe
     size_t offset = 0;
 
     // Get the list of standard option definitions.
-    const OptionDefContainerPtr& option_defs = LibDHCP::getVendorOption4Defs(vendor_id);
+    const OptionDefContainerPtr option_defs_ptr =
+        LibDHCP::getVendorOptionDefs(Option::V4, vendor_id);
     // Get the search index #1. It allows to search for option definitions
     // using option code.
     const OptionDefContainerTypeIndex* idx = NULL;
-    if (option_defs) {
-        idx = &(option_defs->get<1>());
+    if (option_defs_ptr) {
+        idx = &(option_defs_ptr->get<1>());
     }
 
     // The buffer being read comprises a set of options, each starting with
@@ -787,7 +764,7 @@ size_t LibDHCP::unpackVendorOptions4(const uint32_t vendor_id, const OptionBuffe
             options.insert(std::make_pair(opt_type, opt));
             offset += opt_len;
 
-        } // end of data-chunk
+        }  // end of data-chunk
 
         break; // end of the vendor block.
     }
@@ -890,50 +867,16 @@ void LibDHCP::OptionFactoryRegister(Option::Universe u,
     return;
 }
 
-void
-LibDHCP::initStdOptionDefs4() {
-    initOptionSpace(v4option_defs_, STANDARD_V4_OPTION_DEFINITIONS,
-                    STANDARD_V4_OPTION_DEFINITIONS_SIZE);
-}
-
-void
-LibDHCP::initStdOptionDefs6() {
-    initOptionSpace(v6option_defs_, STANDARD_V6_OPTION_DEFINITIONS,
-                    STANDARD_V6_OPTION_DEFINITIONS_SIZE);
-    initOptionSpace(option_defs_[MAPE_V6_OPTION_SPACE], MAPE_V6_OPTION_DEFINITIONS,
-                    MAPE_V6_OPTION_DEFINITIONS_SIZE);
-    initOptionSpace(option_defs_[MAPT_V6_OPTION_SPACE], MAPT_V6_OPTION_DEFINITIONS,
-                    MAPT_V6_OPTION_DEFINITIONS_SIZE);
-    initOptionSpace(option_defs_[LW_V6_OPTION_SPACE], LW_V6_OPTION_DEFINITIONS,
-                    LW_V6_OPTION_DEFINITIONS_SIZE);
-    initOptionSpace(option_defs_[V4V6_RULE_OPTION_SPACE], V4V6_RULE_OPTION_DEFINITIONS,
-                    V4V6_RULE_OPTION_DEFINITIONS_SIZE);
-    initOptionSpace(option_defs_[V4V6_BIND_OPTION_SPACE], V4V6_BIND_OPTION_DEFINITIONS,
-                    V4V6_BIND_OPTION_DEFINITIONS_SIZE);
-}
-
-void
-LibDHCP::initLastResortOptionDefs() {
-    initOptionSpace(lastresort_defs_, LAST_RESORT_V4_OPTION_DEFINITIONS,
-                    LAST_RESORT_V4_OPTION_DEFINITIONS_SIZE);
-}
-
-void
-LibDHCP::initVendorOptsDocsis4() {
-    initOptionSpace(vendor4_defs_[VENDOR_ID_CABLE_LABS], DOCSIS3_V4_DEFS,
-                    DOCSIS3_V4_DEFS_SIZE);
-}
-
-void
-LibDHCP::initVendorOptsDocsis6() {
-    initOptionSpace(vendor6_defs_[VENDOR_ID_CABLE_LABS], DOCSIS3_V6_DEFS,
-                    DOCSIS3_V6_DEFS_SIZE);
-}
-
-void
-LibDHCP::initVendorOptsIsc6() {
-    initOptionSpace(vendor6_defs_[ENTERPRISE_ID_ISC], ISC_V6_OPTION_DEFINITIONS,
-                    ISC_V6_OPTION_DEFINITIONS_SIZE);
+void LibDHCP::initStdOptionDefs(const std::string &space) {
+    if (option_defs_.end() == option_defs_.find(space)) {
+        option_defs_[space] = OptionDefContainerPtr(new OptionDefContainer);
+        for (int i = 0; OPTION_DEF_PARAMS[i].optionDefParams; i++) {
+            if (space == OPTION_DEF_PARAMS[i].space) {
+                initOptionSpace(option_defs_[space], OPTION_DEF_PARAMS[i].optionDefParams, OPTION_DEF_PARAMS[i].size);
+                break;
+            }
+        }
+    }
 }
 
 uint32_t
index 2d29f1474bae08a29fe460e270544d29c47dcbf9..12866a9bde956b2b60db971424ba101626f5eddf 100644 (file)
@@ -9,6 +9,7 @@
 
 #include <dhcp/option_definition.h>
 #include <dhcp/option_space_container.h>
+#include <dhcp/option_space.h>
 #include <dhcp/pkt4.h>
 #include <dhcp/pkt6.h>
 #include <util/buffer.h>
@@ -281,21 +282,15 @@ public:
                                       uint16_t type,
                                       Option::Factory * factory);
 
-    /// @brief Returns v4 option definitions for a given vendor
+    /// @brief Returns option definitions for given universe and vendor
     ///
+    /// @param u option universe
     /// @param vendor_id enterprise-id of a given vendor
-    /// @return a container for a given vendor (or NULL if no option
-    ///         definitions are defined)
-    static const OptionDefContainerPtr&
-    getVendorOption4Defs(const uint32_t vendor_id);
-
-    /// @brief Returns v6 option definitions for a given vendor
     ///
-    /// @param vendor_id enterprise-id of a given vendor
     /// @return a container for a given vendor (or NULL if no option
     ///         definitions are defined)
-    static const OptionDefContainerPtr&
-    getVendorOption6Defs(const uint32_t vendor_id);
+    static const OptionDefContainerPtr
+    getVendorOptionDefs(Option::Universe u, const uint32_t vendor_id);
 
     /// @brief Parses provided buffer as DHCPv6 vendor options and creates
     ///        Option objects.
@@ -372,36 +367,14 @@ public:
 
 private:
 
-    /// Initialize standard DHCPv4 option definitions.
+    /// Initialize DHCP option definitions.
     ///
-    /// The method creates option definitions for all DHCPv4 options.
-    /// Currently this function is not implemented.
+    /// The method creates option definitions for all DHCP options.
     ///
     /// @throw std::bad alloc if system went out of memory.
     /// @throw MalformedOptionDefinition if any of the definitions
     /// are incorrect. This is programming error.
-    static void initStdOptionDefs4();
-
-    /// Initialize standard DHCPv6 option definitions.
-    ///
-    /// The method creates option definitions for all DHCPv6 options.
-    ///
-    /// @throw std::bad_alloc if system went out of memory.
-    /// @throw MalformedOptionDefinition if any of the definitions
-    /// is incorrect. This is a programming error.
-    static void initStdOptionDefs6();
-
-    /// Initialize last resort DHCPv4 option definitions.
-    static void initLastResortOptionDefs();
-
-    /// Initialize DOCSIS DHCPv4 option definitions.
-    static void initVendorOptsDocsis4();
-
-    /// Initialize DOCSIS DHCPv6 option definitions.
-    static void initVendorOptsDocsis6();
-
-    /// Initialize private DHCPv6 option definitions.
-    static void initVendorOptsIsc6();
+    static void initStdOptionDefs(const std::string& space);
 
     /// pointers to factories that produce DHCPv6 options
     static FactoryMap v4factories_;
@@ -409,24 +382,10 @@ private:
     /// pointers to factories that produce DHCPv6 options
     static FactoryMap v6factories_;
 
-    /// Container with DHCPv4 option definitions.
-    static OptionDefContainerPtr v4option_defs_;
-
-    /// Container with DHCPv6 option definitions.
-    static OptionDefContainerPtr v6option_defs_;
 
     /// Container that holds option definitions for various option spaces.
     static OptionDefContainers option_defs_;
 
-    /// Container for v4 vendor option definitions
-    static VendorOptionDefContainers vendor4_defs_;
-
-    /// Container for v6 vendor option definitions
-    static VendorOptionDefContainers vendor6_defs_;
-
-    /// Container with DHCPv4 last resort option definitions.
-    static OptionDefContainerPtr lastresort_defs_;
-
     /// Container for additional option definitions created in runtime.
     static util::StagedValue<OptionDefSpaceContainer> runtime_option_defs_;
 };
index b353286477b46b2ed13351e314b2ef6a562d2607..a28e9bf856e69b36d838c3d00d80876baa9a884c 100644 (file)
@@ -672,9 +672,9 @@ OptionDefinition::writeToBuffer(Option::Universe u,
             OptionDataTypeUtil::writePrefix(PrefixLen(len), address, buf);
 
             return;
-    }
+        }
     case OPT_PSID_TYPE:
-    {
+        {
         std::string txt = value;
 
         // first let's remove any whitespaces
index a19fb8910f0f46c9ca8b2fa06593ed79be54b5fc..368184d4eec0be92f621d147fd7dccf20aefffb7 100644 (file)
 #include <stdint.h>
 #include <string>
 
-#define DHCP4_OPTION_SPACE      "dhcp4"
-#define DHCP6_OPTION_SPACE      "dhcp6"
-#define MAPE_V6_OPTION_SPACE    "s46-cont-mape-options"
-#define MAPT_V6_OPTION_SPACE    "s46-cont-mapt-options"
-#define LW_V6_OPTION_SPACE      "s46-cont-lw-options"
-#define V4V6_RULE_OPTION_SPACE  "s46-rule-options"
-#define V4V6_BIND_OPTION_SPACE  "s46-v4v6bind-options"
+#define DHCP4_OPTION_SPACE          "dhcp4"
+#define DHCP6_OPTION_SPACE          "dhcp6"
+#define DOCSIS3_V4_OPTION_SPACE     "docsis3-v4"
+#define DOCSIS3_V6_OPTION_SPACE     "docsis3-v6"
+#define ISC_V6_OPTION_SPACE         "4o6"
+#define MAPE_V6_OPTION_SPACE        "s46-cont-mape-options"
+#define MAPT_V6_OPTION_SPACE        "s46-cont-mapt-options"
+#define LW_V6_OPTION_SPACE          "s46-cont-lw-options"
+#define V4V6_RULE_OPTION_SPACE      "s46-rule-options"
+#define V4V6_BIND_OPTION_SPACE      "s46-v4v6bind-options"
+#define LAST_RESORT_V4_OPTION_SPACE "last-resort-v4"
 
 namespace isc {
 namespace dhcp {
@@ -183,7 +187,7 @@ private:
     uint32_t enterprise_number_; ///< IANA assigned enterprise number.
 };
 
-} // namespace isc::dhcp
-} // namespace isc
+}  // namespace dhcp
+}  // namespace isc
 
 #endif // OPTION_SPACE_H
index b1f1042446e585c8025f0f9d87e32ae814fbb6b3..495c5d7305575ad1c3b35f0704a3283d2acdf6f2 100644 (file)
@@ -272,7 +272,8 @@ const OptionDefParams STANDARD_V4_OPTION_DEFINITIONS[] = {
 
 /// Number of option definitions defined.
 const int STANDARD_V4_OPTION_DEFINITIONS_SIZE =
-    sizeof(STANDARD_V4_OPTION_DEFINITIONS) / sizeof(STANDARD_V4_OPTION_DEFINITIONS[0]);
+    sizeof(STANDARD_V4_OPTION_DEFINITIONS) /
+    sizeof(STANDARD_V4_OPTION_DEFINITIONS[0]);
 
 /// Last resort definitions (only option 43 for now, these definitions
 /// are applied in deferred unpacking when none is found).
@@ -281,7 +282,9 @@ const OptionDefParams LAST_RESORT_V4_OPTION_DEFINITIONS[] = {
       OPT_EMPTY_TYPE, false, NO_RECORD_DEF, "vendor-encapsulated-options-space" }
 };
 
-const int LAST_RESORT_V4_OPTION_DEFINITIONS_SIZE = 1;
+const int LAST_RESORT_V4_OPTION_DEFINITIONS_SIZE =
+    sizeof(LAST_RESORT_V4_OPTION_DEFINITIONS) /
+    sizeof(LAST_RESORT_V4_OPTION_DEFINITIONS[0]);
 
 /// Start Definition of DHCPv6 options
 
@@ -425,7 +428,7 @@ const OptionDefParams STANDARD_V6_OPTION_DEFINITIONS[] = {
     { "v6-access-domain", D6O_V6_ACCESS_DOMAIN, OPT_FQDN_TYPE, false,
       NO_RECORD_DEF, "" },
     { "sip-ua-cs-list", D6O_SIP_UA_CS_LIST, OPT_FQDN_TYPE, true,
-      NO_RECORD_DEF, "" },      
+      NO_RECORD_DEF, "" },
     { "bootfile-url", D6O_BOOTFILE_URL, OPT_STRING_TYPE, false, NO_RECORD_DEF, "" },
     { "bootfile-param", D6O_BOOTFILE_PARAM, OPT_TUPLE_TYPE, true, NO_RECORD_DEF, "" },
     { "client-arch-type", D6O_CLIENT_ARCH_TYPE, OPT_UINT16_TYPE, true, NO_RECORD_DEF, "" },
@@ -544,9 +547,9 @@ const int V4V6_BIND_OPTION_DEFINITIONS_SIZE =
     sizeof(V4V6_BIND_OPTION_DEFINITIONS) /
     sizeof(V4V6_BIND_OPTION_DEFINITIONS[0]);
 
-} // unnamed namespace
+}  // namespace
 
-} // namespace dhcp
-} // namespace isc
+}  // namespace dhcp
+}  // namespace isc
 
 #endif // STD_OPTION_DEFS_H
index 43f64e7bbe7915dd7934a1f3051cd9648b655ba1..0c46ed984fe9a27655ab65120dd1eef8f638ec95 100644 (file)
@@ -24,7 +24,6 @@
 #include <dhcp/option_int.h>
 #include <dhcp/option_int_array.h>
 #include <dhcp/option_opaque_data_tuples.h>
-#include <dhcp/option_space.h>
 #include <dhcp/option_string.h>
 #include <dhcp/option_vendor.h>
 #include <dhcp/option_vendor_class.h>
@@ -437,7 +436,7 @@ TEST_F(LibDhcpTest, unpackOptions6) {
 
     EXPECT_NO_THROW ({
             LibDHCP::unpackOptions6(OptionBuffer(buf.begin(), buf.begin() + sizeof(v6packed)),
-                                    "dhcp6", options);
+                                    DHCP6_OPTION_SPACE, options);
     });
 
     EXPECT_EQ(options.size(), 6); // there should be 5 options
@@ -783,7 +782,7 @@ TEST_F(LibDhcpTest, unpackOptions4) {
     list<uint16_t> deferred;
 
     ASSERT_NO_THROW(
-        LibDHCP::unpackOptions4(v4packed, "dhcp4", options, deferred);
+        LibDHCP::unpackOptions4(v4packed, DHCP4_OPTION_SPACE, options, deferred);
     );
 
     isc::dhcp::OptionCollection::const_iterator x = options.find(12);
@@ -1835,8 +1834,8 @@ TEST_F(LibDhcpTest, getOptionDefByName4) {
 // This test checks if the definition of the DHCPv6 vendor option can
 // be searched by option name.
 TEST_F(LibDhcpTest, getVendorOptionDefByName6) {
-    const OptionDefContainerPtr& defs =
-        LibDHCP::getVendorOption6Defs(VENDOR_ID_CABLE_LABS);
+    const OptionDefContainerPtr defs =
+        LibDHCP::getVendorOptionDefs(Option::V6, VENDOR_ID_CABLE_LABS);
     ASSERT_TRUE(defs);
     for (OptionDefContainer::const_iterator def = defs->begin();
          def != defs->end(); ++def) {
@@ -1851,8 +1850,8 @@ TEST_F(LibDhcpTest, getVendorOptionDefByName6) {
 // This test checks if the definition of the DHCPv4 vendor option can
 // be searched by option name.
 TEST_F(LibDhcpTest, getVendorOptionDefByName4) {
-    const OptionDefContainerPtr& defs =
-        LibDHCP::getVendorOption4Defs(VENDOR_ID_CABLE_LABS);
+    const OptionDefContainerPtr defs =
+        LibDHCP::getVendorOptionDefs(Option::V4, VENDOR_ID_CABLE_LABS);
     ASSERT_TRUE(defs);
     for (OptionDefContainer::const_iterator def = defs->begin();
          def != defs->end(); ++def) {
@@ -1997,7 +1996,7 @@ TEST_F(LibDhcpTest, vendorClass6) {
     isc::util::encode::decodeHex(vendor_class_hex, bin);
 
     ASSERT_NO_THROW ({
-            LibDHCP::unpackOptions6(bin, "dhcp6", options);
+            LibDHCP::unpackOptions6(bin, DHCP6_OPTION_SPACE, options);
         });
 
     EXPECT_EQ(options.size(), 1); // There should be 1 option.
@@ -2116,7 +2115,7 @@ TEST_F(LibDhcpTest, sw46options) {
 
     OptionBuffer buf(mape_bin);
 
-    size_t parsed;
+    size_t parsed = 0;
 
     EXPECT_NO_THROW (parsed = LibDHCP::unpackOptions6(buf, "dhcp6", options));
     EXPECT_EQ(mape_bin.size(), parsed);
@@ -2175,4 +2174,4 @@ TEST_F(LibDhcpTest, sw46options) {
     EXPECT_EQ("type=00093, len=00004: 8 (uint8) len=6,psid=63 (psid)", portparam->toText());
 }
 
-} // end of anonymous space
+}  // end of anonymous space