| Kea 3.0.2-git

isc::dhcp::SharedNetwork4 Class Reference

Shared network holding IPv4 subnets. More...

`#include <shared_network.h>`

Inheritance diagram for isc::dhcp::SharedNetwork4:
[legend]

## Public Member Functions
| SharedNetwork4 (const std::string &name)
| Constructor.
void | add (const Subnet4Ptr &subnet)
| Adds IPv4 subnet to a shared network.
void | del (const SubnetID &subnet_id)
| Removes subnet from a shared network.
void | delAll ()
| Removes all subnets from a shared network.
const Subnet4SimpleCollection * | getAllSubnets () const
| Returns a pointer to the collection of subnets within this shared network.
virtual std::string | getLabel () const
| Generates an identifying label for logging.
std::string | getName () const
| Returns a name of the shared network.
ConstSubnet4Ptr | getNextSubnet (const ConstSubnet4Ptr &first_subnet, const SubnetID &current_subnet) const
| Retrieves next available IPv4 subnet within shared network.
ConstSubnet4Ptr | getPreferredSubnet (const ConstSubnet4Ptr &selected_subnet) const
| Attempts to find a subnet which is more likely to include available leases than selected subnet.
Subnet4Ptr | getSubnet (const std::string &subnet_prefix) const
| Returns a subnet for a specified subnet prefix.
Subnet4Ptr | getSubnet (const SubnetID &subnet_id) const
| Returns a subnet for a specified subnet id.
bool | replace (const Subnet4Ptr &subnet)
| Replaces IPv4 subnet in a shared network.
void | setName (const std::string &name)
| Sets new name for the shared network.
virtual data::ElementPtr | toElement () const
| Unparses shared network object.
Public Member Functions inherited from isc::dhcp::Network4
| Network4 ()
| Constructor.
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 instead of ignored.
util::Optional< std::string > | getFilename (const Inheritance &inheritance=Inheritance::ALL) const
| Returns boot file name for this subnet.
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< uint32_t > | getOfferLft (const Inheritance &inheritance=Inheritance::ALL) const
| Returns offer lifetime for the network.
virtual asiolink::IOAddress | getServerId () const
| Returns binary representation of the dhcp-server-identifier option (54).
util::Optional< asiolink::IOAddress > | getSiaddr (const Inheritance &inheritance=Inheritance::ALL) const
| Returns siaddr for this network.
util::Optional< std::string > | getSname (const Inheritance &inheritance=Inheritance::ALL) const
| Returns server hostname 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 of ignored.
void | setFilename (const util::Optional< std::string > &filename)
| Sets boot file name for the 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 | setOfferLft (const util::Optional< uint32_t > &offer_lft)
| Sets offer lifetime for the network.
void | setSiaddr (const util::Optional< asiolink::IOAddress > &siaddr)
| Sets siaddr for the network.
void | setSname (const util::Optional< std::string > &sname)
| Sets server hostname for the network.
Public Member Functions inherited from isc::dhcp::Network
| Network ()
| Constructor.
virtual | ~Network ()
| Virtual destructor.
void | addAdditionalClass (const isc::dhcp::ClientClass &class_name)
| Adds class class_name to the additional classes list.
void | addRelayAddress (const asiolink::IOAddress &addr)
| Adds an address to the list addresses in the network's relay info.
void | allowClientClass (const isc::dhcp::ClientClass &class_name)
| Adds class clas_name to the allowed client classes list.
virtual bool | clientSupported (const isc::dhcp::ClientClasses &client_classes) const
| Checks whether this network supports a client that belongs to the specified classes.
const ClientClasses & | getAdditionalClasses () const
| Returns the additional classes list.
util::Optional< std::string > | getAllocatorType (const Inheritance &inheritance=Inheritance::ALL) const
| Returns allocator type.
util::Optional< uint32_t > | getCacheMaxAge (const Inheritance &inheritance=Inheritance::ALL) const
| Returns value in seconds to use as cache maximum age.
util::Optional< double > | getCacheThreshold (const Inheritance &inheritance=Inheritance::ALL) const
| Returns percentage to use as cache threshold.
util::Optional< bool > | getCalculateTeeTimes (const Inheritance &inheritance=Inheritance::ALL) const
| Returns whether or not T1/T2 calculation is enabled.
CfgOptionPtr | getCfgOption ()
| Returns pointer to the option data configuration for this network.
ConstCfgOptionPtr | getCfgOption () const
| Returns const pointer to the option data configuration for this network.
const ClientClasses & | getClientClasses () const
| Returns the list of allowed client classes.
util::Optional< std::string > | getDdnsConflictResolutionMode (const Inheritance &inheritance=Inheritance::ALL) const
| Returns ddns-conflict-resolution-mode.
util::Optional< std::string > | getDdnsGeneratedPrefix (const Inheritance &inheritance=Inheritance::ALL) const
| Returns ddns-generated-prefix.
util::Optional< bool > | getDdnsOverrideClientUpdate (const Inheritance &inheritance=Inheritance::ALL) const
| Returns ddns-override-client-update.
util::Optional< bool > | getDdnsOverrideNoUpdate (const Inheritance &inheritance=Inheritance::ALL) const
| Returns ddns-override-no-update.
util::Optional< std::string > | getDdnsQualifyingSuffix (const Inheritance &inheritance=Inheritance::ALL) const
| Returns ddns-qualifying-suffix.
util::Optional< D2ClientConfig::ReplaceClientNameMode > | getDdnsReplaceClientNameMode (const Inheritance &inheritance=Inheritance::ALL) const
| Returns ddns-replace-client-name-mode.
util::Optional< bool > | getDdnsSendUpdates (const Inheritance &inheritance=Inheritance::ALL) const
| Returns ddns-send-updates.
util::Optional< uint32_t > | getDdnsTtl (const Inheritance &inheritance=Inheritance::ALL) const
| Returns ddns-ttl.
util::Optional< uint32_t > | getDdnsTtlMax (const Inheritance &inheritance=Inheritance::ALL) const
| Returns ddns-ttl-max.
util::Optional< uint32_t > | getDdnsTtlMin (const Inheritance &inheritance=Inheritance::ALL) const
| Returns ddns-ttl-min.
util::Optional< double > | getDdnsTtlPercent (const Inheritance &inheritance=Inheritance::ALL) const
| Returns ddns-ttl-percent.
util::Optional< bool > | getDdnsUpdateOnRenew (const Inheritance &inheritance=Inheritance::ALL) const
| Returns ddns-update-on-renew.
util::Optional< std::string > | getDefaultAllocatorType (const Inheritance &inheritance=Inheritance::ALL) const
| Returns a default allocator type.
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 > | getHostnameCharSet (const Inheritance &inheritance=Inheritance::ALL) const
| Return the char set regexp used to sanitize client hostnames.
util::Optional< std::string > | getIface (const Inheritance &inheritance=Inheritance::ALL) const
| Returns name of the local interface for which this network is selected.
ClientClasses & | getMutableAdditionalClasses ()
| Returns the mutable additional classes list.
ClientClasses & | getMutableClientClasses ()
| Returns the mutable list of allowed client classes.
const IOAddressList & | getRelayAddresses () const
| Returns the list of relay addresses from the network's relay info.
const RelayInfo & | getRelayInfo () const
| Returns const reference to relay information.
util::Optional< bool > | getReservationsGlobal (const Inheritance &inheritance=Inheritance::ALL) const
| Returns whether global reservations should be fetched.
util::Optional< bool > | getReservationsInSubnet (const Inheritance &inheritance=Inheritance::ALL) const
| Returns whether subnet reservations should be fetched.
util::Optional< bool > | getReservationsOutOfPool (const Inheritance &inheritance=Inheritance::ALL) const
| Returns whether only out-of-pool reservations are allowed.
util::Optional< bool > | getStoreExtendedInfo (const Inheritance &inheritance=Inheritance::ALL) const
| Returns store-extended-info.
isc::util::Triplet< uint32_t > | getT1 (const Inheritance &inheritance=Inheritance::ALL) const
| Returns T1 (renew timer), expressed in seconds.
util::Optional< double > | getT1Percent (const Inheritance &inheritance=Inheritance::ALL) const
| Returns percentage to use when calculating the T1 (renew timer).
isc::util::Triplet< uint32_t > | getT2 (const Inheritance &inheritance=Inheritance::ALL) const
| Returns T2 (rebind timer), expressed in seconds.
util::Optional< double > | getT2Percent (const Inheritance &inheritance=Inheritance::ALL) const
| Returns percentage to use when calculating the T2 (rebind timer).
isc::util::Triplet< uint32_t > | getValid (const Inheritance &inheritance=Inheritance::ALL) const
| Return valid-lifetime for addresses in that prefix.
bool | hasFetchGlobalsFn () const
| Checks if the network is associated with a function used to fetch globally configured parameters.
bool | hasRelayAddress (const asiolink::IOAddress &address) const
| Tests if the network's relay info contains the given address.
bool | hasRelays () const
| Indicates if network's relay info has relay addresses.
void | setAllocatorType (const util::Optional< std::string > &allocator_type)
| Sets new allocator type.
void | setCacheMaxAge (const util::Optional< uint32_t > &cache_max_age)
| Sets cache max for a network.
void | setCacheThreshold (const util::Optional< double > &cache_threshold)
| Sets cache threshold for a network.
void | setCalculateTeeTimes (const util::Optional< bool > &calculate_tee_times)
| Sets whether or not T1/T2 calculation is enabled.
void | setDdnsConflictResolutionMode (const util::Optional< std::string > &ddns_conflict_resolution_mode)
| Sets new ddns-conflict-resolution-mode.
void | setDdnsGeneratedPrefix (const util::Optional< std::string > &ddns_generated_prefix)
| Sets new ddns-generated-prefix.
void | setDdnsOverrideClientUpdate (const util::Optional< bool > &ddns_override_client_update)
| Sets new ddns-override-client-update.
void | setDdnsOverrideNoUpdate (const util::Optional< bool > &ddns_override_no_update)
| Sets new ddns-override-no-update.
void | setDdnsQualifyingSuffix (const util::Optional< std::string > &ddns_qualifying_suffix)
| Sets new ddns-qualifying-suffix.
void | setDdnsReplaceClientNameMode (const util::Optional< D2ClientConfig::ReplaceClientNameMode > &ddns_replace_client_name_mode)
| Sets new ddns-replace-client-name-mode.
void | setDdnsSendUpdates (const util::Optional< bool > &ddns_send_updates)
| Sets new ddns-send-updates.
void | setDdnsTtl (const util::Optional< uint32_t > &ddns_ttl)
| Sets new ddns-ttl.
void | setDdnsTtlMax (const util::Optional< uint32_t > &ddns_ttl_max)
| Sets new ddns-ttl-max.
void | setDdnsTtlMin (const util::Optional< uint32_t > &ddns_ttl_min)
| Sets new ddns-ttl-min.
void | setDdnsTtlPercent (const util::Optional< double > &ddns_ttl_percent)
| Sets new ddns-ttl-percent.
void | setDdnsUpdateOnRenew (const util::Optional< bool > &ddns_update_on_renew)
| Sets new ddns-update-on-renew.
void | setDefaultAllocatorType (const std::string &allocator_type)
| Sets a defalt allocator type.
void | setFetchGlobalsFn (FetchNetworkGlobalsFn fetch_globals_fn)
| Sets the optional callback function used to fetch globally configured parameters.
void | setHostnameCharReplacement (const util::Optional< std::string > &hostname_char_replacement)
| Sets new hostname-char-replacement.
void | setHostnameCharSet (const util::Optional< std::string > &hostname_char_set)
| Sets new hostname-char-set.
void | setIface (const util::Optional< std::string > &iface_name)
| Sets local name of the interface for which this network is selected.
void | setRelayInfo (const RelayInfo &relay)
| Sets information about relay.
void | setReservationsGlobal (const util::Optional< bool > &reservations_global)
| Sets whether global reservations should be fetched.
void | setReservationsInSubnet (const util::Optional< bool > &reservations_in_subnet)
| Sets whether subnet reservations should be fetched.
void | setReservationsOutOfPool (const util::Optional< bool > &reservations_out_of_pool)
| Sets whether only out-of-pool reservations are allowed.
void | setStoreExtendedInfo (const util::Optional< bool > &store_extended_info)
| Sets new store-extended-info.
void | setT1 (const isc::util::Triplet< uint32_t > &t1)
| Sets new renew timer for a network.
void | setT1Percent (const util::Optional< double > &t1_percent)
| Sets new percentage for calculating T1 (renew timer).
void | setT2 (const isc::util::Triplet< uint32_t > &t2)
| Sets new rebind timer for a network.
void | setT2Percent (const util::Optional< double > &t2_percent)
| Sets new percentage for calculating T2 (rebind timer).
void | setValid (const isc::util::Triplet< uint32_t > &valid)
| Sets new valid lifetime for a network.
Public Member Functions inherited from isc::data::StampedElement
| StampedElement ()
| Constructor.
void | delServerTag (const std::string &server_tag)
| Deletes server tag.
isc::data::ElementPtr | getMetadata () const
| Returns an object representing metadata to be returned with objects from the configuration backend.
std::set< ServerTag > | getServerTags () const
| Returns server tags.
bool | hasAllServerTag () const
| Checks if the element has 'all' server tag.
bool | hasServerTag (const ServerTag &server_tag) const
| Checks if the element has the given server tag.
void | setServerTag (const std::string &server_tag)
| Adds new server tag.
Public Member Functions inherited from isc::data::BaseStampedElement
| BaseStampedElement ()
| Constructor.
uint64_t | getId () const
| Returns element's database identifier.
boost::posix_time::ptime | getModificationTime () const
| Returns timestamp.
void | setId (const uint64_t id)
| Sets element's database identifier.
void | setModificationTime (const boost::posix_time::ptime &timestamp)
| Sets timestamp to the explicitly provided value.
void | updateModificationTime ()
| Sets timestamp to the current time.
Public Member Functions inherited from isc::data::UserContext
void | contextToElement (data::ElementPtr map) const
| Merge unparse a user_context object.
data::ConstElementPtr | getContext () const
| Returns const pointer to the user context.
void | setContext (const data::ConstElementPtr &ctx)
| Sets user context.
Public Member Functions inherited from isc::data::CfgToElement
virtual | ~CfgToElement ()
| Destructor.

