diff options
author | Tobias Brunner <tobias@strongswan.org> | 2012-09-17 19:04:51 +0200 |
---|---|---|
committer | Tobias Brunner <tobias@strongswan.org> | 2012-09-21 18:16:26 +0200 |
commit | 4106aea8e46d41af66d78b326260dddcf99316c7 (patch) | |
tree | 31dc6ef47046403ee1939ed0cdf3714a3b29eadc /src/libhydra/plugins/kernel_netlink/kernel_netlink_net.c | |
parent | 308ec0b7df3bd61c664b1814b5442bd97a04f17d (diff) | |
download | strongswan-4106aea8e46d41af66d78b326260dddcf99316c7.tar.bz2 strongswan-4106aea8e46d41af66d78b326260dddcf99316c7.tar.xz |
Made IP address enumeration more flexible
Also added an option to enumerate addresses on ignored interfaces.
Diffstat (limited to 'src/libhydra/plugins/kernel_netlink/kernel_netlink_net.c')
-rw-r--r-- | src/libhydra/plugins/kernel_netlink/kernel_netlink_net.c | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/src/libhydra/plugins/kernel_netlink/kernel_netlink_net.c b/src/libhydra/plugins/kernel_netlink/kernel_netlink_net.c index 745f40968..99d750d22 100644 --- a/src/libhydra/plugins/kernel_netlink/kernel_netlink_net.c +++ b/src/libhydra/plugins/kernel_netlink/kernel_netlink_net.c @@ -1080,12 +1080,8 @@ static job_requeue_t receive_events(private_kernel_netlink_net_t *this) /** enumerator over addresses */ typedef struct { private_kernel_netlink_net_t* this; - /** whether to enumerate down interfaces */ - bool include_down_ifaces; - /** whether to enumerate virtual ip addresses */ - bool include_virtual_ips; - /** whether to enumerate loopback interfaces */ - bool include_loopback; + /** which addresses to enumerate */ + kernel_address_type_t which; } address_enumerator_t; /** @@ -1103,7 +1099,7 @@ static void address_enumerator_destroy(address_enumerator_t *data) static bool filter_addresses(address_enumerator_t *data, addr_entry_t** in, host_t** out) { - if (!data->include_virtual_ips && (*in)->virtual) + if (!(data->which & ADDR_TYPE_VIRTUAL) && (*in)->virtual) { /* skip virtual interfaces added by us */ return FALSE; } @@ -1132,15 +1128,15 @@ static enumerator_t *create_iface_enumerator(iface_entry_t *iface, static bool filter_interfaces(address_enumerator_t *data, iface_entry_t** in, iface_entry_t** out) { - if (!(*in)->usable) + if (!(data->which & ADDR_TYPE_IGNORED) && !(*in)->usable) { /* skip interfaces excluded by config */ return FALSE; } - if (!data->include_loopback && ((*in)->flags & IFF_LOOPBACK)) + if (!(data->which & ADDR_TYPE_LOOPBACK) && ((*in)->flags & IFF_LOOPBACK)) { /* ignore loopback devices */ return FALSE; } - if (!data->include_down_ifaces && !((*in)->flags & IFF_UP)) + if (!(data->which & ADDR_TYPE_DOWN) && !((*in)->flags & IFF_UP)) { /* skip interfaces not up */ return FALSE; } @@ -1149,14 +1145,11 @@ static bool filter_interfaces(address_enumerator_t *data, iface_entry_t** in, } METHOD(kernel_net_t, create_address_enumerator, enumerator_t*, - private_kernel_netlink_net_t *this, - bool include_down_ifaces, bool include_virtual_ips, bool include_loopback) + private_kernel_netlink_net_t *this, kernel_address_type_t which) { address_enumerator_t *data = malloc_thing(address_enumerator_t); data->this = this; - data->include_down_ifaces = include_down_ifaces; - data->include_virtual_ips = include_virtual_ips; - data->include_loopback = include_loopback; + data->which = which; this->mutex->lock(this->mutex); return enumerator_create_nested( |