39 const char* KEA_LFC_EXECUTABLE_ENV_NAME =
"KEA_LFC_EXECUTABLE";
94 void setup(
const uint32_t lfc_interval,
95 const boost::shared_ptr<CSVLeaseFile4>& lease_file4,
96 const boost::shared_ptr<CSVLeaseFile6>& lease_file6,
97 bool run_once_now =
false);
105 bool isRunning()
const;
108 int getExitStatus()
const;
114 boost::scoped_ptr<ProcessSpawn> process_;
130 : process_(), callback_(callback), pid_(0),
146 timer_mgr_->unregisterTimer(
"memfile-lfc");
148 }
catch (
const std::exception& ex) {
159 const boost::shared_ptr<CSVLeaseFile4>& lease_file4,
160 const boost::shared_ptr<CSVLeaseFile6>& lease_file6,
164 if (lfc_interval == 0 && !run_once_now) {
169 std::string executable;
170 char* c_executable = getenv(KEA_LFC_EXECUTABLE_ENV_NAME);
172 executable = KEA_LFC_EXECUTABLE;
174 executable = c_executable;
178 std::string lease_file = lease_file4 ? lease_file4->getFilename() :
179 lease_file6->getFilename();
184 args.push_back(lease_file4 ?
"-4" :
"-6");
187 args.push_back(
"-x");
191 args.push_back(
"-i");
195 args.push_back(
"-o");
199 args.push_back(
"-f");
203 args.push_back(
"-p");
208 args.push_back(
"-c");
209 args.push_back(
"ignored-path");
220 if (lfc_interval > 0) {
227 timer_mgr_->registerTimer(
"memfile-lfc", callback_, lfc_interval * 1000,
229 timer_mgr_->setup(
"memfile-lfc");
237 .arg(process_->getCommandLine());
238 pid_ = process_->spawn();
247 return (process_ && process_->isRunning(pid_));
254 " the process is null");
256 return (process_->getExitStatus(pid_));
315 return (
rows_.size());
411 void startSubnets() {
416 Lease4StorageSubnetIdIndex::const_iterator lower;
417 Lease4StorageSubnetIdIndex::const_iterator upper;
440 if (lower == upper) {
448 int64_t assigned = 0;
449 int64_t declined = 0;
450 for (Lease4StorageSubnetIdIndex::const_iterator lease = lower;
451 lease != upper; ++lease) {
454 if ((*lease)->subnet_id_ != cur_id) {
457 rows_.push_back(LeaseStatsRow(cur_id,
464 rows_.push_back(LeaseStatsRow(cur_id,
472 cur_id = (*lease)->subnet_id_;
512 void startSubnetPools() {
514 = storage4_.get<SubnetIdPoolIdIndexTag>();
517 Lease4StorageSubnetIdPoolIdIndex::const_iterator lower;
518 Lease4StorageSubnetIdPoolIdIndex::const_iterator upper;
530 if (lower == upper) {
538 uint32_t cur_pool_id = 0;
539 int64_t assigned = 0;
540 int64_t declined = 0;
541 for (Lease4StorageSubnetIdPoolIdIndex::const_iterator lease = lower;
542 lease != upper; ++lease) {
545 if ((*lease)->pool_id_ != cur_pool_id) {
547 rows_.push_back(LeaseStatsRow(cur_id,
549 assigned, cur_pool_id));
554 rows_.push_back(LeaseStatsRow(cur_id,
556 declined, cur_pool_id));
561 cur_pool_id = (*lease)->pool_id_;
566 if ((*lease)->subnet_id_ != cur_id) {
569 rows_.push_back(LeaseStatsRow(cur_id,
571 assigned, cur_pool_id));
576 rows_.push_back(LeaseStatsRow(cur_id,
578 declined, cur_pool_id));
584 cur_id = (*lease)->subnet_id_;
601 assigned, cur_pool_id));
606 declined, cur_pool_id));
703 virtual void startSubnets() {
708 Lease6StorageSubnetIdIndex::const_iterator lower;
709 Lease6StorageSubnetIdIndex::const_iterator upper;
731 if (lower == upper) {
739 int64_t assigned = 0;
740 int64_t declined = 0;
741 int64_t assigned_pds = 0;
742 for (Lease6StorageSubnetIdIndex::const_iterator lease = lower;
743 lease != upper; ++lease) {
746 if ((*lease)->subnet_id_ != cur_id) {
762 if (assigned_pds > 0) {
771 cur_id = (*lease)->subnet_id_;
776 switch((*lease)->type_) {
805 if (assigned_pds > 0) {
828 virtual void startSubnetPools() {
830 = storage6_.get<SubnetIdPoolIdIndexTag>();
833 Lease6StorageSubnetIdPoolIdIndex::const_iterator lower;
834 Lease6StorageSubnetIdPoolIdIndex::const_iterator upper;
846 if (lower == upper) {
854 uint32_t cur_pool_id = 0;
855 int64_t assigned = 0;
856 int64_t declined = 0;
857 int64_t assigned_pds = 0;
858 for (Lease6StorageSubnetIdPoolIdIndex::const_iterator lease = lower;
859 lease != upper; ++lease) {
862 if ((*lease)->pool_id_ != cur_pool_id) {
866 assigned, cur_pool_id));
873 declined, cur_pool_id));
877 if (assigned_pds > 0) {
880 assigned_pds, cur_pool_id));
885 cur_pool_id = (*lease)->pool_id_;
890 if ((*lease)->subnet_id_ != cur_id) {
895 assigned, cur_pool_id));
902 declined, cur_pool_id));
906 if (assigned_pds > 0) {
909 assigned_pds, cur_pool_id));
915 cur_id = (*lease)->subnet_id_;
923 switch((*lease)->type_) {
954 if (assigned_pds > 0) {
976 :
TrackingLeaseMgr(), lfc_setup_(), conn_(parameters), mutex_(new std::mutex) {
977 bool conversion_needed =
false;
984 if (universe ==
"4") {
985 std::string file4 = initLeaseFilePath(
V4);
986 if (!file4.empty()) {
987 conversion_needed = loadLeasesFromFiles<
Lease4,
994 std::string file6 = initLeaseFilePath(
V6);
995 if (!file6.empty()) {
996 conversion_needed = loadLeasesFromFiles<
Lease6,
1011 if (conversion_needed) {
1016 lfcSetup(conversion_needed);
1033 std::stringstream tmp;
1034 tmp <<
"Memfile backend ";
1037 }
else if (u ==
V6) {
1044 Memfile_LeaseMgr::addLeaseInternal(
const Lease4Ptr& lease) {
1045 if (getLease4Internal(lease->addr_)) {
1057 storage4_.insert(lease);
1061 lease->updateCurrentExpirationTime();
1064 class_lease_counter_.
addLease(lease);
1079 if (MultiThreadingMgr::instance().getMode()) {
1080 std::lock_guard<std::mutex> lock(*mutex_);
1081 return (addLeaseInternal(lease));
1083 return (addLeaseInternal(lease));
1088 Memfile_LeaseMgr::addLeaseInternal(
const Lease6Ptr& lease) {
1089 if (getLease6Internal(lease->type_, lease->addr_)) {
1102 storage6_.insert(lease);
1106 lease->updateCurrentExpirationTime();
1109 class_lease_counter_.
addLease(lease);
1128 if (MultiThreadingMgr::instance().getMode()) {
1129 std::lock_guard<std::mutex> lock(*mutex_);
1130 return (addLeaseInternal(lease));
1132 return (addLeaseInternal(lease));
1139 Lease4StorageAddressIndex::iterator l = idx.find(addr);
1140 if (l == idx.end()) {
1152 if (MultiThreadingMgr::instance().getMode()) {
1153 std::lock_guard<std::mutex> lock(*mutex_);
1154 return (getLease4Internal(addr));
1156 return (getLease4Internal(addr));
1161 Memfile_LeaseMgr::getLease4Internal(
const HWAddr& hwaddr,
1167 std::pair<Lease4StorageHWAddressSubnetIdIndex::const_iterator,
1168 Lease4StorageHWAddressSubnetIdIndex::const_iterator> l
1169 = idx.equal_range(boost::make_tuple(hwaddr.
hwaddr_));
1171 for (
auto lease = l.first; lease != l.second; ++lease) {
1182 if (MultiThreadingMgr::instance().getMode()) {
1183 std::lock_guard<std::mutex> lock(*mutex_);
1184 getLease4Internal(hwaddr, collection);
1186 getLease4Internal(hwaddr, collection);
1189 return (collection);
1193 Memfile_LeaseMgr::getLease4Internal(
const HWAddr& hwaddr,
1199 Lease4StorageHWAddressSubnetIdIndex::const_iterator lease =
1200 idx.find(boost::make_tuple(hwaddr.
hwaddr_, subnet_id));
1202 if (lease == idx.end()) {
1207 return (
Lease4Ptr(
new Lease4(**lease)));
1217 if (MultiThreadingMgr::instance().getMode()) {
1218 std::lock_guard<std::mutex> lock(*mutex_);
1219 return (getLease4Internal(hwaddr, subnet_id));
1221 return (getLease4Internal(hwaddr, subnet_id));
1226 Memfile_LeaseMgr::getLease4Internal(
const ClientId& client_id,
1232 std::pair<Lease4StorageClientIdSubnetIdIndex::const_iterator,
1233 Lease4StorageClientIdSubnetIdIndex::const_iterator> l
1234 = idx.equal_range(boost::make_tuple(client_id.
getClientId()));
1236 for (
auto lease = l.first; lease != l.second; ++lease) {
1247 if (MultiThreadingMgr::instance().getMode()) {
1248 std::lock_guard<std::mutex> lock(*mutex_);
1249 getLease4Internal(client_id, collection);
1251 getLease4Internal(client_id, collection);
1254 return (collection);
1258 Memfile_LeaseMgr::getLease4Internal(
const ClientId& client_id,
1264 Lease4StorageClientIdSubnetIdIndex::const_iterator lease =
1265 idx.find(boost::make_tuple(client_id.
getClientId(), subnet_id));
1267 if (lease == idx.end()) {
1271 return (
Lease4Ptr(
new Lease4(**lease)));
1279 .arg(client_id.
toText());
1281 if (MultiThreadingMgr::instance().getMode()) {
1282 std::lock_guard<std::mutex> lock(*mutex_);
1283 return (getLease4Internal(client_id, subnet_id));
1285 return (getLease4Internal(client_id, subnet_id));
1290 Memfile_LeaseMgr::getLeases4Internal(
SubnetID subnet_id,
1293 std::pair<Lease4StorageSubnetIdIndex::const_iterator,
1294 Lease4StorageSubnetIdIndex::const_iterator> l =
1295 idx.equal_range(subnet_id);
1297 for (
auto lease = l.first; lease != l.second; ++lease) {
1308 if (MultiThreadingMgr::instance().getMode()) {
1309 std::lock_guard<std::mutex> lock(*mutex_);
1310 getLeases4Internal(subnet_id, collection);
1312 getLeases4Internal(subnet_id, collection);
1315 return (collection);
1319 Memfile_LeaseMgr::getLeases4Internal(
const std::string& hostname,
1322 std::pair<Lease4StorageHostnameIndex::const_iterator,
1323 Lease4StorageHostnameIndex::const_iterator> l =
1324 idx.equal_range(hostname);
1326 for (
auto lease = l.first; lease != l.second; ++lease) {
1337 if (MultiThreadingMgr::instance().getMode()) {
1338 std::lock_guard<std::mutex> lock(*mutex_);
1339 getLeases4Internal(hostname, collection);
1341 getLeases4Internal(hostname, collection);
1344 return (collection);
1349 for (
auto lease = storage4_.begin(); lease != storage4_.end(); ++lease) {
1359 if (MultiThreadingMgr::instance().getMode()) {
1360 std::lock_guard<std::mutex> lock(*mutex_);
1361 getLeases4Internal(collection);
1363 getLeases4Internal(collection);
1366 return (collection);
1374 Lease4StorageAddressIndex::const_iterator lb = idx.lower_bound(lower_bound_address);
1377 if ((lb != idx.end()) && ((*lb)->addr_ == lower_bound_address)) {
1382 for (
auto lease = lb;
1383 (lease != idx.end()) && (std::distance(lb, lease) < page_size.
page_size_);
1385 collection.push_back(
Lease4Ptr(
new Lease4(**lease)));
1393 if (!lower_bound_address.
isV4()) {
1395 "retrieving leases from the lease database, got "
1396 << lower_bound_address);
1401 .arg(lower_bound_address.
toText());
1404 if (MultiThreadingMgr::instance().getMode()) {
1405 std::lock_guard<std::mutex> lock(*mutex_);
1406 getLeases4Internal(lower_bound_address, page_size, collection);
1408 getLeases4Internal(lower_bound_address, page_size, collection);
1411 return (collection);
1415 Memfile_LeaseMgr::getLease6Internal(
Lease::Type type,
1417 Lease6Storage::iterator l = storage6_.find(addr);
1418 if (l == storage6_.end() || !(*l) || ((*l)->type_ != type)) {
1427 Lease6Storage::iterator l = storage6_.find(addr);
1428 if (l == storage6_.end() || !(*l)) {
1443 if (MultiThreadingMgr::instance().getMode()) {
1444 std::lock_guard<std::mutex> lock(*mutex_);
1445 return (getLease6Internal(type, addr));
1447 return (getLease6Internal(type, addr));
1452 Memfile_LeaseMgr::getLeases6Internal(
Lease::Type type,
1459 std::pair<Lease6StorageDuidIaidTypeIndex::const_iterator,
1460 Lease6StorageDuidIaidTypeIndex::const_iterator> l =
1461 idx.equal_range(boost::make_tuple(duid.
getDuid(), iaid, type));
1463 for (Lease6StorageDuidIaidTypeIndex::const_iterator lease =
1464 l.first; lease != l.second; ++lease) {
1472 uint32_t iaid)
const {
1480 if (MultiThreadingMgr::instance().getMode()) {
1481 std::lock_guard<std::mutex> lock(*mutex_);
1482 getLeases6Internal(type, duid, iaid, collection);
1484 getLeases6Internal(type, duid, iaid, collection);
1487 return (collection);
1491 Memfile_LeaseMgr::getLeases6Internal(
Lease::Type type,
1499 std::pair<Lease6StorageDuidIaidTypeIndex::const_iterator,
1500 Lease6StorageDuidIaidTypeIndex::const_iterator> l =
1501 idx.equal_range(boost::make_tuple(duid.
getDuid(), iaid, type));
1503 for (Lease6StorageDuidIaidTypeIndex::const_iterator lease =
1504 l.first; lease != l.second; ++lease) {
1506 if ((*lease)->subnet_id_ == subnet_id) {
1525 if (MultiThreadingMgr::instance().getMode()) {
1526 std::lock_guard<std::mutex> lock(*mutex_);
1527 getLeases6Internal(type, duid, iaid, subnet_id, collection);
1529 getLeases6Internal(type, duid, iaid, subnet_id, collection);
1532 return (collection);
1536 Memfile_LeaseMgr::getLeases6Internal(
SubnetID subnet_id,
1539 std::pair<Lease6StorageSubnetIdIndex::const_iterator,
1540 Lease6StorageSubnetIdIndex::const_iterator> l =
1541 idx.equal_range(subnet_id);
1543 for (
auto lease = l.first; lease != l.second; ++lease) {
1554 if (MultiThreadingMgr::instance().getMode()) {
1555 std::lock_guard<std::mutex> lock(*mutex_);
1556 getLeases6Internal(subnet_id, collection);
1558 getLeases6Internal(subnet_id, collection);
1561 return (collection);
1565 Memfile_LeaseMgr::getLeases6Internal(
const std::string& hostname,
1568 std::pair<Lease6StorageHostnameIndex::const_iterator,
1569 Lease6StorageHostnameIndex::const_iterator> l =
1570 idx.equal_range(hostname);
1572 for (
auto lease = l.first; lease != l.second; ++lease) {
1583 if (MultiThreadingMgr::instance().getMode()) {
1584 std::lock_guard<std::mutex> lock(*mutex_);
1585 getLeases6Internal(hostname, collection);
1587 getLeases6Internal(hostname, collection);
1590 return (collection);
1595 for (
auto lease = storage6_.begin(); lease != storage6_.end(); ++lease) {
1605 if (MultiThreadingMgr::instance().getMode()) {
1606 std::lock_guard<std::mutex> lock(*mutex_);
1607 getLeases6Internal(collection);
1609 getLeases6Internal(collection);
1612 return (collection);
1616 Memfile_LeaseMgr::getLeases6Internal(
const DUID& duid,
1619 std::pair<Lease6StorageDuidIndex::const_iterator,
1620 Lease6StorageDuidIndex::const_iterator> l =
1621 idx.equal_range(duid.
getDuid());
1623 for (
auto lease = l.first; lease != l.second; ++lease) {
1634 if (MultiThreadingMgr::instance().getMode()) {
1635 std::lock_guard<std::mutex> lock(*mutex_);
1636 getLeases6Internal(duid, collection);
1638 getLeases6Internal(duid, collection);
1641 return (collection);
1649 Lease6StorageAddressIndex::const_iterator lb = idx.lower_bound(lower_bound_address);
1652 if ((lb != idx.end()) && ((*lb)->addr_ == lower_bound_address)) {
1657 for (
auto lease = lb;
1658 (lease != idx.end()) && (std::distance(lb, lease) < page_size.
page_size_);
1660 collection.push_back(
Lease6Ptr(
new Lease6(**lease)));
1668 if (!lower_bound_address.
isV6()) {
1670 "retrieving leases from the lease database, got "
1671 << lower_bound_address);
1676 .arg(lower_bound_address.
toText());
1679 if (MultiThreadingMgr::instance().getMode()) {
1680 std::lock_guard<std::mutex> lock(*mutex_);
1681 getLeases6Internal(lower_bound_address, page_size, collection);
1683 getLeases6Internal(lower_bound_address, page_size, collection);
1686 return (collection);
1690 Memfile_LeaseMgr::getExpiredLeases4Internal(
Lease4Collection& expired_leases,
1691 const size_t max_leases)
const {
1699 Lease4StorageExpirationIndex::const_iterator ub =
1700 index.upper_bound(boost::make_tuple(
false, time(0)));
1703 for (Lease4StorageExpirationIndex::const_iterator lease = index.begin();
1704 (lease != ub) && ((max_leases == 0) || (std::distance(index.begin(), lease) <
1713 const size_t max_leases)
const {
1717 if (MultiThreadingMgr::instance().getMode()) {
1718 std::lock_guard<std::mutex> lock(*mutex_);
1719 getExpiredLeases4Internal(expired_leases, max_leases);
1721 getExpiredLeases4Internal(expired_leases, max_leases);
1726 Memfile_LeaseMgr::getExpiredLeases6Internal(
Lease6Collection& expired_leases,
1727 const size_t max_leases)
const {
1735 Lease6StorageExpirationIndex::const_iterator ub =
1736 index.upper_bound(boost::make_tuple(
false, time(0)));
1739 for (Lease6StorageExpirationIndex::const_iterator lease = index.begin();
1740 (lease != ub) && ((max_leases == 0) || (std::distance(index.begin(), lease) <
1749 const size_t max_leases)
const {
1753 if (MultiThreadingMgr::instance().getMode()) {
1754 std::lock_guard<std::mutex> lock(*mutex_);
1755 getExpiredLeases6Internal(expired_leases, max_leases);
1757 getExpiredLeases6Internal(expired_leases, max_leases);
1762 Memfile_LeaseMgr::updateLease4Internal(
const Lease4Ptr& lease) {
1769 Lease4StorageAddressIndex::const_iterator lease_it = index.find(lease->addr_);
1770 if (lease_it == index.end()) {
1772 << lease->addr_ <<
" - no such lease");
1773 }
else if ((!persist) && (((*lease_it)->cltt_ != lease->current_cltt_) ||
1774 ((*lease_it)->valid_lft_ != lease->current_valid_lft_))) {
1777 isc_throw(NoSuchLease,
"failed to update the lease with address "
1778 << lease->addr_ <<
" - lease has changed in database");
1789 lease->updateCurrentExpirationTime();
1796 index.replace(lease_it,
Lease4Ptr(
new Lease4(*lease)));
1799 class_lease_counter_.
updateLease(lease, old_lease);
1812 if (MultiThreadingMgr::instance().getMode()) {
1813 std::lock_guard<std::mutex> lock(*mutex_);
1814 updateLease4Internal(lease);
1816 updateLease4Internal(lease);
1821 Memfile_LeaseMgr::updateLease6Internal(
const Lease6Ptr& lease) {
1832 Lease6StorageAddressIndex::const_iterator lease_it = index.find(lease->addr_);
1833 if (lease_it == index.end()) {
1835 << lease->addr_ <<
" - no such lease");
1836 }
else if ((!persist) && (((*lease_it)->cltt_ != lease->current_cltt_) ||
1837 ((*lease_it)->valid_lft_ != lease->current_valid_lft_))) {
1840 isc_throw(NoSuchLease,
"failed to update the lease with address "
1841 << lease->addr_ <<
" - lease has changed in database");
1852 lease->updateCurrentExpirationTime();
1859 index.replace(lease_it,
Lease6Ptr(
new Lease6(*lease)));
1862 class_lease_counter_.
updateLease(lease, old_lease);
1866 switch (recorded_action) {
1892 if (MultiThreadingMgr::instance().getMode()) {
1893 std::lock_guard<std::mutex> lock(*mutex_);
1894 updateLease6Internal(lease);
1896 updateLease6Internal(lease);
1901 Memfile_LeaseMgr::deleteLeaseInternal(
const Lease4Ptr& lease) {
1903 Lease4Storage::iterator l = storage4_.find(addr);
1904 if (l == storage4_.end()) {
1911 Lease4 lease_copy = **l;
1914 lease_copy.valid_lft_ = 0;
1919 if (((*l)->cltt_ != lease->current_cltt_) ||
1920 ((*l)->valid_lft_ != lease->current_valid_lft_)) {
1944 if (MultiThreadingMgr::instance().getMode()) {
1945 std::lock_guard<std::mutex> lock(*mutex_);
1946 return (deleteLeaseInternal(lease));
1948 return (deleteLeaseInternal(lease));
1953 Memfile_LeaseMgr::deleteLeaseInternal(
const Lease6Ptr& lease) {
1957 Lease6Storage::iterator l = storage6_.find(addr);
1958 if (l == storage6_.end()) {
1965 Lease6 lease_copy = **l;
1967 lease_copy.valid_lft_ = 0;
1968 lease_copy.preferred_lft_ = 0;
1973 if (((*l)->cltt_ != lease->current_cltt_) ||
1974 ((*l)->valid_lft_ != lease->current_valid_lft_)) {
2003 if (MultiThreadingMgr::instance().getMode()) {
2004 std::lock_guard<std::mutex> lock(*mutex_);
2005 return (deleteLeaseInternal(lease));
2007 return (deleteLeaseInternal(lease));
2017 if (MultiThreadingMgr::instance().getMode()) {
2018 std::lock_guard<std::mutex> lock(*mutex_);
2019 return (deleteExpiredReclaimedLeases<
2023 return (deleteExpiredReclaimedLeases<
2035 if (MultiThreadingMgr::instance().getMode()) {
2036 std::lock_guard<std::mutex> lock(*mutex_);
2037 return (deleteExpiredReclaimedLeases<
2041 return (deleteExpiredReclaimedLeases<
2047 template<
typename IndexType,
typename LeaseType,
typename StorageType,
2048 typename LeaseFileType>
2050 Memfile_LeaseMgr::deleteExpiredReclaimedLeases(
const uint32_t secs,
2051 const Universe& universe,
2052 StorageType& storage,
2053 LeaseFileType& lease_file) {
2055 IndexType& index = storage.template get<ExpirationIndexTag>();
2066 typename IndexType::const_iterator upper_limit =
2067 index.upper_bound(boost::make_tuple(
true, time(0) - secs));
2076 typename IndexType::const_iterator lower_limit =
2077 index.upper_bound(boost::make_tuple(
true, std::numeric_limits<int64_t>::min()));
2080 uint64_t num_leases =
static_cast<uint64_t
>(std::distance(lower_limit, upper_limit));
2081 if (num_leases > 0) {
2091 for (
typename IndexType::const_iterator lease = lower_limit;
2092 lease != upper_limit; ++lease) {
2094 LeaseType lease_copy(**lease);
2097 lease_copy.valid_lft_ = 0;
2098 lease_file->append(lease_copy);
2103 index.erase(lower_limit, upper_limit);
2107 return (num_leases);
2112 return (std::string(
"In memory database with leases stored in a CSV file."));
2115 std::pair<uint32_t, uint32_t>
2117 std::string
const& universe(conn_.
getParameter(
"universe"));
2118 if (universe ==
"4") {
2120 }
else if (universe ==
"6") {
2140 std::string name(file_name);
2141 switch (file_type) {
2152 name +=
".completed";
2167 std::ostringstream s;
2169 s << (u ==
V4 ?
"4" :
"6");
2196 Memfile_LeaseMgr::initLeaseFilePath(Universe u) {
2197 std::string persist_val;
2203 persist_val =
"true";
2207 if (persist_val ==
"false") {
2210 }
else if (persist_val !=
"true") {
2212 << persist_val <<
"'");
2215 std::string lease_file;
2218 }
catch (
const Exception&) {
2221 return (lease_file);
2224 template<
typename LeaseObjectType,
typename LeaseFileType,
typename StorageType>
2226 Memfile_LeaseMgr::loadLeasesFromFiles(
const std::string& filename,
2227 boost::shared_ptr<LeaseFileType>& lease_file,
2228 StorageType& storage) {
2236 if (pid_file.check()) {
2238 "lease file cleanup is in progress");
2243 std::string max_row_errors_str =
"0";
2245 max_row_errors_str = conn_.
getParameter(
"max-row-errors");
2246 }
catch (
const std::exception&) {
2250 int64_t max_row_errors64;
2252 max_row_errors64 = boost::lexical_cast<int64_t>(max_row_errors_str);
2253 }
catch (
const boost::bad_lexical_cast&) {
2255 << max_row_errors_str <<
" specified");
2257 if ((max_row_errors64 < 0) ||
2258 (max_row_errors64 > std::numeric_limits<uint32_t>::max())) {
2260 << max_row_errors_str <<
" specified");
2262 uint32_t max_row_errors =
static_cast<uint32_t
>(max_row_errors64);
2265 bool conversion_needed =
false;
2266 lease_file.reset(
new LeaseFileType(std::string(filename +
".completed")));
2267 if (lease_file->exists()) {
2268 LeaseFileLoader::load<LeaseObjectType>(*lease_file, storage,
2270 conversion_needed = conversion_needed || lease_file->needsConversion();
2275 if (lease_file->exists()) {
2276 LeaseFileLoader::load<LeaseObjectType>(*lease_file, storage,
2278 conversion_needed = conversion_needed || lease_file->needsConversion();
2282 if (lease_file->exists()) {
2283 LeaseFileLoader::load<LeaseObjectType>(*lease_file, storage,
2285 conversion_needed = conversion_needed || lease_file->needsConversion();
2295 lease_file.reset(
new LeaseFileType(filename));
2296 LeaseFileLoader::load<LeaseObjectType>(*lease_file, storage,
2297 max_row_errors,
false);
2298 conversion_needed = conversion_needed || lease_file->needsConversion();
2300 return (conversion_needed);
2306 return (lfc_setup_->isRunning());
2311 return (lfc_setup_->getExitStatus());
2329 Memfile_LeaseMgr::lfcSetup(
bool conversion_needed) {
2330 std::string lfc_interval_str =
"3600";
2333 }
catch (
const std::exception&) {
2337 uint32_t lfc_interval = 0;
2339 lfc_interval = boost::lexical_cast<uint32_t>(lfc_interval_str);
2340 }
catch (
const boost::bad_lexical_cast&) {
2342 << lfc_interval_str <<
" specified");
2345 if (lfc_interval > 0 || conversion_needed) {
2351 template<
typename LeaseFileType>
2353 Memfile_LeaseMgr::lfcExecute(boost::shared_ptr<LeaseFileType>& lease_file) {
2363 if (!lease_file_finish.exists() && !lease_file_copy.exists()) {
2365 lease_file->close();
2368 do_lfc = (rename(lease_file->getFilename().c_str(),
2369 lease_file_copy.getFilename().c_str()) == 0);
2373 .arg(lease_file->getFilename())
2374 .arg(lease_file_copy.getFilename())
2375 .arg(strerror(errno));
2384 lease_file->open(
true);
2397 .arg(lease_file->getFilename())
2408 lfc_setup_->execute();
2415 if (MultiThreadingMgr::instance().getMode()) {
2416 std::lock_guard<std::mutex> lock(*mutex_);
2428 if (MultiThreadingMgr::instance().getMode()) {
2429 std::lock_guard<std::mutex> lock(*mutex_);
2441 if (MultiThreadingMgr::instance().getMode()) {
2442 std::lock_guard<std::mutex> lock(*mutex_);
2456 if (MultiThreadingMgr::instance().getMode()) {
2457 std::lock_guard<std::mutex> lock(*mutex_);
2469 if (MultiThreadingMgr::instance().getMode()) {
2470 std::lock_guard<std::mutex> lock(*mutex_);
2482 if (MultiThreadingMgr::instance().getMode()) {
2483 std::lock_guard<std::mutex> lock(*mutex_);
2495 if (MultiThreadingMgr::instance().getMode()) {
2496 std::lock_guard<std::mutex> lock(*mutex_);
2510 if (MultiThreadingMgr::instance().getMode()) {
2511 std::lock_guard<std::mutex> lock(*mutex_);
2529 std::pair<Lease4StorageSubnetIdIndex::const_iterator,
2530 Lease4StorageSubnetIdIndex::const_iterator> l =
2531 idx.equal_range(subnet_id);
2535 for (
auto lease = l.first; lease != l.second; ++lease) {
2536 leases.push_back(*lease);
2539 size_t num = leases.size();
2540 for (
auto l = leases.begin(); l != leases.end(); ++l) {
2544 .arg(subnet_id).arg(num);
2558 std::pair<Lease6StorageSubnetIdIndex::const_iterator,
2559 Lease6StorageSubnetIdIndex::const_iterator> l =
2560 idx.equal_range(subnet_id);
2564 for (
auto lease = l.first; lease != l.second; ++lease) {
2565 leases.push_back(*lease);
2568 size_t num = leases.size();
2569 for (
auto l = leases.begin(); l != leases.end(); ++l) {
2573 .arg(subnet_id).arg(num);
2580 class_lease_counter_.
clear();
2581 for (
auto lease = storage4_.begin(); lease != storage4_.end(); ++lease) {
2584 class_lease_counter_.
addLease(*lease);
2591 class_lease_counter_.
clear();
2592 for (
auto lease = storage6_.begin(); lease != storage6_.end(); ++lease) {
2595 class_lease_counter_.
addLease(*lease);
2603 if (MultiThreadingMgr::instance().getMode()) {
2604 std::lock_guard<std::mutex> lock(*mutex_);
2605 return(class_lease_counter_.
getClassCount(client_class, ltype));
2607 return(class_lease_counter_.
getClassCount(client_class, ltype));
2613 return(class_lease_counter_.
clear());
2618 if (!user_context) {
2631 for (
int i = 0; i < classes->size(); ++i) {
2640 std::string name = name_elem->stringValue();
2651 size_t lease_count = 0;
2657 if (lease_count >= limit) {
2658 std::ostringstream ss;
2659 ss <<
"address limit " << limit <<
" for client class \""
2660 << name <<
"\", current lease count " << lease_count;
2676 SubnetID subnet_id = id_elem->intValue();
2683 int64_t lease_count = 0;
2685 lease_count = getSubnetStat(subnet_id,
"assigned-addresses");
2689 if (lease_count >= limit) {
2690 std::ostringstream ss;
2691 ss <<
"address limit " << limit <<
" for subnet ID " << subnet_id
2692 <<
", current lease count " << lease_count;
2704 if (!user_context) {
2718 for (
int i = 0; i < classes->size(); ++i) {
2727 std::string name = name_elem->stringValue();
2732 if (!getLeaseLimit(class_elem, ltype, limit)) {
2734 if (!getLeaseLimit(class_elem, ltype, limit)) {
2742 size_t lease_count = 0;
2748 if (lease_count >= limit) {
2749 std::ostringstream ss;
2751 <<
" limit " << limit <<
" for client class \""
2752 << name <<
"\", current lease count " << lease_count;
2768 SubnetID subnet_id = id_elem->intValue();
2773 if (!getLeaseLimit(subnet_elem, ltype, limit)) {
2775 if (!getLeaseLimit(subnet_elem, ltype, limit)) {
2783 int64_t lease_count = 0;
2785 lease_count = getSubnetStat(subnet_id, (ltype ==
Lease::TYPE_NA ?
2786 "assigned-nas" :
"assigned-pds"));
2790 if (lease_count >= limit) {
2791 std::ostringstream ss;
2793 <<
" limit " << limit <<
" for subnet ID " << subnet_id
2794 <<
", current lease count " << lease_count;
2809 Memfile_LeaseMgr::getSubnetStat(
const SubnetID& subnet_id,
const std::string& stat_label)
const {
2812 std::string stat_name = StatsMgr::generateName(
"subnet", subnet_id, stat_label);
2815 if (samples && samples->size()) {
2816 auto sample = samples->get(0);
2817 if (sample->size()) {
2818 auto count_elem = sample->get(0);
2819 return (count_elem->intValue());
2829 "prefix-limit" :
"address-limit");
2831 limit = limit_elem->intValue();
2842 std::stringstream tmp;
2845 for (std::vector<uint8_t>::const_iterator it =
id.begin();
2846 it !=
id.end(); ++it) {
2850 tmp << std::setw(2) << std::setfill(
'0')
2851 <<
static_cast<unsigned int>(*it);
2863 const time_t& qry_start_time ,
2864 const time_t& qry_end_time ) {
2868 .arg(lower_bound_address.
toText())
2869 .arg(idToText(relay_id))
2870 .arg(qry_start_time)
2874 if (!lower_bound_address.
isV4()) {
2876 "retrieving leases from the lease database, got "
2877 << lower_bound_address);
2881 if ((qry_start_time < 0) || (qry_end_time < 0)) {
2886 if ((qry_start_time > 0) && (qry_end_time > 0) &&
2887 (qry_start_time > qry_end_time)) {
2891 if (MultiThreadingMgr::instance().getMode()) {
2892 std::lock_guard<std::mutex> lock(*mutex_);
2893 return (getLeases4ByRelayIdInternal(relay_id,
2894 lower_bound_address,
2899 return (getLeases4ByRelayIdInternal(relay_id,
2900 lower_bound_address,
2908 Memfile_LeaseMgr::getLeases4ByRelayIdInternal(
const OptionBuffer& relay_id,
2911 const time_t& qry_start_time,
2912 const time_t& qry_end_time) {
2915 Lease4StorageRelayIdIndex::const_iterator lb =
2916 idx.lower_bound(boost::make_tuple(relay_id, lower_bound_address));
2918 IOAddress last_addr = lower_bound_address;
2919 for (; lb != idx.end(); ++lb) {
2920 if ((*lb)->addr_ == last_addr) {
2924 if ((*lb)->relay_id_ != relay_id) {
2928 last_addr = (*lb)->addr_;
2929 if ((qry_start_time > 0) && ((*lb)->cltt_ < qry_start_time)) {
2933 if ((qry_end_time > 0) && ((*lb)->cltt_ > qry_end_time)) {
2937 collection.push_back(
Lease4Ptr(
new Lease4(**lb)));
2938 if (collection.size() >= page_size.
page_size_) {
2942 return (collection);
2949 const time_t& qry_start_time ,
2950 const time_t& qry_end_time ) {
2954 .arg(lower_bound_address.
toText())
2955 .arg(idToText(remote_id))
2956 .arg(qry_start_time)
2960 if (!lower_bound_address.
isV4()) {
2962 "retrieving leases from the lease database, got "
2963 << lower_bound_address);
2967 if ((qry_start_time < 0) || (qry_end_time < 0)) {
2972 if ((qry_start_time > 0) && (qry_end_time > 0) &&
2973 (qry_start_time > qry_end_time)) {
2977 if (MultiThreadingMgr::instance().getMode()) {
2978 std::lock_guard<std::mutex> lock(*mutex_);
2979 return (getLeases4ByRemoteIdInternal(remote_id,
2980 lower_bound_address,
2985 return (getLeases4ByRemoteIdInternal(remote_id,
2986 lower_bound_address,
2994 Memfile_LeaseMgr::getLeases4ByRemoteIdInternal(
const OptionBuffer& remote_id,
2997 const time_t& qry_start_time,
2998 const time_t& qry_end_time) {
3000 std::map<IOAddress, Lease4Ptr> sorted;
3004 for (
auto it = er.first; it != er.second; ++it) {
3006 if (addr <= lower_bound_address) {
3010 if ((qry_start_time > 0) && ((*it)->cltt_ < qry_start_time)) {
3014 if ((qry_end_time > 0) && ((*it)->cltt_ > qry_end_time)) {
3022 for (
auto it : sorted) {
3023 collection.push_back(
Lease4Ptr(
new Lease4(*it.second)));
3024 if (collection.size() >= page_size.
page_size_) {
3028 return (collection);
3033 if (MultiThreadingMgr::instance().getMode()) {
3034 std::lock_guard<std::mutex> lock(*mutex_);
3062 .arg(lower_bound_address.
toText())
3065 .arg(
static_cast<unsigned>(link_len));
3068 if (!link_addr.
isV6()) {
3070 "retrieving leases from the lease database, got "
3073 if (link_len > 128) {
3075 <<
static_cast<unsigned>(link_len));
3077 if (!lower_bound_address.
isV6()) {
3079 "retrieving leases from the lease database, got "
3080 << lower_bound_address);
3083 if (MultiThreadingMgr::instance().getMode()) {
3084 std::lock_guard<std::mutex> lock(*mutex_);
3085 return (getLeases6ByRelayIdInternal(relay_id,
3088 lower_bound_address,
3091 return (getLeases6ByRelayIdInternal(relay_id,
3094 lower_bound_address,
3100 Memfile_LeaseMgr::getLeases6ByRelayIdInternal(
const DUID& relay_id,
3105 const std::vector<uint8_t>& relay_id_data = relay_id.
getDuid();
3109 RelayIdIndex::const_iterator lb =
3110 idx.lower_bound(boost::make_tuple(relay_id_data,
3111 lower_bound_address));
3114 IOAddress last_addr = lower_bound_address;
3115 for (; lb != idx.end(); ++lb) {
3116 if ((*lb)->lease_addr_ == last_addr) {
3120 if ((*lb)->id_ != relay_id_data) {
3124 last_addr = (*lb)->lease_addr_;
3125 Lease6Ptr lease = getAnyLease6Internal(last_addr);
3127 collection.push_back(lease);
3128 if (collection.size() >= page_size.
page_size_) {
3137 (lower_bound_address < first_addr ? first_addr : lower_bound_address);
3138 RelayIdIndex::const_iterator lb =
3139 idx.lower_bound(boost::make_tuple(relay_id_data, start_addr));
3140 RelayIdIndex::const_iterator ub =
3141 idx.upper_bound(boost::make_tuple(relay_id_data, last_addr));
3144 IOAddress last_seen_addr = lower_bound_address;
3145 for (
auto it = lb; it != ub; ++it) {
3146 if ((*it)->lease_addr_ == last_seen_addr) {
3150 last_seen_addr = (*it)->lease_addr_;
3151 Lease6Ptr lease = getAnyLease6Internal(last_seen_addr);
3153 collection.push_back(lease);
3154 if (collection.size() >= page_size.
page_size_) {
3160 return (collection);
3172 .arg(lower_bound_address.
toText())
3173 .arg(idToText(remote_id))
3175 .arg(
static_cast<unsigned>(link_len));
3178 if (!link_addr.
isV6()) {
3180 "retrieving leases from the lease database, got "
3183 if (link_len > 128) {
3185 <<
static_cast<unsigned>(link_len));
3187 if (!lower_bound_address.
isV6()) {
3189 "retrieving leases from the lease database, got "
3190 << lower_bound_address);
3193 if (MultiThreadingMgr::instance().getMode()) {
3194 std::lock_guard<std::mutex> lock(*mutex_);
3195 return (getLeases6ByRemoteIdInternal(remote_id,
3198 lower_bound_address,
3201 return (getLeases6ByRemoteIdInternal(remote_id,
3204 lower_bound_address,
3210 Memfile_LeaseMgr::getLeases6ByRemoteIdInternal(
const OptionBuffer& remote_id,
3216 std::set<IOAddress> sorted;
3221 for (
auto it = er.first; it != er.second; ++it) {
3222 const IOAddress& addr = (*it)->lease_addr_;
3223 if (addr <= lower_bound_address) {
3226 static_cast<void>(sorted.insert(addr));
3231 Lease6Ptr lease = getAnyLease6Internal(addr);
3233 collection.push_back(lease);
3234 if (collection.size() >= page_size.
page_size_) {
3244 for (
auto it = er.first; it != er.second; ++it) {
3245 const IOAddress& addr = (*it)->lease_addr_;
3246 if (addr <= lower_bound_address) {
3249 if ((addr < first_addr) || (last_addr < addr)) {
3252 static_cast<void>(sorted.insert(addr));
3257 Lease6Ptr lease = getAnyLease6Internal(addr);
3259 collection.push_back(lease);
3260 if (collection.size() >= page_size.
page_size_) {
3266 return (collection);
3277 .arg(lower_bound_address.
toText())
3279 .arg(
static_cast<unsigned>(link_len));
3282 if (!link_addr.
isV6()) {
3284 "retrieving leases from the lease database, got "
3287 if ((link_len == 0) || (link_len > 128)) {
3289 <<
static_cast<unsigned>(link_len));
3291 if (!lower_bound_address.
isV6()) {
3293 "retrieving leases from the lease database, got "
3294 << lower_bound_address);
3297 if (MultiThreadingMgr::instance().getMode()) {
3298 std::lock_guard<std::mutex> lock(*mutex_);
3299 return (getLeases6ByLinkInternal(link_addr,
3301 lower_bound_address,
3304 return (getLeases6ByLinkInternal(link_addr,
3306 lower_bound_address,
3312 Memfile_LeaseMgr::getLeases6ByLinkInternal(
const IOAddress& link_addr,
3319 (lower_bound_address < first_addr ? first_addr : lower_bound_address);
3322 Lease6StorageAddressIndex::const_iterator lb = idx.lower_bound(start_addr);
3323 Lease6StorageAddressIndex::const_iterator eb = idx.upper_bound(last_addr);
3326 IOAddress last_seen_addr = lower_bound_address;
3327 for (
auto it = lb; it != eb; ++it) {
3328 if ((*it)->addr_ == last_seen_addr) {
3332 last_seen_addr = (*it)->addr_;
3333 Lease6Ptr lease = getAnyLease6Internal(last_seen_addr);
3335 collection.push_back(lease);
3336 if (collection.size() >= page_size.
page_size_) {
3341 return (collection);
3354 <<
" consistency configuration is null");
3356 auto check = cfg->getExtendedInfoSanityCheck();
3361 .arg(update ?
" updating in file" :
"");
3364 size_t modified = 0;
3366 size_t processed = 0;
3368 auto lease_it = index.begin();
3369 auto next_it = index.end();
3371 for (; lease_it != index.end(); lease_it = next_it) {
3372 next_it = std::next(lease_it);
3387 if (!
copy->relay_id_.empty() || !
copy->remote_id_.empty()) {
3388 index.replace(lease_it,
copy);
3391 }
catch (
const std::exception& ex) {
3394 .arg(lease->addr_.toText())
3419 auto check = cfg->getExtendedInfoSanityCheck();
3425 .arg(enabled ?
"enabled" :
"disabled");
3434 size_t modified = 0;
3435 size_t processed = 0;
3437 for (
auto lease : storage6_) {
3446 }
catch (
const std::exception& ex) {
3449 .arg(lease->addr_.toText())
3469 static_cast<void>(relay_id_idx.erase(addr));
3472 static_cast<void>(remote_id_idx.erase(addr));
3477 const std::vector<uint8_t>& relay_id) {
3485 const std::vector<uint8_t>& remote_id) {
3493 if (MultiThreadingMgr::instance().getMode()) {
3494 std::lock_guard<std::mutex> lock(*mutex_);
3495 writeLeases4Internal(filename);
3497 writeLeases4Internal(filename);
3502 Memfile_LeaseMgr::writeLeases4Internal(
const std::string& filename) {
3508 std::ostringstream old;
3509 old << filename <<
".bak" << getpid();
3510 ::rename(filename.c_str(), old.str().c_str());
3511 CSVLeaseFile4 backup(filename);
3513 for (
const auto& lease : storage4_) {
3514 backup.append(*lease);
3520 }
catch (
const std::exception&) {
3530 if (MultiThreadingMgr::instance().getMode()) {
3531 std::lock_guard<std::mutex> lock(*mutex_);
3532 writeLeases6Internal(filename);
3534 writeLeases6Internal(filename);
3539 Memfile_LeaseMgr::writeLeases6Internal(
const std::string& filename) {
3545 std::ostringstream old;
3546 old << filename <<
".bak" << getpid();
3547 ::rename(filename.c_str(), old.str().c_str());
3548 CSVLeaseFile6 backup(filename);
3550 for (
const auto& lease : storage6_) {
3551 backup.append(*lease);
3557 }
catch (
const std::exception&) {
int version()
returns Kea hooks version.
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 if a parameter given to a method would refer to or modify out-of-r...
A generic exception that is thrown when an unexpected error condition occurs.
The IOAddress class represents an IP addresses (version agnostic)
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.
std::string getParameter(const std::string &name) const
Returns value of a connection parameter.
std::map< std::string, std::string > ParameterMap
Database configuration parameter map.
Exception thrown on failure to open database.
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.
util::Optional< std::string > getDataDir() const
returns path do the data directory
static CfgMgr & instance()
returns a single instance of Configuration Manager
SrvConfigPtr getStagingCfg()
Returns a pointer to the staging configuration.
SrvConfigPtr getCurrentCfg()
Returns a pointer to the current configuration.
void addLease(LeasePtr lease)
Increment the counts for all of a lease's classes by one.
void clear()
Remove all entries.
void removeLease(LeasePtr lease)
Decrement the counts for all of a lease's classes by one.
void updateLease(LeasePtr new_lease, LeasePtr old_lease)
Adjust class lease counts given a new and old version of a lease.
size_t getClassCount(const ClientClass &client_class, const Lease::Type <ype=Lease::TYPE_V4) const
Fetches the lease count for the given class and lease type.
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.
Represents a configuration for Lease File Cleanup.
void execute()
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.
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.
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 isc::asiolink::IOServicePtr & getIOService()
Returns pointer to the IO service.
static std::string getDBVersion()
Class method to return extended version info This class method must be redeclared and redefined in de...
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.
Base class for fulfilling a statistical lease data query.
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.
Base Memfile derivation of the statistical lease data 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.
virtual Lease6Collection getLeases6ByRemoteId(const OptionBuffer &remote_id, const asiolink::IOAddress &link_addr, uint8_t link_len, const asiolink::IOAddress &lower_bound_address, const LeasePageSize &page_size) override
Returns existing IPv6 leases with a given remote-id.
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 Lease6Collection getLeases6ByLink(const asiolink::IOAddress &link_addr, uint8_t link_len, const asiolink::IOAddress &lower_bound_address, const LeasePageSize &page_size) override
Returns existing IPv6 leases with on a given link.
virtual void clearClassLeaseCounts() override
Clears the class-lease count map.
virtual size_t byRelayId6size() const override
Return the by-relay-id table size.
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.
virtual bool isJsonSupported() const override
Checks if JSON support is enabled in the database.
Universe
Specifies universe (V4, V6)
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.
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.
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 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).
virtual std::pair< uint32_t, uint32_t > getVersion() const override
Returns backend version.
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 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.
virtual LeaseStatsQueryPtr startSubnetLeaseStatsQuery6(const SubnetID &subnet_id) override
Creates and runs the IPv6 lease stats query for a single subnet.
virtual Lease6Collection getLeases6ByRelayId(const DUID &relay_id, const asiolink::IOAddress &link_addr, uint8_t link_len, const asiolink::IOAddress &lower_bound_address, const LeasePageSize &page_size) override
Returns existing IPv6 leases with a given relay-id.
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.
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.
std::string getDefaultLeaseFilePath(Universe u) const
Returns default path to the lease file.
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.
Attempt to update lease that was not there.
Manages a pool of asynchronous interval timers.
Introduces callbacks into the LeaseMgr.
void trackUpdateLease(const LeasePtr &lease, bool mt_safe)
Invokes the callbacks when a lease is updated.
void trackAddLease(const LeasePtr &lease, bool mt_safe)
Invokes the callbacks when a new lease is added.
void trackDeleteLease(const LeasePtr &lease, bool mt_safe)
Invokes the callbacks when a lease is deleted.
bool hasCallbacks() const
Checks if any callbacks have been registered.
Exception thrown when an error occurs during CSV file processing.
Provides input/output access to CSV files.
RAII class creating a critical section.
Class to help with processing PID files.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
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
#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.
IOAddress firstAddrInPrefix(const IOAddress &prefix, uint8_t len)
This code is based on similar code from the Dibbler project.
IOAddress lastAddrInPrefix(const IOAddress &prefix, uint8_t len)
returns a last address in a given prefix
ElementPtr copy(ConstElementPtr from, int level)
Copy the data up to a nesting level.
void prettyPrint(ConstElementPtr element, std::ostream &out, unsigned indent, unsigned step)
Pretty prints the data into stream.
boost::shared_ptr< const Element > ConstElementPtr
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.
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_ > > > >> Lease4Storage
A multi index container holding DHCPv4 leases.
const isc::log::MessageID DHCPSRV_MEMFILE_GET_SUBID_HWADDR
const isc::log::MessageID DHCPSRV_MEMFILE_WIPE_LEASES6
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_LFC_UNREGISTER_TIMER_FAILED
const isc::log::MessageID DHCPSRV_MEMFILE_LFC_SPAWN_FAIL
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_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< 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_ > > > >> Lease6Storage
A multi index container holding DHCPv6 leases.
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
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.
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_DELETE_ADDR
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 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_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.
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
const isc::log::MessageID DHCPSRV_MEMFILE_GET_LINKADDR6
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.
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
const isc::log::MessageID DHCPSRV_MEMFILE_GET_PAGE4
const isc::log::MessageID DHCPSRV_MEMFILE_GET_HWADDR
const isc::log::MessageID DHCPSRV_MEMFILE_GET6_DUID
Lease4Storage::index< SubnetIdIndexTag >::type Lease4StorageSubnetIdIndex
DHCPv4 lease storage index subnet-id.
std::vector< uint8_t > OptionBuffer
buffer types used in DHCP code.
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.
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.
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
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 const uint32_t STATE_DEFAULT
A lease in the default state.
static const uint32_t STATE_DECLINED
Declined lease.
Type
Type of lease or pool.
@ TYPE_PD
the lease contains IPv6 prefix (for prefix delegation)
@ TYPE_NA
the lease contains non-temporary IPv6 address
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.