35#include <boost/foreach.hpp>
48const char* KEA_LFC_EXECUTABLE_ENV_NAME =
"KEA_LFC_EXECUTABLE";
106 void setup(
const uint32_t lfc_interval,
107 const boost::shared_ptr<CSVLeaseFile4>& lease_file4,
108 const boost::shared_ptr<CSVLeaseFile6>& lease_file6,
109 bool run_once_now =
false);
112 void execute(
const std::string& lease_file);
129 boost::scoped_ptr<ProcessSpawn> process_;
145 : process_(), callback_(callback), pid_(0),
161 timer_mgr_->unregisterTimer(
"memfile-lfc");
163 }
catch (
const std::exception& ex) {
174 const boost::shared_ptr<CSVLeaseFile4>& lease_file4,
175 const boost::shared_ptr<CSVLeaseFile6>& lease_file6,
179 std::string executable;
180 char* c_executable = getenv(KEA_LFC_EXECUTABLE_ENV_NAME);
182 executable = KEA_LFC_EXECUTABLE;
184 executable = c_executable;
188 std::string lease_file = lease_file4 ? lease_file4->getFilename() :
189 lease_file6->getFilename();
194 args.push_back(lease_file4 ?
"-4" :
"-6");
197 args.push_back(
"-x");
201 args.push_back(
"-i");
205 args.push_back(
"-o");
209 args.push_back(
"-f");
213 args.push_back(
"-p");
218 args.push_back(
"-c");
219 args.push_back(
"ignored-path");
231 if (lfc_interval > 0) {
238 timer_mgr_->registerTimer(
"memfile-lfc", callback_, lfc_interval * 1000,
240 timer_mgr_->setup(
"memfile-lfc");
263 process_->clearState(pid_);
275 .arg(process_->getCommandLine());
277 pid_ = process_->spawn();
289 pid_file.
write(pid_);
299 return (process_ && process_->isRunning(pid_));
306 " the process is null");
308 return (process_->getExitStatus(pid_));
371 return (
rows_.size());
467 void startSubnets() {
472 Lease4StorageSubnetIdIndex::const_iterator lower;
473 Lease4StorageSubnetIdIndex::const_iterator upper;
496 if (lower == upper) {
504 int64_t assigned = 0;
505 int64_t declined = 0;
506 for (Lease4StorageSubnetIdIndex::const_iterator lease = lower;
507 lease != upper; ++lease) {
510 if ((*lease)->subnet_id_ != cur_id) {
513 rows_.push_back(LeaseStatsRow(cur_id,
520 rows_.push_back(LeaseStatsRow(cur_id,
528 cur_id = (*lease)->subnet_id_;
568 void startSubnetPools() {
570 = storage4_.get<SubnetIdPoolIdIndexTag>();
573 Lease4StorageSubnetIdPoolIdIndex::const_iterator lower;
574 Lease4StorageSubnetIdPoolIdIndex::const_iterator upper;
586 if (lower == upper) {
594 uint32_t cur_pool_id = 0;
595 int64_t assigned = 0;
596 int64_t declined = 0;
597 for (Lease4StorageSubnetIdPoolIdIndex::const_iterator lease = lower;
598 lease != upper; ++lease) {
601 if ((*lease)->pool_id_ != cur_pool_id) {
603 rows_.push_back(LeaseStatsRow(cur_id,
605 assigned, cur_pool_id));
610 rows_.push_back(LeaseStatsRow(cur_id,
612 declined, cur_pool_id));
617 cur_pool_id = (*lease)->pool_id_;
622 if ((*lease)->subnet_id_ != cur_id) {
625 rows_.push_back(LeaseStatsRow(cur_id,
627 assigned, cur_pool_id));
632 rows_.push_back(LeaseStatsRow(cur_id,
634 declined, cur_pool_id));
640 cur_id = (*lease)->subnet_id_;
657 assigned, cur_pool_id));
662 declined, cur_pool_id));
761 virtual void startSubnets() {
766 Lease6StorageSubnetIdIndex::const_iterator lower;
767 Lease6StorageSubnetIdIndex::const_iterator upper;
789 if (lower == upper) {
797 int64_t assigned = 0;
798 int64_t declined = 0;
799 int64_t assigned_pds = 0;
800 int64_t registered = 0;
801 for (Lease6StorageSubnetIdIndex::const_iterator lease = lower;
802 lease != upper; ++lease) {
805 if ((*lease)->subnet_id_ != cur_id) {
821 if (assigned_pds > 0) {
828 if (registered > 0) {
837 cur_id = (*lease)->subnet_id_;
842 switch((*lease)->type_) {
876 if (assigned_pds > 0) {
881 if (registered > 0) {
904 virtual void startSubnetPools() {
906 = storage6_.get<SubnetIdPoolIdIndexTag>();
909 Lease6StorageSubnetIdPoolIdIndex::const_iterator lower;
910 Lease6StorageSubnetIdPoolIdIndex::const_iterator upper;
922 if (lower == upper) {
930 uint32_t cur_pool_id = 0;
931 int64_t assigned = 0;
932 int64_t declined = 0;
933 int64_t assigned_pds = 0;
934 for (Lease6StorageSubnetIdPoolIdIndex::const_iterator lease = lower;
935 lease != upper; ++lease) {
938 if ((*lease)->pool_id_ != cur_pool_id) {
942 assigned, cur_pool_id));
949 declined, cur_pool_id));
953 if (assigned_pds > 0) {
956 assigned_pds, cur_pool_id));
961 cur_pool_id = (*lease)->pool_id_;
966 if ((*lease)->subnet_id_ != cur_id) {
971 assigned, cur_pool_id));
978 declined, cur_pool_id));
982 if (assigned_pds > 0) {
985 assigned_pds, cur_pool_id));
991 cur_id = (*lease)->subnet_id_;
999 switch((*lease)->type_) {
1030 if (assigned_pds > 0) {
1052 :
TrackingLeaseMgr(), lfc_setup_(), conn_(parameters), mutex_(new std::mutex) {
1053 bool conversion_needed =
false;
1059 std::string universe = conn_.getParameter(
"universe");
1060 if (universe ==
"4") {
1061 std::string file4 = initLeaseFilePath(
V4);
1062 if (!file4.empty()) {
1063 conversion_needed = loadLeasesFromFiles<
Lease4,
1070 std::string file6 = initLeaseFilePath(
V6);
1071 if (!file6.empty()) {
1072 conversion_needed = loadLeasesFromFiles<
Lease6,
1091 if (conversion_needed) {
1096 lfcSetup(conversion_needed);
1103 if (conn_.reconnectCtl()->maxRetries() > 0) {
1105 <<
" values greater than zero are not supported by memfile");
1108 if (conn_.reconnectCtl()->retryInterval() > 0) {
1110 <<
" values greater than zero are not supported by memfile");
1127 std::stringstream tmp;
1128 tmp <<
"Memfile backend ";
1131 }
else if (u ==
V6) {
1140 if (family == AF_INET6) {
1148Memfile_LeaseMgr::handleDbLost() {
1158Memfile_LeaseMgr::addLeaseInternal(
const Lease4Ptr& lease) {
1159 if (storage4_.count(lease->addr_) != 0) {
1170 }
catch (
const CSVFileFatalError&) {
1176 storage4_.insert(lease);
1180 lease->updateCurrentExpirationTime();
1183 class_lease_counter_.addLease(lease);
1199 std::lock_guard<std::mutex> lock(*mutex_);
1200 return (addLeaseInternal(lease));
1202 return (addLeaseInternal(lease));
1207Memfile_LeaseMgr::addLeaseInternal(
const Lease6Ptr& lease) {
1208 if (storage6_.count(lease->addr_) != 0) {
1226 storage6_.insert(lease);
1230 lease->updateCurrentExpirationTime();
1233 class_lease_counter_.addLease(lease);
1253 std::lock_guard<std::mutex> lock(*mutex_);
1254 return (addLeaseInternal(lease));
1256 return (addLeaseInternal(lease));
1263 Lease4StorageAddressIndex::iterator l = idx.find(addr);
1264 if (l == idx.end()) {
1277 std::lock_guard<std::mutex> lock(*mutex_);
1278 return (getLease4Internal(addr));
1280 return (getLease4Internal(addr));
1285Memfile_LeaseMgr::getLease4Internal(
const HWAddr& hwaddr,
1291 std::pair<Lease4StorageHWAddressSubnetIdIndex::const_iterator,
1292 Lease4StorageHWAddressSubnetIdIndex::const_iterator> l
1293 = idx.equal_range(boost::make_tuple(hwaddr.
hwaddr_));
1295 BOOST_FOREACH(
auto const& lease, l) {
1307 std::lock_guard<std::mutex> lock(*mutex_);
1308 getLease4Internal(hwaddr, collection);
1310 getLease4Internal(hwaddr, collection);
1313 return (collection);
1317Memfile_LeaseMgr::getLease4Internal(
const HWAddr& hwaddr,
1323 Lease4StorageHWAddressSubnetIdIndex::const_iterator lease =
1324 idx.find(boost::make_tuple(hwaddr.
hwaddr_, subnet_id));
1326 if (lease == idx.end()) {
1331 return (
Lease4Ptr(
new Lease4(**lease)));
1342 std::lock_guard<std::mutex> lock(*mutex_);
1343 return (getLease4Internal(hwaddr, subnet_id));
1345 return (getLease4Internal(hwaddr, subnet_id));
1350Memfile_LeaseMgr::getLease4Internal(
const ClientId& client_id,
1356 std::pair<Lease4StorageClientIdSubnetIdIndex::const_iterator,
1357 Lease4StorageClientIdSubnetIdIndex::const_iterator> l
1358 = idx.equal_range(boost::make_tuple(client_id.
getClientId()));
1360 BOOST_FOREACH(
auto const& lease, l) {
1372 std::lock_guard<std::mutex> lock(*mutex_);
1373 getLease4Internal(client_id, collection);
1375 getLease4Internal(client_id, collection);
1378 return (collection);
1382Memfile_LeaseMgr::getLease4Internal(
const ClientId& client_id,
1388 Lease4StorageClientIdSubnetIdIndex::const_iterator lease =
1389 idx.find(boost::make_tuple(client_id.
getClientId(), subnet_id));
1391 if (lease == idx.end()) {
1395 return (
Lease4Ptr(
new Lease4(**lease)));
1403 .arg(client_id.
toText());
1406 std::lock_guard<std::mutex> lock(*mutex_);
1407 return (getLease4Internal(client_id, subnet_id));
1409 return (getLease4Internal(client_id, subnet_id));
1414Memfile_LeaseMgr::getLeases4Internal(
SubnetID subnet_id,
1417 std::pair<Lease4StorageSubnetIdIndex::const_iterator,
1418 Lease4StorageSubnetIdIndex::const_iterator> l =
1419 idx.equal_range(subnet_id);
1421 BOOST_FOREACH(
auto const& lease, l) {
1433 std::lock_guard<std::mutex> lock(*mutex_);
1434 getLeases4Internal(subnet_id, collection);
1436 getLeases4Internal(subnet_id, collection);
1439 return (collection);
1443Memfile_LeaseMgr::getLeases4Internal(
const std::string& hostname,
1446 std::pair<Lease4StorageHostnameIndex::const_iterator,
1447 Lease4StorageHostnameIndex::const_iterator> l =
1448 idx.equal_range(hostname);
1450 BOOST_FOREACH(
auto const& lease, l) {
1462 std::lock_guard<std::mutex> lock(*mutex_);
1463 getLeases4Internal(hostname, collection);
1465 getLeases4Internal(hostname, collection);
1468 return (collection);
1473 for (
auto const& lease : storage4_) {
1484 std::lock_guard<std::mutex> lock(*mutex_);
1485 getLeases4Internal(collection);
1487 getLeases4Internal(collection);
1490 return (collection);
1498 Lease4StorageAddressIndex::const_iterator lb = idx.lower_bound(lower_bound_address);
1501 if ((lb != idx.end()) && ((*lb)->addr_ == lower_bound_address)) {
1506 for (
auto lease = lb;
1507 (lease != idx.end()) &&
1508 (
static_cast<size_t>(std::distance(lb, lease)) < page_size.
page_size_);
1510 collection.push_back(
Lease4Ptr(
new Lease4(**lease)));
1518 if (!lower_bound_address.
isV4()) {
1520 "retrieving leases from the lease database, got "
1521 << lower_bound_address);
1526 .arg(lower_bound_address.
toText());
1530 std::lock_guard<std::mutex> lock(*mutex_);
1531 getLeases4Internal(lower_bound_address, page_size, collection);
1533 getLeases4Internal(lower_bound_address, page_size, collection);
1536 return (collection);
1543 std::lock_guard<std::mutex> lock(*mutex_);
1544 getLeases4ByStateInternal(state, subnet_id, collection);
1546 getLeases4ByStateInternal(state, subnet_id, collection);
1549 return (collection);
1553Memfile_LeaseMgr::getLeases4ByStateInternal(uint32_t state,
1556 if (subnet_id == 0) {
1557 return (getLeases4ByStateInternal(state, collection));
1560 std::pair<Lease4StorageStateIndex::const_iterator,
1561 Lease4StorageStateIndex::const_iterator> l =
1562 idx.equal_range(boost::make_tuple(state, subnet_id));
1564 BOOST_FOREACH(
auto const& lease, l) {
1565 collection.push_back(
Lease4Ptr(
new Lease4(*lease)));
1570Memfile_LeaseMgr::getLeases4ByStateInternal(uint32_t state,
1573 std::pair<Lease4StorageStateIndex::const_iterator,
1574 Lease4StorageStateIndex::const_iterator> l =
1575 idx.equal_range(boost::make_tuple(state));
1577 BOOST_FOREACH(
auto const& lease, l) {
1578 collection.push_back(
Lease4Ptr(
new Lease4(*lease)));
1583Memfile_LeaseMgr::getLease6Internal(
Lease::Type type,
1584 const isc::asiolink::IOAddress& addr)
const {
1585 Lease6Storage::iterator l = storage6_.find(addr);
1586 if (l == storage6_.end() || !(*l) || ((*l)->type_ != type)) {
1594Memfile_LeaseMgr::getLease6Internal(
const HWAddr& hwaddr,
1597 storage6_.get<HWAddressIndexTag>();
1598 std::pair<Lease6StorageHWAddressIndex::const_iterator,
1599 Lease6StorageHWAddressIndex::const_iterator> l
1600 = idx.equal_range(hwaddr.hwaddr_);
1602 BOOST_FOREACH(
auto const& lease, l) {
1603 collection.push_back(
Lease6Ptr(
new Lease6(*lease)));
1614 std::lock_guard<std::mutex> lock(*mutex_);
1615 getLease6Internal(hwaddr, collection);
1617 getLease6Internal(hwaddr, collection);
1620 return (collection);
1625 Lease6Storage::iterator l = storage6_.find(addr);
1626 if (l == storage6_.end() || !(*l)) {
1642 std::lock_guard<std::mutex> lock(*mutex_);
1643 return (getLease6Internal(type, addr));
1645 return (getLease6Internal(type, addr));
1650Memfile_LeaseMgr::getLeases6Internal(
Lease::Type type,
1657 std::pair<Lease6StorageDuidIaidTypeIndex::const_iterator,
1658 Lease6StorageDuidIaidTypeIndex::const_iterator> l =
1659 idx.equal_range(boost::make_tuple(duid.
getDuid(), iaid, type));
1661 for (Lease6StorageDuidIaidTypeIndex::const_iterator lease =
1662 l.first; lease != l.second; ++lease) {
1670 uint32_t iaid)
const {
1679 std::lock_guard<std::mutex> lock(*mutex_);
1680 getLeases6Internal(type, duid, iaid, collection);
1682 getLeases6Internal(type, duid, iaid, collection);
1685 return (collection);
1689Memfile_LeaseMgr::getLeases6Internal(
Lease::Type type,
1697 std::pair<Lease6StorageDuidIaidTypeIndex::const_iterator,
1698 Lease6StorageDuidIaidTypeIndex::const_iterator> l =
1699 idx.equal_range(boost::make_tuple(duid.
getDuid(), iaid, type));
1701 for (Lease6StorageDuidIaidTypeIndex::const_iterator lease =
1702 l.first; lease != l.second; ++lease) {
1704 if ((*lease)->subnet_id_ == subnet_id) {
1724 std::lock_guard<std::mutex> lock(*mutex_);
1725 getLeases6Internal(type, duid, iaid, subnet_id, collection);
1727 getLeases6Internal(type, duid, iaid, subnet_id, collection);
1730 return (collection);
1734Memfile_LeaseMgr::getLeases6Internal(
SubnetID subnet_id,
1737 std::pair<Lease6StorageSubnetIdIndex::const_iterator,
1738 Lease6StorageSubnetIdIndex::const_iterator> l =
1739 idx.equal_range(subnet_id);
1741 BOOST_FOREACH(
auto const& lease, l) {
1753 std::lock_guard<std::mutex> lock(*mutex_);
1754 getLeases6Internal(subnet_id, collection);
1756 getLeases6Internal(subnet_id, collection);
1759 return (collection);
1763Memfile_LeaseMgr::getLeases6Internal(
const std::string& hostname,
1766 std::pair<Lease6StorageHostnameIndex::const_iterator,
1767 Lease6StorageHostnameIndex::const_iterator> l =
1768 idx.equal_range(hostname);
1770 BOOST_FOREACH(
auto const& lease, l) {
1782 std::lock_guard<std::mutex> lock(*mutex_);
1783 getLeases6Internal(hostname, collection);
1785 getLeases6Internal(hostname, collection);
1788 return (collection);
1793 for (
auto const& lease : storage6_) {
1804 std::lock_guard<std::mutex> lock(*mutex_);
1805 getLeases6Internal(collection);
1807 getLeases6Internal(collection);
1810 return (collection);
1814Memfile_LeaseMgr::getLeases6Internal(
const DUID& duid,
1817 std::pair<Lease6StorageDuidIndex::const_iterator,
1818 Lease6StorageDuidIndex::const_iterator> l =
1819 idx.equal_range(duid.
getDuid());
1821 BOOST_FOREACH(
auto const& lease, l) {
1833 std::lock_guard<std::mutex> lock(*mutex_);
1834 getLeases6Internal(duid, collection);
1836 getLeases6Internal(duid, collection);
1839 return (collection);
1847 Lease6StorageAddressIndex::const_iterator lb = idx.lower_bound(lower_bound_address);
1850 if ((lb != idx.end()) && ((*lb)->addr_ == lower_bound_address)) {
1855 for (
auto lease = lb;
1856 (lease != idx.end()) &&
1857 (
static_cast<size_t>(std::distance(lb, lease)) < page_size.
page_size_);
1859 collection.push_back(
Lease6Ptr(
new Lease6(**lease)));
1867 if (!lower_bound_address.
isV6()) {
1869 "retrieving leases from the lease database, got "
1870 << lower_bound_address);
1875 .arg(lower_bound_address.
toText());
1879 std::lock_guard<std::mutex> lock(*mutex_);
1880 getLeases6Internal(lower_bound_address, page_size, collection);
1882 getLeases6Internal(lower_bound_address, page_size, collection);
1885 return (collection);
1889Memfile_LeaseMgr::getLeases6Internal(
SubnetID subnet_id,
1894 Lease6StorageSubnetIdIndex::const_iterator lb =
1895 idx.lower_bound(boost::make_tuple(subnet_id, lower_bound_address));
1898 if ((lb != idx.end()) && ((*lb)->addr_ == lower_bound_address)) {
1903 for (
auto it = lb; it != idx.end(); ++it) {
1904 if ((*it)->subnet_id_ != subnet_id) {
1908 collection.push_back(
Lease6Ptr(
new Lease6(**it)));
1909 if (collection.size() >= page_size.
page_size_) {
1913 return (collection);
1923 .arg(lower_bound_address.
toText())
1927 if (!lower_bound_address.
isV6()) {
1929 "retrieving leases from the lease database, got "
1930 << lower_bound_address);
1934 std::lock_guard<std::mutex> lock(*mutex_);
1935 return (getLeases6Internal(subnet_id,
1936 lower_bound_address,
1939 return (getLeases6Internal(subnet_id,
1940 lower_bound_address,
1949 std::lock_guard<std::mutex> lock(*mutex_);
1950 getLeases6ByStateInternal(state, subnet_id, collection);
1952 getLeases6ByStateInternal(state, subnet_id, collection);
1955 return (collection);
1959Memfile_LeaseMgr::getLeases6ByStateInternal(uint32_t state,
1962 if (subnet_id == 0) {
1963 return (getLeases6ByStateInternal(state, collection));
1966 std::pair<Lease6StorageStateIndex::const_iterator,
1967 Lease6StorageStateIndex::const_iterator> l =
1968 idx.equal_range(boost::make_tuple(state, subnet_id));
1970 BOOST_FOREACH(
auto const& lease, l) {
1971 collection.push_back(
Lease6Ptr(
new Lease6(*lease)));
1976Memfile_LeaseMgr::getLeases6ByStateInternal(uint32_t state,
1979 std::pair<Lease6StorageStateIndex::const_iterator,
1980 Lease6StorageStateIndex::const_iterator> l =
1981 idx.equal_range(boost::make_tuple(state));
1983 BOOST_FOREACH(
auto const& lease, l) {
1984 collection.push_back(
Lease6Ptr(
new Lease6(*lease)));
1989Memfile_LeaseMgr::getExpiredLeases4Internal(
Lease4Collection& expired_leases,
1990 const size_t max_leases)
const {
1998 Lease4StorageExpirationIndex::const_iterator ub =
1999 index.upper_bound(boost::make_tuple(
false, time(0)));
2002 for (Lease4StorageExpirationIndex::const_iterator lease = index.begin();
2004 ((max_leases == 0) ||
2005 (
static_cast<size_t>(std::distance(index.begin(), lease)) < max_leases));
2007 expired_leases.push_back(
Lease4Ptr(
new Lease4(**lease)));
2013 const size_t max_leases)
const {
2018 std::lock_guard<std::mutex> lock(*mutex_);
2019 getExpiredLeases4Internal(expired_leases, max_leases);
2021 getExpiredLeases4Internal(expired_leases, max_leases);
2026Memfile_LeaseMgr::getExpiredLeases6Internal(
Lease6Collection& expired_leases,
2027 const size_t max_leases)
const {
2035 Lease6StorageExpirationIndex::const_iterator ub =
2036 index.upper_bound(boost::make_tuple(
false, time(0)));
2039 for (Lease6StorageExpirationIndex::const_iterator lease = index.begin();
2041 ((max_leases == 0) ||
2042 (
static_cast<size_t>(std::distance(index.begin(), lease)) < max_leases));
2050 const size_t max_leases)
const {
2055 std::lock_guard<std::mutex> lock(*mutex_);
2056 getExpiredLeases6Internal(expired_leases, max_leases);
2058 getExpiredLeases6Internal(expired_leases, max_leases);
2063Memfile_LeaseMgr::updateLease4Internal(
const Lease4Ptr& lease) {
2070 Lease4StorageAddressIndex::const_iterator lease_it = index.find(lease->addr_);
2071 if (lease_it == index.end()) {
2073 << lease->addr_ <<
" - no such lease");
2074 }
else if ((!persist) && (((*lease_it)->cltt_ != lease->current_cltt_) ||
2075 ((*lease_it)->valid_lft_ != lease->current_valid_lft_))) {
2078 isc_throw(NoSuchLease,
"unable to update lease for address " <<
2079 lease->addr_.toText() <<
" either because the lease does not exist, "
2080 "it has been deleted or it has changed in the database.");
2089 }
catch (
const CSVFileFatalError&) {
2096 lease->updateCurrentExpirationTime();
2103 index.replace(lease_it,
Lease4Ptr(
new Lease4(*lease)));
2106 class_lease_counter_.updateLease(lease, old_lease);
2120 std::lock_guard<std::mutex> lock(*mutex_);
2121 updateLease4Internal(lease);
2123 updateLease4Internal(lease);
2128Memfile_LeaseMgr::updateLease6Internal(
const Lease6Ptr& lease) {
2139 Lease6StorageAddressIndex::const_iterator lease_it = index.find(lease->addr_);
2140 if (lease_it == index.end()) {
2142 << lease->addr_ <<
" - no such lease");
2143 }
else if ((!persist) && (((*lease_it)->cltt_ != lease->current_cltt_) ||
2144 ((*lease_it)->valid_lft_ != lease->current_valid_lft_))) {
2147 isc_throw(NoSuchLease,
"unable to update lease for address " <<
2148 lease->addr_.toText() <<
" either because the lease does not exist, "
2149 "it has been deleted or it has changed in the database.");
2158 }
catch (
const CSVFileFatalError&) {
2165 lease->updateCurrentExpirationTime();
2172 index.replace(lease_it,
Lease6Ptr(
new Lease6(*lease)));
2175 class_lease_counter_.updateLease(lease, old_lease);
2179 switch (recorded_action) {
2206 std::lock_guard<std::mutex> lock(*mutex_);
2207 updateLease6Internal(lease);
2209 updateLease6Internal(lease);
2214Memfile_LeaseMgr::deleteLeaseInternal(
const Lease4Ptr& lease) {
2216 Lease4Storage::iterator l = storage4_.find(addr);
2217 if (l == storage4_.end()) {
2224 Lease4 lease_copy = **l;
2227 lease_copy.valid_lft_ = 0;
2237 if (((*l)->cltt_ != lease->current_cltt_) ||
2238 ((*l)->valid_lft_ != lease->current_valid_lft_)) {
2246 class_lease_counter_.removeLease(lease);
2263 std::lock_guard<std::mutex> lock(*mutex_);
2264 return (deleteLeaseInternal(lease));
2266 return (deleteLeaseInternal(lease));
2271Memfile_LeaseMgr::deleteLeaseInternal(
const Lease6Ptr& lease) {
2275 Lease6Storage::iterator l = storage6_.find(addr);
2276 if (l == storage6_.end()) {
2283 Lease6 lease_copy = **l;
2285 lease_copy.valid_lft_ = 0;
2286 lease_copy.preferred_lft_ = 0;
2296 if (((*l)->cltt_ != lease->current_cltt_) ||
2297 ((*l)->valid_lft_ != lease->current_valid_lft_)) {
2305 class_lease_counter_.removeLease(lease);
2327 std::lock_guard<std::mutex> lock(*mutex_);
2328 return (deleteLeaseInternal(lease));
2330 return (deleteLeaseInternal(lease));
2341 std::lock_guard<std::mutex> lock(*mutex_);
2342 return (deleteExpiredReclaimedLeases<
2346 return (deleteExpiredReclaimedLeases<
2359 std::lock_guard<std::mutex> lock(*mutex_);
2360 return (deleteExpiredReclaimedLeases<
2364 return (deleteExpiredReclaimedLeases<
2370template<
typename IndexType,
typename LeaseType,
typename StorageType,
2371 typename LeaseFileType>
2373Memfile_LeaseMgr::deleteExpiredReclaimedLeases(
const uint32_t secs,
2374 const Universe& universe,
2375 StorageType& storage,
2376 LeaseFileType& lease_file) {
2389 typename IndexType::const_iterator upper_limit =
2390 index.upper_bound(boost::make_tuple(
true, time(0) - secs));
2399 typename IndexType::const_iterator lower_limit =
2400 index.upper_bound(boost::make_tuple(
true, std::numeric_limits<int64_t>::min()));
2403 uint64_t num_leases =
static_cast<uint64_t
>(std::distance(lower_limit, upper_limit));
2404 if (num_leases > 0) {
2414 for (
typename IndexType::const_iterator lease = lower_limit;
2415 lease != upper_limit; ++lease) {
2417 LeaseType lease_copy(**lease);
2420 lease_copy.valid_lft_ = 0;
2422 lease_file->append(lease_copy);
2431 index.erase(lower_limit, upper_limit);
2435 return (num_leases);
2440 return (std::string(
"In memory database with leases stored in a CSV file."));
2443std::pair<uint32_t, uint32_t>
2445 std::string
const& universe(conn_.getParameter(
"universe"));
2446 if (universe ==
"4") {
2448 }
else if (universe ==
"6") {
2467 std::string lease_file(file_name);
2468 if (lease_file.empty()) {
2478 std::string file_name;
2486 if (file_name.empty()) {
2498 std::string name(file_name);
2499 switch (file_type) {
2510 name +=
".completed";
2525 std::string filename ) {
2526 std::ostringstream s;;
2528 if (filename.empty()) {
2530 s << (u ==
V4 ?
"4" :
"6");
2533 s <<
"/" << filename;
2561Memfile_LeaseMgr::initLeaseFilePath(Universe u) {
2562 std::string persist_val;
2568 persist_val =
"true";
2575 }
else if (persist_val !=
"true") {
2576 isc_throw(isc::BadValue,
"invalid value 'persist="
2577 << persist_val <<
"'");
2580 std::string lease_file;
2582 lease_file = conn_.getParameter(
"name");
2583 }
catch (
const Exception&) {
2590 }
catch (
const SecurityWarn& ex) {
2595 return (lease_file);
2598template<
typename LeaseObjectType,
typename LeaseFileType,
typename StorageType>
2600Memfile_LeaseMgr::loadLeasesFromFiles(Universe u,
const std::string& filename,
2601 boost::shared_ptr<LeaseFileType>& lease_file,
2602 StorageType& storage) {
2610 isc_throw(DbOpenError,
"unable to load leases from files while the "
2611 "lease file cleanup is in progress");
2616 std::string max_row_errors_str =
"0";
2618 max_row_errors_str = conn_.getParameter(
"max-row-errors");
2619 }
catch (
const std::exception&) {
2623 int64_t max_row_errors64;
2625 max_row_errors64 = boost::lexical_cast<int64_t>(max_row_errors_str);
2626 }
catch (
const boost::bad_lexical_cast&) {
2627 isc_throw(isc::BadValue,
"invalid value of the max-row-errors "
2628 << max_row_errors_str <<
" specified");
2630 if ((max_row_errors64 < 0) ||
2631 (max_row_errors64 > std::numeric_limits<uint32_t>::max())) {
2632 isc_throw(isc::BadValue,
"invalid value of the max-row-errors "
2633 << max_row_errors_str <<
" specified");
2635 uint32_t max_row_errors =
static_cast<uint32_t
>(max_row_errors64);
2638 bool conversion_needed =
false;
2639 lease_file.reset(
new LeaseFileType(std::string(filename +
".completed")));
2640 if (lease_file->exists()) {
2643 conversion_needed = conversion_needed || lease_file->needsConversion();
2648 if (lease_file->exists()) {
2651 conversion_needed = conversion_needed || lease_file->needsConversion();
2655 if (lease_file->exists()) {
2658 conversion_needed = conversion_needed || lease_file->needsConversion();
2668 lease_file.reset(
new LeaseFileType(filename));
2670 max_row_errors,
false);
2671 conversion_needed = conversion_needed || lease_file->needsConversion();
2673 return (conversion_needed);
2678 return (lfc_setup_->isRunning());
2683 return (lfc_setup_->getExitStatus());
2688 return (lfc_setup_->getLastPid());
2704Memfile_LeaseMgr::lfcSetup(
bool conversion_needed) {
2705 std::string lfc_interval_str =
"3600";
2708 }
catch (
const std::exception&) {
2712 uint32_t lfc_interval = 0;
2714 lfc_interval = boost::lexical_cast<uint32_t>(lfc_interval_str);
2715 }
catch (
const boost::bad_lexical_cast&) {
2716 isc_throw(isc::BadValue,
"invalid value of the lfc-interval "
2717 << lfc_interval_str <<
" specified");
2724template<
typename LeaseFileType>
2726Memfile_LeaseMgr::lfcExecute(boost::shared_ptr<LeaseFileType>& lease_file) {
2738 if (!lease_file_finish.exists() && !lease_file_copy.exists()) {
2740 lease_file->close();
2743 do_lfc = (rename(lease_file->getFilename().c_str(),
2744 lease_file_copy.getFilename().c_str()) == 0);
2748 .arg(lease_file->getFilename())
2749 .arg(lease_file_copy.getFilename())
2750 .arg(strerror(errno));
2759 lease_file->open(
true);
2761 }
catch (
const CSVFileError& ex) {
2772 .arg(lease_file->getFilename())
2783 lfc_setup_->execute(lease_file->getFilename());
2790 std::ostringstream msg;
2791 msg <<
"'persist' parameter of 'memfile' lease backend "
2792 <<
"was configured to 'false'";
2809 if (new_pid == -1) {
2811 }
else if (new_pid != previous_pid) {
2822 std::lock_guard<std::mutex> lock(*mutex_);
2835 std::lock_guard<std::mutex> lock(*mutex_);
2848 std::lock_guard<std::mutex> lock(*mutex_);
2863 std::lock_guard<std::mutex> lock(*mutex_);
2876 std::lock_guard<std::mutex> lock(*mutex_);
2889 std::lock_guard<std::mutex> lock(*mutex_);
2902 std::lock_guard<std::mutex> lock(*mutex_);
2917 std::lock_guard<std::mutex> lock(*mutex_);
2931 "single thread mode or a multi thread critical section");
2941 std::pair<Lease4StorageSubnetIdIndex::const_iterator,
2942 Lease4StorageSubnetIdIndex::const_iterator> r =
2943 idx.equal_range(subnet_id);
2947 BOOST_FOREACH(
auto const& lease, r) {
2948 leases.push_back(lease);
2951 size_t num = leases.size();
2952 for (
auto const& l : leases) {
2956 .arg(subnet_id).arg(num);
2966 "single thread mode or a multi thread critical section");
2976 std::pair<Lease6StorageSubnetIdIndex::const_iterator,
2977 Lease6StorageSubnetIdIndex::const_iterator> r =
2978 idx.equal_range(subnet_id);
2982 BOOST_FOREACH(
auto const& lease, r) {
2983 leases.push_back(lease);
2986 size_t num = leases.size();
2987 for (
auto const& l : leases) {
2991 .arg(subnet_id).arg(num);
2998 class_lease_counter_.clear();
2999 for (
auto const& lease : storage4_) {
3002 class_lease_counter_.addLease(lease);
3009 class_lease_counter_.clear();
3010 for (
auto const& lease : storage6_) {
3013 class_lease_counter_.addLease(lease);
3022 std::lock_guard<std::mutex> lock(*mutex_);
3023 return(class_lease_counter_.getClassCount(client_class, ltype));
3025 return(class_lease_counter_.getClassCount(client_class, ltype));
3031 return(class_lease_counter_.clear());
3036 if (!user_context) {
3049 for (
unsigned i = 0; i < classes->size(); ++i) {
3058 std::string name = name_elem->stringValue();
3069 size_t lease_count = 0;
3075 if (lease_count >= limit) {
3076 std::ostringstream ss;
3077 ss <<
"address limit " << limit <<
" for client class \""
3078 << name <<
"\", current lease count " << lease_count;
3094 SubnetID subnet_id = id_elem->intValue();
3101 int64_t lease_count = 0;
3103 lease_count = getSubnetStat(subnet_id,
"assigned-addresses");
3107 if (
static_cast<uint64_t
>(lease_count) >= limit) {
3108 std::ostringstream ss;
3109 ss <<
"address limit " << limit <<
" for subnet ID " << subnet_id
3110 <<
", current lease count " << lease_count;
3122 if (!user_context) {
3136 for (
unsigned i = 0; i < classes->size(); ++i) {
3145 std::string name = name_elem->stringValue();
3150 if (!getLeaseLimit(class_elem, ltype, limit)) {
3152 if (!getLeaseLimit(class_elem, ltype, limit)) {
3160 size_t lease_count = 0;
3166 if (lease_count >= limit) {
3167 std::ostringstream ss;
3169 <<
" limit " << limit <<
" for client class \""
3170 << name <<
"\", current lease count " << lease_count;
3186 SubnetID subnet_id = id_elem->intValue();
3191 if (!getLeaseLimit(subnet_elem, ltype, limit)) {
3193 if (!getLeaseLimit(subnet_elem, ltype, limit)) {
3201 int64_t lease_count = 0;
3203 lease_count = getSubnetStat(subnet_id, (ltype ==
Lease::TYPE_NA ?
3204 "assigned-nas" :
"assigned-pds"));
3208 if (
static_cast<uint64_t
>(lease_count) >= limit) {
3209 std::ostringstream ss;
3211 <<
" limit " << limit <<
" for subnet ID " << subnet_id
3212 <<
", current lease count " << lease_count;
3222Memfile_LeaseMgr::getSubnetStat(
const SubnetID& subnet_id,
const std::string& stat_label)
const {
3228 if (samples && samples->size()) {
3229 auto sample = samples->get(0);
3230 if (sample->size()) {
3231 auto count_elem = sample->get(0);
3232 return (count_elem->intValue());
3242 "prefix-limit" :
"address-limit");
3244 limit = limit_elem->intValue();
3255 const time_t& qry_start_time ,
3256 const time_t& qry_end_time ) {
3260 .arg(lower_bound_address.
toText())
3262 .arg(qry_start_time)
3266 if (!lower_bound_address.
isV4()) {
3268 "retrieving leases from the lease database, got "
3269 << lower_bound_address);
3273 if ((qry_start_time < 0) || (qry_end_time < 0)) {
3278 if ((qry_start_time > 0) && (qry_end_time > 0) &&
3279 (qry_start_time > qry_end_time)) {
3284 std::lock_guard<std::mutex> lock(*mutex_);
3285 return (getLeases4ByRelayIdInternal(relay_id,
3286 lower_bound_address,
3291 return (getLeases4ByRelayIdInternal(relay_id,
3292 lower_bound_address,
3300Memfile_LeaseMgr::getLeases4ByRelayIdInternal(
const OptionBuffer& relay_id,
3303 const time_t& qry_start_time,
3304 const time_t& qry_end_time) {
3307 Lease4StorageRelayIdIndex::const_iterator lb =
3308 idx.lower_bound(boost::make_tuple(relay_id, lower_bound_address));
3310 IOAddress last_addr = lower_bound_address;
3311 for (; lb != idx.end(); ++lb) {
3312 if ((*lb)->addr_ == last_addr) {
3316 if ((*lb)->relay_id_ != relay_id) {
3320 last_addr = (*lb)->addr_;
3321 if ((qry_start_time > 0) && ((*lb)->cltt_ < qry_start_time)) {
3325 if ((qry_end_time > 0) && ((*lb)->cltt_ > qry_end_time)) {
3329 collection.push_back(
Lease4Ptr(
new Lease4(**lb)));
3330 if (collection.size() >= page_size.
page_size_) {
3334 return (collection);
3341 const time_t& qry_start_time ,
3342 const time_t& qry_end_time ) {
3346 .arg(lower_bound_address.
toText())
3348 .arg(qry_start_time)
3352 if (!lower_bound_address.
isV4()) {
3354 "retrieving leases from the lease database, got "
3355 << lower_bound_address);
3359 if ((qry_start_time < 0) || (qry_end_time < 0)) {
3364 if ((qry_start_time > 0) && (qry_end_time > 0) &&
3365 (qry_start_time > qry_end_time)) {
3370 std::lock_guard<std::mutex> lock(*mutex_);
3371 return (getLeases4ByRemoteIdInternal(remote_id,
3372 lower_bound_address,
3377 return (getLeases4ByRemoteIdInternal(remote_id,
3378 lower_bound_address,
3386Memfile_LeaseMgr::getLeases4ByRemoteIdInternal(
const OptionBuffer& remote_id,
3389 const time_t& qry_start_time,
3390 const time_t& qry_end_time) {
3392 std::map<IOAddress, Lease4Ptr> sorted;
3396 BOOST_FOREACH(
auto const& it, er) {
3398 if (addr <= lower_bound_address) {
3402 if ((qry_start_time > 0) && (it->cltt_ < qry_start_time)) {
3406 if ((qry_end_time > 0) && (it->cltt_ > qry_end_time)) {
3414 for (
auto const& it : sorted) {
3415 collection.push_back(
Lease4Ptr(
new Lease4(*it.second)));
3416 if (collection.size() >= page_size.
page_size_) {
3420 return (collection);
3426 std::lock_guard<std::mutex> lock(*mutex_);
3452 .arg(lower_bound_address.
toText())
3456 if (!lower_bound_address.
isV6()) {
3458 "retrieving leases from the lease database, got "
3459 << lower_bound_address);
3463 std::lock_guard<std::mutex> lock(*mutex_);
3464 return (getLeases6ByRelayIdInternal(relay_id,
3465 lower_bound_address,
3468 return (getLeases6ByRelayIdInternal(relay_id,
3469 lower_bound_address,
3475Memfile_LeaseMgr::getLeases6ByRelayIdInternal(
const DUID& relay_id,
3478 const std::vector<uint8_t>& relay_id_data = relay_id.
getDuid();
3481 RelayIdIndex::const_iterator lb =
3482 idx.lower_bound(boost::make_tuple(relay_id_data, lower_bound_address));
3485 IOAddress last_addr = lower_bound_address;
3486 for (; lb != idx.end(); ++lb) {
3487 if ((*lb)->lease_addr_ == last_addr) {
3491 if ((*lb)->id_ != relay_id_data) {
3495 last_addr = (*lb)->lease_addr_;
3496 Lease6Ptr lease = getAnyLease6Internal(last_addr);
3498 collection.push_back(lease);
3499 if (collection.size() >= page_size.
page_size_) {
3504 return (collection);
3514 .arg(lower_bound_address.
toText())
3518 if (!lower_bound_address.
isV6()) {
3520 "retrieving leases from the lease database, got "
3521 << lower_bound_address);
3525 std::lock_guard<std::mutex> lock(*mutex_);
3526 return (getLeases6ByRemoteIdInternal(remote_id,
3527 lower_bound_address,
3530 return (getLeases6ByRemoteIdInternal(remote_id,
3531 lower_bound_address,
3537Memfile_LeaseMgr::getLeases6ByRemoteIdInternal(
const OptionBuffer& remote_id,
3541 std::set<IOAddress> sorted;
3545 BOOST_FOREACH(
auto const& it, er) {
3546 const IOAddress& addr = it->lease_addr_;
3547 if (addr <= lower_bound_address) {
3550 static_cast<void>(sorted.insert(addr));
3555 Lease6Ptr lease = getAnyLease6Internal(addr);
3557 collection.push_back(lease);
3558 if (collection.size() >= page_size.
page_size_) {
3563 return (collection);
3576 <<
" consistency configuration is null");
3578 auto check = cfg->getExtendedInfoSanityCheck();
3583 .arg(update ?
" updating in file" :
"");
3586 size_t modified = 0;
3588 size_t processed = 0;
3590 auto lease_it = index.begin();
3591 auto next_it = index.end();
3593 for (; lease_it != index.end(); lease_it = next_it) {
3594 next_it = std::next(lease_it);
3615 if (!
copy->relay_id_.empty() || !
copy->remote_id_.empty()) {
3616 index.replace(lease_it,
copy);
3619 }
catch (
const std::exception& ex) {
3622 .arg(lease->addr_.toText())
3647 auto check = cfg->getExtendedInfoSanityCheck();
3653 .arg(enabled ?
"enabled" :
"disabled");
3662 size_t modified = 0;
3663 size_t processed = 0;
3665 for (
auto const& lease : storage6_) {
3674 }
catch (
const std::exception& ex) {
3677 .arg(lease->addr_.toText())
3697 static_cast<void>(relay_id_idx.erase(addr));
3700 static_cast<void>(remote_id_idx.erase(addr));
3705 const std::vector<uint8_t>& relay_id) {
3713 const std::vector<uint8_t>& remote_id) {
3722 std::lock_guard<std::mutex> lock(*mutex_);
3723 writeLeases4Internal(filename);
3725 writeLeases4Internal(filename);
3730Memfile_LeaseMgr::writeLeases4Internal(
const std::string& filename) {
3732 std::ostringstream tmp;
3733 tmp << filename <<
".tmp" << getpid();
3734 auto tmpname = tmp.str();
3735 ::remove(tmpname.c_str());
3741 for (
auto const& lease : storage4_) {
3742 tmpfile.append(*lease);
3745 }
catch (
const std::exception&) {
3747 ::remove(tmpname.c_str());
3752 std::ostringstream bak;
3753 bak << filename <<
".bak" << getpid();
3754 auto bakname = bak.str();
3760 static_cast<void>(::rename(filename.c_str(), bakname.c_str()));
3763 static_cast<void>(::rename(tmpname.c_str(), filename.c_str()));
3767 isc_throw(Unexpected,
"lease file '" << filename
3772 }
catch (
const std::exception& ex) {
3773 isc_throw(FatalException,
"Fatal issue: lease file '" << filename
3774 <<
"' is broken: " << ex.what() <<
". See backup '"
3775 << bakname <<
"' or dump '" << tmpname
3776 <<
"' files which can still contain leases.");
3781 static_cast<void>(::rename(filename.c_str(), bakname.c_str()));
3784 static_cast<void>(::rename(tmpname.c_str(), filename.c_str()));
3791 std::lock_guard<std::mutex> lock(*mutex_);
3792 writeLeases6Internal(filename);
3794 writeLeases6Internal(filename);
3799Memfile_LeaseMgr::writeLeases6Internal(
const std::string& filename) {
3801 std::ostringstream tmp;
3802 tmp << filename <<
".tmp" << getpid();
3803 auto tmpname = tmp.str();
3804 ::remove(tmpname.c_str());
3810 for (
auto const& lease : storage6_) {
3811 tmpfile.append(*lease);
3814 }
catch (
const std::exception&) {
3816 ::remove(tmpname.c_str());
3821 std::ostringstream bak;
3822 bak << filename <<
".bak" << getpid();
3823 auto bakname = bak.str();
3829 static_cast<void>(::rename(filename.c_str(), bakname.c_str()));
3832 static_cast<void>(::rename(tmpname.c_str(), filename.c_str()));
3836 isc_throw(Unexpected,
"lease file '" << filename
3841 }
catch (
const std::exception& ex) {
3842 isc_throw(FatalException,
"Fatal issue: lease file '" << filename
3843 <<
"' is broken: " << ex.what() <<
". See backup '"
3844 << bakname <<
"' or dump '" << tmpname
3845 <<
"' files which can still contain leases.");
3850 static_cast<void>(::rename(filename.c_str(), bakname.c_str()));
3853 static_cast<void>(::rename(tmpname.c_str(), filename.c_str()));
3863 }
catch (
const std::exception& ex) {
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
This is a base class for exceptions thrown from the DNS library module.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
A generic exception that is thrown if a function is called in a prohibited way.
A generic exception that is thrown when an unexpected error condition occurs.
The IOAddress class represents an IP addresses (version agnostic).
std::string toText() const
Convert the address to a string.
bool isV6() const
Convenience function to check for an IPv6 address.
bool isV4() const
Convenience function to check for an IPv4 address.
std::function< void()> Callback
Exception thrown when error occurs during spawning a process.
Utility class for spawning new processes.
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::string getParameter(const std::string &name) const
Returns value of a connection parameter.
util::ReconnectCtlPtr reconnectCtl()
The reconnect settings.
static bool invokeDbLostCallback(const util::ReconnectCtlPtr &db_reconnect_ctl)
Invokes the connection's lost connectivity callback.
static std::string redactedAccessString(const ParameterMap ¶meters)
Redact database access string.
static isc::asiolink::IOServicePtr & getIOService()
Returns pointer to the IO service.
std::map< std::string, std::string > ParameterMap
Database configuration parameter map.
Invalid address family used as input to Lease Manager.
Provides methods to access CSV file with DHCPv4 leases.
Provides methods to access CSV file with DHCPv6 leases.
static std::string sanityCheckToText(LeaseSanity check_type)
Converts lease sanity check value to printable text.
uint16_t getFamily() const
Returns address family.
std::string validatePath(const std::string data_path) const
Validates a file path against the supported directory for DHCP data.
static CfgMgr & instance()
returns a single instance of Configuration Manager
SrvConfigPtr getStagingCfg()
Returns a pointer to the staging configuration.
std::string getDataDir(bool reset=false, const std::string explicit_path="")
Fetches the supported DHCP data directory.
SrvConfigPtr getCurrentCfg()
Returns a pointer to the current configuration.
Holds Client identifier or client IPv4 address.
const std::vector< uint8_t > & getClientId() const
Returns reference to the client-id data.
Holds DUID (DHCPv6 Unique Identifier).
const std::vector< uint8_t > & getDuid() const
Returns a const reference to the actual DUID value.
std::string toText() const
Returns textual representation of the identifier (e.g.
int getLastPid() const
Returns pid of the last lease file cleanup.
void execute(const std::string &lease_file)
Spawns a new process.
int getExitStatus() const
Returns exit code of the last completed cleanup.
bool isRunning() const
Checks if the lease file cleanup is in progress.
LFCSetup(asiolink::IntervalTimer::Callback callback)
Constructor.
void setup(const uint32_t lfc_interval, const boost::shared_ptr< CSVLeaseFile4 > &lease_file4, const boost::shared_ptr< CSVLeaseFile6 > &lease_file6, bool run_once_now=false)
Sets the new configuration for the Lease File Cleanup.
Lease6 extended informations for Bulk Lease Query.
static void load(LeaseFileType &lease_file, StorageType &storage, const uint32_t max_errors=0, const bool close_file_on_exit=true)
Load leases from the lease file into the specified storage.
void setExtendedInfoTablesEnabled(const bool enabled)
Modifies the setting whether the lease6 extended info tables are enabled.
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.
bool getExtendedInfoTablesEnabled() const
Returns the setting indicating if lease6 extended info tables are enabled.
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 bool addExtendedInfo6(const Lease6Ptr &lease)
Extract extended info from a lease6 and add it into tables.
Wraps value holding size of the page with leases.
const size_t page_size_
Holds page size.
LeaseStatsQuery(const SelectMode &select_mode=ALL_SUBNETS)
Constructor to query statistics for all subnets.
SubnetID getLastSubnetID() const
Returns the value of last subnet ID specified (or zero).
SubnetID getFirstSubnetID() const
Returns the value of first subnet ID specified (or zero).
SelectMode getSelectMode() const
Returns the selection criteria mode The value returned is based upon the constructor variant used and...
SelectMode
Defines the types of selection criteria supported.
Memfile derivation of the IPv4 statistical lease data query.
MemfileLeaseStatsQuery4(Lease4Storage &storage4, const SubnetID &first_subnet_id, const SubnetID &last_subnet_id)
Constructor for a subnet range query.
MemfileLeaseStatsQuery4(Lease4Storage &storage4, const SelectMode &select_mode=ALL_SUBNETS)
Constructor for an all subnets query.
virtual ~MemfileLeaseStatsQuery4()
Destructor.
void start()
Creates the IPv4 lease statistical data result set.
MemfileLeaseStatsQuery4(Lease4Storage &storage4, const SubnetID &subnet_id)
Constructor for a single subnet query.
Memfile derivation of the IPv6 statistical lease data query.
void start()
Creates the IPv6 lease statistical data result set.
virtual ~MemfileLeaseStatsQuery6()
Destructor.
MemfileLeaseStatsQuery6(Lease6Storage &storage6, const SubnetID &first_subnet_id, const SubnetID &last_subnet_id)
Constructor for a subnet range query.
MemfileLeaseStatsQuery6(Lease6Storage &storage6, const SelectMode &select_mode=ALL_SUBNETS)
Constructor.
MemfileLeaseStatsQuery6(Lease6Storage &storage6, const SubnetID &subnet_id)
Constructor for a single subnet query.
std::vector< LeaseStatsRow >::iterator next_pos_
An iterator for accessing the next row within the result set.
MemfileLeaseStatsQuery(const SubnetID &first_subnet_id, const SubnetID &last_subnet_id)
Constructor for subnet range query.
virtual bool getNextRow(LeaseStatsRow &row)
Fetches the next row in the result set.
std::vector< LeaseStatsRow > rows_
A vector containing the "result set".
MemfileLeaseStatsQuery(const SelectMode &select_mode=ALL_SUBNETS)
Constructor for all subnets query.
virtual ~MemfileLeaseStatsQuery()
Destructor.
int getRowCount() const
Returns the number of rows in the result set.
MemfileLeaseStatsQuery(const SubnetID &subnet_id)
Constructor for single subnet query.
Lease6ExtendedInfoRemoteIdTable remote_id6_
stores IPv6 by-remote-id cross-reference table
virtual void rollback() override
Rollback Transactions.
size_t extractExtendedInfo4(bool update, bool current)
Extract extended info for v4 leases.
virtual LeaseStatsQueryPtr startSubnetRangeLeaseStatsQuery6(const SubnetID &first_subnet_id, const SubnetID &last_subnet_id) override
Creates and runs the IPv6 lease stats query for a single subnet.
virtual void clearClassLeaseCounts() override
Clears the class-lease count map.
virtual size_t byRelayId6size() const override
Return the by-relay-id table size.
virtual data::ElementPtr getStatus() const override
Return status information.
virtual Lease4Collection getLeases4ByRelayId(const OptionBuffer &relay_id, const asiolink::IOAddress &lower_bound_address, const LeasePageSize &page_size, const time_t &qry_start_time=0, const time_t &qry_end_time=0) override
The following queries are used to fulfill Bulk Lease Query queries.
Memfile_LeaseMgr(const db::DatabaseConnection::ParameterMap ¶meters)
The sole lease manager constructor.
bool isLFCRunning() const
Checks if the process performing lease file cleanup is running.
virtual void writeLeases4(const std::string &filename) override
Write V4 leases to a file.
virtual void updateLease4(const Lease4Ptr &lease4) override
Updates IPv4 lease.
virtual size_t wipeLeases4(const SubnetID &subnet_id) override
Removes specified IPv4 leases.
virtual void deleteExtendedInfo6(const isc::asiolink::IOAddress &addr) override
Delete lease6 extended info from tables.
static bool isLFCProcessRunning(const std::string file_name, Universe u)
Check if LFC is running.
Universe
Specifies universe (V4, V6).
static std::string getDefaultLeaseFilePath(Universe u, const std::string filename="")
Returns default path to the lease file.
static TrackingLeaseMgrPtr factory(const isc::db::DatabaseConnection::ParameterMap ¶meters)
Factory class method.
LFCFileType
Types of the lease files used by the Lease File Cleanup.
@ FILE_PREVIOUS
Previous Lease File.
@ FILE_FINISH
LFC Finish File.
@ FILE_OUTPUT
LFC Output File.
@ FILE_INPUT
Lease File Copy
virtual bool deleteLease(const Lease4Ptr &lease) override
Deletes an IPv4 lease.
virtual void commit() override
Commit Transactions.
virtual size_t wipeLeases6(const SubnetID &subnet_id) override
Removed specified IPv6 leases.
virtual std::pair< uint32_t, uint32_t > getVersion(const std::string &timer_name=std::string()) const override
Returns backend version.
int getLFCExitStatus() const
Returns the status code returned by the last executed LFC process.
virtual LeaseStatsQueryPtr startPoolLeaseStatsQuery6() override
Creates and runs the IPv6 lease stats query for all subnets and pools.
bool persistLeases(Universe u) const
Specifies whether or not leases are written to disk.
virtual void addRemoteId6(const isc::asiolink::IOAddress &lease_addr, const std::vector< uint8_t > &remote_id) override
Add lease6 extended info into by-remote-id table.
static std::string getDBVersion()
Return extended version info.
virtual Lease4Collection getLeases4() const override
Returns all IPv4 leases.
virtual size_t getClassLeaseCount(const ClientClass &client_class, const Lease::Type <ype=Lease::TYPE_V4) const override
Returns the class lease count for a given class and lease type.
virtual isc::data::ConstElementPtr lfcStartHandler() override
Handler for kea-lfc-start command.
virtual void getExpiredLeases6(Lease6Collection &expired_leases, const size_t max_leases) const override
Returns a collection of expired DHCPv6 leases.
void buildExtendedInfoTables6()
Extended information / Bulk Lease Query shared interface.
virtual bool addLease(const Lease4Ptr &lease) override
Adds an IPv4 lease.
virtual size_t byRemoteId6size() const override
Return the by-remote-id table size.
virtual void writeLeases6(const std::string &filename) override
Write V6 leases to a file.
Lease6ExtendedInfoRelayIdTable relay_id6_
stores IPv6 by-relay-id cross-reference table
virtual void recountClassLeases6() override
Recount the leases per class for V6 leases.
virtual Lease4Collection getLeases4ByRemoteId(const OptionBuffer &remote_id, const asiolink::IOAddress &lower_bound_address, const LeasePageSize &page_size, const time_t &qry_start_time=0, const time_t &qry_end_time=0) override
Returns existing IPv4 leases with a given remote-id.
virtual void wipeExtendedInfoTables6() override
Wipe extended info table (v6).
boost::shared_ptr< CSVLeaseFile4 > lease_file4_
Holds the pointer to the DHCPv4 lease file IO.
std::string getLeaseFilePath(Universe u) const
Returns an absolute path to the lease file.
virtual Lease6Collection getLeases6ByRemoteId(const OptionBuffer &remote_id, const asiolink::IOAddress &lower_bound_address, const LeasePageSize &page_size) override
Returns existing IPv6 leases with a given remote-id.
virtual Lease6Collection getLeases6() const override
Returns all IPv6 leases.
virtual void lfcCallback()
A callback function triggering Lease File Cleanup (LFC).
virtual LeaseStatsQueryPtr startSubnetLeaseStatsQuery4(const SubnetID &subnet_id) override
Creates and runs the IPv4 lease stats query for a single subnet.
int getLFCLastPid() const
Returns the last lfc process id.
virtual Lease6Collection getLeases6ByRelayId(const DUID &relay_id, const asiolink::IOAddress &lower_bound_address, const LeasePageSize &page_size) override
Returns existing IPv6 leases with a given relay-id.
virtual LeaseStatsQueryPtr startSubnetLeaseStatsQuery6(const SubnetID &subnet_id) override
Creates and runs the IPv6 lease stats query for a single subnet.
virtual std::string getDescription() const override
Returns description of the backend.
static std::string appendSuffix(const std::string &file_name, const LFCFileType &file_type)
Appends appropriate suffix to the file name.
virtual void addRelayId6(const isc::asiolink::IOAddress &lease_addr, const std::vector< uint8_t > &relay_id) override
Add lease6 extended info into by-relay-id table.
virtual size_t upgradeExtendedInfo6(const LeasePageSize &page_size) override
Upgrade extended info (v6).
virtual LeaseStatsQueryPtr startLeaseStatsQuery4() override
Creates and runs the IPv4 lease stats query.
virtual Lease6Ptr getLease6(Lease::Type type, const isc::asiolink::IOAddress &addr) const override
Returns existing IPv6 lease for a given IPv6 address.
virtual void recountClassLeases4() override
Recount the leases per class for V4 leases.
virtual void updateLease6(const Lease6Ptr &lease6) override
Updates IPv6 lease.
virtual LeaseStatsQueryPtr startSubnetRangeLeaseStatsQuery4(const SubnetID &first_subnet_id, const SubnetID &last_subnet_id) override
Creates and runs the IPv4 lease stats query for a single subnet.
virtual uint64_t deleteExpiredReclaimedLeases4(const uint32_t secs) override
Deletes all expired-reclaimed DHCPv4 leases.
static std::string getDBVersionInternal(Universe const &u)
Local version of getDBVersion() class method.
virtual LeaseStatsQueryPtr startPoolLeaseStatsQuery4() override
Creates and runs the IPv4 lease stats query for all subnets and pools.
virtual std::string checkLimits6(isc::data::ConstElementPtr const &user_context) const override
Checks if the IPv6 lease limits set in the given user context are exceeded.
virtual LeaseStatsQueryPtr startLeaseStatsQuery6() override
Creates and runs the IPv6 lease stats query.
virtual Lease4Ptr getLease4(const isc::asiolink::IOAddress &addr) const override
Returns existing IPv4 lease for specified IPv4 address.
virtual ~Memfile_LeaseMgr()
Destructor (closes file).
virtual std::string checkLimits4(isc::data::ConstElementPtr const &user_context) const override
Checks if the IPv4 lease limits set in the given user context are exceeded.
boost::shared_ptr< CSVLeaseFile6 > lease_file6_
Holds the pointer to the DHCPv6 lease file IO.
virtual size_t upgradeExtendedInfo4(const LeasePageSize &page_size) override
Upgrade extended info (v4).
virtual uint64_t deleteExpiredReclaimedLeases6(const uint32_t secs) override
Deletes all expired-reclaimed DHCPv6 leases.
virtual void getExpiredLeases4(Lease4Collection &expired_leases, const size_t max_leases) const override
Returns a collection of expired DHCPv4 leases.
static const unsigned int DB_CONNECTION
The network state is being altered by the DB connection recovery mechanics.
Attempt to update lease that was not there.
Manages a pool of asynchronous interval timers.
static const TimerMgrPtr & instance()
Returns pointer to the sole instance of the TimerMgr.
void trackAddLease(const LeasePtr &lease)
Invokes the callbacks when a new lease is added.
void trackUpdateLease(const LeasePtr &lease)
Invokes the callbacks when a lease is updated.
void trackDeleteLease(const LeasePtr &lease)
Invokes the callbacks when a lease is deleted.
TrackingLeaseMgr()
Constructor.
bool hasCallbacks() const
Checks if any callbacks have been registered.
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.
Exception thrown when an unrecoverable error occurs such as disk-full on write.
RAII class creating a critical section.
static MultiThreadingMgr & instance()
Returns a single instance of Multi Threading Manager.
Exception thrown when an error occurs during PID file processing.
Class to help with processing PID files.
void write(int) const
Write the PID to the file.
void deleteFile() const
Delete the PID file.
std::string getLockname() const
Returns the path to the lock file.
int check() const
Read the PID in from the file and check it.
RAII device to handle a lock file to avoid race conditions.
bool isLocked()
Return the lock status.
This file contains several functions and constants that are used for handling commands and responses ...
int version()
returns Kea hooks version.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
isc::data::ConstElementPtr get(const std::string &name) const
Returns a single statistic as a JSON structure.
static const int MAJOR_VERSION_V4
static const int MINOR_VERSION_V4
the minor version of the v4 memfile backend
static const int MAJOR_VERSION_V6
static const int MINOR_VERSION_V6
the minor version of the v6 memfile backend
int get(CalloutHandle &handle)
The gss-tsig-get command.
#define LOG_ERROR(LOGGER, MESSAGE)
Macro to conveniently test error output and log it.
#define LOG_INFO(LOGGER, MESSAGE)
Macro to conveniently test info output and log it.
#define LOG_WARN(LOGGER, MESSAGE)
Macro to conveniently test warn output and log it.
#define LOG_DEBUG(LOGGER, LEVEL, MESSAGE)
Macro to conveniently test debug output and log it.
std::vector< std::string > ProcessArgs
Type of the container holding arguments of the executable being run as a background process.
std::vector< std::string > ProcessEnvVars
Type of the container holding environment variables of the executable being run as a background proce...
const int CONTROL_RESULT_EMPTY
Status code indicating that the specified command was completed correctly, but failed to produce any ...
const int CONTROL_RESULT_ERROR
Status code indicating a general failure.
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.
const int CONTROL_RESULT_SUCCESS
Status code indicating a successful operation.
void prettyPrint(ConstElementPtr element, std::ostream &out, unsigned indent, unsigned step)
Pretty prints the data into stream.
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
const isc::log::MessageID DHCPSRV_MEMFILE_LFC_START
isc::log::Logger dhcpsrv_logger("dhcpsrv")
DHCP server library Logger.
const isc::log::MessageID DHCPSRV_MEMFILE_GET_SUBID_CLIENTID
const isc::log::MessageID DHCPSRV_MEMFILE_EXTRACT_EXTENDED_INFO4
std::string ClientClass
Defines a single class name.
const isc::log::MessageID DHCPSRV_MEMFILE_GET_SUBID_HWADDR
const isc::log::MessageID DHCPSRV_MEMFILE_WIPE_LEASES6
const isc::log::MessageID DHCPSRV_MEMFILE_LFC_RUNNING
const isc::log::MessageID DHCPSRV_MEMFILE_GET4
const isc::log::MessageID DHCPSRV_MEMFILE_BUILD_EXTENDED_INFO_TABLES6_ERROR
const isc::log::MessageID DHCPSRV_MEMFILE_GET_REMOTEID6
const isc::log::MessageID DHCPSRV_MEMFILE_GET_SUBID_PAGE6
const isc::log::MessageID DHCPSRV_MEMFILE_LFC_UNREGISTER_TIMER_FAILED
const isc::log::MessageID DHCPSRV_MEMFILE_LFC_SPAWN_FAIL
const isc::log::MessageID DHCPSRV_MEMFILE_PATH_SECURITY_WARNING
boost::multi_index_container< Lease6Ptr, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< boost::multi_index::tag< AddressIndexTag >, boost::multi_index::member< Lease, isc::asiolink::IOAddress, &Lease::addr_ > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< DuidIaidTypeIndexTag >, boost::multi_index::composite_key< Lease6, boost::multi_index::const_mem_fun< Lease6, const std::vector< uint8_t > &, &Lease6::getDuidVector >, boost::multi_index::member< Lease6, uint32_t, &Lease6::iaid_ >, boost::multi_index::member< Lease6, Lease::Type, &Lease6::type_ > > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< ExpirationIndexTag >, boost::multi_index::composite_key< Lease6, boost::multi_index::const_mem_fun< Lease, bool, &Lease::stateExpiredReclaimed >, boost::multi_index::const_mem_fun< Lease, int64_t, &Lease::getExpirationTime > > >, boost::multi_index::ordered_unique< boost::multi_index::tag< SubnetIdIndexTag >, boost::multi_index::composite_key< Lease6, boost::multi_index::member< Lease, isc::dhcp::SubnetID, &Lease::subnet_id_ >, boost::multi_index::member< Lease, isc::asiolink::IOAddress, &Lease::addr_ > > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< DuidIndexTag >, boost::multi_index::const_mem_fun< Lease6, const std::vector< uint8_t > &, &Lease6::getDuidVector > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< HostnameIndexTag >, boost::multi_index::member< Lease, std::string, &Lease::hostname_ > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< SubnetIdPoolIdIndexTag >, boost::multi_index::composite_key< Lease6, boost::multi_index::member< Lease, SubnetID, &Lease::subnet_id_ >, boost::multi_index::member< Lease, uint32_t, &Lease::pool_id_ > > >, boost::multi_index::hashed_non_unique< boost::multi_index::tag< HWAddressIndexTag >, boost::multi_index::const_mem_fun< Lease, const std::vector< uint8_t > &, &Lease::getHWAddrVector > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< StateIndexTag >, boost::multi_index::composite_key< Lease6, boost::multi_index::member< Lease, uint32_t, &Lease::state_ >, boost::multi_index::member< Lease, SubnetID, &Lease::subnet_id_ > > > > > Lease6Storage
A multi index container holding DHCPv6 leases.
const isc::log::MessageID DHCPSRV_MEMFILE_DB
Lease6Storage::index< ExpirationIndexTag >::type Lease6StorageExpirationIndex
DHCPv6 lease storage index by expiration time.
const isc::log::MessageID DHCPSRV_MEMFILE_CONVERTING_LEASE_FILES
const isc::log::MessageID DHCPSRV_MEMFILE_LFC_SETUP
const isc::log::MessageID DHCPSRV_MEMFILE_WIPE_LEASES6_FINISHED
Lease4Storage::index< StateIndexTag >::type Lease4StorageStateIndex
DHCPv4 lease storage index by state (and subnet if).
Lease6Storage::index< DuidIndexTag >::type Lease6StorageDuidIndex
DHCPv6 lease storage index by DUID.
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.
const isc::log::MessageID DHCPSRV_MEMFILE_WIPE_LEASES4
Lease6Storage::index< SubnetIdPoolIdIndexTag >::type Lease6StorageSubnetIdPoolIdIndex
DHCPv6 lease storage index subnet-id and pool-id.
boost::multi_index_container< Lease4Ptr, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< boost::multi_index::tag< AddressIndexTag >, boost::multi_index::member< Lease, isc::asiolink::IOAddress, &Lease::addr_ > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< HWAddressSubnetIdIndexTag >, boost::multi_index::composite_key< Lease4, boost::multi_index::const_mem_fun< Lease, const std::vector< uint8_t > &, &Lease::getHWAddrVector >, boost::multi_index::member< Lease, SubnetID, &Lease::subnet_id_ > > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< ClientIdSubnetIdIndexTag >, boost::multi_index::composite_key< Lease4, boost::multi_index::const_mem_fun< Lease4, const std::vector< uint8_t > &, &Lease4::getClientIdVector >, boost::multi_index::member< Lease, uint32_t, &Lease::subnet_id_ > > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< ExpirationIndexTag >, boost::multi_index::composite_key< Lease4, boost::multi_index::const_mem_fun< Lease, bool, &Lease::stateExpiredReclaimed >, boost::multi_index::const_mem_fun< Lease, int64_t, &Lease::getExpirationTime > > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< SubnetIdIndexTag >, boost::multi_index::member< Lease, isc::dhcp::SubnetID, &Lease::subnet_id_ > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< HostnameIndexTag >, boost::multi_index::member< Lease, std::string, &Lease::hostname_ > >, boost::multi_index::hashed_non_unique< boost::multi_index::tag< RemoteIdIndexTag >, boost::multi_index::member< Lease4, std::vector< uint8_t >, &Lease4::remote_id_ > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< RelayIdIndexTag >, boost::multi_index::composite_key< Lease4, boost::multi_index::member< Lease4, std::vector< uint8_t >, &Lease4::relay_id_ >, boost::multi_index::member< Lease, isc::asiolink::IOAddress, &Lease::addr_ > > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< SubnetIdPoolIdIndexTag >, boost::multi_index::composite_key< Lease4, boost::multi_index::member< Lease, SubnetID, &Lease::subnet_id_ >, boost::multi_index::member< Lease, uint32_t, &Lease::pool_id_ > > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< StateIndexTag >, boost::multi_index::composite_key< Lease4, boost::multi_index::member< Lease, uint32_t, &Lease::state_ >, boost::multi_index::member< Lease, SubnetID, &Lease::subnet_id_ > > > > > Lease4Storage
A multi index container holding DHCPv4 leases.
Lease6Storage::index< DuidIaidTypeIndexTag >::type Lease6StorageDuidIaidTypeIndex
DHCPv6 lease storage index by DUID, IAID, lease type.
boost::shared_ptr< TimerMgr > TimerMgrPtr
Type definition of the shared pointer to TimerMgr.
const isc::log::MessageID DHCPSRV_MEMFILE_GET_RELAYID4
const isc::log::MessageID DHCPSRV_MEMFILE_DELETE_EXPIRED_RECLAIMED_START
const isc::log::MessageID DHCPSRV_MEMFILE_LFC_LEASE_FILE_RENAME_FAIL
const isc::log::MessageID DHCPSRV_MEMFILE_UPDATE_ADDR4
const isc::log::MessageID DHCPSRV_MEMFILE_GET_SUBID6
Lease4Storage::index< ExpirationIndexTag >::type Lease4StorageExpirationIndex
DHCPv4 lease storage index by expiration time.
Lease6Storage::index< AddressIndexTag >::type Lease6StorageAddressIndex
DHCPv6 lease storage index by address.
const isc::log::MessageID DHCPSRV_MEMFILE_LFC_FAIL_PID_CREATE
const int DHCPSRV_DBG_TRACE_DETAIL
Additional information.
const isc::log::MessageID DHCPSRV_MEMFILE_GET_ADDR4
const isc::log::MessageID DHCPSRV_MEMFILE_ROLLBACK
const isc::log::MessageID DHCPSRV_MEMFILE_GET_HWADDR6
Lease6Storage::index< HWAddressIndexTag >::type Lease6StorageHWAddressIndex
DHCPv6 lease storage index by HW address.
const isc::log::MessageID DHCPSRV_MEMFILE_UPDATE_ADDR6
Lease4Storage::index< HostnameIndexTag >::type Lease4StorageHostnameIndex
DHCPv4 lease storage index by hostname.
std::pair< Lease4StorageRemoteIdIndex::const_iterator, Lease4StorageRemoteIdIndex::const_iterator > Lease4StorageRemoteIdRange
DHCPv4 lease storage range by remote-id.
const isc::log::MessageID DHCPSRV_MEMFILE_LFC_RESCHEDULED
Lease6Storage::index< HostnameIndexTag >::type Lease6StorageHostnameIndex
DHCPv6 lease storage index by hostname.
const isc::log::MessageID DHCPSRV_MEMFILE_GET_EXPIRED4
const isc::log::MessageID DHCPSRV_MEMFILE_GET_EXPIRED6
const isc::log::MessageID DHCPSRV_MEMFILE_GET_HOSTNAME4
Lease4Storage::index< ClientIdSubnetIdIndexTag >::type Lease4StorageClientIdSubnetIdIndex
DHCPv4 lease storage index by client-id and subnet-id.
Lease4Storage::index< HWAddressSubnetIdIndexTag >::type Lease4StorageHWAddressSubnetIdIndex
DHCPv4 lease storage index by HW address and subnet-id.
const isc::log::MessageID DHCPSRV_MEMFILE_EXTRACT_EXTENDED_INFO4_ERROR
const isc::log::MessageID DHCPSRV_MEMFILE_ADD_ADDR6
Lease6ExtendedInfoRelayIdTable::index< LeaseAddressIndexTag >::type LeaseAddressRelayIdIndex
Lease6 extended information by lease address index of by relay id table.
Lease6ExtendedInfoRelayIdTable::index< RelayIdIndexTag >::type RelayIdIndex
Lease6 extended information by relay id index.
Lease4Storage::index< RemoteIdIndexTag >::type Lease4StorageRemoteIdIndex
DHCPv4 lease storage index by remote-id.
uint32_t SubnetID
Defines unique IPv4 or IPv6 subnet identifier.
Lease6Storage::index< StateIndexTag >::type Lease6StorageStateIndex
DHCPv6 lease storage index by state (and subnet if).
const isc::log::MessageID DHCPSRV_MEMFILE_BEGIN_EXTRACT_EXTENDED_INFO4
const isc::log::MessageID DHCPSRV_MEMFILE_WIPE_LEASES4_FINISHED
const isc::log::MessageID DHCPSRV_MEMFILE_GET_SUBID4
const isc::log::MessageID DHCPSRV_MEMFILE_LFC_LEASE_FILE_REOPEN_FAIL
const isc::log::MessageID DHCPSRV_MEMFILE_COMMIT
const isc::log::MessageID DHCPSRV_MEMFILE_DELETE_EXPIRED_RECLAIMED4
boost::shared_ptr< CfgConsistency > CfgConsistencyPtr
Type used to for pointing to CfgConsistency structure.
const isc::log::MessageID DHCPSRV_MEMFILE_BEGIN_BUILD_EXTENDED_INFO_TABLES6
const isc::log::MessageID DHCPSRV_MEMFILE_GET_HOSTNAME6
const isc::log::MessageID DHCPSRV_MEMFILE_DELETE_EXPIRED_RECLAIMED6
const isc::log::MessageID DHCPSRV_MEMFILE_LFC_EXECUTE
std::pair< RemoteIdIndex::const_iterator, RemoteIdIndex::const_iterator > RemoteIdIndexRange
Lease6 extended information by remote id range.
const isc::log::MessageID DHCPSRV_MEMFILE_GET_RELAYID6
const isc::log::MessageID DHCPSRV_MEMFILE_NO_STORAGE
const isc::log::MessageID DHCPSRV_MEMFILE_BUILD_EXTENDED_INFO_TABLES6
std::unique_ptr< TrackingLeaseMgr > TrackingLeaseMgrPtr
TrackingLeaseMgr pointer.
const isc::log::MessageID DHCPSRV_MEMFILE_GET_PAGE4
const isc::log::MessageID DHCPSRV_MEMFILE_GET6_DUID
Lease4Storage::index< SubnetIdIndexTag >::type Lease4StorageSubnetIdIndex
DHCPv4 lease storage index subnet-id.
const isc::log::MessageID DHCPSRV_MEMFILE_GET_HWADDR4
std::vector< uint8_t > OptionBuffer
buffer types used in DHCP code.
const isc::log::MessageID DHCPSRV_MEMFILE_DELETE_ADDR4
std::vector< Lease4Ptr > Lease4Collection
A collection of IPv4 leases.
const isc::log::MessageID DHCPSRV_MEMFILE_GET_ADDR6
const isc::log::MessageID DHCPSRV_MEMFILE_ADD_ADDR4
const isc::log::MessageID DHCPSRV_MEMFILE_GET_CLIENTID
Lease4Storage::index< AddressIndexTag >::type Lease4StorageAddressIndex
DHCPv4 lease storage index by address.
const isc::log::MessageID DHCPSRV_MEMFILE_GET_IAID_DUID
const isc::log::MessageID DHCPSRV_MEMFILE_GET6
const isc::log::MessageID DHCPSRV_MEMFILE_GET_REMOTEID4
boost::shared_ptr< Lease4 > Lease4Ptr
Pointer to a Lease4 structure.
Lease6ExtendedInfoRemoteIdTable::index< LeaseAddressIndexTag >::type LeaseAddressRemoteIdIndex
Lease6 extended information by lease address index of by remote id table.
const int DHCPSRV_DBG_TRACE
DHCP server library logging levels.
const isc::log::MessageID DHCPSRV_MEMFILE_FAILED_TO_OPEN
Lease6Storage::index< SubnetIdIndexTag >::type Lease6StorageSubnetIdIndex
DHCPv6 lease storage index by subnet-id.
const isc::log::MessageID DHCPSRV_MEMFILE_GET_IAID_SUBID_DUID
boost::shared_ptr< Lease6ExtendedInfo > Lease6ExtendedInfoPtr
Pointer to a Lease6ExtendedInfo object.
const isc::log::MessageID DHCPSRV_MEMFILE_DELETE_ADDR6
Lease6ExtendedInfoRemoteIdTable::index< RemoteIdIndexTag >::type RemoteIdIndex
Lease6 extended information by remote id index.
Lease4Storage::index< SubnetIdPoolIdIndexTag >::type Lease4StorageSubnetIdPoolIdIndex
DHCPv4 lease storage index subnet-id and pool-id.
Lease4Storage::index< RelayIdIndexTag >::type Lease4StorageRelayIdIndex
DHCPv4 lease storage index by relay-id.
const isc::log::MessageID DHCPSRV_MEMFILE_GET_PAGE6
string dumpAsHex(const uint8_t *data, size_t length)
Dumps a buffer of bytes as a string of hexadecimal digits.
Defines the logger used by the top-level component of kea-lfc.
Tag for indexes by address.
Tag for indexes by client-id, subnet-id tuple.
Tag for indexes by DUID, IAID, lease type tuple.
Tag for index using DUID.
Tag for indexes by expiration time.
Hardware type that represents information from DHCPv4 packet.
std::vector< uint8_t > hwaddr_
std::string toText(bool include_htype=true) const
Returns textual representation of a hardware address (e.g.
Tag for indexes by HW address, subnet-id tuple.
Tag for index using hostname.
Structure that holds a lease for IPv4 address.
Structure that holds a lease for IPv6 address and/or prefix.
ExtendedInfoAction
Action on extended info tables.
@ ACTION_UPDATE
update extended info tables.
@ ACTION_DELETE
delete reference to the lease
@ ACTION_IGNORE
ignore extended info,
Tag for indexes by lease address.
Contains a single row of lease statistical data.
static constexpr uint32_t STATE_DEFAULT
A lease in the default state.
static constexpr uint32_t STATE_DECLINED
Declined lease.
static constexpr uint32_t STATE_REGISTERED
Registered self-generated 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
static std::string typeToText(Type type)
returns text representation of a lease type
Tag for index using relay-id.
Tag for index using remote-id.
Tag for indexes by subnet-id (and address for v6).