merging changes from portability branch back to trunk
important change for developers: %Y replaces %D to print identities!
This commit is contained in:
@@ -374,6 +374,24 @@ static protocol_id_t proto_kernel2ike(u_int8_t proto)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* convert the general ipsec mode to the one defined in xfrm.h
|
||||
*/
|
||||
static u_int8_t mode2kernel(ipsec_mode_t mode)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case MODE_TRANSPORT:
|
||||
return XFRM_MODE_TRANSPORT;
|
||||
case MODE_TUNNEL:
|
||||
return XFRM_MODE_TUNNEL;
|
||||
case MODE_BEET:
|
||||
return XFRM_MODE_BEET;
|
||||
default:
|
||||
return mode;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* convert a host_t to a struct xfrm_address
|
||||
*/
|
||||
@@ -803,7 +821,7 @@ static status_t get_spi_internal(private_kernel_netlink_ipsec_t *this,
|
||||
host2xfrm(src, &userspi->info.saddr);
|
||||
host2xfrm(dst, &userspi->info.id.daddr);
|
||||
userspi->info.id.proto = proto;
|
||||
userspi->info.mode = TRUE; /* tunnel mode */
|
||||
userspi->info.mode = XFRM_MODE_TUNNEL;
|
||||
userspi->info.reqid = reqid;
|
||||
userspi->info.family = src->get_family(src);
|
||||
userspi->min = min;
|
||||
@@ -941,7 +959,7 @@ static status_t add_sa(private_kernel_netlink_ipsec_t *this,
|
||||
sa->id.spi = spi;
|
||||
sa->id.proto = proto_ike2kernel(protocol);
|
||||
sa->family = src->get_family(src);
|
||||
sa->mode = mode;
|
||||
sa->mode = mode2kernel(mode);
|
||||
if (mode == MODE_TUNNEL)
|
||||
{
|
||||
sa->flags |= XFRM_STATE_AF_UNSPEC;
|
||||
@@ -1216,8 +1234,9 @@ static status_t get_replay_state(private_kernel_netlink_ipsec_t *this,
|
||||
/**
|
||||
* Implementation of kernel_interface_t.del_sa.
|
||||
*/
|
||||
static status_t del_sa(private_kernel_netlink_ipsec_t *this, host_t *dst,
|
||||
u_int32_t spi, protocol_id_t protocol, u_int16_t cpi)
|
||||
static status_t del_sa(private_kernel_netlink_ipsec_t *this, host_t *src,
|
||||
host_t *dst, u_int32_t spi, protocol_id_t protocol,
|
||||
u_int16_t cpi)
|
||||
{
|
||||
netlink_buf_t request;
|
||||
struct nlmsghdr *hdr;
|
||||
@@ -1226,7 +1245,7 @@ static status_t del_sa(private_kernel_netlink_ipsec_t *this, host_t *dst,
|
||||
/* if IPComp was used, we first delete the additional IPComp SA */
|
||||
if (cpi)
|
||||
{
|
||||
del_sa(this, dst, htonl(ntohs(cpi)), IPPROTO_COMP, 0);
|
||||
del_sa(this, src, dst, htonl(ntohs(cpi)), IPPROTO_COMP, 0);
|
||||
}
|
||||
|
||||
memset(&request, 0, sizeof(request));
|
||||
@@ -1339,7 +1358,7 @@ static status_t update_sa(private_kernel_netlink_ipsec_t *this,
|
||||
}
|
||||
|
||||
/* delete the old SA (without affecting the IPComp SA) */
|
||||
if (del_sa(this, dst, spi, protocol, 0) != SUCCESS)
|
||||
if (del_sa(this, src, dst, spi, protocol, 0) != SUCCESS)
|
||||
{
|
||||
DBG1(DBG_KNL, "unable to delete old SAD entry with SPI %.8x", ntohl(spi));
|
||||
free(out);
|
||||
@@ -1526,7 +1545,7 @@ static status_t add_policy(private_kernel_netlink_ipsec_t *this,
|
||||
tmpl->reqid = reqid;
|
||||
tmpl->id.proto = IPPROTO_COMP;
|
||||
tmpl->aalgos = tmpl->ealgos = tmpl->calgos = ~0;
|
||||
tmpl->mode = mode;
|
||||
tmpl->mode = mode2kernel(mode);
|
||||
tmpl->optional = direction != POLICY_OUT;
|
||||
tmpl->family = src->get_family(src);
|
||||
|
||||
@@ -1547,7 +1566,7 @@ static status_t add_policy(private_kernel_netlink_ipsec_t *this,
|
||||
tmpl->reqid = reqid;
|
||||
tmpl->id.proto = proto_ike2kernel(protocol);
|
||||
tmpl->aalgos = tmpl->ealgos = tmpl->calgos = ~0;
|
||||
tmpl->mode = mode;
|
||||
tmpl->mode = mode2kernel(mode);
|
||||
tmpl->family = src->get_family(src);
|
||||
|
||||
host2xfrm(src, &tmpl->saddr);
|
||||
@@ -1871,7 +1890,7 @@ kernel_netlink_ipsec_t *kernel_netlink_ipsec_create()
|
||||
this->public.interface.get_cpi = (status_t(*)(kernel_ipsec_t*,host_t*,host_t*,u_int32_t,u_int16_t*))get_cpi;
|
||||
this->public.interface.add_sa = (status_t(*)(kernel_ipsec_t *,host_t*,host_t*,u_int32_t,protocol_id_t,u_int32_t,u_int64_t,u_int64_t,u_int16_t,chunk_t,u_int16_t,chunk_t,ipsec_mode_t,u_int16_t,u_int16_t,bool,bool))add_sa;
|
||||
this->public.interface.update_sa = (status_t(*)(kernel_ipsec_t*,u_int32_t,protocol_id_t,u_int16_t,host_t*,host_t*,host_t*,host_t*,bool,bool))update_sa;
|
||||
this->public.interface.del_sa = (status_t(*)(kernel_ipsec_t*,host_t*,u_int32_t,protocol_id_t,u_int16_t))del_sa;
|
||||
this->public.interface.del_sa = (status_t(*)(kernel_ipsec_t*,host_t*,host_t*,u_int32_t,protocol_id_t,u_int16_t))del_sa;
|
||||
this->public.interface.add_policy = (status_t(*)(kernel_ipsec_t*,host_t*,host_t*,traffic_selector_t*,traffic_selector_t*,policy_dir_t,u_int32_t,protocol_id_t,u_int32_t,ipsec_mode_t,u_int16_t,u_int16_t,bool))add_policy;
|
||||
this->public.interface.query_policy = (status_t(*)(kernel_ipsec_t*,traffic_selector_t*,traffic_selector_t*,policy_dir_t,u_int32_t*))query_policy;
|
||||
this->public.interface.del_policy = (status_t(*)(kernel_ipsec_t*,traffic_selector_t*,traffic_selector_t*,policy_dir_t,bool))del_policy;
|
||||
|
||||
Reference in New Issue
Block a user