summaryrefslogtreecommitdiffstats
path: root/sys/net/if.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/net/if.c')
-rw-r--r--sys/net/if.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index 33e26cd..278b4a8 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -1006,6 +1006,33 @@ done:
}
/*
+ * Locate an interface based on the broadcast address.
+ */
+/* ARGSUSED */
+struct ifaddr *
+ifa_ifwithbroadaddr(struct sockaddr *addr)
+{
+ struct ifnet *ifp;
+ struct ifaddr *ifa;
+
+ IFNET_RLOCK();
+ TAILQ_FOREACH(ifp, &ifnet, if_link)
+ TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
+ if (ifa->ifa_addr->sa_family != addr->sa_family)
+ continue;
+ if ((ifp->if_flags & IFF_BROADCAST) &&
+ ifa->ifa_broadaddr &&
+ ifa->ifa_broadaddr->sa_len != 0 &&
+ sa_equal(ifa->ifa_broadaddr, addr))
+ goto done;
+ }
+ ifa = NULL;
+done:
+ IFNET_RUNLOCK();
+ return (ifa);
+}
+
+/*
* Locate the point to point interface with a given destination address.
*/
/*ARGSUSED*/
OpenPOWER on IntegriCloud