21#include <boost/algorithm/string.hpp>
52 if (
page_size_ > std::numeric_limits<uint32_t>::max()) {
54 << std::numeric_limits<uint32_t>::max());
60 uint32_t iaid,
SubnetID subnet_id)
const {
65 <<
static_cast<int>(type) <<
", duid "
66 << duid.
toText() <<
", iaid " << iaid
67 <<
" and subnet-id " << subnet_id);
72 return (*col.begin());
77 using namespace stats;
92 stats_mgr.
setValue(
"assigned-addresses", zero);
94 stats_mgr.
setValue(
"declined-addresses", zero);
98 stats_mgr.
setValue(
"reclaimed-declined-addresses", zero);
103 stats_mgr.
setValue(
"reclaimed-leases", zero);
108 stats_mgr.
setValue(
"cumulative-assigned-addresses", zero);
116 for (
auto const& subnet : *subnets) {
117 SubnetID subnet_id = subnet->getID();
119 "assigned-addresses"),
123 "declined-addresses"),
127 "reclaimed-declined-addresses"));
129 stats_mgr.
setValue(name_rec_dec, zero);
133 "reclaimed-leases"));
141 "assigned-addresses")));
148 "declined-addresses")));
155 "reclaimed-declined-addresses")));
157 stats_mgr.
setValue(pname_rec_dec, zero);
162 "reclaimed-leases")));
164 stats_mgr.
setValue(pname_rec, zero);
172 while (query->getNextRow(row)) {
179 "assigned-addresses"),
184 "declined-addresses"),
196 "assigned-addresses"),
209 while (query->getNextRow(row)) {
214 "assigned-addresses")),
220 "declined-addresses")),
227 "assigned-addresses")),
236 isc_throw(
BadValue,
"LeaseStatsQuery: mode must be either ALL_SUBNETS or ALL_SUBNET_POOLS");
264 "LeaseStatsQuery: last_subnet_id_must be > first_subnet_id_");
296 using namespace stats;
312 stats_mgr.
setValue(
"assigned-nas", zero);
314 stats_mgr.
setValue(
"assigned-pds", zero);
316 stats_mgr.
setValue(
"declined-addresses", zero);
319 stats_mgr.
setValue(
"reclaimed-declined-addresses", zero);
323 stats_mgr.
setValue(
"reclaimed-leases", zero);
328 stats_mgr.
setValue(
"cumulative-assigned-nas", zero);
333 stats_mgr.
setValue(
"cumulative-assigned-pds", zero);
338 stats_mgr.
setValue(
"cumulative-registered-nas", zero);
346 for (
auto const& subnet : *subnets) {
347 SubnetID subnet_id = subnet->getID();
357 "declined-addresses"),
362 "reclaimed-declined-addresses"))) {
365 "reclaimed-declined-addresses"),
371 "reclaimed-leases"))) {
380 "registered-nas"))) {
392 stats_mgr.
setValue(name_anas, zero);
397 "declined-addresses")));
404 "reclaimed-declined-addresses")));
406 stats_mgr.
setValue(name_rec_dec, zero);
411 "reclaimed-leases")));
422 stats_mgr.
setValue(name_apds, zero);
427 "reclaimed-leases")));
437 while (query->getNextRow(row)) {
451 "declined-addresses"),
499 while (query->getNextRow(row)) {
512 "declined-addresses")),
569 std::string extended_info_tables;
571 extended_info_tables = parameters.at(
"extended-info-tables");
572 }
catch (
const exception&) {
573 extended_info_tables =
"false";
576 if (extended_info_tables ==
"true") {
586 bool changed =
false;
604 string verifying =
"";
605 bool removed_extended_info =
false;
608 verifying =
"user context";
612 if (user_context->empty()) {
619 isc = user_context->get(
"ISC");
623 mutable_user_context =
624 boost::const_pointer_cast<Element>(user_context);
625 if (!mutable_user_context) {
627 mutable_user_context =
copy(user_context, 0);
628 lease->setContext(mutable_user_context);
636 mutable_user_context->remove(
"ISC");
637 if (mutable_user_context->empty()) {
643 verifying =
"relay-agent-info";
644 extended_info =
isc->get(
"relay-agent-info");
645 if (!extended_info) {
648 mutable_isc = boost::const_pointer_cast<Element>(
isc);
652 mutable_user_context->set(
"ISC", mutable_isc);
659 upgraded->set(
"sub-options", extended_info);
660 mutable_isc->set(
"relay-agent-info", upgraded);
664 string rai_hex = extended_info->stringValue();
665 vector<uint8_t> rai_data;
674 vector<uint8_t> bytes = remote_id->toBinary();
675 if (bytes.size() > 0) {
676 upgraded->set(
"remote-id",
683 vector<uint8_t> bytes = relay_id->toBinary(
false);
684 if (bytes.size() > 0) {
685 upgraded->set(
"relay-id",
692 .arg(lease->addr_.toText());
695 mutable_isc->remove(
"relay-agent-info");
696 removed_extended_info =
true;
707 verifying =
"sub-options";
709 mutable_isc->remove(
"relay-agent-info");
710 removed_extended_info =
true;
713 string rai_hex = sub_options->stringValue();
714 vector<uint8_t> rai_data;
720 verifying =
"remote-id";
722 mutable_isc->remove(
"relay-agent-info");
723 removed_extended_info =
true;
726 string remote_id_hex = remote_id->stringValue();
727 vector<uint8_t> remote_id_data;
729 if (remote_id_data.empty()) {
730 mutable_isc->remove(
"relay-agent-info");
731 removed_extended_info =
true;
738 verifying =
"relay-id";
740 mutable_isc->remove(
"relay-agent-info");
741 removed_extended_info =
true;
744 string relay_id_hex = relay_id->stringValue();
745 vector<uint8_t> relay_id_data;
747 if (relay_id_data.empty()) {
748 mutable_isc->remove(
"relay-agent-info");
749 removed_extended_info =
true;
758 verifying =
"relay-agent-info";
759 for (
auto const& elem : extended_info->mapValue()) {
760 if ((elem.first !=
"sub-options") &&
761 (elem.first !=
"remote-id") &&
762 (elem.first !=
"relay-id") &&
763 (elem.first !=
"comment")) {
764 mutable_isc->remove(
"relay-agent-info");
765 removed_extended_info =
true;
767 "' entry in relay-agent-info");
772 }
catch (
const exception& ex) {
774 err <<
"in " << verifying <<
" a problem was found: " << ex.what();
776 .arg(lease->addr_.toText())
780 if (verifying ==
"user context") {
782 }
else if (verifying ==
"isc") {
783 mutable_user_context->remove(
"ISC");
784 if (mutable_user_context->empty()) {
788 if (!removed_extended_info) {
789 mutable_isc->remove(
"relay-agent-info");
791 if (mutable_isc->empty()) {
792 mutable_user_context->remove(
"ISC");
793 if (mutable_user_context->empty()) {
805 bool changed =
false;
823 string verifying =
"";
824 bool removed_relay_info =
false;
825 bool upgraded =
false;
826 bool have_both =
false;
830 verifying =
"user context";
834 if (user_context->empty()) {
841 isc = user_context->get(
"ISC");
845 mutable_user_context =
846 boost::const_pointer_cast<Element>(user_context);
847 if (!mutable_user_context) {
849 mutable_user_context =
copy(user_context, 0);
850 lease->setContext(mutable_user_context);
858 mutable_user_context->remove(
"ISC");
859 if (mutable_user_context->empty()) {
864 mutable_isc = boost::const_pointer_cast<Element>(
isc);
868 mutable_user_context->set(
"ISC", mutable_isc);
871 relay_info = mutable_isc->get(
"relays");
872 if (relay_info &&
isc->contains(
"relay-info")) {
874 mutable_isc->remove(
"relays");
882 verifying =
"relays";
883 mutable_isc->set(
"relay-info", relay_info);
884 mutable_isc->remove(
"relays");
887 mutable_isc->remove(
"relay-info");
888 removed_relay_info =
true;
891 if (relay_info->empty()) {
892 mutable_isc->remove(
"relay-info");
893 removed_relay_info =
true;
898 for (i = 0;
static_cast<size_t>(i) < relay_info->size(); ++i) {
899 ElementPtr relay = relay_info->getNonConst(i);
901 mutable_isc->remove(
"relay-info");
902 removed_relay_info =
true;
906 mutable_isc->remove(
"relay-info");
907 removed_relay_info =
true;
917 verifying =
"options";
919 mutable_isc->remove(
"relay-info");
920 removed_relay_info =
true;
923 string options_hex = options->stringValue();
924 vector<uint8_t> options_data;
930 if (remote_id_it != opts.end()) {
931 OptionPtr remote_id = remote_id_it->second;
933 vector<uint8_t> bytes = remote_id->toBinary();
934 if (bytes.size() > 0) {
935 relay->set(
"remote-id",
942 if (relay_id_it != opts.end()) {
943 OptionPtr relay_id = relay_id_it->second;
945 vector<uint8_t> bytes = relay_id->toBinary(
false);
946 if (bytes.size() > 0) {
947 relay->set(
"relay-id",
955 verifying = (upgraded ?
"relays" :
"relay-info");
957 relay_info = mutable_isc->get(
"relay-info");
962 mutable_isc->remove(
"relay-info");
963 removed_relay_info =
true;
966 if (!upgraded && relay_info->empty()) {
967 mutable_isc->remove(
"relay-info");
968 removed_relay_info =
true;
973 for (i = 0;
static_cast<size_t>(i) < relay_info->size(); ++i) {
974 ElementPtr relay = relay_info->getNonConst(i);
975 if (!upgraded && !relay) {
976 mutable_isc->remove(
"relay-info");
977 removed_relay_info =
true;
981 mutable_isc->remove(
"relay-info");
982 removed_relay_info =
true;
987 if (!upgraded && options) {
989 verifying =
"options";
991 mutable_isc->remove(
"relay-info");
992 removed_relay_info =
true;
995 string options_hex = options->stringValue();
996 vector<uint8_t> options_data;
1008 mutable_isc->remove(
"relay-info");
1009 removed_relay_info =
true;
1013 mutable_isc->remove(
"relay-info");
1014 removed_relay_info =
true;
1017 IOAddress laddr(link_addr->stringValue());
1018 if (!laddr.
isV6()) {
1019 mutable_isc->remove(
"relay-info");
1020 removed_relay_info =
true;
1025 if (!upgraded && remote_id) {
1026 verifying =
"remote-id";
1028 mutable_isc->remove(
"relay-info");
1029 removed_relay_info =
true;
1032 string remote_id_hex = remote_id->stringValue();
1033 vector<uint8_t> remote_id_data;
1035 if (remote_id_data.empty()) {
1036 mutable_isc->remove(
"relay-info");
1037 removed_relay_info =
true;
1043 if (!upgraded && relay_id) {
1044 verifying =
"relay-id";
1046 mutable_isc->remove(
"relay-info");
1047 removed_relay_info =
true;
1050 string relay_id_hex = relay_id->stringValue();
1051 vector<uint8_t> relay_id_data;
1053 if (relay_id_data.empty()) {
1054 mutable_isc->remove(
"relay-info");
1055 removed_relay_info =
true;
1067 mutable_isc->remove(
"relay-info");
1068 removed_relay_info =
true;
1072 mutable_isc->remove(
"relay-info");
1073 removed_relay_info =
true;
1076 IOAddress paddr(peer_addr->stringValue());
1077 if (!paddr.
isV6()) {
1078 mutable_isc->remove(
"relay-info");
1079 removed_relay_info =
true;
1086 mutable_isc->remove(
"relay-info");
1087 removed_relay_info =
true;
1091 mutable_isc->remove(
"relay-info");
1092 removed_relay_info =
true;
1096 verifying = (upgraded ?
"relays" :
"relay-info");
1097 for (
auto const& elem : relay->mapValue()) {
1098 if ((elem.first !=
"hop") &&
1099 (elem.first !=
"link") &&
1100 (elem.first !=
"peer") &&
1101 (elem.first !=
"options") &&
1102 (elem.first !=
"remote-id") &&
1103 (elem.first !=
"relay-id") &&
1104 (elem.first !=
"comment")) {
1105 mutable_isc->remove(
"relay-info");
1106 removed_relay_info =
true;
1115 .arg(lease->addr_.toText());
1119 }
catch (
const exception& ex) {
1121 err <<
"in " << verifying;
1123 err <<
" [relay#" << i <<
"]";
1125 err <<
" a problem was found: " << ex.what();
1127 .arg(lease->addr_.toText())
1131 have_both = !have_both;
1132 if (verifying ==
"user context") {
1134 }
else if (verifying ==
"isc") {
1135 mutable_user_context->remove(
"ISC");
1136 if (mutable_user_context->empty()) {
1140 if (!removed_relay_info) {
1141 mutable_isc->remove(
"relay-info");
1143 if (mutable_isc->empty()) {
1144 mutable_user_context->remove(
"ISC");
1145 if (mutable_user_context->empty()) {
1156 bool ignore_errors) {
1162 if (!user_context) {
1166 if (ignore_errors) {
1171 if (user_context->empty()) {
1180 if (ignore_errors) {
1190 if (!extended_info) {
1194 if (ignore_errors) {
1199 if (extended_info->empty()) {
1206 vector<uint8_t> bytes;
1211 if (!ignore_errors) {
1215 lease->relay_id_ = bytes;
1216 }
else if (!ignore_errors) {
1224 vector<uint8_t> bytes;
1229 if (!ignore_errors) {
1233 lease->remote_id_ = bytes;
1234 }
else if (!ignore_errors) {
1249 if (!user_context || (user_context->getType() !=
Element::map) ||
1250 user_context->empty()) {
1260 if (!relay_info || (relay_info->getType() !=
Element::list) ||
1261 relay_info->empty()) {
1265 for (
unsigned i = 0; i < relay_info->size(); ++i) {
1267 if (!relay || (relay->getType() !=
Element::map) || relay->empty()) {
1273 string relay_id_hex = relay_id->stringValue();
1274 vector<uint8_t> relay_id_data;
1276 if (relay_id_data.empty()) {
1285 string remote_id_hex = remote_id->stringValue();
1286 vector<uint8_t> remote_id_data;
1288 if (remote_id_data.empty()) {
1294 }
catch (
const exception&) {
1319 msg <<
"lease backend '" <<
getName() <<
"' is not 'memfile'";
1325 if (!lease->stateExpiredReclaimed()) {
1330 "assigned-addresses"),
1331 static_cast<int64_t
>(1));
1341 "assigned-addresses")),
1342 static_cast<int64_t
>(1));
1346 if (lease->stateDeclined()) {
1351 "declined-addresses"),
1352 static_cast<int64_t
>(1));
1358 "declined-addresses")),
1359 static_cast<int64_t
>(1));
1367 if (lease->stateRegistered()) {
1370 static_cast<int64_t
>(1));
1371 }
else if (!lease->stateExpiredReclaimed()) {
1373 "assigned-nas" :
"assigned-pds",
1374 static_cast<int64_t
>(1));
1379 "assigned-nas" :
"assigned-pds"),
1380 static_cast<int64_t
>(1));
1385 pool = subnet->getPool(lease->type_, lease->addr_,
false);
1390 "pool" :
"pd-pool", pool->getID(),
1392 "assigned-nas" :
"assigned-pds")),
1393 static_cast<int64_t
>(1));
1397 if (lease->stateDeclined()) {
1402 "declined-addresses"),
1403 static_cast<int64_t
>(1));
1409 "declined-addresses")),
1410 static_cast<int64_t
>(1));
1420 static_cast<int64_t
>(value));
1424 static_cast<int64_t
>(value));
1432 static_cast<int64_t
>(value));
1436 static_cast<int64_t
>(value));
1441#define STATE_MASK(new_state, old_state) ((new_state << 4) | old_state)
1512 if (existing->subnet_id_ == lease->subnet_id_) {
1513 if (existing->state_ == lease->state_) {
1521 getCfgSubnets4()->getBySubnetId(existing->subnet_id_);
1527 switch (
STATE_MASK(lease->state_ , existing->state_)) {
1529 bumpStat(
"declined-addresses", existing->subnet_id_, pool, -1);
1534 bumpStat(
"assigned-addresses", existing->subnet_id_, pool, 1);
1538 bumpStat(
"declined-addresses", existing->subnet_id_, pool, 1);
1543 bumpStat(
"assigned-addresses", existing->subnet_id_, pool, 1);
1544 bumpStat(
"declined-addresses", existing->subnet_id_, pool, 1);
1549 bumpStat(
"assigned-addresses", existing->subnet_id_, pool, -1);
1554 bumpStat(
"assigned-addresses", existing->subnet_id_, pool, -1);
1555 bumpStat(
"declined-addresses", existing->subnet_id_, pool, -1);
1568 getCfgSubnets4()->getBySubnetId(lease->subnet_id_);
1571 new_pool = new_subnet->getPool(
Lease::TYPE_V4, lease->addr_,
false);
1576 getCfgSubnets4()->getBySubnetId(existing->subnet_id_);
1578 if (existing_subnet) {
1579 existing_pool = existing_subnet->getPool(
Lease::TYPE_V4, existing->addr_,
false);
1583 switch (
STATE_MASK(lease->state_ , existing->state_)) {
1585 bumpStat(
"assigned-addresses", existing->subnet_id_, existing_pool, -1);
1586 bumpStat(
"assigned-addresses", lease->subnet_id_, new_pool, 1);
1590 bumpStat(
"assigned-addresses", existing->subnet_id_, existing_pool, -1);
1591 bumpStat(
"declined-addresses", existing->subnet_id_, existing_pool, -1);
1592 bumpStat(
"assigned-addresses", lease->subnet_id_, new_pool, 1);
1597 bumpStat(
"assigned-addresses", lease->subnet_id_, new_pool, 1);
1601 bumpStat(
"assigned-addresses", existing->subnet_id_, existing_pool, -1);
1602 bumpStat(
"assigned-addresses", lease->subnet_id_, new_pool, 1);
1603 bumpStat(
"declined-addresses", lease->subnet_id_, new_pool, 1);
1607 bumpStat(
"assigned-addresses", existing->subnet_id_, existing_pool, -1);
1608 bumpStat(
"declined-addresses", existing->subnet_id_, existing_pool, -1);
1609 bumpStat(
"assigned-addresses", lease->subnet_id_, new_pool, 1);
1610 bumpStat(
"declined-addresses", lease->subnet_id_, new_pool, 1);
1615 bumpStat(
"assigned-addresses", lease->subnet_id_, new_pool, 1);
1616 bumpStat(
"declined-addresses", lease->subnet_id_, new_pool, 1);
1621 bumpStat(
"assigned-addresses", existing->subnet_id_, existing_pool, -1);
1626 bumpStat(
"assigned-addresses", existing->subnet_id_, existing_pool, -1);
1627 bumpStat(
"declined-addresses", existing->subnet_id_, existing_pool, -1);
1641 if (existing->type_ != lease->type_) {
1655 if (existing->subnet_id_ == lease->subnet_id_) {
1656 if (existing->state_ == lease->state_) {
1664 getCfgSubnets6()->getBySubnetId(existing->subnet_id_);
1666 pool = subnet->getPool(existing->type_, existing->addr_,
false);
1670 switch (
STATE_MASK(lease->state_, existing->state_)) {
1672 bumpStat(
"declined-addresses", existing->subnet_id_, pool, -1);
1678 bumpStat(
"assigned-nas", existing->subnet_id_, pool, 1);
1685 bumpStat(
"assigned-nas", existing->subnet_id_, pool, 1);
1690 bumpStat(
"declined-addresses", existing->subnet_id_, pool, 1);
1695 bumpStat(
"assigned-nas", existing->subnet_id_, pool, 1);
1696 bumpStat(
"declined-addresses", existing->subnet_id_, pool, 1);
1700 bumpStat(
"declined-addresses", existing->subnet_id_, pool, 1);
1707 bumpStat(
"assigned-nas", existing->subnet_id_, pool, -1);
1720 bumpStat(
"assigned-nas", existing->subnet_id_, pool, -1);
1721 bumpStat(
"declined-addresses", existing->subnet_id_, pool, -1);
1725 bumpStat(
"assigned-nas", existing->subnet_id_, pool, -1);
1730 bumpStat(
"assigned-nas", existing->subnet_id_, pool, -1);
1731 bumpStat(
"declined-addresses", existing->subnet_id_, pool, -1);
1751 getCfgSubnets6()->getBySubnetId(lease->subnet_id_);
1754 new_pool = new_subnet->getPool(lease->type_, lease->addr_,
false);
1759 getCfgSubnets6()->getBySubnetId(existing->subnet_id_);
1761 if (existing_subnet) {
1762 existing_pool = existing_subnet->getPool(existing->type_, existing->addr_,
false);
1766 switch (
STATE_MASK(lease->state_, existing->state_)) {
1769 bumpStat(
"assigned-nas", existing->subnet_id_, existing_pool, -1);
1770 bumpStat(
"assigned-nas", lease->subnet_id_, new_pool, 1);
1772 bumpStatPrefix(
"assigned-pds", existing->subnet_id_, existing_pool, -1);
1778 bumpStat(
"assigned-nas", existing->subnet_id_, existing_pool, -1);
1779 bumpStat(
"declined-addresses", existing->subnet_id_, existing_pool, -1);
1780 bumpStat(
"assigned-nas", lease->subnet_id_, new_pool, 1);
1786 bumpStat(
"assigned-nas", lease->subnet_id_, new_pool, 1);
1794 bumpStat(
"assigned-nas", lease->subnet_id_, new_pool, 1);
1798 bumpStat(
"assigned-nas", existing->subnet_id_, existing_pool, -1);
1799 bumpStat(
"assigned-nas", lease->subnet_id_, new_pool, 1);
1800 bumpStat(
"declined-addresses", lease->subnet_id_, new_pool, 1);
1804 bumpStat(
"assigned-nas", existing->subnet_id_, existing_pool, -1);
1805 bumpStat(
"declined-addresses", existing->subnet_id_, existing_pool, -1);
1806 bumpStat(
"assigned-nas", lease->subnet_id_, new_pool, 1);
1807 bumpStat(
"declined-addresses", lease->subnet_id_, new_pool, 1);
1812 bumpStat(
"assigned-nas", lease->subnet_id_, new_pool, 1);
1813 bumpStat(
"declined-addresses", lease->subnet_id_, new_pool, 1);
1818 bumpStat(
"assigned-nas", lease->subnet_id_, new_pool, 1);
1819 bumpStat(
"declined-addresses", lease->subnet_id_, new_pool, 1);
1825 bumpStat(
"assigned-nas", existing->subnet_id_, existing_pool, -1);
1827 bumpStatPrefix(
"assigned-pds", existing->subnet_id_, existing_pool, -1);
1833 bumpStat(
"assigned-nas", existing->subnet_id_, existing_pool, -1);
1834 bumpStat(
"declined-addresses", existing->subnet_id_, existing_pool, -1);
1843 bumpStat(
"assigned-nas", existing->subnet_id_, existing_pool, -1);
1848 bumpStat(
"assigned-nas", existing->subnet_id_, existing_pool, -1);
1849 bumpStat(
"declined-addresses", existing->subnet_id_, existing_pool, -1);
1873 if (!lease->stateExpiredReclaimed()) {
1878 "assigned-addresses"),
1879 static_cast<int64_t
>(-1));
1889 "assigned-addresses")),
1890 static_cast<int64_t
>(-1));
1894 if (lease->stateDeclined()) {
1899 "declined-addresses"),
1900 static_cast<int64_t
>(-1));
1906 "declined-addresses")),
1907 static_cast<int64_t
>(-1));
1915 if (lease->stateRegistered()) {
1919 static_cast<int64_t
>(-1));
1920 }
else if (!lease->stateExpiredReclaimed()) {
1922 "assigned-nas" :
"assigned-pds",
1923 static_cast<int64_t
>(-1));
1928 "assigned-nas" :
"assigned-pds"),
1929 static_cast<int64_t
>(-1));
1934 pool = subnet->getPool(lease->type_, lease->addr_,
false);
1939 "pool" :
"pd-pool", pool->getID(),
1941 "assigned-nas" :
"assigned-pds")),
1942 static_cast<int64_t
>(-1));
1946 if (lease->stateDeclined()) {
1951 "declined-addresses"),
1952 static_cast<int64_t
>(-1));
1958 "declined-addresses")),
1959 static_cast<int64_t
>(-1));
1991 getCfgSubnets4()->getBySubnetId(lease->subnet_id_);
1995 return (subnet->getAllocator(
Lease::TYPE_V4)->getType() ==
"shared-flq");
2007 getCfgSubnets6()->getBySubnetId(lease->subnet_id_);
2011 return (subnet->getAllocator(lease->getType())->getType() ==
"shared-flq");
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...
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())
Create a NullElement.
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.
virtual data::ElementPtr getStatus() const
Return status information.
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.
static void updateStatsOnAdd(const Lease4Ptr &lease)
Update in-memory stats when adding a v4 lease.
virtual size_t byRemoteId6size() const
Return the by-remote-id table size.
virtual asiolink::IOAddress sflqPickFreeLease4(asiolink::IOAddress start_address, asiolink::IOAddress end_address)
Finds a free V4 address within the given pool range.
static void updateStatsOnUpdate(const Lease4Ptr &existing, const Lease4Ptr &lease)
Update in-memory stats when updating a v4 lease.
static bool useSharedFlqStatement(Lease4Ptr lease)
Determine if SFLQ alternate SQL statements should be used for a given v4 lease.
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.
static void bumpStatPrefix(const std::string &stat, SubnetID &subnet_id, PoolPtr pool, int value)
Helper function that adds a value to a prefix stat's global, subnet, and pool level values.
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.
virtual std::string getName() const =0
Returns backend name.
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.
static void updateStatsOnDelete(const Lease4Ptr &lease)
Update in-memory stats when deleting a v4 lease.
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 isc::data::ConstElementPtr lfcStartHandler()
Handler for kea-lfc-start command.
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.
virtual bool sflqCreateFlqPool4(asiolink::IOAddress start_address, asiolink::IOAddress end_address, SubnetID subnet_id, bool recreate=false)
Creates a v4 SFLQ Pool.
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.
static void bumpStat(const std::string &stat, SubnetID &subnet_id, PoolPtr pool, int value)
Helper function that adds a value to an address stat's global, subnet, and pool level values.
virtual bool addExtendedInfo6(const Lease6Ptr &lease)
Extract extended info from a lease6 and add it into tables.
virtual asiolink::IOAddress sflqPickFreeLease6(asiolink::IOAddress start_address, asiolink::IOAddress end_address)
Finds a free V6 address/prefix within the given pool range.
virtual bool sflqCreateFlqPool6(asiolink::IOAddress start_address, asiolink::IOAddress end_address, Lease::Type lease_type, uint8_t delegated_len, SubnetID subnet_id, bool recreate=false)
Calls stored procedure to create an SFLQ pool for v6.
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 const OptionDefinition & DHO_DHCP_AGENT_OPTIONS_DEF()
Get definition of DHO_DHCP_AGENT_OPTIONS option.
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.
Base class representing a DHCP option definition.
static bool inUse()
Returns the global in-use flag.
Statistics Manager class.
ObservationPtr getObservation(const std::string &name) const
Returns an observation.
static StatsMgr & instance()
Statistics Manager accessor method.
static std::string generateName(const std::string &context, Type index, const std::string &stat_name)
Generates statistic name in a given context.
This file contains several functions and constants that are used for handling commands and responses ...
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
void setValue(const std::string &name, const int64_t value)
Records absolute integer observation.
void addValue(const std::string &name, const int64_t value)
Records incremental integer observation.
#define STATE_MASK(new_state, old_state)
Creates a mask out of two states: new state and old state.
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.
ConstElementPtr createAnswer()
Creates a standard config/command level success answer message (i.e.
const int CONTROL_RESULT_COMMAND_UNSUPPORTED
Status code indicating that the specified command is not supported.
ElementPtr copy(ConstElementPtr from, unsigned 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.
constexpr uint16_t DECLINED_RECLAIMED
constexpr uint16_t RECLAIMED_ASSIGNED
constexpr uint16_t REGISTERED_RELEASED
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.
constexpr uint16_t REGISTERED_ASSIGNED
constexpr uint16_t RELEASED_DECLINED
constexpr uint16_t ASSIGNED_ASSIGNED
Constant expression state masks for use in switch statements.
constexpr uint16_t ASSIGNED_DECLINED
constexpr uint16_t RECLAIMED_REGISTERED
constexpr uint16_t RELEASED_ASSIGNED
constexpr uint16_t RECLAIMED_DECLINED
boost::shared_ptr< Pool > PoolPtr
a pointer to either IPv4 or IPv6 Pool
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.
constexpr uint16_t REGISTERED_REGISTERED
uint32_t SubnetID
Defines unique IPv4 or IPv6 subnet identifier.
constexpr uint16_t DECLINED_ASSIGNED
constexpr uint16_t RELEASED_REGISTERED
constexpr uint16_t ASSIGNED_RECLAIMED
constexpr uint16_t DECLINED_REGISTERED
constexpr uint16_t DECLINED_RELEASED
constexpr uint16_t ASSIGNED_RELEASED
constexpr uint16_t DECLINED_DECLINED
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
constexpr uint16_t REGISTERED_DECLINED
constexpr uint16_t ASSIGNED_REGISTERED
constexpr uint16_t REGISTERED_RECLAIMED
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 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 constexpr uint32_t STATE_DEFAULT
A lease in the default state.
static constexpr uint32_t STATE_EXPIRED_RECLAIMED
Expired and reclaimed lease.
static constexpr uint32_t STATE_DECLINED
Declined lease.
static constexpr uint32_t STATE_REGISTERED
Registered self-generated lease.
static constexpr uint32_t STATE_RELEASED
Released lease held in the database for lease affinity.
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