29const uint32_t MAX_LEASE_ERRORS = 100;
38const char* KEA_LFC_EXECUTABLE_ENV_NAME =
"KEA_LFC_EXECUTABLE";
91 void setup(
const uint32_t lfc_interval,
92 const boost::shared_ptr<CSVLeaseFile4>& lease_file4,
93 const boost::shared_ptr<CSVLeaseFile6>& lease_file6,
94 bool run_once_now =
false);
111 boost::scoped_ptr<util::ProcessSpawn> process_;
127 : process_(), callback_(callback), pid_(0),
143 timer_mgr_->unregisterTimer(
"memfile-lfc");
145 }
catch (
const std::exception& ex) {
150 DHCPSRV_MEMFILE_LFC_UNREGISTER_TIMER_FAILED).arg(ex.what());
156 const boost::shared_ptr<CSVLeaseFile4>& lease_file4,
157 const boost::shared_ptr<CSVLeaseFile6>& lease_file6,
161 if (lfc_interval == 0 && !run_once_now) {
166 std::string executable;
167 char* c_executable = getenv(KEA_LFC_EXECUTABLE_ENV_NAME);
168 if (c_executable == NULL) {
169 executable = KEA_LFC_EXECUTABLE;
171 executable = c_executable;
175 std::string lease_file = lease_file4 ? lease_file4->getFilename() :
176 lease_file6->getFilename();
181 args.push_back(lease_file4 ?
"-4" :
"-6");
184 args.push_back(
"-x");
188 args.push_back(
"-i");
192 args.push_back(
"-o");
196 args.push_back(
"-f");
200 args.push_back(
"-p");
205 args.push_back(
"-c");
206 args.push_back(
"ignored-path");
217 if (lfc_interval > 0) {
224 timer_mgr_->registerTimer(
"memfile-lfc", callback_, lfc_interval * 1000,
226 timer_mgr_->setup(
"memfile-lfc");
234 .arg(process_->getCommandLine());
235 pid_ = process_->spawn();
244 return (process_ && process_->isRunning(pid_));
251 " the process is NULL");
253 return (process_->getExitStatus(pid_));
310 return (
rows_.size());
379 Lease4StorageSubnetIdIndex::const_iterator lower;
380 Lease4StorageSubnetIdIndex::const_iterator upper;
399 if (lower == upper) {
407 int64_t assigned = 0;
408 int64_t declined = 0;
409 for(Lease4StorageSubnetIdIndex::const_iterator lease = lower;
410 lease != upper; ++lease) {
413 if ((*lease)->subnet_id_ != cur_id) {
431 cur_id = (*lease)->subnet_id_;
521 Lease6StorageSubnetIdIndex::const_iterator lower;
522 Lease6StorageSubnetIdIndex::const_iterator upper;
541 if (lower == upper) {
549 int64_t assigned = 0;
550 int64_t declined = 0;
551 int64_t assigned_pds = 0;
552 for(Lease6StorageSubnetIdIndex::const_iterator lease = lower;
553 lease != upper; ++lease) {
556 if ((*lease)->subnet_id_ != cur_id) {
572 if (assigned_pds > 0) {
581 cur_id = (*lease)->subnet_id_;
586 switch((*lease)->type_) {
615 if (assigned_pds > 0) {
635 :
LeaseMgr(), lfc_setup_(), conn_(parameters)
637 bool conversion_needed =
false;
641 if (universe ==
"4") {
642 std::string file4 = initLeaseFilePath(
V4);
643 if (!file4.empty()) {
644 conversion_needed = loadLeasesFromFiles<
Lease4,
650 std::string file6 = initLeaseFilePath(
V6);
651 if (!file6.empty()) {
652 conversion_needed = loadLeasesFromFiles<
Lease6,
666 if (conversion_needed) {
670 lfcSetup(conversion_needed);
677 lease_file4_->close();
678 lease_file4_.reset();
681 lease_file6_->close();
682 lease_file6_.reset();
688 std::stringstream tmp;
697 DHCPSRV_MEMFILE_ADD_ADDR4).arg(lease->addr_.toText());
708 lease_file4_->append(*lease);
711 storage4_.insert(lease);
718 DHCPSRV_MEMFILE_ADD_ADDR6).arg(lease->addr_.toText());
720 if (
getLease6(lease->type_, lease->addr_)) {
729 lease_file6_->append(*lease);
732 storage6_.insert(lease);
739 DHCPSRV_MEMFILE_GET_ADDR4).arg(addr.
toText());
742 Lease4StorageAddressIndex::iterator l = idx.find(addr);
743 if (l == idx.end()) {
753 DHCPSRV_MEMFILE_GET_HWADDR).arg(hwaddr.
toText());
760 std::pair<Lease4StorageHWAddressSubnetIdIndex::const_iterator,
761 Lease4StorageHWAddressSubnetIdIndex::const_iterator> l
762 = idx.equal_range(boost::make_tuple(hwaddr.
hwaddr_));
764 for(
auto lease = l.first; lease != l.second; ++lease) {
774 DHCPSRV_MEMFILE_GET_SUBID_HWADDR).arg(subnet_id)
781 Lease4StorageHWAddressSubnetIdIndex::const_iterator lease =
782 idx.find(boost::make_tuple(hwaddr.
hwaddr_, subnet_id));
784 if (lease == idx.end()) {
795 DHCPSRV_MEMFILE_GET_CLIENTID).arg(client_id.
toText());
801 std::pair<Lease4StorageClientIdSubnetIdIndex::const_iterator,
802 Lease4StorageClientIdSubnetIdIndex::const_iterator> l
803 = idx.equal_range(boost::make_tuple(client_id.
getClientId()));
805 for(
auto lease = l.first; lease != l.second; ++lease) {
817 DHCPSRV_MEMFILE_GET_CLIENTID_HWADDR_SUBID).arg(client_id.
toText())
825 Lease4StorageClientIdHWAddressSubnetIdIndex::const_iterator lease =
829 if (lease == idx.end()) {
842 DHCPSRV_MEMFILE_GET_SUBID_CLIENTID).arg(subnet_id)
849 Lease4StorageClientIdSubnetIdIndex::const_iterator lease =
850 idx.find(boost::make_tuple(client_id.
getClientId(), subnet_id));
852 if (lease == idx.end()) {
866 std::pair<Lease4StorageSubnetIdIndex::const_iterator,
867 Lease4StorageSubnetIdIndex::const_iterator> l =
868 idx.equal_range(subnet_id);
870 for (
auto lease = l.first; lease != l.second; ++lease) {
882 for (
auto lease = storage4_.begin(); lease != storage4_.end(); ++lease ) {
893 if (!lower_bound_address.
isV4()) {
895 "retrieving leases from the lease database, got "
896 << lower_bound_address);
901 .arg(lower_bound_address.
toText());
905 Lease4StorageAddressIndex::const_iterator lb = idx.lower_bound(lower_bound_address);
908 if ((lb != idx.end()) && ((*lb)->addr_ == lower_bound_address)) {
913 for (
auto lease = lb;
914 (lease != idx.end()) && (std::distance(lb, lease) < page_size.
page_size_);
926 DHCPSRV_MEMFILE_GET_ADDR6)
929 Lease6Storage::iterator l = storage6_.find(addr);
930 if (l == storage6_.end() || !(*l) || ((*l)->type_ != type)) {
939 const DUID& duid, uint32_t iaid)
const {
941 DHCPSRV_MEMFILE_GET_IAID_DUID)
949 std::pair<Lease6StorageDuidIaidTypeIndex::const_iterator,
950 Lease6StorageDuidIaidTypeIndex::const_iterator> l =
951 idx.equal_range(boost::make_tuple(duid.
getDuid(), iaid, type));
953 for(Lease6StorageDuidIaidTypeIndex::const_iterator lease =
954 l.first; lease != l.second; ++lease) {
963 const DUID& duid, uint32_t iaid,
966 DHCPSRV_MEMFILE_GET_IAID_SUBID_DUID)
975 std::pair<Lease6StorageDuidIaidTypeIndex::const_iterator,
976 Lease6StorageDuidIaidTypeIndex::const_iterator> l =
977 idx.equal_range(boost::make_tuple(duid.
getDuid(), iaid, type));
979 for(Lease6StorageDuidIaidTypeIndex::const_iterator lease =
980 l.first; lease != l.second; ++lease) {
982 if((*lease)->subnet_id_ == subnet_id) {
997 std::pair<Lease6StorageSubnetIdIndex::const_iterator,
998 Lease6StorageSubnetIdIndex::const_iterator> l =
999 idx.equal_range(subnet_id);
1001 for (
auto lease = l.first; lease != l.second; ++lease) {
1005 return (collection);
1013 for (
auto lease = storage6_.begin(); lease != storage6_.end(); ++lease ) {
1017 return (collection);
1027 std::pair<Lease6StorageDuidIndex::const_iterator,
1028 Lease6StorageDuidIndex::const_iterator> l =
1029 idx.equal_range(duid.
getDuid());
1031 for (
auto lease = l.first; lease != l.second; ++lease) {
1035 return (collection);
1042 if (!lower_bound_address.
isV6()) {
1044 "retrieving leases from the lease database, got "
1045 << lower_bound_address);
1050 .arg(lower_bound_address.
toText());
1054 Lease6StorageAddressIndex::const_iterator lb = idx.lower_bound(lower_bound_address);
1057 if ((lb != idx.end()) && ((*lb)->addr_ == lower_bound_address)) {
1062 for (
auto lease = lb;
1063 (lease != idx.end()) && (std::distance(lb, lease) < page_size.
page_size_);
1068 return (collection);
1073 const size_t max_leases)
const {
1084 Lease4StorageExpirationIndex::const_iterator ub =
1085 index.upper_bound(boost::make_tuple(
false, time(NULL)));
1088 for (Lease4StorageExpirationIndex::const_iterator lease = index.begin();
1089 (lease != ub) && ((max_leases == 0) || (std::distance(index.begin(), lease) <
1098 const size_t max_leases)
const {
1109 Lease6StorageExpirationIndex::const_iterator ub =
1110 index.upper_bound(boost::make_tuple(
false, time(NULL)));
1113 for (Lease6StorageExpirationIndex::const_iterator lease = index.begin();
1114 (lease != ub) && ((max_leases == 0) || (std::distance(index.begin(), lease) <
1124 DHCPSRV_MEMFILE_UPDATE_ADDR4).arg(lease->addr_.toText());
1130 Lease4StorageAddressIndex::const_iterator lease_it = index.find(lease->addr_);
1131 if (lease_it == index.end()) {
1133 << lease->addr_ <<
" - no such lease");
1140 lease_file4_->append(*lease);
1150 DHCPSRV_MEMFILE_UPDATE_ADDR6).arg(lease->addr_.toText());
1156 Lease6StorageAddressIndex::const_iterator lease_it = index.find(lease->addr_);
1157 if (lease_it == index.end()) {
1159 << lease->addr_ <<
" - no such lease");
1166 lease_file6_->append(*lease);
1176 DHCPSRV_MEMFILE_DELETE_ADDR).arg(addr.
toText());
1179 Lease4Storage::iterator l = storage4_.find(addr);
1180 if (l == storage4_.end()) {
1191 lease_file4_->append(lease_copy);
1199 Lease6Storage::iterator l = storage6_.find(addr);
1200 if (l == storage6_.end()) {
1211 lease_file6_->append(lease_copy);
1223 DHCPSRV_MEMFILE_DELETE_EXPIRED_RECLAIMED4)
1225 return (deleteExpiredReclaimedLeases<
1227 >(secs,
V4, storage4_, lease_file4_));
1233 DHCPSRV_MEMFILE_DELETE_EXPIRED_RECLAIMED6)
1235 return (deleteExpiredReclaimedLeases<
1237 >(secs,
V6, storage6_, lease_file6_));
1240template<
typename IndexType,
typename LeaseType,
typename StorageType,
1241 typename LeaseFileType>
1243Memfile_LeaseMgr::deleteExpiredReclaimedLeases(
const uint32_t secs,
1244 const Universe& universe,
1245 StorageType& storage,
1246 LeaseFileType& lease_file)
const {
1248 IndexType& index = storage.template get<ExpirationIndexTag>();
1259 typename IndexType::const_iterator upper_limit =
1260 index.upper_bound(boost::make_tuple(
true, time(NULL) - secs));
1269 typename IndexType::const_iterator lower_limit =
1270 index.upper_bound(boost::make_tuple(
true, std::numeric_limits<int64_t>::min()));
1273 uint64_t num_leases =
static_cast<uint64_t
>(std::distance(lower_limit, upper_limit));
1274 if (num_leases > 0) {
1277 DHCPSRV_MEMFILE_DELETE_EXPIRED_RECLAIMED_START)
1284 for (
typename IndexType::const_iterator lease = lower_limit;
1285 lease != upper_limit; ++lease) {
1287 LeaseType lease_copy(**lease);
1290 lease_copy.valid_lft_ = 0;
1291 lease_file->append(lease_copy);
1296 index.erase(lower_limit, upper_limit);
1299 return (num_leases);
1305 return (std::string(
"In memory database with leases stored in a CSV file."));
1316 DHCPSRV_MEMFILE_ROLLBACK);
1322 std::string name(file_name);
1323 switch (file_type) {
1334 name +=
".completed";
1349 std::ostringstream s;
1351 s << (u ==
V4 ?
"4" :
"6");
1359 return (lease_file4_ ? lease_file4_->getFilename() :
"");
1362 return (lease_file6_ ? lease_file6_->getFilename() :
"");
1370 if (u ==
V4 && lease_file4_) {
1374 return (u ==
V6 && lease_file6_);
1378Memfile_LeaseMgr::initLeaseFilePath(Universe u) {
1379 std::string persist_val;
1385 persist_val =
"true";
1389 if (persist_val ==
"false") {
1392 }
else if (persist_val !=
"true") {
1394 << persist_val <<
"'");
1397 std::string lease_file;
1403 return (lease_file);
1406template<
typename LeaseObjectType,
typename LeaseFileType,
typename StorageType>
1407bool Memfile_LeaseMgr::loadLeasesFromFiles(
const std::string& filename,
1408 boost::shared_ptr<LeaseFileType>& lease_file,
1409 StorageType& storage) {
1417 if (pid_file.check()) {
1419 "lease file cleanup is in progress");
1425 bool conversion_needed =
false;
1426 lease_file.reset(
new LeaseFileType(std::string(filename +
".completed")));
1427 if (lease_file->exists()) {
1428 LeaseFileLoader::load<LeaseObjectType>(*lease_file, storage,
1430 conversion_needed = conversion_needed || lease_file->needsConversion();
1435 if (lease_file->exists()) {
1436 LeaseFileLoader::load<LeaseObjectType>(*lease_file, storage,
1438 conversion_needed = conversion_needed || lease_file->needsConversion();
1442 if (lease_file->exists()) {
1443 LeaseFileLoader::load<LeaseObjectType>(*lease_file, storage,
1445 conversion_needed = conversion_needed || lease_file->needsConversion();
1455 lease_file.reset(
new LeaseFileType(filename));
1456 LeaseFileLoader::load<LeaseObjectType>(*lease_file, storage,
1457 MAX_LEASE_ERRORS,
false);
1458 conversion_needed = conversion_needed || lease_file->needsConversion();
1460 return (conversion_needed);
1466 return (lfc_setup_->isRunning());
1471 return (lfc_setup_->getExitStatus());
1480 lfcExecute(lease_file4_);
1482 }
else if (lease_file6_) {
1483 lfcExecute(lease_file6_);
1488Memfile_LeaseMgr::lfcSetup(
bool conversion_needed) {
1489 std::string lfc_interval_str =
"3600";
1492 }
catch (
const std::exception&) {
1496 uint32_t lfc_interval = 0;
1498 lfc_interval = boost::lexical_cast<uint32_t>(lfc_interval_str);
1499 }
catch (boost::bad_lexical_cast&) {
1501 << lfc_interval_str <<
" specified");
1504 if (lfc_interval > 0 || conversion_needed) {
1506 lfc_setup_->setup(lfc_interval, lease_file4_, lease_file6_, conversion_needed);
1510template<
typename LeaseFileType>
1511void Memfile_LeaseMgr::lfcExecute(boost::shared_ptr<LeaseFileType>& lease_file) {
1521 if (!lease_file_finish.exists() && !lease_file_copy.exists()) {
1523 lease_file->close();
1526 do_lfc = (rename(lease_file->getFilename().c_str(),
1527 lease_file_copy.getFilename().c_str()) == 0);
1531 .arg(lease_file->getFilename())
1532 .arg(lease_file_copy.getFilename())
1533 .arg(strerror(errno));
1542 lease_file->open(
true);
1555 .arg(lease_file->getFilename())
1566 lfc_setup_->execute();
1624 std::pair<Lease4StorageSubnetIdIndex::const_iterator,
1625 Lease4StorageSubnetIdIndex::const_iterator> l =
1626 idx.equal_range(subnet_id);
1630 for(
auto lease = l.first; lease != l.second; ++lease) {
1631 leases.push_back(*lease);
1634 size_t num = leases.size();
1635 for (
auto l = leases.begin(); l != leases.end(); ++l) {
1639 .arg(subnet_id).arg(num);
1652 std::pair<Lease6StorageSubnetIdIndex::const_iterator,
1653 Lease6StorageSubnetIdIndex::const_iterator> l =
1654 idx.equal_range(subnet_id);
1658 for(
auto lease = l.first; lease != l.second; ++lease) {
1659 leases.push_back(*lease);
1662 size_t num = leases.size();
1663 for (
auto l = leases.begin(); l != leases.end(); ++l) {
1667 .arg(subnet_id).arg(num);
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.
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.
boost::function< void()> Callback
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 CfgMgr & instance()
returns a single instance of Configuration Manager
std::string getDataDir() const
returns path do the data directory
Holds Client identifier or client IPv4 address.
const std::vector< uint8_t > & getClientId() const
Returns reference to the client-id data.
std::string toText() const
Returns textual representation of a DUID (e.g. 00:01:02:03:ff)
Holds DUID (DHCPv6 Unique Identifier)
std::string toText() const
Returns textual representation of a DUID (e.g. 00:01:02:03:ff)
const std::vector< uint8_t > & getDuid() const
Returns a const reference to the actual DUID value.
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.
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.
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...
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.
virtual ~MemfileLeaseStatsQuery4()
Destructor.
void start()
Creates the IPv4 lease statistical data result set.
MemfileLeaseStatsQuery4(Lease4Storage &storage4)
Constructor for an all subnets query.
MemfileLeaseStatsQuery4(Lease4Storage &storage4, const SubnetID &subnet_id)
Constructor for a single subnet query.
Memfile derivation of the IPv6 statistical lease data query.
MemfileLeaseStatsQuery6(Lease6Storage &storage6)
Constructor.
virtual 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 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()
Constructor for all subnets query.
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".
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.
virtual Lease4Ptr getLease4(const isc::asiolink::IOAddress &addr) const
Returns existing IPv4 lease for specified IPv4 address.
virtual LeaseStatsQueryPtr startSubnetLeaseStatsQuery6(const SubnetID &subnet_id)
Creates and runs the IPv6 lease stats query for a single subnet.
virtual uint64_t deleteExpiredReclaimedLeases6(const uint32_t secs)
Deletes all expired-reclaimed DHCPv6 leases.
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 size_t wipeLeases4(const SubnetID &subnet_id)
Removes specified IPv4 leases.
virtual size_t wipeLeases6(const SubnetID &subnet_id)
Removed specified IPv6 leases.
virtual uint64_t deleteExpiredReclaimedLeases4(const uint32_t secs)
Deletes all expired-reclaimed DHCPv4 leases.
virtual void getExpiredLeases6(Lease6Collection &expired_leases, const size_t max_leases) const
Returns a collection of expired DHCPv6 leases.
Universe
Specifies universe (V4, V6)
virtual std::string getDescription() const
Returns description of the backend.
virtual LeaseStatsQueryPtr startSubnetLeaseStatsQuery4(const SubnetID &subnet_id)
Creates and runs the IPv4 lease stats query for a single subnet.
virtual LeaseStatsQueryPtr startSubnetRangeLeaseStatsQuery4(const SubnetID &first_subnet_id, const SubnetID &last_subnet_id)
Creates and runs the IPv4 lease stats query for a single subnet.
virtual bool deleteLease(const isc::asiolink::IOAddress &addr)
Deletes a lease.
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 void commit()
Commit Transactions.
virtual bool addLease(const Lease4Ptr &lease)
Adds an IPv4 lease.
int getLFCExitStatus() const
Returns the status code returned by the last executed LFC process.
bool persistLeases(Universe u) const
Specifies whether or not leases are written to disk.
static std::string getDBVersion()
Local version of getDBVersion() class method.
virtual LeaseStatsQueryPtr startLeaseStatsQuery6()
Creates and runs the IPv6 lease stats query.
virtual void rollback()
Rollback Transactions.
virtual LeaseStatsQueryPtr startLeaseStatsQuery4()
Creates and runs the IPv4 lease stats query.
virtual void getExpiredLeases4(Lease4Collection &expired_leases, const size_t max_leases) const
Returns a collection of expired DHCPv4 leases.
virtual Lease6Ptr getLease6(Lease::Type type, const isc::asiolink::IOAddress &addr) const
Returns existing IPv6 lease for a given IPv6 address.
virtual Lease6Collection getLeases6() const
Returns all IPv6 leases.
std::string getLeaseFilePath(Universe u) const
Returns an absolute path to the lease file.
virtual void lfcCallback()
A callback function triggering Lease File Cleanup (LFC).
virtual void updateLease4(const Lease4Ptr &lease4)
Updates IPv4 lease.
virtual LeaseStatsQueryPtr startSubnetRangeLeaseStatsQuery6(const SubnetID &first_subnet_id, const SubnetID &last_subnet_id)
Creates and runs the IPv6 lease stats query for a single subnet.
virtual Lease4Collection getLeases4() const
Returns all IPv4 leases.
static std::string appendSuffix(const std::string &file_name, const LFCFileType &file_type)
Appends appropriate suffix to the file name.
virtual void updateLease6(const Lease6Ptr &lease6)
Updates IPv6 lease.
virtual ~Memfile_LeaseMgr()
Destructor (closes file)
std::string getDefaultLeaseFilePath(Universe u) const
Returns default path to the lease file.
Attempt to update lease that was not there.
Manages a pool of asynchronous interval timers.
Exception thrown when an error occurs during CSV file processing.
Provides input/output access to CSV files.
Class to help with processing PID files.
Exception thrown when error occurs during spawning a process.
Utility class for spawning new processes.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
static const int MAJOR_VERSION
static const int MINOR_VERSION
Defines minor version of the 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.
isc::log::Logger dhcpsrv_logger("dhcpsrv")
DHCP server library Logger.
Lease6Storage::index< ExpirationIndexTag >::type Lease6StorageExpirationIndex
DHCPv6 lease storage index by expiration time.
Lease4Storage::index< ClientIdHWAddressSubnetIdIndexTag >::type Lease4StorageClientIdHWAddressSubnetIdIndex
DHCPv4 lease storage index by client id, HW address and subnet id.
Lease6Storage::index< DuidIndexTag >::type Lease6StorageDuidIndex
DHCPv6 lease storage index by Subnet-id.
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.
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.
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.
Lease4Storage::index< ClientIdSubnetIdIndexTag >::type Lease4StorageClientIdSubnetIdIndex
DHCPv4 lease storage index by client and subnet identifier.
Lease4Storage::index< HWAddressSubnetIdIndexTag >::type Lease4StorageHWAddressSubnetIdIndex
DHCPv4 lease storage index by HW address and subnet identifier.
uint32_t SubnetID
Unique identifier for a subnet (both v4 and v6)
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< ClientIdHWAddressSubnetIdIndexTag >, boost::multi_index::composite_key< Lease4, boost::multi_index::const_mem_fun< Lease4, const std::vector< uint8_t > &, &Lease4::getClientIdVector >, 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< 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_ > > > > Lease4Storage
A multi index container holding DHCPv4 leases.
Lease4Storage::index< SubnetIdIndexTag >::type Lease4StorageSubnetIdIndex
DHCPv4 lease storage index by client id, HW address and subnet id.
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 > > > > Lease6Storage
A multi index container holding DHCPv6 leases.
std::vector< Lease4Ptr > Lease4Collection
A collection of IPv4 leases.
Lease4Storage::index< AddressIndexTag >::type Lease4StorageAddressIndex
DHCPv4 lease storage index by address.
boost::shared_ptr< Lease4 > Lease4Ptr
Pointer to a Lease4 structure.
const int DHCPSRV_DBG_TRACE
DHCP server library logging levels.
Lease6Storage::index< SubnetIdIndexTag >::type Lease6StorageSubnetIdIndex
DHCPv6 lease storage index by Subnet-id.
std::vector< std::string > ProcessArgs
Type of the container holding arguments of the executable being run as a background process.
Defines the logger used by the top-level component of kea-dhcp-ddns.
Tag for indexes by address.
Tag for indexes by client id, HW address and subnet id.
Tag for indexes by client and subnet identifiers.
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 identifier tuple.
Structure that holds a lease for IPv4 address.
Structure that holds a lease for IPv6 address and/or prefix.
uint32_t preferred_lft_
preferred lifetime
Contains a single row of lease statistical data.
static const uint32_t STATE_DEFAULT
A lease in the default state.
uint32_t valid_lft_
Valid lifetime.
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 indexs by subnet-id.