Changeset View
Changeset View
Standalone View
Standalone View
usr.bin/netstat/route.c
| Show First 20 Lines • Show All 572 Lines • ▼ Show 20 Lines | |||||
| netname4(in_addr_t in, in_addr_t mask) | netname4(in_addr_t in, in_addr_t mask) | ||||
| { | { | ||||
| char *cp = 0; | char *cp = 0; | ||||
| static char line[MAXHOSTNAMELEN + sizeof("&0xffffffff")]; | static char line[MAXHOSTNAMELEN + sizeof("&0xffffffff")]; | ||||
| char nline[INET_ADDRSTRLEN]; | char nline[INET_ADDRSTRLEN]; | ||||
| struct netent *np = 0; | struct netent *np = 0; | ||||
| in_addr_t i; | in_addr_t i; | ||||
| if (!numeric_addr && in == INADDR_ANY && mask == 0) { | if (numeric_addr < 2 && in == INADDR_ANY && mask == 0) { | ||||
| strlcpy(line, "default", sizeof(line)); | strlcpy(line, "default", sizeof(line)); | ||||
| return (line); | return (line); | ||||
| } | } | ||||
| /* It is ok to supply host address. */ | /* It is ok to supply host address. */ | ||||
| in &= mask; | in &= mask; | ||||
| i = ntohl(in); | i = ntohl(in); | ||||
| ▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | if (mask) { | ||||
| for (i = 0; i < 16; ++i) | for (i = 0; i < 16; ++i) | ||||
| addr.sin6_addr.s6_addr[i] &= | addr.sin6_addr.s6_addr[i] &= | ||||
| mask->sin6_addr.s6_addr[i]; | mask->sin6_addr.s6_addr[i]; | ||||
| sa6 = &addr; | sa6 = &addr; | ||||
| } | } | ||||
| else | else | ||||
| masklen = 128; | masklen = 128; | ||||
| if (!numeric_addr && masklen == 0 && | if (numeric_addr < 2 && masklen == 0 && | ||||
| IN6_IS_ADDR_UNSPECIFIED(&sa6->sin6_addr)) | IN6_IS_ADDR_UNSPECIFIED(&sa6->sin6_addr)) | ||||
| return("default"); | return("default"); | ||||
| getnameinfo((struct sockaddr *)sa6, sa6->sin6_len, nline, sizeof(nline), | getnameinfo((struct sockaddr *)sa6, sa6->sin6_len, nline, sizeof(nline), | ||||
| NULL, 0, NI_NUMERICHOST); | NULL, 0, NI_NUMERICHOST); | ||||
| if (numeric_addr) | if (numeric_addr) | ||||
| strlcpy(line, nline, sizeof(line)); | strlcpy(line, nline, sizeof(line)); | ||||
| else | else | ||||
| Show All 40 Lines | |||||