fixed CHILD_SA rekeying/delete bug on 64bit machines

removed obsolete methods in delete_payload
This commit is contained in:
Martin Willi
2007-03-19 08:04:37 +00:00
parent 4a82b49126
commit e05a0b765a
3 changed files with 13 additions and 147 deletions
+8 -71
View File
@@ -195,14 +195,6 @@ static size_t get_length(private_delete_payload_t *this)
return this->payload_length;
}
/**
* Implementation of delete_payload_t.set_protocol_id.
*/
static void set_protocol_id (private_delete_payload_t *this, protocol_id_t protocol_id)
{
this->protocol_id = protocol_id;
}
/**
* Implementation of delete_payload_t.get_protocol_id.
*/
@@ -211,60 +203,6 @@ static protocol_id_t get_protocol_id (private_delete_payload_t *this)
return (this->protocol_id);
}
/**
* Implementation of delete_payload_t.set_spi_size.
*/
static void set_spi_size (private_delete_payload_t *this, u_int8_t spi_size)
{
this->spi_size = spi_size;
}
/**
* Implementation of delete_payload_t.get_spi_size.
*/
static u_int8_t get_spi_size (private_delete_payload_t *this)
{
return (this->spi_size);
}
/**
* Implementation of delete_payload_t.set_spi_count.
*/
static void set_spi_count (private_delete_payload_t *this, u_int16_t spi_count)
{
this->spi_count = spi_count;
}
/**
* Implementation of delete_payload_t.get_spi_count.
*/
static u_int16_t get_spi_count(private_delete_payload_t *this)
{
return (this->spi_count);
}
/**
* Implementation of delete_payload_t.set_spis.
*/
static void set_spis(private_delete_payload_t *this, chunk_t spis)
{
if (this->spis.ptr != NULL)
{
chunk_free(&(this->spis));
}
this->spis.ptr = clalloc(spis.ptr,spis.len);
this->spis.len = spis.len;
this->payload_length = DELETE_PAYLOAD_HEADER_LENGTH + this->spis.len;
}
/**
* Implementation of delete_payload_t.get_spis.
*/
static chunk_t get_spis (private_delete_payload_t *this)
{
return (this->spis);
}
/**
* Implementation of delete_payload_t.add_spi.
*/
@@ -277,6 +215,12 @@ static void add_spi(private_delete_payload_t *this, u_int32_t spi)
this->spis.len += this->spi_size;
this->spis.ptr = realloc(this->spis.ptr, this->spis.len);
*(u_int32_t*)(this->spis.ptr + (this->spis.len / this->spi_size - 1)) = spi;
if (this->spi_list)
{
/* reset SPI iterator list */
this->spi_list->destroy(this->spi_list);
this->spi_list = NULL;
}
}
}
@@ -295,8 +239,8 @@ static iterator_t* create_spi_iterator(private_delete_payload_t *this)
{
for (i = 0; i < this->spi_count; i++)
{
u_int32_t spi = *(u_int32_t*)(this->spis.ptr + i * this->spi_size);
this->spi_list->insert_last(this->spi_list, (void*)spi);
this->spi_list->insert_last(this->spi_list, this->spis.ptr + i *
this->spi_size);
}
}
}
@@ -337,14 +281,7 @@ delete_payload_t *delete_payload_create(protocol_id_t protocol_id)
/* public functions */
this->public.destroy = (void (*) (delete_payload_t *)) destroy;
this->public.set_protocol_id = (void (*) (delete_payload_t *,protocol_id_t)) set_protocol_id;
this->public.get_protocol_id = (protocol_id_t (*) (delete_payload_t *)) get_protocol_id;
this->public.set_spi_size = (void (*) (delete_payload_t *,u_int8_t)) set_spi_size;
this->public.get_spi_size = (u_int8_t (*) (delete_payload_t *)) get_spi_size;
this->public.set_spi_count = (void (*) (delete_payload_t *,u_int16_t)) set_spi_count;
this->public.get_spi_count = (u_int16_t (*) (delete_payload_t *)) get_spi_count;
this->public.set_spis = (void (*) (delete_payload_t *,chunk_t)) set_spis;
this->public.get_spis = (chunk_t (*) (delete_payload_t *)) get_spis;
this->public.add_spi = (void (*) (delete_payload_t *,u_int32_t))add_spi;
this->public.create_spi_iterator = (iterator_t* (*) (delete_payload_t *)) create_spi_iterator;
+2 -73
View File
@@ -54,16 +54,6 @@ struct delete_payload_t {
* The payload_t interface.
*/
payload_t payload_interface;
/**
* @brief Set the protocol ID.
*
* @param this calling delete_payload_t object
* @param protocol_id protocol ID
*
* @deprecated is set by constructor
*/
void (*set_protocol_id) (delete_payload_t *this, protocol_id_t protocol_id);
/**
* @brief Get the protocol ID.
@@ -73,66 +63,6 @@ struct delete_payload_t {
*/
protocol_id_t (*get_protocol_id) (delete_payload_t *this);
/**
* @brief Set the SPI size.
*
* @param this calling delete_payload_t object
* @param spi_size SPI size
*
* @deprecated is set by constructor
*/
void (*set_spi_size) (delete_payload_t *this, u_int8_t spi_size);
/**
* @brief Get the SPI size.
*
* @param this calling delete_payload_t object
* @return SPI size
*/
u_int8_t (*get_spi_size) (delete_payload_t *this);
/**
* @brief Set the SPI count.
*
* @param this calling delete_payload_t object
* @param spi_count SPI count
*
* @deprecated is incremented via add_spi
*/
void (*set_spi_count) (delete_payload_t *this, u_int16_t spi_count);
/**
* @brief Get the SPI count.
*
* @param this calling delete_payload_t object
* @return Number of SPI's
*/
u_int16_t (*get_spi_count) (delete_payload_t *this);
/**
* @brief Set the SPI's.
*
* Data are getting cloned.
*
* @param this calling delete_payload_t object
* @param data SPI's as chunk_t
*
* @deprecated use add_spi
*/
void (*set_spis) (delete_payload_t *this, chunk_t spis);
/**
* @brief Get the SPI's.
*
* Returned data are NOT copied.
*
* @param this calling delete_payload_t object
* @return SPI's as chunk_t
*
* @deprecated use create_spi_iterator
*/
chunk_t (*get_spis) (delete_payload_t *this);
/**
* @brief Add an SPI to the list of deleted SAs.
*
@@ -143,9 +73,8 @@ struct delete_payload_t {
/**
* @brief Get an iterator over the SPIs.
*
* The resulting interators current() function returns
* u_int32_t SPIs directly.
*
* The iterate() function returns a pointer to a u_int32_t SPI.
*
* @param this calling delete_payload_t object
* @return iterator over SPIs
+3 -3
View File
@@ -102,7 +102,7 @@ static void process_payloads(private_child_delete_t *this, message_t *message)
iterator_t *payloads, *spis;
payload_t *payload;
delete_payload_t *delete_payload;
u_int32_t spi;
u_int32_t *spi;
protocol_id_t protocol;
child_sa_t *child_sa;
@@ -121,11 +121,11 @@ static void process_payloads(private_child_delete_t *this, message_t *message)
while (spis->iterate(spis, (void**)&spi))
{
child_sa = this->ike_sa->get_child_sa(this->ike_sa, protocol,
spi, FALSE);
*spi, FALSE);
if (child_sa == NULL)
{
DBG1(DBG_IKE, "received DELETE for %N CHILD_SA with SPI 0x%x, "
"but no such SA", protocol_id_names, protocol, ntohl(spi));
"but no such SA", protocol_id_names, protocol, ntohl(*spi));
break;
}