Changeset View
Changeset View
Standalone View
Standalone View
sys/net/rtsock.c
Show First 20 Lines • Show All 1,370 Lines • ▼ Show 20 Lines | case AF_LINK: | ||||
*gw_sdl = sdl; | *gw_sdl = sdl; | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
return (0); | return (0); | ||||
} | } | ||||
static void | |||||
remove_netmask(struct rt_addrinfo *info) | |||||
{ | |||||
info->rti_info[RTAX_NETMASK] = NULL; | |||||
gnn: Remove spare blank line please. | |||||
Done Inline Actionsoh wow! melifaro: oh wow!
I missed this style(9). Awesome we don't need to do it now. | |||||
info->rti_flags |= RTF_HOST; | |||||
info->rti_addrs &= ~RTA_NETMASK; | |||||
} | |||||
#ifdef INET | #ifdef INET | ||||
static int | static int | ||||
cleanup_xaddrs_inet(struct rt_addrinfo *info) | cleanup_xaddrs_inet(struct rt_addrinfo *info) | ||||
{ | { | ||||
struct sockaddr_in *dst_sa, *mask_sa; | struct sockaddr_in *dst_sa, *mask_sa; | ||||
/* Check & fixup dst/netmask combination first */ | /* Check & fixup dst/netmask combination first */ | ||||
dst_sa = (struct sockaddr_in *)info->rti_info[RTAX_DST]; | dst_sa = (struct sockaddr_in *)info->rti_info[RTAX_DST]; | ||||
Show All 13 Lines | cleanup_xaddrs_inet(struct rt_addrinfo *info) | ||||
if (mask_sa && mask_sa->sin_len < sizeof(struct sockaddr_in)) { | if (mask_sa && mask_sa->sin_len < sizeof(struct sockaddr_in)) { | ||||
printf("mask sin_len too small\n"); | printf("mask sin_len too small\n"); | ||||
return (EINVAL); | return (EINVAL); | ||||
} | } | ||||
fill_sockaddr_inet(dst_sa, dst); | fill_sockaddr_inet(dst_sa, dst); | ||||
if (mask.s_addr != INADDR_BROADCAST) | if (mask.s_addr != INADDR_BROADCAST) | ||||
fill_sockaddr_inet(mask_sa, mask); | fill_sockaddr_inet(mask_sa, mask); | ||||
else { | else | ||||
info->rti_info[RTAX_NETMASK] = NULL; | remove_netmask(info); | ||||
info->rti_flags |= RTF_HOST; | |||||
info->rti_addrs &= ~RTA_NETMASK; | |||||
} | |||||
/* Check gateway */ | /* Check gateway */ | ||||
if (info->rti_info[RTAX_GATEWAY] != NULL) | if (info->rti_info[RTAX_GATEWAY] != NULL) | ||||
return (cleanup_xaddrs_gateway(info)); | return (cleanup_xaddrs_gateway(info)); | ||||
return (0); | return (0); | ||||
} | } | ||||
#endif | #endif | ||||
Show All 19 Lines | cleanup_xaddrs_inet6(struct rt_addrinfo *info) | ||||
if (mask_sa && mask_sa->sin6_len < sizeof(struct sockaddr_in6)) { | if (mask_sa && mask_sa->sin6_len < sizeof(struct sockaddr_in6)) { | ||||
printf("mask sin6_len too small\n"); | printf("mask sin6_len too small\n"); | ||||
return (EINVAL); | return (EINVAL); | ||||
} | } | ||||
fill_sockaddr_inet6(dst_sa, &dst_sa->sin6_addr, 0); | fill_sockaddr_inet6(dst_sa, &dst_sa->sin6_addr, 0); | ||||
if (!IN6_ARE_ADDR_EQUAL(&mask, &in6mask128)) | if (!IN6_ARE_ADDR_EQUAL(&mask, &in6mask128)) | ||||
fill_sockaddr_inet6(mask_sa, &mask, 0); | fill_sockaddr_inet6(mask_sa, &mask, 0); | ||||
else { | else | ||||
info->rti_info[RTAX_NETMASK] = NULL; | remove_netmask(info); | ||||
info->rti_flags |= RTF_HOST; | |||||
info->rti_addrs &= ~RTA_NETMASK; | |||||
} | |||||
/* Check gateway */ | /* Check gateway */ | ||||
if (info->rti_info[RTAX_GATEWAY] != NULL) | if (info->rti_info[RTAX_GATEWAY] != NULL) | ||||
return (cleanup_xaddrs_gateway(info)); | return (cleanup_xaddrs_gateway(info)); | ||||
return (0); | return (0); | ||||
} | } | ||||
#endif | #endif | ||||
static int | static int | ||||
cleanup_xaddrs(struct rt_addrinfo *info) | cleanup_xaddrs(struct rt_addrinfo *info) | ||||
{ | { | ||||
int error = EAFNOSUPPORT; | int error = EAFNOSUPPORT; | ||||
if (info->rti_info[RTAX_DST] == NULL) | if (info->rti_info[RTAX_DST] == NULL) | ||||
return (EINVAL); | return (EINVAL); | ||||
if (info->rti_flags & RTF_LLDATA) { | |||||
/* | |||||
Done Inline ActionsAlso this one. gnn: Also this one. | |||||
* arp(8)/ndp(8) sends RTA_NETMASK for the associated | |||||
* prefix along with the actual address in RTA_DST. | |||||
* Remove netmask to avoid unnecessary address masking. | |||||
*/ | |||||
remove_netmask(info); | |||||
} | |||||
switch (info->rti_info[RTAX_DST]->sa_family) { | switch (info->rti_info[RTAX_DST]->sa_family) { | ||||
#ifdef INET | #ifdef INET | ||||
case AF_INET: | case AF_INET: | ||||
error = cleanup_xaddrs_inet(info); | error = cleanup_xaddrs_inet(info); | ||||
break; | break; | ||||
#endif | #endif | ||||
#ifdef INET6 | #ifdef INET6 | ||||
▲ Show 20 Lines • Show All 1,100 Lines • Show Last 20 Lines |
Remove spare blank line please.