diff options
author | Tobias Brunner <tobias@strongswan.org> | 2012-05-15 15:04:11 +0200 |
---|---|---|
committer | Tobias Brunner <tobias@strongswan.org> | 2012-06-11 17:33:31 +0200 |
commit | 6ce841b2133ab41d08f2fde1825d0a6581d8b47f (patch) | |
tree | 922fb3aa65222802280fd5a0011e6ae730bf9dd2 /src | |
parent | 0ac29be793e3f075d931a572be008febb0e357be (diff) | |
download | strongswan-6ce841b2133ab41d08f2fde1825d0a6581d8b47f.tar.bz2 strongswan-6ce841b2133ab41d08f2fde1825d0a6581d8b47f.tar.xz |
starter: Use host_t to parse left|rightsourceip.
Also for the yet unused natip option.
Diffstat (limited to 'src')
-rw-r--r-- | src/starter/confread.c | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/src/starter/confread.c b/src/starter/confread.c index a7fb4a1ff..8f34e1e75 100644 --- a/src/starter/confread.c +++ b/src/starter/confread.c @@ -239,36 +239,35 @@ static void kw_end(starter_conn_t *conn, starter_end_t *end, kw_token_t token, } else { + host_t *host; char *pos; - ip_address addr; - ip_subnet net; - conn->tunnel_addr_family = ip_version(value); pos = strchr(value, '/'); - if (pos) { /* CIDR notation, address pool */ - ugh = ttosubnet(value, 0, conn->tunnel_addr_family, &net); - if (ugh != NULL) + *pos = '\0'; + host = host_create_from_string(value, 0); + if (!host) { - DBG1(DBG_APP, "# bad subnet: %s=%s [%s]", name, value, ugh); + DBG1(DBG_APP, "# bad subnet: %s=%s", name, value); goto err; - } - *pos = '\0'; + } + host->destroy(host); free(end->sourceip); end->sourceip = strdupnull(value); end->sourceip_mask = atoi(pos + 1); } else { /* fixed srcip */ - ugh = ttoaddr(value, 0, conn->tunnel_addr_family, &addr); - if (ugh != NULL) + host = host_create_from_string(value, 0); + if (!host) { - DBG1(DBG_APP, "# bad addr: %s=%s [%s]", name, value, ugh); + DBG1(DBG_APP, "# bad addr: %s=%s", name, value); goto err; } - end->sourceip_mask = (conn->tunnel_addr_family == AF_INET) ? + end->sourceip_mask = (host->get_family(host) == AF_INET) ? 32 : 128; + host->destroy(host); } } conn->mode = MODE_TUNNEL; @@ -300,19 +299,19 @@ static void kw_end(starter_conn_t *conn, starter_end_t *end, kw_token_t token, break; case KW_NATIP: { - ip_address addr; + host_t *host; if (end->sourceip) { DBG1(DBG_APP, "# natip and sourceip cannot be defined at the same time"); goto err; } - conn->tunnel_addr_family = ip_version(value); - ugh = ttoaddr(value, 0, conn->tunnel_addr_family, &addr); - if (ugh != NULL) + host = host_create_from_string(value, 0); + if (!host) { - DBG1(DBG_APP, "# bad addr: %s=%s [%s]", name, value, ugh); + DBG1(DBG_APP, "# bad addr: %s=%s", name, value); goto err; } + host->destroy(host); end->sourceip = strdupnull(value); end->has_natip = TRUE; conn->mode = MODE_TUNNEL; |