summaryrefslogtreecommitdiffstats
path: root/src/bin/d2/d2_config.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/d2/d2_config.h')
-rw-r--r--src/bin/d2/d2_config.h517
1 files changed, 100 insertions, 417 deletions
diff --git a/src/bin/d2/d2_config.h b/src/bin/d2/d2_config.h
index b605193c55..8eb7e6a2db 100644
--- a/src/bin/d2/d2_config.h
+++ b/src/bin/d2/d2_config.h
@@ -1,4 +1,4 @@
-// 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
@@ -9,6 +9,8 @@
#include <asiolink/io_service.h>
#include <cc/data.h>
+#include <cc/simple_parser.h>
+#include <cc/cfg_to_element.h>
#include <dhcpsrv/parsers/dhcp_parsers.h>
#include <dns/tsig.h>
#include <exceptions/exceptions.h>
@@ -36,10 +38,6 @@ namespace d2 {
/// a name, the algorithm method name, optionally the minimum truncated
/// length, and its secret key component.
///
-/// @todo NOTE that TSIG configuration parsing is functional, the use of
-/// TSIG Keys during the actual DNS update transactions is not. This will be
-/// implemented in a future release.
-///
/// Each managed domain list consists of a list one or more domains and is
/// represented by the class DdnsDomainListMgr.
///
@@ -53,9 +51,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
@@ -140,17 +135,6 @@ public:
/// @brief Acts as a storage vault for D2 global scalar parameters
class D2Params {
public:
- /// @brief Default configuration constants.
- //@{
- /// @todo For now these are hard-coded as configuration layer cannot
- /// readily provide them (see Trac #3358).
- static const char *DFT_IP_ADDRESS;
- static const size_t DFT_PORT;
- static const size_t DFT_DNS_SERVER_TIMEOUT;
- 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
@@ -213,10 +197,10 @@ public:
/// @return Configuration summary in the textual format.
std::string getConfigSummary() const;
- /// @brief Compares two D2Paramss for equality
+ /// @brief Compares two D2Params's for equality
bool operator == (const D2Params& other) const;
- /// @brief Compares two D2Paramss for inequality
+ /// @brief Compares two D2Params's for inequality
bool operator != (const D2Params& other) const;
/// @brief Generates a string representation of the class contents.
@@ -258,7 +242,7 @@ private:
/// @brief Dumps the contents of a D2Params as text to an output stream
///
/// @param os output stream to which text should be sent
-/// @param config D2Param instnace to dump
+/// @param config D2Param instance to dump
std::ostream&
operator<<(std::ostream& os, const D2Params& config);
@@ -272,7 +256,7 @@ typedef boost::shared_ptr<D2Params> D2ParamsPtr;
/// instance of the actual key (@ref isc::dns::TSIGKey) that can be used
/// by the IO layer for signing and verifying messages.
///
-class TSIGKeyInfo {
+class TSIGKeyInfo : public isc::data::CfgToElement {
public:
/// @brief Defines string values for the supported TSIG algorithms
//@{
@@ -287,7 +271,7 @@ public:
/// @brief Constructor
///
/// @param name the unique label used to identify this key
- /// @param algorithm the id of the encryption alogirthm this key uses.
+ /// @param algorithm the id of the encryption algorithm this key uses.
/// Currently supported values are (case insensitive):
/// -# "HMAC-MD5"
/// -# "HMAC-SHA1"
@@ -373,6 +357,11 @@ public:
static const dns::Name& stringToAlgorithmName(const std::string&
algorithm_id);
+ /// @brief Unparse a configuration object
+ ///
+ /// @return a pointer to a configuration
+ virtual isc::data::ElementPtr toElement() const;
+
private:
/// @brief Creates the actual TSIG key instance member
///
@@ -422,16 +411,11 @@ typedef boost::shared_ptr<TSIGKeyInfoMap> TSIGKeyInfoMapPtr;
/// belongs to a list of servers supporting DNS for a given domain. It will
/// be used to establish communications with the server to carry out DNS
/// updates.
-class DnsServerInfo {
+class DnsServerInfo : public isc::data::CfgToElement {
public:
-
/// @brief defines DNS standard port value
static const uint32_t STANDARD_DNS_PORT = 53;
- /// @brief defines an "empty" string version of an ip address.
- static const char* EMPTY_IP_STR;
-
-
/// @brief Constructor
///
/// @param hostname is the resolvable name of the server. If not blank,
@@ -494,6 +478,11 @@ public:
/// @brief Returns a text representation for the server.
std::string toText() const;
+ /// @brief Unparse a configuration object
+ ///
+ /// @return a pointer to a configuration
+ virtual isc::data::ElementPtr toElement() const;
+
private:
/// @brief The resolvable name of the server. If not blank, then the
@@ -532,13 +521,13 @@ typedef boost::shared_ptr<DnsServerInfoStorage> DnsServerInfoStoragePtr;
/// @todo Currently the name entry for a domain is just an std::string. It
/// may be worthwhile to change this to a dns::Name for purposes of better
/// validation and matching capabilities.
-class DdnsDomain {
+class DdnsDomain : public isc::data::CfgToElement {
public:
/// @brief Constructor
///
/// @param name is the domain name of the domain.
/// @param servers is the list of server(s) supporting this domain.
- /// @param tsig_key_info pointer to the TSIGKeyInfo for the dommain's key
+ /// @param tsig_key_info pointer to the TSIGKeyInfo for the domain's key
/// It defaults to an empty pointer, signifying the domain has no key.
DdnsDomain(const std::string& name,
DnsServerInfoStoragePtr servers,
@@ -575,6 +564,11 @@ public:
return (tsig_key_info_);
}
+ /// @brief Unparse a configuration object
+ ///
+ /// @return a pointer to a configuration
+ virtual isc::data::ElementPtr toElement() const;
+
private:
/// @brief The domain name of the domain.
std::string name_;
@@ -610,7 +604,7 @@ typedef boost::shared_ptr<DdnsDomainMap> DdnsDomainMapPtr;
/// specify the wild card domain as the only forward domain. All forward DNS
/// updates would be sent to that one list of servers, regardless of the FQDN.
/// As matching capabilities evolve this class is expected to expand.
-class DdnsDomainListMgr {
+class DdnsDomainListMgr : public isc::data::CfgToElement {
public:
/// @brief defines the domain name for denoting the wildcard domain.
static const char* wildcard_domain_name_;
@@ -677,6 +671,11 @@ public:
/// set the internal wild card domain pointer accordingly.
void setDomains(DdnsDomainMapPtr domains);
+ /// @brief Unparse a configuration object
+ ///
+ /// @return a pointer to a configuration
+ virtual isc::data::ElementPtr toElement() const;
+
private:
/// @brief An arbitrary label assigned to this manager.
std::string name_;
@@ -719,6 +718,13 @@ public:
return (process::DCfgContextBasePtr(new DScalarContext(*this)));
}
+ /// @brief Unparse a configuration object
+ ///
+ /// @return a pointer to a configuration
+ virtual isc::data::ElementPtr toElement() const {
+ isc_throw(isc::NotImplemented, "DScalarContext::ElementPtr");
+ }
+
protected:
/// @brief Copy constructor
DScalarContext(const DScalarContext& rhs) : DCfgContextBase(rhs) {
@@ -732,474 +738,151 @@ private:
/// @brief Defines a pointer for DScalarContext instances.
typedef boost::shared_ptr<DScalarContext> DScalarContextPtr;
-/// @brief Parser for TSIGKeyInfo
+/// @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 isc::dhcp::DhcpConfigParser {
+/// This class parses the configuration element "tsig-key"
+/// and creates an instance of a TSIGKeyInfo.
+class TSIGKeyInfoParser : public data::SimpleParser {
public:
- /// @brief Constructor
- ///
- /// @param entry_name is an arbitrary label assigned to this configuration
- /// definition. Since servers are specified in a list this value is likely
- /// be something akin to "key:0", set during parsing.
- /// @param keys is a pointer to the storage area to which the parser
- /// should commit the newly created TSIGKeyInfo instance.
- TSIGKeyInfoParser(const std::string& entry_name, TSIGKeyInfoMapPtr keys);
-
- /// @brief Destructor
- virtual ~TSIGKeyInfoParser();
-
- /// @brief Performs the actual parsing of the given "tsig-key" element.
+ /// @brief Performs the actual parsing of the given "tsig-key" element.
///
/// Parses a configuration for the elements needed to instantiate a
/// TSIGKeyInfo, validates those entries, creates a TSIGKeyInfo instance
- /// then attempts to add to a list of keys
///
/// @param key_config is the "tsig-key" configuration to parse
- virtual void build(isc::data::ConstElementPtr key_config);
-
- /// @brief Creates a parser for the given "tsig-key" member element id.
- ///
- /// The key elements currently supported are(see dhcp-ddns.spec):
- /// 1. name
- /// 2. algorithm
- /// 3. digestbits
- /// 4. secret
- ///
- /// @param config_id is the "item_name" for a specific member element of
- /// the "tsig-key" specification.
- /// @param pos position within the configuration text (or file) of element
- /// to be parsed. This is passed for error messaging.
- ///
- /// @return returns a pointer to newly created parser.
///
- /// @throw D2CfgError if configuration contains an unknown parameter
- virtual isc::dhcp::ParserPtr
- createConfigParser(const std::string& config_id,
- const isc::data::Element::Position& pos =
- isc::data::Element::ZERO_POSITION());
+ /// @return pointer to the new TSIGKeyInfo instance
+ TSIGKeyInfoPtr parse(data::ConstElementPtr key_config);
- /// @brief Commits the TSIGKeyInfo configuration
- /// Currently this method is a NOP, as the key instance is created and
- /// then added to a local list of keys in build().
- virtual void commit();
-
-private:
- /// @brief Arbitrary label assigned to this parser instance.
- /// Since servers are specified in a list this value is likely be something
- /// akin to "key:0", set during parsing. Primarily here for diagnostics.
- std::string entry_name_;
-
- /// @brief Pointer to the storage area to which the parser should commit
- /// the newly created TSIGKeyInfo instance. This is given to us as a
- /// constructor argument by an upper level.
- TSIGKeyInfoMapPtr keys_;
-
- /// @brief Local storage area for scalar parameter values. Use to hold
- /// data until time to commit.
- DScalarContext local_scalars_;
};
/// @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.
-class TSIGKeyInfoListParser : public isc::dhcp::DhcpConfigParser {
+/// The TSIGKeyInfo instances are added to the given storage upon commit.
+class TSIGKeyInfoListParser : public data::SimpleParser {
public:
-
- /// @brief Constructor
- ///
- /// @param list_name is an arbitrary label assigned to this parser instance.
- /// @param keys is a pointer to the storage area to which the parser
- /// should commit the newly created TSIGKeyInfo instance.
- TSIGKeyInfoListParser(const std::string& list_name, TSIGKeyInfoMapPtr keys);
-
- /// @brief Destructor
- virtual ~TSIGKeyInfoListParser();
-
/// @brief Performs the parsing of the given list "tsig-key" elements.
///
- /// 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 build method
- /// 3. Add the parser instance to local storage
+ /// Creates an empty TSIGKeyInfoMap
///
- /// The net effect is to parse all of the key entries in the list
- /// prepping them for commit.
+ /// Instantiates a TSIGKeyInfoParser
+ /// It iterates over each key entry in the list:
+ /// 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.
- virtual void build(isc::data::ConstElementPtr key_list_config);
-
- /// @brief Commits the list of TSIG keys
///
- /// Iterates over the internal list of TSIGKeyInfoParsers, invoking
- /// commit on each one. Then commits the local list of keys to
- /// storage.
- virtual void commit();
-
-private:
- /// @brief Arbitrary label assigned to this parser instance.
- std::string list_name_;
-
- /// @brief Pointer to the storage area to which the parser should commit
- /// the list of newly created TSIGKeyInfo instances. This is given to us
- /// as a constructor argument by an upper level.
- TSIGKeyInfoMapPtr keys_;
-
- /// @brief Local storage area to which individual key parsers commit.
- TSIGKeyInfoMapPtr local_keys_;
-
- /// @brief Local storage of TSIGKeyInfoParser instances
- isc::dhcp::ParserCollection parsers_;
+ /// @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.
-class DnsServerInfoParser : public isc::dhcp::DhcpConfigParser {
+/// This class parses the configuration element "dns-server"
+/// and creates an instance of a DnsServerInfo.
+class DnsServerInfoParser : public data::SimpleParser {
public:
- /// @brief Constructor
- ///
- /// @param entry_name is an arbitrary label assigned to this configuration
- /// definition. Since servers are specified in a list this value is likely
- /// be something akin to "server:0", set during parsing.
- /// @param servers is a pointer to the storage area to which the parser
- /// should commit the newly created DnsServerInfo instance.
- DnsServerInfoParser(const std::string& entry_name,
- DnsServerInfoStoragePtr servers);
-
- /// @brief Destructor
- virtual ~DnsServerInfoParser();
-
/// @brief Performs the actual parsing of the given "dns-server" element.
///
/// Parses a configuration for the elements needed to instantiate a
/// DnsServerInfo, validates those entries, creates a DnsServerInfo instance
- /// then attempts to add to a list of servers.
+ /// and returns it.
///
/// @param server_config is the "dns-server" configuration to parse
///
+ /// @return a pointer to the newly created server instance
+ ///
/// @throw D2CfgError if:
/// -# hostname is not blank, hostname is not yet supported
/// -# ip_address is invalid
/// -# port is 0
- virtual void build(isc::data::ConstElementPtr server_config);
-
- /// @brief Creates a parser for the given "dns-server" member element id.
- ///
- /// The server elements currently supported are(see dhcp-ddns.spec):
- /// 1. hostname
- /// 2. ip_address
- /// 3. port
- ///
- /// @param config_id is the "item_name" for a specific member element of
- /// the "dns-server" specification.
- /// @param pos position within the configuration text (or file) of element
- /// to be parsed. This is passed for error messaging.
- ///
- /// @return returns a pointer to newly created parser.
- ///
- /// @throw D2CfgError if configuration contains an unknown parameter
- virtual isc::dhcp::ParserPtr
- createConfigParser(const std::string& config_id,
- const isc::data::Element::Position& =
- isc::data::Element::ZERO_POSITION());
-
- /// @brief Commits the configured DnsServerInfo
- /// Currently this method is a NOP, as the server instance is created and
- /// then added to the list of servers in build().
- virtual void commit();
-
-private:
- /// @brief Arbitrary label assigned to this parser instance.
- /// Since servers are specified in a list this value is likely be something
- /// akin to "server:0", set during parsing. Primarily here for diagnostics.
- std::string entry_name_;
-
- /// @brief Pointer to the storage area to which the parser should commit
- /// the newly created DnsServerInfo instance. This is given to us as a
- /// constructor argument by an upper level.
- DnsServerInfoStoragePtr servers_;
-
- /// @brief Local storage area for scalar parameter values. Use to hold
- /// data until time to commit.
- DScalarContext local_scalars_;
+ DnsServerInfoPtr parse(data::ConstElementPtr server_config);
};
/// @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 isc::dhcp::DhcpConfigParser {
+class DnsServerInfoListParser : public data::SimpleParser{
public:
-
- /// @brief Constructor
- ///
- /// @param list_name is an arbitrary label assigned to this parser instance.
- /// @param servers is a pointer to the storage area to which the parser
- /// should commit the newly created DnsServerInfo instance.
- DnsServerInfoListParser(const std::string& list_name,
- DnsServerInfoStoragePtr servers);
-
- /// @brief Destructor
- virtual ~DnsServerInfoListParser();
-
/// @brief Performs the actual parsing of the given list "dns-server"
/// elements.
- /// It iterates over each server entry in the list:
- /// 1. Instantiate a DnsServerInfoParser for the entry
- /// 2. Pass the element configuration to the parser's build method
- /// 3. Add the parser instance to local storage
///
- /// The net effect is to parse all of the server entries in the list
- /// prepping them for commit.
+ /// 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
+ /// DnsSeverInfoParser::parse()
+ /// 2. Adds the server to the server list
///
/// @param server_list_config is the list of "dns-server" elements to parse.
- virtual void build(isc::data::ConstElementPtr server_list_config);
-
- /// @brief Commits the list of DnsServerInfos
- ///
- /// Iterates over the internal list of DdnsServerInfoParsers, invoking
- /// commit on each one.
- virtual void commit();
-
-private:
- /// @brief Arbitrary label assigned to this parser instance.
- std::string list_name_;
-
- /// @brief Pointer to the storage area to which the parser should commit
- /// the list of newly created DnsServerInfo instances. This is given to us
- /// as a constructor argument by an upper level.
- DnsServerInfoStoragePtr servers_;
-
- /// @brief Local storage of DnsServerInfoParser instances
- isc::dhcp::ParserCollection parsers_;
+ /// @return A pointer to the new, populated server list
+ DnsServerInfoStoragePtr parse(data::ConstElementPtr server_list_config);
};
/// @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.
-class DdnsDomainParser : public isc::dhcp::DhcpConfigParser {
+/// This class parses the configuration element "ddns-domain"
+/// and creates an instance of a DdnsDomain.
+class DdnsDomainParser : public data::SimpleParser {
public:
- /// @brief Constructor
- ///
- /// @param entry_name is an arbitrary label assigned to this configuration
- /// definition. Since domains are specified in a list this value is likely
- /// be something akin to "forward-ddns:0", set during parsing.
- /// @param domains is a pointer to the storage area to which the parser
- /// @param keys is a pointer to a map of the defined TSIG keys.
- /// should commit the newly created DdnsDomain instance.
- DdnsDomainParser(const std::string& entry_name, DdnsDomainMapPtr domains,
- TSIGKeyInfoMapPtr keys);
-
- /// @brief Destructor
- virtual ~DdnsDomainParser();
-
/// @brief Performs the actual parsing of the given "ddns-domain" element.
///
/// Parses a configuration for the elements needed to instantiate a
- /// DdnsDomain, validates those entries, creates a DdnsDomain instance
- /// then attempts to add it to a list of domains.
+ /// DdnsDomain, validates those entries, and creates a DdnsDomain instance.
///
/// @param domain_config is the "ddns-domain" configuration to parse
- virtual void build(isc::data::ConstElementPtr domain_config);
-
- /// @brief Creates a parser for the given "ddns-domain" member element id.
- ///
- /// The domain elements currently supported are(see dhcp-ddns.spec):
- /// 1. name
- /// 2. key_name
- /// 3. dns_servers
- ///
- /// @param config_id is the "item_name" for a specific member element of
- /// the "ddns-domain" specification.
- /// @param pos position within the configuration text (or file) of element
- /// to be parsed. This is passed for error messaging.
+ /// @param keys map of defined TSIG keys
///
- /// @return returns a pointer to newly created parser.
- ///
- /// @throw D2CfgError if configuration contains an unknown parameter
- virtual isc::dhcp::ParserPtr
- createConfigParser(const std::string& config_id,
- const isc::data::Element::Position& pos =
- isc::data::Element::ZERO_POSITION());
-
- /// @brief Commits the configured DdnsDomain
- /// Currently this method is a NOP, as the domain instance is created and
- /// then added to the list of domains in build().
- virtual void commit();
-
-private:
-
- /// @brief Arbitrary label assigned to this parser instance.
- std::string entry_name_;
-
- /// @brief Pointer to the storage area to which the parser should commit
- /// the newly created DdnsDomain instance. This is given to us as a
- /// constructor argument by an upper level.
- DdnsDomainMapPtr domains_;
-
- /// @brief Pointer to the map of defined TSIG keys.
- /// This map is passed into us and contains all of the TSIG keys defined
- /// for this configuration. It is used to validate the key name entry of
- /// DdnsDomains that specify one.
- TSIGKeyInfoMapPtr keys_;
-
- /// @brief Local storage for DnsServerInfo instances. This is passed into
- /// DnsServerInfoListParser(s), which in turn passes it into each
- /// DnsServerInfoParser. When the DnsServerInfoParsers "commit" they add
- /// their server instance to this storage.
- DnsServerInfoStoragePtr local_servers_;
-
- /// @brief Local storage area for scalar parameter values. Use to hold
- /// data until time to commit.
- DScalarContext local_scalars_;
+ /// @return a pointer to the new domain instance
+ DdnsDomainPtr parse(data::ConstElementPtr domain_config,
+ const TSIGKeyInfoMapPtr keys);
};
/// @brief Parser for a list of DdnsDomains
///
-/// This class parses a list of "ddns-domain" configuration elements.
-/// (see src/bin/d2/dhcp-ddns.spec). The DdnsDomain instances are added
-/// to the given storage upon commit.
-class DdnsDomainListParser : public isc::dhcp::DhcpConfigParser {
+/// This class parses a list of "ddns-domain" configuration elements
+/// into a map of DdnsDomains.
+class DdnsDomainListParser : public data::SimpleParser {
public:
-
- /// @brief Constructor
- ///
- /// @param list_name is an arbitrary label assigned to this parser instance.
- /// @param domains is a pointer to the storage area to which the parser
- /// @param keys is a pointer to a map of the defined TSIG keys.
- /// should commit the newly created DdnsDomain instance.
- DdnsDomainListParser(const std::string& list_name,
- DdnsDomainMapPtr domains, TSIGKeyInfoMapPtr keys);
-
- /// @brief Destructor
- virtual ~DdnsDomainListParser();
-
/// @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. Instantiate a DdnsDomainParser for the entry
- /// 2. Pass the element configuration to the parser's build method
- /// 3. Add the parser instance to local storage
- ///
- /// The net effect is to parse all of the domain entries in the list
- /// prepping them for commit.
+ /// 1. Creates a DdnsDomain instance by passing the entry into @c
+ /// DdnsDomainParser::parser()
+ /// 2. Adds the DdnsDomain instance to the domain map
///
/// @param domain_list_config is the list of "ddns-domain" elements to
/// parse.
- virtual void build(isc::data::ConstElementPtr domain_list_config);
-
- /// @brief Commits the list of DdnsDomains
- ///
- /// Iterates over the internal list of DdnsDomainParsers, invoking
- /// commit on each one.
- virtual void commit();
-
-private:
- /// @brief Arbitrary label assigned to this parser instance.
- std::string list_name_;
-
- /// @brief Pointer to the storage area to which the parser should commit
- /// the list of newly created DdnsDomain instances. This is given to us
- /// as a constructor argument by an upper level.
- DdnsDomainMapPtr domains_;
-
- /// @brief Pointer to the map of defined TSIG keys.
- /// This map is passed into us and contains all of the TSIG keys defined
- /// for this configuration. It is used to validate the key name entry of
- /// DdnsDomains that specify one.
- TSIGKeyInfoMapPtr keys_;
-
- /// @brief Local storage of DdnsDomainParser instances
- isc::dhcp::ParserCollection parsers_;
+ /// @param keys map of defined TSIG keys
+ /// @return a pointer to the newly populated domain map
+ DdnsDomainMapPtr parse(data::ConstElementPtr domain_list_config,
+ const TSIGKeyInfoMapPtr keys);
};
/// @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 upon commit. Note that
-/// unlike other parsers, this parser does NOT instantiate the final object
-/// during the commit phase, it populates it. It must pre-exist.
-class DdnsDomainListMgrParser : public isc::dhcp::DhcpConfigParser {
+/// "reverse-ddns". It populates the given DdnsDomainListMgr with parsed
+/// information.
+class DdnsDomainListMgrParser : public data::SimpleParser {
public:
- /// @brief Constructor
- ///
- /// @param entry_name is an arbitrary label assigned to this configuration
- /// definition.
- /// @param mgr is a pointer to the DdnsDomainListMgr to populate.
- /// @param keys is a pointer to a map of the defined TSIG keys.
- /// @throw throws D2CfgError if mgr pointer is empty.
- DdnsDomainListMgrParser(const std::string& entry_name,
- DdnsDomainListMgrPtr mgr, TSIGKeyInfoMapPtr keys);
-
- /// @brief Destructor
- virtual ~DdnsDomainListMgrParser();
-
/// @brief Performs the actual parsing of the given manager element.
///
/// Parses a configuration for the elements needed to instantiate a
/// DdnsDomainListMgr, validates those entries, then creates a
/// DdnsDomainListMgr.
///
- /// @param mgr_config is the manager configuration to parse
- virtual void build(isc::data::ConstElementPtr mgr_config);
-
- /// @brief Creates a parser for the given manager member element id.
- ///
- /// The manager elements currently supported are (see dhcp-ddns.spec):
- /// 1. ddns_domains
- ///
- /// @param config_id is the "item_name" for a specific member element of
- /// the manager specification.
- /// @param pos position within the configuration text (or file) of element
- /// to be parsed. This is passed for error messaging.
- ///
- /// @return returns a pointer to newly created parser.
+ /// @param mgr_config manager configuration to parse
+ /// @param mgr_name convenience label for the manager instance
+ /// @param keys map of defined TSIG keys
///
- /// @throw D2CfgError if configuration contains an unknown parameter
- virtual isc::dhcp::ParserPtr
- createConfigParser(const std::string& config_id,
- const isc::data::Element::Position& pos =
- isc::data::Element::ZERO_POSITION());
-
- /// @brief Commits the configured DdsnDomainListMgr
- /// Currently this method is a NOP, as the manager instance is created
- /// in build().
- virtual void commit();
-
-private:
- /// @brief Arbitrary label assigned to this parser instance.
- std::string entry_name_;
-
- /// @brief Pointer to manager instance to which the parser should commit
- /// the parsed data. This is given to us as a constructor argument by an
- /// upper level.
- DdnsDomainListMgrPtr mgr_;
-
- /// @brief Pointer to the map of defined TSIG keys.
- /// This map is passed into us and contains all of the TSIG keys defined
- /// for this configuration. It is used to validate the key name entry of
- /// DdnsDomains that specify one.
- TSIGKeyInfoMapPtr keys_;
-
- /// @brief Local storage for DdnsDomain instances. This is passed into a
- /// DdnsDomainListParser(s), which in turn passes it into each
- /// DdnsDomainParser. When the DdnsDomainParsers "commit" they add their
- /// domain instance to this storage.
- DdnsDomainMapPtr local_domains_;
-
- /// @brief Local storage area for scalar parameter values. Use to hold
- /// data until time to commit.
- /// @todo Currently, the manager has no scalars but this is likely to
- /// change as matching capabilities expand.
- DScalarContext local_scalars_;
+ /// @return a pointer to the new manager instance
+ DdnsDomainListMgrPtr parse(data::ConstElementPtr mgr_config,
+ const std::string& mgr_name,
+ const TSIGKeyInfoMapPtr keys);
};