22 #include <boost/shared_ptr.hpp>
23 #include <boost/weak_ptr.hpp>
30 template <
typename... Args>
31 inline void unused(Args
const& ...) {}
158 IOAddressList addresses_;
342 "valid-lifetime",
"min-valid-lifetime",
343 "max-valid-lifetime"));
371 return (getProperty<Network>(&
Network::getT2,
t2_, inheritance,
"rebind-timer"));
389 "reservations-global"));
407 "reservations-in-subnet"));
425 "reservations-out-of-pool"));
454 "calculate-tee-times"));
470 inheritance,
"t1-percent"));
486 inheritance,
"t2-percent"));
502 inheritance,
"ddns-send-updates"));
519 inheritance,
"ddns-override-no-update"));
536 inheritance,
"ddns-override-client-update"));
543 ddns_override_client_update) {
588 ddns_replace_client_name_mode) {
599 inheritance,
"ddns-generated-prefix"));
616 inheritance,
"ddns-qualifying-suffix"));
630 inheritance,
"hostname-char-set"));
645 inheritance,
"hostname-char-replacement"));
652 hostname_char_replacement) {
663 inheritance,
"store-extended-info"));
680 inheritance,
"cache-threshold"));
696 inheritance,
"cache-max-age"));
713 inheritance,
"ddns-update-on-renew"));
730 inheritance,
"ddns-use-conflict-resolution"));
781 template<
typename ReturnType>
783 const std::string& global_name,
784 const std::string& min_name =
"",
785 const std::string& max_name =
"")
const {
786 unused(min_name, max_name);
819 template<
typename NumType>
821 const std::string& global_name,
822 const std::string& min_name =
"",
823 const std::string& max_name =
"")
const {
830 NumType def_value =
static_cast<NumType
>(param->intValue());
831 if (min_name.empty() || max_name.empty()) {
834 NumType min_value = def_value;
835 NumType max_value = def_value;
838 min_value =
static_cast<NumType
>(min_param->intValue());
842 max_value =
static_cast<NumType
>(max_param->intValue());
874 const std::string& global_name,
875 const std::string& min_name =
"",
876 const std::string& max_name =
"")
const;
908 template<
typename BaseType,
typename ReturnType>
912 const std::string& global_name =
"",
913 const std::string& min_name =
"",
914 const std::string& max_name =
"")
const {
922 ReturnType parent_property;
925 auto parent = boost::dynamic_pointer_cast<BaseType>(
parent_network_.lock());
929 return (parent_property);
938 if (property.unspecified()) {
940 auto parent = boost::dynamic_pointer_cast<BaseType>(
parent_network_.lock());
946 auto parent_property = ((*parent).*MethodPointer)(inheritance);
947 if (!parent_property.unspecified()) {
948 return (parent_property);
983 template<
typename BaseType>
994 auto parent = boost::dynamic_pointer_cast<BaseType>(
parent_network_.lock());
1000 return (parent_property);
1010 auto parent = boost::dynamic_pointer_cast<BaseType>(
parent_network_.lock());
1014 OptionPtr parent_property = (((*parent).*MethodPointer)(inheritance));
1015 if (parent_property) {
1016 return (parent_property);
1143 :
Network(), match_client_id_(true, true), authoritative_(),
1144 siaddr_(), sname_(), filename_() {
1157 "match-client-id"));
1166 match_client_id_ = match;
1178 inheritance,
"authoritative"));
1187 authoritative_ = authoritative;
1203 inheritance,
"next-server"));
1218 inheritance,
"server-hostname"));
1233 inheritance,
"boot-file-name"));
1272 :
Network(), preferred_(), interface_id_(), rapid_commit_() {
1282 inheritance,
"preferred-lifetime",
1283 "min-preferred-lifetime",
1284 "max-preferred-lifetime"));
1291 preferred_ = preferred;
1307 interface_id_ = ifaceid;
1319 inheritance,
"rapid-commit"));
1327 rapid_commit_ = rapid_commit;
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.
util::Optional< bool > getReservationsInSubnet(const Inheritance &inheritance=Inheritance::ALL) const
Returns whether subnet reservations should be fetched.
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.
util::Optional< bool > getDdnsOverrideClientUpdate(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-override-client-update.
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.
util::Optional< ClientClass > getClientClass(const Inheritance &inheritance=Inheritance::ALL) const
returns the client class
Triplet< uint32_t > getT2(const Inheritance &inheritance=Inheritance::ALL) const
Returns T2 (rebind timer), expressed in seconds.
util::Optional< ClientClass > client_class_
Optional definition of a client class.
std::vector< isc::asiolink::IOAddress > IOAddressList
List of IOAddresses.
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.
util::Optional< asiolink::IOAddress > getSiaddr(const Inheritance &inheritance=Inheritance::ALL) const
Returns siaddr for this network.
boost::shared_ptr< Network > NetworkPtr
Pointer to the Network object.
OptionPtr getInterfaceId(const Inheritance &inheritance=Inheritance::ALL) const
Returns interface-id value (if specified)
void setSname(const util::Optional< std::string > &sname)
Sets server hostname for the network.
void setCacheMaxAge(const util::Optional< uint32_t > &cache_max_age)
Sets cache max for a network.
ClientClasses required_classes_
Required classes.
virtual bool clientSupported(const isc::dhcp::ClientClasses &client_classes) const
Checks whether this network supports client that belongs to specified classes.
Triplet< uint32_t > getT1(const Inheritance &inheritance=Inheritance::ALL) const
Returns T1 (renew timer), expressed in seconds.
util::Optional< uint32_t > getCacheMaxAge(const Inheritance &inheritance=Inheritance::ALL) const
Returns value in seconds to use as cache maximum age.
Triplet< uint32_t > t2_
a Triplet (min/default/max) holding allowed rebind timer values
Triplet< NumType > getGlobalProperty(Triplet< NumType > property, const std::string &global_name, const std::string &min_name="", const std::string &max_name="") const
The getGlobalProperty specialization for Triplet.
bool hasRelayAddress(const asiolink::IOAddress &address) const
Tests if the network's relay info contains the given address.
virtual data::ElementPtr toElement() const
Unparses network object.
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.
void setValid(const Triplet< uint32_t > &valid)
Sets new valid lifetime for a network.
bool hasAddresses() const
Indicates whether or not the address list has entries.
util::Optional< std::string > getFilename(const Inheritance &inheritance=Inheritance::ALL) const
Returns boot file name for this subnet.
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.
ReturnType getProperty(ReturnType(BaseType::*MethodPointer)(const Inheritance &) const, ReturnType property, const Inheritance &inheritance, const std::string &global_name="", const std::string &min_name="", const std::string &max_name="") const
Returns a value associated with a network using inheritance.
std::function< data::ConstElementPtr()> FetchNetworkGlobalsFn
Callback function for D2ClientConfig that retrieves globally configured parameters.
util::Optional< bool > getDdnsUseConflictResolution(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-use-conflict-resolution.
void setCalculateTeeTimes(const util::Optional< bool > &calculate_tee_times)
Sets whether or not T1/T2 calculation is enabled.
boost::shared_ptr< Option > OptionPtr
virtual data::ElementPtr toElement() const
Unparses network object.
FetchNetworkGlobalsFn getFetchGlobalsFn() const
Gets the optional callback function used to fetch globally configured parameters. ...
const RelayInfo & getRelayInfo() const
Returns const reference to relay information.
ConstCfgOptionPtr getCfgOption() const
Returns const pointer to the option data configuration for this network.
util::Optional< std::string > iface_name_
Holds interface name for which this network is selected.
util::Optional< double > cache_threshold_
Percentage of the lease lifetime to use as cache threshold.
void setSiaddr(const util::Optional< asiolink::IOAddress > &siaddr)
Sets siaddr for the network.
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.
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.
util::Optional< bool > getDdnsOverrideNoUpdate(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-override-no-update.
Specialization of the Network object for DHCPv6 case.
const ClientClasses & getRequiredClasses() const
Returns classes which are required to be evaluated.
virtual data::ElementPtr toElement() const
Unparses network object.
OptionPtr getOptionProperty(OptionPtr(BaseType::*MethodPointer)(const Inheritance &inheritance) const, OptionPtr property, const Inheritance &inheritance) const
Returns option pointer associated with a network using inheritance.
void setStoreExtendedInfo(const util::Optional< bool > &store_extended_info)
Sets new store-extended-info.
util::Optional< std::string > getDdnsQualifyingSuffix(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-qualifying-suffix.
util::Optional< double > getT1Percent(const Inheritance &inheritance=Inheritance::ALL) const
Returns percentage to use when calculating the T1 (renew timer).
Triplet< uint32_t > getPreferred(const Inheritance &inheritance=Inheritance::ALL) const
Returns preferred lifetime (in seconds)
bool hasFetchGlobalsFn() const
Checks if the network is associated with a function used to fetch globally configured parameters...
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.
void setFilename(const util::Optional< std::string > &filename)
Sets boot file name for the network.
void addRelayAddress(const asiolink::IOAddress &addr)
Adds an address to the list addresses in the network's relay info.
Represents option data configuration for the DHCP server.
util::Optional< std::string > getSname(const Inheritance &inheritance=Inheritance::ALL) const
Returns server hostname for this network.
Triplet< uint32_t > valid_
a Triplet (min/default/max) holding allowed valid lifetime values
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...
Abstract class for configuration Cfg_* classes.
void allowClientClass(const isc::dhcp::ClientClass &class_name)
Sets the supported class to class class_name.
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.
ReturnType getGlobalProperty(ReturnType property, const std::string &global_name, const std::string &min_name="", const std::string &max_name="") const
Returns a value of global configuration parameter with a given name.
Common interface representing a network to which the DHCP clients are connected.
boost::shared_ptr< const Element > ConstElementPtr
util::Optional< bool > ddns_update_on_renew_
Should Kea perform updates when leases are extended.
util::Optional< bool > getDdnsSendUpdates(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-send-updates.
void setDdnsGeneratedPrefix(const util::Optional< std::string > &ddns_generated_prefix)
Sets new ddns-generated-prefix.
void setPreferred(const Triplet< uint32_t > &preferred)
Sets new preferred lifetime for a network.
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.
const IOAddressList & getAddresses() const
Returns const reference to the list of addresses.
void setDdnsUseConflictResolution(const util::Optional< bool > &ddns_use_conflict_resolution)
Sets new ddns-use-conflict-resolution.
void setDdnsUpdateOnRenew(const util::Optional< bool > &ddns_update_on_renew)
Sets new ddns-update-on-renew.
void setT1Percent(const util::Optional< double > &t1_percent)
Sets new percentage for calculating T1 (renew timer).
util::Optional< bool > getReservationsGlobal(const Inheritance &inheritance=Inheritance::ALL) const
Returns whether global reservations should be fetched.
util::Optional< std::string > getHostnameCharSet(const Inheritance &inheritance=Inheritance::ALL) const
Return the char set regexp used to sanitize client hostnames.
Defines the logger used by the top-level component of kea-dhcp-ddns.
T get() const
Retrieves the encapsulated value.
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...
void setT2Percent(const util::Optional< double > &t2_percent)
Sets new percentage for calculating T2 (rebind timer).
void addAddress(const asiolink::IOAddress &addr)
Adds an address to the list of addresses.
Triplet< uint32_t > getValid(const Inheritance &inheritance=Inheritance::ALL) const
Return valid-lifetime for addresses in that prefix.
util::Optional< bool > reservations_in_subnet_
Enables subnet reservations.
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...
bool hasRelays() const
Indicates if network's relay info has relay addresses.
util::Optional< double > getT2Percent(const Inheritance &inheritance=Inheritance::ALL) const
Returns percentage to use when calculating the T2 (rebind timer).
CfgOptionPtr cfg_option_
Pointer to the option data configuration for this subnet.
bool containsAddress(const asiolink::IOAddress &addr) const
Checks the address list for the given address.
util::Optional< std::string > getHostnameCharReplacement(const Inheritance &inheritance=Inheritance::ALL) const
Return the invalid char replacement used to sanitize client hostnames.
void requireClientClass(const isc::dhcp::ClientClass &class_name)
Adds class class_name to classes required to be evaluated.
util::Optional< bool > getStoreExtendedInfo(const Inheritance &inheritance=Inheritance::ALL) const
Returns store-extended-info.
const IOAddressList & getRelayAddresses() const
Returns the list of relay addresses from the network's relay info.
util::Optional< bool > reservations_out_of_pool_
Enables out-of-pool reservations optimization.
util::Optional< D2ClientConfig::ReplaceClientNameMode > getDdnsReplaceClientNameMode(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-replace-client-name-mode.
void setReservationsOutOfPool(const util::Optional< bool > &reservations_out_of_pool)
Sets whether only out-of-pool reservations are allowed.
Specialization of the Network object for DHCPv4 case.
virtual asiolink::IOAddress getServerId() const
Returns binary representation of the dhcp-server-identifier option (54).
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< bool > getCalculateTeeTimes(const Inheritance &inheritance=Inheritance::ALL) const
Returns whether or not T1/T2 calculation is enabled.
util::Optional< bool > calculate_tee_times_
Enables calculation of T1 and T2 timers.
void setRelayInfo(const RelayInfo &relay)
Sets information about relay.
std::string ClientClass
Defines a single class name.
The IOAddress class represents an IP addresses (version agnostic)
util::Optional< std::string > getDdnsGeneratedPrefix(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-generated-prefix.
util::Optional< std::string > ddns_generated_prefix_
Prefix Kea should use when generating domain-names.
void setCacheThreshold(const util::Optional< double > &cache_threshold)
Sets cache threshold for a network.
util::Optional< double > getCacheThreshold(const Inheritance &inheritance=Inheritance::ALL) const
Returns percentage to use as cache threshold.
util::Optional< bool > getDdnsUpdateOnRenew(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-update-on-renew.
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...
void setDdnsOverrideClientUpdate(const util::Optional< bool > &ddns_override_client_update)
Sets new ddns-override-client-update.
util::Optional< std::string > getIface(const Inheritance &inheritance=Inheritance::ALL) const
Returns name of the local interface for which this network is selected.
RelayInfo relay_
Relay information.
Container for storing client class names.
void setT1(const Triplet< uint32_t > &t1)
Sets new renew timer for a network.
util::Optional< bool > ddns_override_client_update_
Should Kea perform updates, even if client requested delegation.
void setFetchGlobalsFn(FetchNetworkGlobalsFn fetch_globals_fn)
Sets the optional callback function used to fetch globally configured parameters. ...
void setT2(const Triplet< uint32_t > &t2)
Sets new rebind timer for a network.
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.
Triplet< uint32_t > t1_
a Triplet (min/default/max) holding allowed renew timer values
void setReservationsGlobal(const util::Optional< bool > &reservations_global)
Sets whether global reservations should be fetched.
util::Optional< bool > getReservationsOutOfPool(const Inheritance &inheritance=Inheritance::ALL) const
Returns whether only out-of-pool reservations are allowed.
Template class for converting a value encapsulated in the Element object into a simple type...