void
InterfaceListConfigParser::build(ConstElementPtr value) {
+ // Copy the current interface configuration.
ConfigurationPtr config = CfgMgr::instance().getConfiguration();
- config->cfg_iface_.reset();
+ cfg_iface_ = config->cfg_iface_;
+ cfg_iface_.reset();
BOOST_FOREACH(ConstElementPtr iface, value->listValue()) {
std::string iface_name = iface->stringValue();
try {
- config->cfg_iface_.use(iface_name);
+ cfg_iface_.use(iface_name);
} catch (const std::exception& ex) {
isc_throw(DhcpConfigError, "Failed to select interface: "
void
InterfaceListConfigParser::commit() {
- // Do nothing. CfgMgr has been updated during build.
+ // Use the new configuration created in a build time.
+ CfgMgr::instance().getConfiguration()->cfg_iface_ = cfg_iface_;
}
bool
#include <dhcp/option_definition.h>
#include <dhcpsrv/d2_client_cfg.h>
#include <dhcpsrv/dhcp_config_parser.h>
+#include <dhcpsrv/cfg_iface.h>
#include <dhcpsrv/option_space_container.h>
#include <dhcpsrv/subnet.h>
#include <exceptions/exceptions.h>
/// @param value pointer to the content of parsed values
virtual void build(isc::data::ConstElementPtr value);
- /// @brief Does nothing.
+ /// @brief Assignes a parsed list of interfaces to the configuration.
+ ///
+ /// This is exception safe operation.
virtual void commit();
private:
// Parsed parameter name
std::string param_name_;
+
+ /// Holds the configuration created during
+ CfgIface cfg_iface_;
};
/// @brief Parser for hooks library list
// This should parse the configuration and add eth0 and eth1 to the list
// of interfaces that server should listen on.
parser->build(list_element);
+ parser->commit();
// Use CfgMgr instance to check if eth0 and eth1 was added, and that
// eth2 was not added.
cfg->cfg_iface_.reset();
parser->build(list_element);
+ parser->commit();
ASSERT_NO_THROW(cfg->cfg_iface_.openSockets(10000));
EXPECT_TRUE(test_config.socketOpen("eth0", AF_INET));