Commit bfaf5c81 authored by Marcin Siodelski's avatar Marcin Siodelski

[5305] Added shared-networks configuration to server config.

parent 1328552a
......@@ -25,6 +25,8 @@ SrvConfig::SrvConfig()
: sequence_(0), cfg_iface_(new CfgIface()),
cfg_option_def_(new CfgOptionDef()), cfg_option_(new CfgOption()),
cfg_subnets4_(new CfgSubnets4()), cfg_subnets6_(new CfgSubnets6()),
cfg_shared_networks4_(new CfgSharedNetworks4()),
cfg_shared_networks6_(new CfgSharedNetworks6()),
cfg_hosts_(new CfgHosts()), cfg_rsoo_(new CfgRSOO()),
cfg_expiration_(new CfgExpiration()), cfg_duid_(new CfgDUID()),
cfg_db_access_(new CfgDbAccess()),
......@@ -39,6 +41,8 @@ SrvConfig::SrvConfig(const uint32_t sequence)
: sequence_(sequence), cfg_iface_(new CfgIface()),
cfg_option_def_(new CfgOptionDef()), cfg_option_(new CfgOption()),
cfg_subnets4_(new CfgSubnets4()), cfg_subnets6_(new CfgSubnets6()),
cfg_shared_networks4_(new CfgSharedNetworks4()),
cfg_shared_networks6_(new CfgSharedNetworks6()),
cfg_hosts_(new CfgHosts()), cfg_rsoo_(new CfgRSOO()),
cfg_expiration_(new CfgExpiration()), cfg_duid_(new CfgDUID()),
cfg_db_access_(new CfgDbAccess()),
......@@ -228,14 +232,22 @@ SrvConfig::toElement() const {
dhcp->set("option-def", cfg_option_def_->toElement());
// Set option-data
dhcp->set("option-data", cfg_option_->toElement());
// Set subnets
// Set subnets and shared networks.
ConstElementPtr subnets;
if (family == AF_INET) {
subnets = cfg_subnets4_->toElement();
dhcp->set("subnet4", subnets);
ConstElementPtr shared_networks = cfg_shared_networks4_->toElement();
dhcp->set("shared-networks", shared_networks);
} else {
subnets = cfg_subnets6_->toElement();
dhcp->set("subnet6", subnets);
ConstElementPtr shared_networks = cfg_shared_networks6_->toElement();
dhcp->set("shared-networks", shared_networks);
}
// Insert reservations
CfgHostsList resv_list;
......
......@@ -17,6 +17,7 @@
#include <dhcpsrv/cfg_option.h>
#include <dhcpsrv/cfg_option_def.h>
#include <dhcpsrv/cfg_rsoo.h>
#include <dhcpsrv/cfg_shared_networks.h>
#include <dhcpsrv/cfg_subnets4.h>
#include <dhcpsrv/cfg_subnets6.h>
#include <dhcpsrv/cfg_mac_source.h>
......@@ -201,6 +202,24 @@ public:
return (cfg_subnets4_);
}
/// @brief Returns pointer to non-const object holding configuration of
/// shared networks in DHCPv4;
///
/// @return Pointer to the object holding shared networks configuration
/// for DHCPv4.
CfgSharedNetworks4Ptr getCfgSharedNetworks4() const {
return (cfg_shared_networks4_);
}
/// @brief Returns pointer to non-const object holding configuration of
/// shared networks in DHCPv6.
///
/// @return Pointer to the object holding shared networks configuration
/// for DHCPv6.
CfgSharedNetworks6Ptr getCfgSharedNetworks6() const {
return (cfg_shared_networks6_);
}
/// @brief Returns pointer to const object holding subnets configuration for
/// DHCPv4.
///
......@@ -573,6 +592,12 @@ private:
/// @brief Pointer to subnets configuration for IPv6.
CfgSubnets6Ptr cfg_subnets6_;
/// @brief Pointer to IPv4 shared networks configuration.
CfgSharedNetworks4Ptr cfg_shared_networks4_;
/// @brief Pointer to IPv4 shared networks configuration.
CfgSharedNetworks6Ptr cfg_shared_networks6_;
/// @brief Pointer to the configuration for hosts reservation.
///
/// This object holds a list of @c Host objects representing host
......
......@@ -448,11 +448,13 @@ TEST_F(SrvConfigTest, unparse) {
defaults += conf.getD2ClientConfig()->toElement()->str() + ",\n";
std::string defaults4 = "\"echo-client-id\": true,\n";
defaults4 += "\"shared-networks\": [ ],\n";
defaults4 += "\"subnet4\": [ ],\n";
defaults4 += "\"host-reservation-identifiers\": ";
defaults4 += "[ \"hw-address\", \"duid\", \"circuit-id\", \"client-id\" ],\n";
std::string defaults6 = "\"relay-supplied-options\": [ \"65\" ],\n";
defaults6 += "\"shared-networks\": [ ],\n";
defaults6 += "\"subnet6\": [ ],\n";
defaults6 += "\"server-id\": ";
defaults6 += conf.getCfgDUID()->toElement()->str() + ",\n";
......
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