Kea  2.3.5-git
cfg_subnets4.h
Go to the documentation of this file.
1 // Copyright (C) 2014-2022 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 CFG_SUBNETS4_H
8 #define CFG_SUBNETS4_H
9 
10 #include <asiolink/io_address.h>
11 #include <cc/cfg_to_element.h>
12 #include <dhcp/pkt4.h>
14 #include <dhcpsrv/subnet.h>
15 #include <dhcpsrv/subnet_id.h>
17 #include <boost/shared_ptr.hpp>
18 #include <string>
19 
20 namespace isc {
21 namespace dhcp {
22 
34 public:
35 
42  void add(const Subnet4Ptr& subnet);
43 
52  Subnet4Ptr replace(const Subnet4Ptr& subnet);
53 
59  void del(const ConstSubnet4Ptr& subnet);
60 
66  void del(const SubnetID& subnet_id);
67 
109  void merge(CfgOptionDefPtr cfg_def, CfgSharedNetworks4Ptr networks,
110  CfgSubnets4& other);
111 
119  const Subnet4Collection* getAll() const {
120  return (&subnets_);
121  }
122 
138  ConstSubnet4Ptr getBySubnetId(const SubnetID& subnet_id) const;
139 
155  ConstSubnet4Ptr getByPrefix(const std::string& subnet_prefix) const;
156 
163  bool hasSubnetWithServerId(const asiolink::IOAddress& server_id) const;
164 
171  static SubnetSelector initSelector(const Pkt4Ptr& query);
172 
220  Subnet4Ptr selectSubnet(const SubnetSelector& selector) const;
221 
229  Subnet4Ptr getSubnet(const SubnetID id) const;
230 
252  const ClientClasses& client_classes
253  = ClientClasses()) const;
254 
276  Subnet4Ptr selectSubnet(const std::string& iface,
277  const ClientClasses& client_classes) const;
278 
298  Subnet4Ptr
299  selectSubnet4o6(const SubnetSelector& selector) const;
300 
310  SubnetIDSet getLinks(const asiolink::IOAddress& link_addr,
311  uint8_t& link_len) const;
312 
320  void updateStatistics();
321 
328  void removeStatistics();
329 
333  virtual isc::data::ElementPtr toElement() const;
334 
335 private:
336 
338  Subnet4Collection subnets_;
339 
340 };
341 
343 
344 typedef boost::shared_ptr<CfgSubnets4> CfgSubnets4Ptr;
346 
348 typedef boost::shared_ptr<const CfgSubnets4> ConstCfgSubnets4Ptr;
349 
351 
352 }
353 }
354 
355 #endif // CFG_SUBNETS4_H
Subnet4Ptr replace(const Subnet4Ptr &subnet)
Replaces subnet in the configuration.
Definition: cfg_subnets4.cc:46
Subnet4Ptr selectSubnet(const SubnetSelector &selector) const
Returns a pointer to the selected subnet.
void merge(CfgOptionDefPtr cfg_def, CfgSharedNetworks4Ptr networks, CfgSubnets4 &other)
Merges specified subnet configuration into this configuration.
Definition: cfg_subnets4.cc:89
SubnetIDSet getLinks(const asiolink::IOAddress &link_addr, uint8_t &link_len) const
Convert a link address into a link set.
static SubnetSelector initSelector(const Pkt4Ptr &query)
Build selector from a client&#39;s message.
Subnet4Ptr getSubnet(const SubnetID id) const
Returns subnet with specified subnet-id value.
bool hasSubnetWithServerId(const asiolink::IOAddress &server_id) const
Checks if specified server identifier has been specified for any subnet.
boost::shared_ptr< Subnet4 > Subnet4Ptr
A pointer to a Subnet4 object.
Definition: subnet.h:477
void add(const Subnet4Ptr &subnet)
Adds new subnet to the configuration.
Definition: cfg_subnets4.cc:28
boost::shared_ptr< Element > ElementPtr
Definition: data.h:24
boost::shared_ptr< CfgOptionDef > CfgOptionDefPtr
Non-const pointer.
boost::shared_ptr< CfgSubnets4 > CfgSubnets4Ptr
Non-const pointer.
Definition: cfg_subnets4.h:345
boost::shared_ptr< const CfgSubnets4 > ConstCfgSubnets4Ptr
Const pointer.
Definition: cfg_subnets4.h:348
std::set< dhcp::SubnetID > SubnetIDSet
Ordered list aka set of subnetIDs.
Definition: subnet_id.h:43
Subnet selector used to specify parameters used to select a subnet.
boost::shared_ptr< CfgSharedNetworks4 > CfgSharedNetworks4Ptr
Pointer to the configuration of IPv4 shared networks.
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
Abstract class for configuration Cfg_* classes.
boost::shared_ptr< Pkt4 > Pkt4Ptr
A pointer to Pkt4 object.
Definition: pkt4.h:547
Subnet4Ptr selectSubnet4o6(const SubnetSelector &selector) const
Attempts to do subnet selection based on DHCP4o6 information.
Holds subnets configured for the DHCPv4 server.
Definition: cfg_subnets4.h:33
virtual isc::data::ElementPtr toElement() const
Unparse a configuration object.
Defines the logger used by the top-level component of kea-lfc.
boost::shared_ptr< const Subnet4 > ConstSubnet4Ptr
A const pointer to a Subnet4 object.
Definition: subnet.h:471
void removeStatistics()
Removes statistics.
ConstSubnet4Ptr getBySubnetId(const SubnetID &subnet_id) const
Returns const pointer to a subnet identified by the specified subnet identifier.
ConstSubnet4Ptr getByPrefix(const std::string &subnet_prefix) const
Returns const pointer to a subnet which matches the specified prefix in the canonical form...
void del(const ConstSubnet4Ptr &subnet)
Removes subnet from the configuration.
Definition: cfg_subnets4.cc:67
const Subnet4Collection * getAll() const
Returns pointer to the collection of all IPv4 subnets.
Definition: cfg_subnets4.h:119
Container for storing client class names.
Definition: classify.h:108
void updateStatistics()
Updates statistics.
uint32_t SubnetID
Defines unique IPv4 or IPv6 subnet identifier.
Definition: subnet_id.h:25