bind_[9].is_unsigned = MLM_TRUE;
// bind_[9].is_null = &MLM_FALSE; // commented out for performance
// reasons, see memset() above
+
// Add the error flags
setErrorIndicators(bind_, error_, LEASE_COLUMNS);
client_id_buffer_, client_id_length_,
valid_lifetime_, 0, 0, cltt, subnet_id_,
fqdn_fwd_, fqdn_rev_, hostname));
+
+ // Set state.
lease->state_ = state_;
+
return (lease);
}
// Note: Arrays are declared fixed length for speed of creation
uint32_t addr4_; ///< IPv4 address
MYSQL_BIND bind_[LEASE_COLUMNS]; ///< Bind array
- std::string columns_[LEASE_COLUMNS];///< Column names
- my_bool error_[LEASE_COLUMNS]; ///< Error array
+ std::string columns_[LEASE_COLUMNS]; ///< Column names
+ my_bool error_[LEASE_COLUMNS]; ///< Error array
std::vector<uint8_t> hwaddr_; ///< Hardware address
uint8_t hwaddr_buffer_[HWAddr::MAX_HWADDR_LEN];
///< Hardware address buffer
///< Client hostname
unsigned long hostname_length_; ///< Client hostname length
uint32_t state_; ///< Lease state
-
};
-
/// @brief Exchange MySQL and Lease6 Data
///
/// On any MySQL operation, arrays of MYSQL_BIND structures must be built to
public:
/// @brief Constructor
///
- /// The initialization of the variables here is nonly to satisfy cppcheck -
+ /// The initialization of the variables here is only to satisfy cppcheck -
/// all variables are initialized/set in the methods before they are used.
MySqlLease6Exchange() : addr6_length_(0), duid_length_(0),
iaid_(0), lease_type_(0), prefixlen_(0),
// code that explicitly sets is_null is there, but is commented out.
memset(bind_, 0, sizeof(bind_));
- // address: varchar(39)
+ // address: varchar(39)
// A Lease6_ address has a maximum of 39 characters. The array is
// one byte longer than this to guarantee that we can always null
// terminate it whatever is returned.
bind_[15].is_unsigned = MLM_TRUE;
// bind_[15].is_null = &MLM_FALSE; // commented out for performance
// reasons, see memset() above
+
// Add the error flags
setErrorIndicators(bind_, error_, LEASE_COLUMNS);
// schema.
// Note: arrays are declared fixed length for speed of creation
std::string addr6_; ///< String form of address
- char addr6_buffer_[ADDRESS6_TEXT_MAX_LEN + 1]; ///< Character
+ char addr6_buffer_[ADDRESS6_TEXT_MAX_LEN + 1]; ///< Character
///< array form of V6 address
unsigned long addr6_length_; ///< Length of the address
MYSQL_BIND bind_[LEASE_COLUMNS]; ///< Bind array
- std::string columns_[LEASE_COLUMNS];///< Column names
+ std::string columns_[LEASE_COLUMNS]; ///< Column names
std::vector<uint8_t> duid_; ///< Client identification
uint8_t duid_buffer_[DUID::MAX_DUID_LEN]; ///< Buffer form of DUID
unsigned long duid_length_; ///< Length of the DUID
conn_.checkError(status, statement_index_, "results storage failed");
}
-
/// @brief Fetches the next row in the result set
///
/// Once the internal result set has been populated by invoking the
exchange6_.reset(new MySqlLease6Exchange());
}
-
MySqlLeaseMgr::~MySqlLeaseMgr() {
// There is no need to close the database in this destructor: it is
// closed in the destructor of the mysql_ member variable.
}
}
-
void MySqlLeaseMgr::getLease(StatementIndex stindex, MYSQL_BIND* bind,
Lease4Ptr& result) const {
// Create appropriate collection object and get all leases matching
}
}
-
void MySqlLeaseMgr::getLease(StatementIndex stindex, MYSQL_BIND* bind,
Lease6Ptr& result) const {
// Create appropriate collection object and get all leases matching
}
}
-
// Basic lease access methods. Obtain leases from the database using various
// criteria.
return (result);
}
-
Lease4Collection
MySqlLeaseMgr::getLease4(const HWAddr& hwaddr) const {
LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL,
return (result);
}
-
Lease4Ptr
MySqlLeaseMgr::getLease4(const HWAddr& hwaddr, SubnetID subnet_id) const {
LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL,
return (result);
}
-
Lease4Collection
MySqlLeaseMgr::getLease4(const ClientId& clientid) const {
LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL,
return (result);
}
-
Lease6Collection
MySqlLeaseMgr::getLeases6(Lease::Type lease_type,
const DUID& duid, uint32_t iaid) const {
getLeaseCollection(statement_index, inbind, expired_leases);
}
-
-
// Update lease methods. These comprise common code that handles the actual
// update, and type-specific methods that set up the parameters for the prepared
// statement depending on the type of lease.
}
}
-
void
MySqlLeaseMgr::updateLease4(const Lease4Ptr& lease) {
const StatementIndex stindex = UPDATE_LEASE4;
updateLeaseCommon(stindex, &bind[0], lease);
}
-
void
MySqlLeaseMgr::updateLease6(const Lease6Ptr& lease) {
const StatementIndex stindex = UPDATE_LEASE6;
return (name);
}
-
std::string
MySqlLeaseMgr::getDescription() const {
return (std::string("MySQL Database"));
}
-
std::pair<uint32_t, uint32_t>
MySqlLeaseMgr::getVersion() const {
const StatementIndex stindex = GET_VERSION;
}
}
-
void
MySqlLeaseMgr::rollback() {
LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MYSQL_ROLLBACK);
"get_lease4_addr",
"SELECT address, hwaddr, client_id, "
"valid_lifetime, extract(epoch from expire)::bigint, subnet_id, "
- "fqdn_fwd, fqdn_rev, hostname, state "
+ "fqdn_fwd, fqdn_rev, hostname, "
+ "state "
"FROM lease4 "
"WHERE address = $1"},
"get_lease4_clientid",
"SELECT address, hwaddr, client_id, "
"valid_lifetime, extract(epoch from expire)::bigint, subnet_id, "
- "fqdn_fwd, fqdn_rev, hostname, state "
+ "fqdn_fwd, fqdn_rev, hostname, "
+ "state "
"FROM lease4 "
"WHERE client_id = $1"},
"get_lease4_clientid_subid",
"SELECT address, hwaddr, client_id, "
"valid_lifetime, extract(epoch from expire)::bigint, subnet_id, "
- "fqdn_fwd, fqdn_rev, hostname, state "
+ "fqdn_fwd, fqdn_rev, hostname, "
+ "state "
"FROM lease4 "
"WHERE client_id = $1 AND subnet_id = $2"},
"get_lease4_hwaddr",
"SELECT address, hwaddr, client_id, "
"valid_lifetime, extract(epoch from expire)::bigint, subnet_id, "
- "fqdn_fwd, fqdn_rev, hostname, state "
+ "fqdn_fwd, fqdn_rev, hostname, "
+ "state "
"FROM lease4 "
"WHERE hwaddr = $1"},
"get_lease4_hwaddr_subid",
"SELECT address, hwaddr, client_id, "
"valid_lifetime, extract(epoch from expire)::bigint, subnet_id, "
- "fqdn_fwd, fqdn_rev, hostname, state "
+ "fqdn_fwd, fqdn_rev, hostname, "
+ "state "
"FROM lease4 "
"WHERE hwaddr = $1 AND subnet_id = $2"},
{ 3, { OID_INT8, OID_TIMESTAMP, OID_INT8 },
"get_lease4_expire",
"SELECT address, hwaddr, client_id, "
- "valid_lifetime, extract(epoch from expire)::bigint, subnet_id, "
- "fqdn_fwd, fqdn_rev, hostname, state "
- "FROM lease4 "
- "WHERE state != $1 AND expire < $2 "
- "ORDER BY expire "
- "LIMIT $3"},
+ "valid_lifetime, extract(epoch from expire)::bigint, subnet_id, "
+ "fqdn_fwd, fqdn_rev, hostname, "
+ "state "
+ "FROM lease4 "
+ "WHERE state != $1 AND expire < $2 "
+ "ORDER BY expire "
+ "LIMIT $3"},
// GET_LEASE6_ADDR
{ 2, { OID_VARCHAR, OID_INT2 },
{ 3, { OID_INT8, OID_TIMESTAMP, OID_INT8 },
"get_lease6_expire",
"SELECT address, duid, valid_lifetime, "
- "extract(epoch from expire)::bigint, subnet_id, pref_lifetime, "
- "lease_type, iaid, prefix_len, "
- "fqdn_fwd, fqdn_rev, hostname, state "
- "state "
- "FROM lease6 "
- "WHERE state != $1 AND expire < $2 "
- "ORDER BY expire "
- "LIMIT $3"},
+ "extract(epoch from expire)::bigint, subnet_id, pref_lifetime, "
+ "lease_type, iaid, prefix_len, "
+ "fqdn_fwd, fqdn_rev, hostname, "
+ "state "
+ "FROM lease6 "
+ "WHERE state != $1 AND expire < $2 "
+ "ORDER BY expire "
+ "LIMIT $3"},
// GET_VERSION
{ 0, { OID_NONE },
};
-
/// @brief Supports exchanging IPv4 leases with PostgreSQL.
class PgSqlLease4Exchange : public PgSqlLeaseExchange {
private:
valid_lifetime_, 0, 0, cltt_,
subnet_id_, fqdn_fwd_, fqdn_rev_,
hostname_));
+
result->state_ = state;
+
return (result);
} catch (const std::exception& ex) {
isc_throw(DbOperationError,
subnet_id_, fqdn_fwd_, fqdn_rev_,
hostname_, hwaddr, prefix_len_));
result->cltt_ = cltt_;
+
result->state_ = state;
+
return (result);
} catch (const std::exception& ex) {
isc_throw(DbOperationError,
}
}
-
void
PgSqlLeaseMgr::getLease(StatementIndex stindex, PsqlBindArray& bind_array,
Lease4Ptr& result) const {
}
}
-
void
PgSqlLeaseMgr::getLease(StatementIndex stindex, PsqlBindArray& bind_array,
Lease6Ptr& result) const {
getLeaseCollection(statement_index, bind_array, expired_leases);
}
-
template<typename LeasePtr>
void
PgSqlLeaseMgr::updateLeaseCommon(StatementIndex stindex,
"that had the address " << lease->addr_.toText());
}
-
void
PgSqlLeaseMgr::updateLease4(const Lease4Ptr& lease) {
const StatementIndex stindex = UPDATE_LEASE4;