## Static Public Member Functions
static SharedNetwork4Ptr | create (const std::string &name)
| Factory function creating an instance of the `SharedNetwork4`.
static bool | subnetsIncludeMatchClientId (const ConstSubnet4Ptr &first_subnet, const ClientClasses &client_classes)
| Checks if the shared network includes a subnet with the match client ID flag set to true.
Static Public Member Functions inherited from isc::data::UserContext
static data::ElementPtr | toElement (data::ConstElementPtr map)
| Copy an Element map.

## Additional Inherited Members
Public Types inherited from isc::dhcp::Network
enum class | Inheritance { NONE , PARENT_NETWORK , GLOBAL , ALL }
| Inheritance "mode" used when fetching an optional `Network` parameter. More...
typedef boost::shared_ptr< Network::RelayInfo > | RelayInfoPtr
| Pointer to the RelayInfo structure.
Protected Member Functions inherited from isc::dhcp::Network
FetchNetworkGlobalsFn | getFetchGlobalsFn () const
| Gets the optional callback function used to fetch globally configured parameters.
template<typename NumType>
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>.
template<typename ReturnType>
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< asiolink::IOAddress > | getGlobalProperty (util::Optional< asiolink::IOAddress > property, const int global_index, const int min_index=-1, const int max_index=-1) const
| The `getGlobalProperty` specialization for Optional<IOAddress>.
template<typename BaseType>
OptionPtr | getOptionProperty (OptionPtr(BaseType::*MethodPointer)(const Inheritance &inheritance) const, OptionPtr property, const Inheritance &inheritance) const
| Returns option pointer associated with a network using inheritance.
template<typename BaseType, typename ReturnType>
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.
Protected Attributes inherited from isc::dhcp::Network
ClientClasses | additional_classes_
| Additional classes.
util::Optional< std::string > | allocator_type_
| Allocator used for IP address allocations.
util::Optional< uint32_t > | cache_max_age_
| Value in seconds to use as cache maximal age.
util::Optional< double > | cache_threshold_
| Percentage of the lease lifetime to use as cache threshold.
util::Optional< bool > | calculate_tee_times_
| Enables calculation of T1 and T2 timers.
CfgOptionPtr | cfg_option_
| Pointer to the option data configuration for this subnet.
ClientClasses | client_classes_
| List of client classes allowed to use this network.
util::Optional< std::string > | ddns_conflict_resolution_mode_
| DDNS conflict resolution mode.
util::Optional< std::string > | ddns_generated_prefix_
| Prefix Kea should use when generating domain-names.
util::Optional< bool > | ddns_override_client_update_
| Should Kea perform updates, even if client requested delegation.
util::Optional< bool > | ddns_override_no_update_
| Should Kea perform updates, even if client requested no updates.
util::Optional< std::string > | ddns_qualifying_suffix_
| Suffix Kea should use when to qualify partial domain-names.
util::Optional< D2ClientConfig::ReplaceClientNameMode > | ddns_replace_client_name_mode_
| How Kea should handle the domain-name supplied by the client.
util::Optional< bool > | ddns_send_updates_
| Should Kea perform DNS updates.
util::Optional< uint32_t > | ddns_ttl_
| Explicit value to use for DNS TTL.
util::Optional< uint32_t > | ddns_ttl_max_
| Maximum value to use for DNS TTL.
util::Optional< uint32_t > | ddns_ttl_min_
| Minimum value to use for DNS TTL.
util::Optional< double > | ddns_ttl_percent_
| Percentage of the lease lifetime to use for DNS TTL.
util::Optional< bool > | ddns_update_on_renew_
| Should Kea perform updates when leases are extended.
util::Optional< std::string > | default_allocator_type_
| Default allocator type.
FetchNetworkGlobalsFn | fetch_globals_fn_
| Pointer to the optional callback used to fetch globally configured parameters inherited to the `Network` object.
util::Optional< std::string > | hostname_char_replacement_
| A string to replace invalid characters when scrubbing hostnames.
util::Optional< std::string > | hostname_char_set_
| Regular expression describing invalid characters for client hostnames.
util::Optional< std::string > | iface_name_
| Holds interface name for which this network is selected.
WeakNetworkPtr | parent_network_
| Pointer to another network that this network belongs to.
RelayInfo | relay_
| Relay information.
util::Optional< bool > | reservations_global_
| Enables global reservations.
util::Optional< bool > | reservations_in_subnet_
| Enables subnet reservations.
util::Optional< bool > | reservations_out_of_pool_
| Enables out-of-pool reservations optimization.
util::Optional< bool > | store_extended_info_
| Should Kea store additional client query data (e.g.
isc::util::Triplet< uint32_t > | t1_
| a isc::util::Triplet (min/default/max) holding allowed renew timer values
util::Optional< double > | t1_percent_
| Percentage of the lease lifetime to use when calculating T1 timer.
isc::util::Triplet< uint32_t > | t2_
| a isc::util::Triplet (min/default/max) holding allowed rebind timer values
util::Optional< double > | t2_percent_
| Percentage of the lease lifetime to use when calculating T2 timer.
isc::util::Triplet< uint32_t > | valid_
| a isc::util::Triplet (min/default/max) holding allowed valid lifetime values
Protected Attributes inherited from isc::data::BaseStampedElement
uint64_t | id_
| Database identifier of the configuration element.
boost::posix_time::ptime | timestamp_
| Holds timestamp value.
Protected Attributes inherited from isc::data::UserContext
data::ConstElementPtr | user_context_
| Pointer to the user context (may be NULL).

## Detailed Description

Shared network holding IPv4 subnets.

Specialization of the Network4 class for IPv4 shared networks.

Definition at line 51 of file shared_network.h.

## Constructor & Destructor Documentation

## ◆ SharedNetwork4()

isc::dhcp::SharedNetwork4::SharedNetwork4 | ( | const std::string & | name | ) |
| inline explicit

Constructor.

Sets name of the shared network.

Parameters

  name | Name of the shared network.

Definition at line 60 of file shared_network.h.

## Member Function Documentation

## ◆ add()

void isc::dhcp::SharedNetwork4::add | ( | const Subnet4Ptr & | subnet | ) |

Adds IPv4 subnet to a shared network.

Parameters

  subnet | Pointer to a subnet being added to this shared network.

Exceptions

  isc::BadValue | if subnet is null.
  isc::DuplicateSubnetID | if a subnet with the given subnet id already exists in this shared network.
  InvalidOperation | if a subnet is already associated with some shared network.

Definition at line 345 of file shared_network.cc.

## ◆ create()

SharedNetwork4Ptr isc::dhcp::SharedNetwork4::create | ( | const std::string & | name | ) |
| static

Factory function creating an instance of the `SharedNetwork4`.

This function should be used to create an instance of the shared network within a hooks library in cases when the library may be unloaded before the object is destroyed. This ensures that the ownership of the object by the Kea process is retained.

Parameters

  name | Name of the shared network.

Returns
  Pointer to the `SharedNetwork4` instance.

Definition at line 340 of file shared_network.cc.

## ◆ del()

void isc::dhcp::SharedNetwork4::del | ( | const SubnetID & | subnet_id | ) |

Removes subnet from a shared network.

Parameters

  subnet_id | Identifier of a subnet to be removed.

Exceptions

  BadValue | When specified subnet doesn't exist.

Definition at line 373 of file shared_network.cc.

## ◆ delAll()

void isc::dhcp::SharedNetwork4::delAll | ( |  | ) |

Removes all subnets from a shared network.

Definition at line 380 of file shared_network.cc.

## ◆ getAllSubnets()

const Subnet4SimpleCollection * isc::dhcp::SharedNetwork4::getAllSubnets | ( |  | ) | const
| inline

Returns a pointer to the collection of subnets within this shared network.

Definition at line 124 of file shared_network.h.

## ◆ getLabel()

virtual std::string isc::dhcp::SharedNetwork4::getLabel | ( |  | ) | const
| inline virtual

Generates an identifying label for logging.

Returns
  string containing the label

Reimplemented from isc::dhcp::Network.

Definition at line 206 of file shared_network.h.

## ◆ getName()

std::string isc::dhcp::SharedNetwork4::getName | ( |  | ) | const
| inline

Returns a name of the shared network.

Definition at line 77 of file shared_network.h.

## ◆ getNextSubnet()

ConstSubnet4Ptr isc::dhcp::SharedNetwork4::getNextSubnet | ( | const ConstSubnet4Ptr & | first_subnet,
|  | const SubnetID & | current_subnet ) const

Retrieves next available IPv4 subnet within shared network.

See documentation for SharedNetwork4::getNextSubnet.

Parameters

  first_subnet | Pointer to a subnet from which the caller is iterating over subnets within shared network. This is typically a subnet selected during "subnet selection" step.
  current_subnet | Identifier of a subnet for which next subnet is to be found.

Returns
  Pointer to next subnet or null pointer if no more subnets found.

Exceptions

  isc::BadValue | if invalid arguments specified, e.g. unable to find first or current subnet within shared network.

Definition at line 399 of file shared_network.cc.

## ◆ getPreferredSubnet()

ConstSubnet4Ptr isc::dhcp::SharedNetwork4::getPreferredSubnet | ( | const ConstSubnet4Ptr & | selected_subnet | ) | const

Attempts to find a subnet which is more likely to include available leases than selected subnet.

When allocating unreserved leases from a shared network it is important to remember from which subnet within the shared network we have been recently handing out leases. The allocation engine can use that information to start trying allocation of the leases from that subnet rather than from the default subnet selected for this client. Starting from the default subnet causes a risk of having to walk over many subnets with exhausted address pools before getting to the subnet with available leases. This method attempts to find such subnet by inspecting "last allocation" timestamps. The one with most recent timestamp is selected.

The preferred subnet must also fulfil the condition of equal client classes with the `selected_subnet`.

Todo
  Need extensions to this logic when we support more than one client class for a subnet.

Parameters

  selected_subnet | Pointer to a currently selected subnet.

Returns
  Pointer to a preferred subnet. It may be the same as `selected_subnet` if no better subnet was found.

Definition at line 405 of file shared_network.cc.

References isc::dhcp::Lease::TYPE_V4.

## ◆ getSubnet() [1/2]

Subnet4Ptr isc::dhcp::SharedNetwork4::getSubnet | ( | const std::string & | subnet_prefix | ) | const

Returns a subnet for a specified subnet prefix.

Parameters

  subnet_prefix | Subnet prefix.

Returns
  Shared pointer to a subnet using this prefix or null pointer if such subnet doesn't exist within shared network.

Definition at line 394 of file shared_network.cc.

## ◆ getSubnet() [2/2]

Subnet4Ptr isc::dhcp::SharedNetwork4::getSubnet | ( | const SubnetID & | subnet_id | ) | const

Returns a subnet for a specified subnet id.

Parameters

  subnet_id | Subnet identifier.

Returns
  Shared pointer to a subnet using this id or null pointer if such subnet doesn't exist within shared network.

Definition at line 389 of file shared_network.cc.

Referenced by replace().

## ◆ replace()

bool isc::dhcp::SharedNetwork4::replace | ( | const Subnet4Ptr & | subnet | ) |

Replaces IPv4 subnet in a shared network.

This method replaces a subnet by another subnet with the same ID. The prefix should be the same too.

Parameters

  subnet | Pointer to a subnet replacing the subnet with the same ID in this shared network.

Exceptions

  isc::BadValue | if subnet is null.
  InvalidOperation | if a subnet is already associated with some shared network.

Returns
  true if the operation succeeded, false otherwise.

Definition at line 353 of file shared_network.cc.

References getSubnet(), and isc_throw.

Here is the call graph for this function:

## ◆ setName()

void isc::dhcp::SharedNetwork4::setName | ( | const std::string & | name | ) |
| inline

Sets new name for the shared network.

Parameters

  name | New name for the shared network.

Definition at line 84 of file shared_network.h.

## ◆ subnetsIncludeMatchClientId()

bool isc::dhcp::SharedNetwork4::subnetsIncludeMatchClientId | ( | const ConstSubnet4Ptr & | first_subnet,
|  | const ClientClasses & | client_classes )
| static

Checks if the shared network includes a subnet with the match client ID flag set to true.

Parameters

  first_subnet | Pointer to the subnet from which iteration starts.
  client_classes | List of classes that the client belongs to.

Returns
  true if the shared network includes at least one subnet guarded by a given class with the match client ID flag set to true. False otherwise.

Definition at line 410 of file shared_network.cc.

## ◆ toElement()

ElementPtr isc::dhcp::SharedNetwork4::toElement | ( |  | ) | const
| virtual

Unparses shared network object.

Returns
  A pointer to unparsed shared network configuration.

Reimplemented from isc::dhcp::Network4.

Definition at line 422 of file shared_network.cc.

References isc::data::Element::create(), isc::data::Element::createList(), and isc::dhcp::Network4::toElement().

Here is the call graph for this function:

The documentation for this class was generated from the following files:

- shared_network.h
- shared_network.cc