FreeBSD/sys/netinet/in.c
/*
 * Return 1 if an internet address is configured on an interface.
 */
Return 1 if an internet address is configured on an interface.
Return 1 if an internet address is configured on an interface .
int
in_ifhasaddr(struct ifnet *ifp, struct in_addr in)
{
	struct ifaddr *ifa;
	struct in_ifaddr *ia;
	IF_ADDR_RLOCK(ifp);
	TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
		if (ifa->ifa_addr->sa_family != AF_INET)
			continue;
		ia = (struct in_ifaddr *)ifa;
		if (ia->ia_addr.sin_addr.s_addr == in.s_addr) {
			IF_ADDR_RUNLOCK(ifp);
			return (1);
		}
	}
	IF_ADDR_RUNLOCK(ifp);
	return (0);
}
int in_ifhasaddr ( struct ifnet * ifp , struct in_addr in ) { struct ifaddr * ifa ; struct in_ifaddr * ia ; IF_ADDR_RLOCK ( ifp ) ; TAILQ_FOREACH ( ifa , & ifp -> if_addrhead , ifa_link ) { if ( ifa -> ifa_addr -> sa_family != AF_INET ) continue ; ia = ( struct in_ifaddr * ) ifa ; if ( ia -> ia_addr . sin_addr . s_addr == in . s_addr ) { IF_ADDR_RUNLOCK ( ifp ) ; return ( 1 ) ; } } IF_ADDR_RUNLOCK ( ifp ) ; return ( 0 ) ; }
Return 1 if an internet address is configured on an interface.
Return 1 if an internet address is configured on an interface .