pluto: Adapted sag_eroute to the new signature of eroute_connection.
This commit is contained in:
+18
-43
@@ -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,
|
static bool sag_eroute(struct state *st, struct spd_route *sr,
|
||||||
unsigned op, const char *opname)
|
unsigned op, const char *opname)
|
||||||
{
|
{
|
||||||
u_int inner_proto = 0;
|
u_int inner_proto, inner_satype;
|
||||||
u_int inner_satype = 0;
|
|
||||||
ipsec_spi_t inner_spi = 0;
|
ipsec_spi_t inner_spi = 0;
|
||||||
struct pfkey_proto_info proto_info[4];
|
struct kernel_proto_info proto_info = {
|
||||||
int i;
|
.mode = MODE_TRANSPORT,
|
||||||
bool tunnel;
|
};
|
||||||
|
bool tunnel = FALSE;
|
||||||
/* 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;
|
|
||||||
|
|
||||||
if (st->st_ah.present)
|
if (st->st_ah.present)
|
||||||
{
|
{
|
||||||
inner_spi = st->st_ah.attrs.spi;
|
inner_spi = st->st_ah.attrs.spi;
|
||||||
inner_proto = SA_AH;
|
inner_proto = SA_AH;
|
||||||
inner_satype = SADB_SATYPE_AH;
|
inner_satype = SADB_SATYPE_AH;
|
||||||
|
proto_info.ah_spi = inner_spi;
|
||||||
i--;
|
tunnel |= st->st_ah.attrs.encapsulation == ENCAPSULATION_MODE_TUNNEL;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (st->st_esp.present)
|
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_spi = st->st_esp.attrs.spi;
|
||||||
inner_proto = SA_ESP;
|
inner_proto = SA_ESP;
|
||||||
inner_satype = SADB_SATYPE_ESP;
|
inner_satype = SADB_SATYPE_ESP;
|
||||||
|
proto_info.esp_spi = inner_spi;
|
||||||
i--;
|
tunnel |= st->st_esp.attrs.encapsulation == ENCAPSULATION_MODE_TUNNEL;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (st->st_ipcomp.present)
|
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_spi = st->st_ipcomp.attrs.spi;
|
||||||
inner_proto = SA_COMP;
|
inner_proto = SA_COMP;
|
||||||
inner_satype = SADB_X_SATYPE_COMP;
|
inner_satype = SADB_X_SATYPE_COMP;
|
||||||
|
proto_info.cpi = htons(ntohl(inner_spi));
|
||||||
i--;
|
proto_info.ipcomp = st->st_ipcomp.attrs.transid;
|
||||||
proto_info[i].proto = IPPROTO_COMP;
|
tunnel |= st->st_ipcomp.attrs.encapsulation == ENCAPSULATION_MODE_TUNNEL;
|
||||||
proto_info[i].encapsulation = st->st_ipcomp.attrs.encapsulation;
|
|
||||||
tunnel |= proto_info[i].encapsulation == ENCAPSULATION_MODE_TUNNEL;
|
|
||||||
proto_info[i].reqid = sr->reqid + 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i == sizeof(proto_info) / sizeof(proto_info[0]) - 1)
|
if (!inner_spi)
|
||||||
{
|
{
|
||||||
impossible(); /* no transform at all! */
|
impossible(); /* no transform at all! */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tunnel)
|
if (tunnel)
|
||||||
{
|
{
|
||||||
int j;
|
|
||||||
|
|
||||||
inner_spi = st->st_tunnel_out_spi;
|
inner_spi = st->st_tunnel_out_spi;
|
||||||
inner_proto = SA_IPIP;
|
inner_proto = SA_IPIP;
|
||||||
inner_satype = SADB_X_SATYPE_IPIP;
|
inner_satype = SADB_X_SATYPE_IPIP;
|
||||||
|
proto_info.mode = MODE_TUNNEL;
|
||||||
proto_info[i].encapsulation = ENCAPSULATION_MODE_TUNNEL;
|
|
||||||
for (j = i + 1; proto_info[j].proto; j++)
|
|
||||||
{
|
|
||||||
proto_info[j].encapsulation = ENCAPSULATION_MODE_TRANSPORT;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return eroute_connection(sr
|
proto_info.reqid = sr->reqid;
|
||||||
, inner_spi, inner_proto, inner_satype, proto_info + i
|
|
||||||
, op, opname);
|
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 */
|
/* compute a (host-order!) SPI to implement the policy in connection c */
|
||||||
|
|||||||
Reference in New Issue
Block a user