24#include <boost/multi_index/hashed_index.hpp>
25#include <boost/multi_index/identity.hpp>
26#include <boost/multi_index/indexed_by.hpp>
27#include <boost/multi_index/sequenced_index.hpp>
28#include <boost/multi_index_container.hpp>
29#include <boost/shared_ptr.hpp>
30#include <boost/weak_ptr.hpp>
38template <
typename... Args>
39inline void unused(Args
const& ...) {}
52typedef boost::multi_index_container<
56 boost::multi_index::indexed_by<
58 boost::multi_index::sequenced<
59 boost::multi_index::tag<IOAddressListListTag>
62 boost::multi_index::hashed_unique<
63 boost::multi_index::tag<IOAddressListSetTag>,
64 boost::multi_index::identity<asiolink::IOAddress>
257 if (iface_name.empty()) {
588 ddns_override_client_update) {
613 if (!mode_label.unspecified()) {
634 ddns_replace_client_name_mode) {
716 hostname_char_replacement) {
857 return (
"base-network");
896 template<
typename ReturnType>
898 const int global_index,
899 const int min_index = -1,
900 const int max_index = -1)
const {
901 unused(min_index, max_index);
934 template<
typename NumType>
936 const int global_index,
937 const int min_index = -1,
938 const int max_index = -1)
const {
945 NumType def_value =
static_cast<NumType
>(param->intValue());
946 if ((min_index < 0) || (max_index < 0)) {
949 NumType min_value = def_value;
950 NumType max_value = def_value;
953 min_value =
static_cast<NumType
>(min_param->intValue());
957 max_value =
static_cast<NumType
>(max_param->intValue());
989 const int global_index,
990 const int min_index = -1,
991 const int max_index = -1)
const;
1023 template<
typename BaseType,
typename ReturnType>
1025 ReturnType property,
1027 const int global_index = -1,
1028 const int min_index = -1,
1029 const int max_index = -1) const {
1037 ReturnType parent_property;
1040 auto parent = boost::dynamic_pointer_cast<BaseType>(
parent_network_.lock());
1044 return (parent_property);
1053 if (property.unspecified()) {
1055 auto parent = boost::dynamic_pointer_cast<BaseType>(
parent_network_.lock());
1061 auto parent_property = ((*parent).*MethodPointer)(inheritance);
1062 if (!parent_property.unspecified()) {
1063 return (parent_property);
1098 template<
typename BaseType>
1109 auto parent = boost::dynamic_pointer_cast<BaseType>(parent_network_.lock());
1115 return (parent_property);
1125 auto parent = boost::dynamic_pointer_cast<BaseType>(parent_network_.lock());
1129 OptionPtr parent_property = (((*parent).*MethodPointer)(inheritance));
1130 if (parent_property) {
1131 return (parent_property);
1271 :
Network(), match_client_id_(true, true), authoritative_(),
1272 siaddr_(), sname_(), filename_(), offer_lft_() {
1282 return (getProperty<Network4>(&Network4::getMatchClientId,
1285 CfgGlobals::MATCH_CLIENT_ID));
1294 match_client_id_ = match;
1305 return (getProperty<Network4>(&Network4::getAuthoritative,
1306 authoritative_, inheritance,
1307 CfgGlobals::AUTHORITATIVE));
1316 authoritative_ = authoritative;
1331 return (getProperty<Network4>(&Network4::getSiaddr, siaddr_,
1332 inheritance, CfgGlobals::NEXT_SERVER));
1346 return (getProperty<Network4>(&Network4::getSname, sname_,
1348 CfgGlobals::SERVER_HOSTNAME));
1362 return (getProperty<Network4>(&Network4::getFilename, filename_,
1364 CfgGlobals::BOOT_FILE_NAME));
1371 offer_lft_ = offer_lft;
1380 return (getProperty<Network4>(&Network4::getOfferLft, offer_lft_,
1382 CfgGlobals::OFFER_LIFETIME));
1432 :
Network(), preferred_(), interface_id_(), rapid_commit_(),
1433 default_pd_allocator_type_(){
1442 return (getProperty<Network6>(&Network6::getPreferred, preferred_,
1444 CfgGlobals::PREFERRED_LIFETIME,
1445 CfgGlobals::MIN_PREFERRED_LIFETIME,
1446 CfgGlobals::MAX_PREFERRED_LIFETIME));
1453 preferred_ = preferred;
1461 return (getOptionProperty<Network6>(&Network6::getInterfaceId, interface_id_,
1469 interface_id_ = ifaceid;
1482 return (getProperty<Network6>(&Network6::getRapidCommit, rapid_commit_,
1491 rapid_commit_ = rapid_commit;
1499 return (getProperty<Network6>(&Network6::getPdAllocatorType,
1502 CfgGlobals::PD_ALLOCATOR));
1513 pd_allocator_type_ = allocator_type;
1524 return (getProperty<Network6>(&Network6::getDefaultPdAllocatorType,
1525 default_pd_allocator_type_,
1533 default_pd_allocator_type_ = allocator_type;
Defines elements for storing the names of client classes.
The IOAddress class represents an IP addresses (version agnostic)
Template class for converting a value encapsulated in the Element object into a simple type.
This class represents configuration element which is associated with database identifier,...
@ DDNS_CONFLICT_RESOLUTION_MODE
@ DDNS_OVERRIDE_NO_UPDATE
@ DDNS_OVERRIDE_CLIENT_UPDATE
@ HOSTNAME_CHAR_REPLACEMENT
@ RESERVATIONS_OUT_OF_POOL
@ DDNS_REPLACE_CLIENT_NAME
Represents option data configuration for the DHCP server.
Container for storing client class names.
static ReplaceClientNameMode stringToReplaceClientNameMode(const std::string &mode_str)
Converts labels to ReplaceClientNameMode enum values.
Specialization of the Network object for DHCPv4 case.
util::Optional< std::string > getFilename(const Inheritance &inheritance=Inheritance::ALL) const
Returns boot file name for this subnet.
void setMatchClientId(const util::Optional< bool > &match)
Sets the flag indicating if the client identifier should be used to identify the client's lease.
util::Optional< std::string > getSname(const Inheritance &inheritance=Inheritance::ALL) const
Returns server hostname for this network.
util::Optional< asiolink::IOAddress > getSiaddr(const Inheritance &inheritance=Inheritance::ALL) const
Returns siaddr for this network.
void setAuthoritative(const util::Optional< bool > &authoritative)
Sets the flag indicating if requests for unknown IP addresses should be rejected with DHCPNAK instead...
util::Optional< uint32_t > getOfferLft(const Inheritance &inheritance=Inheritance::ALL) const
Returns offer lifetime for the network.
void setOfferLft(const util::Optional< uint32_t > &offer_lft)
Sets offer lifetime for the network.
util::Optional< bool > getMatchClientId(const Inheritance &inheritance=Inheritance::ALL) const
Returns the flag indicating if the client identifiers should be used to identify the client's lease.
util::Optional< bool > getAuthoritative(const Inheritance &inheritance=Inheritance::ALL) const
Returns the flag indicating if requests for unknown IP addresses should be rejected with DHCPNAK inst...
Specialization of the Network object for DHCPv6 case.
void setRapidCommit(const util::Optional< bool > &rapid_commit)
Enables or disables Rapid Commit option support for the subnet.
void setDefaultPdAllocatorType(const std::string &allocator_type)
Sets a defalt allocator type for prefix delegation.
util::Optional< std::string > getDefaultPdAllocatorType(const Inheritance &inheritance=Inheritance::ALL) const
Returns a default allocator type for prefix delegation.
isc::util::Triplet< uint32_t > getPreferred(const Inheritance &inheritance=Inheritance::ALL) const
Returns preferred lifetime (in seconds)
void setPdAllocatorType(const util::Optional< std::string > &allocator_type)
Sets new allocator type for prefix delegation.
util::Optional< bool > getRapidCommit(const Inheritance &inheritance=Inheritance::ALL) const
Returns boolean value indicating that the Rapid Commit option is supported or unsupported for the sub...
void setInterfaceId(const OptionPtr &ifaceid)
sets interface-id option (if defined)
void setPreferred(const isc::util::Triplet< uint32_t > &preferred)
Sets new preferred lifetime for a network.
OptionPtr getInterfaceId(const Inheritance &inheritance=Inheritance::ALL) const
Returns interface-id value (if specified)
util::Optional< std::string > getPdAllocatorType(const Inheritance &inheritance=Inheritance::ALL) const
Returns allocator type for prefix delegation.
Holds optional information about relay.
const IOAddressList & getAddresses() const
Returns const reference to the list of addresses.
void addAddress(const asiolink::IOAddress &addr)
Adds an address to the list of addresses.
bool containsAddress(const asiolink::IOAddress &addr) const
Checks the address list for the given address.
bool hasAddresses() const
Indicates whether or not the address list has entries.
Common interface representing a network to which the DHCP clients are connected.
virtual bool clientSupported(const isc::dhcp::ClientClasses &client_classes) const
Checks whether this network supports client that belongs to specified classes.
util::Optional< bool > getCalculateTeeTimes(const Inheritance &inheritance=Inheritance::ALL) const
Returns whether or not T1/T2 calculation is enabled.
util::Optional< std::string > getDdnsQualifyingSuffix(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-qualifying-suffix.
isc::util::Triplet< uint32_t > t2_
a isc::util::Triplet (min/default/max) holding allowed rebind timer values
util::Optional< D2ClientConfig::ReplaceClientNameMode > getDdnsReplaceClientNameMode(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-replace-client-name-mode.
void setT2(const isc::util::Triplet< uint32_t > &t2)
Sets new rebind timer for a network.
void addRelayAddress(const asiolink::IOAddress &addr)
Adds an address to the list addresses in the network's relay info.
util::Optional< std::string > hostname_char_replacement_
A string to replace invalid characters when scrubbing hostnames.
RelayInfo relay_
Relay information.
boost::shared_ptr< Network::RelayInfo > RelayInfoPtr
Pointer to the RelayInfo structure.
util::Optional< double > getCacheThreshold(const Inheritance &inheritance=Inheritance::ALL) const
Returns percentage to use as cache threshold.
util::Optional< bool > reservations_out_of_pool_
Enables out-of-pool reservations optimization.
util::Optional< std::string > getHostnameCharReplacement(const Inheritance &inheritance=Inheritance::ALL) const
Return the invalid char replacement used to sanitize client hostnames.
util::Optional< bool > ddns_update_on_renew_
Should Kea perform updates when leases are extended.
util::Optional< std::string > allocator_type_
Allocator used for IP address allocations.
CfgOptionPtr cfg_option_
Pointer to the option data configuration for this subnet.
void setAllocatorType(const util::Optional< std::string > &allocator_type)
Sets new allocator type.
void setDdnsReplaceClientNameMode(const util::Optional< D2ClientConfig::ReplaceClientNameMode > &ddns_replace_client_name_mode)
Sets new ddns-replace-client-name-mode.
const IOAddressList & getRelayAddresses() const
Returns the list of relay addresses from the network's relay info.
ClientClasses & getMutableAdditionalClasses()
Returns the mutable additional classes list.
void setCacheMaxAge(const util::Optional< uint32_t > &cache_max_age)
Sets cache max for a network.
ClientClasses additional_classes_
Additional classes.
util::Optional< double > getDdnsTtlPercent(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-ttl-percent.
void allowClientClass(const isc::dhcp::ClientClass &class_name)
Sets the supported class to class class_name.
Inheritance
Inheritance "mode" used when fetching an optional Network parameter.
void setCacheThreshold(const util::Optional< double > &cache_threshold)
Sets cache threshold for a network.
void setT1Percent(const util::Optional< double > &t1_percent)
Sets new percentage for calculating T1 (renew timer).
util::Optional< bool > reservations_global_
Enables global reservations.
util::Optional< bool > getDdnsOverrideClientUpdate(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-override-client-update.
bool hasFetchGlobalsFn() const
Checks if the network is associated with a function used to fetch globally configured parameters.
util::Optional< bool > ddns_override_client_update_
Should Kea perform updates, even if client requested delegation.
OptionPtr getOptionProperty(OptionPtr(BaseType::*MethodPointer)(const Inheritance &inheritance) const, OptionPtr property, const Inheritance &inheritance) const
Returns option pointer associated with a network using inheritance.
util::Optional< bool > reservations_in_subnet_
Enables subnet reservations.
util::Optional< std::string > getHostnameCharSet(const Inheritance &inheritance=Inheritance::ALL) const
Return the char set regexp used to sanitize client hostnames.
FetchNetworkGlobalsFn getFetchGlobalsFn() const
Gets the optional callback function used to fetch globally configured parameters.
void setReservationsInSubnet(const util::Optional< bool > &reservations_in_subnet)
Sets whether subnet reservations should be fetched.
FetchNetworkGlobalsFn fetch_globals_fn_
Pointer to the optional callback used to fetch globally configured parameters inherited to the Networ...
void setStoreExtendedInfo(const util::Optional< bool > &store_extended_info)
Sets new store-extended-info.
util::Optional< double > t2_percent_
Percentage of the lease lifetime to use when calculating T2 timer.
void setIface(const util::Optional< std::string > &iface_name)
Sets local name of the interface for which this network is selected.
util::Optional< bool > getDdnsUpdateOnRenew(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-update-on-renew.
void setDdnsOverrideClientUpdate(const util::Optional< bool > &ddns_override_client_update)
Sets new ddns-override-client-update.
const RelayInfo & getRelayInfo() const
Returns const reference to relay information.
WeakNetworkPtr parent_network_
Pointer to another network that this network belongs to.
ReturnType getProperty(ReturnType(BaseType::*MethodPointer)(const Inheritance &) const, ReturnType property, const Inheritance &inheritance, const int global_index=-1, const int min_index=-1, const int max_index=-1) const
Returns a value associated with a network using inheritance.
isc::util::Triplet< uint32_t > getT1(const Inheritance &inheritance=Inheritance::ALL) const
Returns T1 (renew timer), expressed in seconds.
util::Optional< bool > getReservationsGlobal(const Inheritance &inheritance=Inheritance::ALL) const
Returns whether global reservations should be fetched.
util::Optional< std::string > ddns_generated_prefix_
Prefix Kea should use when generating domain-names.
util::Optional< double > t1_percent_
Percentage of the lease lifetime to use when calculating T1 timer.
bool hasRelays() const
Indicates if network's relay info has relay addresses.
void setDdnsConflictResolutionMode(const util::Optional< std::string > &ddns_conflict_resolution_mode)
Sets new ib-ddns-conflict-resolution-mode.
util::Optional< bool > getDdnsOverrideNoUpdate(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-override-no-update.
util::Optional< ClientClass > client_class_
Optional definition of a client class.
util::Optional< std::string > getAllocatorType(const Inheritance &inheritance=Inheritance::ALL) const
Returns allocator type.
void setHostnameCharSet(const util::Optional< std::string > &hostname_char_set)
Sets new hostname-char-set.
util::Optional< std::string > getDdnsGeneratedPrefix(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-generated-prefix.
util::Optional< bool > getDdnsSendUpdates(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-send-updates.
virtual data::ElementPtr toElement() const
Unparses network object.
void setReservationsOutOfPool(const util::Optional< bool > &reservations_out_of_pool)
Sets whether only out-of-pool reservations are allowed.
util::Optional< std::string > hostname_char_set_
Regular expression describing invalid characters for client hostnames.
util::Optional< std::string > getDefaultAllocatorType(const Inheritance &inheritance=Inheritance::ALL) const
Returns a default allocator type.
util::Optional< std::string > getDdnsConflictResolutionMode(const Inheritance &inheritance=Inheritance::ALL) const
Returns ib-ddns-conflict-resolution-mode.
void setDdnsGeneratedPrefix(const util::Optional< std::string > &ddns_generated_prefix)
Sets new ddns-generated-prefix.
void setT1(const isc::util::Triplet< uint32_t > &t1)
Sets new renew timer for a network.
bool hasRelayAddress(const asiolink::IOAddress &address) const
Tests if the network's relay info contains the given address.
util::Optional< double > getT2Percent(const Inheritance &inheritance=Inheritance::ALL) const
Returns percentage to use when calculating the T2 (rebind timer).
void addAdditionalClass(const isc::dhcp::ClientClass &class_name)
Adds class class_name to the additional classes list.
util::Optional< std::string > iface_name_
Holds interface name for which this network is selected.
void setFetchGlobalsFn(FetchNetworkGlobalsFn fetch_globals_fn)
Sets the optional callback function used to fetch globally configured parameters.
isc::util::Triplet< uint32_t > getT2(const Inheritance &inheritance=Inheritance::ALL) const
Returns T2 (rebind timer), expressed in seconds.
void setValid(const isc::util::Triplet< uint32_t > &valid)
Sets new valid lifetime for a network.
virtual std::string getLabel() const
Generates an identifying label for logging.
void setT2Percent(const util::Optional< double > &t2_percent)
Sets new percentage for calculating T2 (rebind timer).
isc::util::Triplet< NumType > getGlobalProperty(isc::util::Triplet< NumType > property, const int global_index, const int min_index=-1, const int max_index=-1) const
The getGlobalProperty specialization for isc::util::Triplet<T>.
util::Optional< bool > ddns_send_updates_
Should Kea perform DNS updates.
virtual ~Network()
Virtual destructor.
util::Optional< std::string > ddns_conflict_resolution_mode_
DDNS conflict resolution mode.
util::Optional< bool > store_extended_info_
Should Kea store additional client query data (e.g.
isc::util::Triplet< uint32_t > valid_
a isc::util::Triplet (min/default/max) holding allowed valid lifetime values
ConstCfgOptionPtr getCfgOption() const
Returns const pointer to the option data configuration for this network.
const ClientClasses & getAdditionalClasses() const
Returns the additional classes list.
util::Optional< bool > getReservationsOutOfPool(const Inheritance &inheritance=Inheritance::ALL) const
Returns whether only out-of-pool reservations are allowed.
util::Optional< bool > calculate_tee_times_
Enables calculation of T1 and T2 timers.
util::Optional< uint32_t > cache_max_age_
Value in seconds to use as cache maximal age.
ReturnType getGlobalProperty(ReturnType property, const int global_index, const int min_index=-1, const int max_index=-1) const
Returns a value of global configuration parameter with a given index.
util::Optional< bool > ddns_override_no_update_
Should Kea perform updates, even if client requested no updates.
void setCalculateTeeTimes(const util::Optional< bool > &calculate_tee_times)
Sets whether or not T1/T2 calculation is enabled.
util::Optional< std::string > ddns_qualifying_suffix_
Suffix Kea should use when to qualify partial domain-names.
util::Optional< bool > getStoreExtendedInfo(const Inheritance &inheritance=Inheritance::ALL) const
Returns store-extended-info.
void setDdnsOverrideNoUpdate(const util::Optional< bool > &ddns_override_no_update)
Sets new ddns-override-no-update.
void setDefaultAllocatorType(const std::string &allocator_type)
Sets a defalt allocator type.
util::Optional< bool > getReservationsInSubnet(const Inheritance &inheritance=Inheritance::ALL) const
Returns whether subnet reservations should be fetched.
void setHostnameCharReplacement(const util::Optional< std::string > &hostname_char_replacement)
Sets new hostname-char-replacement.
util::Optional< uint32_t > getCacheMaxAge(const Inheritance &inheritance=Inheritance::ALL) const
Returns value in seconds to use as cache maximum age.
void setReservationsGlobal(const util::Optional< bool > &reservations_global)
Sets whether global reservations should be fetched.
util::Optional< double > getT1Percent(const Inheritance &inheritance=Inheritance::ALL) const
Returns percentage to use when calculating the T1 (renew timer).
void setDdnsSendUpdates(const util::Optional< bool > &ddns_send_updates)
Sets new ddns-send-updates.
void setDdnsUpdateOnRenew(const util::Optional< bool > &ddns_update_on_renew)
Sets new ddns-update-on-renew.
void setDdnsQualifyingSuffix(const util::Optional< std::string > &ddns_qualifying_suffix)
Sets new ddns-qualifying-suffix.
util::Optional< double > ddns_ttl_percent_
Percentage of the lease lifetime to use for DNS TTL.
util::Optional< ClientClass > getClientClass(const Inheritance &inheritance=Inheritance::ALL) const
returns the client class
util::Optional< std::string > getIface(const Inheritance &inheritance=Inheritance::ALL) const
Returns name of the local interface for which this network is selected.
void setDdnsTtlPercent(const util::Optional< double > &ddns_ttl_percent)
Sets new ddns-ttl-percent.
util::Optional< D2ClientConfig::ReplaceClientNameMode > ddns_replace_client_name_mode_
How Kea should handle the domain-name supplied by the client.
void setRelayInfo(const RelayInfo &relay)
Sets information about relay.
isc::util::Triplet< uint32_t > getValid(const Inheritance &inheritance=Inheritance::ALL) const
Return valid-lifetime for addresses in that prefix.
util::Optional< std::string > default_allocator_type_
Default allocator type.
isc::util::Triplet< uint32_t > t1_
a isc::util::Triplet (min/default/max) holding allowed renew timer values
CfgOptionPtr getCfgOption()
Returns pointer to the option data configuration for this network.
util::Optional< double > cache_threshold_
Percentage of the lease lifetime to use as cache threshold.
A template representing an optional value.
This template specifies a parameter value.
Defines the D2ClientConfig class.
boost::shared_ptr< const Element > ConstElementPtr
boost::shared_ptr< Element > ElementPtr
std::string ClientClass
Defines a single class name.
boost::shared_ptr< const CfgGlobals > ConstCfgGlobalsPtr
Const shared pointer to a CfgGlobals instance.
boost::shared_ptr< Network4 > Network4Ptr
Pointer to the Network4 object.
boost::shared_ptr< CfgOption > CfgOptionPtr
Non-const pointer.
boost::shared_ptr< Network6 > Network6Ptr
Pointer to the Network6 object.
std::function< ConstCfgGlobalsPtr()> FetchNetworkGlobalsFn
Callback function for D2ClientConfig that retrieves globally configured parameters.
boost::weak_ptr< Network > WeakNetworkPtr
Weak pointer to the Network object.
boost::multi_index_container< asiolink::IOAddress, boost::multi_index::indexed_by< boost::multi_index::sequenced< boost::multi_index::tag< IOAddressListListTag > >, boost::multi_index::hashed_unique< boost::multi_index::tag< IOAddressListSetTag >, boost::multi_index::identity< asiolink::IOAddress > > > > IOAddressList
List of IO addresses.
boost::shared_ptr< Network > NetworkPtr
Pointer to the Network object.
boost::shared_ptr< Option > OptionPtr
boost::shared_ptr< const CfgOption > ConstCfgOptionPtr
Const pointer.
Defines the logger used by the top-level component of kea-lfc.
Abstract class for configuration Cfg_* classes.
Base class for user context.
Tag for the list of IO addresses as a list.
Tag for the list of IO addresses as a set.