Support multiple addresses/pools in left/rightsourceip

This commit is contained in:
Martin Willi
2012-08-30 16:43:42 +02:00
parent 497ce2cf51
commit 96c2b3cf89
9 changed files with 189 additions and 156 deletions
-53
View File
@@ -231,59 +231,6 @@ static void kw_end(starter_conn_t *conn, starter_end_t *end, kw_token_t token,
end->host = strdupnull(value);
break;
case KW_SOURCEIP:
if (value[0] == '%')
{
if (streq(value, "%modeconfig") || streq(value, "%modecfg") ||
streq(value, "%config") || streq(value, "%cfg"))
{
/* request ip via config payload */
free(end->sourceip);
end->sourceip = NULL;
end->sourceip_mask = 1;
}
else
{ /* %poolname, strip %, serve ip requests */
free(end->sourceip);
end->sourceip = strdupnull(value+1);
end->sourceip_mask = 0;
}
end->modecfg = TRUE;
}
else
{
host_t *host;
char *sep;
sep = strchr(value, '/');
if (sep)
{ /* CIDR notation, address pool */
*sep = '\0';
host = host_create_from_string(value, 0);
if (!host)
{
DBG1(DBG_APP, "# bad subnet: %s=%s", name, value);
goto err;
}
host->destroy(host);
free(end->sourceip);
end->sourceip = strdupnull(value);
end->sourceip_mask = atoi(sep + 1);
/* restore the original text in case also= is used */
*sep = '/';
}
else
{ /* fixed srcip */
host = host_create_from_string(value, 0);
if (!host)
{
DBG1(DBG_APP, "# bad addr: %s=%s", name, value);
goto err;
}
end->sourceip_mask = (host->get_family(host) == AF_INET) ?
32 : 128;
host->destroy(host);
}
}
conn->mode = MODE_TUNNEL;
conn->proxy_mode = FALSE;
break;