diff options
author | Eric Andersen <andersen@codepoet.org> | 2001-07-17 01:12:36 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2001-07-17 01:12:36 +0000 |
commit | 044228d5ecb9b79397f9fc915d046cf4538281e2 (patch) | |
tree | 4c43e4947b0196d807249f8f6e1c9c679b6bbcde /networking/traceroute.c | |
parent | 51ded05b3bf4df6f126420d39a40d27ea0728aa9 (diff) | |
download | busybox-w32-044228d5ecb9b79397f9fc915d046cf4538281e2.tar.gz busybox-w32-044228d5ecb9b79397f9fc915d046cf4538281e2.tar.bz2 busybox-w32-044228d5ecb9b79397f9fc915d046cf4538281e2.zip |
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 106cf043b..a3af5f698 100644 --- a/networking/traceroute.c +++ b/networking/traceroute.c | |||
@@ -131,40 +131,38 @@ static int nflag; /* print addresses numerically */ | |||
131 | * If the nflag has been supplied, give | 131 | * If the nflag has been supplied, give |
132 | * numeric value, otherwise try for symbolic name. | 132 | * numeric value, otherwise try for symbolic name. |
133 | */ | 133 | */ |
134 | static inline char * | 134 | static inline void |
135 | inetname(struct in_addr in) | 135 | inetname(struct sockaddr_in *from) |
136 | { | 136 | { |
137 | char *cp; | 137 | char *cp; |
138 | static char line[50]; | ||
139 | struct hostent *hp; | 138 | struct hostent *hp; |
140 | static char domain[MAXHOSTNAMELEN + 1]; | 139 | static char domain[MAXHOSTNAMELEN + 1]; |
141 | static int first = 1; | 140 | static int first = 1; |
141 | const char *ina; | ||
142 | 142 | ||
143 | if (first && !nflag) { | 143 | if (first && !nflag) { |
144 | first = 0; | 144 | first = 0; |
145 | if (gethostname(domain, MAXHOSTNAMELEN) == 0 && | 145 | if (gethostname(domain, MAXHOSTNAMELEN) == 0 && |
146 | (cp = index(domain, '.'))) | 146 | (cp = strchr(domain, '.'))) |
147 | (void) strcpy(domain, cp + 1); | 147 | (void) strcpy(domain, cp + 1); |
148 | else | 148 | else |
149 | domain[0] = 0; | 149 | domain[0] = 0; |
150 | } | 150 | } |
151 | cp = 0; | 151 | cp = 0; |
152 | if (!nflag && in.s_addr != INADDR_ANY) { | 152 | if (!nflag && from->sin_addr.s_addr != INADDR_ANY) { |
153 | hp = gethostbyaddr((char *)&in, sizeof (in), AF_INET); | 153 | hp = gethostbyaddr((char *)&(from->sin_addr), sizeof (from->sin_addr), AF_INET); |
154 | if (hp) { | 154 | if (hp) { |
155 | if ((cp = index(hp->h_name, '.')) && | 155 | if ((cp = strchr(hp->h_name, '.')) && |
156 | !strcmp(cp + 1, domain)) | 156 | !strcmp(cp + 1, domain)) |
157 | *cp = 0; | 157 | *cp = 0; |
158 | cp = (char *)hp->h_name; | 158 | cp = (char *)hp->h_name; |
159 | } | 159 | } |
160 | } | 160 | } |
161 | if (cp) | 161 | ina = inet_ntoa(from->sin_addr); |
162 | (void) strcpy(line, cp); | 162 | if (nflag) |
163 | else { | 163 | printf(" %s", ina); |
164 | in.s_addr = ntohl(in.s_addr); | 164 | else |
165 | strcpy(line, inet_ntoa(in)); | 165 | printf(" %s (%s)", (cp ? cp : ina), ina); |
166 | } | ||
167 | return (line); | ||
168 | } | 166 | } |
169 | 167 | ||
170 | static inline void | 168 | static inline void |
@@ -177,12 +175,7 @@ print(u_char *buf, int cc, struct sockaddr_in *from) | |||
177 | hlen = ip->ip_hl << 2; | 175 | hlen = ip->ip_hl << 2; |
178 | cc -= hlen; | 176 | cc -= hlen; |
179 | 177 | ||
180 | if (nflag) | 178 | inetname(from); |
181 | printf(" %s", inet_ntoa(from->sin_addr)); | ||
182 | else | ||
183 | printf(" %s (%s)", inetname(from->sin_addr), | ||
184 | inet_ntoa(from->sin_addr)); | ||
185 | |||
186 | #ifdef BB_FEATURE_TRACEROUTE_VERBOSE | 179 | #ifdef BB_FEATURE_TRACEROUTE_VERBOSE |
187 | if (verbose) | 180 | if (verbose) |
188 | printf (" %d bytes to %s", cc, inet_ntoa (ip->ip_dst)); | 181 | printf (" %d bytes to %s", cc, inet_ntoa (ip->ip_dst)); |