FreeBSD/sys/netinet/in.c
/*
 * Return 1 if the address might be a local broadcast address.
 */
Return 1 if the address might be a local broadcast address.
Return 1 if the address might be a local broadcast address .
int
in_broadcast(struct in_addr in, struct ifnet *ifp)
{
	register struct ifaddr *ifa;
	u_long t;
	if (in.s_addr == INADDR_BROADCAST ||
	    in.s_addr == INADDR_ANY)
		return (1);
	if ((ifp->if_flags & IFF_BROADCAST) == 0)
		return (0);
	t = ntohl(in.s_addr);
#define ia ((struct in_ifaddr *)ifa)
	TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link)
		if (ifa->ifa_addr->sa_family == AF_INET &&
		    (in.s_addr == ia->ia_broadaddr.sin_addr.s_addr ||
		    (ia->ia_subnetmask != IN_RFC3021_MASK &&
		    t == ia->ia_subnet)) &&
		    ia->ia_subnetmask != (u_long)0xffffffff)
			    return (1);
	return (0);
#undef ia
}
int in_broadcast ( struct in_addr in , struct ifnet * ifp ) { register struct ifaddr * ifa ; u_long t ; if ( in . s_addr == INADDR_BROADCAST || in . s_addr == INADDR_ANY ) return ( 1 ) ; if ( ( ifp -> if_flags & IFF_BROADCAST ) == 0 ) return ( 0 ) ; t = ntohl ( in . s_addr ) ; #define ia  ((struct in_ifaddr *)ifa) TAILQ_FOREACH ( ifa , & ifp -> if_addrhead , ifa_link ) if ( ifa -> ifa_addr -> sa_family == AF_INET && ( in . s_addr == ia -> ia_broadaddr . sin_addr . s_addr || ( ia -> ia_subnetmask != IN_RFC3021_MASK && t == ia -> ia_subnet ) ) && ia -> ia_subnetmask != ( u_long ) 0xffffffff ) return ( 1 ) ; return ( 0 ) ; #undef  ia }
Return 1 if the address might be a local broadcast address.
Return 1 if the address might be a local broadcast address .
/*
	 * Look through the list of addresses for a match
	 * with a broadcast address.
	 */ /*
		      * Check for old-style (host 0) broadcast, but
		      * taking into account that RFC 3021 obsoletes it.
		      */ /*
		      * Check for an all one subnetmask. These
		      * only exist when an interface gets a secondary
		      * address.
		      */