ts.get_subnet() returns TRUE if the selector actually is a subnet
authorMartin Willi <martin@revosec.ch>
Fri, 18 Nov 2011 13:30:15 +0000 (14:30 +0100)
committerMartin Willi <martin@revosec.ch>
Tue, 20 Mar 2012 16:30:44 +0000 (17:30 +0100)
src/libstrongswan/selectors/traffic_selector.c
src/libstrongswan/selectors/traffic_selector.h

index b1bcf1b..8b862a8 100644 (file)
@@ -571,7 +571,7 @@ METHOD(traffic_selector_t, includes, bool,
        return FALSE;
 }
 
-METHOD(traffic_selector_t, to_subnet, void,
+METHOD(traffic_selector_t, to_subnet, bool,
        private_traffic_selector_t *this, host_t **net, u_int8_t *mask)
 {
        /* there is no way to do this cleanly, as the address range may
@@ -597,7 +597,7 @@ METHOD(traffic_selector_t, to_subnet, void,
                        break;
                default:
                        /* unreachable */
-                       return;
+                       return FALSE;
        }
 
        net_chunk.ptr = malloc(net_chunk.len);
@@ -616,6 +616,8 @@ METHOD(traffic_selector_t, to_subnet, void,
 
        *net = host_create_from_chunk(family, net_chunk, port);
        chunk_free(&net_chunk);
+
+       return this->netbits != NON_SUBNET_ADDRESS_RANGE;
 }
 
 METHOD(traffic_selector_t, clone_, traffic_selector_t*,
index 257da3f..67b5da5 100644 (file)
@@ -203,8 +203,9 @@ struct traffic_selector_t {
         *
         * @param net           converted subnet (has to be freed)
         * @param mask          converted net mask
+        * @return                      TRUE if traffic selector matches exactly to the subnet
         */
-       void (*to_subnet) (traffic_selector_t *this, host_t **net, u_int8_t *mask);
+       bool (*to_subnet) (traffic_selector_t *this, host_t **net, u_int8_t *mask);
 
        /**
         * Destroys the ts object