aboutsummaryrefslogtreecommitdiffstats
path: root/src/starter/starterwhack.c
diff options
context:
space:
mode:
authorMartin Willi <martin@strongswan.org>2008-04-25 12:41:37 +0000
committerMartin Willi <martin@strongswan.org>2008-04-25 12:41:37 +0000
commit3444390241db7d0c598e026ba598f4263b3620ef (patch)
tree281972313638f85a74db44a36c77ed5efc053193 /src/starter/starterwhack.c
parent1aedf08183a70a4259b74f0b074da6bda483c513 (diff)
downloadstrongswan-3444390241db7d0c598e026ba598f4263b3620ef.tar.bz2
strongswan-3444390241db7d0c598e026ba598f4263b3620ef.tar.xz
supporting multiple comma seperated subnets in left/rightsubnet definition
e.g. leftsubnet=10.2.0.0/16,10.4.0.0/16
Diffstat (limited to 'src/starter/starterwhack.c')
-rw-r--r--src/starter/starterwhack.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/starter/starterwhack.c b/src/starter/starterwhack.c
index 84c1972ed..4535a583e 100644
--- a/src/starter/starterwhack.c
+++ b/src/starter/starterwhack.c
@@ -32,6 +32,8 @@
#include "confread.h"
#include "files.h"
+#define ip_version(string) (strchr(string, '.') ? AF_INET : AF_INET6)
+
static int
pack_str (char **p, char **next, char **roof)
{
@@ -153,22 +155,22 @@ set_whack_end(whack_end_t *w, starter_end_t *end, sa_family_t family)
if (end->srcip && end->srcip[0] != '%')
{
int len = 0;
- char *pos, *v6;
+ char *pos;
pos = strchr(end->srcip, '/');
- v6 = strchr(end->srcip, ':');
if (pos)
{
/* use first address only for pluto */
len = pos - end->srcip;
}
w->has_srcip = !end->has_natip;
- ttoaddr(end->srcip, len, v6 ? AF_INET6 : AF_INET, &w->host_srcip);
+ ttoaddr(end->srcip, len, ip_version(end->srcip), &w->host_srcip);
}
else
{
anyaddr(AF_INET, &w->host_srcip);
- }
+ }
+
w->id = end->id;
w->cert = end->cert;
w->ca = end->ca;
@@ -183,7 +185,17 @@ set_whack_end(whack_end_t *w, starter_end_t *end, sa_family_t family)
w->host_nexthop = end->nexthop;
if (w->has_client)
- w->client = end->subnet;
+ {
+ char *pos;
+ int len = 0;
+
+ pos = strchr(end->subnet, ',');
+ if (pos)
+ {
+ len = pos - end->subnet;
+ }
+ ttosubnet(end->subnet, len, ip_version(end->subnet), &w->client);
+ }
else
w->client.addr.u.v4.sin_family = addrtypeof(&w->host_addr);