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> 38 template <
typename... Args>
39 inline void unused(Args
const& ...) {}
52 typedef 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>
169 void addAddress(
const asiolink::IOAddress& addr);
179 bool hasAddresses()
const;
184 bool containsAddress(
const asiolink::IOAddress& addr)
const;
214 : iface_name_(), client_class_(), t1_(), t2_(), valid_(),
215 reservations_global_(false, true), reservations_in_subnet_(true, true),
216 reservations_out_of_pool_(false, true), cfg_option_(new
CfgOption()),
217 calculate_tee_times_(), t1_percent_(), t2_percent_(),
218 ddns_send_updates_(), ddns_override_no_update_(), ddns_override_client_update_(),
219 ddns_replace_client_name_mode_(), ddns_generated_prefix_(), ddns_qualifying_suffix_(),
220 hostname_char_set_(), hostname_char_replacement_(), store_extended_info_(),
221 cache_threshold_(), cache_max_age_(), ddns_update_on_renew_(),
222 ddns_use_conflict_resolution_() {
235 fetch_globals_fn_ = fetch_globals_fn;
243 return (static_cast<bool>(fetch_globals_fn_));
256 if (iface_name.
empty()) {
259 iface_name_ = iface_name;
311 void addRelayAddress(
const asiolink::IOAddress& addr);
321 bool hasRelays()
const;
327 bool hasRelayAddress(
const asiolink::IOAddress& address)
const;
425 reservations_global_,
434 reservations_global_ = reservations_global;
443 reservations_in_subnet_,
452 reservations_in_subnet_ = reservations_in_subnet;
461 reservations_out_of_pool_,
470 reservations_out_of_pool_ = reservations_out_of_pool;
475 return (cfg_option_);
481 return (cfg_option_);
490 calculate_tee_times_,
499 calculate_tee_times_ = calculate_tee_times;
515 t1_percent_ = t1_percent;
531 t2_percent_ = t2_percent;
540 ddns_send_updates_, inheritance,
548 ddns_send_updates_ = ddns_send_updates;
557 ddns_override_no_update_, inheritance,
565 ddns_override_no_update_ = ddns_override_no_update;
574 ddns_override_client_update_, inheritance,
582 ddns_override_client_update) {
583 ddns_override_client_update_ = ddns_override_client_update;
597 ddns_replace_client_name_mode_, inheritance);
602 (inheritance != Inheritance::PARENT_NETWORK)) {
605 mode_label = getGlobalProperty(mode_label,
628 ddns_replace_client_name_mode) {
629 ddns_replace_client_name_mode_ = ddns_replace_client_name_mode;
638 ddns_generated_prefix_, inheritance,
646 ddns_generated_prefix_ = ddns_generated_prefix;
655 ddns_qualifying_suffix_, inheritance,
663 ddns_qualifying_suffix_ = ddns_qualifying_suffix;
670 hostname_char_set_, inheritance,
678 hostname_char_set_ = hostname_char_set;
685 hostname_char_replacement_, inheritance,
693 hostname_char_replacement) {
694 hostname_char_replacement_ = hostname_char_replacement;
703 store_extended_info_, inheritance,
711 store_extended_info_ = store_extended_info;
720 cache_threshold_, inheritance,
728 cache_threshold_ = cache_threshold;
744 cache_max_age_ = cache_max_age;
753 ddns_update_on_renew_, inheritance,
761 ddns_update_on_renew_ = ddns_update_on_renew;
770 ddns_use_conflict_resolution_,
779 ddns_use_conflict_resolution_ = ddns_use_conflict_resolution;
801 allocator_type_ = allocator_type;
816 return (fetch_globals_fn_);
845 template<
typename ReturnType>
847 const int global_index,
848 const int min_index = -1,
849 const int max_index = -1)
const {
850 unused(min_index, max_index);
851 if ((global_index >= 0) && fetch_globals_fn_) {
883 template<
typename NumType>
885 const int global_index,
886 const int min_index = -1,
887 const int max_index = -1)
const {
889 if ((global_index >= 0) && fetch_globals_fn_) {
894 NumType def_value =
static_cast<NumType
>(param->intValue());
895 if ((min_index < 0) || (max_index < 0)) {
898 NumType min_value = def_value;
899 NumType max_value = def_value;
902 min_value =
static_cast<NumType
>(min_param->intValue());
906 max_value =
static_cast<NumType
>(max_param->intValue());
938 const int global_index,
939 const int min_index = -1,
940 const int max_index = -1)
const;
972 template<
typename BaseType,
typename ReturnType>
976 const int global_index = -1,
977 const int min_index = -1,
978 const int max_index = -1)
const {
985 }
else if (inheritance == Inheritance::PARENT_NETWORK) {
986 ReturnType parent_property;
989 auto parent = boost::dynamic_pointer_cast<BaseType>(parent_network_.lock());
993 return (parent_property);
996 }
else if (inheritance == Inheritance::GLOBAL) {
997 return (getGlobalProperty(ReturnType(), global_index, min_index, max_index));
1002 if (property.unspecified()) {
1004 auto parent = boost::dynamic_pointer_cast<BaseType>(parent_network_.lock());
1010 auto parent_property = ((*parent).*MethodPointer)(inheritance);
1011 if (!parent_property.unspecified()) {
1012 return (parent_property);
1020 return (getGlobalProperty(property, global_index, min_index, max_index));
1047 template<
typename BaseType>
1058 auto parent = boost::dynamic_pointer_cast<BaseType>(parent_network_.lock());
1064 return (parent_property);
1074 auto parent = boost::dynamic_pointer_cast<BaseType>(parent_network_.lock());
1078 OptionPtr parent_property = (((*parent).*MethodPointer)(inheritance));
1079 if (parent_property) {
1080 return (parent_property);
1210 :
Network(), match_client_id_(true, true), authoritative_(),
1211 siaddr_(), sname_(), filename_() {
1233 match_client_id_ = match;
1245 authoritative_, inheritance,
1255 authoritative_ = authoritative;
1315 virtual asiolink::IOAddress getServerId()
const;
1347 :
Network(), preferred_(), interface_id_(), rapid_commit_() {
1367 preferred_ = preferred;
1383 interface_id_ = ifaceid;
1405 rapid_commit_ = rapid_commit;
1427 pd_allocator_type_ = allocator_type;
util::Optional< bool > store_extended_info_
Should Kea store additional client query data (e.g.
WeakNetworkPtr parent_network_
Pointer to another network that this network belongs to.
virtual ~Network()
Virtual destructor.
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< uint32_t > cache_max_age_
Value in seconds to use as cache maximal age.
Defines the D2ClientConfig class.
util::Optional< bool > reservations_global_
Enables global reservations.
void setDdnsSendUpdates(const util::Optional< bool > &ddns_send_updates)
Sets new ddns-send-updates.
void unspecified(bool unspecified)
Modifies the flag that indicates whether the value is specified or unspecified.
boost::weak_ptr< Network > WeakNetworkPtr
Weak pointer to the Network object.
This class represents configuration element which is associated with database identifier, modification timestamp and servers.
util::Optional< double > t2_percent_
Percentage of the lease lifetime to use when calculating T2 timer.
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< ClientClass > client_class_
Optional definition of a client class.
util::Optional< std::string > getAllocatorType(const Inheritance &inheritance=Inheritance::ALL) const
Returns allocator type.
boost::shared_ptr< CfgOption > CfgOptionPtr
Non-const pointer.
void setHostnameCharSet(const util::Optional< std::string > &hostname_char_set)
Sets new hostname-char-set.
util::Optional< bool > ddns_override_no_update_
Should Kea perform updates, even if client requested no updates.
boost::shared_ptr< Network > NetworkPtr
Pointer to the Network object.
void setCacheMaxAge(const util::Optional< uint32_t > &cache_max_age)
Sets cache max for a network.
util::Optional< std::string > getDdnsQualifyingSuffix(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-qualifying-suffix.
ClientClasses required_classes_
Required classes.
util::Optional< bool > getStoreExtendedInfo(const Inheritance &inheritance=Inheritance::ALL) const
Returns store-extended-info.
util::Optional< ClientClass > getClientClass(const Inheritance &inheritance=Inheritance::ALL) const
returns the client class
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...
Tag for the list of IO addresses as a list.
isc::util::Triplet< uint32_t > getPreferred(const Inheritance &inheritance=Inheritance::ALL) const
Returns preferred lifetime (in seconds)
util::Optional< bool > getDdnsUseConflictResolution(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-use-conflict-resolution.
util::Optional< std::string > ddns_qualifying_suffix_
Suffix Kea should use when to qualify partial domain-names.
boost::shared_ptr< Network::RelayInfo > RelayInfoPtr
Pointer to the RelayInfo structure.
Base class for user context.
boost::shared_ptr< const CfgOption > ConstCfgOptionPtr
Const pointer.
util::Optional< bool > getDdnsOverrideClientUpdate(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-override-client-update.
FetchNetworkGlobalsFn fetch_globals_fn_
Pointer to the optional callback used to fetch globally configured parameters inherited to the Networ...
Defines elements for storing the names of client classes.
util::Optional< std::string > getHostnameCharSet(const Inheritance &inheritance=Inheritance::ALL) const
Return the char set regexp used to sanitize client hostnames.
void setCalculateTeeTimes(const util::Optional< bool > &calculate_tee_times)
Sets whether or not T1/T2 calculation is enabled.
boost::shared_ptr< Option > OptionPtr
util::Optional< std::string > iface_name_
Holds interface name for which this network is selected.
boost::shared_ptr< const CfgGlobals > ConstCfgGlobalsPtr
Const shared pointer to a CfgGlobals instance.
void setT1(const isc::util::Triplet< uint32_t > &t1)
Sets new renew timer for a network.
util::Optional< double > cache_threshold_
Percentage of the lease lifetime to use as cache threshold.
T get() const
Retrieves the encapsulated value.
boost::shared_ptr< Element > ElementPtr
void setHostnameCharReplacement(const util::Optional< std::string > &hostname_char_replacement)
Sets new hostname-char-replacement.
util::Optional< bool > ddns_send_updates_
Should Kea perform DNS updates.
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< double > getT2Percent(const Inheritance &inheritance=Inheritance::ALL) const
Returns percentage to use when calculating the T2 (rebind timer).
void setInterfaceId(const OptionPtr &ifaceid)
sets interface-id option (if defined)
util::Optional< bool > ddns_use_conflict_resolution_
Used to to tell kea-dhcp-ddns whether or not to use conflict resolution.
CfgOptionPtr getCfgOption()
Returns pointer to the option data configuration for this network.
boost::shared_ptr< Network6 > Network6Ptr
Pointer to the Network6 object.
util::Optional< D2ClientConfig::ReplaceClientNameMode > getDdnsReplaceClientNameMode(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-replace-client-name-mode.
util::Optional< double > getT1Percent(const Inheritance &inheritance=Inheritance::ALL) const
Returns percentage to use when calculating the T1 (renew timer).
util::Optional< uint32_t > getCacheMaxAge(const Inheritance &inheritance=Inheritance::ALL) const
Returns value in seconds to use as cache maximum age.
Specialization of the Network object for DHCPv6 case.
util::Optional< std::string > getSname(const Inheritance &inheritance=Inheritance::ALL) const
Returns server hostname for this network.
void setStoreExtendedInfo(const util::Optional< bool > &store_extended_info)
Sets new store-extended-info.
Holds optional information about relay.
util::Optional< std::string > hostname_char_replacement_
A string to replace invalid characters when scrubbing hostnames.
void setDdnsReplaceClientNameMode(const util::Optional< D2ClientConfig::ReplaceClientNameMode > &ddns_replace_client_name_mode)
Sets new ddns-replace-client-name-mode.
void setDdnsQualifyingSuffix(const util::Optional< std::string > &ddns_qualifying_suffix)
Sets new ddns-qualifying-suffix.
std::function< ConstCfgGlobalsPtr()> FetchNetworkGlobalsFn
Callback function for D2ClientConfig that retrieves globally configured parameters.
Represents option data configuration for the DHCP server.
util::Optional< double > t1_percent_
Percentage of the lease lifetime to use when calculating T1 timer.
void setAuthoritative(const util::Optional< bool > &authoritative)
Sets the flag indicating if requests for unknown IP addresses should be rejected with DHCPNAK instead...
isc::util::Triplet< uint32_t > t1_
a isc::util::Triplet (min/default/max) holding allowed renew timer values
Abstract class for configuration Cfg_* classes.
void setRapidCommit(const util::Optional< bool > &rapid_commit)
Enables or disables Rapid Commit option support for the subnet.
Inheritance
Inheritance "mode" used when fetching an optional Network parameter.
Common interface representing a network to which the DHCP clients are connected.
bool hasFetchGlobalsFn() const
Checks if the network is associated with a function used to fetch globally configured parameters...
boost::shared_ptr< const Element > ConstElementPtr
util::Optional< bool > ddns_update_on_renew_
Should Kea perform updates when leases are extended.
void setDdnsGeneratedPrefix(const util::Optional< std::string > &ddns_generated_prefix)
Sets new ddns-generated-prefix.
void setMatchClientId(const util::Optional< bool > &match)
Sets the flag indicating if the client identifier should be used to identify the client's lease...
void setReservationsInSubnet(const util::Optional< bool > &reservations_in_subnet)
Sets whether subnet reservations should be fetched.
util::Optional< std::string > getPdAllocatorType(const Inheritance &inheritance=Inheritance::ALL) const
Returns allocator type for prefix delegation.
util::Optional< std::string > getFilename(const Inheritance &inheritance=Inheritance::ALL) const
Returns boot file name for this subnet.
void setDdnsUseConflictResolution(const util::Optional< bool > &ddns_use_conflict_resolution)
Sets new ddns-use-conflict-resolution.
util::Optional< bool > getDdnsOverrideNoUpdate(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-override-no-update.
void setDdnsUpdateOnRenew(const util::Optional< bool > &ddns_update_on_renew)
Sets new ddns-update-on-renew.
util::Optional< std::string > getDdnsGeneratedPrefix(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-generated-prefix.
void setT1Percent(const util::Optional< double > &t1_percent)
Sets new percentage for calculating T1 (renew timer).
void setPdAllocatorType(const util::Optional< std::string > &allocator_type)
Sets new allocator type for prefix delegation.
util::Optional< bool > getDdnsUpdateOnRenew(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-update-on-renew.
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.
void setPreferred(const isc::util::Triplet< uint32_t > &preferred)
Sets new preferred lifetime for a network.
isc::util::Triplet< uint32_t > getT1(const Inheritance &inheritance=Inheritance::ALL) const
Returns T1 (renew timer), expressed in seconds.
Defines the logger used by the top-level component of kea-lfc.
void setT2Percent(const util::Optional< double > &t2_percent)
Sets new percentage for calculating T2 (rebind timer).
util::Optional< asiolink::IOAddress > getSiaddr(const Inheritance &inheritance=Inheritance::ALL) const
Returns siaddr for this network.
util::Optional< std::string > allocator_type_
Allocator used for IP address allocations.
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.
OptionPtr getInterfaceId(const Inheritance &inheritance=Inheritance::ALL) const
Returns interface-id value (if specified)
util::Optional< bool > reservations_in_subnet_
Enables subnet reservations.
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...
CfgOptionPtr cfg_option_
Pointer to the option data configuration for this subnet.
isc::util::Triplet< uint32_t > getValid(const Inheritance &inheritance=Inheritance::ALL) const
Return valid-lifetime for addresses in that prefix.
ConstCfgOptionPtr getCfgOption() const
Returns const pointer to the option data configuration for this network.
void setAllocatorType(const util::Optional< std::string > &allocator_type)
Sets new allocator type.
util::Optional< bool > reservations_out_of_pool_
Enables out-of-pool reservations optimization.
Tag for the list of IO addresses as a set.
util::Optional< double > getCacheThreshold(const Inheritance &inheritance=Inheritance::ALL) const
Returns percentage to use as cache threshold.
void setReservationsOutOfPool(const util::Optional< bool > &reservations_out_of_pool)
Sets whether only out-of-pool reservations are allowed.
const RelayInfo & getRelayInfo() const
Returns const reference to relay information.
Specialization of the Network object for DHCPv4 case.
util::Optional< std::string > getHostnameCharReplacement(const Inheritance &inheritance=Inheritance::ALL) const
Return the invalid char replacement used to sanitize client hostnames.
util::Optional< std::string > hostname_char_set_
Regular expression describing invalid characters for client hostnames.
void setDdnsOverrideNoUpdate(const util::Optional< bool > &ddns_override_no_update)
Sets new ddns-override-no-update.
void setIface(const util::Optional< std::string > &iface_name)
Sets local name of the interface for which this network is selected.
util::Optional< std::string > getIface(const Inheritance &inheritance=Inheritance::ALL) const
Returns name of the local interface for which this network is selected.
void setValid(const isc::util::Triplet< uint32_t > &valid)
Sets new valid lifetime for a network.
isc::util::Triplet< uint32_t > getT2(const Inheritance &inheritance=Inheritance::ALL) const
Returns T2 (rebind timer), expressed in seconds.
util::Optional< bool > calculate_tee_times_
Enables calculation of T1 and T2 timers.
util::Optional< bool > getCalculateTeeTimes(const Inheritance &inheritance=Inheritance::ALL) const
Returns whether or not T1/T2 calculation is enabled.
isc::util::Triplet< uint32_t > t2_
a isc::util::Triplet (min/default/max) holding allowed rebind timer values
void setRelayInfo(const RelayInfo &relay)
Sets information about relay.
void setT2(const isc::util::Triplet< uint32_t > &t2)
Sets new rebind timer for a network.
std::string ClientClass
Defines a single class name.
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...
util::Optional< bool > getReservationsGlobal(const Inheritance &inheritance=Inheritance::ALL) const
Returns whether global reservations should be fetched.
The IOAddress class represents an IP addresses (version agnostic)
util::Optional< std::string > ddns_generated_prefix_
Prefix Kea should use when generating domain-names.
bool empty() const
Checks if the encapsulated value is empty.
void setCacheThreshold(const util::Optional< double > &cache_threshold)
Sets cache threshold for a network.
void setDdnsOverrideClientUpdate(const util::Optional< bool > &ddns_override_client_update)
Sets new ddns-override-client-update.
RelayInfo relay_
Relay information.
util::Optional< bool > getReservationsOutOfPool(const Inheritance &inheritance=Inheritance::ALL) const
Returns whether only out-of-pool reservations are allowed.
Container for storing client class names.
util::Optional< bool > ddns_override_client_update_
Should Kea perform updates, even if client requested delegation.
util::Optional< bool > getReservationsInSubnet(const Inheritance &inheritance=Inheritance::ALL) const
Returns whether subnet reservations should be fetched.
void setFetchGlobalsFn(FetchNetworkGlobalsFn fetch_globals_fn)
Sets the optional callback function used to fetch globally configured parameters. ...
util::Optional< D2ClientConfig::ReplaceClientNameMode > ddns_replace_client_name_mode_
How Kea should handle the domain-name supplied by the client.
static ReplaceClientNameMode stringToReplaceClientNameMode(const std::string &mode_str)
Converts labels to ReplaceClientNameMode enum values.
util::Optional< bool > getDdnsSendUpdates(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-send-updates.
void setReservationsGlobal(const util::Optional< bool > &reservations_global)
Sets whether global reservations should be fetched.
FetchNetworkGlobalsFn getFetchGlobalsFn() const
Gets the optional callback function used to fetch globally configured parameters. ...
isc::util::Triplet< uint32_t > valid_
a isc::util::Triplet (min/default/max) holding allowed valid lifetime values
Template class for converting a value encapsulated in the Element object into a simple type...