aboutsummaryrefslogtreecommitdiffstats
path: root/src/libhydra/plugins/kernel_pfroute/kernel_pfroute_net.c
diff options
context:
space:
mode:
authorTobias Brunner <tobias@strongswan.org>2012-09-14 16:27:33 +0200
committerTobias Brunner <tobias@strongswan.org>2012-09-21 18:16:26 +0200
commit9ba36c0f7f68af814c9805ec8ac11d2f3ae2f5d7 (patch)
tree2ff3c2a3433ef923620072150a7161c6140a1017 /src/libhydra/plugins/kernel_pfroute/kernel_pfroute_net.c
parentaed33805ce92a1d075971734357a111637488a2a (diff)
downloadstrongswan-9ba36c0f7f68af814c9805ec8ac11d2f3ae2f5d7.tar.bz2
strongswan-9ba36c0f7f68af814c9805ec8ac11d2f3ae2f5d7.tar.xz
Make it easy to check if an address is locally usable via changed get_interface() method
Diffstat (limited to 'src/libhydra/plugins/kernel_pfroute/kernel_pfroute_net.c')
-rw-r--r--src/libhydra/plugins/kernel_pfroute/kernel_pfroute_net.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/libhydra/plugins/kernel_pfroute/kernel_pfroute_net.c b/src/libhydra/plugins/kernel_pfroute/kernel_pfroute_net.c
index 878573793..d24820caf 100644
--- a/src/libhydra/plugins/kernel_pfroute/kernel_pfroute_net.c
+++ b/src/libhydra/plugins/kernel_pfroute/kernel_pfroute_net.c
@@ -472,15 +472,13 @@ METHOD(kernel_net_t, create_address_enumerator, enumerator_t*,
(void*)address_enumerator_destroy);
}
-METHOD(kernel_net_t, get_interface_name, char*,
- private_kernel_pfroute_net_t *this, host_t* ip)
+METHOD(kernel_net_t, get_interface_name, bool,
+ private_kernel_pfroute_net_t *this, host_t* ip, char **name)
{
enumerator_t *ifaces, *addrs;
iface_entry_t *iface;
addr_entry_t *addr;
- char *name = NULL;
-
- DBG2(DBG_KNL, "getting interface name for %H", ip);
+ bool found = FALSE;
this->mutex->lock(this->mutex);
ifaces = this->ifaces->create_enumerator(this->ifaces);
@@ -491,12 +489,16 @@ METHOD(kernel_net_t, get_interface_name, char*,
{
if (ip->ip_equals(ip, addr->ip))
{
- name = strdup(iface->ifname);
+ found = TRUE;
+ if (name)
+ {
+ *name = strdup(iface->ifname);
+ }
break;
}
}
addrs->destroy(addrs);
- if (name)
+ if (found)
{
break;
}
@@ -504,15 +506,15 @@ METHOD(kernel_net_t, get_interface_name, char*,
ifaces->destroy(ifaces);
this->mutex->unlock(this->mutex);
- if (name)
+ if (!found)
{
- DBG2(DBG_KNL, "%H is on interface %s", ip, name);
+ DBG2(DBG_KNL, "%H is not a local address", ip);
}
- else
+ else if (name)
{
- DBG2(DBG_KNL, "%H is not a local address", ip);
+ DBG2(DBG_KNL, "%H is on interface %s", ip, *name);
}
- return name;
+ return found;
}
METHOD(kernel_net_t, get_source_addr, host_t*,