kernel-interface: Add interface name to local subnet enumerator
authorTobias Brunner <tobias@strongswan.org>
Wed, 12 Oct 2016 10:11:24 +0000 (12:11 +0200)
committerTobias Brunner <tobias@strongswan.org>
Wed, 8 Feb 2017 09:38:28 +0000 (10:38 +0100)
src/libcharon/kernel/kernel_interface.h
src/libcharon/kernel/kernel_net.h
src/libcharon/plugins/bypass_lan/bypass_lan_listener.c
src/libcharon/plugins/kernel_netlink/kernel_netlink_net.c

index dca4bab..96c9ffa 100644 (file)
@@ -320,7 +320,9 @@ struct kernel_interface_t {
         *
         * Local subnets are subnets the host is directly connected to.
         *
-        * @return                              enumerator over host_t*, uint8_t
+        * The enumerator returns the network, subnet mask and interface.
+        *
+        * @return                              enumerator over host_t*, uint8_t, char*
         */
        enumerator_t *(*create_local_subnet_enumerator)(kernel_interface_t *this);
 
index a1ced36..12475b1 100644 (file)
@@ -123,7 +123,9 @@ struct kernel_net_t {
         *
         * Local subnets are subnets the host is directly connected to.
         *
-        * @return                              enumerator over host_t*, uint8_t
+        * The enumerator returns the network, subnet mask and interface.
+        *
+        * @return                              enumerator over host_t*, uint8_t, char*
         */
        enumerator_t *(*create_local_subnet_enumerator)(kernel_net_t *this);
 
index 7963677..3e744b9 100644 (file)
@@ -102,6 +102,7 @@ static job_requeue_t update_bypass(private_bypass_lan_listener_t *this)
        bypass_policy_t *found, *lookup;
        host_t *net;
        uint8_t mask;
+       char *iface;
 
        seen = hashtable_create((hashtable_hash_t)policy_hash,
                                                        (hashtable_equals_t)policy_equals, 4);
@@ -109,7 +110,7 @@ static job_requeue_t update_bypass(private_bypass_lan_listener_t *this)
        this->mutex->lock(this->mutex);
 
        enumerator = charon->kernel->create_local_subnet_enumerator(charon->kernel);
-       while (enumerator->enumerate(enumerator, &net, &mask))
+       while (enumerator->enumerate(enumerator, &net, &mask, &iface))
        {
                INIT(lookup,
                        .net = net->clone(net),
index a31f312..61e0292 100644 (file)
@@ -2148,7 +2148,7 @@ METHOD(enumerator_t, destroy_subnet_enumerator, void,
 }
 
 METHOD(enumerator_t, enumerate_subnets, bool,
-       subnet_enumerator_t *this, host_t **net, uint8_t *mask)
+       subnet_enumerator_t *this, host_t **net, uint8_t *mask, char **ifname)
 {
        if (!this->current)
        {
@@ -2204,6 +2204,7 @@ METHOD(enumerator_t, enumerate_subnets, bool,
                                        this->net = host_create_from_chunk(msg->rtm_family, dst, 0);
                                        *net = this->net;
                                        *mask = msg->rtm_dst_len;
+                                       *ifname = NULL;
                                        return TRUE;
                                }
                                break;