pluto: Migrated update_ipsec_sa to libhydra's kernel interface.
This commit is contained in:
+21
-20
@@ -2546,31 +2546,32 @@ void delete_ipsec_sa(struct state *st USED_BY_KLIPS,
|
|||||||
static bool update_nat_t_ipsec_esp_sa (struct state *st, bool inbound)
|
static bool update_nat_t_ipsec_esp_sa (struct state *st, bool inbound)
|
||||||
{
|
{
|
||||||
connection_t *c = st->st_connection;
|
connection_t *c = st->st_connection;
|
||||||
char text_said[SATOT_BUF];
|
host_t *host_src, *host_dst, *new_src, *new_dst;
|
||||||
struct kernel_sa sa;
|
mark_t mark_none = { 0, 0 };
|
||||||
ip_address
|
bool result;
|
||||||
src = inbound? c->spd.that.host_addr : c->spd.this.host_addr,
|
ipsec_spi_t spi = inbound ? st->st_esp.our_spi : st->st_esp.attrs.spi;
|
||||||
dst = inbound? c->spd.this.host_addr : c->spd.that.host_addr;
|
struct end *src = inbound ? &c->spd.that : &c->spd.this,
|
||||||
|
*dst = inbound ? &c->spd.this : &c->spd.that;
|
||||||
|
|
||||||
ipsec_spi_t esp_spi = inbound? st->st_esp.our_spi : st->st_esp.attrs.spi;
|
host_src = host_create_from_sockaddr((sockaddr_t*)&src->host_addr);
|
||||||
|
host_dst = host_create_from_sockaddr((sockaddr_t*)&dst->host_addr);
|
||||||
|
|
||||||
u_int16_t
|
new_src = host_src->clone(host_src);
|
||||||
natt_sport = inbound? c->spd.that.host_port : c->spd.this.host_port,
|
new_dst = host_dst->clone(host_dst);
|
||||||
natt_dport = inbound? c->spd.this.host_port : c->spd.that.host_port;
|
new_src->set_port(new_src, src->host_port);
|
||||||
|
new_dst->set_port(new_dst, dst->host_port);
|
||||||
|
|
||||||
set_text_said(text_said, &dst, esp_spi, SA_ESP);
|
result = hydra->kernel_interface->update_sa(hydra->kernel_interface,
|
||||||
|
spi, IPPROTO_ESP, 0 /* cpi */, host_src, host_dst,
|
||||||
|
new_src, new_dst, TRUE /* encap */, TRUE /* new_encap */,
|
||||||
|
mark_none) == SUCCESS;
|
||||||
|
|
||||||
memset(&sa, 0, sizeof(sa));
|
host_src->destroy(host_src);
|
||||||
sa.spi = esp_spi;
|
host_dst->destroy(host_dst);
|
||||||
sa.src = &src;
|
new_src->destroy(new_src);
|
||||||
sa.dst = &dst;
|
new_dst->destroy(new_dst);
|
||||||
sa.text_said = text_said;
|
|
||||||
sa.authalg = alg_info_esp_aa2sadb(st->st_esp.attrs.auth);
|
|
||||||
sa.natt_sport = natt_sport;
|
|
||||||
sa.natt_dport = natt_dport;
|
|
||||||
sa.transid = st->st_esp.attrs.transid;
|
|
||||||
|
|
||||||
return kernel_ops->add_sa(&sa, TRUE);
|
return result;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user