| Kea 3.0.2-git

subnet.h
Go to the documentation of this file.
1// Copyright (C) 2012-2025 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#ifndef SUBNET_H
8#define SUBNET_H
9
10#include <asiolink/io_address.h>
11#include <cc/data.h>
12#include <cc/user_context.h>
13#include <dhcp/option_space_container.h>
14#include <dhcpsrv/allocator.h>
15#include <dhcpsrv/allocation_state.h>
16#include <dhcpsrv/lease.h>
17#include <dhcpsrv/network.h>
18#include <dhcpsrv/pool.h>
19#include <dhcpsrv/subnet_id.h>
20#include <util/bigints.h>
21#include <util/dhcp_space.h>
22#include <util/triplet.h>
23
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>
33
34#include <cstdint>
35#include <map>
36#include <utility>
37
38 namespace isc {
39 namespace dhcp {
40
41 class Subnet : public virtual Network {
42 public:
43
49 bool inRange(const isc::asiolink::IOAddress& addr) const;
50
65 bool inPool(Lease::Type type, const isc::asiolink::IOAddress& addr) const;
66
76 bool inPool(Lease::Type type,
77 const isc::asiolink::IOAddress& addr,
78 const ClientClasses& client_classes) const;
79
83 SubnetID getID() const {
84 return (id_);
85 }
86
90 std::pair<isc::asiolink::IOAddress, uint8_t> get() const {
91 return (std::make_pair(prefix_, prefix_len_));
92 }
93
115 void addPool(const PoolPtr& pool);
116
122 void delPools(Lease::Type type);
123
142 const PoolPtr getPool(Lease::Type type, const isc::asiolink::IOAddress& addr,
143 bool anypool = true) const;
144
152 const PoolPtr getPool(Lease::Type type,
153 const ClientClasses& client_classes,
154 const isc::asiolink::IOAddress& addr) const;
155
160 PoolPtr getAnyPool(Lease::Type type) {
161 return (getPool(type, default_pool()));
162 }
163
168 virtual isc::asiolink::IOAddress default_pool() const = 0;
169
176 const PoolCollection& getPools(Lease::Type type) const;
177
181 isc::util::uint128_t getPoolCapacity(Lease::Type type) const;
182
189 isc::util::uint128_t getPoolCapacity(Lease::Type type,
190 const ClientClasses& client_classes) const;
191
203 isc::util::uint128_t getPoolCapacity(Lease::Type type,
204 const ClientClasses& client_classes,
205 Allocator::PrefixLenMatchType prefix_length_match,
206 uint8_t hint_prefix_length) const;
207
212 virtual std::string toText() const;
213
230 template<typename SharedNetworkPtrType>
231 void getSharedNetwork(SharedNetworkPtrType& shared_network) const {
232 shared_network = boost::dynamic_pointer_cast<
233 typename SharedNetworkPtrType::element_type>(parent_network_.lock());
234 }
235
243 void setSharedNetwork(const NetworkPtr& shared_network) {
244 parent_network_ = shared_network;
245 }
246
250 std::string getSharedNetworkName() const {
251 return (shared_network_name_);
252 }
253
266 void setSharedNetworkName(const std::string& shared_network_name) {
267 shared_network_name_ = shared_network_name;
268 }
269
276 PoolCollection& getPoolsWritable(Lease::Type type);
277
288 AllocatorPtr getAllocator(Lease::Type type) const;
289
297 void setAllocator(Lease::Type type, const AllocatorPtr& allocator);
298
305 SubnetAllocationStatePtr getAllocationState(Lease::Type type) const;
306
311 void setAllocationState(Lease::Type type, const SubnetAllocationStatePtr& allocation_state);
312
320 virtual void createAllocators() = 0;
321
323 void initAllocatorsAfterConfigure();
324
325 protected:
326
328 //
335 Subnet(const isc::asiolink::IOAddress& prefix, uint8_t len,
336 const SubnetID id);
337
342 virtual ~Subnet() { }
343
352 virtual void checkType(Lease::Type type) const = 0;
353
358 isc::util::uint128_t sumPoolCapacity(const PoolCollection& pools) const;
359
365 isc::util::uint128_t sumPoolCapacity(const PoolCollection& pools,
366 const ClientClasses& client_classes) const;
367
380 isc::util::uint128_t sumPoolCapacity(const PoolCollection& pools,
381 const ClientClasses& client_classes,
382 Allocator::PrefixLenMatchType prefix_length_match,
383 uint8_t hint_prefix_length) const;
384
393 bool poolOverlaps(const Lease::Type& pool_type, const PoolPtr& pool) const;
394
398 virtual data::ElementPtr toElement() const;
399
400 virtual std::string getLabel() const {
401 std::stringstream ss;
402 ss << "subnet-id " << id_;
403 return (ss.str());
404 }
405
414 static std::pair<asiolink::IOAddress, uint8_t>
415 parsePrefixCommon(const std::string& prefix);
416
421 SubnetID id_;
422
424 PoolCollection pools_;
425
427 PoolCollection pools_ta_;
428
430 PoolCollection pools_pd_;
431
433 isc::asiolink::IOAddress prefix_;
434
436 uint8_t prefix_len_;
437
439 std::string shared_network_name_;
440
442 std::map<Lease::Type, AllocatorPtr> allocators_;
443
445 std::map<Lease::Type, SubnetAllocationStatePtr> allocation_states_;
446};
447
449 typedef boost::shared_ptr<Subnet> SubnetPtr;
450
452 typedef boost::shared_ptr<const Subnet> ConstSubnetPtr;
453
454
455 class Subnet4;
456
458 typedef boost::shared_ptr<const Subnet4> ConstSubnet4Ptr;
459
461 typedef boost::shared_ptr<Subnet4> Subnet4Ptr;
462
468 class Subnet4 : public virtual Subnet, public virtual Network4, public boost::enable_shared_from_this<Subnet4> {
469 public:
470
481 Subnet4(const isc::asiolink::IOAddress& prefix, uint8_t length,
482 const util::Triplet<uint32_t>& t1,
483 const util::Triplet<uint32_t>& t2,
484 const util::Triplet<uint32_t>& valid_lifetime,
485 const SubnetID id);
486
506 static Subnet4Ptr
507 create(const isc::asiolink::IOAddress& prefix, uint8_t length,
508 const util::Triplet<uint32_t>& t1,
509 const util::Triplet<uint32_t>& t2,
510 const util::Triplet<uint32_t>& valid_lifetime,
511 const SubnetID id);
512
525 ConstSubnet4Ptr getNextSubnet(const ConstSubnet4Ptr& first_subnet) const;
526
539 ConstSubnet4Ptr getNextSubnet(const ConstSubnet4Ptr& first_subnet,
540 const ClientClasses& client_classes) const;
541
553 virtual bool
554 clientSupported(const isc::dhcp::ClientClasses& client_classes) const;
555
560 Cfg4o6& get4o6() {
561 return (dhcp4o6_);
562 }
563
568 const Cfg4o6& get4o6() const {
569 return (dhcp4o6_);
570 }
571
575 virtual data::ElementPtr toElement() const;
576
584 virtual void createAllocators();
585
590 static std::pair<asiolink::IOAddress, uint8_t>
591 parsePrefix(const std::string& prefix);
592
593 private:
594
596 Subnet4(const Subnet4&) = delete;
597
599 Subnet4& operator=(const Subnet4&) = delete;
600
604 virtual isc::asiolink::IOAddress default_pool() const {
605 return (isc::asiolink::IOAddress("0.0.0.0"));
606 }
607
614 virtual void checkType(Lease::Type type) const;
615
617 Cfg4o6 dhcp4o6_;
618};
619
620 class Subnet6;
621
623 typedef boost::shared_ptr<const Subnet6> ConstSubnet6Ptr;
624
626 typedef boost::shared_ptr<Subnet6> Subnet6Ptr;
627
633 class Subnet6 : public virtual Subnet, public virtual Network6, public boost::enable_shared_from_this<Subnet6> {
634 public:
635
648 Subnet6(const isc::asiolink::IOAddress& prefix, uint8_t length,
649 const util::Triplet<uint32_t>& t1,
650 const util::Triplet<uint32_t>& t2,
651 const util::Triplet<uint32_t>& preferred_lifetime,
652 const util::Triplet<uint32_t>& valid_lifetime,
653 const SubnetID id);
654
675 static Subnet6Ptr
676 create(const isc::asiolink::IOAddress& prefix, uint8_t length,
677 const util::Triplet<uint32_t>& t1,
678 const util::Triplet<uint32_t>& t2,
679 const util::Triplet<uint32_t>& preferred_lifetime,
680 const util::Triplet<uint32_t>& valid_lifetime,
681 const SubnetID id);
682
695 ConstSubnet6Ptr getNextSubnet(const ConstSubnet6Ptr& first_subnet) const;
696
709 ConstSubnet6Ptr getNextSubnet(const ConstSubnet6Ptr& first_subnet,
710 const ClientClasses& client_classes) const;
711
723 virtual bool
724 clientSupported(const isc::dhcp::ClientClasses& client_classes) const;
725
733 virtual void createAllocators();
734
738 virtual data::ElementPtr toElement() const;
739
744 static std::pair<asiolink::IOAddress, uint8_t>
745 parsePrefix(const std::string& prefix);
746
747 private:
748
750 Subnet6(const Subnet6&) = delete;
751
753 Subnet6& operator=(const Subnet6&) = delete;
754
758 virtual isc::asiolink::IOAddress default_pool() const {
759 return (isc::asiolink::IOAddress("::"));
760 }
761
768 virtual void checkType(Lease::Type type) const;
769
770};
771
774
775
777 struct SubnetSubnetIdIndexTag { };
778
780 struct SubnetPrefixIndexTag { };
781
783 struct SubnetServerIdIndexTag { };
784
786 struct SubnetModificationTimeIndexTag { };
787
794 typedef boost::multi_index_container<
795 // Multi index container holds pointers to the subnets.
796 Subnet4Ptr,
797 // The following holds all indexes.
798 boost::multi_index::indexed_by<
799 // First index allows for searching using subnet identifier.
800 boost::multi_index::ordered_unique<
801 boost::multi_index::tag<SubnetSubnetIdIndexTag>,
802 boost::multi_index::const_mem_fun<Subnet, SubnetID, &Subnet::getID>
803 >,
804 // Second index allows for searching using an output from toText function.
805 boost::multi_index::ordered_unique<
806 boost::multi_index::tag<SubnetPrefixIndexTag>,
807 boost::multi_index::const_mem_fun<Subnet, std::string, &Subnet::toText>
808 >
809 >
810> Subnet4SimpleCollection;
811
835 typedef boost::multi_index_container<
836 // Multi index container holds pointers to the subnets.
837 Subnet4Ptr,
838 // The following holds all indexes.
839 boost::multi_index::indexed_by<
840 // First index allows for searching using subnet identifier.
841 boost::multi_index::ordered_unique<
842 boost::multi_index::tag<SubnetSubnetIdIndexTag>,
843 boost::multi_index::const_mem_fun<Subnet, SubnetID, &Subnet::getID>
844 >,
845 // Second index allows for searching using an output from toText function.
846 boost::multi_index::ordered_unique<
847 boost::multi_index::tag<SubnetPrefixIndexTag>,
848 boost::multi_index::const_mem_fun<Subnet, std::string, &Subnet::toText>
849 >,
850
851 // Third index allows for searching using an output from getServerId.
852 boost::multi_index::ordered_non_unique<
853 boost::multi_index::tag<SubnetServerIdIndexTag>,
854 boost::multi_index::const_mem_fun<Network4, asiolink::IOAddress,
855 &Network4::getServerId>
856 >,
857
858 // Forth index allows for searching using subnet modification time.
859 boost::multi_index::ordered_non_unique<
860 boost::multi_index::tag<SubnetModificationTimeIndexTag>,
861 boost::multi_index::const_mem_fun<data::BaseStampedElement,
862 boost::posix_time::ptime,
863 &data::BaseStampedElement::getModificationTime>
864 >
865 >
866> Subnet4Collection;
867
874 typedef boost::multi_index_container<
875 // Multi index container holds pointers to the subnets.
876 Subnet6Ptr,
877 // The following holds all indexes.
878 boost::multi_index::indexed_by<
879 // First index allows for searching using subnet identifier.
880 boost::multi_index::ordered_unique<
881 boost::multi_index::tag<SubnetSubnetIdIndexTag>,
882 boost::multi_index::const_mem_fun<Subnet, SubnetID, &Subnet::getID>
883 >,
884 // Second index allows for searching using an output from toText function.
885 boost::multi_index::ordered_unique<
886 boost::multi_index::tag<SubnetPrefixIndexTag>,
887 boost::multi_index::const_mem_fun<Subnet, std::string, &Subnet::toText>
888 >
889 >
890> Subnet6SimpleCollection;
891
914 typedef boost::multi_index_container<
915 // Multi index container holds pointers to the subnets.
916 Subnet6Ptr,
917 // The following holds all indexes.
918 boost::multi_index::indexed_by<
919 // First index allows for searching using subnet identifier.
920 boost::multi_index::ordered_unique<
921 boost::multi_index::tag<SubnetSubnetIdIndexTag>,
922 boost::multi_index::const_mem_fun<Subnet, SubnetID, &Subnet::getID>
923 >,
924 // Second index allows for searching using an output from toText function.
925 boost::multi_index::ordered_unique<
926 boost::multi_index::tag<SubnetPrefixIndexTag>,
927 boost::multi_index::const_mem_fun<Subnet, std::string, &Subnet::toText>
928 >,
929 // Third index allows for searching using subnet modification time.
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,
934 &data::BaseStampedElement::getModificationTime>
935 >
936 >
937> Subnet6Collection;
938
946 template<typename ReturnPtrType, typename CollectionType>
947 class SubnetFetcher {
948 public:
949
957 static ReturnPtrType get(const CollectionType& collection,
958 const SubnetID& subnet_id) {
959 auto& index = collection.template get<SubnetSubnetIdIndexTag>();
960 auto s = index.find(subnet_id);
961 if (s != index.end()) {
962 return (*s);
963 }
964 // No subnet found. Return null pointer.
965 return (ReturnPtrType());
966 }
967};
968
970 using SubnetFetcher4 = SubnetFetcher<Subnet4Ptr, Subnet4Collection>;
971
973 using SubnetFetcher6 = SubnetFetcher<Subnet6Ptr, Subnet6Collection>;
975
978 namespace {
979
980 template <isc::util::DhcpSpace D>
981 struct AdapterSubnet {};
982
983 template <>
984 struct AdapterSubnet<isc::util::DHCPv4> {
985 using type = Subnet4;
986};
987
988 template <>
989 struct AdapterSubnet<isc::util::DHCPv6> {
990 using type = Subnet6;
991};
992
993} // namespace
994
995 template <isc::util::DhcpSpace D>
996 using SubnetT = typename AdapterSubnet<D>::type;
997
998 template <isc::util::DhcpSpace D>
999 using SubnetTPtr = boost::shared_ptr<SubnetT<D>>;
1000
1001 template <isc::util::DhcpSpace D>
1002 using ConstSubnetTPtr = boost::shared_ptr<const SubnetT<D>>;
1004
1005} // end of isc::dhcp namespace
1006} // end of isc namespace
1007
1008#endif // SUBNET_H
allocation_state.h
allocator.h
bigints.h
isc::asiolink::IOAddress
The IOAddress class represents an IP addresses (version agnostic).
Definition io_address.h:45
isc::data::BaseStampedElement
This class represents configuration element which is associated with database identifier and the modi...
Definition base_stamped_element.h:30
isc::data::BaseStampedElement::getModificationTime
boost::posix_time::ptime getModificationTime() const
Returns timestamp.
Definition base_stamped_element.h:61
isc::dhcp::Allocator::PrefixLenMatchType
PrefixLenMatchType
Type of preferred PD-pool prefix length selection criteria.
Definition allocator.h:61
isc::dhcp::ClientClasses
Container for storing client class names.
Definition classify.h:109
isc::dhcp::Network4
Specialization of the Network object for DHCPv4 case.
Definition network.h:1325
isc::dhcp::Network4::getServerId
virtual asiolink::IOAddress getServerId() const
Returns binary representation of the dhcp-server-identifier option (54).
Definition network.cc:339
isc::dhcp::Network4::Network4
Network4()
Constructor.
Definition network.h:1329
isc::dhcp::Network6::Network6
Network6()
Constructor.
Definition network.h:1490
isc::dhcp::Network::Network
Network()
Constructor.
Definition network.h:213
isc::dhcp::Network::parent_network_
WeakNetworkPtr parent_network_
Pointer to another network that this network belongs to.
Definition network.h:1317
isc::dhcp::Subnet4
A configuration holder for IPv4 subnet.
Definition subnet.h:468
isc::dhcp::Subnet4::clientSupported
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...
Definition subnet.cc:319
isc::dhcp::Subnet4::get4o6
Cfg4o6 & get4o6()
Returns DHCP4o6 configuration parameters.
Definition subnet.h:560
isc::dhcp::Subnet4::getNextSubnet
ConstSubnet4Ptr getNextSubnet(const ConstSubnet4Ptr &first_subnet) const
Returns next subnet within shared network.
Definition subnet.cc:280
isc::dhcp::Subnet4::createAllocators
virtual void createAllocators()
Instantiates the allocator and its state.
Definition subnet.cc:755
isc::dhcp::Subnet4::toElement
virtual data::ElementPtr toElement() const
Unparse a subnet object.
Definition subnet.cc:794
isc::dhcp::Subnet4::create
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.
Definition subnet.cc:263
isc::dhcp::Subnet4::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.
Definition subnet.cc:246
isc::dhcp::Subnet4::get4o6
const Cfg4o6 & get4o6() const
Returns const DHCP4o6 configuration parameters.
Definition subnet.h:568
isc::dhcp::Subnet4::parsePrefix
static std::pair< asiolink::IOAddress, uint8_t > parsePrefix(const std::string &prefix)
Converts subnet prefix to a pair of prefix/length pair.
Definition subnet.cc:818
isc::dhcp::Subnet6
A configuration holder for IPv6 subnet.
Definition subnet.h:633
isc::dhcp::Subnet6::clientSupported
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...
Definition subnet.cc:727
isc::dhcp::Subnet6::create
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.
Definition subnet.cc:651
isc::dhcp::Subnet6::parsePrefix
static std::pair< asiolink::IOAddress, uint8_t > parsePrefix(const std::string &prefix)
Converts subnet prefix to a pair of prefix/length pair.
Definition subnet.cc:935
isc::dhcp::Subnet6::createAllocators
virtual void createAllocators()
Instantiates the allocators and their states.
Definition subnet.cc:828
isc::dhcp::Subnet6::toElement
virtual data::ElementPtr toElement() const
Unparse a subnet object.
Definition subnet.cc:906
isc::dhcp::Subnet6::getNextSubnet
ConstSubnet6Ptr getNextSubnet(const ConstSubnet6Ptr &first_subnet) const
Returns next subnet within shared network.
Definition subnet.cc:689
isc::dhcp::Subnet6::Subnet6
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.
Definition subnet.cc:631
isc::dhcp::SubnetFetcher
A class containing static convenience methods to fetch the subnets from the containers.
Definition subnet.h:947
isc::dhcp::SubnetFetcher::get
static ReturnPtrType get(const CollectionType &collection, const SubnetID &subnet_id)
Fetches subnets by id.
Definition subnet.h:957
isc::dhcp::Subnet::getPoolCapacity
isc::util::uint128_t getPoolCapacity(Lease::Type type) const
Returns the number of possible leases for specified lease type.
Definition subnet.cc:97
isc::dhcp::Subnet::setSharedNetworkName
void setSharedNetworkName(const std::string &shared_network_name)
Sets new shared network name.
Definition subnet.h:266
isc::dhcp::Subnet::prefix_
isc::asiolink::IOAddress prefix_
a prefix of the subnet.
Definition subnet.h:433
isc::dhcp::Subnet::getID
SubnetID getID() const
Returns unique ID for that subnet.
Definition subnet.h:83
isc::dhcp::Subnet::prefix_len_
uint8_t prefix_len_
a prefix length of the subnet.
Definition subnet.h:436
isc::dhcp::Subnet::sumPoolCapacity
isc::util::uint128_t sumPoolCapacity(const PoolCollection &pools) const
Returns a sum of possible leases in all pools.
Definition subnet.cc:150
isc::dhcp::Subnet::toElement
virtual data::ElementPtr toElement() const
Unparse a subnet object.
Definition subnet.cc:738
isc::dhcp::Subnet::getAllocator
AllocatorPtr getAllocator(Lease::Type type) const
Returns lease allocator instance.
Definition subnet.cc:366
isc::dhcp::Subnet::pools_ta_
PoolCollection pools_ta_
collection of IPv6 temporary address pools in that subnet.
Definition subnet.h:427
isc::dhcp::Subnet::getSharedNetwork
void getSharedNetwork(SharedNetworkPtrType &shared_network) const
Retrieves pointer to a shared network associated with a subnet.
Definition subnet.h:231
isc::dhcp::Subnet::initAllocatorsAfterConfigure
void initAllocatorsAfterConfigure()
Calls initAfterConfigure for each allocator.
Definition subnet.cc:437
isc::dhcp::Subnet::id_
SubnetID id_
subnet-id
Definition subnet.h:421
isc::dhcp::Subnet::getAllocationState
SubnetAllocationStatePtr getAllocationState(Lease::Type type) const
Returns subnet-specific allocation state.
Definition subnet.cc:382
isc::dhcp::Subnet::getAnyPool
PoolPtr getAnyPool(Lease::Type type)
Returns a pool without any address specified.
Definition subnet.h:160
isc::dhcp::Subnet::addPool
void addPool(const PoolPtr &pool)
Adds a new pool for the subnet.
Definition subnet.cc:472
isc::dhcp::Subnet::~Subnet
virtual ~Subnet()
virtual destructor.
Definition subnet.h:342
isc::dhcp::Subnet::inRange
bool inRange(const isc::asiolink::IOAddress &addr) const
checks if specified address is in range.
Definition subnet.cc:82
isc::dhcp::Subnet::allocators_
std::map< Lease::Type, AllocatorPtr > allocators_
Lease allocators used by the subnet.
Definition subnet.h:442
isc::dhcp::Subnet::toText
virtual std::string toText() const
Returns textual representation of the subnet (e.g.
Definition subnet.cc:90
isc::dhcp::Subnet::delPools
void delPools(Lease::Type type)
Deletes all pools of specified type.
Definition subnet.cc:527
isc::dhcp::Subnet::get
std::pair< isc::asiolink::IOAddress, uint8_t > get() const
Returns subnet parameters (prefix and prefix length).
Definition subnet.h:90
isc::dhcp::Subnet::getLabel
virtual std::string getLabel() const
Generates an identifying label for logging.
Definition subnet.h:400
isc::dhcp::Subnet::parsePrefixCommon
static std::pair< asiolink::IOAddress, uint8_t > parsePrefixCommon(const std::string &prefix)
Converts subnet prefix to a pair of prefix/length pair.
Definition subnet.cc:221
isc::dhcp::Subnet::setAllocator
void setAllocator(Lease::Type type, const AllocatorPtr &allocator)
Sets new allocator instance.
Definition subnet.cc:377
isc::dhcp::Subnet::getSharedNetworkName
std::string getSharedNetworkName() const
Returns shared network name.
Definition subnet.h:250
isc::dhcp::Subnet::pools_
PoolCollection pools_
collection of IPv4 or non-temporary IPv6 pools in that subnet.
Definition subnet.h:424
isc::dhcp::Subnet::getPoolsWritable
PoolCollection & getPoolsWritable(Lease::Type type)
Returns all pools (non-const variant).
Definition subnet.cc:347
isc::dhcp::Subnet::getPool
const PoolPtr getPool(Lease::Type type, const isc::asiolink::IOAddress &addr, bool anypool=true) const
Returns a pool that specified address belongs to.
Definition subnet.cc:397
isc::dhcp::Subnet::Subnet
Subnet(const isc::asiolink::IOAddress &prefix, uint8_t len, const SubnetID id)
Protected constructor.
Definition subnet.cc:68
isc::dhcp::Subnet::shared_network_name_
std::string shared_network_name_
Shared network name.
Definition subnet.h:439
isc::dhcp::Subnet::poolOverlaps
bool poolOverlaps(const Lease::Type &pool_type, const PoolPtr &pool) const
Checks if the specified pool overlaps with an existing pool.
Definition subnet.cc:573
isc::dhcp::Subnet::default_pool
virtual isc::asiolink::IOAddress default_pool() const =0
Returns the default address that will be used for pool selection.
isc::dhcp::Subnet::pools_pd_
PoolCollection pools_pd_
collection of IPv6 prefix pools in that subnet.
Definition subnet.h:430
isc::dhcp::Subnet::getPools
const PoolCollection & getPools(Lease::Type type) const
Returns all pools (const variant).
Definition subnet.cc:329
isc::dhcp::Subnet::checkType
virtual void checkType(Lease::Type type) const =0
Checks if used pool type is valid.
isc::dhcp::Subnet::allocation_states_
std::map< Lease::Type, SubnetAllocationStatePtr > allocation_states_
Holds subnet-specific allocation state.
Definition subnet.h:445
isc::dhcp::Subnet::createAllocators
virtual void createAllocators()=0
Instantiates the allocators and their states.
isc::dhcp::Subnet::inPool
bool inPool(Lease::Type type, const isc::asiolink::IOAddress &addr) const
checks if the specified address is in pools.
Definition subnet.cc:532
isc::dhcp::Subnet::setSharedNetwork
void setSharedNetwork(const NetworkPtr &shared_network)
Assigns shared network to a subnet.
Definition subnet.h:243
isc::dhcp::Subnet::setAllocationState
void setAllocationState(Lease::Type type, const SubnetAllocationStatePtr &allocation_state)
Sets subnet-specific allocation state.
Definition subnet.cc:393
isc::util::Triplet
This template specifies a parameter value.
Definition triplet.h:37
data.h
dhcp_space.h
io_address.h
lease.h
isc::data::ElementPtr
boost::shared_ptr< Element > ElementPtr
Definition data.h:28
isc::dhcp
Definition dhcp4/client_handler.cc:20
isc::dhcp::SubnetPtr
boost::shared_ptr< Subnet > SubnetPtr
A generic pointer to either Subnet4 or Subnet6 object.
Definition subnet.h:449
isc::dhcp::Subnet4Ptr
boost::shared_ptr< Subnet4 > Subnet4Ptr
A pointer to a Subnet4 object.
Definition subnet.h:461
isc::dhcp::ConstSubnet6Ptr
boost::shared_ptr< const Subnet6 > ConstSubnet6Ptr
A const pointer to a Subnet6 object.
Definition subnet.h:623
isc::dhcp::SubnetFetcher6
SubnetFetcher< Subnet6Ptr, Subnet6Collection > SubnetFetcher6
Type of the SubnetFetcher used for IPv6.
Definition subnet.h:973
isc::dhcp::ConstSubnet4Ptr
boost::shared_ptr< const Subnet4 > ConstSubnet4Ptr
A const pointer to a Subnet4 object.
Definition subnet.h:458
isc::dhcp::SubnetTPtr
boost::shared_ptr< SubnetT< D > > SubnetTPtr
Definition subnet.h:999
isc::dhcp::Subnet6Ptr
boost::shared_ptr< Subnet6 > Subnet6Ptr
A pointer to a Subnet6 object.
Definition subnet.h:626
isc::dhcp::Subnet6Collection
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.
Definition subnet.h:937
isc::dhcp::ConstSubnetTPtr
boost::shared_ptr< const SubnetT< D > > ConstSubnetTPtr
Definition subnet.h:1002
isc::dhcp::PoolCollection
std::vector< PoolPtr > PoolCollection
a container for either IPv4 or IPv6 Pools
Definition pool.h:729
isc::dhcp::Subnet4SimpleCollection
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.
Definition subnet.h:810
isc::dhcp::PoolPtr
boost::shared_ptr< Pool > PoolPtr
a pointer to either IPv4 or IPv6 Pool
Definition pool.h:726
isc::dhcp::Subnet4Collection
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.
Definition subnet.h:866
isc::dhcp::SubnetID
uint32_t SubnetID
Defines unique IPv4 or IPv6 subnet identifier.
Definition subnet_id.h:25
isc::dhcp::Subnet6SimpleCollection
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.
Definition subnet.h:890
isc::dhcp::ConstSubnetPtr
boost::shared_ptr< const Subnet > ConstSubnetPtr
A generic pointer to either const Subnet4 or const Subnet6 object.
Definition subnet.h:452
isc::dhcp::NetworkPtr
boost::shared_ptr< Network > NetworkPtr
Pointer to the Network object.
Definition network.h:73
isc::dhcp::AllocatorPtr
boost::shared_ptr< Allocator > AllocatorPtr
Defines a pointer to an allocator.
Definition allocator.h:239
isc::dhcp::SubnetAllocationStatePtr
boost::shared_ptr< SubnetAllocationState > SubnetAllocationStatePtr
Definition allocation_state.h:80
isc::dhcp::SubnetFetcher4
SubnetFetcher< Subnet4Ptr, Subnet4Collection > SubnetFetcher4
Type of the SubnetFetcher used for IPv4.
Definition subnet.h:970
isc::dhcp::SubnetT
typename AdapterSubnet< D >::type SubnetT
Definition subnet.h:996
isc::util::DHCPv6
@ DHCPv6
Definition dhcp_space.h:19
isc::util::DHCPv4
@ DHCPv4
Definition dhcp_space.h:18
isc::util::uint128_t
boost::multiprecision::checked_uint128_t uint128_t
Definition bigints.h:21
isc
Defines the logger used by the top-level component of kea-lfc.
Definition agent_parser.cc:148
network.h
option_space_container.h
pool.h
isc::dhcp::Cfg4o6
This structure contains information about DHCP4o6 (RFC7341).
Definition cfg_4o6.h:22
isc::dhcp::Lease::Type
Type
Type of lease or pool.
Definition lease.h:46
isc::dhcp::SubnetModificationTimeIndexTag
Tag for the index for searching by subnet modification time.
Definition subnet.h:786
isc::dhcp::SubnetPrefixIndexTag
Tag for the index for searching by subnet prefix.
Definition subnet.h:780
isc::dhcp::SubnetServerIdIndexTag
Tag for the index for searching by server identifier.
Definition subnet.h:783
isc::dhcp::SubnetSubnetIdIndexTag
Tag for the index for searching by subnet identifier.
Definition subnet.h:777
subnet_id.h
triplet.h
user_context.h