d2_config.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661
  1. // Copyright (C) 2013 Internet Systems Consortium, Inc. ("ISC")
  2. //
  3. // Permission to use, copy, modify, and/or distribute this software for any
  4. // purpose with or without fee is hereby granted, provided that the above
  5. // copyright notice and this permission notice appear in all copies.
  6. //
  7. // THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  8. // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  9. // AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  10. // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  11. // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  12. // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  13. // PERFORMANCE OF THIS SOFTWARE.
  14. #ifndef D2_CONFIG_H
  15. #define D2_CONFIG_H
  16. #include <asiolink/io_address.h>
  17. #include <cc/data.h>
  18. #include <d2/d_cfg_mgr.h>
  19. #include <dhcpsrv/dhcp_parsers.h>
  20. #include <exceptions/exceptions.h>
  21. #include <boost/foreach.hpp>
  22. #include <stdint.h>
  23. #include <string>
  24. namespace isc {
  25. namespace d2 {
  26. /// @file d2_config.h
  27. /// @brief A collection of classes for housing and parsing the application
  28. /// configuration necessary for the DHCP-DDNS application (aka D2).
  29. ///
  30. /// This file contains the class declarations for the class hierarchy created
  31. /// from the D2 configuration and the parser classes used to create it.
  32. /// The application configuration consists of a set of scalar parameters and
  33. /// two managed lists of domains: one list for forward domains and one list for
  34. /// reverse domains.
  35. ///
  36. /// Each managed list consists of a list one or more domains and is represented
  37. /// by the class DdnsDomainListMgr.
  38. ///
  39. /// Each domain consists of a set of scalars parameters and a list of DNS
  40. /// servers which support that domain. Domains are represented by the class,
  41. /// DdnsDomain.
  42. ///
  43. /// Each server consists of a set of scalars used to describe the server such
  44. /// that the application can carry out DNS update exchanges with it. Servers
  45. /// are represented by the class, DnsServerInfo.
  46. ///
  47. /// The configuration specification for use with BIND10 is detailed in the file
  48. /// dhcp-ddns.spec.
  49. ///
  50. /// The parsing class hierarchy reflects this same scheme. Working top down:
  51. ///
  52. /// A DdnsDomainListMgrParser parses a managed domain list entry. It handles
  53. /// any scalars which belong to the manager as well as creating and invoking a
  54. /// DdnsDomainListParser to parse its list of domain entries.
  55. ///
  56. /// A DdnsDomainLiatParser creates and invokes DdnsDomainListParser for each
  57. /// domain entry in its list.
  58. ///
  59. /// A DdnsDomainParser handles the scalars which belong to the domain as well as
  60. /// creating and invoking a DnsSeverInfoListParser to parse its list of server
  61. /// entries.
  62. ///
  63. /// A DnsServerInfoListParser creates and invokes a DnsServerInfoParser for
  64. /// each server entry in its list.
  65. ///
  66. /// A DdnsServerInfoParser handles the scalars which belong to the server.
  67. /// @brief Exception thrown when the error during configuration handling
  68. /// occurs.
  69. class D2CfgError : public isc::Exception {
  70. public:
  71. D2CfgError(const char* file, size_t line, const char* what) :
  72. isc::Exception(file, line, what) { };
  73. };
  74. /// @brief Represents a specific DNS Server.
  75. /// It provides information about the server's network identity and typically
  76. /// belongs to a list of servers supporting DNS for a given domain. It will
  77. /// be used to establish communications with the server to carry out DNS
  78. /// updates.
  79. class DnsServerInfo {
  80. public:
  81. /// @brief defines DNS standard port value
  82. static const uint32_t standard_dns_port;
  83. /// @brief defines an "empty" string version of an ip address.
  84. static const char* empty_ip_str;
  85. /// @brief Constructor
  86. ///
  87. /// @param hostname is the resolvable name of the server. If not blank,
  88. /// then the server address should be resolved at runtime.
  89. /// @param ip_address is the static IP address of the server. If hostname
  90. /// is blank, then this address should be used to connect to the server.
  91. /// @param port is the port number on which the server listens.
  92. /// primarily meant for testing purposes. Normally, DNS traffic is on
  93. /// is port 53. (NOTE the constructing code is responsible for setting
  94. /// the default.)
  95. /// @param enabled is a flag that indicates whether this server is
  96. /// enabled for use. It defaults to true.
  97. DnsServerInfo(const std::string& hostname,
  98. isc::asiolink::IOAddress ip_address, uint32_t port,
  99. bool enabled=true);
  100. /// @brief Destructor
  101. virtual ~DnsServerInfo();
  102. /// @brief Getter which returns the server's hostname.
  103. ///
  104. /// @return returns the hostname as as std::string.
  105. const std::string getHostname() const {
  106. return (hostname_);
  107. }
  108. /// @brief Getter which returns the server's port number.
  109. ///
  110. /// @return returns the port number as a unsigned integer.
  111. uint32_t getPort() const {
  112. return (port_);
  113. }
  114. /// @brief Getter which returns the server's ip_address.
  115. ///
  116. /// @return returns the address as an IOAddress reference.
  117. const isc::asiolink::IOAddress& getIpAddress() const {
  118. return (ip_address_);
  119. }
  120. /// @brief Convenience method which returns whether or not the
  121. /// server is enabled.
  122. ///
  123. /// @return returns true if the server is enabled, false otherwise.
  124. bool isEnabled() const {
  125. return (enabled_);
  126. }
  127. /// @brief Sets the server's enabled flag to true.
  128. void enable() {
  129. enabled_ = true;
  130. }
  131. /// @brief Sets the server's enabled flag to false.
  132. void disable() {
  133. enabled_ = false;
  134. }
  135. private:
  136. /// @brief The resolvable name of the server. If not blank, then the
  137. /// server's IP address should be dynamically resolved at runtime.
  138. std::string hostname_;
  139. /// @brief The static IP address of the server. When hostname is blank,
  140. /// then this address should be used to connect to the server.
  141. isc::asiolink::IOAddress ip_address_;
  142. /// @brief The port number on which the server listens for DNS traffic.
  143. uint32_t port_;
  144. /// @param enabled is a flag that indicates whether this server is
  145. /// enabled for use. It defaults to true.
  146. bool enabled_;
  147. };
  148. /// @brief Defines a pointer for DnsServerInfo instances.
  149. typedef boost::shared_ptr<DnsServerInfo> DnsServerInfoPtr;
  150. /// @brief Defines a storage container for DnsServerInfo pointers.
  151. typedef std::vector<DnsServerInfoPtr> DnsServerInfoStorage;
  152. /// @brief Defines a pointer to DnsServerInfo storage containers.
  153. typedef boost::shared_ptr<DnsServerInfoStorage> DnsServerInfoStoragePtr;
  154. /// @brief Represents a DNS domain that is may be updated dynamically.
  155. /// This class specifies a DNS domain and the list of DNS servers that support
  156. /// it. It's primary use is to map a domain to the DNS server(s) responsible
  157. /// for it.
  158. class DdnsDomain {
  159. public:
  160. /// @brief Constructor
  161. ///
  162. /// @param name is the domain name of the domain.
  163. /// @param key_name is the TSIG key name for use with this domain.
  164. /// (@TODO TSIG is not yet functional).
  165. /// @param servers is the list of server(s) supporting this domain.
  166. DdnsDomain(const std::string& name, const std::string& key_name,
  167. DnsServerInfoStoragePtr servers);
  168. /// @brief Destructor
  169. virtual ~DdnsDomain();
  170. /// @brief Getter which returns the domain's name.
  171. ///
  172. /// @return returns the name in an std::string.
  173. const std::string getName() const {
  174. return (name_);
  175. }
  176. /// @brief Getter which returns the domain's TSIG key name.
  177. ///
  178. /// @return returns the key name in an std::string.
  179. const std::string getKeyName() const {
  180. return (key_name_);
  181. }
  182. /// @brief Getter which returns the domain's list of servers.
  183. ///
  184. /// @return returns the pointer to the server storage.
  185. const DnsServerInfoStoragePtr& getServers() {
  186. return (servers_);
  187. }
  188. private:
  189. /// @brief The domain name of the domain.
  190. std::string name_;
  191. /// @brief The name of the TSIG key for use with this domain.
  192. /// @TODO TSIG is not yet functional).
  193. std::string key_name_;
  194. /// @brief The list of server(s) supporting this domain.
  195. DnsServerInfoStoragePtr servers_;
  196. };
  197. /// @brief Defines a pointer for DdnsDomain instances.
  198. typedef boost::shared_ptr<DdnsDomain> DdnsDomainPtr;
  199. /// @brief Defines a storage container for DdnsDomain pointers.
  200. typedef std::map<std::string, DdnsDomainPtr> DdnsDomainStorage;
  201. /// @brief Defines a pointer to DdnsDomain storage containers.
  202. typedef boost::shared_ptr<DdnsDomainStorage> DdnsDomainStoragePtr;
  203. /// @brief Defines a domain and domain key pair for iterating.
  204. typedef std::pair<std::string, DdnsDomainPtr> DdnsDomainPtrPair;
  205. /// @brief Provides storage for and management of a list of DNS domains.
  206. /// In addition to housing the domain list storage, it provides domain matching
  207. /// services. These services are used to match a FQDN to a domain. Currently
  208. /// it supports a single matching service, which will return the matching
  209. /// domain or a wild card domain if one is specified. The wild card domain is
  210. /// specified as a domain whose name is "*".
  211. /// As matching capabilities evolve this class is expected to expand.
  212. class DdnsDomainListMgr {
  213. public:
  214. /// @brief Constructor
  215. ///
  216. /// @param name is an arbitrary label assigned to this manager.
  217. DdnsDomainListMgr(const std::string& name);
  218. /// @brief Destructor
  219. virtual ~DdnsDomainListMgr ();
  220. /// @brief Matches a given name to a domain based on a longest match
  221. /// scheme.
  222. ///
  223. /// Given a FQDN, search the list of domains, successively removing a
  224. /// sub-domain from the FQDN until a match is found. If no match is found
  225. /// and the wild card domain is present in the list, then return it as the
  226. /// match. If the wild card domain is the only domain in the list, then
  227. /// the it will be returned immediately for any FQDN.
  228. ///
  229. /// @param fqdn is the name for which to look.
  230. /// @param domain receives the matching domain. Note that it will be reset
  231. /// upon entry and only set if a match is subsequently found.
  232. ///
  233. /// @return returns true if a match is found, false otherwise.
  234. virtual bool matchDomain(const std::string& fqdn, DdnsDomainPtr& domain);
  235. /// @brief Fetches the manager's name.
  236. ///
  237. /// @return returns a std::string containing the name of the manager.
  238. const std::string getName() const {
  239. return (name_);
  240. }
  241. /// @brief Returns the number of domains in the domain list.
  242. ///
  243. /// @brief returns an unsigned int containing the domain count.
  244. uint32_t size() const {
  245. return (domains_->size());
  246. }
  247. /// @brief Fetches the wild card domain.
  248. ///
  249. /// @return returns a pointer reference to the domain. The pointer will
  250. /// empty if the wild card domain is not present.
  251. const DdnsDomainPtr& getWildcardDomain() {
  252. return (wildcard_domain_);
  253. }
  254. /// @brief Fetches the domain list.
  255. ///
  256. /// @return returns a pointer reference to the list of domains.
  257. const DdnsDomainStoragePtr &getDomains() {
  258. return (domains_);
  259. }
  260. /// @brief Sets the manger's domain list to the given list of domains.
  261. /// This method will scan the inbound list for the wild card domain and
  262. /// set the internal wild card domain pointer accordingly.
  263. void setDomains(DdnsDomainStoragePtr domains);
  264. private:
  265. /// @brief An arbitrary label assigned to this manager.
  266. std::string name_;
  267. /// @brief Storage for the list of domains.
  268. DdnsDomainStoragePtr domains_;
  269. /// @brief Pointer to the wild card domain.
  270. DdnsDomainPtr wildcard_domain_;
  271. };
  272. /// @brief Defines a pointer for DdnsDomain instances.
  273. typedef boost::shared_ptr<DdnsDomainListMgr> DdnsDomainListMgrPtr;
  274. /// @brief Storage container for scalar configuration parameters.
  275. /// This class is useful for implementing parsers for more complex configuration
  276. /// elements (e.g. those of item type "map"). It provides a convenient way to
  277. /// add storage to the parser for an arbitrary number and variety of simple
  278. /// configuration items (e.g. ints, bools, strings...) without explicitly adding
  279. /// storage for each individual type needed by the parser.
  280. class DScalarContext : public DCfgContextBase {
  281. public:
  282. /// @brief Constructor
  283. DScalarContext() {
  284. };
  285. /// @brief Destructor
  286. virtual ~DScalarContext() {
  287. }
  288. /// @brief Creates a clone of a DStubContext.
  289. ///
  290. /// @return returns a raw pointer to the new clone.
  291. virtual DScalarContext* clone() {
  292. return (new DScalarContext(*this));
  293. }
  294. protected:
  295. /// @brief Copy constructor
  296. DScalarContext(const DScalarContext& rhs) : DCfgContextBase(rhs){
  297. }
  298. private:
  299. /// @brief Private assignment operator, not implemented.
  300. DScalarContext& operator=(const DScalarContext& rhs);
  301. };
  302. /// @brief Parser for DnsServerInfo
  303. ///
  304. /// This class parses the configuration element "dns_server" defined in
  305. /// src/bin/d2/dhcp-ddns.spec and creates an instance of a DnsServerInfo.
  306. class DnsServerInfoParser : public isc::dhcp::DhcpConfigParser {
  307. public:
  308. /// @brief Constructor
  309. ///
  310. /// @param entry_name is an arbitrary label assigned to this configuration
  311. /// definition. Since servers are specified in a list this value is likely
  312. /// be something akin to "server:0", set during parsing.
  313. /// @param servers is a pointer to the storage area to which the parser
  314. /// should commit the newly created DnsServerInfo instance.
  315. DnsServerInfoParser(const std::string& entry_name,
  316. DnsServerInfoStoragePtr servers);
  317. /// @brief Destructor
  318. virtual ~DnsServerInfoParser();
  319. /// @brief Performs the actual parsing of the given "dns_server" element.
  320. /// The results of the parsing are retained internally for use during
  321. /// commit.
  322. ///
  323. /// @param server_config is the "dns_server" configuration to parse
  324. virtual void build(isc::data::ConstElementPtr server_config);
  325. /// @brief Creates a parser for the given "dns_server" member element id.
  326. ///
  327. /// The server elements currently supported are(see dhcp-ddns.spec):
  328. /// 1. hostname
  329. /// 2. ip_address
  330. /// 3. port
  331. ///
  332. /// @param config_id is the "item_name" for a specific member element of
  333. /// the "dns_server" specification.
  334. ///
  335. /// @return returns a pointer to newly created parser.
  336. virtual isc::dhcp::ParserPtr createConfigParser(const std::string&
  337. config_id);
  338. /// @brief Instantiates a DnsServerInfo from internal data values
  339. /// saves it to the storage area pointed to by servers_.
  340. virtual void commit();
  341. private:
  342. /// @brief Arbitrary label assigned to this parser instance.
  343. /// Since servers are specified in a list this value is likely be something
  344. /// akin to "server:0", set during parsing. Primarily here for diagnostics.
  345. std::string entry_name_;
  346. /// @brief Pointer to the storage area to which the parser should commit
  347. /// the newly created DnsServerInfo instance. This is given to us as a
  348. /// constructor argument by an upper level.
  349. DnsServerInfoStoragePtr servers_;
  350. /// @brief Local storage area for scalar parameter values. Use to hold
  351. /// data until time to commit.
  352. DScalarContext local_scalars_;
  353. };
  354. /// @brief Parser for a list of DnsServerInfos
  355. ///
  356. /// This class parses a list of "dns_server" configuration elements.
  357. /// (see src/bin/d2/dhcp-ddns.spec). The DnsServerInfo instances are added
  358. /// to the given storage upon commit.
  359. class DnsServerInfoListParser : public isc::dhcp::DhcpConfigParser {
  360. public:
  361. /// @brief Constructor
  362. ///
  363. /// @param list_name is an arbitrary label assigned to this parser instance.
  364. /// @param servers is a pointer to the storage area to which the parser
  365. /// should commit the newly created DnsServerInfo instance.
  366. DnsServerInfoListParser(const std::string& list_name,
  367. DnsServerInfoStoragePtr servers_);
  368. /// @brief Destructor
  369. virtual ~DnsServerInfoListParser();
  370. /// @brief Performs the actual parsing of the given list "dns_server"
  371. /// elements.
  372. /// It iterates over each server entry in the list:
  373. /// 1. Instantiate a DnsServerInfoParser for the entry
  374. /// 2. Pass the element configuration to the parser's build method
  375. /// 3. Add the parser instance to local storage
  376. ///
  377. /// The net effect is to parse all of the server entries in the list
  378. /// prepping them for commit.
  379. ///
  380. /// @param server_list_config is the list of "dns_server" elements to parse.
  381. virtual void build(isc::data::ConstElementPtr server_list_config);
  382. /// @brief Iterates over the internal list of DnsServerInfoParsers,
  383. /// invoking commit on each. This causes each parser to instantiate a
  384. /// DnsServerInfo from its internal data values and add that that server
  385. /// instance to the storage area, servers_.
  386. virtual void commit();
  387. private:
  388. /// @brief Arbitrary label assigned to this parser instance.
  389. std::string list_name_;
  390. /// @brief Pointer to the storage area to which the parser should commit
  391. /// the list of newly created DnsServerInfo instances. This is given to us
  392. /// as a constructor argument by an upper level.
  393. DnsServerInfoStoragePtr servers_;
  394. /// @brief Local storage of DnsServerInfoParser instances
  395. isc::dhcp::ParserCollection parsers_;
  396. };
  397. /// @brief Parser for DdnsDomain
  398. ///
  399. /// This class parses the configuration element "ddns_domain" defined in
  400. /// src/bin/d2/dhcp-ddns.spec and creates an instance of a DdnsDomain.
  401. class DdnsDomainParser : public isc::dhcp::DhcpConfigParser {
  402. public:
  403. /// @brief Constructor
  404. ///
  405. /// @param entry_name is an arbitrary label assigned to this configuration
  406. /// definition. Since domains are specified in a list this value is likely
  407. /// be something akin to "forward_ddns:0", set during parsing.
  408. /// @param domains is a pointer to the storage area to which the parser
  409. /// should commit the newly created DdnsDomain instance.
  410. DdnsDomainParser(const std::string& entry_name,
  411. DdnsDomainStoragePtr domains);
  412. /// @brief Destructor
  413. virtual ~DdnsDomainParser();
  414. /// @brief Performs the actual parsing of the given "ddns_domain" element.
  415. /// The results of the parsing are retained internally for use during
  416. /// commit.
  417. ///
  418. /// @param server_config is the "ddns_domain" configuration to parse
  419. virtual void build(isc::data::ConstElementPtr domain_config);
  420. /// @brief Creates a parser for the given "ddns_domain" member element id.
  421. ///
  422. /// The domain elements currently supported are(see dhcp-ddns.spec):
  423. /// 1. name
  424. /// 2. key_name
  425. /// 3. dns_servers
  426. ///
  427. /// @param config_id is the "item_name" for a specific member element of
  428. /// the "ddns_domain" specification.
  429. ///
  430. /// @return returns a pointer to newly created parser.
  431. virtual isc::dhcp::ParserPtr createConfigParser(const std::string&
  432. config_id);
  433. /// @brief Instantiates a DdnsDomain from internal data values
  434. /// saves it to the storage area pointed to by domains_.
  435. virtual void commit();
  436. private:
  437. /// @brief Arbitrary label assigned to this parser instance.
  438. std::string entry_name_;
  439. /// @brief Pointer to the storage area to which the parser should commit
  440. /// the newly created DdnsDomain instance. This is given to us as a
  441. /// constructor argument by an upper level.
  442. DdnsDomainStoragePtr domains_;
  443. /// @brief Local storage for DnsServerInfo instances. This is passed into
  444. /// DnsServerInfoListParser(s), which in turn passes it into each
  445. /// DnsServerInfoParser. When the DnsServerInfoParsers "commit" they add
  446. /// their server instance to this storage.
  447. DnsServerInfoStoragePtr local_servers_;
  448. /// @brief Local storage area for scalar parameter values. Use to hold
  449. /// data until time to commit.
  450. DScalarContext local_scalars_;
  451. };
  452. /// @brief Parser for a list of DdnsDomains
  453. ///
  454. /// This class parses a list of "ddns_domain" configuration elements.
  455. /// (see src/bin/d2/dhcp-ddns.spec). The DdnsDomain instances are added
  456. /// to the given storage upon commit.
  457. class DdnsDomainListParser : public isc::dhcp::DhcpConfigParser {
  458. public:
  459. /// @brief Constructor
  460. ///
  461. /// @param list_name is an arbitrary label assigned to this parser instance.
  462. /// @param domains is a pointer to the storage area to which the parser
  463. /// should commit the newly created DdnsDomain instance.
  464. DdnsDomainListParser(const std::string& list_name,
  465. DdnsDomainStoragePtr domains_);
  466. /// @brief Destructor
  467. virtual ~DdnsDomainListParser();
  468. /// @brief Performs the actual parsing of the given list "ddns_domain"
  469. /// elements.
  470. /// It iterates over each server entry in the list:
  471. /// 1. Instantiate a DdnsDomainParser for the entry
  472. /// 2. Pass the element configuration to the parser's build method
  473. /// 3. Add the parser instance to local storage
  474. ///
  475. /// The net effect is to parse all of the domain entries in the list
  476. /// prepping them for commit.
  477. ///
  478. /// @param domain_list_config is the list of "ddns_domain" elements to
  479. /// parse.
  480. virtual void build(isc::data::ConstElementPtr domain_list_config);
  481. /// @brief Iterates over the internal list of DdnsDomainParsers, invoking
  482. /// commit on each. This causes each parser to instantiate a DdnsDomain
  483. /// from its internal data values and add that domain instance to the
  484. /// storage area, domains_.
  485. virtual void commit();
  486. private:
  487. /// @brief Arbitrary label assigned to this parser instance.
  488. std::string list_name_;
  489. /// @brief Pointer to the storage area to which the parser should commit
  490. /// the list of newly created DdnsDomain instances. This is given to us
  491. /// as a constructor argument by an upper level.
  492. DdnsDomainStoragePtr domains_;
  493. /// @brief Local storage of DdnsDomainParser instances
  494. isc::dhcp::ParserCollection parsers_;
  495. };
  496. /// @brief Parser for DdnsDomainListMgr
  497. ///
  498. /// This class parses the configuration elements "forward_ddns" and
  499. /// "reverse_ddns" as defined in src/bin/d2/dhcp-ddns.spec. It populates the
  500. /// given DdnsDomainListMgr with parsed information upon commit. Note that
  501. /// unlike other parsers, this parser does NOT instantiate the final object
  502. /// during the commit phase, it populates it. It must pre-exist.
  503. class DdnsDomainListMgrParser : public isc::dhcp::DhcpConfigParser {
  504. public:
  505. /// @brief Constructor
  506. ///
  507. /// @param entry_name is an arbitrary label assigned to this configuration
  508. /// definition.
  509. /// @param mgr is a pointer to the DdnsDomainListMgr to populate.
  510. /// @throw throws D2CfgError if mgr pointer is empty.
  511. DdnsDomainListMgrParser(const std::string& entry_name,
  512. DdnsDomainListMgrPtr& mgr);
  513. /// @brief Destructor
  514. virtual ~DdnsDomainListMgrParser();
  515. /// @brief Performs the actual parsing of the given manager element.
  516. /// The results of the parsing are retained internally for use during
  517. /// commit.
  518. ///
  519. /// @param mgr_config is the manager configuration to parse
  520. virtual void build(isc::data::ConstElementPtr mgr_config);
  521. /// @brief Creates a parser for the given manager member element id.
  522. ///
  523. ///
  524. /// The manager elements currently supported are (see dhcp-ddns.spec):
  525. /// 1. ddns_domains
  526. ///
  527. /// @param config_id is the "item_name" for a specific member element of
  528. /// the manager specification.
  529. ///
  530. /// @return returns a pointer to newly created parser.
  531. virtual isc::dhcp::ParserPtr createConfigParser(const std::string&
  532. config_id);
  533. /// @brief Populates the DdnsDomainListMgr from internal data values
  534. /// set during parsing.
  535. virtual void commit();
  536. private:
  537. /// @brief Arbitrary label assigned to this parser instance.
  538. std::string entry_name_;
  539. /// @brief Pointer to manager instance to which the parser should commit
  540. /// the parsed data. This is given to us as a constructor argument by an
  541. /// upper level.
  542. DdnsDomainListMgrPtr mgr_;
  543. /// @brief Local storage for DdnsDomain instances. This is passed into a
  544. /// DdnsDomainListParser(s), which in turn passes it into each
  545. /// DdnsDomainParser. When the DdnsDomainParsers "commit" they add their
  546. /// domain instance to this storage.
  547. DdnsDomainStoragePtr local_domains_;
  548. /// @brief Local storage area for scalar parameter values. Use to hold
  549. /// data until time to commit.
  550. /// @TODO Currently, the manager has no scalars but this is likely to
  551. /// change as matching capabilities expand.
  552. DScalarContext local_scalars_;
  553. };
  554. }; // end of isc::d2 namespace
  555. }; // end of isc namespace
  556. #endif // D2_CONFIG_H