7#ifndef SHARED_NETWORK_H
8#define SHARED_NETWORK_H
14#include <boost/enable_shared_from_this.hpp>
15#include <boost/multi_index/mem_fun.hpp>
16#include <boost/multi_index/hashed_index.hpp>
17#include <boost/multi_index/indexed_by.hpp>
18#include <boost/multi_index/ordered_index.hpp>
19#include <boost/multi_index/random_access_index.hpp>
20#include <boost/multi_index_container.hpp>
21#include <boost/shared_ptr.hpp>
52 public boost::enable_shared_from_this<SharedNetwork4> {
61 : name_(name), subnets_() {
159 const SubnetID& current_subnet)
const;
207 std::stringstream ss;
208 ss <<
"shared-network " << name_;
226typedef boost::multi_index_container<
229 boost::multi_index::indexed_by<
232 boost::multi_index::random_access<
233 boost::multi_index::tag<SharedNetworkRandomAccessIndexTag>
236 boost::multi_index::hashed_non_unique<
237 boost::multi_index::tag<SharedNetworkIdIndexTag>,
242 boost::multi_index::ordered_unique<
243 boost::multi_index::tag<SharedNetworkNameIndexTag>,
244 boost::multi_index::const_mem_fun<SharedNetwork4, std::string,
249 boost::multi_index::ordered_non_unique<
250 boost::multi_index::tag<SharedNetworkServerIdIndexTag>,
255 boost::multi_index::ordered_non_unique<
256 boost::multi_index::tag<SharedNetworkModificationTimeIndexTag>,
258 boost::posix_time::ptime,
273 public boost::enable_shared_from_this<SharedNetwork6> {
280 : name_(name), subnets_() {
378 const SubnetID& current_subnet)
const;
414 std::stringstream ss;
415 ss <<
"shared-network " << name_;
433typedef boost::multi_index_container<
436 boost::multi_index::indexed_by<
439 boost::multi_index::random_access<
440 boost::multi_index::tag<SharedNetworkRandomAccessIndexTag>
443 boost::multi_index::hashed_non_unique<
444 boost::multi_index::tag<SharedNetworkIdIndexTag>,
449 boost::multi_index::ordered_unique<
450 boost::multi_index::tag<SharedNetworkNameIndexTag>,
451 boost::multi_index::const_mem_fun<SharedNetwork6, std::string,
455 boost::multi_index::ordered_non_unique<
456 boost::multi_index::tag<SharedNetworkModificationTimeIndexTag>,
458 boost::posix_time::ptime,
471template<
typename ReturnPtrType,
typename CollectionType>
482 static ReturnPtrType
get(
const CollectionType& collection,
const std::string& name) {
483 auto& index = collection.template get<SharedNetworkNameIndexTag>();
484 auto sn = index.find(name);
485 if (sn != index.end()) {
489 return (ReturnPtrType());
The IOAddress class represents an IP addresses (version agnostic)
This class represents configuration element which is associated with database identifier and the modi...
boost::posix_time::ptime getModificationTime() const
Returns timestamp.
uint64_t getId() const
Returns element's database identifier.
Container for storing client class names.
Specialization of the Network object for DHCPv4 case.
virtual asiolink::IOAddress getServerId() const
Returns binary representation of the dhcp-server-identifier option (54).
Specialization of the Network object for DHCPv6 case.
Shared network holding IPv4 subnets.
std::string getName() const
Returns a name of the shared network.
const Subnet4SimpleCollection * getAllSubnets() const
Returns a pointer to the collection of subnets within this shared network.
bool replace(const Subnet4Ptr &subnet)
Replaces IPv4 subnet in a shared network.
static SharedNetwork4Ptr create(const std::string &name)
Factory function creating an instance of the SharedNetwork4.
void setName(const std::string &name)
Sets new name for the shared network.
ConstSubnet4Ptr getNextSubnet(const ConstSubnet4Ptr &first_subnet, const SubnetID ¤t_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.
virtual data::ElementPtr toElement() const
Unparses shared network object.
virtual std::string getLabel() const
Generates an identifying label for logging.
void add(const Subnet4Ptr &subnet)
Adds IPv4 subnet to a shared network.
void del(const SubnetID &subnet_id)
Removes subnet from a shared network.
Subnet4Ptr getSubnet(const SubnetID &subnet_id) const
Returns a subnet for a specified subnet id.
void delAll()
Removes all subnets from a shared network.
SharedNetwork4(const std::string &name)
Constructor.
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.
Shared network holding IPv6 subnets.
void setName(const std::string &name)
Sets new name for the shared network.
static SharedNetwork6Ptr create(const std::string &name)
Factory function creating an instance of the SharedNetwork6.
ConstSubnet6Ptr getPreferredSubnet(const ConstSubnet6Ptr &selected_subnet, const Lease::Type &lease_type) const
Attempts to find a subnet which is more likely to include available leases than selected subnet.
Subnet6Ptr getSubnet(const SubnetID &subnet_id) const
Returns a subnet for a specified subnet id.
SharedNetwork6(const std::string &name)
Constructor.
const Subnet6SimpleCollection * 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.
void del(const SubnetID &subnet_id)
Removes subnet from a shared network.
void add(const Subnet6Ptr &subnet)
Adds IPv6 subnet to a shared network.
ConstSubnet6Ptr getNextSubnet(const ConstSubnet6Ptr &first_subnet, const SubnetID ¤t_subnet) const
Retrieves next available IPv6 subnet within shared network.
virtual data::ElementPtr toElement() const
Unparses shared network object.
bool replace(const Subnet6Ptr &subnet)
Replaces IPv6 subnet in a shared network.
std::string getName() const
Returns a name of the shared network.
void delAll()
Removes all subnets from a shared network.
A class containing static convenience methods to fetch the shared networks from the containers.
static ReturnPtrType get(const CollectionType &collection, const std::string &name)
Fetches shared network by name.
boost::shared_ptr< Element > ElementPtr
boost::shared_ptr< Subnet4 > Subnet4Ptr
A pointer to a Subnet4 object.
SharedNetworkFetcher< SharedNetwork4Ptr, SharedNetwork4Collection > SharedNetworkFetcher4
Type of the SharedNetworkFetcher used for IPv4.
boost::multi_index_container< SharedNetwork6Ptr, boost::multi_index::indexed_by< boost::multi_index::random_access< boost::multi_index::tag< SharedNetworkRandomAccessIndexTag > >, boost::multi_index::hashed_non_unique< boost::multi_index::tag< SharedNetworkIdIndexTag >, boost::multi_index::const_mem_fun< data::BaseStampedElement, uint64_t, &data::BaseStampedElement::getId > >, boost::multi_index::ordered_unique< boost::multi_index::tag< SharedNetworkNameIndexTag >, boost::multi_index::const_mem_fun< SharedNetwork6, std::string, &SharedNetwork6::getName > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< SharedNetworkModificationTimeIndexTag >, boost::multi_index::const_mem_fun< data::BaseStampedElement, boost::posix_time::ptime, &data::BaseStampedElement::getModificationTime > > > > SharedNetwork6Collection
Multi index container holding shared networks.
boost::shared_ptr< const Subnet6 > ConstSubnet6Ptr
A const pointer to a Subnet6 object.
boost::shared_ptr< const Subnet4 > ConstSubnet4Ptr
A const pointer to a Subnet4 object.
boost::shared_ptr< Subnet6 > Subnet6Ptr
A pointer to a Subnet6 object.
boost::multi_index_container< Subnet4Ptr, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< boost::multi_index::tag< SubnetSubnetIdIndexTag >, boost::multi_index::const_mem_fun< Subnet, SubnetID, &Subnet::getID > >, boost::multi_index::ordered_unique< boost::multi_index::tag< SubnetPrefixIndexTag >, boost::multi_index::const_mem_fun< Subnet, std::string, &Subnet::toText > > > > Subnet4SimpleCollection
A simple collection of Subnet4 objects.
boost::shared_ptr< SharedNetwork6 > SharedNetwork6Ptr
Pointer to SharedNetwork6 object.
uint32_t SubnetID
Defines unique IPv4 or IPv6 subnet identifier.
boost::multi_index_container< Subnet6Ptr, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< boost::multi_index::tag< SubnetSubnetIdIndexTag >, boost::multi_index::const_mem_fun< Subnet, SubnetID, &Subnet::getID > >, boost::multi_index::ordered_unique< boost::multi_index::tag< SubnetPrefixIndexTag >, boost::multi_index::const_mem_fun< Subnet, std::string, &Subnet::toText > > > > Subnet6SimpleCollection
A simple collection of Subnet6 objects.
boost::multi_index_container< SharedNetwork4Ptr, boost::multi_index::indexed_by< boost::multi_index::random_access< boost::multi_index::tag< SharedNetworkRandomAccessIndexTag > >, boost::multi_index::hashed_non_unique< boost::multi_index::tag< SharedNetworkIdIndexTag >, boost::multi_index::const_mem_fun< data::BaseStampedElement, uint64_t, &data::BaseStampedElement::getId > >, boost::multi_index::ordered_unique< boost::multi_index::tag< SharedNetworkNameIndexTag >, boost::multi_index::const_mem_fun< SharedNetwork4, std::string, &SharedNetwork4::getName > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< SharedNetworkServerIdIndexTag >, boost::multi_index::const_mem_fun< Network4, asiolink::IOAddress, &Network4::getServerId > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< SharedNetworkModificationTimeIndexTag >, boost::multi_index::const_mem_fun< data::BaseStampedElement, boost::posix_time::ptime, &data::BaseStampedElement::getModificationTime > > > > SharedNetwork4Collection
Multi index container holding shared networks.
boost::shared_ptr< SharedNetwork4 > SharedNetwork4Ptr
Pointer to SharedNetwork4 object.
SharedNetworkFetcher< SharedNetwork6Ptr, SharedNetwork6Collection > SharedNetworkFetcher6
Type of the SharedNetworkFetcher used for IPv6.
Defines the logger used by the top-level component of kea-lfc.
Type
Type of lease or pool.
A tag for accessing index by id.
Tag for the index for searching by shared network modification time.
A tag for accessing index by shared network name.
A tag for accessing random access index.
A tag for accessing index by server identifier.