Changeset View
Changeset View
Standalone View
Standalone View
sbin/ifconfig/af_inet.c
Show First 20 Lines • Show All 136 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
struct in_addr a; | struct in_addr a; | ||||
a.s_addr = htonl(plen ? ~((1 << (32 - plen)) - 1) : 0); | a.s_addr = htonl(plen ? ~((1 << (32 - plen)) - 1) : 0); | ||||
return (a); | return (a); | ||||
} | } | ||||
static struct sockaddr_in * | |||||
satosin(struct sockaddr *sa) | |||||
{ | |||||
return ((struct sockaddr_in *)(void *)sa); | |||||
} | |||||
static void | static void | ||||
in_status_nl(struct ifconfig_args *args __unused, struct io_handler *h, | in_status_nl(struct ifconfig_args *args __unused, struct io_handler *h, | ||||
if_link_t *link, if_addr_t *ifa) | if_link_t *link, if_addr_t *ifa) | ||||
{ | { | ||||
struct sockaddr_in *sin = satosin(ifa->ifa_local); | struct sockaddr_in *sin = satosin(ifa->ifa_local); | ||||
int plen = ifa->ifa_prefixlen; | int plen = ifa->ifa_prefixlen; | ||||
print_addr(sin); | print_addr(sin); | ||||
Show All 40 Lines | in_getaddr(const char *s, int which) | ||||
sin->sin_family = AF_INET; | sin->sin_family = AF_INET; | ||||
if (which == ADDR) { | if (which == ADDR) { | ||||
char *p = NULL; | char *p = NULL; | ||||
if((p = strrchr(s, '/')) != NULL) { | if((p = strrchr(s, '/')) != NULL) { | ||||
const char *errstr; | const char *errstr; | ||||
/* address is `name/masklen' */ | /* address is `name/masklen' */ | ||||
int masklen; | int masklen = 0; | ||||
struct sockaddr_in *min = sintab[MASK]; | struct sockaddr_in *min = sintab[MASK]; | ||||
*p = '\0'; | *p = '\0'; | ||||
if (!isdigit(*(p + 1))) | if (!isdigit(*(p + 1))) | ||||
errstr = "invalid"; | errstr = "invalid"; | ||||
else | else | ||||
masklen = (int)strtonum(p + 1, 0, 32, &errstr); | masklen = (int)strtonum(p + 1, 0, 32, &errstr); | ||||
if (errstr != NULL) { | if (errstr != NULL) { | ||||
*p = '/'; | *p = '/'; | ||||
▲ Show 20 Lines • Show All 108 Lines • Show Last 20 Lines |