19#include <boost/algorithm/string.hpp>
42 : page_size_(page_size) {
48 if (
page_size_ > std::numeric_limits<uint32_t>::max()) {
50 << std::numeric_limits<uint32_t>::max());
56 uint32_t iaid,
SubnetID subnet_id)
const {
61 <<
static_cast<int>(type) <<
", duid "
62 << duid.
toText() <<
", iaid " << iaid
63 <<
" and subnet-id " << subnet_id);
68 return (*col.begin());
73 using namespace stats;
75 StatsMgr& stats_mgr = StatsMgr::instance();
87 stats_mgr.setValue(
"declined-addresses", zero);
90 if (!stats_mgr.getObservation(
"reclaimed-declined-addresses")) {
91 stats_mgr.setValue(
"reclaimed-declined-addresses", zero);
95 if (!stats_mgr.getObservation(
"reclaimed-leases")) {
96 stats_mgr.setValue(
"reclaimed-leases", zero);
100 if (!stats_mgr.getObservation(
"cumulative-assigned-addresses")) {
101 stats_mgr.setValue(
"cumulative-assigned-addresses", zero);
109 for (
auto const& subnet : *subnets) {
110 SubnetID subnet_id = subnet->getID();
111 stats_mgr.setValue(StatsMgr::generateName(
"subnet", subnet_id,
112 "assigned-addresses"),
115 stats_mgr.setValue(StatsMgr::generateName(
"subnet", subnet_id,
116 "declined-addresses"),
119 const std::string name_rec_dec(StatsMgr::generateName(
"subnet", subnet_id,
120 "reclaimed-declined-addresses"));
121 if (!stats_mgr.getObservation(name_rec_dec)) {
122 stats_mgr.setValue(name_rec_dec, zero);
125 const std::string name_rec(StatsMgr::generateName(
"subnet", subnet_id,
126 "reclaimed-leases"));
127 if (!stats_mgr.getObservation(name_rec)) {
128 stats_mgr.setValue(name_rec, zero);
132 const std::string name_aa(StatsMgr::generateName(
"subnet", subnet_id,
133 StatsMgr::generateName(
"pool", pool->getID(),
134 "assigned-addresses")));
135 if (!stats_mgr.getObservation(name_aa)) {
136 stats_mgr.setValue(name_aa, zero);
139 const std::string& name_da(StatsMgr::generateName(
"subnet", subnet_id,
140 StatsMgr::generateName(
"pool", pool->getID(),
141 "declined-addresses")));
142 if (!stats_mgr.getObservation(name_da)) {
143 stats_mgr.setValue(name_da, zero);
146 const std::string& name_rec_dec(StatsMgr::generateName(
"subnet", subnet_id,
147 StatsMgr::generateName(
"pool", pool->getID(),
148 "reclaimed-declined-addresses")));
149 if (!stats_mgr.getObservation(name_rec_dec)) {
150 stats_mgr.setValue(name_rec_dec, zero);
153 const std::string& name_rec(StatsMgr::generateName(
"subnet", subnet_id,
154 StatsMgr::generateName(
"pool", pool->getID(),
155 "reclaimed-leases")));
156 if (!stats_mgr.getObservation(name_rec)) {
157 stats_mgr.setValue(name_rec, zero);
165 while (query->getNextRow(row)) {
168 stats_mgr.addValue(StatsMgr::generateName(
"subnet", row.
subnet_id_,
169 "assigned-addresses"),
173 stats_mgr.setValue(StatsMgr::generateName(
"subnet", row.
subnet_id_,
174 "declined-addresses"),
178 stats_mgr.addValue(
"declined-addresses", row.
state_count_);
182 stats_mgr.addValue(StatsMgr::generateName(
"subnet", row.
subnet_id_,
183 "assigned-addresses"),
196 while (query->getNextRow(row)) {
199 stats_mgr.addValue(StatsMgr::generateName(
"subnet", row.
subnet_id_,
200 StatsMgr::generateName(
"pool", row.
pool_id_,
201 "assigned-addresses")),
205 stats_mgr.setValue(StatsMgr::generateName(
"subnet", row.
subnet_id_,
206 StatsMgr::generateName(
"pool", row.
pool_id_,
207 "declined-addresses")),
212 stats_mgr.addValue(StatsMgr::generateName(
"subnet", row.
subnet_id_,
213 StatsMgr::generateName(
"pool", row.
pool_id_,
214 "assigned-addresses")),
221 : first_subnet_id_(0), last_subnet_id_(0), select_mode_(select_mode) {
223 isc_throw(
BadValue,
"LeaseStatsQuery: mode must be either ALL_SUBNETS or ALL_SUBNET_POOLS");
228 : first_subnet_id_(subnet_id), last_subnet_id_(0),
229 select_mode_(SINGLE_SUBNET) {
238 : first_subnet_id_(first_subnet_id), last_subnet_id_(last_subnet_id),
239 select_mode_(SUBNET_RANGE) {
251 "LeaseStatsQuery: last_subnet_id_must be > first_subnet_id_");
283 using namespace stats;
285 StatsMgr& stats_mgr = StatsMgr::instance();
297 stats_mgr.setValue(
"declined-addresses", zero);
299 if (!stats_mgr.getObservation(
"reclaimed-declined-addresses")) {
300 stats_mgr.setValue(
"reclaimed-declined-addresses", zero);
303 if (!stats_mgr.getObservation(
"reclaimed-leases")) {
304 stats_mgr.setValue(
"reclaimed-leases", zero);
308 if (!stats_mgr.getObservation(
"cumulative-assigned-nas")) {
309 stats_mgr.setValue(
"cumulative-assigned-nas", zero);
313 if (!stats_mgr.getObservation(
"cumulative-assigned-pds")) {
314 stats_mgr.setValue(
"cumulative-assigned-pds", zero);
322 for (
auto const& subnet : *subnets) {
323 SubnetID subnet_id = subnet->getID();
324 stats_mgr.setValue(StatsMgr::generateName(
"subnet", subnet_id,
328 stats_mgr.setValue(StatsMgr::generateName(
"subnet", subnet_id,
332 stats_mgr.setValue(StatsMgr::generateName(
"subnet", subnet_id,
333 "declined-addresses"),
336 if (!stats_mgr.getObservation(
337 StatsMgr::generateName(
"subnet", subnet_id,
338 "reclaimed-declined-addresses"))) {
340 StatsMgr::generateName(
"subnet", subnet_id,
341 "reclaimed-declined-addresses"),
345 if (!stats_mgr.getObservation(
346 StatsMgr::generateName(
"subnet", subnet_id,
347 "reclaimed-leases"))) {
349 StatsMgr::generateName(
"subnet", subnet_id,
355 const std::string& name_anas(StatsMgr::generateName(
"subnet", subnet_id,
356 StatsMgr::generateName(
"pool", pool->getID(),
358 if (!stats_mgr.getObservation(name_anas)) {
359 stats_mgr.setValue(name_anas, zero);
362 const std::string& name_da(StatsMgr::generateName(
"subnet", subnet_id,
363 StatsMgr::generateName(
"pool", pool->getID(),
364 "declined-addresses")));
365 if (!stats_mgr.getObservation(name_da)) {
366 stats_mgr.setValue(name_da, zero);
369 const std::string name_rec_dec(StatsMgr::generateName(
"subnet", subnet_id,
370 StatsMgr::generateName(
"pool", pool->getID(),
371 "reclaimed-declined-addresses")));
372 if (!stats_mgr.getObservation(name_rec_dec)) {
373 stats_mgr.setValue(name_rec_dec, zero);
376 const std::string& name_rec(StatsMgr::generateName(
"subnet", subnet_id,
377 StatsMgr::generateName(
"pool", pool->getID(),
378 "reclaimed-leases")));
379 if (!stats_mgr.getObservation(name_rec)) {
380 stats_mgr.setValue(name_rec, zero);
385 const std::string& name_apds(StatsMgr::generateName(
"subnet", subnet_id,
386 StatsMgr::generateName(
"pd-pool", pool->getID(),
388 if (!stats_mgr.getObservation(name_apds)) {
389 stats_mgr.setValue(name_apds, zero);
392 const std::string& name_rec(StatsMgr::generateName(
"subnet", subnet_id,
393 StatsMgr::generateName(
"pd-pool", pool->getID(),
394 "reclaimed-leases")));
395 if (!stats_mgr.getObservation(name_rec)) {
396 stats_mgr.setValue(name_rec, zero);
404 while (query->getNextRow(row)) {
409 stats_mgr.addValue(StatsMgr::generateName(
"subnet", row.
subnet_id_,
414 stats_mgr.setValue(StatsMgr::generateName(
"subnet", row.
subnet_id_,
415 "declined-addresses"),
419 stats_mgr.addValue(
"declined-addresses", row.
state_count_);
423 stats_mgr.addValue(StatsMgr::generateName(
"subnet", row.
subnet_id_,
432 stats_mgr.setValue(StatsMgr::generateName(
"subnet", row.
subnet_id_,
452 while (query->getNextRow(row)) {
457 stats_mgr.addValue(StatsMgr::generateName(
"subnet", row.
subnet_id_,
458 StatsMgr::generateName(
"pool", row.
pool_id_,
463 stats_mgr.setValue(StatsMgr::generateName(
"subnet", row.
subnet_id_,
464 StatsMgr::generateName(
"pool", row.
pool_id_,
465 "declined-addresses")),
470 stats_mgr.addValue(StatsMgr::generateName(
"subnet", row.
subnet_id_,
471 StatsMgr::generateName(
"pool", row.
pool_id_,
480 stats_mgr.setValue(StatsMgr::generateName(
"subnet", row.
subnet_id_,
481 StatsMgr::generateName(
"pd-pool", row.
pool_id_,
522 std::string extended_info_tables;
524 extended_info_tables = parameters.at(
"extended-info-tables");
525 }
catch (
const exception&) {
526 extended_info_tables =
"false";
529 if (extended_info_tables ==
"true") {
539 bool changed =
false;
568 string verifying =
"";
569 bool removed_extended_info =
false;
572 verifying =
"user context";
576 if (user_context->empty()) {
583 isc = user_context->get(
"ISC");
587 mutable_user_context =
588 boost::const_pointer_cast<Element>(user_context);
589 if (!mutable_user_context) {
591 mutable_user_context =
copy(user_context, 0);
592 lease->setContext(mutable_user_context);
600 mutable_user_context->remove(
"ISC");
601 if (mutable_user_context->empty()) {
607 verifying =
"relay-agent-info";
608 extended_info =
isc->get(
"relay-agent-info");
609 if (!extended_info) {
612 mutable_isc = boost::const_pointer_cast<Element>(
isc);
616 mutable_user_context->set(
"ISC", mutable_isc);
623 upgraded->set(
"sub-options", extended_info);
624 mutable_isc->set(
"relay-agent-info", upgraded);
628 string rai_hex = extended_info->stringValue();
629 vector<uint8_t> rai_data;
638 vector<uint8_t> bytes = remote_id->toBinary();
639 if (bytes.size() > 0) {
640 upgraded->set(
"remote-id",
647 vector<uint8_t> bytes = relay_id->toBinary(
false);
648 if (bytes.size() > 0) {
649 upgraded->set(
"relay-id",
656 .arg(lease->addr_.toText());
659 mutable_isc->remove(
"relay-agent-info");
660 removed_extended_info =
true;
671 verifying =
"sub-options";
673 mutable_isc->remove(
"relay-agent-info");
674 removed_extended_info =
true;
677 string rai_hex = sub_options->stringValue();
678 vector<uint8_t> rai_data;
684 verifying =
"remote-id";
686 mutable_isc->remove(
"relay-agent-info");
687 removed_extended_info =
true;
690 string remote_id_hex = remote_id->stringValue();
691 vector<uint8_t> remote_id_data;
693 if (remote_id_data.empty()) {
694 mutable_isc->remove(
"relay-agent-info");
695 removed_extended_info =
true;
702 verifying =
"relay-id";
704 mutable_isc->remove(
"relay-agent-info");
705 removed_extended_info =
true;
708 string relay_id_hex = relay_id->stringValue();
709 vector<uint8_t> relay_id_data;
711 if (relay_id_data.empty()) {
712 mutable_isc->remove(
"relay-agent-info");
713 removed_extended_info =
true;
722 verifying =
"relay-agent-info";
723 for (
auto const& elem : extended_info->mapValue()) {
724 if ((elem.first !=
"sub-options") &&
725 (elem.first !=
"remote-id") &&
726 (elem.first !=
"relay-id") &&
727 (elem.first !=
"comment")) {
728 mutable_isc->remove(
"relay-agent-info");
729 removed_extended_info =
true;
731 "' entry in relay-agent-info");
736 }
catch (
const exception& ex) {
738 err <<
"in " << verifying <<
" a problem was found: " << ex.what();
740 .arg(lease->addr_.toText())
744 if (verifying ==
"user context") {
746 }
else if (verifying ==
"isc") {
747 mutable_user_context->remove(
"ISC");
748 if (mutable_user_context->empty()) {
752 if (!removed_extended_info) {
753 mutable_isc->remove(
"relay-agent-info");
755 if (mutable_isc->empty()) {
756 mutable_user_context->remove(
"ISC");
757 if (mutable_user_context->empty()) {
769 bool changed =
false;
787 string verifying =
"";
788 bool removed_relay_info =
false;
789 bool upgraded =
false;
790 bool have_both =
false;
794 verifying =
"user context";
798 if (user_context->empty()) {
805 isc = user_context->get(
"ISC");
809 mutable_user_context =
810 boost::const_pointer_cast<Element>(user_context);
811 if (!mutable_user_context) {
813 mutable_user_context =
copy(user_context, 0);
814 lease->setContext(mutable_user_context);
822 mutable_user_context->remove(
"ISC");
823 if (mutable_user_context->empty()) {
828 mutable_isc = boost::const_pointer_cast<Element>(
isc);
832 mutable_user_context->set(
"ISC", mutable_isc);
835 relay_info = mutable_isc->get(
"relays");
836 if (relay_info &&
isc->contains(
"relay-info")) {
838 mutable_isc->remove(
"relays");
846 verifying =
"relays";
847 mutable_isc->set(
"relay-info", relay_info);
848 mutable_isc->remove(
"relays");
851 mutable_isc->remove(
"relay-info");
852 removed_relay_info =
true;
855 if (relay_info->empty()) {
856 mutable_isc->remove(
"relay-info");
857 removed_relay_info =
true;
862 for (i = 0; i < relay_info->size(); ++i) {
863 ElementPtr relay = relay_info->getNonConst(i);
865 mutable_isc->remove(
"relay-info");
866 removed_relay_info =
true;
870 mutable_isc->remove(
"relay-info");
871 removed_relay_info =
true;
881 verifying =
"options";
883 mutable_isc->remove(
"relay-info");
884 removed_relay_info =
true;
887 string options_hex = options->stringValue();
888 vector<uint8_t> options_data;
894 if (remote_id_it != opts.end()) {
895 OptionPtr remote_id = remote_id_it->second;
897 vector<uint8_t> bytes = remote_id->toBinary();
898 if (bytes.size() > 0) {
899 relay->set(
"remote-id",
906 if (relay_id_it != opts.end()) {
907 OptionPtr relay_id = relay_id_it->second;
909 vector<uint8_t> bytes = relay_id->toBinary(
false);
910 if (bytes.size() > 0) {
911 relay->set(
"relay-id",
919 verifying = (upgraded ?
"relays" :
"relay-info");
921 relay_info = mutable_isc->get(
"relay-info");
926 mutable_isc->remove(
"relay-info");
927 removed_relay_info =
true;
930 if (!upgraded && relay_info->empty()) {
931 mutable_isc->remove(
"relay-info");
932 removed_relay_info =
true;
937 for (i = 0; i < relay_info->size(); ++i) {
938 ElementPtr relay = relay_info->getNonConst(i);
939 if (!upgraded && !relay) {
940 mutable_isc->remove(
"relay-info");
941 removed_relay_info =
true;
945 mutable_isc->remove(
"relay-info");
946 removed_relay_info =
true;
951 if (!upgraded && options) {
953 verifying =
"options";
955 mutable_isc->remove(
"relay-info");
956 removed_relay_info =
true;
959 string options_hex = options->stringValue();
960 vector<uint8_t> options_data;
972 mutable_isc->remove(
"relay-info");
973 removed_relay_info =
true;
977 mutable_isc->remove(
"relay-info");
978 removed_relay_info =
true;
981 IOAddress laddr(link_addr->stringValue());
983 mutable_isc->remove(
"relay-info");
984 removed_relay_info =
true;
989 if (!upgraded && remote_id) {
990 verifying =
"remote-id";
992 mutable_isc->remove(
"relay-info");
993 removed_relay_info =
true;
996 string remote_id_hex = remote_id->stringValue();
997 vector<uint8_t> remote_id_data;
999 if (remote_id_data.empty()) {
1000 mutable_isc->remove(
"relay-info");
1001 removed_relay_info =
true;
1007 if (!upgraded && relay_id) {
1008 verifying =
"relay-id";
1010 mutable_isc->remove(
"relay-info");
1011 removed_relay_info =
true;
1014 string relay_id_hex = relay_id->stringValue();
1015 vector<uint8_t> relay_id_data;
1017 if (relay_id_data.empty()) {
1018 mutable_isc->remove(
"relay-info");
1019 removed_relay_info =
true;
1031 mutable_isc->remove(
"relay-info");
1032 removed_relay_info =
true;
1036 mutable_isc->remove(
"relay-info");
1037 removed_relay_info =
true;
1040 IOAddress paddr(peer_addr->stringValue());
1041 if (!paddr.
isV6()) {
1042 mutable_isc->remove(
"relay-info");
1043 removed_relay_info =
true;
1050 mutable_isc->remove(
"relay-info");
1051 removed_relay_info =
true;
1055 mutable_isc->remove(
"relay-info");
1056 removed_relay_info =
true;
1060 verifying = (upgraded ?
"relays" :
"relay-info");
1061 for (
auto const& elem : relay->mapValue()) {
1062 if ((elem.first !=
"hop") &&
1063 (elem.first !=
"link") &&
1064 (elem.first !=
"peer") &&
1065 (elem.first !=
"options") &&
1066 (elem.first !=
"remote-id") &&
1067 (elem.first !=
"relay-id") &&
1068 (elem.first !=
"comment")) {
1069 mutable_isc->remove(
"relay-info");
1070 removed_relay_info =
true;
1079 .arg(lease->addr_.toText());
1083 }
catch (
const exception& ex) {
1085 err <<
"in " << verifying;
1087 err <<
" [relay#" << i <<
"]";
1089 err <<
" a problem was found: " << ex.what();
1091 .arg(lease->addr_.toText())
1095 have_both = !have_both;
1096 if (verifying ==
"user context") {
1098 }
else if (verifying ==
"isc") {
1099 mutable_user_context->remove(
"ISC");
1100 if (mutable_user_context->empty()) {
1104 if (!removed_relay_info) {
1105 mutable_isc->remove(
"relay-info");
1107 if (mutable_isc->empty()) {
1108 mutable_user_context->remove(
"ISC");
1109 if (mutable_user_context->empty()) {
1120 bool ignore_errors) {
1126 if (!user_context) {
1130 if (ignore_errors) {
1135 if (user_context->empty()) {
1144 if (ignore_errors) {
1154 if (!extended_info) {
1158 if (ignore_errors) {
1163 if (extended_info->empty()) {
1170 vector<uint8_t> bytes;
1175 if (!ignore_errors) {
1179 lease->relay_id_ = bytes;
1180 }
else if (!ignore_errors) {
1188 vector<uint8_t> bytes;
1193 if (!ignore_errors) {
1197 lease->remote_id_ = bytes;
1198 }
else if (!ignore_errors) {
1213 if (!user_context || (user_context->getType() !=
Element::map) ||
1214 user_context->empty()) {
1224 if (!relay_info || (relay_info->getType() !=
Element::list) ||
1225 relay_info->empty()) {
1229 for (
int i = 0; i < relay_info->size(); ++i) {
1231 if (!relay || (relay->getType() !=
Element::map) || relay->empty()) {
1237 string relay_id_hex = relay_id->stringValue();
1238 vector<uint8_t> relay_id_data;
1240 if (relay_id_data.empty()) {
1249 string remote_id_hex = remote_id->stringValue();
1250 vector<uint8_t> remote_id_data;
1252 if (remote_id_data.empty()) {
1258 }
catch (
const exception&) {
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
A generic exception that is thrown when a function is not implemented.
A generic exception that is thrown if a parameter given to a method would refer to or modify out-of-r...
A generic exception that is thrown when an unexpected error condition occurs.
The IOAddress class represents an IP addresses (version agnostic)
bool isV6() const
Convenience function to check for an IPv6 address.
static ElementPtr create(const Position &pos=ZERO_POSITION())
static ElementPtr createMap(const Position &pos=ZERO_POSITION())
Creates an empty MapElement type ElementPtr.
std::map< std::string, std::string > ParameterMap
Database configuration parameter map.
Multiple lease records found where one expected.
ExtendedInfoSanity
Values for extended info sanity checks done for leases.
@ EXTENDED_INFO_CHECK_PEDANTIC
@ EXTENDED_INFO_CHECK_FIX
@ EXTENDED_INFO_CHECK_NONE
static CfgMgr & instance()
returns a single instance of Configuration Manager
SrvConfigPtr getCurrentCfg()
Returns a pointer to the current configuration.
Holds DUID (DHCPv6 Unique Identifier)
std::string toText() const
Returns textual representation of the identifier (e.g.
virtual LeaseStatsQueryPtr startSubnetLeaseStatsQuery6(const SubnetID &subnet_id)
Creates and runs the IPv6 lease stats query for a single subnet.
virtual LeaseStatsQueryPtr startPoolLeaseStatsQuery6()
Creates and runs the IPv6 lease stats query for all subnets and pools.
virtual Lease6Collection getLeases6() const =0
Returns all IPv6 leases.
void recountLeaseStats6()
Recalculates per-subnet and global stats for IPv6 leases.
void setExtendedInfoTablesEnabled(const bool enabled)
Modifies the setting whether the lease6 extended info tables are enabled.
virtual size_t byRelayId6size() const
Return the by-relay-id table size.
static bool upgradeLease6ExtendedInfo(const Lease6Ptr &lease, CfgConsistency::ExtendedInfoSanity check=CfgConsistency::EXTENDED_INFO_CHECK_FIX)
Upgrade a V6 lease user context to the new extended info entry.
virtual size_t byRemoteId6size() const
Return the by-remote-id table size.
virtual void addRelayId6(const isc::asiolink::IOAddress &lease_addr, const std::vector< uint8_t > &relay_id)=0
Add lease6 extended info into by-relay-id table.
virtual LeaseStatsQueryPtr startSubnetRangeLeaseStatsQuery4(const SubnetID &first_subnet_id, const SubnetID &last_subnet_id)
Creates and runs the IPv4 lease stats query for a single subnet.
void recountLeaseStats4()
Recalculates per-subnet and global stats for IPv4 leases.
static std::string getDBVersion()
Class method to return extended version info This class method must be redeclared and redefined in de...
virtual LeaseStatsQueryPtr startSubnetRangeLeaseStatsQuery6(const SubnetID &first_subnet_id, const SubnetID &last_subnet_id)
Creates and runs the IPv6 lease stats query for a single subnet.
virtual LeaseStatsQueryPtr startSubnetLeaseStatsQuery4(const SubnetID &subnet_id)
Creates and runs the IPv4 lease stats query for a single subnet.
virtual Lease6Ptr getLease6(Lease::Type type, const isc::asiolink::IOAddress &addr) const =0
Returns existing IPv6 lease for a given IPv6 address.
virtual LeaseStatsQueryPtr startLeaseStatsQuery4()
Creates and runs the IPv4 lease stats query for all subnets.
static void extractLease4ExtendedInfo(const Lease4Ptr &lease, bool ignore_errors=true)
Extract relay and remote identifiers from the extended info.
static bool upgradeLease4ExtendedInfo(const Lease4Ptr &lease, CfgConsistency::ExtendedInfoSanity check=CfgConsistency::EXTENDED_INFO_CHECK_FIX)
The following queries are used to fulfill Bulk Lease Query queries.
virtual void addRemoteId6(const isc::asiolink::IOAddress &lease_addr, const std::vector< uint8_t > &remote_id)=0
Add lease6 extended info into by-remote-id table.
virtual LeaseStatsQueryPtr startPoolLeaseStatsQuery4()
Creates and runs the IPv4 lease stats query for all subnets and pools.
virtual bool addExtendedInfo6(const Lease6Ptr &lease)
Extract extended info from a lease6 and add it into tables.
virtual LeaseStatsQueryPtr startLeaseStatsQuery6()
Creates and runs the IPv6 lease stats query for all subnets.
const size_t page_size_
Holds page size.
LeasePageSize(const size_t page_size)
Constructor.
LeaseStatsQuery(const SelectMode &select_mode=ALL_SUBNETS)
Constructor to query statistics for all subnets.
SubnetID first_subnet_id_
First (or only) subnet_id in the selection criteria.
SubnetID last_subnet_id_
Last subnet_id in the selection criteria when a range is given.
virtual bool getNextRow(LeaseStatsRow &row)
Fetches the next row of data.
SelectMode
Defines the types of selection criteria supported.
static OptionDefinitionPtr getOptionDef(const std::string &space, const uint16_t code)
Return the first option definition matching a particular option code.
static size_t unpackOptions6(const OptionBuffer &buf, const std::string &option_space, isc::dhcp::OptionCollection &options, size_t *relay_msg_offset=0, size_t *relay_msg_len=0)
Parses provided buffer as DHCPv6 options and creates Option objects.
Option with defined data fields represented as buffers that can be accessed using data field index.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
An abstract API for lease database.
#define LOG_ERROR(LOGGER, MESSAGE)
Macro to conveniently test error output and log it.
#define LOG_DEBUG(LOGGER, LEVEL, MESSAGE)
Macro to conveniently test debug output and log it.
ElementPtr copy(ConstElementPtr from, int level)
Copy the data up to a nesting level.
boost::shared_ptr< const Element > ConstElementPtr
boost::shared_ptr< Element > ElementPtr
isc::log::Logger dhcpsrv_logger("dhcpsrv")
DHCP server library Logger.
const isc::log::MessageID DHCPSRV_LEASE6_EXTENDED_INFO_UPGRADED
boost::shared_ptr< OptionCustom > OptionCustomPtr
A pointer to the OptionCustom object.
boost::shared_ptr< Lease6 > Lease6Ptr
Pointer to a Lease6 structure.
std::vector< Lease6Ptr > Lease6Collection
A collection of IPv6 leases.
boost::shared_ptr< LeaseStatsQuery > LeaseStatsQueryPtr
Defines a pointer to a LeaseStatsQuery.
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.
std::multimap< unsigned int, OptionPtr > OptionCollection
A collection of DHCP (v4 or v6) options.
boost::shared_ptr< OptionDefinition > OptionDefinitionPtr
Pointer to option definition object.
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.
uint32_t SubnetID
Defines unique IPv4 or IPv6 subnet identifier.
const isc::log::MessageID DHCPSRV_LEASE4_EXTENDED_INFO_SANITY_FAIL
const isc::log::MessageID DHCPSRV_LEASE4_EXTENDED_INFO_UPGRADED
boost::shared_ptr< Lease4 > Lease4Ptr
Pointer to a Lease4 structure.
const int DHCPSRV_DBG_TRACE
DHCP server library logging levels.
boost::shared_ptr< Option > OptionPtr
const isc::log::MessageID DHCPSRV_LEASE6_EXTENDED_INFO_SANITY_FAIL
void decodeHex(const string &encoded_str, vector< uint8_t > &output)
Decode a base16 encoded string into binary data.
string encodeHex(const vector< uint8_t > &binary)
Encode binary data in the base16 format.
void decodeFormattedHexString(const string &hex_string, vector< uint8_t > &binary)
Converts a formatted string of hexadecimal digits into a vector.
Defines the logger used by the top-level component of kea-lfc.
#define DHCP4_OPTION_SPACE
global std option spaces
#define DHCP6_OPTION_SPACE
Contains a single row of lease statistical data.
uint32_t pool_id_
The pool ID to which this data applies.
int64_t state_count_
state_count The count of leases in the lease state
uint32_t lease_state_
The lease_state to which the count applies.
SubnetID subnet_id_
The subnet ID to which this data applies.
Lease::Type lease_type_
The lease_type to which the count applies.
static const uint32_t STATE_DEFAULT
A lease in the default state.
static const uint32_t STATE_DECLINED
Declined lease.
Type
Type of lease or pool.
@ TYPE_PD
the lease contains IPv6 prefix (for prefix delegation)
@ TYPE_NA
the lease contains non-temporary IPv6 address