aboutsummaryrefslogtreecommitdiffstats
path: root/src/pluto/kernel.c
diff options
context:
space:
mode:
authorTobias Brunner <tobias@strongswan.org>2010-07-29 11:01:30 +0200
committerTobias Brunner <tobias@strongswan.org>2010-09-02 19:04:20 +0200
commit3ecf66c9e324837768a9f39d3db8f98654c742ae (patch)
tree45a0c7c62a53e4a203bbf41c7896646a78e21327 /src/pluto/kernel.c
parent952487d6890031224195ca0ba8df0e7f2b072261 (diff)
downloadstrongswan-3ecf66c9e324837768a9f39d3db8f98654c742ae.tar.bz2
strongswan-3ecf66c9e324837768a9f39d3db8f98654c742ae.tar.xz
pluto: Adapted sag_eroute to the new signature of eroute_connection.
Diffstat (limited to 'src/pluto/kernel.c')
-rw-r--r--src/pluto/kernel.c61
1 files changed, 18 insertions, 43 deletions
diff --git a/src/pluto/kernel.c b/src/pluto/kernel.c
index 0ed8e7702..86f20841e 100644
--- a/src/pluto/kernel.c
+++ b/src/pluto/kernel.c
@@ -1240,32 +1240,20 @@ bool assign_hold(connection_t *c USED_BY_DEBUG, struct spd_route *sr,
static bool sag_eroute(struct state *st, struct spd_route *sr,
unsigned op, const char *opname)
{
- u_int inner_proto = 0;
- u_int inner_satype = 0;
+ u_int inner_proto, inner_satype;
ipsec_spi_t inner_spi = 0;
- struct pfkey_proto_info proto_info[4];
- int i;
- bool tunnel;
-
- /* figure out the SPI and protocol (in two forms)
- * for the innermost transformation.
- */
-
- i = sizeof(proto_info) / sizeof(proto_info[0]) - 1;
- proto_info[i].proto = 0;
- tunnel = FALSE;
+ struct kernel_proto_info proto_info = {
+ .mode = MODE_TRANSPORT,
+ };
+ bool tunnel = FALSE;
if (st->st_ah.present)
{
inner_spi = st->st_ah.attrs.spi;
inner_proto = SA_AH;
inner_satype = SADB_SATYPE_AH;
-
- i--;
- proto_info[i].proto = IPPROTO_AH;
- proto_info[i].encapsulation = st->st_ah.attrs.encapsulation;
- tunnel |= proto_info[i].encapsulation == ENCAPSULATION_MODE_TUNNEL;
- proto_info[i].reqid = sr->reqid;
+ proto_info.ah_spi = inner_spi;
+ tunnel |= st->st_ah.attrs.encapsulation == ENCAPSULATION_MODE_TUNNEL;
}
if (st->st_esp.present)
@@ -1273,12 +1261,8 @@ static bool sag_eroute(struct state *st, struct spd_route *sr,
inner_spi = st->st_esp.attrs.spi;
inner_proto = SA_ESP;
inner_satype = SADB_SATYPE_ESP;
-
- i--;
- proto_info[i].proto = IPPROTO_ESP;
- proto_info[i].encapsulation = st->st_esp.attrs.encapsulation;
- tunnel |= proto_info[i].encapsulation == ENCAPSULATION_MODE_TUNNEL;
- proto_info[i].reqid = sr->reqid + 1;
+ proto_info.esp_spi = inner_spi;
+ tunnel |= st->st_esp.attrs.encapsulation == ENCAPSULATION_MODE_TUNNEL;
}
if (st->st_ipcomp.present)
@@ -1286,37 +1270,28 @@ static bool sag_eroute(struct state *st, struct spd_route *sr,
inner_spi = st->st_ipcomp.attrs.spi;
inner_proto = SA_COMP;
inner_satype = SADB_X_SATYPE_COMP;
-
- i--;
- proto_info[i].proto = IPPROTO_COMP;
- proto_info[i].encapsulation = st->st_ipcomp.attrs.encapsulation;
- tunnel |= proto_info[i].encapsulation == ENCAPSULATION_MODE_TUNNEL;
- proto_info[i].reqid = sr->reqid + 2;
+ proto_info.cpi = htons(ntohl(inner_spi));
+ proto_info.ipcomp = st->st_ipcomp.attrs.transid;
+ tunnel |= st->st_ipcomp.attrs.encapsulation == ENCAPSULATION_MODE_TUNNEL;
}
- if (i == sizeof(proto_info) / sizeof(proto_info[0]) - 1)
+ if (!inner_spi)
{
impossible(); /* no transform at all! */
}
if (tunnel)
{
- int j;
-
inner_spi = st->st_tunnel_out_spi;
inner_proto = SA_IPIP;
inner_satype = SADB_X_SATYPE_IPIP;
-
- proto_info[i].encapsulation = ENCAPSULATION_MODE_TUNNEL;
- for (j = i + 1; proto_info[j].proto; j++)
- {
- proto_info[j].encapsulation = ENCAPSULATION_MODE_TRANSPORT;
- }
+ proto_info.mode = MODE_TUNNEL;
}
- return eroute_connection(sr
- , inner_spi, inner_proto, inner_satype, proto_info + i
- , op, opname);
+ proto_info.reqid = sr->reqid;
+
+ return eroute_connection(sr, inner_spi, inner_proto, inner_satype,
+ &proto_info, op, opname);
}
/* compute a (host-order!) SPI to implement the policy in connection c */