2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-09-05 16:35:23 +00:00

[#2869] Implemented new deletes

This commit is contained in:
Francis Dupont
2023-05-25 02:29:39 +02:00
parent 5415988d92
commit 5ab389783d
4 changed files with 146 additions and 4 deletions

View File

@@ -3812,8 +3812,69 @@ MySqlLeaseMgr::checkError(MySqlLeaseContextPtr& ctx,
}
void
MySqlLeaseMgr::deleteExtendedInfo6(const IOAddress& /* addr */) {
isc_throw(NotImplemented, "MySqlLeaseMgr::deleteExtendedInfo6 not implemented");
MySqlLeaseMgr::deleteExtendedInfo6(const IOAddress& addr) {
deleteRelayId6(addr);
deleteRemoteId6(addr);
}
void
MySqlLeaseMgr::deleteRelayId6(const IOAddress& addr) {
// Get a context.
MySqlLeaseContextAlloc get_context(*this);
MySqlLeaseContextPtr ctx = get_context.ctx_;
// Bind the lease address.
MYSQL_BIND bind[1];
memset(bind, 0, sizeof(bind));
std::vector<uint8_t> addr_data = addr.toBytes();
// Do not check the address length as it does not really matter.
unsigned long addr_length = addr_data.size();
bind[0].buffer_type = MYSQL_TYPE_BLOB;
bind[0].buffer = reinterpret_cast<char*>(&addr_data[0]);
bind[0].buffer_length = addr_length;
bind[0].length = &addr_length;
// Delete from lease6_relay_id table.
StatementIndex stindex = DELETE_RELAY_ID6;
// Bind the input parameters to the statement.
int status = mysql_stmt_bind_param(ctx->conn_.statements_[stindex], bind);
checkError(ctx, status, stindex, "unable to bind WHERE clause parameter");
// Execute.
status = MysqlExecuteStatement(ctx->conn_.statements_[stindex]);
checkError(ctx, status, stindex, "unable to execute");
}
void
MySqlLeaseMgr::deleteRemoteId6(const IOAddress& addr) {
// Get a context.
MySqlLeaseContextAlloc get_context(*this);
MySqlLeaseContextPtr ctx = get_context.ctx_;
// Bind the lease address.
MYSQL_BIND bind[1];
memset(bind, 0, sizeof(bind));
std::vector<uint8_t> addr_data = addr.toBytes();
// Do not check the address length as it does not really matter.
unsigned long addr_length = addr_data.size();
bind[0].buffer_type = MYSQL_TYPE_BLOB;
bind[0].buffer = reinterpret_cast<char*>(&addr_data[0]);
bind[0].buffer_length = addr_length;
bind[0].length = &addr_length;
// Delete from lease6_remote_id table.
StatementIndex stindex = DELETE_REMOTE_ID6;
// Bind the input parameters to the statement.
int status = mysql_stmt_bind_param(ctx->conn_.statements_[stindex], bind);
checkError(ctx, status, stindex, "unable to bind WHERE clause parameter");
// Execute.
status = MysqlExecuteStatement(ctx->conn_.statements_[stindex]);
checkError(ctx, status, stindex, "unable to execute");
}
void