Kea  1.5.0
srv_config.h
Go to the documentation of this file.
1 // Copyright (C) 2014-2018 Internet Systems Consortium, Inc. ("ISC")
2 //
3 // This Source Code Form is subject to the terms of the Mozilla Public
4 // License, v. 2.0. If a copy of the MPL was not distributed with this
5 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 
7 #ifndef DHCPSRV_CONFIG_H
8 #define DHCPSRV_CONFIG_H
9 
10 #include <cc/cfg_to_element.h>
11 #include <dhcpsrv/cfg_db_access.h>
12 #include <dhcpsrv/cfg_duid.h>
13 #include <dhcpsrv/cfg_expiration.h>
15 #include <dhcpsrv/cfg_hosts.h>
16 #include <dhcpsrv/cfg_iface.h>
17 #include <dhcpsrv/cfg_option.h>
18 #include <dhcpsrv/cfg_option_def.h>
19 #include <dhcpsrv/cfg_rsoo.h>
21 #include <dhcpsrv/cfg_subnets4.h>
22 #include <dhcpsrv/cfg_subnets6.h>
23 #include <dhcpsrv/cfg_mac_source.h>
26 #include <dhcpsrv/d2_client_cfg.h>
27 #include <process/config_base.h>
28 #include <hooks/hooks_config.h>
29 #include <cc/data.h>
30 #include <cc/user_context.h>
31 #include <boost/shared_ptr.hpp>
32 #include <vector>
33 #include <stdint.h>
34 
35 namespace isc {
36 namespace dhcp {
37 
38 class CfgMgr;
39 
40 
45 public:
48 
49  static const uint32_t CFGSEL_NONE = 0x00000000;
52  static const uint32_t CFGSEL_SUBNET4 = 0x00000001;
54  static const uint32_t CFGSEL_SUBNET6 = 0x00000002;
56  static const uint32_t CFGSEL_IFACE4 = 0x00000004;
58  static const uint32_t CFGSEL_IFACE6 = 0x00000008;
60  static const uint32_t CFGSEL_DDNS = 0x00000010;
62  static const uint32_t CFGSEL_SUBNET = 0x00000003;
64  static const uint32_t CFGSEL_GLOBALS = 0x00000020;
66  static const uint32_t CFGSEL_CFG_CTL = 0x00000040;
68  static const uint32_t CFGSEL_ALL4 = 0x00000035;
70  static const uint32_t CFGSEL_ALL6 = 0x0000003A;
72  static const uint32_t CFGSEL_ALL = 0xFFFFFFFF;
74 
78  SrvConfig();
79 
83  SrvConfig(const uint32_t sequence);
84 
103  std::string getConfigSummary(const uint32_t selection) const;
104 
106  uint32_t getSequence() const {
107  return (sequence_);
108  }
109 
120  bool sequenceEquals(const SrvConfig& other);
121 
129  return (cfg_iface_);
130  }
131 
139  return (cfg_iface_);
140  }
141 
150  return (cfg_option_def_);
151  }
152 
161  return (cfg_option_def_);
162  }
163 
171  return (cfg_option_);
172  }
173 
181  return (cfg_option_);
182  }
183 
189  return (cfg_subnets4_);
190  }
191 
198  return (cfg_shared_networks4_);
199  }
200 
207  return (cfg_shared_networks6_);
208  }
209 
215  return (cfg_subnets4_);
216  }
217 
223  return (cfg_subnets6_);
224  }
225 
231  return (cfg_subnets6_);
232  }
233 
239  return (cfg_hosts_);
240  }
241 
247  return (cfg_hosts_);
248  }
249 
256  return (cfg_rsoo_);
257  }
258 
265  return (cfg_rsoo_);
266  }
267 
271  return (cfg_expiration_);
272  }
273 
277  return (cfg_expiration_);
278  }
279 
283  return (cfg_duid_);
284  }
285 
289  return (cfg_duid_);
290  }
291 
295  return (cfg_db_access_);
296  }
297 
301  return (cfg_db_access_);
302  }
303 
307  return (cfg_host_operations4_);
308  }
309 
313  return (cfg_host_operations4_);
314  }
315 
319  return (cfg_host_operations6_);
320  }
321 
325  return (cfg_host_operations6_);
326  }
327 
330  return (cfg_consist_);
331  }
332 
334 
340  return (cfg_mac_source_);
341  }
342 
347  const CfgMACSource& getMACSources() const {
348  return (cfg_mac_source_);
349  }
350 
354  return (control_socket_);
355  }
356 
359  void setControlSocketInfo(const isc::data::ConstElementPtr& control_socket) {
360  control_socket_ = control_socket;
361  }
362 
366  return (dhcp_queue_control_);
367  }
368 
371  void setDHCPQueueControl(const isc::data::ConstElementPtr dhcp_queue_control) {
372  dhcp_queue_control_ = dhcp_queue_control;
373  }
374 
378  return (class_dictionary_);
379  }
380 
384  return (class_dictionary_);
385  }
386 
390  class_dictionary_ = dictionary;
391  }
392 
397  return (hooks_config_);
398  }
399 
404  return (hooks_config_);
405  }
406 
423  void copy(SrvConfig& new_config) const;
424 
427 
428  bool equals(const SrvConfig& other) const;
438 
447  bool nequals(const SrvConfig& other) const {
448  return (!equals(other));
449  }
450 
459  bool operator==(const SrvConfig& other) const {
460  return (equals(other));
461  }
462 
471  bool operator!=(const SrvConfig& other) const {
472  return (nequals(other));
473  }
474 
476 
482  void updateStatistics();
483 
489  void removeStatistics();
490 
497  void setDeclinePeriod(const uint32_t decline_timer) {
498  decline_timer_ = decline_timer;
499  }
500 
505  uint32_t getDeclinePeriod() const {
506  return (decline_timer_);
507  }
508 
515  void setEchoClientId(const bool echo) {
516  echo_v4_client_id_ = echo;
517  }
518 
521  bool getEchoClientId() const {
522  return (echo_v4_client_id_);
523  }
524 
531  void setDhcp4o6Port(uint16_t port) {
532  dhcp4o6_port_ = port;
533  }
534 
539  uint16_t getDhcp4o6Port() {
540  return (dhcp4o6_port_);
541  }
542 
545  return (d2_client_config_);
546  }
547 
550  return (d2_client_config_);
551  }
552 
555  void setD2ClientConfig(const D2ClientConfigPtr& d2_client_config) {
556  d2_client_config_ = d2_client_config;
557  }
558 
561  return (isc::data::ConstElementPtr(configured_globals_));
562  }
563 
566 
570  void addConfiguredGlobal(const std::string& name, isc::data::ConstElementPtr value) {
571  configured_globals_->set(name, value);
572  }
573 
578  void setServerTag(const std::string& server_tag) {
579  server_tag_ = server_tag;
580  }
581 
585  std::string getServerTag() const {
586  return (server_tag_);
587  }
588 
592  virtual isc::data::ElementPtr toElement() const;
593 
594 private:
595 
597  uint32_t sequence_;
598 
603  CfgIfacePtr cfg_iface_;
604 
609  CfgOptionDefPtr cfg_option_def_;
610 
615  CfgOptionPtr cfg_option_;
616 
618  CfgSubnets4Ptr cfg_subnets4_;
619 
621  CfgSubnets6Ptr cfg_subnets6_;
622 
624  CfgSharedNetworks4Ptr cfg_shared_networks4_;
625 
627  CfgSharedNetworks6Ptr cfg_shared_networks6_;
628 
633  CfgHostsPtr cfg_hosts_;
634 
636  CfgMACSource cfg_mac_source_;
637 
642  CfgRSOOPtr cfg_rsoo_;
643 
646  CfgExpirationPtr cfg_expiration_;
647 
649  CfgDUIDPtr cfg_duid_;
650 
653  CfgDbAccessPtr cfg_db_access_;
654 
657  CfgHostOperationsPtr cfg_host_operations4_;
658 
661  CfgHostOperationsPtr cfg_host_operations6_;
662 
664  isc::data::ConstElementPtr control_socket_;
665 
667  isc::data::ConstElementPtr dhcp_queue_control_;
668 
670  ClientClassDictionaryPtr class_dictionary_;
671 
673  isc::hooks::HooksConfig hooks_config_;
674 
679  uint32_t decline_timer_;
680 
682  bool echo_v4_client_id_;
683 
688  uint16_t dhcp4o6_port_;
689 
691  D2ClientConfigPtr d2_client_config_;
692 
694  isc::data::ElementPtr configured_globals_;
695 
697  CfgConsistencyPtr cfg_consist_;
698 
700  std::string server_tag_;
701 };
702 
705 
706 typedef boost::shared_ptr<SrvConfig> SrvConfigPtr;
708 
710 typedef boost::shared_ptr<const SrvConfig> ConstSrvConfigPtr;
712 
713 } // namespace isc::dhcp
714 } // namespace isc
715 
716 #endif // DHCPSRV_CONFIG_H
const isc::data::ConstElementPtr getControlSocketInfo() const
Returns information about control socket.
Definition: srv_config.h:353
Defines the D2ClientConfig class.
D2ClientConfigPtr getD2ClientConfig()
Returns pointer to the D2 client configuration.
Definition: srv_config.h:544
boost::shared_ptr< CfgSharedNetworks6 > CfgSharedNetworks6Ptr
Pointer to the configuration of IPv6 shared networks.
uint32_t getSequence() const
Returns configuration sequence number.
Definition: srv_config.h:106
const CfgMACSource & getMACSources() const
Returns const reference to an array that stores MAC/hardware address sources.
Definition: srv_config.h:347
boost::shared_ptr< CfgOption > CfgOptionPtr
Non-const pointer.
Definition: cfg_option.h:497
ConstCfgRSOOPtr getCfgRSOO() const
Returns pointer to the const object representing set of RSOO-enabled options.
Definition: srv_config.h:264
SrvConfig()
Default constructor.
Definition: srv_config.cc:26
ConstCfgDbAccessPtr getCfgDbAccess() const
Returns const pointer to the object holding configuration of the lease and host database connection p...
Definition: srv_config.h:300
boost::shared_ptr< const CfgOptionDef > ConstCfgOptionDefPtr
Const pointer.
static const uint32_t CFGSEL_IFACE4
Number of enabled ifaces.
Definition: srv_config.h:56
boost::shared_ptr< const CfgOption > ConstCfgOptionPtr
Const pointer.
Definition: cfg_option.h:500
static const uint32_t CFGSEL_CFG_CTL
Config control info.
Definition: srv_config.h:66
isc::data::ConstElementPtr getConfiguredGlobals() const
Returns pointer to configured global parameters.
Definition: srv_config.h:560
CfgConsistencyPtr getConsistency()
Returns const pointer to object holding sanity checks flags.
Definition: srv_config.h:329
Base class for all configurations.
Definition: config_base.h:31
void removeStatistics()
Removes statistics.
Definition: srv_config.cc:160
boost::shared_ptr< SrvConfig > SrvConfigPtr
Non-const pointer to the SrvConfig.
Definition: srv_config.h:707
void setServerTag(const std::string &server_tag)
Sets the server's logical name.
Definition: srv_config.h:578
boost::shared_ptr< const CfgRSOO > ConstCfgRSOOPtr
Pointer to the const object.
Definition: cfg_rsoo.h:74
boost::shared_ptr< const CfgHosts > ConstCfgHostsPtr
Const pointer.
Definition: cfg_hosts.h:485
void setControlSocketInfo(const isc::data::ConstElementPtr &control_socket)
Sets information about the control socket.
Definition: srv_config.h:359
boost::shared_ptr< Element > ElementPtr
Definition: data.h:20
boost::shared_ptr< CfgIface > CfgIfacePtr
A pointer to the CfgIface .
Definition: cfg_iface.h:387
ConstCfgHostsPtr getCfgHosts() const
Returns pointer to the const objects representing host reservations for different IPv4 and IPv6 subne...
Definition: srv_config.h:246
Wrapper class that holds hooks libraries configuration.
Definition: hooks_config.h:36
CfgSubnets6Ptr getCfgSubnets6()
Returns pointer to non-const object holding subnets configuration for DHCPv6.
Definition: srv_config.h:222
boost::shared_ptr< CfgOptionDef > CfgOptionDefPtr
Non-const pointer.
bool nequals(const SrvConfig &other) const
Compares two objects for inequality.
Definition: srv_config.h:447
bool operator!=(const SrvConfig &other) const
Definition: srv_config.h:471
boost::shared_ptr< CfgConsistency > CfgConsistencyPtr
Type used to for pointing to CfgConsistency structure.
void updateStatistics()
Updates statistics.
Definition: srv_config.cc:169
const isc::data::ConstElementPtr getDHCPQueueControl() const
Returns DHCP queue control information.
Definition: srv_config.h:365
boost::shared_ptr< const CfgDUID > ConstCfgDUIDPtr
Pointer to the const object.
Definition: cfg_duid.h:152
uint32_t getDeclinePeriod() const
Returns probation-period.
Definition: srv_config.h:505
boost::shared_ptr< CfgSubnets4 > CfgSubnets4Ptr
Non-const pointer.
Definition: cfg_subnets4.h:270
void setDHCPQueueControl(const isc::data::ConstElementPtr dhcp_queue_control)
Sets information about the dhcp queue control.
Definition: srv_config.h:371
boost::shared_ptr< const CfgSubnets4 > ConstCfgSubnets4Ptr
Const pointer.
Definition: cfg_subnets4.h:273
boost::shared_ptr< CfgExpiration > CfgExpirationPtr
Pointer to the Non-const object.
CfgOptionDefPtr getCfgOptionDef()
Return pointer to non-const object representing user-defined option definitions.
Definition: srv_config.h:149
boost::shared_ptr< const CfgDbAccess > ConstCfgDbAccessPtr
A pointer to the const CfgDbAccess.
std::string getConfigSummary(const uint32_t selection) const
Returns summary of the configuration in the textual format.
Definition: srv_config.cc:65
void setEchoClientId(const bool echo)
Sets whether server should send back client-id in DHCPv4.
Definition: srv_config.h:515
bool getEchoClientId() const
Returns whether server should send back client-id in DHCPv4.
Definition: srv_config.h:521
boost::shared_ptr< CfgSharedNetworks4 > CfgSharedNetworks4Ptr
Pointer to the configuration of IPv4 shared networks.
boost::shared_ptr< const SrvConfig > ConstSrvConfigPtr
Const pointer to the SrvConfig.
Definition: srv_config.h:710
CfgSharedNetworks6Ptr getCfgSharedNetworks6() const
Returns pointer to non-const object holding configuration of shared networks in DHCPv6.
Definition: srv_config.h:206
ConstCfgSubnets6Ptr getCfgSubnets6() const
Returns pointer to const object holding subnets configuration for DHCPv6.
Definition: srv_config.h:230
Wrapper class that holds MAC/hardware address sources.
ConstCfgExpirationPtr getCfgExpiration() const
Returns pointer to the const object holding configuration pertaining to processing expired leases.
Definition: srv_config.h:276
boost::shared_ptr< CfgDbAccess > CfgDbAccessPtr
A pointer to the CfgDbAccess.
void setDeclinePeriod(const uint32_t decline_timer)
Sets decline probation-period.
Definition: srv_config.h:497
const ConstCfgOptionPtr getCfgOption() const
Returns pointer to the const object holding options.
Definition: srv_config.h:180
boost::shared_ptr< const CfgSubnets6 > ConstCfgSubnets6Ptr
Const pointer.
Definition: cfg_subnets6.h:271
const isc::hooks::HooksConfig & getHooksConfig() const
Returns const reference to configured hooks libraries.
Definition: srv_config.h:403
boost::shared_ptr< ClientClassDictionary > ClientClassDictionaryPtr
Defines a pointer to a ClientClassDictionary.
void addConfiguredGlobal(const std::string &name, isc::data::ConstElementPtr value)
Adds a parameter to the collection configured globals.
Definition: srv_config.h:570
boost::shared_ptr< const CfgExpiration > ConstCfgExpirationPtr
Pointer to the const object.
ConstCfgSubnets4Ptr getCfgSubnets4() const
Returns pointer to const object holding subnets configuration for DHCPv4.
Definition: srv_config.h:214
boost::shared_ptr< const Element > ConstElementPtr
Definition: data.h:23
boost::shared_ptr< CfgRSOO > CfgRSOOPtr
Pointer to the Non-const object.
Definition: cfg_rsoo.h:71
CfgDbAccessPtr getCfgDbAccess()
Returns pointer to the object holding configuration of the lease and host database connection paramet...
Definition: srv_config.h:294
boost::shared_ptr< CfgSubnets6 > CfgSubnets6Ptr
Non-const pointer.
Definition: cfg_subnets6.h:268
CfgExpirationPtr getCfgExpiration()
Returns pointer to the object holding configuration pertaining to processing expired leases.
Definition: srv_config.h:270
CfgHostOperationsPtr getCfgHostOperations4()
Returns pointer to the object holding general configuration for host reservations in DHCPv4.
Definition: srv_config.h:306
const D2ClientConfigPtr getD2ClientConfig() const
Returns pointer to const D2 client configuration.
Definition: srv_config.h:549
CfgIfacePtr getCfgIface()
Returns non-const pointer to interface configuration.
Definition: srv_config.h:128
ConstCfgHostOperationsPtr getCfgHostOperations6() const
Returns const pointer to the object holding general configuration for host reservations in DHCPv6.
Definition: srv_config.h:324
static const uint32_t CFGSEL_SUBNET
Number of all subnets.
Definition: srv_config.h:62
Specifies current DHCP configuration.
Definition: srv_config.h:44
static const uint32_t CFGSEL_ALL6
IPv6 related config.
Definition: srv_config.h:70
CfgRSOOPtr getCfgRSOO()
Returns pointer to the non-const object representing set of RSOO-enabled options.
Definition: srv_config.h:255
Defines the logger used by the top-level component of kea-dhcp-ddns.
bool equals(const SrvConfig &other) const
Compares two objects for equality.
Definition: srv_config.cc:134
CfgMACSource & getMACSources()
Returns non-const reference to an array that stores MAC/hardware address sources.
Definition: srv_config.h:339
static const uint32_t CFGSEL_SUBNET4
Number of IPv4 subnets.
Definition: srv_config.h:52
CfgDUIDPtr getCfgDUID()
Returns pointer to the object holding configuration of the server identifier.
Definition: srv_config.h:282
ConstCfgOptionDefPtr getCfgOptionDef() const
Returns pointer to the const object representing user-defined option definitions.
Definition: srv_config.h:160
static const uint32_t CFGSEL_ALL
Whole config.
Definition: srv_config.h:72
void setClientClassDictionary(const ClientClassDictionaryPtr &dictionary)
Sets the client class dictionary.
Definition: srv_config.h:389
bool sequenceEquals(const SrvConfig &other)
Compares configuration sequence with other sequence.
Definition: srv_config.cc:106
void extractConfiguredGlobals(isc::data::ConstElementPtr config)
Saves scalar elements from the global scope of a configuration.
Definition: srv_config.cc:184
isc::hooks::HooksConfig & getHooksConfig()
Returns non-const reference to configured hooks libraries.
Definition: srv_config.h:396
static const uint32_t CFGSEL_DDNS
DDNS enabled/disabled.
Definition: srv_config.h:60
boost::shared_ptr< const CfgIface > ConstCfgIfacePtr
A pointer to the const CfgIface.
Definition: cfg_iface.h:390
ClientClassDictionaryPtr getClientClassDictionary()
Returns pointer to the dictionary of global client class definitions.
Definition: srv_config.h:377
boost::shared_ptr< const CfgHostOperations > ConstCfgHostOperationsPtr
Pointer to the const object.
CfgHostsPtr getCfgHosts()
Returns pointer to the non-const objects representing host reservations for different IPv4 and IPv6 s...
Definition: srv_config.h:238
CfgSubnets4Ptr getCfgSubnets4()
Returns pointer to non-const object holding subnets configuration for DHCPv4.
Definition: srv_config.h:188
static const uint32_t CFGSEL_GLOBALS
Configured globals.
Definition: srv_config.h:64
ConstCfgIfacePtr getCfgIface() const
Returns const pointer to interface configuration.
Definition: srv_config.h:138
void copy(SrvConfig &new_config) const
Copies the current configuration to a new configuration.
Definition: srv_config.cc:111
CfgOptionPtr getCfgOption()
Returns pointer to the non-const object holding options.
Definition: srv_config.h:170
CfgHostOperationsPtr getCfgHostOperations6()
Returns pointer to the object holding general configuration for host reservations in DHCPv6.
Definition: srv_config.h:318
ConstCfgHostOperationsPtr getCfgHostOperations4() const
Returns const pointer to the object holding general configuration for host reservations in DHCPv4.
Definition: srv_config.h:312
static const uint32_t CFGSEL_SUBNET6
Number of IPv6 subnets.
Definition: srv_config.h:54
boost::shared_ptr< CfgDUID > CfgDUIDPtr
Pointer to the Non-const object.
Definition: cfg_duid.h:149
bool operator==(const SrvConfig &other) const
Equality operator.
Definition: srv_config.h:459
CfgSharedNetworks4Ptr getCfgSharedNetworks4() const
Returns pointer to non-const object holding configuration of shared networks in DHCPv4;.
Definition: srv_config.h:197
boost::shared_ptr< D2ClientConfig > D2ClientConfigPtr
Defines a pointer for D2ClientConfig instances.
uint16_t getDhcp4o6Port()
Returns DHCP4o6 IPC port.
Definition: srv_config.h:539
void setDhcp4o6Port(uint16_t port)
Sets DHCP4o6 IPC port.
Definition: srv_config.h:531
Defines classes for storing client class definitions.
void setD2ClientConfig(const D2ClientConfigPtr &d2_client_config)
Sets the D2 client configuration.
Definition: srv_config.h:555
ConstCfgDUIDPtr getCfgDUID() const
Returns const pointer to the object holding configuration of the server identifier.
Definition: srv_config.h:288
static const uint32_t CFGSEL_NONE
Nothing selected.
Definition: srv_config.h:50
boost::shared_ptr< CfgHostOperations > CfgHostOperationsPtr
Pointer to the Non-const object.
std::string getServerTag() const
Returns the server's logical name.
Definition: srv_config.h:585
virtual isc::data::ElementPtr toElement() const
Unparse a configuration object.
Definition: srv_config.cc:199
static const uint32_t CFGSEL_ALL4
IPv4 related config.
Definition: srv_config.h:68
const ClientClassDictionaryPtr getClientClassDictionary() const
Returns pointer to const dictionary of global client class definitions.
Definition: srv_config.h:383
static const uint32_t CFGSEL_IFACE6
Number of v6 ifaces.
Definition: srv_config.h:58
boost::shared_ptr< CfgHosts > CfgHostsPtr
Non-const pointer.
Definition: cfg_hosts.h:482