diff options
author | marius <marius@FreeBSD.org> | 2008-02-07 23:00:40 +0000 |
---|---|---|
committer | marius <marius@FreeBSD.org> | 2008-02-07 23:00:40 +0000 |
commit | 1811facdc68ad94c8c4a23211234958cb208f15f (patch) | |
tree | 65cd34d1c6822171ca81a78bce6b8342af1dd0a3 | |
parent | 5c2c2c18448463ab0bbae66c7a933a25628ac24c (diff) | |
download | FreeBSD-src-1811facdc68ad94c8c4a23211234958cb208f15f.zip FreeBSD-src-1811facdc68ad94c8c4a23211234958cb208f15f.tar.gz |
Fix netname() [1] and routename() on big-endian LP64 archs.
Submitted by: Yuri Pankov [1]
MFC after: 3 days
-rw-r--r-- | usr.bin/netstat/netstat.h | 4 | ||||
-rw-r--r-- | usr.bin/netstat/route.c | 11 |
2 files changed, 7 insertions, 8 deletions
diff --git a/usr.bin/netstat/netstat.h b/usr.bin/netstat/netstat.h index 24d8bf7..ed4f76a 100644 --- a/usr.bin/netstat/netstat.h +++ b/usr.bin/netstat/netstat.h @@ -123,8 +123,8 @@ char *ipx_phost(struct sockaddr *); char *ns_phost(struct sockaddr *); void upHex(char *); -char *routename(u_long); -char *netname(u_long, u_long); +char *routename(in_addr_t); +char *netname(in_addr_t, u_long); char *atalk_print(struct sockaddr *, int); char *atalk_print2(struct sockaddr *, struct sockaddr *, int); char *ipx_print(struct sockaddr *); diff --git a/usr.bin/netstat/route.c b/usr.bin/netstat/route.c index 4bb4123..5df4d80 100644 --- a/usr.bin/netstat/route.c +++ b/usr.bin/netstat/route.c @@ -775,7 +775,7 @@ p_rtentry(struct rtentry *rt) } char * -routename(u_long in) +routename(in_addr_t in) { char *cp; static char line[MAXHOSTNAMELEN]; @@ -783,8 +783,7 @@ routename(u_long in) cp = 0; if (!numeric_addr) { - hp = gethostbyaddr((char *)&in, sizeof (struct in_addr), - AF_INET); + hp = gethostbyaddr(&in, sizeof (struct in_addr), AF_INET); if (hp) { cp = hp->h_name; trimdomain(cp, strlen(cp)); @@ -796,7 +795,7 @@ routename(u_long in) } else { #define C(x) ((x) & 0xff) in = ntohl(in); - sprintf(line, "%lu.%lu.%lu.%lu", + sprintf(line, "%u.%u.%u.%u", C(in >> 24), C(in >> 16), C(in >> 8), C(in)); } return (line); @@ -841,7 +840,7 @@ domask(char *dst, u_long addr __unused, u_long mask) * The address is assumed to be that of a net or subnet, not a host. */ char * -netname(u_long in, u_long mask) +netname(in_addr_t in, u_long mask) { char *cp = 0; static char line[MAXHOSTNAMELEN]; @@ -860,7 +859,7 @@ netname(u_long in, u_long mask) strncpy(line, cp, sizeof(line) - 1); line[sizeof(line) - 1] = '\0'; } else { - inet_ntop(AF_INET, (char *)&in, line, sizeof(line) - 1); + inet_ntop(AF_INET, &in, line, sizeof(line) - 1); } domask(line + strlen(line), i, mask); return (line); |