Commit 8a21830a authored by Marcin Siodelski's avatar Marcin Siodelski
Browse files

[2491] Added function to get a single option definition using a code.

parent ac111116
......@@ -45,7 +45,7 @@ OptionDefContainer LibDHCP::v4option_defs_;
OptionDefContainer LibDHCP::v6option_defs_;
const OptionDefContainer&
LibDHCP::getOptionDefs(Option::Universe u) {
LibDHCP::getOptionDefs(const Option::Universe u) {
switch (u) {
case Option::V4:
initStdOptionDefs4();
......@@ -60,6 +60,17 @@ LibDHCP::getOptionDefs(Option::Universe u) {
}
}
OptionDefinitionPtr
LibDHCP::getOptionDef(const Option::Universe u, const uint16_t code) {
const OptionDefContainer& defs = getOptionDefs(u);
const OptionDefContainerTypeIndex& idx = defs.get<1>();
const OptionDefContainerTypeRange& range = idx.equal_range(code);
if (range.first != range.second) {
return (*range.first);
}
return (OptionDefinitionPtr());
}
OptionPtr
LibDHCP::optionFactory(Option::Universe u,
uint16_t type,
......
......@@ -42,7 +42,18 @@ public:
/// @param u universe of the options (V4 or V6).
///
/// @return collection of option definitions.
static const OptionDefContainer& getOptionDefs(Option::Universe u);
static const OptionDefContainer& getOptionDefs(const Option::Universe u);
/// @brief Return the first option definition matching a
/// particular option code.
///
/// @param u universe (V4 or V6)
/// @param code option code.
///
/// @return reference to an option definition being requested
/// or NULL pointer if option definition has not been found.
static OptionDefinitionPtr getOptionDef(const Option::Universe u,
const uint16_t code);
/// @brief Factory function to create instance of option.
///
......
Supports Markdown
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