aboutsummaryrefslogtreecommitdiff
path: root/sys/net/if.c
diff options
context:
space:
mode:
authorRobert Watson <rwatson@FreeBSD.org>2009-06-22 10:59:34 +0000
committerRobert Watson <rwatson@FreeBSD.org>2009-06-22 10:59:34 +0000
commit8896f83a58b5c4ff6288c8f101df25e92a371d83 (patch)
tree45a4f946feeb75c5ed5e8dcc028809c6966e1ba1 /sys/net/if.c
parentf863f9cbd9abad9ed571176939c6fb48f861d3e2 (diff)
downloadsrc-8896f83a58b5c4ff6288c8f101df25e92a371d83.tar.gz
src-8896f83a58b5c4ff6288c8f101df25e92a371d83.zip
Add a new function, ifa_ifwithaddr_check(), which rather than returning
a pointer to an ifaddr matching the passed socket address, returns a boolean indicating whether one was present. In the (near) future, ifa_ifwithaddr() will return a referenced ifaddr rather than a raw ifaddr pointer, and the new wrapper will allow callers that care only about the boolean condition to avoid having to free that reference. MFC after: 3 weeks
Notes
Notes: svn path=/head/; revision=194622
Diffstat (limited to 'sys/net/if.c')
-rw-r--r--sys/net/if.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index bc135014cb20..eb5e519b2b2b 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -1466,8 +1466,8 @@ ifa_free(struct ifaddr *ifa)
* Locate an interface based on a complete address.
*/
/*ARGSUSED*/
-struct ifaddr *
-ifa_ifwithaddr(struct sockaddr *addr)
+static struct ifaddr *
+ifa_ifwithaddr_internal(struct sockaddr *addr)
{
INIT_VNET_NET(curvnet);
struct ifnet *ifp;
@@ -1500,6 +1500,20 @@ done:
return (ifa);
}
+struct ifaddr *
+ifa_ifwithaddr(struct sockaddr *addr)
+{
+
+ return (ifa_ifwithaddr_internal(addr));
+}
+
+int
+ifa_ifwithaddr_check(struct sockaddr *addr)
+{
+
+ return (ifa_ifwithaddr_internal(addr) != NULL);
+}
+
/*
* Locate an interface based on the broadcast address.
*/