21#include <boost/make_shared.hpp>
22#include <boost/static_assert.hpp>
47 "DELETE FROM lease4 WHERE address = $1 AND expire = $2"},
51 "delete_lease4_state_expired",
53 "WHERE state = $1 AND expire < $2"},
58 "DELETE FROM lease6 WHERE address = $1 AND expire = $2"},
62 "delete_lease6_state_expired",
64 "WHERE state = $1 AND expire < $2"},
69 "SELECT address, hwaddr, client_id, "
70 "valid_lifetime, extract(epoch from expire)::bigint, subnet_id, "
71 "fqdn_fwd, fqdn_rev, hostname, "
72 "state, user_context "
78 "SELECT address, hwaddr, client_id, "
79 "valid_lifetime, extract(epoch from expire)::bigint, subnet_id, "
80 "fqdn_fwd, fqdn_rev, hostname, "
81 "state, user_context "
83 "WHERE address = $1"},
87 "get_lease4_clientid",
88 "SELECT address, hwaddr, client_id, "
89 "valid_lifetime, extract(epoch from expire)::bigint, subnet_id, "
90 "fqdn_fwd, fqdn_rev, hostname, "
91 "state, user_context "
93 "WHERE client_id = $1"},
97 "get_lease4_clientid_subid",
98 "SELECT address, hwaddr, client_id, "
99 "valid_lifetime, extract(epoch from expire)::bigint, subnet_id, "
100 "fqdn_fwd, fqdn_rev, hostname, "
101 "state, user_context "
103 "WHERE client_id = $1 AND subnet_id = $2"},
108 "SELECT address, hwaddr, client_id, "
109 "valid_lifetime, extract(epoch from expire)::bigint, subnet_id, "
110 "fqdn_fwd, fqdn_rev, hostname, "
111 "state, user_context "
113 "WHERE hwaddr = $1"},
117 "get_lease4_hwaddr_subid",
118 "SELECT address, hwaddr, client_id, "
119 "valid_lifetime, extract(epoch from expire)::bigint, subnet_id, "
120 "fqdn_fwd, fqdn_rev, hostname, "
121 "state, user_context "
123 "WHERE hwaddr = $1 AND subnet_id = $2"},
128 "SELECT address, hwaddr, client_id, "
129 "valid_lifetime, extract(epoch from expire)::bigint, subnet_id, "
130 "fqdn_fwd, fqdn_rev, hostname, "
131 "state, user_context "
133 "WHERE address > $1 "
140 "SELECT address, hwaddr, client_id, "
141 "valid_lifetime, extract(epoch from expire)::bigint, subnet_id, "
142 "fqdn_fwd, fqdn_rev, hostname, "
143 "state, user_context "
145 "WHERE subnet_id = $1"},
149 "get_lease4_hostname",
150 "SELECT address, hwaddr, client_id, "
151 "valid_lifetime, extract(epoch from expire)::bigint, subnet_id, "
152 "fqdn_fwd, fqdn_rev, hostname, "
153 "state, user_context "
155 "WHERE lower(hostname) = $1"},
160 "SELECT address, hwaddr, client_id, "
161 "valid_lifetime, extract(epoch from expire)::bigint, subnet_id, "
162 "fqdn_fwd, fqdn_rev, hostname, "
163 "state, user_context "
165 "WHERE state != $1 AND valid_lifetime != 4294967295 AND expire < $2 "
172 "SELECT address, duid, valid_lifetime, "
173 "extract(epoch from expire)::bigint, subnet_id, pref_lifetime, "
174 "lease_type, iaid, prefix_len, fqdn_fwd, fqdn_rev, hostname, "
175 "hwaddr, hwtype, hwaddr_source, "
176 "state, user_context "
182 "SELECT address, duid, valid_lifetime, "
183 "extract(epoch from expire)::bigint, subnet_id, pref_lifetime, "
184 "lease_type, iaid, prefix_len, fqdn_fwd, fqdn_rev, hostname, "
185 "hwaddr, hwtype, hwaddr_source, "
186 "state, user_context "
188 "WHERE address = $1 AND lease_type = $2"},
192 "get_lease6_duid_iaid",
193 "SELECT address, duid, valid_lifetime, "
194 "extract(epoch from expire)::bigint, subnet_id, pref_lifetime, "
195 "lease_type, iaid, prefix_len, fqdn_fwd, fqdn_rev, hostname, "
196 "hwaddr, hwtype, hwaddr_source, "
197 "state, user_context "
199 "WHERE duid = $1 AND iaid = $2 AND lease_type = $3"},
203 "get_lease6_duid_iaid_subid",
204 "SELECT address, duid, valid_lifetime, "
205 "extract(epoch from expire)::bigint, subnet_id, pref_lifetime, "
206 "lease_type, iaid, prefix_len, fqdn_fwd, fqdn_rev, hostname, "
207 "hwaddr, hwtype, hwaddr_source, "
208 "state, user_context "
210 "WHERE lease_type = $1 "
211 "AND duid = $2 AND iaid = $3 AND subnet_id = $4"},
216 "SELECT address, duid, valid_lifetime, "
217 "extract(epoch from expire)::bigint, subnet_id, pref_lifetime, "
218 "lease_type, iaid, prefix_len, fqdn_fwd, fqdn_rev, hostname, "
219 "hwaddr, hwtype, hwaddr_source, "
220 "state, user_context "
222 "WHERE address > $1 "
229 "SELECT address, duid, valid_lifetime, "
230 "extract(epoch from expire)::bigint, subnet_id, pref_lifetime, "
231 "lease_type, iaid, prefix_len, fqdn_fwd, fqdn_rev, hostname, "
232 "hwaddr, hwtype, hwaddr_source, "
233 "state, user_context "
235 "WHERE subnet_id = $1"},
240 "SELECT address, duid, valid_lifetime, "
241 "extract(epoch from expire)::bigint, subnet_id, pref_lifetime, "
242 "lease_type, iaid, prefix_len, fqdn_fwd, fqdn_rev, hostname, "
243 "hwaddr, hwtype, hwaddr_source, "
244 "state, user_context "
250 "get_lease6_hostname",
251 "SELECT address, duid, valid_lifetime, "
252 "extract(epoch from expire)::bigint, subnet_id, pref_lifetime, "
253 "lease_type, iaid, prefix_len, fqdn_fwd, fqdn_rev, hostname, "
254 "hwaddr, hwtype, hwaddr_source, "
255 "state, user_context "
257 "WHERE lower(hostname) = $1"},
262 "SELECT address, duid, valid_lifetime, "
263 "extract(epoch from expire)::bigint, subnet_id, pref_lifetime, "
264 "lease_type, iaid, prefix_len, "
265 "fqdn_fwd, fqdn_rev, hostname, "
266 "hwaddr, hwtype, hwaddr_source, "
267 "state, user_context "
269 "WHERE state != $1 AND valid_lifetime != 4294967295 AND expire < $2 "
277 "INSERT INTO lease4(address, hwaddr, client_id, "
278 "valid_lifetime, expire, subnet_id, fqdn_fwd, fqdn_rev, hostname, "
279 "state, user_context) "
280 "VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)"},
287 "INSERT INTO lease6(address, duid, valid_lifetime, "
288 "expire, subnet_id, pref_lifetime, "
289 "lease_type, iaid, prefix_len, fqdn_fwd, fqdn_rev, hostname, "
290 "hwaddr, hwtype, hwaddr_source, "
291 "state, user_context) "
292 "VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17)"},
298 "UPDATE lease4 SET address = $1, hwaddr = $2, "
299 "client_id = $3, valid_lifetime = $4, expire = $5, "
300 "subnet_id = $6, fqdn_fwd = $7, fqdn_rev = $8, hostname = $9, "
301 "state = $10, user_context = $11 "
302 "WHERE address = $12 AND expire = $13"},
310 "UPDATE lease6 SET address = $1, duid = $2, "
311 "valid_lifetime = $3, expire = $4, subnet_id = $5, "
312 "pref_lifetime = $6, lease_type = $7, iaid = $8, "
313 "prefix_len = $9, fqdn_fwd = $10, fqdn_rev = $11, hostname = $12, "
314 "hwaddr = $13, hwtype = $14, hwaddr_source = $15, "
315 "state = $16, user_context = $17 "
316 "WHERE address = $18 AND expire = $19"},
321 "SELECT subnet_id, state, leases as state_count"
322 " FROM lease4_stat ORDER BY subnet_id, state"},
326 "subnet_lease4_stats",
327 "SELECT subnet_id, state, leases as state_count"
329 " WHERE subnet_id = $1 "
334 "subnet_range_lease4_stats",
335 "SELECT subnet_id, state, leases as state_count"
337 " WHERE subnet_id >= $1 and subnet_id <= $2 "
338 " ORDER BY subnet_id, state"},
343 "SELECT subnet_id, lease_type, state, leases as state_count"
344 " FROM lease6_stat ORDER BY subnet_id, lease_type, state" },
348 "subnet_lease6_stats",
349 "SELECT subnet_id, lease_type, state, leases as state_count"
351 " WHERE subnet_id = $1 "
352 " ORDER BY lease_type, state" },
356 "subnet_range_lease6_stats",
357 "SELECT subnet_id, lease_type, state, leases as state_count"
359 " WHERE subnet_id >= $1 and subnet_id <= $2 "
360 " ORDER BY subnet_id, lease_type, state" },
364 "check_lease4_limits",
365 "SELECT checkLease4Limits($1)" },
369 "check_lease6_limits",
370 "SELECT checkLease6Limits($1)" },
375 "SELECT isJsonSupported()" },
379 "get_lease4_count_by_class",
381 "FROM lease4_stat_by_client_class "
382 "WHERE client_class = $1"},
386 "get_lease6_count_by_class",
388 "FROM lease6_stat_by_client_class "
389 "WHERE client_class = $1 AND lease_type = $2"},
392 { 0, { 0 }, NULL, NULL}
449 static const size_t ADDRESS_COL = 0;
450 static const size_t HWADDR_COL = 1;
451 static const size_t CLIENT_ID_COL = 2;
452 static const size_t VALID_LIFETIME_COL = 3;
453 static const size_t EXPIRE_COL = 4;
454 static const size_t SUBNET_ID_COL = 5;
455 static const size_t FQDN_FWD_COL = 6;
456 static const size_t FQDN_REV_COL = 7;
457 static const size_t HOSTNAME_COL = 8;
458 static const size_t STATE_COL = 9;
459 static const size_t USER_CONTEXT_COL = 10;
461 static const size_t LEASE_COLUMNS = 11;
467 : lease_(), addr4_(0), client_id_length_(0) {
469 BOOST_STATIC_ASSERT(9 < LEASE_COLUMNS);
472 memset(client_id_buffer_, 0,
sizeof(client_id_buffer_));
478 columns_.push_back(
"valid_lifetime");
509 addr_str_ = boost::lexical_cast<std::string>(lease->addr_.toUint32());
512 if (lease->hwaddr_ && !lease->hwaddr_->hwaddr_.empty()) {
517 << lease_->hwaddr_->hwaddr_.size()
518 <<
" exceeds maximum allowed of: "
521 bind_array.
add(lease->hwaddr_->hwaddr_);
526 if (lease->client_id_) {
527 bind_array.
add(lease->client_id_->getClientId());
549 subnet_id_str_ = boost::lexical_cast<std::string>(lease->subnet_id_);
552 bind_array.
add(lease->fqdn_fwd_);
554 bind_array.
add(lease->fqdn_rev_);
556 bind_array.
add(lease->hostname_);
558 state_str_ = boost::lexical_cast<std::string>(lease->state_);
568 }
catch (
const std::exception& ex) {
570 "Could not create bind array from Lease4: "
571 << lease_->addr_.toText() <<
", reason: " << ex.what());
591 sizeof(client_id_buffer_), client_id_length_);
625 <<
"' is not a JSON map");
629 Lease4Ptr result(boost::make_shared<Lease4>(addr4_, hwaddr,
636 result->state_ = state;
639 result->setContext(ctx);
643 }
catch (
const std::exception& ex) {
645 "Could not convert data to Lease4, reason: "
659 size_t client_id_length_;
672 static const int ADDRESS_COL = 0;
673 static const int DUID_COL = 1;
674 static const int VALID_LIFETIME_COL = 2;
675 static const int EXPIRE_COL = 3;
676 static const int SUBNET_ID_COL = 4;
677 static const int PREF_LIFETIME_COL = 5;
678 static const int LEASE_TYPE_COL = 6;
679 static const int IAID_COL = 7;
680 static const int PREFIX_LEN_COL = 8;
681 static const int FQDN_FWD_COL = 9;
682 static const int FQDN_REV_COL = 10;
683 static const int HOSTNAME_COL = 11;
684 static const int HWADDR_COL = 12;
685 static const int HWTYPE_COL = 13;
686 static const int HWADDR_SOURCE_COL = 14;
687 static const int STATE_COL = 15;
688 static const size_t USER_CONTEXT_COL = 16;
691 static const size_t LEASE_COLUMNS = 17;
712 return (boost::lexical_cast<std::string>(
ival_));
720 : lease_(), duid_length_(0), duid_(duid_length_), iaid_u_(0),
721 iaid_str_(
""), lease_type_(
Lease6::TYPE_NA), lease_type_str_(
""),
722 prefix_len_(0), prefix_len_str_(
""), pref_lifetime_(0),
723 preferred_lifetime_str_(
""), hwtype_(0), hwtype_str_(
""),
724 hwaddr_source_(0), hwaddr_source_str_(
"") {
726 BOOST_STATIC_ASSERT(15 < LEASE_COLUMNS);
728 memset(duid_buffer_, 0,
sizeof(duid_buffer_));
733 columns_.push_back(
"valid_lifetime");
736 columns_.push_back(
"pref_lifetime");
745 columns_.push_back(
"hwaddr_source");
774 bind_array.
add(lease_->duid_->getDuid());
796 subnet_id_str_ = boost::lexical_cast<std::string>(lease->subnet_id_);
799 preferred_lifetime_str_ = boost::lexical_cast<std::string>(lease_->preferred_lft_);
800 bind_array.
add(preferred_lifetime_str_);
802 lease_type_str_ = boost::lexical_cast<std::string>(lease_->type_);
803 bind_array.
add(lease_type_str_);
808 iaid_u_.
uval_ = lease_->iaid_;
810 bind_array.
add(iaid_str_);
812 prefix_len_str_ = boost::lexical_cast<std::string>
813 (
static_cast<unsigned int>(lease_->prefixlen_));
814 bind_array.
add(prefix_len_str_);
816 bind_array.
add(lease->fqdn_fwd_);
818 bind_array.
add(lease->fqdn_rev_);
820 bind_array.
add(lease->hostname_);
822 if (lease->hwaddr_ && !lease->hwaddr_->hwaddr_.empty()) {
827 << lease_->hwaddr_->hwaddr_.size()
828 <<
" exceeds maximum allowed of: "
831 bind_array.
add(lease->hwaddr_->hwaddr_);
836 if (lease->hwaddr_) {
837 hwtype_str_ = boost::lexical_cast<std::string>
838 (
static_cast<unsigned int>(lease_->hwaddr_->htype_));
839 hwaddr_source_str_ = boost::lexical_cast<std::string>
840 (
static_cast<unsigned int>(lease_->hwaddr_->source_));
842 hwtype_str_ = boost::lexical_cast<std::string>
844 hwaddr_source_str_ = boost::lexical_cast<std::string>
848 bind_array.
add(hwtype_str_);
850 bind_array.
add(hwaddr_source_str_);
852 state_str_ = boost::lexical_cast<std::string>(lease->state_);
862 }
catch (
const std::exception& ex) {
864 "Could not create bind array from Lease6: "
865 << lease_->addr_.toText() <<
", reason: " << ex.what());
890 convertFromBytea(r, row, DUID_COL, duid_buffer_,
sizeof(duid_buffer_), duid_length_);
891 DuidPtr duid_ptr(
new DUID(duid_buffer_, duid_length_));
934 hwaddr->source_ = hwaddr_source_;
946 <<
"' is not a JSON map");
950 Lease6Ptr result(boost::make_shared<Lease6>(lease_type_, addr,
957 hwaddr, prefix_len_));
959 result->cltt_ =
cltt_;
960 result->current_cltt_ =
cltt_;
962 result->state_ = state;
965 result->setContext(ctx);
969 }
catch (
const std::exception& ex) {
971 "Could not convert data to Lease6, reason: "
990 uint32_t raw_value = 0;
1013 size_t duid_length_;
1014 std::vector<uint8_t> duid_;
1016 union Uiaid iaid_u_;
1017 std::string iaid_str_;
1019 std::string lease_type_str_;
1020 uint8_t prefix_len_;
1021 std::string prefix_len_str_;
1022 uint32_t pref_lifetime_;
1023 std::string preferred_lifetime_str_;
1025 std::string hwtype_str_;
1026 uint32_t hwaddr_source_;
1027 std::string hwaddr_source_str_;
1048 const bool fetch_type)
1062 const bool fetch_type,
const SubnetID& subnet_id)
1078 const bool fetch_type,
const SubnetID& first_subnet_id,
1153 uint32_t lease_type;
1214 : conn_(parameters, io_service_accessor, db_reconnect_callback) {
1219PgSqlLeaseMgr::PgSqlLeaseContextAlloc::PgSqlLeaseContextAlloc(
1222 if (MultiThreadingMgr::instance().getMode()) {
1226 lock_guard<mutex> lock(mgr_.pool_->mutex_);
1227 if (!mgr_.pool_->pool_.empty()) {
1228 ctx_ = mgr_.pool_->pool_.back();
1229 mgr_.pool_->pool_.pop_back();
1233 ctx_ = mgr_.createContext();
1237 if (mgr_.pool_->pool_.empty()) {
1240 ctx_ = mgr_.pool_->pool_.back();
1244PgSqlLeaseMgr::PgSqlLeaseContextAlloc::~PgSqlLeaseContextAlloc() {
1245 if (MultiThreadingMgr::instance().getMode()) {
1247 lock_guard<mutex> lock(mgr_.pool_->mutex_);
1248 mgr_.pool_->pool_.push_back(ctx_);
1256 : parameters_(parameters), timer_name_(
"") {
1259 timer_name_ =
"PgSqlLeaseMgr[";
1260 timer_name_ += boost::lexical_cast<std::string>(
reinterpret_cast<uint64_t
>(
this));
1261 timer_name_ +=
"]DbReconnectTimer";
1265 tls += parameters.count(
"trust-anchor");
1266 tls += parameters.count(
"cert-file");
1267 tls += parameters.count(
"key-file");
1268 tls += parameters.count(
"cipher-list");
1269#ifdef HAVE_PGSQL_SSL
1281 <<
"backend (built with this feature disabled)");
1288 std::pair<uint32_t, uint32_t> db_version =
getVersion();
1289 if (code_version != db_version) {
1291 "PostgreSQL schema version mismatch: need version: "
1292 << code_version.first <<
"." << code_version.second
1293 <<
" found version: " << db_version.first <<
"."
1294 << db_version.second);
1314 bool reopened =
false;
1316 const std::string timer_name = db_reconnect_ctl->timerName();
1324 }
catch (
const std::exception& ex) {
1340 if (!db_reconnect_ctl->checkRetries()) {
1343 .arg(db_reconnect_ctl->maxRetries());
1356 .arg(db_reconnect_ctl->maxRetries() - db_reconnect_ctl->retriesLeft() + 1)
1357 .arg(db_reconnect_ctl->maxRetries())
1358 .arg(db_reconnect_ctl->retryInterval());
1364 db_reconnect_ctl->retryInterval(),
1382 ctx->conn_.openDatabase();
1386 for (; tagged_statements[i].text != NULL; ++i) {
1387 ctx->conn_.prepareStatement(tagged_statements[i]);
1402 ctx->conn_.makeReconnectCtl(timer_name_);
1409 std::stringstream tmp;
1412 tmp <<
", library " << PQlibVersion();
1418 StatementIndex stindex,
1420 PgSqlResult r(PQexecPrepared(ctx->conn_, tagged_statements[stindex].name,
1421 tagged_statements[stindex].nbparams,
1426 int s = PQresultStatus(r);
1428 if (s != PGRES_COMMAND_OK) {
1435 ctx->conn_.checkStatementError(r, tagged_statements[stindex]);
1444 .arg(lease->addr_.toText());
1447 PgSqlLeaseContextAlloc get_context(*
this);
1451 ctx->exchange4_->createBindForSend(lease, bind_array);
1452 auto result = addLeaseCommon(ctx,
INSERT_LEASE4, bind_array);
1456 lease->updateCurrentExpirationTime();
1464 .arg(lease->addr_.toText())
1468 PgSqlLeaseContextAlloc get_context(*
this);
1472 ctx->exchange6_->createBindForSend(lease, bind_array);
1474 auto result = addLeaseCommon(ctx,
INSERT_LEASE6, bind_array);
1478 lease->updateCurrentExpirationTime();
1483template <
typename Exchange,
typename LeaseCollection>
1486 StatementIndex stindex,
1489 LeaseCollection& result,
1490 bool single)
const {
1491 const int n = tagged_statements[stindex].nbparams;
1493 tagged_statements[stindex].name, n,
1494 n > 0 ? &bind_array.
values_[0] : NULL,
1495 n > 0 ? &bind_array.
lengths_[0] : NULL,
1496 n > 0 ? &bind_array.
formats_[0] : NULL, 0));
1498 ctx->conn_.checkStatementError(r, tagged_statements[stindex]);
1500 int rows = PQntuples(r);
1501 if (single && rows > 1) {
1503 "database where only one was expected for query "
1504 << tagged_statements[stindex].name);
1507 for(
int i = 0; i < rows; ++ i) {
1508 result.push_back(exchange->convertFromDatabase(r, i));
1522 getLeaseCollection(ctx, stindex, bind_array, ctx->exchange4_,
1526 if (collection.empty()) {
1529 result = *collection.begin();
1543 getLeaseCollection(ctx, stindex, bind_array, ctx->exchange6_,
1547 if (collection.empty()) {
1550 result = *collection.begin();
1563 std::string addr_str = boost::lexical_cast<std::string>(addr.
toUint32());
1564 bind_array.
add(addr_str);
1570 PgSqlLeaseContextAlloc get_context(*
this);
1587 if (!hwaddr.
hwaddr_.empty()) {
1597 PgSqlLeaseContextAlloc get_context(*
this);
1615 if (!hwaddr.
hwaddr_.empty()) {
1622 std::string subnet_id_str = boost::lexical_cast<std::string>(subnet_id);
1623 bind_array.
add(subnet_id_str);
1629 PgSqlLeaseContextAlloc get_context(*
this);
1652 PgSqlLeaseContextAlloc get_context(*
this);
1673 std::string subnet_id_str = boost::lexical_cast<std::string>(subnet_id);
1674 bind_array.
add(subnet_id_str);
1680 PgSqlLeaseContextAlloc get_context(*
this);
1697 std::string subnet_id_str = boost::lexical_cast<std::string>(subnet_id);
1698 bind_array.
add(subnet_id_str);
1704 PgSqlLeaseContextAlloc get_context(*
this);
1721 bind_array.
add(hostname);
1727 PgSqlLeaseContextAlloc get_context(*
this);
1745 PgSqlLeaseContextAlloc get_context(*
this);
1748 getLeaseCollection(ctx,
GET_LEASE4, bind_array, result);
1757 if (!lower_bound_address.
isV4()) {
1759 "retrieving leases from the lease database, got "
1760 << lower_bound_address);
1765 .arg(lower_bound_address.
toText());
1771 std::string lb_address_data = boost::lexical_cast<std::string>(lower_bound_address.
toUint32());
1772 bind_array.
add(lb_address_data);
1775 std::string page_size_data = boost::lexical_cast<std::string>(page_size.
page_size_);
1776 bind_array.
add(page_size_data);
1782 PgSqlLeaseContextAlloc get_context(*
this);
1801 std::string addr_str = addr.
toText();
1802 bind_array.
add(addr_str);
1805 std::string type_str_ = boost::lexical_cast<std::string>(lease_type);
1806 bind_array.
add(type_str_);
1812 PgSqlLeaseContextAlloc get_context(*
this);
1822 uint32_t iaid)
const {
1836 bind_array.
add(iaid_str);
1839 std::string lease_type_str = boost::lexical_cast<std::string>(lease_type);
1840 bind_array.
add(lease_type_str);
1846 PgSqlLeaseContextAlloc get_context(*
this);
1856 uint32_t iaid,
SubnetID subnet_id)
const {
1867 std::string lease_type_str = boost::lexical_cast<std::string>(lease_type);
1868 bind_array.
add(lease_type_str);
1875 bind_array.
add(iaid_str);
1878 std::string subnet_id_str = boost::lexical_cast<std::string>(subnet_id);
1879 bind_array.
add(subnet_id_str);
1885 PgSqlLeaseContextAlloc get_context(*
this);
1902 std::string subnet_id_str = boost::lexical_cast<std::string>(subnet_id);
1903 bind_array.
add(subnet_id_str);
1909 PgSqlLeaseContextAlloc get_context(*
this);
1930 PgSqlLeaseContextAlloc get_context(*
this);
1948 bind_array.
add(hostname);
1954 PgSqlLeaseContextAlloc get_context(*
this);
1972 PgSqlLeaseContextAlloc get_context(*
this);
1975 getLeaseCollection(ctx,
GET_LEASE6, bind_array, result);
1984 if (!lower_bound_address.
isV6()) {
1986 "retrieving leases from the lease database, got "
1987 << lower_bound_address);
1992 .arg(lower_bound_address.
toText());
2000 std::string lb_address_data =
"0";
2001 if (!lower_bound_address.
isV6Zero()) {
2002 lb_address_data = lower_bound_address.
toText();
2006 bind_array.
add(lb_address_data);
2009 std::string page_size_data = boost::lexical_cast<std::string>(page_size.
page_size_);
2010 bind_array.
add(page_size_data);
2016 PgSqlLeaseContextAlloc get_context(*
this);
2026 const size_t max_leases)
const {
2034 const size_t max_leases)
const {
2040template<
typename LeaseCollection>
2042PgSqlLeaseMgr::getExpiredLeasesCommon(LeaseCollection& expired_leases,
2043 const size_t max_leases,
2044 StatementIndex statement_index)
const {
2049 bind_array.
add(state_str);
2053 bind_array.
add(timestamp_str);
2057 uint32_t limit = max_leases > 0 ?
static_cast<uint32_t
>(max_leases) :
2058 std::numeric_limits<uint32_t>::max();
2059 std::string limit_str = boost::lexical_cast<std::string>(limit);
2060 bind_array.
add(limit_str);
2063 PgSqlLeaseContextAlloc get_context(*
this);
2067 getLeaseCollection(ctx, statement_index, bind_array, expired_leases);
2070template<
typename LeasePtr>
2073 StatementIndex stindex,
2076 PgSqlResult r(PQexecPrepared(ctx->conn_, tagged_statements[stindex].name,
2077 tagged_statements[stindex].nbparams,
2082 ctx->conn_.checkStatementError(r, tagged_statements[stindex]);
2084 int affected_rows = boost::lexical_cast<int>(PQcmdTuples(r));
2087 if (affected_rows == 1) {
2092 if (affected_rows == 0) {
2094 lease->addr_.toText() <<
" as it does not exist");
2100 "that had the address " << lease->addr_.toText());
2108 .arg(lease->addr_.toText());
2111 PgSqlLeaseContextAlloc get_context(*
this);
2116 ctx->exchange4_->createBindForSend(lease, bind_array);
2119 std::string addr4_str = boost::lexical_cast<std::string>(lease->addr_.toUint32());
2120 bind_array.
add(addr4_str);
2122 std::string expire_str;
2128 lease->current_valid_lft_);
2130 bind_array.
add(expire_str);
2133 updateLeaseCommon(ctx, stindex, bind_array, lease);
2136 lease->updateCurrentExpirationTime();
2144 .arg(lease->addr_.toText())
2148 PgSqlLeaseContextAlloc get_context(*
this);
2153 ctx->exchange6_->createBindForSend(lease, bind_array);
2156 std::string addr_str = lease->addr_.
toText();
2157 bind_array.
add(addr_str);
2159 std::string expire_str;
2165 lease->current_valid_lft_);
2167 bind_array.
add(expire_str);
2170 updateLeaseCommon(ctx, stindex, bind_array, lease);
2173 lease->updateCurrentExpirationTime();
2177PgSqlLeaseMgr::deleteLeaseCommon(StatementIndex stindex,
2180 PgSqlLeaseContextAlloc get_context(*
this);
2183 PgSqlResult r(PQexecPrepared(ctx->conn_, tagged_statements[stindex].name,
2184 tagged_statements[stindex].nbparams,
2189 ctx->conn_.checkStatementError(r, tagged_statements[stindex]);
2190 int affected_rows = boost::lexical_cast<int>(PQcmdTuples(r));
2192 return (affected_rows);
2204 std::string addr4_str = boost::lexical_cast<std::string>(addr.
toUint32());
2205 bind_array.
add(addr4_str);
2207 std::string expire_str;
2213 lease->current_valid_lft_);
2215 bind_array.
add(expire_str);
2217 auto affected_rows = deleteLeaseCommon(
DELETE_LEASE4, bind_array);
2220 if (affected_rows == 1) {
2225 if (affected_rows == 0) {
2232 "that had the address " << lease->addr_.toText());
2245 std::string addr6_str = addr.
toText();
2246 bind_array.
add(addr6_str);
2248 std::string expire_str;
2254 lease->current_valid_lft_);
2256 bind_array.
add(expire_str);
2258 auto affected_rows = deleteLeaseCommon(
DELETE_LEASE6, bind_array);
2261 if (affected_rows == 1) {
2266 if (affected_rows == 0) {
2273 "that had the address " << lease->addr_.toText());
2291PgSqlLeaseMgr::deleteExpiredReclaimedLeasesCommon(
const uint32_t secs,
2292 StatementIndex statement_index) {
2297 bind_array.
add(state_str);
2301 static_cast<time_t
>(secs));
2302 bind_array.
add(expiration_str);
2305 return (deleteLeaseCommon(statement_index, bind_array));
2309PgSqlLeaseMgr::checkLimits(
ConstElementPtr const& user_context, StatementIndex
const stindex)
const {
2311 if (!user_context) {
2316 PgSqlLeaseContextAlloc get_context(*
this);
2321 std::string
const user_context_str(user_context->str());
2322 bind_array.
add(user_context_str);
2326 tagged_statements[stindex].name,
2327 tagged_statements[stindex].nbparams,
2331 ctx->conn_.checkStatementError(r, tagged_statements[stindex]);
2339PgSqlLeaseMgr::checkLimits4(
ConstElementPtr const& user_context)
const {
2344PgSqlLeaseMgr::checkLimits6(
ConstElementPtr const& user_context)
const {
2349PgSqlLeaseMgr::isJsonSupported()
const {
2351 PgSqlLeaseContextAlloc get_context(*
this);
2356 PgSqlResult r(PQexecPrepared(ctx->conn_, tagged_statements[stindex].name,
2358 ctx->conn_.checkStatementError(r, tagged_statements[stindex]);
2360 bool json_supported;
2362 return json_supported;
2366PgSqlLeaseMgr::getClassLeaseCount(
const ClientClass& client_class,
2369 PgSqlLeaseContextAlloc get_context(*
this);
2374 bind_array.
add(client_class);
2376 bind_array.
add(ltype);
2383 tagged_statements[stindex].name,
2384 tagged_statements[stindex].nbparams,
2388 ctx->conn_.checkStatementError(r, tagged_statements[stindex]);
2390 int rows = PQntuples(r);
2402PgSqlLeaseMgr::recountClassLeases4() {
2407PgSqlLeaseMgr::recountClassLeases6() {
2412PgSqlLeaseMgr::clearClassLeaseCounts() {
2419 PgSqlLeaseContextAlloc get_context(*
this);
2432 PgSqlLeaseContextAlloc get_context(*
this);
2447 PgSqlLeaseContextAlloc get_context(*
this);
2462 PgSqlLeaseContextAlloc get_context(*
this);
2475 PgSqlLeaseContextAlloc get_context(*
this);
2490 PgSqlLeaseContextAlloc get_context(*
this);
2515 PgSqlLeaseContextAlloc get_context(*
this);
2518 std::string name =
"";
2520 name = ctx->conn_.getParameter(
"name");
2529 return (std::string(
"PostgreSQL Database"));
2532std::pair<uint32_t, uint32_t>
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
A generic exception that is thrown when a function is not implemented.
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.
uint32_t toUint32() const
Converts IPv4 address to uint32_t.
bool isV6() const
Convenience function to check for an IPv6 address.
bool isV4() const
Convenience function to check for an IPv4 address.
bool isV6Zero() const
Convenience function to check if it is an IPv4 zero address.
static ElementPtr fromJSON(const std::string &in, bool preproc=false)
These functions will parse the given string (JSON) representation of a compound element.
static bool invokeDbLostCallback(const util::ReconnectCtlPtr &db_reconnect_ctl)
Invokes the connection's lost connectivity callback.
static std::string redactedAccessString(const ParameterMap ¶meters)
Redact database access string.
static bool invokeDbFailedCallback(const util::ReconnectCtlPtr &db_reconnect_ctl)
Invokes the connection's restore failed connectivity callback.
static bool invokeDbRecoveredCallback(const util::ReconnectCtlPtr &db_reconnect_ctl)
Invokes the connection's restored connectivity callback.
std::map< std::string, std::string > ParameterMap
Database configuration parameter map.
Exception thrown on failure to open database.
Exception thrown on failure to execute a database function.
Invalid address family used as input to Lease Manager.
Multiple lease records found where one expected.
Common PgSql Connector Pool.
static bool warned_about_tls
Emit the TLS support warning only once.
static const char DUPLICATE_KEY[]
Define the PgSql error state for a duplicate key error.
static std::pair< uint32_t, uint32_t > getVersion(const ParameterMap ¶meters)
Get the schema version.
void checkStatementError(const PgSqlResult &r, PgSqlTaggedStatement &statement)
Checks result of the r object.
Base class for marshalling data to and from PostgreSQL.
static const char * getRawColumnValue(const PgSqlResult &r, const int row, const size_t col)
Gets a pointer to the raw column value in a result set row.
static std::string convertToDatabaseTime(const time_t input_time)
Converts UTC time_t value to a text representation in local time.
static std::string getColumnLabel(const PgSqlResult &r, const size_t col)
Fetches the name of the column in a result set.
static void convertFromBytea(const PgSqlResult &r, const int row, const size_t col, uint8_t *buffer, const size_t buffer_size, size_t &bytes_converted)
Converts a column in a row in a result set to a binary bytes.
static void getColumnValue(const PgSqlResult &r, const int row, const size_t col, std::string &value)
Fetches text column value as a string.
static time_t convertFromDatabaseTime(const std::string &db_time_val)
Converts time stamp from the database to a time_t.
std::vector< std::string > columns_
Stores text labels for columns, currently only used for logging and errors.
static isc::asiolink::IOAddress getIPv6Value(const PgSqlResult &r, const int row, const size_t col)
Converts a column in a row in a result set into IPv6 address.
RAII wrapper for PostgreSQL Result sets.
static CfgMgr & instance()
returns a single instance of Configuration Manager
SrvConfigPtr getCurrentCfg()
Returns a pointer to the current configuration.
Holds Client identifier or client IPv4 address.
static const size_t MAX_CLIENT_ID_LEN
Maximum size of a client ID.
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)
static const size_t MAX_DUID_LEN
maximum duid size As defined in RFC 8415, section 11.1
const std::vector< uint8_t > & getDuid() const
Returns a const reference to the actual DUID value.
static void create(const std::string &dbaccess)
Create an instance of a lease manager.
static void destroy()
Destroy lease manager.
static isc::asiolink::IOServicePtr & getIOService()
Returns pointer to the IO service.
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...
Attempt to update lease that was not there.
Supports exchanging IPv4 leases with PostgreSQL.
Lease4Ptr convertFromDatabase(const PgSqlResult &r, int row)
Creates a Lease4 object from a given row in a result set.
PgSqlLease4Exchange()
Constructor.
void createBindForSend(const Lease4Ptr &lease, PsqlBindArray &bind_array)
Creates the bind array for sending Lease4 data to the database.
Supports exchanging IPv6 leases with PostgreSQL.
void createBindForSend(const Lease6Ptr &lease, PsqlBindArray &bind_array)
Creates the bind array for sending Lease6 data to the database.
void getLeaseTypeColumnValue(const PgSqlResult &r, const int row, const size_t col, Lease6::Type &value) const
Fetches an integer text column as a Lease6::Type.
Lease6Ptr convertFromDatabase(const PgSqlResult &r, int row)
Creates a Lease6 object from a given row in a result set.
PostgreSQL Lease Context Pool.
PostgreSQL Lease Context.
PgSqlLeaseContext(const db::DatabaseConnection::ParameterMap ¶meters, db::IOServiceAccessorPtr io_service_accessor, db::DbCallback db_reconnect_callback)
Constructor.
Base class for marshalling leases to and from PostgreSQL.
std::string valid_lifetime_str_
uint8_t hwaddr_buffer_[HWAddr::MAX_HWADDR_LEN]
virtual ~PgSqlLeaseExchange()
std::string subnet_id_str_
std::vector< uint8_t > hwaddr_
std::string user_context_
std::string addr_str_
Common Instance members used for binding and conversion.
PostgreSQL Lease Manager.
virtual LeaseStatsQueryPtr startLeaseStatsQuery4() override
Creates and runs the IPv4 lease stats query.
virtual size_t wipeLeases4(const SubnetID &subnet_id) override
Removes specified IPv4 leases.
PgSqlLeaseContextPtr createContext() const
Create a new context.
virtual Lease4Collection getLeases4() const override
Returns all IPv4 leases.
virtual LeaseStatsQueryPtr startLeaseStatsQuery6() override
Creates and runs the IPv6 lease stats query.
virtual uint64_t deleteExpiredReclaimedLeases4(const uint32_t secs) override
Deletes all expired-reclaimed DHCPv4 leases.
static std::string getDBVersion()
Local version of getDBVersion() class method.
virtual LeaseStatsQueryPtr startSubnetLeaseStatsQuery4(const SubnetID &subnet_id) override
Creates and runs the IPv4 lease stats query for a single subnet.
virtual uint64_t deleteExpiredReclaimedLeases6(const uint32_t secs) override
Deletes all expired-reclaimed DHCPv6 leases.
virtual size_t wipeLeases6(const SubnetID &subnet_id) override
Removed specified IPv6 leases.
virtual void getExpiredLeases4(Lease4Collection &expired_leases, const size_t max_leases) const override
Returns a collection of expired DHCPv4 leases.
virtual void updateLease6(const Lease6Ptr &lease6) override
Updates IPv6 lease.
virtual std::pair< uint32_t, uint32_t > getVersion() const override
Returns backend version.
virtual std::string getDescription() const override
Returns description of the backend.
virtual LeaseStatsQueryPtr startSubnetRangeLeaseStatsQuery6(const SubnetID &first_subnet_id, const SubnetID &last_subnet_id) override
Creates and runs the IPv6 lease stats query for a single subnet.
virtual void commit() override
Commit Transactions.
virtual LeaseStatsQueryPtr startSubnetLeaseStatsQuery6(const SubnetID &subnet_id) override
Creates and runs the IPv6 lease stats query for a single subnet.
virtual Lease6Ptr getLease6(Lease::Type type, const isc::asiolink::IOAddress &addr) const override
Returns existing IPv6 lease for a given IPv6 address.
virtual Lease6Collection getLeases6() const override
Returns all IPv6 leases.
StatementIndex
Statement Tags.
@ SUBNET_RANGE_LEASE4_STATS
@ SUBNET_RANGE_LEASE6_STATS
@ GET_LEASE4_COUNT_BY_CLASS
@ GET_LEASE6_DUID_IAID_SUBID
@ GET_LEASE6_COUNT_BY_CLASS
@ GET_LEASE4_HWADDR_SUBID
@ GET_LEASE4_CLIENTID_SUBID
@ DELETE_LEASE6_STATE_EXPIRED
@ DELETE_LEASE4_STATE_EXPIRED
virtual void rollback() override
Rollback Transactions.
virtual void updateLease4(const Lease4Ptr &lease4) override
Updates IPv4 lease.
virtual void getExpiredLeases6(Lease6Collection &expired_leases, const size_t max_leases) const override
Returns a collection of expired DHCPv6 leases.
virtual std::string getName() const override
Returns backend name.
PgSqlLeaseMgr(const db::DatabaseConnection::ParameterMap ¶meters)
Constructor.
virtual Lease4Ptr getLease4(const isc::asiolink::IOAddress &addr) const override
Returns an IPv4 lease for specified IPv4 address.
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.
static bool dbReconnect(util::ReconnectCtlPtr db_reconnect_ctl)
Attempts to reconnect the server to the lease DB backend manager.
virtual ~PgSqlLeaseMgr()
Destructor (closes database)
virtual bool addLease(const Lease4Ptr &lease) override
Adds an IPv4 lease.
virtual bool deleteLease(const Lease4Ptr &lease) override
Deletes an IPv4 lease.
Base PgSql derivation of the statistical lease data query.
bool fetch_type_
Indicates if query supplies lease type.
boost::shared_ptr< PgSqlResult > result_set_
The result set returned by Postgres.
PgSqlLeaseStatsQuery(PgSqlConnection &conn, PgSqlTaggedStatement &statement, const bool fetch_type, const SubnetID &first_subnet_id, const SubnetID &last_subnet_id)
Constructor to query for the stats for a range of subnets.
PgSqlConnection & conn_
Database connection to use to execute the query.
virtual ~PgSqlLeaseStatsQuery()
Destructor.
PgSqlTaggedStatement & statement_
The query's prepared statement.
static bool negative_count_
Received negative state count showing a problem.
bool getNextRow(LeaseStatsRow &row)
Fetches the next row in the result set.
PgSqlLeaseStatsQuery(PgSqlConnection &conn, PgSqlTaggedStatement &statement, const bool fetch_type)
Constructor to query for all subnets' stats.
PgSqlLeaseStatsQuery(PgSqlConnection &conn, PgSqlTaggedStatement &statement, const bool fetch_type, const SubnetID &subnet_id)
Constructor to query for a single subnet's stats.
void start()
Creates the lease statistical data result set.
uint32_t next_row_
Index of the next row to fetch.
static const TimerMgrPtr & instance()
Returns pointer to the sole instance of the TimerMgr.
RAII class creating a critical section.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
static const uint32_t HWADDR_SOURCE_UNKNOWN
Used when actual origin is not known, e.g.
#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.
boost::shared_ptr< const Element > ConstElementPtr
boost::shared_ptr< IOServiceAccessor > IOServiceAccessorPtr
Pointer to an instance of IOServiceAccessor.
const size_t OID_NONE
Constants for PostgreSQL data types These are defined by PostgreSQL in <catalog/pg_type....
const size_t OID_TIMESTAMP
const uint32_t PGSQL_SCHEMA_VERSION_MINOR
std::function< bool(util::ReconnectCtlPtr db_reconnect_ctl)> DbCallback
Defines a callback prototype for propagating events upward.
std::function< isc::asiolink::IOServicePtr()> IOServiceAccessor
Function which returns the IOService that can be used to recover the connection.
const uint32_t PGSQL_SCHEMA_VERSION_MAJOR
Define the PostgreSQL backend version.
const isc::log::MessageID DHCPSRV_PGSQL_GET_SUBID4
isc::log::Logger dhcpsrv_logger("dhcpsrv")
DHCP server library Logger.
const isc::log::MessageID DHCPSRV_PGSQL_ADD_ADDR4
std::string ClientClass
Defines a single class name.
const isc::log::MessageID DHCPSRV_PGSQL_GET_SUBID_CLIENTID
const isc::log::MessageID DHCPSRV_PGSQL_GET_ADDR6
const isc::log::MessageID DHCPSRV_PGSQL_GET_DUID
const isc::log::MessageID DHCPSRV_PGSQL_GET6
const isc::log::MessageID DHCPSRV_PGSQL_GET_SUBID6
const isc::log::MessageID DHCPSRV_PGSQL_GET_PAGE4
boost::shared_ptr< CfgDbAccess > CfgDbAccessPtr
A pointer to the CfgDbAccess.
boost::shared_ptr< DUID > DuidPtr
boost::shared_ptr< Lease6 > Lease6Ptr
Pointer to a Lease6 structure.
const isc::log::MessageID DHCPSRV_PGSQL_GET_HOSTNAME6
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_PGSQL_GET_IAID_SUBID_DUID
const isc::log::MessageID DHCPSRV_PGSQL_GET_ADDR4
const isc::log::MessageID DHCPSRV_PGSQL_GET_HOSTNAME4
boost::shared_ptr< HWAddr > HWAddrPtr
Shared pointer to a hardware address structure.
const int DHCPSRV_DBG_TRACE_DETAIL
Additional information.
const isc::log::MessageID DHCPSRV_PGSQL_ROLLBACK
const isc::log::MessageID DHCPSRV_PGSQL_GET_HWADDR
const isc::log::MessageID DHCPSRV_PGSQL_NO_TLS_SUPPORT
const isc::log::MessageID DHCPSRV_PGSQL_GET_PAGE6
const isc::log::MessageID DHCPSRV_PGSQL_DELETE_EXPIRED_RECLAIMED4
const isc::log::MessageID DHCPSRV_PGSQL_UPDATE_ADDR4
const isc::log::MessageID DHCPSRV_PGSQL_GET_SUBID_HWADDR
const isc::log::MessageID DHCPSRV_PGSQL_GET_VERSION
const isc::log::MessageID DHCPSRV_PGSQL_LEASE_DB_RECONNECT_ATTEMPT_FAILED
const isc::log::MessageID DHCPSRV_PGSQL_TLS_SUPPORT
uint32_t SubnetID
Defines unique IPv4 or IPv6 subnet identifier.
boost::shared_ptr< Lease > LeasePtr
Pointer to the lease object.
const isc::log::MessageID DHCPSRV_PGSQL_GET4
const isc::log::MessageID DHCPSRV_PGSQL_ADD_ADDR6
const isc::log::MessageID DHCPSRV_PGSQL_GET_CLIENTID
const isc::log::MessageID DHCPSRV_PGSQL_GET_IAID_DUID
const isc::log::MessageID DHCPSRV_PGSQL_UPDATE_ADDR6
boost::shared_ptr< PgSqlLeaseContext > PgSqlLeaseContextPtr
Type of pointers to contexts.
const isc::log::MessageID DHCPSRV_PGSQL_LEASE_DB_RECONNECT_FAILED
std::vector< Lease4Ptr > Lease4Collection
A collection of IPv4 leases.
@ HTYPE_UNDEFINED
not specified or undefined
@ HTYPE_ETHER
Ethernet 10Mbps.
const isc::log::MessageID DHCPSRV_PGSQL_NEGATIVE_LEASES_STAT
const isc::log::MessageID DHCPSRV_PGSQL_GET_EXPIRED4
const isc::log::MessageID DHCPSRV_PGSQL_GET_EXPIRED6
const isc::log::MessageID DHCPSRV_PGSQL_LEASE_DB_RECONNECT_ATTEMPT_SCHEDULE
const isc::log::MessageID DHCPSRV_PGSQL_DELETE_ADDR
boost::shared_ptr< Lease4 > Lease4Ptr
Pointer to a Lease4 structure.
const isc::log::MessageID DHCPSRV_PGSQL_COMMIT
const isc::log::MessageID DHCPSRV_PGSQL_DELETE_EXPIRED_RECLAIMED6
boost::shared_ptr< ReconnectCtl > ReconnectCtlPtr
Pointer to an instance of ReconnectCtl.
Defines the logger used by the top-level component of kea-lfc.
Define a PostgreSQL statement.
const char * name
Short name of the query.
void addTempString(const std::string &str)
Binds the given string to the bind array.
std::vector< const char * > values_
Vector of pointers to the data values.
std::vector< int > formats_
Vector of "format" for each value.
void add(const char *value)
Adds a char array to bind array based.
size_t size() const
Fetches the number of entries in the array.
std::string toText() const
Dumps the contents of the array to a string.
std::vector< int > lengths_
Vector of data lengths for each value.
Hardware type that represents information from DHCPv4 packet.
static const size_t MAX_HWADDR_LEN
Maximum size of a hardware address.
std::vector< uint8_t > hwaddr_
std::string toText(bool include_htype=true) const
Returns textual representation of a hardware address (e.g.
Structure that holds a lease for IPv6 address and/or prefix.
Contains a single row of lease statistical data.
int64_t state_count_
state_count The count of leases in the lease state
uint32_t lease_state_
The lease_state to which the count applies.
SubnetID subnet_id_
The subnet ID to which this data applies.
Lease::Type lease_type_
The lease_type to which the count applies.
static const uint32_t INFINITY_LFT
Infinity (means static, i.e. never expire)
static const uint32_t STATE_EXPIRED_RECLAIMED
Expired and reclaimed lease.
Type
Type of lease or pool.
@ TYPE_TA
the lease contains temporary IPv6 address
@ TYPE_PD
the lease contains IPv6 prefix (for prefix delegation)
@ TYPE_NA
the lease contains non-temporary IPv6 address
Union for marshalling IAID into and out of the database IAID is defined in the RFC as 4 octets,...
Uiaid(uint32_t val)
Constructor.
std::string dbInputString()
Return a string representing the signed 32-bit value.
Uiaid(int32_t val)
Constructor.