# It's a basic scenario with four IPv6 subnets configured. In each
# subnet, there's a smaller pool of dynamic addresses.
+{ "Dhcp6":
+
{
# Kea is told to listen on eth0 interface only.
"interfaces": [ "eth0" ],
{ "pool": [ "2001:db8:4::/80" ],
"subnet": "2001:db8:4::/64" } ]
}
+
+}
+
// configuration from a JSON file.
isc::data::ConstElementPtr json;
+ isc::data::ConstElementPtr dhcp6;
isc::data::ConstElementPtr result;
// Basic sanity check: file name must not be empty.
// Read contents of the file and parse it as JSON
json = Element::fromJSONFile(file_name, true);
+ if (!json) {
+ LOG_ERROR(dhcp6_logger, DHCP6_CONFIG_LOAD_FAIL)
+ .arg("Config file " + file_name + " missing or empty.");
+ isc_throw(BadValue, "Unable to process JSON configuration file:"
+ + file_name);
+ }
+
+ // Get Dhcp6 component from the config
+ dhcp6 = json->get("Dhcp6");
+
+ if (!dhcp6) {
+ LOG_ERROR(dhcp6_logger, DHCP6_CONFIG_LOAD_FAIL)
+ .arg("Config file " + file_name + " does not include 'Dhcp6' entry.");
+ isc_throw(BadValue, "Unable to process JSON configuration file:"
+ + file_name);
+ }
+
// Use parsed JSON structures to configure the server
- result = processCommand("config-reload", json);
+ result = processCommand("config-reload", dhcp6);
} catch (const std::exception& ex) {
LOG_ERROR(dhcp6_logger, DHCP6_CONFIG_LOAD_FAIL).arg(ex.what());
TEST_F(JSONFileBackendTest, jsonFile) {
// Prepare configuration file.
- string config = "{ \"interfaces\": [ \"*\" ],"
+ string config = "{ \"Dhcp6\": { \"interfaces\": [ \"*\" ],"
"\"preferred-lifetime\": 3000,"
"\"rebind-timer\": 2000, "
"\"renew-timer\": 1000, "
" \"pool\": [ \"2001:db8:3::/80\" ],"
" \"subnet\": \"2001:db8:3::/64\" "
" } ],"
- "\"valid-lifetime\": 4000 }";
+ "\"valid-lifetime\": 4000 }"
+ "}";
writeFile(TEST_FILE, config);
// Now initialize the server
string config_hash_comments = "# This is a comment. It should be \n"
"#ignored. Real config starts in line below\n"
- "{ \"interfaces\": [ \"*\" ],"
+ "{ \"Dhcp6\": { \"interfaces\": [ \"*\" ],"
"\"preferred-lifetime\": 3000,"
"\"rebind-timer\": 2000, "
"\"renew-timer\": 1000, \n"
" \"pool\": [ \"2001:db8:1::/80\" ],"
" \"subnet\": \"2001:db8:1::/64\" "
" } ],"
- "\"valid-lifetime\": 4000 }";
+ "\"valid-lifetime\": 4000 }"
+ "}";
/// @todo: Implement C++-style (// ...) comments
/// @todo: Implement C-style (/* ... */) comments