Commit 207b4e83 authored by Razvan Becheriu's avatar Razvan Becheriu

[#889] addressed review

parent 4a2f150e
...@@ -88,21 +88,15 @@ void initOptionSpace(OptionDefContainerPtr& defs, ...@@ -88,21 +88,15 @@ void initOptionSpace(OptionDefContainerPtr& defs,
const OptionDefParams* params, const OptionDefParams* params,
size_t params_size); size_t params_size);
bool initialized = LibDHCP::initOptionDefs(); bool LibDHCP::initialized_ = LibDHCP::initOptionDefs();
const OptionDefContainerPtr const OptionDefContainerPtr
LibDHCP::getOptionDefs(const std::string& space) { 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 (option_defs_.end() == option_defs_.find(space)) {
isc_throw(isc::Unexpected, "option definitions should have been "
"automatically initialized at process startup");
}
OptionDefContainers::const_iterator container = option_defs_.find(space); OptionDefContainers::const_iterator container = option_defs_.find(space);
if (container != option_defs_.end()) { if (container != option_defs_.end()) {
return (container->second); return (container->second);
} }
return (null_option_def_container_); return (null_option_def_container_);
} }
...@@ -119,6 +113,7 @@ LibDHCP::getVendorOptionDefs(const Option::Universe u, const uint32_t vendor_id) ...@@ -119,6 +113,7 @@ LibDHCP::getVendorOptionDefs(const Option::Universe u, const uint32_t vendor_id)
return getOptionDefs(ISC_V6_OPTION_SPACE); return getOptionDefs(ISC_V6_OPTION_SPACE);
} }
} }
return (null_option_def_container_); return (null_option_def_container_);
} }
...@@ -130,6 +125,7 @@ LibDHCP::getOptionDef(const std::string& space, const uint16_t code) { ...@@ -130,6 +125,7 @@ LibDHCP::getOptionDef(const std::string& space, const uint16_t code) {
if (range.first != range.second) { if (range.first != range.second) {
return (*range.first); return (*range.first);
} }
return (OptionDefinitionPtr()); return (OptionDefinitionPtr());
} }
...@@ -141,6 +137,7 @@ LibDHCP::getOptionDef(const std::string& space, const std::string& name) { ...@@ -141,6 +137,7 @@ LibDHCP::getOptionDef(const std::string& space, const std::string& name) {
if (range.first != range.second) { if (range.first != range.second) {
return (*range.first); return (*range.first);
} }
return (OptionDefinitionPtr()); return (OptionDefinitionPtr());
} }
...@@ -158,6 +155,7 @@ LibDHCP::getVendorOptionDef(const Option::Universe u, const uint32_t vendor_id, ...@@ -158,6 +155,7 @@ LibDHCP::getVendorOptionDef(const Option::Universe u, const uint32_t vendor_id,
if (range.first != range.second) { if (range.first != range.second) {
return (*range.first); return (*range.first);
} }
return (OptionDefinitionPtr()); return (OptionDefinitionPtr());
} }
...@@ -178,6 +176,7 @@ LibDHCP::getVendorOptionDef(const Option::Universe u, const uint32_t vendor_id, ...@@ -178,6 +176,7 @@ LibDHCP::getVendorOptionDef(const Option::Universe u, const uint32_t vendor_id,
if (range.first != range.second) { if (range.first != range.second) {
return (*range.first); return (*range.first);
} }
return (OptionDefinitionPtr()); return (OptionDefinitionPtr());
} }
...@@ -270,6 +269,7 @@ LibDHCP::getLastResortOptionDefs(const std::string& space) { ...@@ -270,6 +269,7 @@ LibDHCP::getLastResortOptionDefs(const std::string& space) {
if (space == DHCP4_OPTION_SPACE) { if (space == DHCP4_OPTION_SPACE) {
return getOptionDefs(LAST_RESORT_V4_OPTION_SPACE); return getOptionDefs(LAST_RESORT_V4_OPTION_SPACE);
} }
return (null_option_def_container_); return (null_option_def_container_);
} }
...@@ -907,7 +907,8 @@ LibDHCP::initOptionDefs() { ...@@ -907,7 +907,8 @@ LibDHCP::initOptionDefs() {
OPTION_DEF_PARAMS[i].optionDefParams, OPTION_DEF_PARAMS[i].optionDefParams,
OPTION_DEF_PARAMS[i].size); OPTION_DEF_PARAMS[i].size);
} }
return true;
return (true);
} }
uint32_t uint32_t
......
...@@ -363,6 +363,8 @@ public: ...@@ -363,6 +363,8 @@ public:
/// @return vendor id. /// @return vendor id.
static uint32_t optionSpaceToVendorId(const std::string& option_space); static uint32_t optionSpaceToVendorId(const std::string& option_space);
private:
/// Initialize DHCP option definitions. /// Initialize DHCP option definitions.
/// ///
/// The method creates option definitions for all DHCP options. /// The method creates option definitions for all DHCP options.
...@@ -372,7 +374,8 @@ public: ...@@ -372,7 +374,8 @@ public:
/// are incorrect. This is programming error. /// are incorrect. This is programming error.
static bool initOptionDefs(); static bool initOptionDefs();
private: /// flag which indicates initialization state
static bool initialized_;
/// pointers to factories that produce DHCPv6 options /// pointers to factories that produce DHCPv6 options
static FactoryMap v4factories_; static FactoryMap v4factories_;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment