16#include <boost/foreach.hpp>
30 << subnet->getID() <<
"' is already in use");
36 << subnet->toText() <<
"' already exists");
40 .arg(subnet->toText());
41 subnets_.push_back(subnet);
47 auto subnet_it = index.find(subnet->getID());
48 if (subnet_it == index.end()) {
52 index.erase(subnet_it);
55 .arg(subnet->toText());
61 auto subnet_it = index.find(subnet_id);
62 return ((subnet_it != index.cend()) ? (*subnet_it) :
ConstSubnet6Ptr());
68 auto subnet_it = index.find(subnet_text);
69 return ((subnet_it != index.cend()) ? (*subnet_it) :
ConstSubnet6Ptr());
82 if (!query->relay_info_.empty()) {
140 const bool is_relay_address)
const {
144 if (is_relay_address) {
145 for (Subnet6Collection::const_iterator subnet = subnets_.begin();
146 subnet != subnets_.end(); ++subnet) {
150 if (is_relay_address &&
151 ((*subnet)->hasRelayAddress(address)) &&
152 (*subnet)->clientSupported(client_classes)) {
154 DHCPSRV_CFGMGR_SUBNET6_RELAY)
155 .arg((*subnet)->toText()).arg(address.
toText());
164 for (Subnet6Collection::const_iterator subnet = subnets_.begin();
165 subnet != subnets_.end(); ++subnet) {
166 if ((*subnet)->inRange(address) &&
167 (*subnet)->clientSupported(client_classes)) {
169 .arg((*subnet)->toText()).arg(address.
toText());
184 if (!iface_name.empty()) {
185 for (Subnet6Collection::const_iterator subnet = subnets_.begin();
186 subnet != subnets_.end(); ++subnet) {
191 if ((iface_name == (*subnet)->getIface()) &&
192 (*subnet)->clientSupported(client_classes)) {
195 DHCPSRV_CFGMGR_SUBNET6_IFACE)
196 .arg((*subnet)->toText()).arg(iface_name);
208 const ClientClasses& client_classes)
const {
212 for (Subnet6Collection::const_iterator subnet = subnets_.begin();
213 subnet != subnets_.end(); ++subnet) {
217 if ((*subnet)->getInterfaceId() &&
218 (*subnet)->getInterfaceId()->equals(interface_id) &&
219 (*subnet)->clientSupported(client_classes)) {
222 DHCPSRV_CFGMGR_SUBNET6_IFACE_ID)
223 .arg((*subnet)->toText());
237 for (
auto subnet = subnets_.begin(); subnet != subnets_.end(); ++subnet) {
238 if ((*subnet)->getID() ==
id) {
249 StatsMgr& stats_mgr = StatsMgr::instance();
251 for (Subnet6Collection::const_iterator subnet6 = subnets_.begin();
252 subnet6 != subnets_.end(); ++subnet6) {
253 SubnetID subnet_id = (*subnet6)->getID();
254 stats_mgr.
del(StatsMgr::generateName(
"subnet", subnet_id,
"total-nas"));
256 stats_mgr.
del(StatsMgr::generateName(
"subnet", subnet_id,
259 stats_mgr.
del(StatsMgr::generateName(
"subnet", subnet_id,
"total-pds"));
261 stats_mgr.
del(StatsMgr::generateName(
"subnet", subnet_id,
264 stats_mgr.
del(StatsMgr::generateName(
"subnet", subnet_id,
265 "declined-addresses"));
267 stats_mgr.
del(StatsMgr::generateName(
"subnet", subnet_id,
268 "declined-reclaimed-addresses"));
270 stats_mgr.
del(StatsMgr::generateName(
"subnet", subnet_id,
271 "reclaimed-leases"));
279 StatsMgr& stats_mgr = StatsMgr::instance();
281 for (Subnet6Collection::const_iterator subnet6 = subnets_.begin();
282 subnet6 != subnets_.end(); ++subnet6) {
283 SubnetID subnet_id = (*subnet6)->getID();
285 stats_mgr.
setValue(StatsMgr::generateName(
"subnet", subnet_id,
290 stats_mgr.
setValue(StatsMgr::generateName(
"subnet", subnet_id,
297 if (subnets_.begin() != subnets_.end()) {
306 for (Subnet6Collection::const_iterator subnet = subnets_.cbegin();
307 subnet != subnets_.cend(); ++subnet) {
308 result->add((*subnet)->toElement());
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
The IOAddress class represents an IP addresses (version agnostic)
std::string toText() const
Convert the address to a string.
bool isV6Zero() const
Convenience function to check if it is an IPv4 zero address.
bool isV6LinkLocal() const
checks whether and address is IPv6 and is link-local
static ElementPtr createList(const Position &pos=ZERO_POSITION())
Creates an empty ListElement type ElementPtr.
void updateStatistics()
Updates statistics.
virtual isc::data::ElementPtr toElement() const
Unparse a configuration object.
Subnet6Ptr selectSubnet(const SubnetSelector &selector) const
Selects a subnet using parameters specified in the selector.
Subnet6Ptr getSubnet(const SubnetID id) const
Returns subnet with specified subnet-id value.
void removeStatistics()
Removes statistics.
void add(const Subnet6Ptr &subnet)
Adds new subnet to the configuration.
static SubnetSelector initSelector(const Pkt6Ptr &query)
Build selector from a client's message.
void del(const ConstSubnet6Ptr &subnet)
Removes subnet from the configuration.
ConstSubnet6Ptr getByPrefix(const std::string &subnet_prefix) const
Returns const pointer to a subnet which matches the specified prefix in the canonical form.
ConstSubnet6Ptr getBySubnetId(const SubnetID &subnet_id) const
Returns const pointer to a subnet identified by the specified subnet identifier.
Container for storing client class names.
Exception thrown upon attempt to add subnet with an ID that belongs to the subnet that already exists...
static LeaseMgr & instance()
Return current lease manager.
void recountLeaseStats6()
Recalculates per-subnet and global stats for IPv6 leases.
Statistics Manager class.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
bool del(const std::string &name)
Removes specified statistic.
void setValue(const std::string &name, const int64_t value)
Records absolute integer observation.
#define LOG_DEBUG(LOGGER, LEVEL, MESSAGE)
Macro to conveniently test debug output and log it.
boost::shared_ptr< Element > ElementPtr
isc::log::Logger dhcpsrv_logger("dhcpsrv")
DHCP server library Logger.
boost::shared_ptr< const Subnet6 > ConstSubnet6Ptr
A const pointer to a Subnet6 object.
boost::shared_ptr< Subnet6 > Subnet6Ptr
A pointer to a Subnet6 object.
uint32_t SubnetID
Unique identifier for a subnet (both v4 and v6)
boost::shared_ptr< Pkt6 > Pkt6Ptr
A pointer to Pkt6 packet.
const int DHCPSRV_DBG_TRACE
DHCP server library logging levels.
boost::shared_ptr< Option > OptionPtr
Defines the logger used by the top-level component of kea-dhcp-ddns.
@ TYPE_PD
the lease contains IPv6 prefix (for prefix delegation)
@ TYPE_NA
the lease contains non-temporary IPv6 address
structure that describes a single relay information
isc::asiolink::IOAddress linkaddr_
fixed field in relay-forw/relay-reply
Tag for the index for searching by subnet prefix.
Subnet selector used to specify parameters used to select a subnet.
std::string iface_name_
Name of the interface on which the message was received.
ClientClasses client_classes_
Classes that the client belongs to.
asiolink::IOAddress remote_address_
Source address of the message.
OptionPtr interface_id_
Interface id option.
asiolink::IOAddress first_relay_linkaddr_
First relay link address.
Tag for the index for searching by subnet identifier.