<note>
Note that formerly, this parameter was a boolean and permitted only values
of <command>true</command> and <command>false</command>. Boolean values
- will still be accepted but may eventually be deprecated. A value of
- <command>true</command> equates to <command>when-present</command>,
- <command>false</command> equates to <command>never</command>.
+ have been deprecated and are no longer accepted. If you are currently using
+ booleans, you must replace them with the desired mode name. A value of
+ <command>true</command> maps to <command>"when-present"</command>, while
+ <command>false</command> maps to <command>"never"</command>.
</note>
For example, To instruct kea-dhcp6 to always generate the FQDN for a
hooks_parser->commit();
}
- {
- // Used to be done by parser commit
- D2ClientConfigPtr cfg;
- cfg = CfgMgr::instance().getStagingCfg()->getD2ClientConfig();
- CfgMgr::instance().setD2ClientConfig(cfg);
- }
+ // Apply the staged D2ClientConfig, used to be done by parser commit
+ D2ClientConfigPtr cfg;
+ cfg = CfgMgr::instance().getStagingCfg()->getD2ClientConfig();
+ CfgMgr::instance().setD2ClientConfig(cfg);
}
catch (const isc::Exception& ex) {
LOG_ERROR(dhcp4_logger, DHCP4_PARSER_COMMIT_FAIL).arg(ex.what());
// in a client request correctly, according to the replace-client-name
// mode configuration parameter.
//
- // @param mode - value to use client-name-replacment parameter - for
- // mode labels such as NEVER and ALWAYS must incluce enclosing quotes:
- // "\"NEVER\"". This allows us to also pass in boolean literals which
- // are unquoted.
+ // @param mode - value to use for replace-client-name
// @param client_name_flag - specifies whether or not the client request
// should contain a hostname option
// @param exp_replacement_flag - specifies whether or not the server is
"\"dhcp-ddns\": {"
"\"enable-updates\": true,"
"\"qualifying-suffix\": \"fake-suffix.isc.org.\","
- "\"replace-client-name\": %s"
+ "\"replace-client-name\": \"%s\""
"}}";
// Create the configuration and configure the server
// the supported modes.
TEST_F(NameDhcpv4SrvTest, replaceClientNameModeTest) {
- testReplaceClientNameMode("\"never\"",
+ testReplaceClientNameMode("never",
CLIENT_NAME_NOT_PRESENT, NAME_NOT_REPLACED);
- testReplaceClientNameMode("\"never\"",
+ testReplaceClientNameMode("never",
CLIENT_NAME_PRESENT, NAME_NOT_REPLACED);
- testReplaceClientNameMode("\"always\"",
+ testReplaceClientNameMode("always",
CLIENT_NAME_NOT_PRESENT, NAME_REPLACED);
- testReplaceClientNameMode("\"always\"",
+ testReplaceClientNameMode("always",
CLIENT_NAME_PRESENT, NAME_REPLACED);
- testReplaceClientNameMode("\"when-present\"",
+ testReplaceClientNameMode("when-present",
CLIENT_NAME_NOT_PRESENT, NAME_NOT_REPLACED);
- testReplaceClientNameMode("\"when-present\"",
+ testReplaceClientNameMode("when-present",
CLIENT_NAME_PRESENT, NAME_REPLACED);
- testReplaceClientNameMode("\"when-not-present\"",
+ testReplaceClientNameMode("when-not-present",
CLIENT_NAME_NOT_PRESENT, NAME_REPLACED);
- testReplaceClientNameMode("\"when-not-present\"",
+ testReplaceClientNameMode("when-not-present",
CLIENT_NAME_PRESENT, NAME_NOT_REPLACED);
}
parser = new DbAccessParser(config_id, DbAccessParser::HOSTS_DB);
} else if (config_id.compare("hooks-libraries") == 0) {
parser = new HooksLibrariesParser(config_id);
- } else if (config_id.compare("dhcp-ddns") == 0) {
- parser = new D2ClientConfigParser(config_id);
+ // dhcp-ddns has been converted to SimpleParser
} else if (config_id.compare("mac-sources") == 0) {
parser = new MACSourcesListConfigParser(config_id,
globalContext());
continue;
}
+ if (config_pair.first == "dhcp-ddns") {
+ D2ClientConfigParser parser;
+ D2ClientConfigPtr cfg = parser.parse(config_pair.second);
+ CfgMgr::instance().getStagingCfg()->setD2ClientConfig(cfg);
+ continue;
+ }
+
ParserPtr parser(createGlobal6DhcpConfigParser(config_pair.first,
config_pair.second));
LOG_DEBUG(dhcp6_logger, DBG_DHCP6_DETAIL, DHCP6_PARSER_CREATED)
if (hooks_parser) {
hooks_parser->commit();
}
+
+ // Apply staged D2ClientConfig, used to be done by parser commit
+ D2ClientConfigPtr cfg;
+ cfg = CfgMgr::instance().getStagingCfg()->getD2ClientConfig();
+ CfgMgr::instance().setD2ClientConfig(cfg);
}
catch (const isc::Exception& ex) {
LOG_ERROR(dhcp6_logger, DHCP6_PARSER_COMMIT_FAIL).arg(ex.what());
-// Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2017 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
return ("loggers");
case OUTPUT_OPTIONS:
return ("output-options");
+ case DHCP_DDNS:
+ return ("dhcp-ddns");
default:
return ("__unknown__");
}
-// Copyright (C) 2015-2016 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2015-2017 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
PARSER_OPTION_DATA,
/// This will parse the input as hooks-library.
- PARSER_HOOKS_LIBRARY
+ PARSER_HOOKS_LIBRARY,
+
+ /// This will parse the input as dhcp-ddns. (D2 client config)
+ PARSER_DHCP_DDNS
} ParserType;
/// @brief Default constructor.
LOGGERS,
/// Used while parsing Logging/loggers/output_options structures.
- OUTPUT_OPTIONS
+ OUTPUT_OPTIONS,
+
+ /// Used while parsing Dhcp6/dhcp-ddns
+ DHCP_DDNS
} ParserContext;
/// @brief File name
-// Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2017 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
"preferred-lifetime",
"valid-lifetime"
};
+
+/// @brief This table defines default values for D2 client configuration
+///
+const SimpleDefaults SimpleParser6::D2_CLIENT_CONFIG_DEFAULTS = {
+ { "server-ip", Element::string, "127.0.0.1" },
+ { "server-port", Element::integer, "53001" },
+ // default sender-ip depends on server-ip family, so we leave default blank
+ // parser knows to use the appropriate ZERO address based on server-ip
+ { "sender-ip", Element::string, "" },
+ { "sender-port", Element::integer, "0" },
+ { "max-queue-size", Element::integer, "1024" },
+ { "ncr-protocol", Element::string, "UDP" },
+ { "ncr-format", Element::string, "JSON" },
+ { "always-include-fqdn", Element::boolean, "false" },
+ { "override-no-update", Element::boolean, "false" },
+ { "override-client-update", Element::boolean, "false" },
+ { "replace-client-name", Element::string, "NEVER" },
+ { "generated-prefix", Element::string, "myhost" },
+ { "qualifying-suffix", Element::string, "" }
+};
+
/// @}
/// ---------------------------------------------------------------------------
}
}
+ ConstElementPtr d2_client = global->get("dhcp-ddns");
+ /// @todo - what if it's not in global? should we add it?
+ if (d2_client) {
+ // Because "dhcp-ddns" is a MapElement and global->get()
+ // returns a ConstElementPtr, then we get a map we can't
+ // change. So go thru gyrations to create a non-const
+ // map, update it with default values and then replace
+ // the one in global with the new one. Ick.
+ std::map<std::string, ConstElementPtr> d2_map;
+ d2_client->getValue(d2_map);
+ ElementPtr new_map(new MapElement());
+ new_map->setValue(d2_map);
+ cnt += SimpleParser::setDefaults(new_map, D2_CLIENT_CONFIG_DEFAULTS);
+ global->set("dhcp-ddns", new_map);
+ }
+
return (cnt);
}
static const isc::data::SimpleDefaults OPTION6_DEFAULTS;
static const isc::data::SimpleDefaults GLOBAL6_DEFAULTS;
static const isc::data::ParamsList INHERIT_GLOBAL_TO_SUBNET6;
+ static const isc::data::SimpleDefaults D2_CLIENT_CONFIG_DEFAULTS;
};
};
-// Copyright (C) 2014-2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2014-2017 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
" \"allow-client-update\" : true, "
" \"override-no-update\" : true, "
" \"override-client-update\" : true, "
- " \"replace-client-name\" : true, "
+ " \"replace-client-name\" : \"when-present\", "
" \"generated-prefix\" : \"test.prefix\", "
" \"qualifying-suffix\" : \"test.suffix.\" },"
"\"valid-lifetime\": 4000 }";
-// Copyright (C) 2013-2016 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013-2017 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// in a client request correctly, according to the replace-client-name
// mode configuration parameter.
//
- // @param mode - value to use client-name-replacment parameter - for
- // mode labels such as NEVER and ALWAYS must incluce enclosing quotes:
- // "\"NEVER\"". This allows us to also pass in boolean literals which
- // are unquoted.
+ // @param mode - value to use for replace-client-name mode
+ //
// @param client_name_flag - specifies whether or not the client request
// should contain a hostname option
// @param exp_replacement_flag - specifies whether or not the server is
"\"dhcp-ddns\": { \n"
"\"enable-updates\": true, \n"
"\"qualifying-suffix\": \"fake-suffix.isc.org.\", \n"
- "\"replace-client-name\": %s \n"
+ "\"replace-client-name\": \"%s\" \n"
"}} \n";
// Create the configuration and configure the server
TEST_F(FqdnDhcpv6SrvTest, replaceClientNameModeTest) {
isc::dhcp::test::IfaceMgrTestConfig test_config(true);
- // We pass mode labels in with enclosing quotes so we can also test
- // unquoted boolean literals true/false
- testReplaceClientNameMode("\"never\"",
+ testReplaceClientNameMode("never",
CLIENT_NAME_NOT_PRESENT, NAME_NOT_REPLACED);
- testReplaceClientNameMode("\"never\"",
+ testReplaceClientNameMode("never",
CLIENT_NAME_PRESENT, NAME_NOT_REPLACED);
- testReplaceClientNameMode("\"always\"",
+ testReplaceClientNameMode("always",
CLIENT_NAME_NOT_PRESENT, NAME_REPLACED);
- testReplaceClientNameMode("\"always\"",
+ testReplaceClientNameMode("always",
CLIENT_NAME_PRESENT, NAME_REPLACED);
- testReplaceClientNameMode("\"when-present\"",
+ testReplaceClientNameMode("when-present",
CLIENT_NAME_NOT_PRESENT, NAME_NOT_REPLACED);
- testReplaceClientNameMode("\"when-present\"",
+ testReplaceClientNameMode("when-present",
CLIENT_NAME_PRESENT, NAME_REPLACED);
- testReplaceClientNameMode("\"when-not-present\"",
+ testReplaceClientNameMode("when-not-present",
CLIENT_NAME_NOT_PRESENT, NAME_REPLACED);
- testReplaceClientNameMode("\"when-not-present\"",
- CLIENT_NAME_PRESENT, NAME_NOT_REPLACED);
-
- // Verify that boolean false produces the same result as RCM_NEVER
- testReplaceClientNameMode("false",
- CLIENT_NAME_NOT_PRESENT, NAME_NOT_REPLACED);
- testReplaceClientNameMode("false",
+ testReplaceClientNameMode("when-not-present",
CLIENT_NAME_PRESENT, NAME_NOT_REPLACED);
-
- // Verify that boolean true produces the same result as RCM_WHEN_PRESENT
- testReplaceClientNameMode("true",
- CLIENT_NAME_NOT_PRESENT, NAME_NOT_REPLACED);
- testReplaceClientNameMode("true",
- CLIENT_NAME_PRESENT, NAME_REPLACED);
}
} // end of anonymous namespace