"lease_type, iaid, prefix_len, "
"fqdn_fwd, fqdn_rev, hostname, "
"hwaddr, hwtype, hwaddr_source, "
- "state, user_context) "
- "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"},
+ "state, user_context, binaddr) "
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"},
{MySqlLeaseMgr::UPDATE_LEASE4,
"UPDATE lease4 SET address = ?, hwaddr = ?, "
"client_id = ?, valid_lifetime = ?, expire = ?, "
"pref_lifetime = ?, lease_type = ?, iaid = ?, "
"prefix_len = ?, fqdn_fwd = ?, fqdn_rev = ?, "
"hostname = ?, hwaddr = ?, hwtype = ?, hwaddr_source = ?, "
- "state = ?, user_context = ? "
+ "state = ?, user_context = ?, binaddr = ? "
"WHERE address = ? AND expire = ?"},
{MySqlLeaseMgr::ALL_LEASE4_STATS,
"SELECT subnet_id, state, leases as state_count "
class MySqlLease6Exchange : public MySqlLeaseExchange {
/// @brief Set number of database columns for this lease structure
- static const size_t LEASE_COLUMNS = 17;
+ static const size_t LEASE_COLUMNS = 18;
public:
fqdn_fwd_(false), fqdn_rev_(false),
hostname_length_(0), hwtype_(0), hwaddr_source_(0),
state_(0), user_context_length_(0),
- user_context_null_(MLM_FALSE) {
+ user_context_null_(MLM_FALSE), binaddr_length_(16) {
memset(addr6_buffer_, 0, sizeof(addr6_buffer_));
memset(duid_buffer_, 0, sizeof(duid_buffer_));
memset(hostname_buffer_, 0, sizeof(hostname_buffer_));
columns_[14] = "hwaddr_source";
columns_[15] = "state";
columns_[16] = "user_context";
- BOOST_STATIC_ASSERT(16 < LEASE_COLUMNS);
+ columns_[17] = "binaddr";
+ BOOST_STATIC_ASSERT(17 < LEASE_COLUMNS);
}
/// @brief Create MYSQL_BIND objects for Lease6 Pointer
bind_[9].buffer_type = MYSQL_TYPE_TINY;
bind_[9].buffer = reinterpret_cast<char*>(&lease_->fqdn_fwd_);
bind_[9].is_unsigned = MLM_TRUE;
- // bind_[7].is_null = &MLM_FALSE; // commented out for performance
+ // bind_[9].is_null = &MLM_FALSE; // commented out for performance
// reasons, see memset() above
// fqdn_rev: boolean
bind_[16].buffer_type = MYSQL_TYPE_NULL;
}
+ // binaddr: binary(16)
+ binaddr_ = lease->addr_.toBytes();
+ if (binaddr_.size() != 16) {
+ isc_throw(DbOperationError, "lease6 address is not 16 byte long");
+ }
+
+ binaddr_length_ = 16;
+ bind_[17].buffer_type = MYSQL_TYPE_BLOB;
+ bind_[17].buffer = reinterpret_cast<char*>(&binaddr_[0]);
+ bind_[17].buffer_length = 16;
+ bind_[17].length = &binaddr_length_;
+ // bind_[17].is_null = &MLM_FALSE; // commented out for performance
+ // reasons, see memset() above
+
// Add the error flags
setErrorIndicators(bind_, error_, LEASE_COLUMNS);
// .. and check that we have the numbers correct at compile time.
- BOOST_STATIC_ASSERT(16 < LEASE_COLUMNS);
+ BOOST_STATIC_ASSERT(17 < LEASE_COLUMNS);
} catch (const std::exception& ex) {
isc_throw(DbOperationError,
bind_[16].is_null = &user_context_null_;
// Add the error flags
- setErrorIndicators(bind_, error_, LEASE_COLUMNS);
+ setErrorIndicators(bind_, error_, LEASE_COLUMNS - 1);
// .. and check that we have the numbers correct at compile time.
- BOOST_STATIC_ASSERT(16 < LEASE_COLUMNS);
+ BOOST_STATIC_ASSERT(16 < LEASE_COLUMNS - 1);
// Add the data to the vector. Note the end element is one after the
// end of the array.
- return (std::vector<MYSQL_BIND>(&bind_[0], &bind_[LEASE_COLUMNS]));
+ return (std::vector<MYSQL_BIND>(&bind_[0], &bind_[LEASE_COLUMNS - 1]));
}
/// @brief Copy Received Data into Lease6 Object
char user_context_[USER_CONTEXT_MAX_LEN]; ///< User context
unsigned long user_context_length_; ///< Length of user context
my_bool user_context_null_; ///< Used when user context is null
+ std::vector<uint8_t> binaddr_; ///< Binary address
+ unsigned long binaddr_length_; ///< Length of binary data
};
/// @brief MySql derivation of the statistical lease data query
"VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13)"},
// INSERT_LEASE6
- { 17, { OID_VARCHAR, OID_BYTEA, OID_INT8, OID_TIMESTAMP, OID_INT8,
+ { 18, { OID_VARCHAR, OID_BYTEA, OID_INT8, OID_TIMESTAMP, OID_INT8,
OID_INT8, OID_INT2, OID_INT8, OID_INT2, OID_BOOL, OID_BOOL,
- OID_VARCHAR, OID_BYTEA, OID_INT2, OID_INT2, OID_INT8, OID_TEXT },
+ OID_VARCHAR, OID_BYTEA, OID_INT2, OID_INT2, OID_INT8, OID_TEXT,
+ OID_BYTEA },
"insert_lease6",
"INSERT INTO lease6(address, duid, valid_lifetime, "
"expire, subnet_id, pref_lifetime, "
"lease_type, iaid, prefix_len, fqdn_fwd, fqdn_rev, hostname, "
"hwaddr, hwtype, hwaddr_source, "
- "state, user_context) "
- "VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17)"},
+ "state, user_context, binaddr) "
+ "VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18)"},
// UPDATE_LEASE4
{ 15, { OID_INT8, OID_BYTEA, OID_BYTEA, OID_INT8, OID_TIMESTAMP, OID_INT8,
"WHERE address = $14 AND expire = $15"},
// UPDATE_LEASE6
- { 19, { OID_VARCHAR, OID_BYTEA, OID_INT8, OID_TIMESTAMP, OID_INT8, OID_INT8,
+ { 20, { OID_VARCHAR, OID_BYTEA, OID_INT8, OID_TIMESTAMP, OID_INT8, OID_INT8,
OID_INT2, OID_INT8, OID_INT2, OID_BOOL, OID_BOOL, OID_VARCHAR,
OID_BYTEA, OID_INT2, OID_INT2,
- OID_INT8, OID_TEXT, OID_VARCHAR, OID_TIMESTAMP },
+ OID_INT8, OID_TEXT, OID_BYTEA, OID_VARCHAR, OID_TIMESTAMP },
"update_lease6",
"UPDATE lease6 SET address = $1, duid = $2, "
"valid_lifetime = $3, expire = $4, subnet_id = $5, "
"pref_lifetime = $6, lease_type = $7, iaid = $8, "
"prefix_len = $9, fqdn_fwd = $10, fqdn_rev = $11, hostname = $12, "
"hwaddr = $13, hwtype = $14, hwaddr_source = $15, "
- "state = $16, user_context = $17 "
- "WHERE address = $18 AND expire = $19"},
+ "state = $16, user_context = $17, binaddr = $18 "
+ "WHERE address = $19 AND expire = $20"},
// ALL_LEASE4_STATS
{ 0, { OID_NONE },
valid_lifetime_(0), valid_lifetime_str_(""), expire_(0),
expire_str_(""), subnet_id_(0), subnet_id_str_(""), cltt_(0),
fqdn_fwd_(false), fqdn_rev_(false), hostname_(""), state_str_(""),
- user_context_("") {
+ user_context_(""), addr_bin_(16) {
}
virtual ~PgSqlLeaseExchange(){}
std::string hostname_;
std::string state_str_;
std::string user_context_;
+ std::vector<uint8_t> addr_bin_;
//@}
};
: lease_(), addr4_(0), client_id_length_(0),
relay_id_length_(0), remote_id_length_(0) {
- BOOST_STATIC_ASSERT(9 < LEASE_COLUMNS);
+ BOOST_STATIC_ASSERT(12 < LEASE_COLUMNS);
memset(hwaddr_buffer_, 0, sizeof(hwaddr_buffer_));
memset(client_id_buffer_, 0, sizeof(client_id_buffer_));
static const int HWTYPE_COL = 13;
static const int HWADDR_SOURCE_COL = 14;
static const int STATE_COL = 15;
- static const size_t USER_CONTEXT_COL = 16;
+ static const int USER_CONTEXT_COL = 16;
+ static const int BINADDR_COL = 17;
//@}
/// @brief Number of columns in the table holding DHCPv6 leases.
- static const size_t LEASE_COLUMNS = 17;
+ static const size_t LEASE_COLUMNS = 18;
public:
preferred_lifetime_str_(""), hwtype_(0), hwtype_str_(""),
hwaddr_source_(0), hwaddr_source_str_("") {
- BOOST_STATIC_ASSERT(15 < LEASE_COLUMNS);
+ BOOST_STATIC_ASSERT(17 < LEASE_COLUMNS);
memset(duid_buffer_, 0, sizeof(duid_buffer_));
columns_.push_back("hwaddr_source");
columns_.push_back("state");
columns_.push_back("user_context");
+ columns_.push_back("binaddr");
}
/// @brief Creates the bind array for sending Lease6 data to the database.
user_context_ = "";
}
bind_array.add(user_context_);
+
+ addr_bin_ = lease_->addr_.toBytes();
+ bind_array.add(addr_bin_);
} catch (const std::exception& ex) {
isc_throw(DbOperationError,
"Could not create bind array from Lease6: "