#include <boost/multi_index/sequenced_index.hpp>
#include <boost/multi_index/mem_fun.hpp>
#include <boost/multi_index/member.hpp>
+#include <boost/shared_ptr.hpp>
#include <stdint.h>
#include <string>
uint32_t> VendorOptionSpaceCollection;
/// @brief Container holding options grouped by vendor id.
VendorOptionSpaceCollection vendor_options_;
-
};
+/// @name Pointers to the @c CfgOption objects.
+//@{
+/// @brief Non-const pointer.
+typedef boost::shared_ptr<CfgOption> CfgOptionPtr;
+
+/// @brief Const pointer.
+typedef boost::shared_ptr<const CfgOption> ConstCfgOptionPtr;
+
+//@}
+
}
}
typename OptionSpaceMap::const_iterator other_it =
other.option_space_map_.find(it->first);
- if (other_it == option_space_map_.end()) {
+ if (other_it == other.option_space_map_.end()) {
return (false);
}
+ // If containers have different sizes it is an indication that
+ // they are unequal.
+ if (it->second->size() != other_it->second->size()) {
+ return (false);
+ }
+
+ // If they have the same sizes, we have to compare each element.
for (typename ContainerType::const_iterator items_it =
it->second->begin();
items_it != it->second->end(); ++items_it) {
- if (it->second->size() != other_it->second->size()) {
- return (false);
- }
-
bool match_found = false;
for (typename ContainerType::const_iterator other_items_it =
other_it->second->begin();
namespace dhcp {
SrvConfig::SrvConfig()
- : sequence_(0), cfg_option_def_(new CfgOptionDef()) {
+ : sequence_(0), cfg_option_def_(new CfgOptionDef()),
+ cfg_option_(new CfgOption()) {
}
-SrvConfig::SrvConfig(uint32_t sequence)
- : sequence_(sequence), cfg_option_def_(new CfgOptionDef()) {
+SrvConfig::SrvConfig(const uint32_t sequence)
+ : sequence_(sequence), cfg_option_def_(new CfgOptionDef()),
+ cfg_option_(new CfgOption()) {
}
std::string
new_config.setCfgIface(cfg_iface_);
// Replace option definitions.
cfg_option_def_->copyTo(*new_config.cfg_option_def_);
+ cfg_option_->copy(*new_config.cfg_option_);
}
void
}
// Logging information is equal between objects, so check other values.
return ((cfg_iface_ == other.cfg_iface_) &&
- (*cfg_option_def_ == *other.cfg_option_def_));
+ (*cfg_option_def_ == *other.cfg_option_def_) &&
+ (*cfg_option_ == *other.cfg_option_));
}
}
#define DHCPSRV_CONFIG_H
#include <dhcpsrv/cfg_iface.h>
+#include <dhcpsrv/cfg_option.h>
#include <dhcpsrv/cfg_option_def.h>
#include <dhcpsrv/logging_info.h>
#include <boost/shared_ptr.hpp>
/// @brief Constructor.
///
/// Sets arbitrary configuration sequence number.
- SrvConfig(uint32_t sequence);
+ SrvConfig(const uint32_t sequence);
/// @brief Returns summary of the configuration in the textual format.
///
return (cfg_option_def_);
}
+ /// @brief Returns pointer to the non-const object holding options.
+ ///
+ /// This method returns a pointer to the object which holds instances
+ /// of the options to be returned to the clients belonging to any subnet.
+ ///
+ /// @return Pointer to the object holding options.
+ CfgOptionPtr getCfgOption() {
+ return (cfg_option_);
+ }
+
+ /// @brief Returns pointer to the const object holding options.
+ ///
+ /// This method returns a pointer to the object which holds instances
+ /// of the options to be returned to the clients belonging to any subnet.
+ ///
+ /// @return Pointer to the object holding options.
+ const ConstCfgOptionPtr getCfgOption() const {
+ return (cfg_option_);
+ }
+
//@}
/// @brief Copies the currnet configuration to a new configuration.
/// by option space name.
CfgOptionDefPtr cfg_option_def_;
+ /// @brief Pointer to options (data) configuration.
+ ///
+ /// This object holds the instances of the options to be sent to clients
+ /// connected to any subnet.
+ CfgOptionPtr cfg_option_;
+
};
/// @name Pointers to the @c SrvConfig object.
conf1.addLoggingInfo(info);
conf1.setCfgIface(cfg_iface);
- conf1.getCfgOptionDef()->add(OptionDefinitionPtr(new OptionDefinition("option-foo", 5,
- "string")), "isc");
+
+ // Add option definition.
+ OptionDefinitionPtr def(new OptionDefinition("option-foo", 5, "string"));
+ conf1.getCfgOptionDef()->add(def, "isc");
+
+ // Add an option.
+ OptionPtr option(new Option(Option::V6, 1000, OptionBuffer(10, 0xFF)));
+ conf1.getCfgOption()->add(option, true, "dhcp6");
// Make sure both configurations are different.
ASSERT_TRUE(conf1 != conf2);
"uint16_t")), "isc");
EXPECT_TRUE(conf1 == conf2);
EXPECT_FALSE(conf1 != conf2);
+
+ // Differ by option data.
+ OptionPtr option(new Option(Option::V6, 1000, OptionBuffer(1, 0xFF)));
+ conf1.getCfgOption()->add(option, false, "isc");
+
+ EXPECT_FALSE(conf1 == conf2);
+ EXPECT_TRUE(conf1 != conf2);
+
+ conf2.getCfgOption()->add(option, false, "isc");
+
+ EXPECT_TRUE(conf1 == conf2);
+ EXPECT_FALSE(conf1 != conf2);
}
} // end of anonymous namespace