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;
-1
View File
@@ -111,7 +111,6 @@ struct starter_end {
u_int16_t port;
u_int8_t protocol;
char *sourceip;
int sourceip_mask;
char *dns;
};
-1
View File
@@ -140,7 +140,6 @@ static void starter_stroke_add_end(stroke_msg_t *msg, stroke_end_t *msg_end, sta
msg_end->ikeport = conn_end->ikeport;
msg_end->subnets = push_string(msg, conn_end->subnet);
msg_end->sourceip = push_string(msg, conn_end->sourceip);
msg_end->sourceip_mask = conn_end->sourceip_mask;
msg_end->dns = push_string(msg, conn_end->dns);
msg_end->sendcert = conn_end->sendcert;
msg_end->hostaccess = conn_end->hostaccess;