26 SrvConfig::SrvConfig()
27 : sequence_(0), cfg_iface_(new
CfgIface()),
38 decline_timer_(0), echo_v4_client_id_(true), dhcp4o6_port_(0),
40 configured_globals_(
Element::createMap()),
46 : sequence_(sequence), cfg_iface_(new
CfgIface()),
57 decline_timer_(0), echo_v4_client_id_(true), dhcp4o6_port_(0),
59 configured_globals_(
Element::createMap()),
70 if (subnets_num > 0) {
71 s <<
"added IPv4 subnets: " << subnets_num;
73 s <<
"no IPv4 subnets!";
80 if (subnets_num > 0) {
81 s <<
"added IPv6 subnets: " << subnets_num;
83 s <<
"no IPv6 subnets!";
90 s <<
"DDNS: " << (ddns_enabled ?
"enabled" :
"disabled") <<
"; ";
93 if (s.tellp() == static_cast<std::streampos>(0)) {
94 s <<
"no config details available";
97 std::string summary = s.str();
98 size_t last_separator_pos = summary.find_last_of(
";");
99 if (last_separator_pos == summary.length() - 2) {
100 summary.erase(last_separator_pos);
115 new_config.cfg_iface_.reset(
new CfgIface(*cfg_iface_));
117 cfg_option_def_->copyTo(*new_config.cfg_option_def_);
118 cfg_option_->copyTo(*new_config.cfg_option_);
124 new_config.hooks_config_.
clear();
126 for (HookLibsCollection::const_iterator it =
127 hooks_config_.get().begin();
128 it != hooks_config_.get().end(); ++it) {
129 new_config.hooks_config_.
add(it->first, it->second);
137 if (!ConfigBase::equals(other)) {
142 if ((*cfg_iface_ != *other.cfg_iface_) ||
143 (*cfg_option_def_ != *other.cfg_option_def_) ||
144 (*cfg_option_ != *other.cfg_option_) ||
145 (*class_dictionary_ != *other.class_dictionary_) ||
146 (*d2_client_config_ != *other.d2_client_config_)) {
152 if (hooks_config_.
get().size() != other.hooks_config_.
get().size()) {
156 return (hooks_config_.
equal(other.hooks_config_));
185 if (config->getType() != Element::map) {
189 const std::map<std::string, ConstElementPtr>& values = config->mapValue();
190 for (
auto value = values.begin(); value != values.end(); ++value) {
191 if (value->second->getType() != Element::list &&
192 value->second->getType() != Element::map) {
209 dhcp->setValue(configured_globals_->mapValue());
215 dhcp->set(
"decline-probation-period",
216 Element::create(static_cast<long long>(decline_timer_)));
218 if (family == AF_INET) {
219 dhcp->set(
"echo-client-id", Element::create(echo_v4_client_id_));
222 dhcp->set(
"dhcp4o6-port",
223 Element::create(static_cast<int>(dhcp4o6_port_)));
226 dhcp->set(
"dhcp-ddns", d2_client_config_->toElement());
228 dhcp->set(
"interfaces-config", cfg_iface_->toElement());
230 dhcp->set(
"option-def", cfg_option_def_->toElement());
232 dhcp->set(
"option-data", cfg_option_->toElement());
245 std::vector<ElementPtr> sn_list;
247 if (family == AF_INET) {
249 ElementPtr plain_subnets = Element::createList();
251 for (Subnet4Collection::const_iterator subnet = subnets->cbegin();
252 subnet != subnets->cend(); ++subnet) {
255 (*subnet)->getSharedNetwork(network);
259 ElementPtr subnet_cfg = (*subnet)->toElement();
260 sn_list.push_back(subnet_cfg);
261 plain_subnets->add(subnet_cfg);
263 dhcp->set(
"subnet4", plain_subnets);
266 ElementPtr shared_networks = cfg_shared_networks4_->toElement();
267 dhcp->set(
"shared-networks", shared_networks);
270 const std::vector<ElementPtr> networks = shared_networks->listValue();
271 for (
auto network = networks.cbegin();
272 network != networks.cend(); ++network) {
273 const std::vector<ElementPtr> sh_list =
274 (*network)->get(
"subnet4")->listValue();
275 for (
auto subnet = sh_list.cbegin();
276 subnet != sh_list.cend(); ++subnet) {
277 sn_list.push_back(*subnet);
283 ElementPtr plain_subnets = Element::createList();
285 for (Subnet6Collection::const_iterator subnet = subnets->cbegin();
286 subnet != subnets->cend(); ++subnet) {
289 (*subnet)->getSharedNetwork(network);
293 ElementPtr subnet_cfg = (*subnet)->toElement();
294 sn_list.push_back(subnet_cfg);
295 plain_subnets->add(subnet_cfg);
297 dhcp->set(
"subnet6", plain_subnets);
300 ElementPtr shared_networks = cfg_shared_networks6_->toElement();
301 dhcp->set(
"shared-networks", shared_networks);
304 const std::vector<ElementPtr> networks = shared_networks->listValue();
305 for (
auto network = networks.cbegin();
306 network != networks.cend(); ++network) {
307 const std::vector<ElementPtr> sh_list =
308 (*network)->get(
"subnet6")->listValue();
309 for (
auto subnet = sh_list.cbegin();
310 subnet != sh_list.cend(); ++subnet) {
311 sn_list.push_back(*subnet);
322 if (global_resvs->size() > 0) {
323 dhcp->set(
"reservations", global_resvs);
327 for (std::vector<ElementPtr>::const_iterator subnet = sn_list.cbegin();
328 subnet != sn_list.cend(); ++subnet) {
333 SubnetID subnet_id =
id->intValue();
335 (*subnet)->set(
"reservations", resvs);
340 dhcp->set(
"expired-leases-processing", expired);
341 if (family == AF_INET6) {
343 dhcp->set(
"server-id", cfg_duid_->toElement());
346 dhcp->set(
"relay-supplied-options", cfg_rsoo_->toElement());
350 dhcp->set(
"lease-database", lease_db.
toElement());
354 if (hosts_databases->size() > 0) {
355 dhcp->set(
"hosts-databases", hosts_databases);
359 if (family == AF_INET) {
360 host_ids = cfg_host_operations4_->toElement();
362 host_ids = cfg_host_operations6_->toElement();
364 dhcp->set(
"host-reservation-identifiers", host_ids);
366 if (family == AF_INET6) {
367 dhcp->set(
"mac-sources", cfg_mac_source_.
toElement());
370 if (!
isNull(control_socket_)) {
371 dhcp->set(
"control-socket", UserContext::toElement(control_socket_));
376 if (!client_classes->empty()) {
377 dhcp->set(
"client-classes", client_classes);
381 dhcp->set(
"hooks-libraries", hooks_libs);
383 result->set(family == AF_INET ?
"Dhcp4" :
"Dhcp6", dhcp);
386 dhcp->set(
"sanity-checks", cfg_consist);
392 dhcp->set(
"config-control", info_elem);
397 if (dhcp_queue_control) {
398 dhcp->set(
"dhcp-queue-control", dhcp_queue_control);
Represents configuration of the RSOO options for the DHCP server.
D2ClientConfigPtr getD2ClientConfig()
Returns pointer to the D2 client configuration.
void internalize(isc::data::ConstElementPtr list)
Internalize a list Element.
uint32_t getSequence() const
Returns configuration sequence number.
SrvConfig()
Default constructor.
Utility class to represent host reservation configurations internally as a map keyed by subnet IDs,...
Holds subnets configured for the DHCPv6 server.
boost::multi_index_container< Subnet6Ptr, boost::multi_index::indexed_by< boost::multi_index::random_access< boost::multi_index::tag< SubnetRandomAccessIndexTag > >, boost::multi_index::ordered_unique< boost::multi_index::tag< SubnetSubnetIdIndexTag >, boost::multi_index::const_mem_fun< Subnet, SubnetID, &Subnet::getID > >, boost::multi_index::ordered_unique< boost::multi_index::tag< SubnetPrefixIndexTag >, boost::multi_index::const_mem_fun< Subnet, std::string, &Subnet::toText > > >> Subnet6Collection
A collection of Subnet6 objects.
Represents configuration of IPv4 shared networks.
static CfgMgr & instance()
returns a single instance of Configuration Manager
void removeStatistics()
Removes statistics.
boost::shared_ptr< Element > ElementPtr
CfgSubnets6Ptr getCfgSubnets6()
Returns pointer to non-const object holding subnets configuration for DHCPv6.
Holds configuration parameters pertaining to lease expiration and lease affinity.
bool isNull(ConstElementPtr p)
Checks whether the given ElementPtr is a NULL pointer.
void updateStatistics()
Updates statistics.
const isc::data::ConstElementPtr getDHCPQueueControl() const
Returns DHCP queue control information.
Maintains a list of ClientClassDef's.
process::ConstConfigControlInfoPtr getConfigControlInfo() const
Fetches a read-only copy of the configuration control information.
void clear()
Removes all configured hooks libraries.
std::string getConfigSummary(const uint32_t selection) const
Returns summary of the configuration in the textual format.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
Parameters for various consistency checks.
Represents option data configuration for the DHCP server.
ElementPtr copy(ConstElementPtr from, int level)
Copy the data up to a nesting level.
virtual isc::data::ElementPtr toElement() const
Unparse.
virtual isc::data::ElementPtr toElement() const
Unparse a configuration object.
Acts as a storage vault for D2 client configuration.
uint16_t getFamily() const
Returns address family.
void addConfiguredGlobal(const std::string &name, isc::data::ConstElementPtr value)
Adds a parameter to the collection configured globals.
boost::shared_ptr< const Element > ConstElementPtr
Represents option definitions used by the DHCP server.
Holds access parameters and the configuration of the lease and hosts database connection.
void contextToElement(data::ElementPtr map) const
Merge unparse a user_context object.
Represents global configuration for host reservations.
Holds subnets configured for the DHCPv4 server.
boost::shared_ptr< SharedNetwork6 > SharedNetwork6Ptr
Pointer to SharedNetwork6 object.
boost::shared_ptr< SharedNetwork4 > SharedNetwork4Ptr
Pointer to SharedNetwork4 object.
utility class for unparsing
Represents configuration of IPv6 shared networks.
Specifies current DHCP configuration.
Defines the logger used by the top-level component of kea-dhcp-ddns.
void add(std::string libname, isc::data::ConstElementPtr parameters)
Adds additional hooks libraries.
bool equals(const SrvConfig &other) const
Compares two objects for equality.
boost::multi_index_container< Subnet4Ptr, boost::multi_index::indexed_by< boost::multi_index::random_access< boost::multi_index::tag< SubnetRandomAccessIndexTag > >, boost::multi_index::ordered_unique< boost::multi_index::tag< SubnetSubnetIdIndexTag >, boost::multi_index::const_mem_fun< Subnet, SubnetID, &Subnet::getID > >, boost::multi_index::ordered_unique< boost::multi_index::tag< SubnetPrefixIndexTag >, boost::multi_index::const_mem_fun< Subnet, std::string, &Subnet::toText > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< SubnetServerIdIndexTag >, boost::multi_index::const_mem_fun< Network4, asiolink::IOAddress, &Network4::getServerId > > >> Subnet4Collection
A collection of Subnet4 objects.
static const uint32_t CFGSEL_SUBNET4
Number of IPv4 subnets.
const isc::hooks::HookLibsCollection & get() const
Provides access to the configured hooks libraries.
bool sequenceEquals(const SrvConfig &other)
Compares configuration sequence with other sequence.
void extractConfiguredGlobals(isc::data::ConstElementPtr config)
Saves scalar elements from the global scope of a configuration.
The Element class represents a piece of data, used by the command channel and configuration parts.
Represents the host reservations specified in the configuration file.
static const uint32_t CFGSEL_DDNS
DDNS enabled/disabled.
isc::data::ElementPtr toElement() const
Unparse a configuration object.
static bool haveInstance()
Indicates if the lease manager has been instantiated.
CfgSubnets4Ptr getCfgSubnets4()
Returns pointer to non-const object holding subnets configuration for DHCPv4.
isc::data::ConstElementPtr get(SubnetID id) const
Return the host reservations for a subnet ID.
void copy(SrvConfig &new_config) const
Copies the current configuration to a new configuration.
static const uint32_t CFGSEL_SUBNET6
Number of IPv6 subnets.
virtual isc::data::ElementPtr toElement() const
Unparse.
bool equal(const HooksConfig &other) const
Compares two Hooks Config classes for equality.
Holds manual configuration of the server identifier (DUID).
void setD2ClientConfig(const D2ClientConfigPtr &d2_client_config)
Sets the D2 client configuration.
uint32_t SubnetID
Unique identifier for a subnet (both v4 and v6)
virtual isc::data::ElementPtr toElement() const
Unparse a configuration object.
boost::shared_ptr< const ConfigControlInfo > ConstConfigControlInfoPtr
Defines a pointer to a const ConfigControlInfo.