// We validate them here rather than just relying on D2Param constructor
// so we can spit out config text position info with errors.
- // Fetch and validate io_address.
+ // Fetch and validate ip_address.
D2CfgContextPtr context = getD2CfgContext();
isc::dhcp::StringStoragePtr strings = context->getStringStorage();
- asiolink::IOAddress ip_address(strings->
- getOptionalParam("ip_address",
- D2Params::DFT_IP_ADDRESS));
+ asiolink::IOAddress ip_address(D2Params::DFT_IP_ADDRESS);
+
+ std::string ip_address_str = strings->getOptionalParam("ip_address",
+ D2Params::
+ DFT_IP_ADDRESS);
+ try {
+ ip_address = asiolink::IOAddress(ip_address_str);
+ } catch (const std::exception& ex) {
+ isc_throw(D2CfgError, "IP address invalid : \""
+ << ip_address_str << "\" : "
+ << strings->getPosition("ip_address"));
+ }
if ((ip_address.toText() == "0.0.0.0") || (ip_address.toText() == "::")) {
isc_throw(D2CfgError, "IP address cannot be \"" << ip_address << "\" : "
// Domains must have at least one server.
if (parsers_.size() == 0) {
- isc_throw (D2CfgError, "Server List must contain at least one server");
+ isc_throw (D2CfgError, "Server List must contain at least one server"
+ << " : " << server_list->getPosition());
}
}
objects_map.erase(it);
}
else {
- isc_throw(DCfgMgrBaseError, "Element:" << element_id <<
- " is listed in the parse order but is not "
- " present in the configuration");
+ isc_throw(DCfgMgrBaseError,
+ "Element required by parsing order is missing: "
+ << element_id << " : "
+ << config_set->getPosition());
}
}
}
}
+#-----
+,{
+"description" : "D2.forward_ddns.dhcp_ddns.dns_servers.ip_address invalid address ",
+"should_fail" : true,
+"data" :
+ {
+ "forward_ddns" :
+ {
+ "ddns_domains" :
+ [
+ {
+ "name" : "four.example.com.",
+ "dns_servers" :
+ [
+ {
+ "ip_address" : "bogus"
+ }
+ ]
+ }
+ ]
+ },
+ "reverse_ddns" : {},
+ "tsig_keys" : []
+ }
+}
+
+
#-----
,{
"description" : "D2.forward_ddns.dhcp_ddns.dns_servers.port valid value ",
"tsig_keys" : []
}
}
+#-----
+,{
+"description" : "D2.reverse_ddns.dhcp_ddns.dns_servers.ip_address invalid value",
+"should_fail" : true,
+"data" :
+ {
+ "forward_ddns" : {},
+ "reverse_ddns" :
+ {
+ "ddns_domains" :
+ [
+ {
+ "name" : "2.0.192.in-addr.arpa.",
+ "dns_servers" :
+ [
+ {
+ "ip_address" : "bogus"
+ }
+ ]
+ }
+ ]
+ },
+ "tsig_keys" : []
+ }
+}
+
#-----
,{