Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/in.c
Show First 20 Lines • Show All 930 Lines • ▼ Show 20 Lines | |||||
/* | /* | ||||
* Return 1 if the address might be a local broadcast address. | * Return 1 if the address might be a local broadcast address. | ||||
*/ | */ | ||||
int | int | ||||
in_broadcast(struct in_addr in, struct ifnet *ifp) | in_broadcast(struct in_addr in, struct ifnet *ifp) | ||||
{ | { | ||||
register struct ifaddr *ifa; | register struct ifaddr *ifa; | ||||
u_long t; | u_long t; | ||||
int found; | |||||
if (in.s_addr == INADDR_BROADCAST || | if (in.s_addr == INADDR_BROADCAST || | ||||
in.s_addr == INADDR_ANY) | in.s_addr == INADDR_ANY) | ||||
return (1); | return (1); | ||||
if ((ifp->if_flags & IFF_BROADCAST) == 0) | if ((ifp->if_flags & IFF_BROADCAST) == 0) | ||||
return (0); | return (0); | ||||
t = ntohl(in.s_addr); | t = ntohl(in.s_addr); | ||||
found = 0; | |||||
/* | /* | ||||
* Look through the list of addresses for a match | * Look through the list of addresses for a match | ||||
* with a broadcast address. | * with a broadcast address. | ||||
*/ | */ | ||||
#define ia ((struct in_ifaddr *)ifa) | #define ia ((struct in_ifaddr *)ifa) | ||||
IF_ADDR_RLOCK(ifp); | |||||
TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) | TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) | ||||
if (ifa->ifa_addr->sa_family == AF_INET && | if (ifa->ifa_addr->sa_family == AF_INET && | ||||
(in.s_addr == ia->ia_broadaddr.sin_addr.s_addr || | (in.s_addr == ia->ia_broadaddr.sin_addr.s_addr || | ||||
/* | /* | ||||
* Check for old-style (host 0) broadcast, but | * Check for old-style (host 0) broadcast, but | ||||
* taking into account that RFC 3021 obsoletes it. | * taking into account that RFC 3021 obsoletes it. | ||||
*/ | */ | ||||
(ia->ia_subnetmask != IN_RFC3021_MASK && | (ia->ia_subnetmask != IN_RFC3021_MASK && | ||||
t == ia->ia_subnet)) && | t == ia->ia_subnet)) && | ||||
/* | /* | ||||
* Check for an all one subnetmask. These | * Check for an all one subnetmask. These | ||||
* only exist when an interface gets a secondary | * only exist when an interface gets a secondary | ||||
* address. | * address. | ||||
*/ | */ | ||||
ia->ia_subnetmask != (u_long)0xffffffff) | ia->ia_subnetmask != (u_long)0xffffffff) { | ||||
return (1); | found = 1; | ||||
return (0); | break; | ||||
} | |||||
IF_ADDR_RUNLOCK(ifp); | |||||
return (found); | |||||
#undef ia | #undef ia | ||||
} | } | ||||
/* | /* | ||||
* On interface removal, clean up IPv4 data structures hung off of the ifnet. | * On interface removal, clean up IPv4 data structures hung off of the ifnet. | ||||
*/ | */ | ||||
void | void | ||||
in_ifdetach(struct ifnet *ifp) | in_ifdetach(struct ifnet *ifp) | ||||
▲ Show 20 Lines • Show All 501 Lines • Show Last 20 Lines |