Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/in.c
Show First 20 Lines • Show All 756 Lines • ▼ Show 20 Lines | if (all) { | ||||
lltable_prefix_free(AF_INET, saddr, smask, flags); | lltable_prefix_free(AF_INET, saddr, smask, flags); | ||||
} else { | } else { | ||||
/* Remove interface address only */ | /* Remove interface address only */ | ||||
addr.sin_addr.s_addr = ia->ia_addr.sin_addr.s_addr; | addr.sin_addr.s_addr = ia->ia_addr.sin_addr.s_addr; | ||||
lltable_delete_addr(LLTABLE(ifp), LLE_IFADDR, saddr); | lltable_delete_addr(LLTABLE(ifp), LLE_IFADDR, saddr); | ||||
} | } | ||||
} | } | ||||
int | |||||
in_ifaddr_broadcast(struct in_addr in, struct in_ifaddr *ia) | |||||
{ | |||||
return ((in.s_addr == ia->ia_broadaddr.sin_addr.s_addr || | |||||
/* | /* | ||||
* Check for old-style (host 0) broadcast, but | |||||
* taking into account that RFC 3021 obsoletes it. | |||||
*/ | |||||
(ia->ia_subnetmask != IN_RFC3021_MASK && | |||||
ntohl(in.s_addr) == ia->ia_subnet)) && | |||||
/* | |||||
* Check for an all one subnetmask. These | |||||
* only exist when an interface gets a secondary | |||||
* address. | |||||
*/ | |||||
ia->ia_subnetmask != (u_long)0xffffffff); | |||||
} | |||||
/* | |||||
* If there is no other address in the system that can serve a route to the | * If there is no other address in the system that can serve a route to the | ||||
* same prefix, remove the route. Hand over the route to the new address | * same prefix, remove the route. Hand over the route to the new address | ||||
* otherwise. | * otherwise. | ||||
*/ | */ | ||||
int | int | ||||
in_scrubprefix(struct in_ifaddr *target, u_int flags) | in_scrubprefix(struct in_ifaddr *target, u_int flags) | ||||
{ | { | ||||
struct rm_priotracker in_ifa_tracker; | struct rm_priotracker in_ifa_tracker; | ||||
▲ Show 20 Lines • Show All 156 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; | |||||
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); | |||||
/* | /* | ||||
* 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) | |||||
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_ifaddr_broadcast(in, (struct in_ifaddr *)ifa)) | ||||
/* | |||||
* Check for old-style (host 0) broadcast, but | |||||
* taking into account that RFC 3021 obsoletes it. | |||||
*/ | |||||
(ia->ia_subnetmask != IN_RFC3021_MASK && | |||||
t == ia->ia_subnet)) && | |||||
/* | |||||
* Check for an all one subnetmask. These | |||||
* only exist when an interface gets a secondary | |||||
* address. | |||||
*/ | |||||
ia->ia_subnetmask != (u_long)0xffffffff) | |||||
return (1); | return (1); | ||||
return (0); | return (0); | ||||
#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 500 Lines • Show Last 20 Lines |