Commit a4a614f4 authored by Thomas Markwalder's avatar Thomas Markwalder
Browse files

[5589] Addressed review comments except for unit tests not loading library

    Too numerous to mention.
parent b53946b9
......@@ -7,7 +7,8 @@
statistics in deployments running multiple Kea servers that use
shared lease back end. The in-memory statistics kept by individual
servers only track lease changes made by that server. Thus in a
deployment with multiple servers, these statistics are incomplete.
deployment with multiple servers (e.g. two kea-dhcp6 servers using the
same PostgreSQL database for lease storage), these statistics are incomplete.
In Kea 1.4, the MySQL and PostgreSQL back ends were modified to track
lease allocation changes as they occur via database triggers. Additionally,
all four lease back ends were extended to support retrieving lease
......@@ -111,9 +112,7 @@
The following command would fetch lease statistcis for all known subnets from kea-dhcp4 server:
<screen>
{
"command": "stat-lease4-get",
"arguments": {
}
"command": "stat-lease4-get"
}
</screen>
</para>
......@@ -170,22 +169,12 @@
<itemizedlist>
<listitem><simpara><command>subnet-id</command> - ID of the subnet</simpara></listitem>
<listitem><simpara><command>total-addresses</command> - total number of addresses
available for DHCPv4 management. In other words, this is the sum of all
addresses in all configured pools. This statistic changes only during
configuration changes. Note it does not take into account any addresses that
may be reserved due to host reservation.
</simpara></listitem>
<listitem><simpara><command>assigned-addresses</command> - number of assigned
addresses in a given subnet. It increases every time a new lease is
allocated (as a result of receiving a DHCPREQUEST message) and is decreased
every time a lease is released (a DHCPRELEASE message is received) or expires.
</simpara></listitem>
<listitem><simpara><command>declined-addresses</command> - number of IPv4 addresses
that are currently declined in a given subnet, so is a count of the number
of leases currently unavailable. Once a lease is recovered, this statistic
will be decreased. Ideally, this statistic should be zero. If this statistic
is non-zero (or worse increasing), a network administrator should investigate
if there is a misbehaving device in his network.
available for DHCPv4 management in the subnet. In other words, this is the sum of all
addresses in all the configured pools in the subnet.</simpara></listitem>
<listitem><simpara><command>assigned-addresses</command> - number of addresses
in the subnet that are currently assigned to a client.</simpara></listitem>
<listitem><simpara><command>declined-addresses</command> - number of addresses
in the subnet that are currently declined and are thus unavailable for assignment.
</simpara></listitem>
</itemizedlist></para>
</listitem>
......@@ -193,35 +182,17 @@
<itemizedlist>
<listitem><simpara><command>subnet-id</command> - ID of the subnet</simpara></listitem>
<listitem><simpara><command>total-nas</command> - number of NA addresses available
for DHCPv6 management for a given subnet. In other words, this is the
sum of all addresses in all configured pools. This statistic changes
only during configuration changes. Note that it does not take into account
any addresses that may be reserved due to host reservation.</simpara>
</listitem>
for DHCPv6 management in the subnet. In other words, this is the sum of all
the NA addresses in the all configured NA pools in the subnet.</simpara></listitem>
<listitem><simpara><command>assigned-nas</command> - number of NA addresses in a
the subnet that are assigned. This statistic increases every time a new
lease is allocated (as a result of receiving a REQUEST message) and is
decreased every time a lease is released (a RELEASE message is received)
or expires.
</simpara></listitem>
<listitem><simpara><command>declined-nas</command> - number of IPv6 addresses that
are currently declined and so counts the number of leases currently
unavailable. Once a lease is recovered, this statistic will be decreased.
Ideally, this statistic should be zero. If this statistic is non-zero
(or worse, increasing), the network administrator should investigate if
there is a misbehaving device in the network.
</simpara></listitem>
<listitem><simpara><command>total-pds</command> - total number of PD prefixes available
of DHCPv6 management for a given subnet. In other words, this is the sum
of all prefixes in all configured pools. This statistic changes only during
configuration changes. Note it does not take into account any prefixes that
may be reserved due to host reservation.
</simpara></listitem>
<listitem><simpara><command>assigned-pds</command> - number of PD prefixes in a given
subnet that are assigned. This statistic increases every time a new lease is
allocated (as a result of receiving a REQUEST message) and is decreased every
time a lease is released (a RELEASE message is received) or expires.
</simpara></listitem>
the subnet that are currently assigned to a client.</simpara></listitem>
<listitem><simpara><command>declined-nas</command> - number of NA addresses that
are currently declined and are thus unavailable for assignment.</simpara></listitem>
<listitem><simpara><command>total-pds</command> - total number of prefixes available
of DHCPv6 management in the subnet. In other words, this is the sum of all prefixes
in all the configured prefix pools in the subnet.</simpara></listitem>
<listitem><simpara><command>assigned-pds</command> - number of prefixes in the subnet
that are currently assigned to a client.</simpara></listitem>
</itemizedlist></para>
</listitem>
<listitem><para><command>rows</command> - a list of rows, one per subnet ID. Each row
......@@ -245,7 +216,8 @@
"result-set": {
"columns": [ "subnet-id", "total-addresses", "assigned-addresses", "declined-addresses" ]
"rows": [
[ 10, 256, 111, 0 ], [ 20, 4098, 2034, 4 ]
[ 10, 256, 111, 0 ],
[ 20, 4098, 2034, 4 ]
],
"timestamp": "2018-05-04 15:03:37.000000"
}
......@@ -254,7 +226,9 @@
</screen>
</para>
<para>
The response to a DHCPv6 command might look as follows:
The response to a DHCPv6 command might look as follows (subnet 10 has no
prefix pools, subnet 20 has no NA pools, and subnet 30 has both NA and PD
pools):
<screen>
{
"result": 0,
......@@ -263,8 +237,9 @@
"result-set": {
"columns": [ "subnet-id", "total-nas", "assigned-nas", "declined-nas", "total-pds", "assigned-pds" ]
"rows": [
[ 10, 256, 111, 0 ],
[ 20, 4098, 2034, 4 ]
[ 10, 4096, 2400, 3, 0, 0],
[ 20, 0, 0, 0, 1048, 233 ]
[ 30, 256, 60, 0, 1048, 15 ]
],
"timestamp": "2018-05-04 15:03:37.000000"
}
......
......@@ -313,6 +313,15 @@
</simpara>
</listitem>
<listitem>
<simpara>
<command>kea-dhcp4.stat-cmds-hooks</command> - this logger is used
to log messages related to operation of the Stats Cmds hooks library.
In general these will pertain to loading and unloading the library,
as well as execution of commands by the library.
</simpara>
</listitem>
<listitem>
<simpara>
<command>kea-dhcp6</command> - the root logger for the DHCPv6
......
......@@ -60,6 +60,25 @@ public:
/// @brief Denotes the query selection mode all, subnet,
/// or subnet range
LeaseStatsQuery::SelectMode select_mode_;
/// @brief Generate a string version of the contents
std::string toText() {
std::stringstream os;
switch (select_mode_) {
case LeaseStatsQuery::ALL_SUBNETS:
os << "[all subnets]";
break;
case LeaseStatsQuery::SINGLE_SUBNET:
os << "[subnet-id=" << first_subnet_id_ << "]";
break;
case LeaseStatsQuery::SUBNET_RANGE:
os << "[subnets " << first_subnet_id_
<< " through " << last_subnet_id_ << "]";
break;
}
return (os.str());
}
};
public:
......@@ -102,8 +121,7 @@ public:
/// must fulfill: 0 < first-subnet-id < last-subnet-id
/// -# subnet-id and subnet-range are mutually exclusive
Parameters getParameters(const ConstElementPtr& cmd_args);
/// @brief Executes the lease4 query and constructs the outbound result set
/// @brief Executes the lease4 query and constructs the outbound result set
///
/// This method uses the command parameters to identify the range
/// of configured subnets. If the range contains no known subnets
......@@ -195,39 +213,46 @@ public:
int
LeaseStatCmdsImpl::statLease4GetHandler(CalloutHandle& handle) {
ElementPtr result = Element::createMap();
int response_code;
string txt = "malformed command";
Parameters params;
ConstElementPtr response;
// Extract the command and then the parameters
try {
// Extract the command and then the parameters
extractCommand(handle);
Parameters params = getParameters(cmd_args_);
params = getParameters(cmd_args_);
} catch (const std::exception& ex) {
LOG_ERROR(stat_cmds_logger, STAT_CMDS_LEASE4_GET_INVALID)
.arg(ex.what());
setErrorResponse(handle, ex.what());
return (1);
}
try {
// Now build the result set
txt = "building result";
uint64_t rows = makeResultSet4(result, params);
// Eureka it worked!
response_code = CONTROL_RESULT_SUCCESS;
LOG_INFO(stat_cmds_logger, STAT_CMDS_LEASE4_GET)
.arg(params.toText())
.arg(rows);
std::stringstream os;
os << "stat-lease4-get: " << rows << " rows found";
txt = os.str();
os << "stat-lease4-get" << params.toText() << ": " << rows << " rows found";
response = createAnswer(CONTROL_RESULT_SUCCESS, os.str(), result);
} catch (const NotFound& ex) {
// Criteria was valid but included no known subnets,
// so we return a not found response.
response_code = CONTROL_RESULT_EMPTY;
LOG_INFO(stat_cmds_logger, STAT_CMDS_LEASE4_GET_NO_SUBNETS)
.arg(params.toText())
.arg(ex.what());
std::stringstream os;
os << "stat-lease4-get: " << "no matching data, " << ex.what();
txt = os.str();
os << "stat-lease4-get" << params.toText() << ": no matching data, " << ex.what();
response = createAnswer(CONTROL_RESULT_EMPTY, os.str(), result);
} catch (const std::exception& ex) {
LOG_ERROR(stat_cmds_logger, STAT_LEASE4_GET_FAILED)
.arg(txt)
.arg(ex.what());
LOG_ERROR(stat_cmds_logger, STAT_CMDS_LEASE4_GET_FAILED)
.arg(params.toText())
.arg(ex.what());
setErrorResponse(handle, ex.what());
return (1);
}
LOG_INFO(stat_cmds_logger, STAT_LEASE4_GET).arg(txt);
ConstElementPtr response = createAnswer(response_code, txt, result);
setResponse(handle, response);
return (0);
}
......@@ -235,40 +260,46 @@ LeaseStatCmdsImpl::statLease4GetHandler(CalloutHandle& handle) {
int
LeaseStatCmdsImpl::statLease6GetHandler(CalloutHandle& handle) {
ElementPtr result = Element::createMap();
int response_code;
string txt = "malformed command";
Parameters params;
ConstElementPtr response;
// Extract the command and then the parameters
try {
// Extract the command and then the parameters
extractCommand(handle);
Parameters params = getParameters(cmd_args_);
params = getParameters(cmd_args_);
} catch (const std::exception& ex) {
LOG_ERROR(stat_cmds_logger, STAT_CMDS_LEASE6_GET_INVALID)
.arg(ex.what());
setErrorResponse(handle, ex.what());
return (1);
}
try {
// Now build the result set
txt = "building result";
uint64_t rows = makeResultSet6(result, params);
// Eureka it worked!
response_code = CONTROL_RESULT_SUCCESS;
LOG_INFO(stat_cmds_logger, STAT_CMDS_LEASE6_GET)
.arg(params.toText())
.arg(rows);
std::stringstream os;
os << "stat-lease6-get: " << rows << " rows found";
txt = os.str();
os << "stat-lease6-get" << params.toText() << ": " << rows << " rows found";
response = createAnswer(CONTROL_RESULT_SUCCESS, os.str(), result);
} catch (const NotFound& ex) {
// Criteria was valid but included no known subnets,
// so we return a not found response.
result = Element::createMap();
response_code = CONTROL_RESULT_EMPTY;
LOG_INFO(stat_cmds_logger, STAT_CMDS_LEASE6_GET_NO_SUBNETS)
.arg(params.toText())
.arg(ex.what());
std::stringstream os;
os << "stat-lease6-get: " << "no matching data, " << ex.what();
txt = os.str();
os << "stat-lease6-get" << params.toText() << ": no matching data, " << ex.what();
response = createAnswer(CONTROL_RESULT_EMPTY, os.str(), result);
} catch (const std::exception& ex) {
LOG_ERROR(stat_cmds_logger, STAT_LEASE6_GET_FAILED)
.arg(txt)
.arg(ex.what());
LOG_ERROR(stat_cmds_logger, STAT_CMDS_LEASE6_GET_FAILED)
.arg(params.toText())
.arg(ex.what());
setErrorResponse(handle, ex.what());
return (1);
}
LOG_INFO(stat_cmds_logger, STAT_LEASE6_GET).arg(txt);
ConstElementPtr response = createAnswer(response_code, txt, result);
setResponse(handle, response);
return (0);
}
......@@ -277,8 +308,14 @@ LeaseStatCmdsImpl::Parameters
LeaseStatCmdsImpl::getParameters(const ConstElementPtr& cmd_args) {
Parameters params;
if (!cmd_args || cmd_args->getType() != Element::map) {
isc_throw(BadValue, "Parameters missing or are not a map.");
params.select_mode_ = LeaseStatsQuery::ALL_SUBNETS;
if (!cmd_args ) {
// No arguments defaults to ALL_SUBNETS.
return (params);
}
if (cmd_args->getType() != Element::map) {
isc_throw(BadValue, "'arguments' parameter is not a map");
}
params.select_mode_ = LeaseStatsQuery::ALL_SUBNETS;
......@@ -299,7 +336,7 @@ LeaseStatCmdsImpl::getParameters(const ConstElementPtr& cmd_args) {
if (cmd_args->contains("subnet-range")) {
if (params.select_mode_ == LeaseStatsQuery::SINGLE_SUBNET) {
isc_throw(BadValue, "Cannot specify both subnet-id and subnet-range");
isc_throw(BadValue, "cannot specify both subnet-id and subnet-range");
}
ConstElementPtr range = cmd_args->get("subnet-range");
......@@ -567,7 +604,8 @@ LeaseStatCmdsImpl::createResultSet(const ElementPtr &result_wrapper,
result_wrapper->set("result-set", result_set);
// Create the timestamp based on time now and add it to the result set.
boost::posix_time::ptime now(boost::posix_time::second_clock::universal_time());
boost::posix_time::ptime now(boost::posix_time::microsec_clock::universal_time());
ElementPtr timestamp = Element::create(isc::util::ptimeToText(now));
result_set->set("timestamp", timestamp);
......@@ -632,8 +670,5 @@ StatCmds::statLease6GetHandler(CalloutHandle& handle) {
return(impl.statLease6GetHandler(handle));
}
StatCmds::StatCmds() {
}
};
};
// Copyright (C) 2017-2018 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
......@@ -7,7 +7,6 @@
#ifndef STAT_CMDS_H
#define STAT_CMDS_H
#include <cc/data.h>
#include <hooks/hooks.h>
#include <boost/shared_ptr.hpp>
......@@ -25,14 +24,12 @@ class StatCmdsImpl;
/// stat manipulations.
class StatCmds {
public:
/// @brief Constructor.
///
/// It creates an instance of the @c StatCmdsImpl.
StatCmds();
/// @brief Default Constructor.
StatCmds() {};
/// @brief stat-lease4-get command handler
///
/// This command attempts to fetch lease4 statistics for one or
/// This command attempts to fetch lease4 statistics for one or
/// more subnets based upon subnet selection criteria (or lack thereof).
/// It extracts the command name and arguments from the given Callouthandle,
/// attempts to process them, and then set's the handle's "response"
......@@ -40,10 +37,10 @@ public:
/// {
/// "command": "stat-lease4-get",
/// "arguments": {
/// "subnet-id": x // optional
/// "subnet-id": 10 // optional
/// "subnet-range": { // optional
/// "first-subnet-id": x, // id >= x
/// "last-subnet-id": y // id <= x
/// "first-subnet-id": 10, // id >= 10
/// "last-subnet-id": 50 // id <= 50
/// }
/// }
/// }
......@@ -56,7 +53,7 @@ public:
/// "arguments": {
/// "result-set": {
/// "timestamp": "2018-03-22 09:43:30.815371",
/// "columns": ["subnet_id", "total-addresses",
/// "columns": ["subnet_id", "total-addresses",
/// "assigned-addresses", "declined-addresses"],
/// "rows": [
/// [1, 600, 450, 3],
......@@ -75,7 +72,7 @@ public:
/// @brief stat-lease6-get command handler
///
/// This command attempts to fetch lease6 statistics for one or
/// This command attempts to fetch lease6 statistics for one or
/// more subnets based upon subnet selection criteria (or lack thereof).
/// It extracts the command name and arguments from the given Callouthandle,
/// attempts to process them, and then set's the handle's "response"
......@@ -83,10 +80,10 @@ public:
/// {
/// "command": "stat-lease6-get",
/// "arguments": {
/// "subnet-id": x // optional
/// "subnet-id": 10 // optional
/// "subnet-range": { // optional
/// "first-subnet-id": x, // id >= x
/// "last-subnet-id": y // id <= x
/// "first-subnet-id": 10, // id >= 10
/// "last-subnet-id": 50 // id <= 50
/// }
/// }
/// }
......@@ -99,8 +96,8 @@ public:
/// "arguments": {
/// "result-set": {
/// "timestamp": "2018-03-22 09:43:30.815371",
/// "columns": ["subnet_id", "total-nas",
/// "assigned-nas", "declined-nas",
/// "columns": ["subnet_id", "total-nas",
/// "assigned-nas", "declined-nas",
/// "total-pds", "assigned-pds"],
/// "rows": [
/// [1, 600, 450, 3, 64, 10],
......@@ -116,11 +113,6 @@ public:
/// @return result of the operation
int
statLease6GetHandler(hooks::CalloutHandle& handle);
#if 0
private:
/// Pointer to the actual implementation
boost::shared_ptr<StatCmdsImpl> impl_;
#endif
};
};
......
......@@ -13,8 +13,6 @@
#include <cc/command_interpreter.h>
#include <hooks/hooks.h>
using namespace isc::config;
using namespace isc::data;
using namespace isc::hooks;
using namespace isc::stat_cmds;
......@@ -49,7 +47,7 @@ int stat_lease6_get(CalloutHandle& handle) {
int load(LibraryHandle& handle) {
handle.registerCommandCallout("stat-lease4-get", stat_lease4_get);
handle.registerCommandCallout("stat-lease6-get", stat_lease6_get);
LOG_INFO(stat_cmds_logger, STAT_CMDS_INIT_OK);
LOG_INFO(stat_cmds_logger, STAT_CMDS_CMDS_INIT_OK);
return (0);
}
......@@ -57,7 +55,7 @@ int load(LibraryHandle& handle) {
///
/// @return 0 if deregistration was successful, 1 otherwise
int unload() {
LOG_INFO(stat_cmds_logger, STAT_CMDS_DEINIT_OK);
LOG_INFO(stat_cmds_logger, STAT_CMDS_CMDS_DEINIT_OK);
return (0);
}
......
......@@ -9,7 +9,7 @@
namespace isc {
namespace stat_cmds {
isc::log::Logger stat_cmds_logger("stat_cmds_hooks");
isc::log::Logger stat_cmds_logger("stat-cmds-hooks");
}
}
......
# Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC")
% STAT_LEASE4_GET stat-lease4-get command successful (parameters: %1)
The stat-lease4-get command has been successful. Parameters of the command
are logged.
% STAT_CMDS_LEASE4_GET stat-lease4-get command successful, parameters: %1 rows found: %2
The stat-lease4-get command has been successful. The log will contain
the parameters supplied and the number of rows found.
% STAT_LEASE4_GET_FAILED stat-lease4-get command failed (parameters: %1, reason: %2)
The stat-lease4-get command has failed. Both the reason as well as the
parameters passed are logged.
% STAT_CMDS_LEASE4_GET_FAILED stat-lease4-get command failed: parameters: %1, reason: %2
The stat-lease4-get command has failed. Both the parameters supplied and
the reason for failure are logged.
% STAT_LEASE6_GET stat-lease4-get command successful (parameters: %1)
The stat-lease4-get command has been successful. Parameters of the command
are logged.
% STAT_CMDS_LEASE4_GET_INVALID stat-lease4-get command is malformed or invalid, reason: %1
The stat-lease4-get command was either malformed or contained invalid
parameters. A detailed explanation should be logged.
% STAT_LEASE6_GET_FAILED stat-lease4-get command failed (parameters: %1, reason: %2)
The stat-lease4-get command has failed. Both the reason as well as the
parameters passed are logged.
% STAT_CMDS_LEASE4_GET_NO_SUBNETS stat-lease4-get, parameters: %1, %2"
The parameters submitted with stat-lease4-get were valid but excluded all
known subnets. The parameters supplied along with an explanation should
be logged.
% STAT_CMDS_DEINIT_FAILED unloading Stat Commands hooks library failed: %1
% STAT_CMDS_LEASE6_GET stat-lease6-get command successful, parameters: %1 rows found: %2
The stat-lease6-get command has been successful. The log will contain
the parameters supplied and the number of rows found.
% STAT_CMDS_LEASE6_GET_FAILED stat-lease4-get command failed: parameters: %1, reason: %2
The stat-lease6-get command has failed. Both the parameters supplied and
the reason for failure are logged.
% STAT_CMDS_LEASE6_GET_INVALID stat-lease6-get command is malformed or invalid, reason: %1
The stat-lease6-get command was either malformed or contained invalid
parameters. A detailed explanation should be logged.
% STAT_CMDS_LEASE6_GET_NO_SUBNETS stat-lease6-get, parameters: %1, %2"
The parameters submitted with stat-lease6-get were valid but excluded all
known subnets. The parameters supplied along with an explanation should
be logged.
% STAT_CMDS_CMDS_DEINIT_FAILED unloading Stat Commands hooks library failed: %1
This error message indicates an error during unloading the Lease Commands
hooks library. The details of the error are provided as argument of
the log message.
% STAT_CMDS_DEINIT_OK unloading Stat Commands hooks library successful
% STAT_CMDS_CMDS_DEINIT_OK unloading Stat Commands hooks library successful
This info message indicates that the Stat Commands hooks library has been
removed successfully.
% STAT_CMDS_INIT_FAILED loading Stat Commands hooks library failed: %1
% STAT_CMDS_CMDS_INIT_FAILED loading Stat Commands hooks library failed: %1
This error message indicates an error during loading the Lease Commands
hooks library. The details of the error are provided as argument of
the log message.
% STAT_CMDS_INIT_OK loading Stat Commands hooks library successful
% STAT_CMDS_CMDS_INIT_OK loading Stat Commands hooks library successful
This info message indicates that the Stat Commands hooks library has been
loaded successfully. Enjoy!
......@@ -35,12 +35,18 @@ stat_cmds_unittests_LDFLAGS = $(AM_LDFLAGS) $(CRYPTO_LDFLAGS) $(GTEST_LDFLAGS)
stat_cmds_unittests_CXXFLAGS = $(AM_CXXFLAGS)
stat_cmds_unittests_LDADD = $(top_builddir)/src/lib/dhcpsrv/libkea-dhcpsrv.la
stat_cmds_unittests_LDADD += $(top_builddir)/src/lib/dhcp/libkea-dhcp++.la
stat_cmds_unittests_LDADD += $(top_builddir)/src/lib/config/libkea-cfgclient.la
stat_cmds_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la
stat_cmds_unittests_LDADD += $(top_builddir)/src/lib/dns/libkea-dns++.la
stat_cmds_unittests_LDADD += $(top_builddir)/src/lib/cc/libkea-cc.la
stat_cmds_unittests_LDADD += $(top_builddir)/src/lib/config/libkea-cfgclient.la
stat_cmds_unittests_LDADD += $(top_builddir)/src/lib/hooks/libkea-hooks.la
stat_cmds_unittests_LDADD += $(top_builddir)/src/lib/dhcp/libkea-dhcp++.la
stat_cmds_unittests_LDADD += $(top_builddir)/src/lib/eval/libkea-eval.la
stat_cmds_unittests_LDADD += $(top_builddir)/src/lib/dhcp_ddns/libkea-dhcp_ddns.la
stat_cmds_unittests_LDADD += $(top_builddir)/src/lib/stats/libkea-stats.la
stat_cmds_unittests_LDADD += $(top_builddir)/src/lib/cryptolink/libkea-cryptolink.la
stat_cmds_unittests_LDADD += $(top_builddir)/src/lib/log/libkea-log.la
stat_cmds_unittests_LDADD += $(top_builddir)/src/lib/util/threads/libkea-threads.la
stat_cmds_unittests_LDADD += $(top_builddir)/src/lib/util/libkea-util.la
stat_cmds_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la
stat_cmds_unittests_LDADD += $(LOG4CPLUS_LIBS)
......
// Copyright (C) 2017 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
......
......@@ -526,13 +526,11 @@ public:
/// @brief Creates an IPv6 lease
///
/// Lease parameters: cltt = 12345678, fqdn-fwd = false, fqdn-rev = true,
/// hostname = myhost.example.com, preferred lifetime = 1800,
/// valid lifetime = 3600
///
/// @param ip_address IP address for the lease.
/// @param subnet_id subnet identifier
/// @param state lease state
/// @param state lease state of the lease, defaults to STATE_DEFAULT
/// @param lease_type type of the lease, defaults to TYPE_NA
/// @param prefix_len prefix length of the lease, defaults to 128
void addLease6(const std::string& ip_address, const SubnetID& subnet_id,
const int state = Lease::STATE_DEFAULT,
const Lease::Type& lease_type = Lease::TYPE_NA,
......@@ -556,10 +554,16 @@ public:
<< "cannot add lease6: " << lease->toText();
}
void addPrefix(const std::string& ip_address, const int prefix_len,
/// @brief Creates an IPv6 PD lease
///
/// @param prefix IP address prefix for the lease.
/// @param prefix_len prefix length of the lease
/// @param subnet_id subnet identifier
/// @param state lease state of the lease, defaults to STATE_DEFAULT
void addPrefix(const std::string& prefix, const int prefix_len,
const SubnetID& subnet_id,
const int state = Lease::STATE_DEFAULT) {
addLease6(ip_address, subnet_id, state, Lease::TYPE_PD, prefix_len);
addLease6(prefix, subnet_id, state, Lease::TYPE_PD, prefix_len);
}