Commit 265ab8e4 authored by Marcin Siodelski's avatar Marcin Siodelski
Browse files

[3409] Log position of the elements in DHCPv6 config parser.

parent 5763b603
...@@ -231,30 +231,33 @@ public: ...@@ -231,30 +231,33 @@ public:
uint32_values_)); uint32_values_));
parser = code_parser; parser = code_parser;
} else { } else {
isc_throw(DhcpConfigError, "invalid parameter: " << entry); isc_throw(DhcpConfigError, "unsupported parameter: " << entry
<< " (" << param.second->getPosition() << ")");
} }
parser->build(param.second); parser->build(param.second);
parser->commit(); parser->commit();
} }
// Try to obtain the pool parameters. It will throw an exception if any
// of the required parameters are not present or invalid.
std::string addr_str;
uint32_t prefix_len;
uint32_t delegated_len;
try { try {
// We should now have all of the pool elements we need to create addr_str = string_values_->getParam("prefix");
// the pool. Fetch them and pass them into the Pool6 constructor. prefix_len = uint32_values_->getParam("prefix-len");
// The constructor is expected to enforce any value validation. delegated_len = uint32_values_->getParam("delegated-len");
const std::string addr_str = string_values_->getParam("prefix");
IOAddress addr(addr_str);
uint32_t prefix_len = uint32_values_->getParam("prefix-len");
uint32_t delegated_len = uint32_values_->getParam("delegated-len");
// Attempt to construct the local pool. // Attempt to construct the local pool.
pool_.reset(new Pool6(Lease::TYPE_PD, addr, prefix_len, pool_.reset(new Pool6(Lease::TYPE_PD, IOAddress(addr_str),
delegated_len)); prefix_len, delegated_len));
} catch (const std::exception& ex) { } catch (const std::exception& ex) {
isc_throw(isc::dhcp::DhcpConfigError, // Some parameters don't exist or are invalid. Since we are not
"PdPoolParser failed to build pool: " << ex.what()); // aware whether they don't exist or are invalid, let's append
// the position of the pool map element.
isc_throw(isc::dhcp::DhcpConfigError, ex.what()
<< " (" << pd_pool_->getPosition() << ")");
} }
} }
...@@ -319,7 +322,7 @@ public: ...@@ -319,7 +322,7 @@ public:
// Make sure we have a configuration elements to parse. // Make sure we have a configuration elements to parse.
if (!pd_pool_list) { if (!pd_pool_list) {
isc_throw(DhcpConfigError, isc_throw(DhcpConfigError,
"PdPoolListParser: list of pool definitions is empty"); "PdPoolListParser: list of pool definitions is NULL");
} }
// Loop through the list of pd pools. // Loop through the list of pd pools.
...@@ -379,7 +382,7 @@ public: ...@@ -379,7 +382,7 @@ public:
if (!sub6ptr) { if (!sub6ptr) {
// If we hit this, it is a programming error. // If we hit this, it is a programming error.
isc_throw(Unexpected, isc_throw(Unexpected,
"Invalid cast in Subnet4ConfigParser::commit"); "Invalid cast in Subnet6ConfigParser::commit");
} }
// Set relay infomation if it was provided // Set relay infomation if it was provided
...@@ -425,8 +428,7 @@ protected: ...@@ -425,8 +428,7 @@ protected:
global_context_, global_context_,
Dhcp6OptionDataParser::factory); Dhcp6OptionDataParser::factory);
} else { } else {
isc_throw(NotImplemented, isc_throw(NotImplemented, "unsupported parameter: " << config_id);
"parser error: Subnet6 parameter not supported: " << config_id);
} }
return (parser); return (parser);
......
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