diff options
Diffstat (limited to 'sys/net/if.c')
-rw-r--r-- | sys/net/if.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/sys/net/if.c b/sys/net/if.c index b4662375189..2f4d0399f6f 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.406 2015/11/13 10:18:04 mpi Exp $ */ +/* $OpenBSD: if.c,v 1.407 2015/11/18 13:58:02 mpi Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -945,6 +945,36 @@ if_detach(struct ifnet *ifp) } /* + * Returns true if ``ifp0'' is connected to the interface with index ``ifidx''. + */ +int +if_isconnected(const struct ifnet *ifp0, unsigned int ifidx) +{ + struct ifnet *ifp; + int connected = 0; + + ifp = if_get(ifidx); + if (ifp == NULL) + return (0); + + if (ifp0->if_index == ifp->if_index) + connected = 1; + +#if NBRIDGE > 0 + if (SAME_BRIDGE(ifp0->if_bridgeport, ifp->if_bridgeport)) + connected = 1; +#endif +#if NCARP > 0 + if ((ifp0->if_type == IFT_CARP && ifp0->if_carpdev == ifp) || + (ifp->if_type == IFT_CARP && ifp->if_carpdev == ifp0)) + connected = 1; +#endif + + if_put(ifp); + return (connected); +} + +/* * Create a clone network interface. */ int |