host_t *dst;
/**
- * SPI of CHILD SA.
+ * Local SPI of CHILD SA.
*/
- u_int32_t spi;
+ u_int32_t spi_loc;
+
+ /**
+ * Remote SPI of CHILD SA.
+ */
+ u_int32_t spi_rem;
/**
* Protocol of CHILD SA (ESP/AH).
}
/**
- * Find a list entry with given src, dst, spi and proto values.
+ * Find a list entry with given src, dst, (remote) spi and proto values.
*/
static bool sad_entry_match(sad_entry_t * const entry, const host_t * const src,
const host_t * const dst, const u_int32_t * const spi,
return src->ip_equals(entry->src, (host_t *)src) &&
dst->ip_equals(entry->dst, (host_t *)dst) &&
- entry->spi == *spi && entry->proto == *proto;
+ entry->spi_rem == *spi && entry->proto == *proto;
}
/**
const u_int32_t * const spi,
const u_int8_t * const proto)
{
- return entry->reqid == *reqid &&
- entry->spi == *spi &&
- entry->proto == *proto;
+ return entry->reqid == *reqid &&
+ entry->spi_rem == *spi &&
+ entry->proto == *proto;
}
/**
left->reqid == right->reqid &&
left->src->ip_equals(left->src, right->src) &&
left->dst->ip_equals(left->dst, right->dst) &&
- left->spi == right->spi && left->proto == right->proto;
+ left->spi_loc == right->spi_loc &&
+ left->spi_rem == right->spi_rem &&
+ left->proto == right->proto;
}
METHOD(tkm_kernel_sad_t, insert, bool,
private_tkm_kernel_sad_t * const this, const esa_id_type esa_id,
const u_int32_t reqid, const host_t * const src, const host_t * const dst,
- const u_int32_t spi, const u_int8_t proto)
+ const u_int32_t spi_loc, const u_int32_t spi_rem, const u_int8_t proto)
{
status_t result;
sad_entry_t *new_entry;
.reqid = reqid,
.src = (host_t *)src,
.dst = (host_t *)dst,
- .spi = spi,
+ .spi_loc = spi_loc,
+ .spi_rem = spi_rem,
.proto = proto,
);
if (result == NOT_FOUND)
{
DBG3(DBG_KNL, "inserting SAD entry (esa: %llu, reqid: %u, src: %H, "
- "dst: %H, spi: %x, proto: %u)", esa_id, reqid, src, dst,
- ntohl(spi), proto);
+ "dst: %H, spi_loc: %x, spi_rem: %x,proto: %u)", esa_id, reqid, src,
+ dst, ntohl(spi_loc), ntohl(spi_rem), proto);
new_entry->src = src->clone((host_t *)src);
new_entry->dst = dst->clone((host_t *)dst);
this->data->insert_last(this->data, new_entry);
* @param reqid reqid of the SA
* @param src source address of CHILD SA
* @param dst destination address of CHILD SA
- * @param spi SPI of CHILD SA
+ * @param spi_loc Local SPI of CHILD SA
+ * @param spi_rem Remote SPI of CHILD SA
* @param proto protocol of CHILD SA (ESP/AH)
* @return TRUE if entry was inserted, FALSE otherwise
*/
bool (*insert)(tkm_kernel_sad_t * const this, const esa_id_type esa_id,
const u_int32_t reqid, const host_t * const src,
- const host_t * const dst, const u_int32_t spi,
- const u_int8_t proto);
+ const host_t * const dst, const u_int32_t spi_loc,
+ const u_int32_t spi_rem, const u_int8_t proto);
/**
* Get ESA id for entry with given parameters.
*
* @param src source address of CHILD SA
* @param dst destination address of CHILD SA
- * @param spi SPI of CHILD SA
+ * @param spi Remote SPI of CHILD SA
* @param proto protocol of CHILD SA (ESP/AH)
* @return ESA id of entry if found, 0 otherwise
*/
* Get destination host for entry with given parameters.
*
* @param reqid reqid of CHILD SA
- * @param spi SPI of CHILD SA
+ * @param spi Remote SPI of CHILD SA
* @param proto protocol of CHILD SA (ESP/AH)
* @return destination host of entry if found, NULL otherwise
*/
host_t *addr = host_create_from_string("127.0.0.1", 1024);
tkm_kernel_sad_t *sad = tkm_kernel_sad_create();
- fail_unless(sad->insert(sad, 1, 2, addr, addr, 42, 50),
+ fail_unless(sad->insert(sad, 1, 2, addr, addr, 27, 42, 50),
"Error inserting SAD entry");
sad->destroy(sad);
host_t *addr = host_create_from_string("127.0.0.1", 1024);
tkm_kernel_sad_t *sad = tkm_kernel_sad_create();
- fail_unless(sad->insert(sad, 1, 2, addr, addr, 42, 50),
+ fail_unless(sad->insert(sad, 1, 2, addr, addr, 27, 42, 50),
"Error inserting SAD entry");
- fail_if(sad->insert(sad, 1, 2, addr, addr, 42, 50),
+ fail_if(sad->insert(sad, 1, 2, addr, addr, 27, 42, 50),
"Expected error inserting duplicate entry");
sad->destroy(sad);
{
host_t *addr = host_create_from_string("127.0.0.1", 1024);
tkm_kernel_sad_t *sad = tkm_kernel_sad_create();
- fail_unless(sad->insert(sad, 23, 54, addr, addr, 42, 50),
+ fail_unless(sad->insert(sad, 23, 54, addr, addr, 27, 42, 50),
"Error inserting SAD entry");
fail_unless(sad->get_esa_id(sad, addr, addr, 42, 50) == 23,
"Error getting esa id");
{
host_t *addr = host_create_from_string("127.0.0.1", 1024);
tkm_kernel_sad_t *sad = tkm_kernel_sad_create();
- fail_unless(sad->insert(sad, 23, 54, addr, addr, 42, 50),
+ fail_unless(sad->insert(sad, 23, 54, addr, addr, 27, 42, 50),
"Error inserting SAD entry");
- fail_unless(sad->insert(sad, 24, 54, addr, addr, 42, 50),
+ fail_unless(sad->insert(sad, 24, 54, addr, addr, 27, 42, 50),
"Error inserting SAD entry");
fail_unless(sad->get_other_esa_id(sad, 23) == 24,
"Error getting other esa id");
tkm_kernel_sad_t *sad = tkm_kernel_sad_create();
fail_unless(sad->get_other_esa_id(sad, 1) == 0,
"Got other esa id for nonexistent SAD entry");
- fail_unless(sad->insert(sad, 23, 54, addr, addr, 42, 50),
+ fail_unless(sad->insert(sad, 23, 54, addr, addr, 27, 42, 50),
"Error inserting SAD entry");
fail_unless(sad->get_other_esa_id(sad, 23) == 0,
"Got own esa id");
{
host_t *addr = host_create_from_string("127.0.0.1", 1024);
tkm_kernel_sad_t *sad = tkm_kernel_sad_create();
- fail_unless(sad->insert(sad, 23, 54, addr, addr, 42, 50),
+ fail_unless(sad->insert(sad, 23, 54, addr, addr, 27, 42, 50),
"Error inserting SAD entry");
host_t *dst = sad->get_dst_host(sad, 54, 42, 50);
{
host_t *addr = host_create_from_string("127.0.0.1", 1024);
tkm_kernel_sad_t *sad = tkm_kernel_sad_create();
- fail_unless(sad->insert(sad, 23, 54, addr, addr, 42, 50),
+ fail_unless(sad->insert(sad, 23, 54, addr, addr, 27, 42, 50),
"Error inserting SAD entry");
fail_unless(sad->get_esa_id(sad, addr, addr, 42, 50) == 23,
"Error getting esa id");