aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Willi <martin@revosec.ch>2013-02-21 11:24:37 +0100
committerMartin Willi <martin@revosec.ch>2013-02-21 11:52:33 +0100
commit0e7ef7f5221a4ce444ec77268a1b6bb16af1d824 (patch)
treeb6c0ff302555689752d7cd61ee4a06cd2074e6ca /src
parentfd658bce2853a7f727075c4257079f314bb5f0ce (diff)
downloadstrongswan-0e7ef7f5221a4ce444ec77268a1b6bb16af1d824.tar.bz2
strongswan-0e7ef7f5221a4ce444ec77268a1b6bb16af1d824.tar.xz
Optionally support port ranges in leftprotoport
Diffstat (limited to 'src')
-rw-r--r--src/starter/confread.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/starter/confread.c b/src/starter/confread.c
index 22f0b7344..883534aad 100644
--- a/src/starter/confread.c
+++ b/src/starter/confread.c
@@ -303,7 +303,7 @@ static void kw_end(starter_conn_t *conn, starter_end_t *end, kw_token_t token,
end->from_port = 0xffff;
end->to_port = 0;
}
- else
+ else if (*port)
{
svc = getservbyname(port, NULL);
if (svc)
@@ -313,12 +313,28 @@ static void kw_end(starter_conn_t *conn, starter_end_t *end, kw_token_t token,
else
{
p = strtol(port, &endptr, 0);
- if ((*port && *endptr) || p < 0 || p > 0xffff)
+ if (p < 0 || p > 0xffff)
+ {
+ DBG1(DBG_APP, "# bad port: %s=%s", name, port);
+ goto err;
+ }
+ end->from_port = p;
+ if (*endptr == '-')
+ {
+ port = endptr + 1;
+ p = strtol(port, &endptr, 0);
+ if (p < 0 || p > 0xffff)
+ {
+ DBG1(DBG_APP, "# bad port: %s=%s", name, port);
+ goto err;
+ }
+ }
+ end->to_port = p;
+ if (*endptr)
{
- DBG1(DBG_APP, "# bad port: %s=%s", name, value);
+ DBG1(DBG_APP, "# bad port: %s=%s", name, port);
goto err;
}
- end->from_port = end->to_port = (u_int16_t)p;
}
}
if (sep)