Commit 38719d4f authored by Marcin Siodelski's avatar Marcin Siodelski
Browse files

[5305] Migrated SharedNetwork6Parser to SimpleParser.

parent e624c91a
......@@ -70,42 +70,36 @@ SharedNetwork6Parser::parse(const data::ConstElementPtr& shared_network_data) {
SharedNetwork6Ptr shared_network;
std::string name;
try {
// Shared network is a map.
const auto& element = shared_network_data->mapValue();
// Make sure that the network name has been specified. The name is required
// to create a SharedNetwork6 object.
const auto& name_it = element.find("name");
if (name_it == element.cend()) {
isc_throw(DhcpConfigError, "parameter \"name\" must be specified for"
" a shared network");
std::string name = getString(shared_network_data, "name");
shared_network.reset(new SharedNetwork6(name));
// Interface is an optional parameter
if (shared_network_data->contains("interface")) {
shared_network->setIface(getString(shared_network_data, "interface"));
}
shared_network.reset(new SharedNetwork6(name_it->second->stringValue()));
// Iterate over all parameters within the map and assign them to the
// shared network.
for (auto param = element.cbegin(); param != element.cend(); ++param) {
if (param->first == "interface") {
shared_network->setIface(param->second->stringValue());
} else if (param->first == "option-data") {
// Create parser instance for option-data.
CfgOptionPtr cfg_option = shared_network->getCfgOption();
OptionDataListParser parser(AF_INET6);
parser.parse(cfg_option, param->second);
} else if (param->first == "subnet6") {
// Create parser instance of subnet6.
Subnets6ListConfigParser parser;
Subnet6Collection subnets;
parser.parse(subnets, param->second);
// Add all returned subnets into shared network.
for (auto subnet = subnets.cbegin(); subnet != subnets.cend();
++subnet) {
shared_network->add(*subnet);
}
if (shared_network_data->contains("option-data")) {
auto json = shared_network_data->get("option-data");
// Create parser instance for option-data.
CfgOptionPtr cfg_option = shared_network->getCfgOption();
OptionDataListParser parser(AF_INET6);
parser.parse(cfg_option, json);
}
if (shared_network_data->contains("subnet6")) {
auto json = shared_network_data->get("subnet6");
// Create parser instance of subnet6.
Subnets6ListConfigParser parser;
Subnet6Collection subnets;
parser.parse(subnets, json);
// Add all returned subnets into shared network.
for (auto subnet = subnets.cbegin(); subnet != subnets.cend();
++subnet) {
shared_network->add(*subnet);
}
}
......
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