Make use of new CIDR string ts constructor where appropriate

This commit is contained in:
Martin Willi
2012-10-24 13:25:08 +02:00
parent fd6c0c8fb4
commit 1efd6c6f2a
4 changed files with 23 additions and 74 deletions
+4 -20
View File
@@ -87,28 +87,12 @@ static traffic_selector_t *create_ts(char *string)
{
if (string)
{
int netbits = 32;
host_t *net;
char *pos;
traffic_selector_t *ts;
string = strdupa(string);
pos = strchr(string, '/');
if (pos)
ts = traffic_selector_create_from_cidr(string, 0, 0);
if (ts)
{
*pos++ = '\0';
netbits = atoi(pos);
}
else
{
if (strchr(string, ':'))
{
netbits = 128;
}
}
net = host_create_from_string(string, 0);
if (net)
{
return traffic_selector_create_from_subnet(net, netbits, 0, 0);
return ts;
}
}
return traffic_selector_create_dynamic(0, 0, 65535);