aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Willi <martin@revosec.ch>2012-07-02 17:25:26 +0200
committerMartin Willi <martin@revosec.ch>2012-07-02 17:25:26 +0200
commit997fdd1f024a8e30c97dcc86c874129f0fc8247f (patch)
tree8c747fdea34191768b0361d93df40ef378bdbc6d /src
parentb8d4cd294b5a15c9204d5e2336e5342b02db2e12 (diff)
downloadstrongswan-997fdd1f024a8e30c97dcc86c874129f0fc8247f.tar.bz2
strongswan-997fdd1f024a8e30c97dcc86c874129f0fc8247f.tar.xz
Accept non-"/0" subnet sizes for traffic selectors starting at 0.0.0.0
Diffstat (limited to 'src')
-rw-r--r--src/libstrongswan/selectors/traffic_selector.c49
1 files changed, 9 insertions, 40 deletions
diff --git a/src/libstrongswan/selectors/traffic_selector.c b/src/libstrongswan/selectors/traffic_selector.c
index 8b862a8dc..27a42f4ea 100644
--- a/src/libstrongswan/selectors/traffic_selector.c
+++ b/src/libstrongswan/selectors/traffic_selector.c
@@ -737,66 +737,35 @@ traffic_selector_t *traffic_selector_create_from_rfc3779_format(ts_type_t type,
traffic_selector_t *traffic_selector_create_from_subnet(host_t *net,
u_int8_t netbits, u_int8_t protocol, u_int16_t port)
{
- private_traffic_selector_t *this = traffic_selector_create(protocol, 0, 0, 65535);
+ private_traffic_selector_t *this;
+ chunk_t from;
+
+ this = traffic_selector_create(protocol, 0, 0, 65535);
switch (net->get_family(net))
{
case AF_INET:
- {
- chunk_t from;
-
this->type = TS_IPV4_ADDR_RANGE;
- from = net->get_address(net);
- memcpy(this->from, from.ptr, from.len);
- if (this->from4[0] == 0)
- {
- /* use /0 for 0.0.0.0 */
- this->to4[0] = ~0;
- this->netbits = 0;
- }
- else
- {
- calc_range(this, netbits);
- }
break;
- }
case AF_INET6:
- {
- chunk_t from;
-
this->type = TS_IPV6_ADDR_RANGE;
- from = net->get_address(net);
- memcpy(this->from, from.ptr, from.len);
- if (this->from6[0] == 0 && this->from6[1] == 0 &&
- this->from6[2] == 0 && this->from6[3] == 0)
- {
- /* use /0 for ::0 */
- this->to6[0] = ~0;
- this->to6[1] = ~0;
- this->to6[2] = ~0;
- this->to6[3] = ~0;
- this->netbits = 0;
- }
- else
- {
- calc_range(this, netbits);
- }
break;
- }
default:
- {
net->destroy(net);
free(this);
return NULL;
- }
}
+ from = net->get_address(net);
+ memcpy(this->from, from.ptr, from.len);
+ calc_range(this, netbits);
if (port)
{
this->from_port = port;
this->to_port = port;
}
net->destroy(net);
- return (&this->public);
+
+ return &this->public;
}
/*