Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/in.c
Show First 20 Lines • Show All 133 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
/* | /* | ||||
* Return 1 if an internet address is configured on an interface. | * Return 1 if an internet address is configured on an interface. | ||||
*/ | */ | ||||
int | int | ||||
in_ifhasaddr(struct ifnet *ifp, struct in_addr in) | in_ifhasaddr(struct ifnet *ifp, struct in_addr in) | ||||
{ | { | ||||
struct epoch_tracker et; | |||||
struct ifaddr *ifa; | struct ifaddr *ifa; | ||||
struct in_ifaddr *ia; | struct in_ifaddr *ia; | ||||
NET_EPOCH_ENTER(et); | NET_EPOCH_ASSERT(); | ||||
CK_STAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { | CK_STAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { | ||||
if (ifa->ifa_addr->sa_family != AF_INET) | if (ifa->ifa_addr->sa_family != AF_INET) | ||||
continue; | continue; | ||||
ia = (struct in_ifaddr *)ifa; | ia = (struct in_ifaddr *)ifa; | ||||
if (ia->ia_addr.sin_addr.s_addr == in.s_addr) { | if (ia->ia_addr.sin_addr.s_addr == in.s_addr) | ||||
NET_EPOCH_EXIT(et); | |||||
return (1); | return (1); | ||||
} | } | ||||
} | |||||
NET_EPOCH_EXIT(et); | |||||
return (0); | return (0); | ||||
} | } | ||||
/* | /* | ||||
* Return a reference to the interface address which is different to | * Return a reference to the interface address which is different to | ||||
* the supplied one but with same IP address value. | * the supplied one but with same IP address value. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 800 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) | ||||
{ | { | ||||
struct epoch_tracker et; | |||||
struct ifaddr *ifa; | struct ifaddr *ifa; | ||||
int found; | int found; | ||||
NET_EPOCH_ASSERT(); | |||||
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); | ||||
found = 0; | 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. | ||||
*/ | */ | ||||
NET_EPOCH_ENTER(et); | |||||
CK_STAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) | CK_STAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) | ||||
if (ifa->ifa_addr->sa_family == AF_INET && | if (ifa->ifa_addr->sa_family == AF_INET && | ||||
in_ifaddr_broadcast(in, (struct in_ifaddr *)ifa)) { | in_ifaddr_broadcast(in, (struct in_ifaddr *)ifa)) { | ||||
found = 1; | found = 1; | ||||
break; | break; | ||||
} | } | ||||
NET_EPOCH_EXIT(et); | |||||
return (found); | return (found); | ||||
} | } | ||||
/* | /* | ||||
* 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 520 Lines • Show Last 20 Lines |