aboutsummaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
authorandersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277>2001-07-17 01:12:36 +0000
committerandersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277>2001-07-17 01:12:36 +0000
commit40f493d3ba67ef58f18450dca116680a627d1cf7 (patch)
tree4c43e4947b0196d807249f8f6e1c9c679b6bbcde /networking
parent9b29bac7278544197cdc0f2554ed089f97ec39a4 (diff)
downloadbusybox-w32-40f493d3ba67ef58f18450dca116680a627d1cf7.tar.gz
busybox-w32-40f493d3ba67ef58f18450dca116680a627d1cf7.tar.bz2
busybox-w32-40f493d3ba67ef58f18450dca116680a627d1cf7.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) git-svn-id: svn://busybox.net/trunk/busybox@3103 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'networking')
-rw-r--r--networking/ping.c3
-rw-r--r--networking/traceroute.c33
2 files changed, 14 insertions, 22 deletions
diff --git a/networking/ping.c b/networking/ping.c
index 620a29dc9..5ca5dd9e0 100644
--- a/networking/ping.c
+++ b/networking/ping.c
@@ -1,6 +1,6 @@
1/* vi: set sw=4 ts=4: */ 1/* vi: set sw=4 ts=4: */
2/* 2/*
3 * $Id: ping.c,v 1.45 2001/07/13 20:56:27 kraai Exp $ 3 * $Id: ping.c,v 1.46 2001/07/17 01:12:36 andersen Exp $
4 * Mini ping implementation for busybox 4 * Mini ping implementation for busybox
5 * 5 *
6 * Copyright (C) 1999 by Randolph Chung <tausq@debian.org> 6 * Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
@@ -430,7 +430,6 @@ static void ping(const char *host)
430 if (h->h_addrtype != AF_INET) 430 if (h->h_addrtype != AF_INET)
431 error_msg_and_die("unknown address type; only AF_INET is currently supported."); 431 error_msg_and_die("unknown address type; only AF_INET is currently supported.");
432 432
433 pingaddr.sin_family = AF_INET; /* h->h_addrtype */
434 memcpy(&pingaddr.sin_addr, h->h_addr, sizeof(pingaddr.sin_addr)); 433 memcpy(&pingaddr.sin_addr, h->h_addr, sizeof(pingaddr.sin_addr));
435 strncpy(buf, h->h_name, sizeof(buf) - 1); 434 strncpy(buf, h->h_name, sizeof(buf) - 1);
436 hostname = buf; 435 hostname = buf;
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 */
134static inline char * 134static inline void
135inetname(struct in_addr in) 135inetname(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
170static inline void 168static 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));