24#include <boost/enable_shared_from_this.hpp>
25#include <boost/multi_index/mem_fun.hpp>
26#include <boost/multi_index/indexed_by.hpp>
27#include <boost/multi_index/ordered_index.hpp>
28#include <boost/multi_index/random_access_index.hpp>
29#include <boost/multi_index_container.hpp>
30#include <boost/date_time/posix_time/posix_time.hpp>
31#include <boost/pointer_cast.hpp>
32#include <boost/shared_ptr.hpp>
90 std::pair<isc::asiolink::IOAddress, uint8_t>
get()
const {
143 bool anypool =
true)
const;
206 uint8_t hint_prefix_length)
const;
212 virtual std::string
toText()
const;
239 template<
typename SharedNetworkPtrType>
241 shared_network = boost::dynamic_pointer_cast<
423 uint8_t hint_prefix_length)
const;
441 std::stringstream ss;
442 ss <<
"subnet-id " <<
id_;
454 static std::pair<asiolink::IOAddress, uint8_t>
627 static std::pair<asiolink::IOAddress, uint8_t>
781 static std::pair<asiolink::IOAddress, uint8_t>
831typedef boost::multi_index_container<
835 boost::multi_index::indexed_by<
837 boost::multi_index::ordered_unique<
838 boost::multi_index::tag<SubnetSubnetIdIndexTag>,
839 boost::multi_index::const_mem_fun<Subnet, SubnetID, &Subnet::getID>
842 boost::multi_index::ordered_unique<
843 boost::multi_index::tag<SubnetPrefixIndexTag>,
844 boost::multi_index::const_mem_fun<Subnet, std::string, &Subnet::toText>
872typedef boost::multi_index_container<
876 boost::multi_index::indexed_by<
878 boost::multi_index::ordered_unique<
879 boost::multi_index::tag<SubnetSubnetIdIndexTag>,
880 boost::multi_index::const_mem_fun<Subnet, SubnetID, &Subnet::getID>
883 boost::multi_index::ordered_unique<
884 boost::multi_index::tag<SubnetPrefixIndexTag>,
885 boost::multi_index::const_mem_fun<Subnet, std::string, &Subnet::toText>
889 boost::multi_index::ordered_non_unique<
890 boost::multi_index::tag<SubnetServerIdIndexTag>,
896 boost::multi_index::ordered_non_unique<
897 boost::multi_index::tag<SubnetModificationTimeIndexTag>,
899 boost::posix_time::ptime,
911typedef boost::multi_index_container<
915 boost::multi_index::indexed_by<
917 boost::multi_index::ordered_unique<
918 boost::multi_index::tag<SubnetSubnetIdIndexTag>,
919 boost::multi_index::const_mem_fun<Subnet, SubnetID, &Subnet::getID>
922 boost::multi_index::ordered_unique<
923 boost::multi_index::tag<SubnetPrefixIndexTag>,
924 boost::multi_index::const_mem_fun<Subnet, std::string, &Subnet::toText>
951typedef boost::multi_index_container<
955 boost::multi_index::indexed_by<
957 boost::multi_index::ordered_unique<
958 boost::multi_index::tag<SubnetSubnetIdIndexTag>,
959 boost::multi_index::const_mem_fun<Subnet, SubnetID, &Subnet::getID>
962 boost::multi_index::ordered_unique<
963 boost::multi_index::tag<SubnetPrefixIndexTag>,
964 boost::multi_index::const_mem_fun<Subnet, std::string, &Subnet::toText>
967 boost::multi_index::ordered_non_unique<
968 boost::multi_index::tag<SubnetModificationTimeIndexTag>,
970 boost::posix_time::ptime,
983template<
typename ReturnPtrType,
typename CollectionType>
994 static ReturnPtrType
get(
const CollectionType& collection,
996 auto& index = collection.template get<SubnetSubnetIdIndexTag>();
997 auto s = index.find(subnet_id);
998 if (s != index.end()) {
1002 return (ReturnPtrType());
1017template <isc::util::DhcpSpace D>
1018struct AdapterSubnet {};
1032template <isc::util::DhcpSpace D>
1035template <isc::util::DhcpSpace D>
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.
PrefixLenMatchType
Type of preferred PD-pool prefix length selection criteria.
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.
Common interface representing a network to which the DHCP clients are connected.
WeakNetworkPtr parent_network_
Pointer to another network that this network belongs to.
A configuration holder for IPv4 subnet.
virtual bool clientSupported(const isc::dhcp::ClientClasses &client_classes) const
Checks whether this subnet and parent shared network supports the client that belongs to specified cl...
Cfg4o6 & get4o6()
Returns DHCP4o6 configuration parameters.
Subnet4Ptr getNextSubnet(const Subnet4Ptr &first_subnet) const
Returns next subnet within shared network.
virtual void createAllocators()
Instantiates the allocator and its state.
virtual data::ElementPtr toElement() const
Unparse a subnet object.
static Subnet4Ptr create(const isc::asiolink::IOAddress &prefix, uint8_t length, const util::Triplet< uint32_t > &t1, const util::Triplet< uint32_t > &t2, const util::Triplet< uint32_t > &valid_lifetime, const SubnetID id)
Factory function creating an instance of the Subnet4.
Subnet4(const isc::asiolink::IOAddress &prefix, uint8_t length, const util::Triplet< uint32_t > &t1, const util::Triplet< uint32_t > &t2, const util::Triplet< uint32_t > &valid_lifetime, const SubnetID id)
Constructor with all parameters.
const Cfg4o6 & get4o6() const
Returns const DHCP4o6 configuration parameters.
static std::pair< asiolink::IOAddress, uint8_t > parsePrefix(const std::string &prefix)
Converts subnet prefix to a pair of prefix/length pair.
A configuration holder for IPv6 subnet.
virtual bool clientSupported(const isc::dhcp::ClientClasses &client_classes) const
Checks whether this subnet and parent shared network supports the client that belongs to specified cl...
static Subnet6Ptr create(const isc::asiolink::IOAddress &prefix, uint8_t length, const util::Triplet< uint32_t > &t1, const util::Triplet< uint32_t > &t2, const util::Triplet< uint32_t > &preferred_lifetime, const util::Triplet< uint32_t > &valid_lifetime, const SubnetID id)
Factory function creating an instance of the Subnet4.
static std::pair< asiolink::IOAddress, uint8_t > parsePrefix(const std::string &prefix)
Converts subnet prefix to a pair of prefix/length pair.
virtual void createAllocators()
Instantiates the allocators and their states.
Subnet6Ptr getNextSubnet(const Subnet6Ptr &first_subnet) const
Returns next subnet within shared network.
virtual data::ElementPtr toElement() const
Unparse a subnet object.
Subnet6(const isc::asiolink::IOAddress &prefix, uint8_t length, const util::Triplet< uint32_t > &t1, const util::Triplet< uint32_t > &t2, const util::Triplet< uint32_t > &preferred_lifetime, const util::Triplet< uint32_t > &valid_lifetime, const SubnetID id)
Constructor with all parameters.
A class containing static convenience methods to fetch the subnets from the containers.
static ReturnPtrType get(const CollectionType &collection, const SubnetID &subnet_id)
Fetches subnets by id.
isc::util::uint128_t getPoolCapacity(Lease::Type type) const
Returns the number of possible leases for specified lease type.
void setSharedNetworkName(const std::string &shared_network_name)
Sets new shared network name.
isc::asiolink::IOAddress prefix_
a prefix of the subnet.
SubnetID getID() const
Returns unique ID for that subnet.
uint8_t prefix_len_
a prefix length of the subnet.
isc::util::uint128_t sumPoolCapacity(const PoolCollection &pools) const
Returns a sum of possible leases in all pools.
static void resetSubnetID()
Resets subnet-id counter to its initial value (1).
virtual data::ElementPtr toElement() const
Unparse a subnet object.
AllocatorPtr getAllocator(Lease::Type type) const
Returns lease allocator instance.
static SubnetID generateNextID()
returns the next unique Subnet-ID.
PoolCollection pools_ta_
collection of IPv6 temporary address pools in that subnet.
void getSharedNetwork(SharedNetworkPtrType &shared_network) const
Retrieves pointer to a shared network associated with a subnet.
void initAllocatorsAfterConfigure()
Calls initAfterConfigure for each allocator.
SubnetAllocationStatePtr getAllocationState(Lease::Type type) const
Returns subnet-specific allocation state.
PoolPtr getAnyPool(Lease::Type type)
Returns a pool without any address specified.
void addPool(const PoolPtr &pool)
Adds a new pool for the subnet.
virtual ~Subnet()
virtual destructor.
bool inRange(const isc::asiolink::IOAddress &addr) const
checks if specified address is in range.
std::map< Lease::Type, AllocatorPtr > allocators_
Lease allocators used by the subnet.
virtual std::string toText() const
Returns textual representation of the subnet (e.g.
void delPools(Lease::Type type)
Deletes all pools of specified type.
std::pair< isc::asiolink::IOAddress, uint8_t > get() const
Returns subnet parameters (prefix and prefix length).
virtual std::string getLabel() const
Generates an identifying label for logging.
static std::pair< asiolink::IOAddress, uint8_t > parsePrefixCommon(const std::string &prefix)
Converts subnet prefix to a pair of prefix/length pair.
void setAllocator(Lease::Type type, const AllocatorPtr &allocator)
Sets new allocator instance.
std::string getSharedNetworkName() const
Returns shared network name.
PoolCollection pools_
collection of IPv4 or non-temporary IPv6 pools in that subnet.
PoolCollection & getPoolsWritable(Lease::Type type)
Returns all pools (non-const variant).
const PoolPtr getPool(Lease::Type type, const isc::asiolink::IOAddress &addr, bool anypool=true) const
Returns a pool that specified address belongs to.
Subnet(const isc::asiolink::IOAddress &prefix, uint8_t len, const SubnetID id)
Protected constructor.
std::string shared_network_name_
Shared network name.
bool poolOverlaps(const Lease::Type &pool_type, const PoolPtr &pool) const
Checks if the specified pool overlaps with an existing pool.
virtual isc::asiolink::IOAddress default_pool() const =0
Returns the default address that will be used for pool selection.
PoolCollection pools_pd_
collection of IPv6 prefix pools in that subnet.
const PoolCollection & getPools(Lease::Type type) const
Returns all pools (const variant).
static SubnetID static_id_
keeps the subnet-id value.
virtual void checkType(Lease::Type type) const =0
Checks if used pool type is valid.
std::map< Lease::Type, SubnetAllocationStatePtr > allocation_states_
Holds subnet-specific allocation state.
virtual void createAllocators()=0
Instantiates the allocators and their states.
bool inPool(Lease::Type type, const isc::asiolink::IOAddress &addr) const
checks if the specified address is in pools.
void setSharedNetwork(const NetworkPtr &shared_network)
Assigns shared network to a subnet.
void setAllocationState(Lease::Type type, const SubnetAllocationStatePtr &allocation_state)
Sets subnet-specific allocation state.
boost::shared_ptr< Element > ElementPtr
boost::shared_ptr< Subnet > SubnetPtr
A generic pointer to either Subnet4 or Subnet6 object.
boost::shared_ptr< Subnet4 > Subnet4Ptr
A pointer to a Subnet4 object.
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.
typename AdapterSubnet< D >::type SubnetT
boost::shared_ptr< Subnet6 > Subnet6Ptr
A pointer to a Subnet6 object.
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 > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< SubnetModificationTimeIndexTag >, boost::multi_index::const_mem_fun< data::BaseStampedElement, boost::posix_time::ptime, &data::BaseStampedElement::getModificationTime > > > > Subnet6Collection
A collection of Subnet6 objects.
std::vector< PoolPtr > PoolCollection
a container for either IPv4 or IPv6 Pools
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< Pool > PoolPtr
a pointer to either IPv4 or IPv6 Pool
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 > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< SubnetServerIdIndexTag >, boost::multi_index::const_mem_fun< Network4, asiolink::IOAddress, &Network4::getServerId > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< SubnetModificationTimeIndexTag >, boost::multi_index::const_mem_fun< data::BaseStampedElement, boost::posix_time::ptime, &data::BaseStampedElement::getModificationTime > > > > Subnet4Collection
A collection of Subnet4 objects.
boost::shared_ptr< SubnetT< D > > SubnetTPtr
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::shared_ptr< Network > NetworkPtr
Pointer to the Network object.
boost::shared_ptr< Allocator > AllocatorPtr
Defines a pointer to an allocator.
boost::shared_ptr< SubnetAllocationState > SubnetAllocationStatePtr
boost::multiprecision::checked_uint128_t uint128_t
Defines the logger used by the top-level component of kea-lfc.
This structure contains information about DHCP4o6 (RFC7341)
Type
Type of lease or pool.
Tag for the index for searching by subnet modification time.
Tag for the index for searching by subnet prefix.
Tag for the index for searching by server identifier.
Tag for the index for searching by subnet identifier.