aboutsummaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
Diffstat (limited to 'networking')
-rw-r--r--networking/netstat.c25
-rw-r--r--networking/traceroute.c10
-rw-r--r--networking/wget.c17
3 files changed, 14 insertions, 38 deletions
diff --git a/networking/netstat.c b/networking/netstat.c
index 4faa40cd4..6d91bb3f4 100644
--- a/networking/netstat.c
+++ b/networking/netstat.c
@@ -11,18 +11,8 @@
11 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 11 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
12 */ 12 */
13 13
14#include <stdio.h>
15#include <stdlib.h>
16#include <string.h>
17#include <stdarg.h>
18#include <signal.h>
19#include <errno.h>
20#include <sys/stat.h>
21#include <dirent.h>
22#include <unistd.h>
23#include "inet_common.h"
24#include "busybox.h" 14#include "busybox.h"
25#include "pwd_.h" 15#include "inet_common.h"
26 16
27#ifdef CONFIG_ROUTE 17#ifdef CONFIG_ROUTE
28extern void displayroutes(int noresolve, int netstatfmt); 18extern void displayroutes(int noresolve, int netstatfmt);
@@ -87,19 +77,6 @@ typedef enum {
87#define SO_WAITDATA (1<<17) /* wait data to read */ 77#define SO_WAITDATA (1<<17) /* wait data to read */
88#define SO_NOSPACE (1<<18) /* no space to write */ 78#define SO_NOSPACE (1<<18) /* no space to write */
89 79
90static char *itoa(unsigned int i)
91{
92 /* 21 digits plus null terminator, good for 64-bit or smaller ints */
93 static char local[22];
94 char *p = &local[21];
95 *p-- = '\0';
96 do {
97 *p-- = '0' + i % 10;
98 i /= 10;
99 } while (i > 0);
100 return p + 1;
101}
102
103static char *get_sname(int port, const char *proto, int num) 80static char *get_sname(int port, const char *proto, int num)
104{ 81{
105 char *str=itoa(ntohs(port)); 82 char *str=itoa(ntohs(port));
diff --git a/networking/traceroute.c b/networking/traceroute.c
index 190f19ddc..79f3957a6 100644
--- a/networking/traceroute.c
+++ b/networking/traceroute.c
@@ -548,7 +548,7 @@ static int
548wait_for_reply(int sock, struct sockaddr_in *fromp, const struct timeval *tp) 548wait_for_reply(int sock, struct sockaddr_in *fromp, const struct timeval *tp)
549{ 549{
550 fd_set fds; 550 fd_set fds;
551 struct timeval now, wait; 551 struct timeval now, tvwait;
552 struct timezone tz; 552 struct timezone tz;
553 int cc = 0; 553 int cc = 0;
554 socklen_t fromlen = sizeof(*fromp); 554 socklen_t fromlen = sizeof(*fromp);
@@ -556,12 +556,12 @@ wait_for_reply(int sock, struct sockaddr_in *fromp, const struct timeval *tp)
556 FD_ZERO(&fds); 556 FD_ZERO(&fds);
557 FD_SET(sock, &fds); 557 FD_SET(sock, &fds);
558 558
559 wait.tv_sec = tp->tv_sec + waittime; 559 tvwait.tv_sec = tp->tv_sec + waittime;
560 wait.tv_usec = tp->tv_usec; 560 tvwait.tv_usec = tp->tv_usec;
561 (void)gettimeofday(&now, &tz); 561 (void)gettimeofday(&now, &tz);
562 tvsub(&wait, &now); 562 tvsub(&tvwait, &now);
563 563
564 if (select(sock + 1, &fds, NULL, NULL, &wait) > 0) 564 if (select(sock + 1, &fds, NULL, NULL, &tvwait) > 0)
565 cc = recvfrom(sock, (char *)packet, sizeof(packet), 0, 565 cc = recvfrom(sock, (char *)packet, sizeof(packet), 0,
566 (struct sockaddr *)fromp, &fromlen); 566 (struct sockaddr *)fromp, &fromlen);
567 567
diff --git a/networking/wget.c b/networking/wget.c
index 64cdf6220..6565bb1f3 100644
--- a/networking/wget.c
+++ b/networking/wget.c
@@ -697,12 +697,11 @@ updateprogressmeter(int ignore)
697 errno = save_errno; 697 errno = save_errno;
698} 698}
699 699
700static void 700static void alarmtimer(int iwait)
701alarmtimer(int wait)
702{ 701{
703 struct itimerval itv; 702 struct itimerval itv;
704 703
705 itv.it_value.tv_sec = wait; 704 itv.it_value.tv_sec = iwait;
706 itv.it_value.tv_usec = 0; 705 itv.it_value.tv_usec = 0;
707 itv.it_interval = itv.it_value; 706 itv.it_interval = itv.it_value;
708 setitimer(ITIMER_REAL, &itv, NULL); 707 setitimer(ITIMER_REAL, &itv, NULL);
@@ -715,7 +714,7 @@ progressmeter(int flag)
715 static struct timeval lastupdate; 714 static struct timeval lastupdate;
716 static off_t lastsize, totalsize; 715 static off_t lastsize, totalsize;
717 716
718 struct timeval now, td, wait; 717 struct timeval now, td, tvwait;
719 off_t abbrevsize; 718 off_t abbrevsize;
720 int elapsed, ratio, barlength, i; 719 int elapsed, ratio, barlength, i;
721 char buf[256]; 720 char buf[256];
@@ -753,18 +752,18 @@ progressmeter(int flag)
753 /* See http://en.wikipedia.org/wiki/Tera */ 752 /* See http://en.wikipedia.org/wiki/Tera */
754 fprintf(stderr, "%6d %c%c ", (int)abbrevsize, " KMGTPEZY"[i], i?'B':' '); 753 fprintf(stderr, "%6d %c%c ", (int)abbrevsize, " KMGTPEZY"[i], i?'B':' ');
755 754
756 timersub(&now, &lastupdate, &wait); 755 timersub(&now, &lastupdate, &tvwait);
757 if (transferred > lastsize) { 756 if (transferred > lastsize) {
758 lastupdate = now; 757 lastupdate = now;
759 lastsize = transferred; 758 lastsize = transferred;
760 if (wait.tv_sec >= STALLTIME) 759 if (tvwait.tv_sec >= STALLTIME)
761 timeradd(&start, &wait, &start); 760 timeradd(&start, &tvwait, &start);
762 wait.tv_sec = 0; 761 tvwait.tv_sec = 0;
763 } 762 }
764 timersub(&now, &start, &td); 763 timersub(&now, &start, &td);
765 elapsed = td.tv_sec; 764 elapsed = td.tv_sec;
766 765
767 if (wait.tv_sec >= STALLTIME) { 766 if (tvwait.tv_sec >= STALLTIME) {
768 fprintf(stderr, " - stalled -"); 767 fprintf(stderr, " - stalled -");
769 } else if (transferred <= 0 || elapsed <= 0 || transferred > totalsize || chunked) { 768 } else if (transferred <= 0 || elapsed <= 0 || transferred > totalsize || chunked) {
770 fprintf(stderr, "--:--:-- ETA"); 769 fprintf(stderr, "--:--:-- ETA");