Commit 393abcf8 authored by Tomek Mrugalski's avatar Tomek Mrugalski 🛰
Browse files

[3274] Support for relay information in parser for DHCPv6 added

parent a58621d8
......@@ -368,7 +368,7 @@ public:
/// @param ignored first parameter
/// stores global scope parameters, options, option defintions.
Subnet6ConfigParser(const std::string&)
:SubnetConfigParser("", globalContext()) {
:SubnetConfigParser("", globalContext(), IOAddress("::")) {
}
/// @brief Adds the created subnet to a server's configuration.
......@@ -381,6 +381,12 @@ public:
isc_throw(Unexpected,
"Invalid cast in Subnet4ConfigParser::commit");
}
// Set relay infomation if it was provided
if (relay_info_) {
sub6ptr->setRelay(*relay_info_);
}
isc::dhcp::CfgMgr::instance().addSubnet6(sub6ptr);
}
}
......@@ -408,6 +414,8 @@ protected:
parser = new StringParser(config_id, string_values_);
} else if (config_id.compare("pool") == 0) {
parser = new Pool6Parser(config_id, pools_);
} else if (config_id.compare("relay") == 0) {
parser = new RelayInfoParser(config_id, relay_info_, IOAddress("::"));
} else if (config_id.compare("pd-pools") == 0) {
parser = new PdPoolListParser(config_id, pools_);
} else if (config_id.compare("option-data") == 0) {
......
......@@ -2924,4 +2924,34 @@ TEST_F(Dhcp6ParserTest, allInterfaces) {
}
// This test checks if it is possible to specify relay information
TEST_F(Dhcp6ParserTest, subnetRelayInfo) {
ConstElementPtr status;
// A config with relay information.
string config = "{ \"interfaces\": [ \"*\" ],"
"\"rebind-timer\": 2000, "
"\"renew-timer\": 1000, "
"\"subnet6\": [ { "
" \"pool\": [ \"2001:db8:1::1 - 2001:db8:1::ffff\" ],"
" \"relay\": { "
" \"ip-address\": \"2001:db8:1::abcd\""
" },"
" \"subnet\": \"2001:db8:1::/64\" } ],"
"\"preferred-lifetime\": 3000, "
"\"valid-lifetime\": 4000 }";
ElementPtr json = Element::fromJSON(config);
EXPECT_NO_THROW(status = configureDhcp6Server(srv_, json));
// returned value should be 0 (configuration success)
checkResult(status, 0);
Subnet6Ptr subnet = CfgMgr::instance().getSubnet6(IOAddress("2001:db8:1::1"));
ASSERT_TRUE(subnet);
EXPECT_EQ("2001:db8:1::abcd", subnet->relay_.addr_.toText());
}
};
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