23 #include <boost/multi_index/mem_fun.hpp> 24 #include <boost/multi_index/indexed_by.hpp> 25 #include <boost/multi_index/ordered_index.hpp> 26 #include <boost/multi_index/random_access_index.hpp> 27 #include <boost/multi_index_container.hpp> 28 #include <boost/date_time/posix_time/posix_time.hpp> 29 #include <boost/pointer_cast.hpp> 30 #include <boost/scoped_ptr.hpp> 31 #include <boost/shared_ptr.hpp> 87 std::pair<isc::asiolink::IOAddress, uint8_t>
get()
const {
140 bool anypool =
true)
const;
203 uint8_t hint_prefix_length)
const;
209 virtual std::string
toText()
const;
236 template<
typename SharedNetworkPtrType>
238 shared_network = boost::dynamic_pointer_cast<
362 if (static_id_ == SUBNET_ID_MAX) {
366 return (static_id_++);
408 uint8_t hint_prefix_length)
const;
433 static std::pair<asiolink::IOAddress, uint8_t>
543 Subnet4Ptr getNextSubnet(
const Subnet4Ptr& first_subnet)
const;
557 Subnet4Ptr getNextSubnet(
const Subnet4Ptr& first_subnet,
599 static std::pair<asiolink::IOAddress, uint8_t>
600 parsePrefix(
const std::string& prefix);
705 Subnet6Ptr getNextSubnet(
const Subnet6Ptr& first_subnet)
const;
719 Subnet6Ptr getNextSubnet(
const Subnet6Ptr& first_subnet,
745 static std::pair<asiolink::IOAddress, uint8_t>
746 parsePrefix(
const std::string& prefix);
794 typedef boost::multi_index_container<
798 boost::multi_index::indexed_by<
800 boost::multi_index::ordered_unique<
801 boost::multi_index::tag<SubnetSubnetIdIndexTag>,
802 boost::multi_index::const_mem_fun<Subnet, SubnetID, &Subnet::getID>
805 boost::multi_index::ordered_unique<
806 boost::multi_index::tag<SubnetPrefixIndexTag>,
807 boost::multi_index::const_mem_fun<Subnet, std::string, &Subnet::toText>
835 typedef boost::multi_index_container<
839 boost::multi_index::indexed_by<
841 boost::multi_index::ordered_unique<
842 boost::multi_index::tag<SubnetSubnetIdIndexTag>,
843 boost::multi_index::const_mem_fun<Subnet, SubnetID, &Subnet::getID>
846 boost::multi_index::ordered_unique<
847 boost::multi_index::tag<SubnetPrefixIndexTag>,
848 boost::multi_index::const_mem_fun<Subnet, std::string, &Subnet::toText>
852 boost::multi_index::ordered_non_unique<
853 boost::multi_index::tag<SubnetServerIdIndexTag>,
859 boost::multi_index::ordered_non_unique<
860 boost::multi_index::tag<SubnetModificationTimeIndexTag>,
862 boost::posix_time::ptime,
874 typedef boost::multi_index_container<
878 boost::multi_index::indexed_by<
880 boost::multi_index::ordered_unique<
881 boost::multi_index::tag<SubnetSubnetIdIndexTag>,
882 boost::multi_index::const_mem_fun<Subnet, SubnetID, &Subnet::getID>
885 boost::multi_index::ordered_unique<
886 boost::multi_index::tag<SubnetPrefixIndexTag>,
887 boost::multi_index::const_mem_fun<Subnet, std::string, &Subnet::toText>
914 typedef boost::multi_index_container<
918 boost::multi_index::indexed_by<
920 boost::multi_index::ordered_unique<
921 boost::multi_index::tag<SubnetSubnetIdIndexTag>,
922 boost::multi_index::const_mem_fun<Subnet, SubnetID, &Subnet::getID>
925 boost::multi_index::ordered_unique<
926 boost::multi_index::tag<SubnetPrefixIndexTag>,
927 boost::multi_index::const_mem_fun<Subnet, std::string, &Subnet::toText>
930 boost::multi_index::ordered_non_unique<
931 boost::multi_index::tag<SubnetModificationTimeIndexTag>,
932 boost::multi_index::const_mem_fun<data::BaseStampedElement,
933 boost::posix_time::ptime,
946 template<
typename ReturnPtrType,
typename CollectionType>
957 static ReturnPtrType
get(
const CollectionType& collection,
959 auto& index = collection.template get<SubnetSubnetIdIndexTag>();
960 auto s = index.find(subnet_id);
961 if (s != index.end()) {
965 return (ReturnPtrType());
980 template <isc::util::DhcpSpace D>
981 struct AdapterSubnet {};
995 template <isc::util::DhcpSpace D>
996 using SubnetT =
typename AdapterSubnet<D>::type;
998 template <isc::util::DhcpSpace D>
WeakNetworkPtr parent_network_
Pointer to another network that this network belongs to.
SubnetAllocationStatePtr getAllocationState(Lease::Type type) const
Returns subnet-specific allocation state.
boost::shared_ptr< Network > NetworkPtr
Pointer to the Network object.
Tag for the index for searching by subnet identifier.
Cfg4o6 & get4o6()
Returns DHCP4o6 configuration parameters.
typename AdapterSubnet< D >::type SubnetT
bool inRange(const isc::asiolink::IOAddress &addr) const
checks if specified address is in range.
void setAllocator(Lease::Type type, const AllocatorPtr &allocator)
Sets new allocator instance.
boost::shared_ptr< Subnet4 > Subnet4Ptr
A pointer to a Subnet4 object.
void addPool(const PoolPtr &pool)
Adds a new pool for the subnet.
boost::shared_ptr< Element > ElementPtr
std::vector< PoolPtr > PoolCollection
a container for either IPv4 or IPv6 Pools
Tag for the index for searching by subnet prefix.
std::map< Lease::Type, AllocatorPtr > allocators_
Lease allocators used by the subnet.
A configuration holder for IPv4 subnet.
boost::shared_ptr< Pool > PoolPtr
a pointer to either IPv4 or IPv6 Pool
bool inPool(Lease::Type type, const isc::asiolink::IOAddress &addr) const
checks if the specified address is in pools.
void setAllocationState(Lease::Type type, const SubnetAllocationStatePtr &allocation_state)
Sets subnet-specific allocation state.
uint8_t prefix_len_
a prefix length of the subnet.
A class containing static convenience methods to fetch the subnets from the containers.
Specialization of the Network object for DHCPv6 case.
boost::shared_ptr< SubnetT< D > > SubnetTPtr
SubnetID getID() const
Returns unique ID for that subnet.
Tag for the index for searching by server identifier.
AllocatorPtr getAllocator(Lease::Type type) const
Returns lease allocator instance.
PrefixLenMatchType
Type of preferred PD-pool prefix length selection criteria.
std::string shared_network_name_
Shared network name.
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.
This structure contains information about DHCP4o6 (RFC7341)
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.
void getSharedNetwork(SharedNetworkPtrType &shared_network) const
Retrieves pointer to a shared network associated with a subnet.
boost::posix_time::ptime getModificationTime() const
Returns timestamp.
Common interface representing a network to which the DHCP clients are connected.
boost::shared_ptr< const Subnet6 > ConstSubnet6Ptr
A const pointer to a Subnet6 object.
const PoolCollection & getPools(Lease::Type type) const
Returns all pools (const variant).
boost::shared_ptr< SubnetAllocationState > SubnetAllocationStatePtr
static SubnetID static_id_
keeps the subnet-id value.
void setSharedNetworkName(const std::string &shared_network_name)
Sets new shared network name.
static void resetSubnetID()
Resets subnet-id counter to its initial value (1).
const Cfg4o6 & get4o6() const
Returns const DHCP4o6 configuration parameters.
std::string getSharedNetworkName() const
Returns shared network name.
uint64_t sumPoolCapacity(const PoolCollection &pools) const
Returns a sum of possible leases in all pools.
static std::pair< asiolink::IOAddress, uint8_t > parsePrefixCommon(const std::string &prefix)
Converts subnet prefix to a pair of prefix/length pair.
uint64_t getPoolCapacity(Lease::Type type) const
Returns the number of possible leases for specified lease type.
isc::asiolink::IOAddress prefix_
a prefix of the subnet.
PoolCollection pools_
collection of IPv4 or non-temporary IPv6 pools in that subnet.
virtual bool clientSupported(const isc::dhcp::ClientClasses &client_classes) const
Checks whether this network supports client that belongs to specified classes.
bool poolOverlaps(const Lease::Type &pool_type, const PoolPtr &pool) const
Checks if the specified pool overlaps with an existing pool.
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.
virtual data::ElementPtr toElement() const
Unparse a subnet 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.
Defines the logger used by the top-level component of kea-lfc.
PoolPtr getAnyPool(Lease::Type type)
Returns a pool without any address specified.
boost::shared_ptr< const Subnet4 > ConstSubnet4Ptr
A const pointer to a Subnet4 object.
void setSharedNetwork(const NetworkPtr &shared_network)
Assigns shared network to a subnet.
A configuration holder for IPv6 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.
Type
Type of lease or pool.
This class represents configuration element which is associated with database identifier and the modi...
virtual asiolink::IOAddress getServerId() const
Returns binary representation of the dhcp-server-identifier option (54).
virtual void checkType(Lease::Type type) const =0
Checks if used pool type is valid.
Specialization of the Network object for DHCPv4 case.
void delPools(Lease::Type type)
Deletes all pools of specified type.
Subnet(const isc::asiolink::IOAddress &prefix, uint8_t len, const SubnetID id)
Protected constructor.
boost::shared_ptr< Subnet6 > Subnet6Ptr
A pointer to a Subnet6 object.
PoolCollection pools_ta_
collection of IPv6 temporary address pools in that subnet.
The IOAddress class represents an IP addresses (version agnostic)
boost::shared_ptr< Allocator > AllocatorPtr
Defines a pointer to an allocator.
Tag for the index for searching by subnet modification time.
PoolCollection pools_pd_
collection of IPv6 prefix pools in that subnet.
virtual isc::asiolink::IOAddress default_pool() const =0
Returns the default address that will be used for pool selection.
Container for storing client class names.
virtual std::string toText() const
Returns textual representation of the subnet (e.g.
static SubnetID generateNextID()
returns the next unique Subnet-ID.
std::map< Lease::Type, SubnetAllocationStatePtr > allocation_states_
Holds subnet-specific allocation state.
boost::shared_ptr< Subnet > SubnetPtr
A generic pointer to either Subnet4 or Subnet6 object.
uint32_t SubnetID
Defines unique IPv4 or IPv6 subnet identifier.
virtual ~Subnet()
virtual destructor.