diff options
author | Eric Andersen | 2001-07-17 01:12:36 +0000 |
---|---|---|
committer | Eric Andersen | 2001-07-17 01:12:36 +0000 |
commit | 044228d5ecb9b79397f9fc915d046cf4538281e2 (patch) | |
tree | 4c43e4947b0196d807249f8f6e1c9c679b6bbcde /networking/traceroute.c | |
parent | 51ded05b3bf4df6f126420d39a40d27ea0728aa9 (diff) | |
download | busybox-044228d5ecb9b79397f9fc915d046cf4538281e2.zip busybox-044228d5ecb9b79397f9fc915d046cf4538281e2.tar.gz |
This is vodz' latest patch. Sorry it took so long...
1) ping cleanup (compile fix from this patch already applied).
2) traceroute call not spare ntohl() now (and reduce size);
3) Fix for functions not declared static in insmod, ash, vi and mount.
4) a more simple API cmdedit :))
5) adds "stopped jobs" warning to ash on Ctrl-D and fixes "ignoreeof" option
6) reduce exporting library function index->strchr (traceroute), bzero->memset (syslogd)
Diffstat (limited to 'networking/traceroute.c')
-rw-r--r-- | networking/traceroute.c | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/networking/traceroute.c b/networking/traceroute.c index 106cf04..a3af5f6 100644 --- a/networking/traceroute.c +++ b/networking/traceroute.c @@ -131,40 +131,38 @@ static int nflag; /* print addresses numerically */ * If the nflag has been supplied, give * numeric value, otherwise try for symbolic name. */ -static inline char * -inetname(struct in_addr in) +static inline void +inetname(struct sockaddr_in *from) { char *cp; - static char line[50]; struct hostent *hp; static char domain[MAXHOSTNAMELEN + 1]; static int first = 1; + const char *ina; if (first && !nflag) { first = 0; if (gethostname(domain, MAXHOSTNAMELEN) == 0 && - (cp = index(domain, '.'))) + (cp = strchr(domain, '.'))) (void) strcpy(domain, cp + 1); else domain[0] = 0; } cp = 0; - if (!nflag && in.s_addr != INADDR_ANY) { - hp = gethostbyaddr((char *)&in, sizeof (in), AF_INET); + if (!nflag && from->sin_addr.s_addr != INADDR_ANY) { + hp = gethostbyaddr((char *)&(from->sin_addr), sizeof (from->sin_addr), AF_INET); if (hp) { - if ((cp = index(hp->h_name, '.')) && + if ((cp = strchr(hp->h_name, '.')) && !strcmp(cp + 1, domain)) *cp = 0; cp = (char *)hp->h_name; } } - if (cp) - (void) strcpy(line, cp); - else { - in.s_addr = ntohl(in.s_addr); - strcpy(line, inet_ntoa(in)); - } - return (line); + ina = inet_ntoa(from->sin_addr); + if (nflag) + printf(" %s", ina); + else + printf(" %s (%s)", (cp ? cp : ina), ina); } static inline void @@ -177,12 +175,7 @@ print(u_char *buf, int cc, struct sockaddr_in *from) hlen = ip->ip_hl << 2; cc -= hlen; - if (nflag) - printf(" %s", inet_ntoa(from->sin_addr)); - else - printf(" %s (%s)", inetname(from->sin_addr), - inet_ntoa(from->sin_addr)); - + inetname(from); #ifdef BB_FEATURE_TRACEROUTE_VERBOSE if (verbose) printf (" %d bytes to %s", cc, inet_ntoa (ip->ip_dst)); |