Parcourir la source

[5110] Replaced constants in D2SimpleParser with literals

Thomas Markwalder il y a 8 ans
Parent
commit
3be8803580
3 fichiers modifiés avec 19 ajouts et 40 suppressions
  1. 2 15
      src/bin/d2/d2_config.cc
  2. 0 16
      src/bin/d2/d2_config.h
  3. 17 9
      src/bin/d2/d2_simple_parser.cc

+ 2 - 15
src/bin/d2/d2_config.cc

@@ -26,14 +26,6 @@ namespace d2 {
 
 // *********************** D2Params  *************************
 
-const char*     D2Params::DFT_IP_ADDRESS = "127.0.0.1";
-const uint32_t  D2Params::DFT_PORT = 53001;
-const char*     D2Params::DFT_PORT_STR = "53001";
-const uint32_t  D2Params::DFT_DNS_SERVER_TIMEOUT = 100;
-const char*     D2Params::DFT_DNS_SERVER_TIMEOUT_STR = "100";
-const char*     D2Params::DFT_NCR_PROTOCOL = "UDP";
-const char*     D2Params::DFT_NCR_FORMAT = "JSON";
-
 D2Params::D2Params(const isc::asiolink::IOAddress& ip_address,
                    const size_t port,
                    const size_t dns_server_timeout,
@@ -48,8 +40,8 @@ D2Params::D2Params(const isc::asiolink::IOAddress& ip_address,
 }
 
 D2Params::D2Params()
-    : ip_address_(isc::asiolink::IOAddress(DFT_IP_ADDRESS)),
-     port_(DFT_PORT), dns_server_timeout_(DFT_DNS_SERVER_TIMEOUT),
+    : ip_address_(isc::asiolink::IOAddress("127.0.0.1")),
+     port_(53001), dns_server_timeout_(100),
      ncr_protocol_(dhcp_ddns::NCR_UDP),
      ncr_format_(dhcp_ddns::FMT_JSON) {
     validateContents();
@@ -189,10 +181,6 @@ TSIGKeyInfo::remakeKey() {
 }
 
 // *********************** DnsServerInfo  *************************
-
-const char* DnsServerInfo::STANDARD_DNS_PORT_STR = "53";
-const char* DnsServerInfo::EMPTY_IP_STR = "0.0.0.0";
-
 DnsServerInfo::DnsServerInfo(const std::string& hostname,
                              isc::asiolink::IOAddress ip_address, uint32_t port,
                              bool enabled)
@@ -429,7 +417,6 @@ DnsServerInfoParser::parse(data::ConstElementPtr server_config) {
         /// @code
         /// // When  hostname is specified, create a valid, blank IOAddress
         /// // and then create the DnsServerInfo.
-        /// isc::asiolink::IOAddress io_addr(DnsServerInfo::EMPTY_IP_STR);
         /// serverInfo.reset(new DnsServerInfo(hostname, io_addr, port));
         ///
         /// @endcode

+ 0 - 16
src/bin/d2/d2_config.h

@@ -134,18 +134,6 @@ public:
 /// @brief Acts as a storage vault for D2 global scalar parameters
 class D2Params {
 public:
-
-    /// @brief Default configuration constants.
-    //@{
-    static const char*      DFT_IP_ADDRESS;
-    static const uint32_t   DFT_PORT;
-    static const char*      DFT_PORT_STR;
-    static const uint32_t   DFT_DNS_SERVER_TIMEOUT;
-    static const char*      DFT_DNS_SERVER_TIMEOUT_STR;
-    static const char*      DFT_NCR_PROTOCOL;
-    static const char*      DFT_NCR_FORMAT;
-    //@}
-
     /// @brief Constructor
     ///
     /// @param ip_address IP address at which D2 should listen for NCRs
@@ -421,10 +409,6 @@ class DnsServerInfo {
 public:
     /// @brief defines DNS standard port value
     static const uint32_t STANDARD_DNS_PORT = 53;
-    static const char* STANDARD_DNS_PORT_STR;
-
-    /// @brief defines an "empty" string version of an ip address.
-    static const char* EMPTY_IP_STR;
 
     /// @brief Constructor
     ///

+ 17 - 9
src/bin/d2/d2_simple_parser.cc

@@ -34,28 +34,36 @@ namespace d2 {
 /// in DhcpDdns) are optional. If not defined, the following values will be
 /// used.
 const SimpleDefaults D2SimpleParser::D2_GLOBAL_DEFAULTS = {
-    { "ip-address",         Element::string, D2Params::DFT_IP_ADDRESS },
-    { "port",               Element::integer, D2Params::DFT_PORT_STR },
-    { "dns-server-timeout", Element::integer, D2Params::DFT_DNS_SERVER_TIMEOUT_STR },
-    { "ncr-protocol",       Element::string, D2Params::DFT_NCR_PROTOCOL },
-    { "ncr-format",         Element::string, D2Params::DFT_NCR_FORMAT }
+    { "ip-address",         Element::string, "127.0.0.1" },
+    { "port",               Element::integer, "53001" },
+    { "dns-server-timeout", Element::integer, "100" }, // in seconds
+    { "ncr-protocol",       Element::string, "UDP" },
+    { "ncr-format",         Element::string, "JSON" }
 };
 
+/// Supplies defaults for ddns-domoains list elements (i.e. DdnsDomains)
 const SimpleDefaults D2SimpleParser::TSIG_KEY_DEFAULTS = {
-    { "digest-bits",    Element::integer, "0" }
+    { "digest-bits", Element::integer, "0" }
 };
 
+/// Supplies defaults for optional values in DDNS domain managers
+/// (e.g. "forward-ddns" and "reverse-ddns").
+/// @note  While there are none yet defined, it is highly likely
+/// there will be domain manager defaults added in the future.
+/// This code to set defaults already uses this list, so supporting
+/// values will simply require adding them to this list.
 const SimpleDefaults D2SimpleParser::DDNS_DOMAIN_MGR_DEFAULTS = {
-    // none yet
 };
 
+/// Supplies defaults for ddns-domoains list elements (i.e. DdnsDomains)
 const SimpleDefaults D2SimpleParser::DDNS_DOMAIN_DEFAULTS = {
-    { "key-name",    Element::string, "" }
+    { "key-name", Element::string, "" }
 };
 
+/// Supplies defaults for optional values DdnsDomain entries.
 const SimpleDefaults D2SimpleParser::DNS_SERVER_DEFAULTS = {
     { "hostname", Element::string, "" },
-    { "port",     Element::integer, DnsServerInfo::STANDARD_DNS_PORT_STR },
+    { "port",     Element::integer, "53" },
 };
 
 /// @}