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"));
+ << 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 << "\" : "
- << strings->getPosition("ip_address"));
+ isc_throw(D2CfgError, "IP address cannot be \"" << ip_address << "\" ("
+ << strings->getPosition("ip_address") << ")");
}
// Fetch and validate port.
uint32_t port = ints->getOptionalParam("port", D2Params::DFT_PORT);
if (port == 0) {
- isc_throw(D2CfgError, "port cannot be 0 : "
- << ints->getPosition("port"));
+ isc_throw(D2CfgError, "port cannot be 0 ("
+ << ints->getPosition("port") << ")");
}
// Fetch and validate dns_server_timeout.
D2Params::DFT_DNS_SERVER_TIMEOUT);
if (dns_server_timeout < 1) {
- isc_throw(D2CfgError, "DNS server timeout must be larger than 0 : "
- << ints->getPosition("dns_server_timeout"));
+ isc_throw(D2CfgError, "DNS server timeout must be larger than 0 ("
+ << ints->getPosition("dns_server_timeout") << ")");
}
// Fetch and validate ncr_protocol.
DFT_NCR_PROTOCOL));
} catch (const std::exception& ex) {
isc_throw(D2CfgError, "ncr_protocol : "
- << ex.what() << " : "
- << strings->getPosition("ncr_protocol"));
+ << ex.what() << " ("
+ << strings->getPosition("ncr_protocol") << ")");
}
if (ncr_protocol != dhcp_ddns::NCR_UDP) {
isc_throw(D2CfgError, "ncr_protocol : "
<< dhcp_ddns::ncrProtocolToString(ncr_protocol)
- << " is not yet supported : "
- << strings->getPosition("ncr_protocol"));
+ << " is not yet supported ("
+ << strings->getPosition("ncr_protocol") << ")");
}
// Fetch and validate ncr_format.
DFT_NCR_FORMAT));
} catch (const std::exception& ex) {
isc_throw(D2CfgError, "ncr_format : "
- << ex.what() << " : "
- << strings->getPosition("ncr_format"));
+ << ex.what() << " ("
+ << strings->getPosition("ncr_format") << ")");
}
if (ncr_format != dhcp_ddns::FMT_JSON) {
isc_throw(D2CfgError, "NCR Format:"
<< dhcp_ddns::ncrFormatToString(ncr_format)
- << " is not yet supported : "
- << strings->getPosition("ncr_format"));
+ << " is not yet supported ("
+ << strings->getPosition("ncr_format") << ")");
}
// Attempt to create the new client config. This ought to fly as
std::string name;
std::string algorithm;
std::string secret;
- std::vector<isc::data::Element::Position> pos;
+ std::map<std::string, isc::data::Element::Position> pos;
// Fetch the key's parsed scalar values from parser's local storage.
// All are required, if any are missing we'll throw.
try {
- pos.push_back(local_scalars_.getParam("name", name));
- pos.push_back(local_scalars_.getParam("algorithm", algorithm));
- pos.push_back(local_scalars_.getParam("secret", secret));
+ pos["name"] = local_scalars_.getParam("name", name);
+ pos["algorithm"] = local_scalars_.getParam("algorithm", algorithm);
+ pos["secret"] = local_scalars_.getParam("secret", secret);
} catch (const std::exception& ex) {
isc_throw(D2CfgError, "TSIG Key incomplete : " << ex.what()
- << " : " << key_config->getPosition());
+ << " (" << key_config->getPosition() << ")");
}
// Name cannot be blank.
if (name.empty()) {
- isc_throw(D2CfgError, "TSIG key must specify name : " << pos[0]);
+ isc_throw(D2CfgError, "TSIG key must specify name (" << pos["name"] << ")");
}
// Currently, the premise is that key storage is always empty prior to
// are not allowed and should be flagged as a configuration error.
if (keys_->find(name) != keys_->end()) {
isc_throw(D2CfgError, "Duplicate TSIG key name specified : " << name
- << " : " << pos[0]);
+ << " (" << pos["name"] << ")");
}
// Algorithm must be valid.
try {
TSIGKeyInfo::stringToAlgorithmName(algorithm);
} catch (const std::exception& ex) {
- isc_throw(D2CfgError, "TSIG key : " << ex.what() << " : " << pos[1]);
+ isc_throw(D2CfgError, "TSIG key : " << ex.what() << " (" << pos["algorithm"] << ")");
}
// Secret cannot be blank.
- // Cryptolink lib doesn't offer anyway to validate these. As long as it
+ // Cryptolink lib doesn't offer any way to validate these. As long as it
// isn't blank we'll accept it. If the content is bad, the call to in
// TSIGKeyInfo::remakeKey() made in the TSIGKeyInfo ctor will throw.
// We'll deal with that below.
if (secret.empty()) {
- isc_throw(D2CfgError, "TSIG key must specify secret : " << pos[2]);
+ isc_throw(D2CfgError, "TSIG key must specify secret (" << pos["secret"] << ")");
}
// Everything should be valid, so create the key instance.
try {
key_info.reset(new TSIGKeyInfo(name, algorithm, secret));
} catch (const std::exception& ex) {
- isc_throw(D2CfgError, ex.what() << " : " << key_config->getPosition());
+ isc_throw(D2CfgError, ex.what() << " (" << key_config->getPosition() << ")");
}
} else {
isc_throw(NotImplemented,
"parser error: TSIGKeyInfo parameter not supported: "
- << config_id << " : " << pos);
+ << config_id << " (" << pos << ")");
}
// Return the new parser instance.
std::string hostname;
std::string ip_address;
uint32_t port = DnsServerInfo::STANDARD_DNS_PORT;
- std::vector<isc::data::Element::Position> pos;
+ std::map<std::string, isc::data::Element::Position> pos;
// Fetch the server configuration's parsed scalar values from parser's
// local storage. They're all optional, so no try-catch here.
- pos.push_back(local_scalars_.getParam("hostname", hostname,
- DCfgContextBase::OPTIONAL));
- pos.push_back(local_scalars_.getParam("ip_address", ip_address,
- DCfgContextBase::OPTIONAL));
- pos.push_back(local_scalars_.getParam("port", port,
- DCfgContextBase::OPTIONAL));
+ pos["hostname"] = local_scalars_.getParam("hostname", hostname,
+ DCfgContextBase::OPTIONAL);
+ pos["ip_address"] = local_scalars_.getParam("ip_address", ip_address,
+ DCfgContextBase::OPTIONAL);
+ pos["port"] = local_scalars_.getParam("port", port,
+ DCfgContextBase::OPTIONAL);
// The configuration must specify one or the other.
if (hostname.empty() == ip_address.empty()) {
isc_throw(D2CfgError, "Dns Server must specify one or the other"
" of hostname or IP address"
- << " : " << server_config->getPosition());
+ << " (" << server_config->getPosition() << ")");
}
// Port cannot be zero.
if (port == 0) {
isc_throw(D2CfgError, "Dns Server : port cannot be 0"
- << " : " << pos[2]);
+ << " (" << pos["port"] << ")");
}
DnsServerInfoPtr serverInfo;
/// processing.
/// Until then we'll throw unsupported.
isc_throw(D2CfgError, "Dns Server : hostname is not yet supported"
- << " : " << pos[0]);
+ << " (" << pos["hostname"] << ")");
} else {
try {
// Create an IOAddress from the IP address string given and then
serverInfo.reset(new DnsServerInfo(hostname, io_addr, port));
} catch (const isc::asiolink::IOError& ex) {
isc_throw(D2CfgError, "Dns Server : invalid IP address : "
- << ip_address << " : " << pos[1]);
+ << ip_address << " (" << pos["ip_address"] << ")");
}
}
} else {
isc_throw(NotImplemented,
"parser error: DnsServerInfo parameter not supported: "
- << config_id << " : " << pos);
+ << config_id << " (" << pos << ")");
}
// Return the new parser instance.
// Domains must have at least one server.
if (parsers_.size() == 0) {
isc_throw (D2CfgError, "Server List must contain at least one server"
- << " : " << server_list->getPosition());
+ << " (" << server_list->getPosition() << ")");
}
}
// Now construct the domain.
std::string name;
std::string key_name;
- std::vector<isc::data::Element::Position> pos;
+ std::map<std::string, isc::data::Element::Position> pos;
+
// Fetch the parsed scalar values from parser's local storage.
// Any required that are missing will throw.
try {
- pos.push_back(local_scalars_.getParam("name", name));
- pos.push_back(local_scalars_.getParam("key_name", key_name,
- DCfgContextBase::OPTIONAL));
+ pos["name"] = local_scalars_.getParam("name", name);
+ pos["key_name"] = local_scalars_.getParam("key_name", key_name,
+ DCfgContextBase::OPTIONAL);
} catch (const std::exception& ex) {
isc_throw(D2CfgError, "DdnsDomain incomplete : " << ex.what()
- << " : " << domain_config->getPosition());
+ << " (" << domain_config->getPosition() << ")");
}
// Blank domain names are not allowed.
if (name.empty()) {
- isc_throw(D2CfgError, "DndsDomain : name cannot be blank : "
- << pos[0]);
+ isc_throw(D2CfgError, "DndsDomain : name cannot be blank ("
+ << pos["name"] << ")");
}
// Currently, the premise is that domain storage is always empty
// error.
if (domains_->find(name) != domains_->end()) {
isc_throw(D2CfgError, "Duplicate domain specified:" << name
- << " : " << pos[0]);
+ << " (" << pos["name"] << ")");
}
// Key name is optional. If it is not blank, then find the key in the
if (!tsig_key_info) {
isc_throw(D2CfgError, "DdnsDomain : " << name
<< " specifies an undefined key: " << key_name
- << " : " << pos[1]);
+ << " (" << pos["key_name"] << ")");
}
}
} else {
isc_throw(NotImplemented,
"parser error: DdnsDomain parameter not supported: "
- << config_id << " : " << pos);
+ << config_id << " (" << pos << ")");
}
// Return the new domain parser instance.
} else {
isc_throw(NotImplemented, "parser error: "
"DdnsDomainListMgr parameter not supported: " << config_id
- << " : " << pos);
+ << " (" << pos << ")");
}
// Return the new domain parser instance.