From 0fe888f4cdeba873ee8ab96c4a38b1ed915b880b Mon Sep 17 00:00:00 2001 From: Thomas Markwalder Date: Wed, 15 Feb 2017 14:57:47 -0500 Subject: [PATCH] [5110] Addressed review comments part 1 Fixed unused parameter errors Fixed doxygen errors Commentary changes Removed reference to .spec file from commentary TSIGKeyListParser now uses only one instance of TSIGKeyInfoParser src/bin/d2/d2_parser.yy - added upper limit to port tests Updated unit tests to use "example.com" --- src/bin/d2/d2_cfg_mgr.h | 6 +- src/bin/d2/d2_config.cc | 2 +- src/bin/d2/d2_config.h | 38 ++-- src/bin/d2/d2_parser.cc | 190 +++++++++--------- src/bin/d2/d2_parser.h | 12 +- src/bin/d2/d2_parser.yy | 8 +- src/bin/d2/d2_simple_parser.h | 5 +- src/bin/d2/location.hh | 9 +- src/bin/d2/parser_context.cc | 6 +- src/bin/d2/parser_context.h | 3 - src/bin/d2/position.hh | 9 +- src/bin/d2/stack.hh | 9 +- src/bin/d2/tests/d2_cfg_mgr_unittests.cc | 52 ++--- src/bin/d2/tests/d2_process_unittests.cc | 10 +- src/bin/d2/tests/d2_simple_parser_unittest.cc | 56 +++--- src/bin/d2/tests/nc_test_utils.cc | 8 +- src/bin/d2/tests/testdata/d2_cfg_tests.json | 6 +- src/lib/process/d_cfg_mgr.cc | 9 + src/lib/process/d_cfg_mgr.h | 8 +- src/lib/process/d_controller.cc | 10 +- src/lib/process/d_controller.h | 5 +- 21 files changed, 230 insertions(+), 231 deletions(-) diff --git a/src/bin/d2/d2_cfg_mgr.h b/src/bin/d2/d2_cfg_mgr.h index 004dd45004..e85ebcda7b 100644 --- a/src/bin/d2/d2_cfg_mgr.h +++ b/src/bin/d2/d2_cfg_mgr.h @@ -58,7 +58,7 @@ public: } /// @brief Sets the forward domain list manager - /// @param pointer to the new forward manager + /// @param forward_mgr pointer to the new forward manager void setForwardMgr(DdnsDomainListMgrPtr forward_mgr) { forward_mgr_ = forward_mgr; } @@ -71,7 +71,7 @@ public: } /// @brief Sets the reverse domain list manager - /// @param pointer to the new reverse manager + /// @param reverse_mgr pointer to the new reverse manager void setReverseMgr(DdnsDomainListMgrPtr reverse_mgr) { reverse_mgr_ = reverse_mgr; } @@ -85,7 +85,7 @@ public: /// @brief Sets the map of TSIG keys /// - /// @param pointer to the new TSIG key map + /// @param keys pointer to the new TSIG key map void setKeys(const TSIGKeyInfoMapPtr& keys) { keys_ = keys; } diff --git a/src/bin/d2/d2_config.cc b/src/bin/d2/d2_config.cc index 090db6696c..f2e2a5c3d2 100644 --- a/src/bin/d2/d2_config.cc +++ b/src/bin/d2/d2_config.cc @@ -389,8 +389,8 @@ TSIGKeyInfoMapPtr TSIGKeyInfoListParser::parse(data::ConstElementPtr key_list) { TSIGKeyInfoMapPtr keys(new TSIGKeyInfoMap()); data::ConstElementPtr key_config; + TSIGKeyInfoParser key_parser; BOOST_FOREACH(key_config, key_list->listValue()) { - TSIGKeyInfoParser key_parser; TSIGKeyInfoPtr key = key_parser.parse(key_config); // Duplicates are not allowed and should be flagged as an error. diff --git a/src/bin/d2/d2_config.h b/src/bin/d2/d2_config.h index c8a6d79bb9..8b246e66d6 100644 --- a/src/bin/d2/d2_config.h +++ b/src/bin/d2/d2_config.h @@ -50,9 +50,6 @@ namespace d2 { /// that the application can carry out DNS update exchanges with it. Servers /// are represented by the class, DnsServerInfo. /// -/// The configuration specification for use with Kea is detailed in the file -/// dhcp-ddns.spec. -/// /// The parsing class hierarchy reflects this same scheme. Working top down: /// /// A DdnsDomainListMgrParser parses a managed domain list entry. It handles @@ -731,9 +728,9 @@ typedef boost::shared_ptr DScalarContextPtr; /// @brief Parser for TSIGKeyInfo /// -/// This class parses the configuration element "tsig-key" defined in -/// src/bin/d2/dhcp-ddns.spec and creates an instance of a TSIGKeyInfo. -class TSIGKeyInfoParser : public data::SimpleParser { +/// This class parses the configuration element "tsig-key" +/// and creates an instance of a TSIGKeyInfo. +class TSIGKeyInfoParser : public data::SimpleParser { public: /// @brief Performs the actual parsing of the given "tsig-key" element. /// @@ -750,29 +747,28 @@ public: /// @brief Parser for a list of TSIGKeyInfos /// /// This class parses a list of "tsig-key" configuration elements. -/// (see src/bin/d2/dhcp-ddns.spec). The TSIGKeyInfo instances are added -/// to the given storage upon commit. +/// The TSIGKeyInfo instances are added to the given storage upon commit. class TSIGKeyInfoListParser : public data::SimpleParser { public: /// @brief Performs the parsing of the given list "tsig-key" elements. /// /// Creates an empty TSIGKeyInfoMap /// + /// Instantiates a TSIGKeyInfoParser /// It iterates over each key entry in the list: - /// 1. Instantiate a TSIGKeyInfoParser for the entry /// 2. Pass the element configuration to the parser's parse method /// 3. Add the new TSIGKeyInfo instance to the key map /// /// @param key_list_config is the list of "tsig_key" elements to parse. /// - /// @return a map containing the TSIGKeyInfo instances + /// @return a map containing the TSIGKeyInfo instances TSIGKeyInfoMapPtr parse(data::ConstElementPtr key_list_config); }; /// @brief Parser for DnsServerInfo /// -/// This class parses the configuration element "dns-server" defined in -/// src/bin/d2/dhcp-ddns.spec and creates an instance of a DnsServerInfo. +/// This class parses the configuration element "dns-server" +/// and creates an instance of a DnsServerInfo. class DnsServerInfoParser : public data::SimpleParser { public: /// @brief Performs the actual parsing of the given "dns-server" element. @@ -795,7 +791,7 @@ public: /// @brief Parser for a list of DnsServerInfos /// /// This class parses a list of "dns-server" configuration elements. -/// (see src/bin/d2/dhcp-ddns.spec). The DnsServerInfo instances are added +/// The DnsServerInfo instances are added /// to the given storage upon commit. class DnsServerInfoListParser : public data::SimpleParser{ public: @@ -804,7 +800,7 @@ public: /// /// Creates an empty server list /// It iterates over each server entry in the list: - /// 1. Creates a server instance by passing the entry to @c + /// 1. Creates a server instance by passing the entry to @c /// DnsSeverInfoParser::parse() /// 2. Adds the server to the server list /// @@ -815,8 +811,8 @@ public: /// @brief Parser for DdnsDomain /// -/// This class parses the configuration element "ddns-domain" defined in -/// src/bin/d2/dhcp-ddns.spec and creates an instance of a DdnsDomain. +/// This class parses the configuration element "ddns-domain" +/// and creates an instance of a DdnsDomain. class DdnsDomainParser : public data::SimpleParser { public: /// @brief Performs the actual parsing of the given "ddns-domain" element. @@ -834,15 +830,15 @@ public: /// @brief Parser for a list of DdnsDomains /// -/// This class parses a list of "ddns-domain" configuration elements. -/// (see src/bin/d2/dhcp-ddns.spec) into a map of DdnsDomains. +/// This class parses a list of "ddns-domain" configuration elements +/// into a map of DdnsDomains. class DdnsDomainListParser : public data::SimpleParser { public: /// @brief Performs the actual parsing of the given list "ddns-domain" /// elements. /// Creates a new DdnsDomain map /// It iterates over each domain entry in the list: - /// 1. Creates a DdnsDomain instance by passing the entry into @c + /// 1. Creates a DdnsDomain instance by passing the entry into @c /// DdnsDomainParser::parser() /// 2. Adds the DdnsDomain instance to the domain map /// @@ -857,8 +853,8 @@ public: /// @brief Parser for DdnsDomainListMgr /// /// This class parses the configuration elements "forward-ddns" and -/// "reverse-ddns" as defined in src/bin/d2/dhcp-ddns.spec. It populates the -/// given DdnsDomainListMgr with parsed information. +/// "reverse-ddns". It populates the given DdnsDomainListMgr with parsed +/// information. class DdnsDomainListMgrParser : public data::SimpleParser { public: /// @brief Performs the actual parsing of the given manager element. diff --git a/src/bin/d2/d2_parser.cc b/src/bin/d2/d2_parser.cc index 752a420772..425679037d 100644 --- a/src/bin/d2/d2_parser.cc +++ b/src/bin/d2/d2_parser.cc @@ -874,7 +874,7 @@ namespace isc { namespace d2 { break; case 65: -#line 265 "d2_parser.yy" // lalr1.cc:859 +#line 266 "d2_parser.yy" // lalr1.cc:859 { ctx.enter(ctx.NO_KEYWORD); } @@ -882,7 +882,7 @@ namespace isc { namespace d2 { break; case 66: -#line 267 "d2_parser.yy" // lalr1.cc:859 +#line 268 "d2_parser.yy" // lalr1.cc:859 { ElementPtr s(new StringElement(yystack_[0].value.as< std::string > (), ctx.loc2pos(yystack_[0].location))); ctx.stack_.back()->set("ip-address", s); @@ -892,10 +892,10 @@ namespace isc { namespace d2 { break; case 67: -#line 273 "d2_parser.yy" // lalr1.cc:859 +#line 274 "d2_parser.yy" // lalr1.cc:859 { - if (yystack_[0].value.as< int64_t > () <= 0) { - error(yystack_[0].location, "port must be greater than zero"); + if (yystack_[0].value.as< int64_t > () <= 0 || yystack_[0].value.as< int64_t > () >= 65792 ) { + error(yystack_[0].location, "port must be greater than zero but less than 65792"); } ElementPtr i(new IntElement(yystack_[0].value.as< int64_t > (), ctx.loc2pos(yystack_[0].location))); ctx.stack_.back()->set("port", i); @@ -904,7 +904,7 @@ namespace isc { namespace d2 { break; case 68: -#line 281 "d2_parser.yy" // lalr1.cc:859 +#line 282 "d2_parser.yy" // lalr1.cc:859 { if (yystack_[0].value.as< int64_t > () <= 0) { error(yystack_[0].location, "dns-server-timeout must be greater than zero"); @@ -917,7 +917,7 @@ namespace isc { namespace d2 { break; case 69: -#line 290 "d2_parser.yy" // lalr1.cc:859 +#line 291 "d2_parser.yy" // lalr1.cc:859 { ctx.enter(ctx.NCR_PROTOCOL); } @@ -925,7 +925,7 @@ namespace isc { namespace d2 { break; case 70: -#line 292 "d2_parser.yy" // lalr1.cc:859 +#line 293 "d2_parser.yy" // lalr1.cc:859 { ctx.stack_.back()->set("ncr-protocol", yystack_[0].value.as< ElementPtr > ()); ctx.leave(); @@ -934,19 +934,19 @@ namespace isc { namespace d2 { break; case 71: -#line 298 "d2_parser.yy" // lalr1.cc:859 +#line 299 "d2_parser.yy" // lalr1.cc:859 { yylhs.value.as< ElementPtr > () = ElementPtr(new StringElement("UDP", ctx.loc2pos(yystack_[0].location))); } #line 940 "d2_parser.cc" // lalr1.cc:859 break; case 72: -#line 299 "d2_parser.yy" // lalr1.cc:859 +#line 300 "d2_parser.yy" // lalr1.cc:859 { yylhs.value.as< ElementPtr > () = ElementPtr(new StringElement("TCP", ctx.loc2pos(yystack_[0].location))); } #line 946 "d2_parser.cc" // lalr1.cc:859 break; case 73: -#line 302 "d2_parser.yy" // lalr1.cc:859 +#line 303 "d2_parser.yy" // lalr1.cc:859 { ctx.enter(ctx.NCR_FORMAT); } @@ -954,7 +954,7 @@ namespace isc { namespace d2 { break; case 74: -#line 304 "d2_parser.yy" // lalr1.cc:859 +#line 305 "d2_parser.yy" // lalr1.cc:859 { ElementPtr json(new StringElement("JSON", ctx.loc2pos(yystack_[0].location))); ctx.stack_.back()->set("ncr-format", json); @@ -964,7 +964,7 @@ namespace isc { namespace d2 { break; case 75: -#line 310 "d2_parser.yy" // lalr1.cc:859 +#line 311 "d2_parser.yy" // lalr1.cc:859 { ElementPtr m(new MapElement(ctx.loc2pos(yystack_[0].location))); ctx.stack_.back()->set("forward-ddns", m); @@ -975,7 +975,7 @@ namespace isc { namespace d2 { break; case 76: -#line 315 "d2_parser.yy" // lalr1.cc:859 +#line 316 "d2_parser.yy" // lalr1.cc:859 { ctx.stack_.pop_back(); ctx.leave(); @@ -984,7 +984,7 @@ namespace isc { namespace d2 { break; case 77: -#line 320 "d2_parser.yy" // lalr1.cc:859 +#line 321 "d2_parser.yy" // lalr1.cc:859 { ElementPtr m(new MapElement(ctx.loc2pos(yystack_[0].location))); ctx.stack_.back()->set("reverse-ddns", m); @@ -995,7 +995,7 @@ namespace isc { namespace d2 { break; case 78: -#line 325 "d2_parser.yy" // lalr1.cc:859 +#line 326 "d2_parser.yy" // lalr1.cc:859 { ctx.stack_.pop_back(); ctx.leave(); @@ -1004,7 +1004,7 @@ namespace isc { namespace d2 { break; case 85: -#line 344 "d2_parser.yy" // lalr1.cc:859 +#line 345 "d2_parser.yy" // lalr1.cc:859 { ElementPtr l(new ListElement(ctx.loc2pos(yystack_[0].location))); ctx.stack_.back()->set("ddns-domains", l); @@ -1015,7 +1015,7 @@ namespace isc { namespace d2 { break; case 86: -#line 349 "d2_parser.yy" // lalr1.cc:859 +#line 350 "d2_parser.yy" // lalr1.cc:859 { ctx.stack_.pop_back(); ctx.leave(); @@ -1024,7 +1024,7 @@ namespace isc { namespace d2 { break; case 87: -#line 354 "d2_parser.yy" // lalr1.cc:859 +#line 355 "d2_parser.yy" // lalr1.cc:859 { ElementPtr l(new ListElement(ctx.loc2pos(yystack_[0].location))); ctx.stack_.push_back(l); @@ -1033,7 +1033,7 @@ namespace isc { namespace d2 { break; case 88: -#line 357 "d2_parser.yy" // lalr1.cc:859 +#line 358 "d2_parser.yy" // lalr1.cc:859 { // parsing completed } @@ -1041,7 +1041,7 @@ namespace isc { namespace d2 { break; case 93: -#line 369 "d2_parser.yy" // lalr1.cc:859 +#line 370 "d2_parser.yy" // lalr1.cc:859 { ElementPtr m(new MapElement(ctx.loc2pos(yystack_[0].location))); ctx.stack_.back()->add(m); @@ -1051,7 +1051,7 @@ namespace isc { namespace d2 { break; case 94: -#line 373 "d2_parser.yy" // lalr1.cc:859 +#line 374 "d2_parser.yy" // lalr1.cc:859 { ctx.stack_.pop_back(); } @@ -1059,7 +1059,7 @@ namespace isc { namespace d2 { break; case 95: -#line 377 "d2_parser.yy" // lalr1.cc:859 +#line 378 "d2_parser.yy" // lalr1.cc:859 { ElementPtr m(new MapElement(ctx.loc2pos(yystack_[0].location))); ctx.stack_.push_back(m); @@ -1068,7 +1068,7 @@ namespace isc { namespace d2 { break; case 96: -#line 380 "d2_parser.yy" // lalr1.cc:859 +#line 381 "d2_parser.yy" // lalr1.cc:859 { // parsing completed } @@ -1076,7 +1076,7 @@ namespace isc { namespace d2 { break; case 103: -#line 395 "d2_parser.yy" // lalr1.cc:859 +#line 396 "d2_parser.yy" // lalr1.cc:859 { ctx.enter(ctx.NO_KEYWORD); } @@ -1084,7 +1084,7 @@ namespace isc { namespace d2 { break; case 104: -#line 397 "d2_parser.yy" // lalr1.cc:859 +#line 398 "d2_parser.yy" // lalr1.cc:859 { if (yystack_[0].value.as< std::string > () == "") { error(yystack_[1].location, "Ddns domain name cannot be blank"); @@ -1098,7 +1098,7 @@ namespace isc { namespace d2 { break; case 105: -#line 407 "d2_parser.yy" // lalr1.cc:859 +#line 408 "d2_parser.yy" // lalr1.cc:859 { ctx.enter(ctx.NO_KEYWORD); } @@ -1106,7 +1106,7 @@ namespace isc { namespace d2 { break; case 106: -#line 409 "d2_parser.yy" // lalr1.cc:859 +#line 410 "d2_parser.yy" // lalr1.cc:859 { ElementPtr elem(new StringElement(yystack_[0].value.as< std::string > (), ctx.loc2pos(yystack_[0].location))); ElementPtr name(new StringElement(yystack_[0].value.as< std::string > (), ctx.loc2pos(yystack_[0].location))); @@ -1117,7 +1117,7 @@ namespace isc { namespace d2 { break; case 107: -#line 419 "d2_parser.yy" // lalr1.cc:859 +#line 420 "d2_parser.yy" // lalr1.cc:859 { ElementPtr l(new ListElement(ctx.loc2pos(yystack_[0].location))); ctx.stack_.back()->set("dns-servers", l); @@ -1128,7 +1128,7 @@ namespace isc { namespace d2 { break; case 108: -#line 424 "d2_parser.yy" // lalr1.cc:859 +#line 425 "d2_parser.yy" // lalr1.cc:859 { ctx.stack_.pop_back(); ctx.leave(); @@ -1137,7 +1137,7 @@ namespace isc { namespace d2 { break; case 109: -#line 429 "d2_parser.yy" // lalr1.cc:859 +#line 430 "d2_parser.yy" // lalr1.cc:859 { ElementPtr l(new ListElement(ctx.loc2pos(yystack_[0].location))); ctx.stack_.push_back(l); @@ -1146,7 +1146,7 @@ namespace isc { namespace d2 { break; case 110: -#line 432 "d2_parser.yy" // lalr1.cc:859 +#line 433 "d2_parser.yy" // lalr1.cc:859 { // parsing completed } @@ -1154,7 +1154,7 @@ namespace isc { namespace d2 { break; case 113: -#line 440 "d2_parser.yy" // lalr1.cc:859 +#line 441 "d2_parser.yy" // lalr1.cc:859 { ElementPtr m(new MapElement(ctx.loc2pos(yystack_[0].location))); ctx.stack_.back()->add(m); @@ -1164,7 +1164,7 @@ namespace isc { namespace d2 { break; case 114: -#line 444 "d2_parser.yy" // lalr1.cc:859 +#line 445 "d2_parser.yy" // lalr1.cc:859 { ctx.stack_.pop_back(); } @@ -1172,7 +1172,7 @@ namespace isc { namespace d2 { break; case 115: -#line 448 "d2_parser.yy" // lalr1.cc:859 +#line 449 "d2_parser.yy" // lalr1.cc:859 { ElementPtr m(new MapElement(ctx.loc2pos(yystack_[0].location))); ctx.stack_.push_back(m); @@ -1181,7 +1181,7 @@ namespace isc { namespace d2 { break; case 116: -#line 451 "d2_parser.yy" // lalr1.cc:859 +#line 452 "d2_parser.yy" // lalr1.cc:859 { // parsing completed } @@ -1189,7 +1189,7 @@ namespace isc { namespace d2 { break; case 123: -#line 465 "d2_parser.yy" // lalr1.cc:859 +#line 466 "d2_parser.yy" // lalr1.cc:859 { ctx.enter(ctx.NO_KEYWORD); } @@ -1197,7 +1197,7 @@ namespace isc { namespace d2 { break; case 124: -#line 467 "d2_parser.yy" // lalr1.cc:859 +#line 468 "d2_parser.yy" // lalr1.cc:859 { if (yystack_[0].value.as< std::string > () != "") { error(yystack_[1].location, "hostname is not yet supported"); @@ -1211,7 +1211,7 @@ namespace isc { namespace d2 { break; case 125: -#line 477 "d2_parser.yy" // lalr1.cc:859 +#line 478 "d2_parser.yy" // lalr1.cc:859 { ctx.enter(ctx.NO_KEYWORD); } @@ -1219,7 +1219,7 @@ namespace isc { namespace d2 { break; case 126: -#line 479 "d2_parser.yy" // lalr1.cc:859 +#line 480 "d2_parser.yy" // lalr1.cc:859 { ElementPtr s(new StringElement(yystack_[0].value.as< std::string > (), ctx.loc2pos(yystack_[0].location))); ctx.stack_.back()->set("ip-address", s); @@ -1229,10 +1229,10 @@ namespace isc { namespace d2 { break; case 127: -#line 485 "d2_parser.yy" // lalr1.cc:859 +#line 486 "d2_parser.yy" // lalr1.cc:859 { - if (yystack_[0].value.as< int64_t > () <= 0) { - error(yystack_[0].location, "port must be greater than zero"); + if (yystack_[0].value.as< int64_t > () <= 0 || yystack_[0].value.as< int64_t > () >= 65792 ) { + error(yystack_[0].location, "port must be greater than zero but less than 65792"); } ElementPtr i(new IntElement(yystack_[0].value.as< int64_t > (), ctx.loc2pos(yystack_[0].location))); ctx.stack_.back()->set("port", i); @@ -1241,7 +1241,7 @@ namespace isc { namespace d2 { break; case 128: -#line 499 "d2_parser.yy" // lalr1.cc:859 +#line 500 "d2_parser.yy" // lalr1.cc:859 { ElementPtr l(new ListElement(ctx.loc2pos(yystack_[0].location))); ctx.stack_.back()->set("tsig-keys", l); @@ -1252,7 +1252,7 @@ namespace isc { namespace d2 { break; case 129: -#line 504 "d2_parser.yy" // lalr1.cc:859 +#line 505 "d2_parser.yy" // lalr1.cc:859 { ctx.stack_.pop_back(); ctx.leave(); @@ -1261,7 +1261,7 @@ namespace isc { namespace d2 { break; case 130: -#line 509 "d2_parser.yy" // lalr1.cc:859 +#line 510 "d2_parser.yy" // lalr1.cc:859 { ElementPtr l(new ListElement(ctx.loc2pos(yystack_[0].location))); ctx.stack_.push_back(l); @@ -1270,7 +1270,7 @@ namespace isc { namespace d2 { break; case 131: -#line 512 "d2_parser.yy" // lalr1.cc:859 +#line 513 "d2_parser.yy" // lalr1.cc:859 { // parsing completed } @@ -1278,7 +1278,7 @@ namespace isc { namespace d2 { break; case 136: -#line 524 "d2_parser.yy" // lalr1.cc:859 +#line 525 "d2_parser.yy" // lalr1.cc:859 { ElementPtr m(new MapElement(ctx.loc2pos(yystack_[0].location))); ctx.stack_.back()->add(m); @@ -1288,7 +1288,7 @@ namespace isc { namespace d2 { break; case 137: -#line 528 "d2_parser.yy" // lalr1.cc:859 +#line 529 "d2_parser.yy" // lalr1.cc:859 { ctx.stack_.pop_back(); } @@ -1296,7 +1296,7 @@ namespace isc { namespace d2 { break; case 138: -#line 532 "d2_parser.yy" // lalr1.cc:859 +#line 533 "d2_parser.yy" // lalr1.cc:859 { // Parse tsig key list entry map ElementPtr m(new MapElement(ctx.loc2pos(yystack_[0].location))); @@ -1306,7 +1306,7 @@ namespace isc { namespace d2 { break; case 139: -#line 536 "d2_parser.yy" // lalr1.cc:859 +#line 537 "d2_parser.yy" // lalr1.cc:859 { // parsing completed } @@ -1314,7 +1314,7 @@ namespace isc { namespace d2 { break; case 147: -#line 552 "d2_parser.yy" // lalr1.cc:859 +#line 553 "d2_parser.yy" // lalr1.cc:859 { ctx.enter(ctx.NO_KEYWORD); } @@ -1322,7 +1322,7 @@ namespace isc { namespace d2 { break; case 148: -#line 554 "d2_parser.yy" // lalr1.cc:859 +#line 555 "d2_parser.yy" // lalr1.cc:859 { if (yystack_[0].value.as< std::string > () == "") { error(yystack_[1].location, "TSIG key name cannot be blank"); @@ -1336,7 +1336,7 @@ namespace isc { namespace d2 { break; case 149: -#line 564 "d2_parser.yy" // lalr1.cc:859 +#line 565 "d2_parser.yy" // lalr1.cc:859 { ctx.enter(ctx.NO_KEYWORD); } @@ -1344,7 +1344,7 @@ namespace isc { namespace d2 { break; case 150: -#line 566 "d2_parser.yy" // lalr1.cc:859 +#line 567 "d2_parser.yy" // lalr1.cc:859 { if (yystack_[0].value.as< std::string > () == "") { error(yystack_[1].location, "TSIG key algorithm cannot be blank"); @@ -1357,7 +1357,7 @@ namespace isc { namespace d2 { break; case 151: -#line 575 "d2_parser.yy" // lalr1.cc:859 +#line 576 "d2_parser.yy" // lalr1.cc:859 { if (yystack_[0].value.as< int64_t > () < 0 || (yystack_[0].value.as< int64_t > () > 0 && (yystack_[0].value.as< int64_t > () % 8 != 0))) { error(yystack_[0].location, "TSIG key digest-bits must either be zero or a positive, multiple of eight"); @@ -1369,7 +1369,7 @@ namespace isc { namespace d2 { break; case 152: -#line 583 "d2_parser.yy" // lalr1.cc:859 +#line 584 "d2_parser.yy" // lalr1.cc:859 { ctx.enter(ctx.NO_KEYWORD); } @@ -1377,7 +1377,7 @@ namespace isc { namespace d2 { break; case 153: -#line 585 "d2_parser.yy" // lalr1.cc:859 +#line 586 "d2_parser.yy" // lalr1.cc:859 { if (yystack_[0].value.as< std::string > () == "") { error(yystack_[1].location, "TSIG key secret cannot be blank"); @@ -1390,7 +1390,7 @@ namespace isc { namespace d2 { break; case 154: -#line 598 "d2_parser.yy" // lalr1.cc:859 +#line 599 "d2_parser.yy" // lalr1.cc:859 { ctx.enter(ctx.NO_KEYWORD); } @@ -1398,7 +1398,7 @@ namespace isc { namespace d2 { break; case 155: -#line 600 "d2_parser.yy" // lalr1.cc:859 +#line 601 "d2_parser.yy" // lalr1.cc:859 { ctx.stack_.back()->set("Dhcp6", yystack_[0].value.as< ElementPtr > ()); ctx.leave(); @@ -1407,7 +1407,7 @@ namespace isc { namespace d2 { break; case 156: -#line 605 "d2_parser.yy" // lalr1.cc:859 +#line 606 "d2_parser.yy" // lalr1.cc:859 { ctx.enter(ctx.NO_KEYWORD); } @@ -1415,7 +1415,7 @@ namespace isc { namespace d2 { break; case 157: -#line 607 "d2_parser.yy" // lalr1.cc:859 +#line 608 "d2_parser.yy" // lalr1.cc:859 { ctx.stack_.back()->set("Dhcp4", yystack_[0].value.as< ElementPtr > ()); ctx.leave(); @@ -1424,7 +1424,7 @@ namespace isc { namespace d2 { break; case 158: -#line 617 "d2_parser.yy" // lalr1.cc:859 +#line 618 "d2_parser.yy" // lalr1.cc:859 { ElementPtr m(new MapElement(ctx.loc2pos(yystack_[0].location))); ctx.stack_.back()->set("Logging", m); @@ -1435,7 +1435,7 @@ namespace isc { namespace d2 { break; case 159: -#line 622 "d2_parser.yy" // lalr1.cc:859 +#line 623 "d2_parser.yy" // lalr1.cc:859 { ctx.stack_.pop_back(); ctx.leave(); @@ -1444,7 +1444,7 @@ namespace isc { namespace d2 { break; case 163: -#line 639 "d2_parser.yy" // lalr1.cc:859 +#line 640 "d2_parser.yy" // lalr1.cc:859 { ElementPtr l(new ListElement(ctx.loc2pos(yystack_[0].location))); ctx.stack_.back()->set("loggers", l); @@ -1455,7 +1455,7 @@ namespace isc { namespace d2 { break; case 164: -#line 644 "d2_parser.yy" // lalr1.cc:859 +#line 645 "d2_parser.yy" // lalr1.cc:859 { ctx.stack_.pop_back(); ctx.leave(); @@ -1464,7 +1464,7 @@ namespace isc { namespace d2 { break; case 167: -#line 656 "d2_parser.yy" // lalr1.cc:859 +#line 657 "d2_parser.yy" // lalr1.cc:859 { ElementPtr l(new MapElement(ctx.loc2pos(yystack_[0].location))); ctx.stack_.back()->add(l); @@ -1474,7 +1474,7 @@ namespace isc { namespace d2 { break; case 168: -#line 660 "d2_parser.yy" // lalr1.cc:859 +#line 661 "d2_parser.yy" // lalr1.cc:859 { ctx.stack_.pop_back(); } @@ -1482,7 +1482,7 @@ namespace isc { namespace d2 { break; case 176: -#line 675 "d2_parser.yy" // lalr1.cc:859 +#line 676 "d2_parser.yy" // lalr1.cc:859 { ctx.enter(ctx.NO_KEYWORD); } @@ -1490,7 +1490,7 @@ namespace isc { namespace d2 { break; case 177: -#line 677 "d2_parser.yy" // lalr1.cc:859 +#line 678 "d2_parser.yy" // lalr1.cc:859 { ElementPtr name(new StringElement(yystack_[0].value.as< std::string > (), ctx.loc2pos(yystack_[0].location))); ctx.stack_.back()->set("name", name); @@ -1500,7 +1500,7 @@ namespace isc { namespace d2 { break; case 178: -#line 683 "d2_parser.yy" // lalr1.cc:859 +#line 684 "d2_parser.yy" // lalr1.cc:859 { ElementPtr dl(new IntElement(yystack_[0].value.as< int64_t > (), ctx.loc2pos(yystack_[0].location))); ctx.stack_.back()->set("debuglevel", dl); @@ -1509,7 +1509,7 @@ namespace isc { namespace d2 { break; case 179: -#line 687 "d2_parser.yy" // lalr1.cc:859 +#line 688 "d2_parser.yy" // lalr1.cc:859 { ctx.enter(ctx.NO_KEYWORD); } @@ -1517,7 +1517,7 @@ namespace isc { namespace d2 { break; case 180: -#line 689 "d2_parser.yy" // lalr1.cc:859 +#line 690 "d2_parser.yy" // lalr1.cc:859 { ElementPtr sev(new StringElement(yystack_[0].value.as< std::string > (), ctx.loc2pos(yystack_[0].location))); ctx.stack_.back()->set("severity", sev); @@ -1527,7 +1527,7 @@ namespace isc { namespace d2 { break; case 181: -#line 695 "d2_parser.yy" // lalr1.cc:859 +#line 696 "d2_parser.yy" // lalr1.cc:859 { ElementPtr l(new ListElement(ctx.loc2pos(yystack_[0].location))); ctx.stack_.back()->set("output_options", l); @@ -1538,7 +1538,7 @@ namespace isc { namespace d2 { break; case 182: -#line 700 "d2_parser.yy" // lalr1.cc:859 +#line 701 "d2_parser.yy" // lalr1.cc:859 { ctx.stack_.pop_back(); ctx.leave(); @@ -1547,7 +1547,7 @@ namespace isc { namespace d2 { break; case 185: -#line 709 "d2_parser.yy" // lalr1.cc:859 +#line 710 "d2_parser.yy" // lalr1.cc:859 { ElementPtr m(new MapElement(ctx.loc2pos(yystack_[0].location))); ctx.stack_.back()->add(m); @@ -1557,7 +1557,7 @@ namespace isc { namespace d2 { break; case 186: -#line 713 "d2_parser.yy" // lalr1.cc:859 +#line 714 "d2_parser.yy" // lalr1.cc:859 { ctx.stack_.pop_back(); } @@ -1565,7 +1565,7 @@ namespace isc { namespace d2 { break; case 189: -#line 721 "d2_parser.yy" // lalr1.cc:859 +#line 722 "d2_parser.yy" // lalr1.cc:859 { ctx.enter(ctx.NO_KEYWORD); } @@ -1573,7 +1573,7 @@ namespace isc { namespace d2 { break; case 190: -#line 723 "d2_parser.yy" // lalr1.cc:859 +#line 724 "d2_parser.yy" // lalr1.cc:859 { ElementPtr sev(new StringElement(yystack_[0].value.as< std::string > (), ctx.loc2pos(yystack_[0].location))); ctx.stack_.back()->set("output", sev); @@ -2160,21 +2160,21 @@ namespace isc { namespace d2 { 129, 130, 131, 132, 133, 134, 135, 138, 143, 143, 155, 156, 159, 163, 170, 170, 177, 178, 181, 185, 196, 206, 206, 218, 219, 223, 224, 225, 226, 227, - 232, 232, 242, 242, 250, 251, 254, 255, 256, 257, - 258, 259, 260, 261, 262, 265, 265, 273, 281, 290, - 290, 298, 299, 302, 302, 310, 310, 320, 320, 330, - 331, 334, 335, 338, 339, 344, 344, 354, 354, 361, - 362, 365, 366, 369, 369, 377, 377, 384, 385, 388, - 389, 390, 391, 395, 395, 407, 407, 419, 419, 429, - 429, 436, 437, 440, 440, 448, 448, 455, 456, 459, - 460, 461, 462, 465, 465, 477, 477, 485, 499, 499, - 509, 509, 516, 517, 520, 521, 524, 524, 532, 532, - 541, 542, 545, 546, 547, 548, 549, 552, 552, 564, - 564, 575, 583, 583, 598, 598, 605, 605, 617, 617, - 630, 631, 635, 639, 639, 651, 652, 656, 656, 664, - 665, 668, 669, 670, 671, 672, 675, 675, 683, 687, - 687, 695, 695, 705, 706, 709, 709, 717, 718, 721, - 721 + 232, 232, 242, 242, 250, 251, 255, 256, 257, 258, + 259, 260, 261, 262, 263, 266, 266, 274, 282, 291, + 291, 299, 300, 303, 303, 311, 311, 321, 321, 331, + 332, 335, 336, 339, 340, 345, 345, 355, 355, 362, + 363, 366, 367, 370, 370, 378, 378, 385, 386, 389, + 390, 391, 392, 396, 396, 408, 408, 420, 420, 430, + 430, 437, 438, 441, 441, 449, 449, 456, 457, 460, + 461, 462, 463, 466, 466, 478, 478, 486, 500, 500, + 510, 510, 517, 518, 521, 522, 525, 525, 533, 533, + 542, 543, 546, 547, 548, 549, 550, 553, 553, 565, + 565, 576, 584, 584, 599, 599, 606, 606, 618, 618, + 631, 632, 636, 640, 640, 652, 653, 657, 657, 665, + 666, 669, 670, 671, 672, 673, 676, 676, 684, 688, + 688, 696, 696, 706, 707, 710, 710, 718, 719, 722, + 722 }; // Print the state stack on the debug stream. @@ -2210,7 +2210,7 @@ namespace isc { namespace d2 { #line 14 "d2_parser.yy" // lalr1.cc:1167 } } // isc::d2 #line 2213 "d2_parser.cc" // lalr1.cc:1167 -#line 729 "d2_parser.yy" // lalr1.cc:1168 +#line 730 "d2_parser.yy" // lalr1.cc:1168 void diff --git a/src/bin/d2/d2_parser.h b/src/bin/d2/d2_parser.h index f9089359b6..2bc6746ec4 100644 --- a/src/bin/d2/d2_parser.h +++ b/src/bin/d2/d2_parser.h @@ -40,7 +40,7 @@ #ifndef YY_D2_PARSER_D2_PARSER_H_INCLUDED # define YY_D2_PARSER_D2_PARSER_H_INCLUDED // // "%code requires" blocks. -#line 17 "d2_parser.yy" // lalr1.cc:377 +#line 17 "d2_parser.yy" // lalr1.cc:392 #include #include @@ -52,7 +52,7 @@ using namespace isc::d2; using namespace isc::data; using namespace std; -#line 56 "d2_parser.h" // lalr1.cc:377 +#line 56 "d2_parser.h" // lalr1.cc:392 # include # include // std::abort @@ -135,9 +135,9 @@ using namespace std; # endif /* ! defined YYDEBUG */ #endif /* ! defined D2_PARSER_DEBUG */ -#line 14 "d2_parser.yy" // lalr1.cc:377 +#line 14 "d2_parser.yy" // lalr1.cc:392 namespace isc { namespace d2 { -#line 141 "d2_parser.h" // lalr1.cc:377 +#line 141 "d2_parser.h" // lalr1.cc:392 @@ -1552,9 +1552,9 @@ namespace isc { namespace d2 { } -#line 14 "d2_parser.yy" // lalr1.cc:377 +#line 14 "d2_parser.yy" // lalr1.cc:392 } } // isc::d2 -#line 1558 "d2_parser.h" // lalr1.cc:377 +#line 1558 "d2_parser.h" // lalr1.cc:392 diff --git a/src/bin/d2/d2_parser.yy b/src/bin/d2/d2_parser.yy index facfce7b26..bd28a36867 100644 --- a/src/bin/d2/d2_parser.yy +++ b/src/bin/d2/d2_parser.yy @@ -272,8 +272,8 @@ ip_address: IP_ADDRESS { }; port: PORT COLON INTEGER { - if ($3 <= 0) { - error(@3, "port must be greater than zero"); + if ($3 <= 0 || $3 >= 65792 ) { + error(@3, "port must be greater than zero but less than 65792"); } ElementPtr i(new IntElement($3, ctx.loc2pos(@3))); ctx.stack_.back()->set("port", i); @@ -484,8 +484,8 @@ dns_server_ip_address: IP_ADDRESS { }; dns_server_port: PORT COLON INTEGER { - if ($3 <= 0) { - error(@3, "port must be greater than zero"); + if ($3 <= 0 || $3 >= 65792 ) { + error(@3, "port must be greater than zero but less than 65792"); } ElementPtr i(new IntElement($3, ctx.loc2pos(@3))); ctx.stack_.back()->set("port", i); diff --git a/src/bin/d2/d2_simple_parser.h b/src/bin/d2/d2_simple_parser.h index e927c4c80c..b504baa116 100644 --- a/src/bin/d2/d2_simple_parser.h +++ b/src/bin/d2/d2_simple_parser.h @@ -66,8 +66,11 @@ public: /// found, then an empty map entry is added for it, thus defaulting the /// manager to "disabled". /// - /// @param domain DDNS domain manager element to which defaults should be + /// @param global element tree containgin the DDNS domain manager element + /// to which defaults should be /// added + /// @param mgr_name name of the manager element within the element tree + /// (e.g. "forward-ddns", "reverse-ddns") /// @param mgr_defaults list of default values from which to add /// @return returns the number of default values added static size_t setManagerDefaults(data::ElementPtr global, diff --git a/src/bin/d2/location.hh b/src/bin/d2/location.hh index 481e6ba199..80826e9758 100644 --- a/src/bin/d2/location.hh +++ b/src/bin/d2/location.hh @@ -1,4 +1,3 @@ -// Generated 201702011423 // A Bison parser, made by GNU Bison 3.0.4. // Locations for Bison parsers in C++ @@ -41,9 +40,9 @@ # include "position.hh" -#line 14 "d2_parser.yy" // location.cc:296 +#line 14 "d2_parser.yy" // location.cc:337 namespace isc { namespace d2 { -#line 46 "location.hh" // location.cc:296 +#line 46 "location.hh" // location.cc:337 /// Abstract a location. class location { @@ -187,7 +186,7 @@ namespace isc { namespace d2 { return ostr; } -#line 14 "d2_parser.yy" // location.cc:296 +#line 14 "d2_parser.yy" // location.cc:337 } } // isc::d2 -#line 192 "location.hh" // location.cc:296 +#line 192 "location.hh" // location.cc:337 #endif // !YY_D2_PARSER_LOCATION_HH_INCLUDED diff --git a/src/bin/d2/parser_context.cc b/src/bin/d2/parser_context.cc index 394fb2464f..4faa599a83 100644 --- a/src/bin/d2/parser_context.cc +++ b/src/bin/d2/parser_context.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2016-2017 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 @@ -20,10 +20,6 @@ D2ParserContext::D2ParserContext() { } -D2ParserContext::~D2ParserContext() -{ -} - isc::data::ElementPtr D2ParserContext::parseString(const std::string& str, ParserType parser_type) { diff --git a/src/bin/d2/parser_context.h b/src/bin/d2/parser_context.h index 3dacb5749e..15e9da2065 100644 --- a/src/bin/d2/parser_context.h +++ b/src/bin/d2/parser_context.h @@ -76,9 +76,6 @@ public: /// @brief Default constructor. D2ParserContext(); - /// @brief destructor - virtual ~D2ParserContext(); - /// @brief JSON elements being parsed. std::vector stack_; diff --git a/src/bin/d2/position.hh b/src/bin/d2/position.hh index 1a25813df1..41f8acd1b9 100644 --- a/src/bin/d2/position.hh +++ b/src/bin/d2/position.hh @@ -1,4 +1,3 @@ -// Generated 201702011423 // A Bison parser, made by GNU Bison 3.0.4. // Positions for Bison parsers in C++ @@ -51,9 +50,9 @@ # endif # endif -#line 14 "d2_parser.yy" // location.cc:296 +#line 14 "d2_parser.yy" // location.cc:337 namespace isc { namespace d2 { -#line 56 "position.hh" // location.cc:296 +#line 56 "position.hh" // location.cc:337 /// Abstract a position. class position { @@ -175,7 +174,7 @@ namespace isc { namespace d2 { return ostr << pos.line << '.' << pos.column; } -#line 14 "d2_parser.yy" // location.cc:296 +#line 14 "d2_parser.yy" // location.cc:337 } } // isc::d2 -#line 180 "position.hh" // location.cc:296 +#line 180 "position.hh" // location.cc:337 #endif // !YY_D2_PARSER_POSITION_HH_INCLUDED diff --git a/src/bin/d2/stack.hh b/src/bin/d2/stack.hh index 1cde71173b..92c74d309e 100644 --- a/src/bin/d2/stack.hh +++ b/src/bin/d2/stack.hh @@ -1,4 +1,3 @@ -// Generated 201702011423 // A Bison parser, made by GNU Bison 3.0.4. // Stack handling for Bison parsers in C++ @@ -41,9 +40,9 @@ # include -#line 14 "d2_parser.yy" // stack.hh:132 +#line 14 "d2_parser.yy" // stack.hh:151 namespace isc { namespace d2 { -#line 46 "stack.hh" // stack.hh:132 +#line 46 "stack.hh" // stack.hh:151 template > class stack { @@ -151,8 +150,8 @@ namespace isc { namespace d2 { unsigned int range_; }; -#line 14 "d2_parser.yy" // stack.hh:132 +#line 14 "d2_parser.yy" // stack.hh:151 } } // isc::d2 -#line 156 "stack.hh" // stack.hh:132 +#line 156 "stack.hh" // stack.hh:151 #endif // !YY_D2_PARSER_STACK_HH_INCLUDED diff --git a/src/bin/d2/tests/d2_cfg_mgr_unittests.cc b/src/bin/d2/tests/d2_cfg_mgr_unittests.cc index b90e381efc..886eeed7d9 100644 --- a/src/bin/d2/tests/d2_cfg_mgr_unittests.cc +++ b/src/bin/d2/tests/d2_cfg_mgr_unittests.cc @@ -421,7 +421,7 @@ TEST_F(D2CfgMgrTest, invalidEntry) { // Cannot use port 0 config = makeParamsConfigString ("127.0.0.1", 0, 333, "UDP", "JSON"); - SYNTAX_ERROR(config, ":1.40: port must be greater than zero"); + SYNTAX_ERROR(config, ":1.40: port must be greater than zero but less than 65792"); // Cannot use dns server timeout of 0 config = makeParamsConfigString ("127.0.0.1", 777, 0, "UDP", "JSON"); @@ -460,7 +460,7 @@ TEST_F(D2CfgMgrTest, fullConfig) { " \"ncr-format\": \"JSON\", " "\"tsig-keys\": [" "{" - " \"name\": \"d2_key.tmark.org\" , " + " \"name\": \"d2_key.example.com\" , " " \"algorithm\": \"hmac-md5\" , " " \"secret\": \"LSWXnfkKZjdPJI5QxlpnfQ==\" " "}," @@ -473,8 +473,8 @@ TEST_F(D2CfgMgrTest, fullConfig) { "]," "\"forward-ddns\" : {" "\"ddns-domains\": [ " - "{ \"name\": \"tmark.org\" , " - " \"key-name\": \"d2_key.tmark.org\" , " + "{ \"name\": \"example.com\" , " + " \"key-name\": \"d2_key.example.com\" , " " \"dns-servers\" : [ " " { \"ip-address\": \"127.0.0.1\" } , " " { \"ip-address\": \"127.0.0.2\" } , " @@ -492,7 +492,7 @@ TEST_F(D2CfgMgrTest, fullConfig) { "\"reverse-ddns\" : {" "\"ddns-domains\": [ " "{ \"name\": \" 0.168.192.in.addr.arpa.\" , " - " \"key-name\": \"d2_key.tmark.org\" , " + " \"key-name\": \"d2_key.example.com\" , " " \"dns-servers\" : [ " " { \"ip-address\": \"127.0.1.1\" } , " " { \"ip-address\": \"127.0.2.1\" } , " @@ -598,12 +598,12 @@ TEST_F(D2CfgMgrTest, forwardMatch) { "\"tsig-keys\": [] ," "\"forward-ddns\" : {" "\"ddns-domains\": [ " - "{ \"name\": \"tmark.org\" , " + "{ \"name\": \"example.com\" , " " \"dns-servers\" : [ " " { \"ip-address\": \"127.0.0.1\" } " " ] } " ", " - "{ \"name\": \"one.tmark.org\" , " + "{ \"name\": \"one.example.com\" , " " \"dns-servers\" : [ " " { \"ip-address\": \"127.0.0.2\" } " " ] } " @@ -629,24 +629,24 @@ TEST_F(D2CfgMgrTest, forwardMatch) { DdnsDomainPtr match; // Verify that an exact match works. - EXPECT_TRUE(cfg_mgr_->matchForward("tmark.org", match)); - EXPECT_EQ("tmark.org", match->getName()); + EXPECT_TRUE(cfg_mgr_->matchForward("example.com", match)); + EXPECT_EQ("example.com", match->getName()); // Verify that search is case insensisitive. - EXPECT_TRUE(cfg_mgr_->matchForward("TMARK.ORG", match)); - EXPECT_EQ("tmark.org", match->getName()); + EXPECT_TRUE(cfg_mgr_->matchForward("EXAMPLE.COM", match)); + EXPECT_EQ("example.com", match->getName()); // Verify that an exact match works. - EXPECT_TRUE(cfg_mgr_->matchForward("one.tmark.org", match)); - EXPECT_EQ("one.tmark.org", match->getName()); + EXPECT_TRUE(cfg_mgr_->matchForward("one.example.com", match)); + EXPECT_EQ("one.example.com", match->getName()); // Verify that a FQDN for sub-domain matches. - EXPECT_TRUE(cfg_mgr_->matchForward("blue.tmark.org", match)); - EXPECT_EQ("tmark.org", match->getName()); + EXPECT_TRUE(cfg_mgr_->matchForward("blue.example.com", match)); + EXPECT_EQ("example.com", match->getName()); // Verify that a FQDN for sub-domain matches. - EXPECT_TRUE(cfg_mgr_->matchForward("red.one.tmark.org", match)); - EXPECT_EQ("one.tmark.org", match->getName()); + EXPECT_TRUE(cfg_mgr_->matchForward("red.one.example.com", match)); + EXPECT_EQ("one.example.com", match->getName()); // Verify that an FQDN with no match, returns the wild card domain. EXPECT_TRUE(cfg_mgr_->matchForward("shouldbe.wildcard", match)); @@ -668,12 +668,12 @@ TEST_F(D2CfgMgrTest, matchNoWildcard) { "\"tsig-keys\": [] ," "\"forward-ddns\" : {" "\"ddns-domains\": [ " - "{ \"name\": \"tmark.org\" , " + "{ \"name\": \"example.com\" , " " \"dns-servers\" : [ " " { \"ip-address\": \"127.0.0.1\" } " " ] } " ", " - "{ \"name\": \"one.tmark.org\" , " + "{ \"name\": \"one.example.com\" , " " \"dns-servers\" : [ " " { \"ip-address\": \"127.0.0.2\" } " " ] } " @@ -690,14 +690,14 @@ TEST_F(D2CfgMgrTest, matchNoWildcard) { DdnsDomainPtr match; // Verify that full or partial matches, still match. - EXPECT_TRUE(cfg_mgr_->matchForward("tmark.org", match)); - EXPECT_EQ("tmark.org", match->getName()); + EXPECT_TRUE(cfg_mgr_->matchForward("example.com", match)); + EXPECT_EQ("example.com", match->getName()); - EXPECT_TRUE(cfg_mgr_->matchForward("blue.tmark.org", match)); - EXPECT_EQ("tmark.org", match->getName()); + EXPECT_TRUE(cfg_mgr_->matchForward("blue.example.com", match)); + EXPECT_EQ("example.com", match->getName()); - EXPECT_TRUE(cfg_mgr_->matchForward("red.one.tmark.org", match)); - EXPECT_EQ("one.tmark.org", match->getName()); + EXPECT_TRUE(cfg_mgr_->matchForward("red.one.example.com", match)); + EXPECT_EQ("one.example.com", match->getName()); // Verify that a FQDN with no match, fails to match. EXPECT_FALSE(cfg_mgr_->matchForward("shouldbe.wildcard", match)); @@ -729,7 +729,7 @@ TEST_F(D2CfgMgrTest, matchAll) { // Verify that wild card domain is returned for any FQDN. DdnsDomainPtr match; - EXPECT_TRUE(cfg_mgr_->matchForward("tmark.org", match)); + EXPECT_TRUE(cfg_mgr_->matchForward("example.com", match)); EXPECT_EQ("*", match->getName()); EXPECT_TRUE(cfg_mgr_->matchForward("shouldbe.wildcard", match)); EXPECT_EQ("*", match->getName()); diff --git a/src/bin/d2/tests/d2_process_unittests.cc b/src/bin/d2/tests/d2_process_unittests.cc index 8ab84bf240..9634ca77d4 100644 --- a/src/bin/d2/tests/d2_process_unittests.cc +++ b/src/bin/d2/tests/d2_process_unittests.cc @@ -33,21 +33,21 @@ const char* bad_ip_d2_config = "{ " "\"ip-address\" : \"1.1.1.1\" , " "\"port\" : 5031, " "\"tsig-keys\": [" - "{ \"name\": \"d2_key.tmark.org\" , " + "{ \"name\": \"d2_key.example.com\" , " " \"algorithm\": \"HMAC-MD5\" ," " \"secret\": \"LSWXnfkKZjdPJI5QxlpnfQ==\" " "} ]," "\"forward-ddns\" : {" "\"ddns-domains\": [ " - "{ \"name\": \"tmark.org\" , " - " \"key-name\": \"d2_key.tmark.org\" , " + "{ \"name\": \"example.com\" , " + " \"key-name\": \"d2_key.example.com\" , " " \"dns-servers\" : [ " " { \"ip-address\": \"127.0.0.101\" } " "] } ] }, " "\"reverse-ddns\" : {" "\"ddns-domains\": [ " "{ \"name\": \" 0.168.192.in.addr.arpa.\" , " - " \"key-name\": \"d2_key.tmark.org\" , " + " \"key-name\": \"d2_key.example.com\" , " " \"dns-servers\" : [ " " { \"ip-address\": \"127.0.0.101\" , " " \"port\": 100 } ] } " @@ -512,7 +512,7 @@ TEST_F(D2ProcessTest, canShutdown) { " \"change-type\" : 0 , " " \"forward-change\" : true , " " \"reverse-change\" : false , " - " \"fqdn\" : \"fish.tmark.org\" , " + " \"fqdn\" : \"fish.example.com\" , " " \"ip-address\" : \"192.168.2.1\" , " " \"dhcid\" : \"010203040A7F8E3D\" , " " \"lease-expires-on\" : \"20130121132405\" , " diff --git a/src/bin/d2/tests/d2_simple_parser_unittest.cc b/src/bin/d2/tests/d2_simple_parser_unittest.cc index 868147f440..b9a7946a97 100644 --- a/src/bin/d2/tests/d2_simple_parser_unittest.cc +++ b/src/bin/d2/tests/d2_simple_parser_unittest.cc @@ -2,7 +2,7 @@ // // 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 -// file, You can obtain one at http://mozilla.org/MPL/2.0/. +// file, You can obtain one at http://mozilla.com/MPL/2.0/. #include #include @@ -816,7 +816,7 @@ TEST_F(TSIGKeyInfoListParserTest, validTSIGKeyList) { TEST_F(DnsServerInfoParserTest, invalidEntry) { // Create a config in which both host and ip address are supplied. // Verify that parsing fails. - std::string config = "{ \"hostname\": \"pegasus.tmark\", " + std::string config = "{ \"hostname\": \"pegasus.example\", " " \"ip-address\": \"127.0.0.1\", " " \"port\": 100} "; PARSE_FAIL(config, ":1.13: hostname is not yet supported"); @@ -835,7 +835,7 @@ TEST_F(DnsServerInfoParserTest, invalidEntry) { config = "{ \"hostname\": \"\", " " \"ip-address\": \"192.168.5.6\" ," " \"port\": -100 }"; - PARSE_FAIL(config, ":1.60-63: port must be greater than zero"); + PARSE_FAIL(config, ":1.60-63: port must be greater than zero but less than 65792"); } @@ -848,7 +848,7 @@ TEST_F(DnsServerInfoParserTest, invalidEntry) { TEST_F(DnsServerInfoParserTest, validEntry) { /// @todo When resolvable hostname is supported you'll need this test. /// // Valid entries for dynamic host - /// std::string config = "{ \"hostname\": \"pegasus.tmark\" }"; + /// std::string config = "{ \"hostname\": \"pegasus.example\" }"; /// ASSERT_TRUE(fromJSON(config)); /// // Verify that it builds and commits without throwing. @@ -861,7 +861,7 @@ TEST_F(DnsServerInfoParserTest, validEntry) { /// Verify the server exists and has the correct values. /// DnsServerInfoPtr server = (*servers_)[0]; - /// EXPECT_TRUE(checkServer(server, "pegasus.tmark", + /// EXPECT_TRUE(checkServer(server, "pegasus.example", /// DnsServerInfo::EMPTY_IP_STR, /// DnsServerInfo::STANDARD_DNS_PORT)); @@ -934,7 +934,7 @@ TEST_F(DnsServerInfoListParserTest, validServerList) { /// 5. That an undefined key name is detected. TEST_F(DdnsDomainParserTest, invalidDomain) { // Create a domain configuration without a name - std::string config = "{ \"key-name\": \"d2_key.tmark.org\" , " + std::string config = "{ \"key-name\": \"d2_key.example.com\" , " " \"dns-servers\" : [ " " { \"ip-address\": \"127.0.0.1\" , " " \"port\": 100 }," @@ -945,40 +945,40 @@ TEST_F(DdnsDomainParserTest, invalidDomain) { PARSE_FAIL(config, "String parameter name not found(:1:1)"); // Create a domain configuration with an empty server list. - config = "{ \"name\": \"tmark.org\" , " + config = "{ \"name\": \"example.com\" , " " \"key-name\": \"\" , " " \"dns-servers\" : [ " " ] } "; - PARSE_FAIL(config, ":1.67: syntax error, unexpected ], expecting {"); + PARSE_FAIL(config, ":1.69: syntax error, unexpected ], expecting {"); // Create a domain configuration with a mal-formed server entry. - config = "{ \"name\": \"tmark.org\" , " + config = "{ \"name\": \"example.com\" , " " \"key-name\": \"\" , " " \"dns-servers\" : [ " " { \"ip-address\": \"127.0.0.3\" , " " \"port\": -1 } ] } "; - PARSE_FAIL(config, ":1.109-110: port must be greater than zero"); + PARSE_FAIL(config, ":1.111-112: port must be greater than zero but less than 65792"); // Create a domain configuration without an defined key name - config = "{ \"name\": \"tmark.org\" , " - " \"key-name\": \"d2_key.tmark.org\" , " + config = "{ \"name\": \"example.com\" , " + " \"key-name\": \"d2_key.example.com\" , " " \"dns-servers\" : [ " " { \"ip-address\": \"127.0.0.3\" , " " \"port\": 300 } ] } "; - PARSE_FAIL(config, "DdnsDomain : tmark.org specifies" - " an undefined key: d2_key.tmark.org (:1:39)"); + PARSE_FAIL(config, "DdnsDomain : example.com specifies" + " an undefined key: d2_key.example.com (:1:41)"); } /// @brief Verifies the basics of parsing of a DdnsDomain. TEST_F(DdnsDomainParserTest, validDomain) { // Add a TSIG key to the test key map, so key validation will pass. - addKey("d2_key.tmark.org", "HMAC-MD5", "GWG/Xfbju4O2iXGqkSu4PQ=="); + addKey("d2_key.example.com", "HMAC-MD5", "GWG/Xfbju4O2iXGqkSu4PQ=="); // Create a valid domain configuration entry containing three valid // servers. std::string config = - "{ \"name\": \"tmark.org\" , " - " \"key-name\": \"d2_key.tmark.org\" , " + "{ \"name\": \"example.com\" , " + " \"key-name\": \"d2_key.example.com\" , " " \"dns-servers\" : [ " " { \"ip-address\": \"127.0.0.1\" , " " \"port\": 100 }," @@ -992,8 +992,8 @@ TEST_F(DdnsDomainParserTest, validDomain) { ASSERT_TRUE(domain_); // Verify the name and key_name values. - EXPECT_EQ("tmark.org", domain_->getName()); - EXPECT_EQ("d2_key.tmark.org", domain_->getKeyName()); + EXPECT_EQ("example.com", domain_->getName()); + EXPECT_EQ("d2_key.example.com", domain_->getKeyName()); ASSERT_TRUE(domain_->getTSIGKeyInfo()); ASSERT_TRUE(domain_->getTSIGKeyInfo()->getTSIGKey()); @@ -1025,15 +1025,15 @@ TEST_F(DdnsDomainParserTest, validDomain) { /// it will accurately parse and populate each domain in the list. TEST_F(DdnsDomainListParserTest, validList) { // Add keys to key map so key validation passes. - addKey("d2_key.tmark.org", "HMAC-MD5", "GWG/Xfbju4O2iXGqkSu4PQ=="); + addKey("d2_key.example.com", "HMAC-MD5", "GWG/Xfbju4O2iXGqkSu4PQ=="); addKey("d2_key.billcat.net", "HMAC-MD5", "GWG/Xfbju4O2iXGqkSu4PQ=="); // Create a valid domain list configuration, with two domains // that have three servers each. std::string config = "[ " - "{ \"name\": \"tmark.org\" , " - " \"key-name\": \"d2_key.tmark.org\" , " + "{ \"name\": \"example.com\" , " + " \"key-name\": \"d2_key.example.com\" , " " \"dns-servers\" : [ " " { \"ip-address\": \"127.0.0.1\" , " " \"port\": 100 }," @@ -1059,13 +1059,13 @@ TEST_F(DdnsDomainListParserTest, validList) { EXPECT_EQ(2, domains_->size()); // Verify that the first domain exists and can be retrieved. - DdnsDomainMap::iterator gotit = domains_->find("tmark.org"); + DdnsDomainMap::iterator gotit = domains_->find("example.com"); ASSERT_TRUE(gotit != domains_->end()); DdnsDomainPtr& domain = gotit->second; // Verify the name and key_name values of the first domain. - EXPECT_EQ("tmark.org", domain->getName()); - EXPECT_EQ("d2_key.tmark.org", domain->getKeyName()); + EXPECT_EQ("example.com", domain->getName()); + EXPECT_EQ("d2_key.example.com", domain->getKeyName()); // Verify the TSIGKeyInfo name and that the actual key was created ASSERT_TRUE(domain->getTSIGKeyInfo()); @@ -1126,19 +1126,19 @@ TEST_F(DdnsDomainListParserTest, duplicateDomain) { // the same name. std::string config = "[ " - "{ \"name\": \"tmark.org\" , " + "{ \"name\": \"example.com\" , " " \"dns-servers\" : [ " " { \"ip-address\": \"127.0.0.3\" , " " \"port\": 300 } ] } " ", " - "{ \"name\": \"tmark.org\" , " + "{ \"name\": \"example.com\" , " " \"dns-servers\" : [ " " { \"ip-address\": \"127.0.0.3\" , " " \"port\": 300 } ] } " "] "; // Verify that the parsing fails. PARSE_FAIL(config, - "Duplicate domain specified:tmark.org (:1:113)"); + "Duplicate domain specified:example.com (:1:115)"); } }; diff --git a/src/bin/d2/tests/nc_test_utils.cc b/src/bin/d2/tests/nc_test_utils.cc index 00ade2f36c..0f6b228b04 100644 --- a/src/bin/d2/tests/nc_test_utils.cc +++ b/src/bin/d2/tests/nc_test_utils.cc @@ -26,21 +26,21 @@ const char* valid_d2_config = "{ " "\"ip-address\" : \"127.0.0.1\" , " "\"port\" : 5031, " "\"tsig-keys\": [" - "{ \"name\": \"d2_key.tmark.org\" , " + "{ \"name\": \"d2_key.example.com\" , " " \"algorithm\": \"HMAC-MD5\" ," " \"secret\": \"LSWXnfkKZjdPJI5QxlpnfQ==\" " "} ]," "\"forward-ddns\" : {" "\"ddns-domains\": [ " - "{ \"name\": \"tmark.org.\" , " - " \"key-name\": \"d2_key.tmark.org\" , " + "{ \"name\": \"example.com.\" , " + " \"key-name\": \"d2_key.example.com\" , " " \"dns-servers\" : [ " " { \"ip-address\": \"127.0.0.101\" } " "] } ] }, " "\"reverse-ddns\" : {" "\"ddns-domains\": [ " "{ \"name\": \" 0.168.192.in.addr.arpa.\" , " - " \"key-name\": \"d2_key.tmark.org\" , " + " \"key-name\": \"d2_key.example.com\" , " " \"dns-servers\" : [ " " { \"ip-address\": \"127.0.0.101\" , " " \"port\": 100 } ] } " diff --git a/src/bin/d2/tests/testdata/d2_cfg_tests.json b/src/bin/d2/tests/testdata/d2_cfg_tests.json index 6250ba91a4..f86cf7b622 100644 --- a/src/bin/d2/tests/testdata/d2_cfg_tests.json +++ b/src/bin/d2/tests/testdata/d2_cfg_tests.json @@ -163,7 +163,7 @@ #----- ,{ "description" : "D2Params.port can't be 0", -"syntax-error" : ":1.33: port must be greater than zero", +"syntax-error" : ":1.33: port must be greater than zero but less than 65792", "data" : { "port" : 0, @@ -1088,7 +1088,7 @@ #----- ,{ "description" : "D2.forward-ddns.dhcp-ddns.dns-servers.port cannot be 0 ", -"syntax-error" : ":1.97: port must be greater than zero", +"syntax-error" : ":1.97: port must be greater than zero but less than 65792", "data" : { "forward-ddns" : @@ -1481,7 +1481,7 @@ #----- ,{ "description" : "D2.reverse-ddns.dhcp-ddns.dns-servers.port cannot be 0 ", -"syntax-error" : ":1.119: port must be greater than zero", +"syntax-error" : ":1.119: port must be greater than zero but less than 65792", "data" : { "forward-ddns" : {}, diff --git a/src/lib/process/d_cfg_mgr.cc b/src/lib/process/d_cfg_mgr.cc index 3a994026b8..8cf2498fbf 100644 --- a/src/lib/process/d_cfg_mgr.cc +++ b/src/lib/process/d_cfg_mgr.cc @@ -260,6 +260,15 @@ DCfgMgrBase::parseConfig(isc::data::ConstElementPtr config_set) { return (answer); } +void +DCfgMgrBase::setCfgDefaults(isc::data::ElementPtr) { +} + +void +DCfgMgrBase::parseElement(const std::string&, isc::data::ConstElementPtr) { +}; + + void DCfgMgrBase::buildParams(isc::data::ConstElementPtr params_config) { // Loop through scalars parsing them and committing them to storage. diff --git a/src/lib/process/d_cfg_mgr.h b/src/lib/process/d_cfg_mgr.h index 1128c0657f..e7868cb2af 100644 --- a/src/lib/process/d_cfg_mgr.h +++ b/src/lib/process/d_cfg_mgr.h @@ -321,10 +321,9 @@ protected: /// Element map prior to parsing it. /// /// @param mutable_config - configuration to which defaults should be added - virtual void setCfgDefaults(isc::data::ElementPtr mutable_config) { - } + virtual void setCfgDefaults(isc::data::ElementPtr mutable_config); - /// @brief Parses the an element using an alternate parsing mechanism + /// @brief Parses an individual element /// /// Each element to be parsed is passed into this method to be converted /// into the requisite application object(s). @@ -333,8 +332,7 @@ protected: /// @param element value of the element as ElementPtr /// virtual void parseElement(const std::string& element_id, - isc::data::ConstElementPtr element) { - }; + isc::data::ConstElementPtr element); /// @brief Parses a set of scalar configuration elements into global /// parameters diff --git a/src/lib/process/d_controller.cc b/src/lib/process/d_controller.cc index 3caa71d256..a9f9da15f1 100644 --- a/src/lib/process/d_controller.cc +++ b/src/lib/process/d_controller.cc @@ -54,6 +54,12 @@ DControllerBase::setController(const DControllerBasePtr& controller) { controller_ = controller; } +isc::data::ConstElementPtr +DControllerBase::parseFile(const std::string&) { + isc::data::ConstElementPtr elements; + return (elements); +} + void DControllerBase::launch(int argc, char* argv[], const bool test_mode) { @@ -168,7 +174,7 @@ DControllerBase::parseArgs(int argc, char* argv[]) // rather than calling exit() here which disrupts gtest. isc_throw(VersionMessage, getVersion(true)); break; - + case 'W': // gather Kea config report and throw so main() can catch and // return rather than calling exit() here which disrupts gtest. @@ -484,7 +490,7 @@ DControllerBase::getVersion(bool extended) { tmp << "linked with:" << std::endl; tmp << isc::log::Logger::getVersion() << std::endl; tmp << isc::cryptolink::CryptoLink::getVersion() << std::endl; - tmp << "database:" << std::endl; + tmp << "database:" << std::endl; #ifdef HAVE_MYSQL tmp << isc::dhcp::MySqlLeaseMgr::getDBVersion() << std::endl; #endif diff --git a/src/lib/process/d_controller.h b/src/lib/process/d_controller.h index 7bdc4c54a8..612c5e1237 100644 --- a/src/lib/process/d_controller.h +++ b/src/lib/process/d_controller.h @@ -411,10 +411,7 @@ protected: /// /// @return pointer to the elements created /// - virtual isc::data::ConstElementPtr parseFile(const std::string& file_name) { - isc::data::ConstElementPtr elements; - return (elements); - } + virtual isc::data::ConstElementPtr parseFile(const std::string& file_name); ///@brief Parse text into Elements /// -- 2.47.3