summaryrefslogtreecommitdiff
path: root/networking/traceroute.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-12-19 20:32:02 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-12-19 20:32:02 +0000
commit28703015ab71784f40bc97f720ed900e26bd03ca (patch)
treeff0f9a21d1822c9a2f35819db4156d9555f56116 /networking/traceroute.c
parentf58906b6463436f6a19f72d43c3ab4ba69d79104 (diff)
downloadbusybox-w32-28703015ab71784f40bc97f720ed900e26bd03ca.tar.gz
busybox-w32-28703015ab71784f40bc97f720ed900e26bd03ca.tar.bz2
busybox-w32-28703015ab71784f40bc97f720ed900e26bd03ca.zip
u_short, ulong exterminated
fdiskXXX: add a bit of sanity (not enough by far)
Diffstat (limited to 'networking/traceroute.c')
-rw-r--r--networking/traceroute.c32
1 files changed, 15 insertions, 17 deletions
diff --git a/networking/traceroute.c b/networking/traceroute.c
index 490076543..1462543f1 100644
--- a/networking/traceroute.c
+++ b/networking/traceroute.c
@@ -316,8 +316,8 @@ static int pmtu; /* Path MTU Discovery (RFC1191) */
316 316
317static char *hostname; 317static char *hostname;
318 318
319static u_short ident; 319static uint16_t ident;
320static u_short port = 32768 + 666; /* start udp dest port # for probe packets */ 320static uint16_t port = 32768 + 666; /* start udp dest port # for probe packets */
321 321
322static int waittime = 5; /* time to wait for response (in seconds) */ 322static int waittime = 5; /* time to wait for response (in seconds) */
323static int nflag; /* print addresses numerically */ 323static int nflag; /* print addresses numerically */
@@ -539,12 +539,12 @@ wait_for_reply(int sock, struct sockaddr_in *fromp, const struct timeval *tp)
539/* 539/*
540 * Checksum routine for Internet Protocol family headers (C Version) 540 * Checksum routine for Internet Protocol family headers (C Version)
541 */ 541 */
542static u_short 542static uint16_t
543in_cksum(u_short *addr, int len) 543in_cksum(uint16_t *addr, int len)
544{ 544{
545 int nleft = len; 545 int nleft = len;
546 u_short *w = addr; 546 uint16_t *w = addr;
547 u_short answer; 547 uint16_t answer;
548 int sum = 0; 548 int sum = 0;
549 549
550 /* 550 /*
@@ -589,7 +589,7 @@ send_probe(int seq, int ttl, struct timeval *tp)
589 */ 589 */
590 if (doipcksum) { 590 if (doipcksum) {
591 outip->ip_sum = 591 outip->ip_sum =
592 in_cksum((u_short *)outip, sizeof(*outip) + optlen); 592 in_cksum((uint16_t *)outip, sizeof(*outip) + optlen);
593 if (outip->ip_sum == 0) 593 if (outip->ip_sum == 0)
594 outip->ip_sum = 0xffff; 594 outip->ip_sum = 0xffff;
595 } 595 }
@@ -610,7 +610,7 @@ send_probe(int seq, int ttl, struct timeval *tp)
610 if (useicmp) { 610 if (useicmp) {
611 /* Always calculate checksum for icmp packets */ 611 /* Always calculate checksum for icmp packets */
612 outicmp->icmp_cksum = 0; 612 outicmp->icmp_cksum = 0;
613 outicmp->icmp_cksum = in_cksum((u_short *)outicmp, 613 outicmp->icmp_cksum = in_cksum((uint16_t *)outicmp,
614 packlen - (sizeof(*outip) + optlen)); 614 packlen - (sizeof(*outip) + optlen));
615 if (outicmp->icmp_cksum == 0) 615 if (outicmp->icmp_cksum == 0)
616 outicmp->icmp_cksum = 0xffff; 616 outicmp->icmp_cksum = 0xffff;
@@ -628,7 +628,7 @@ send_probe(int seq, int ttl, struct timeval *tp)
628 ui->ui_pr = oui->ui_pr; 628 ui->ui_pr = oui->ui_pr;
629 ui->ui_len = outudp->len; 629 ui->ui_len = outudp->len;
630 outudp->check = 0; 630 outudp->check = 0;
631 outudp->check = in_cksum((u_short *)ui, packlen); 631 outudp->check = in_cksum((uint16_t *)ui, packlen);
632 if (outudp->check == 0) 632 if (outudp->check == 0)
633 outudp->check = 0xffff; 633 outudp->check = 0xffff;
634 *outip = tip; 634 *outip = tip;
@@ -637,11 +637,11 @@ send_probe(int seq, int ttl, struct timeval *tp)
637#if ENABLE_FEATURE_TRACEROUTE_VERBOSE 637#if ENABLE_FEATURE_TRACEROUTE_VERBOSE
638 /* XXX undocumented debugging hack */ 638 /* XXX undocumented debugging hack */
639 if (verbose > 1) { 639 if (verbose > 1) {
640 const u_short *sp; 640 const uint16_t *sp;
641 int nshorts, i; 641 int nshorts, i;
642 642
643 sp = (u_short *)outip; 643 sp = (uint16_t *)outip;
644 nshorts = (u_int)packlen / sizeof(u_short); 644 nshorts = (u_int)packlen / sizeof(uint16_t);
645 i = 0; 645 i = 0;
646 printf("[ %d bytes", packlen); 646 printf("[ %d bytes", packlen);
647 while (--nshorts >= 0) { 647 while (--nshorts >= 0) {
@@ -906,7 +906,7 @@ traceroute_main(int argc, char *argv[])
906#if ENABLE_FEATURE_TRACEROUTE_SOURCE_ROUTE 906#if ENABLE_FEATURE_TRACEROUTE_SOURCE_ROUTE
907 int lsrr = 0; 907 int lsrr = 0;
908#endif 908#endif
909 u_short off = 0; 909 uint16_t off = 0;
910 struct IFADDRLIST *al; 910 struct IFADDRLIST *al;
911 char *device = NULL; 911 char *device = NULL;
912 int max_ttl = 30; 912 int max_ttl = 30;
@@ -1137,17 +1137,15 @@ traceroute_main(int argc, char *argv[])
1137 outicmp = (struct icmp *)outp; 1137 outicmp = (struct icmp *)outp;
1138 outicmp->icmp_type = ICMP_ECHO; 1138 outicmp->icmp_type = ICMP_ECHO;
1139 outicmp->icmp_id = htons(ident); 1139 outicmp->icmp_id = htons(ident);
1140
1141 outdata = (struct outdata *)(outp + 8); /* XXX magic number */ 1140 outdata = (struct outdata *)(outp + 8); /* XXX magic number */
1142 } else 1141 } else
1143#endif 1142#endif
1144 { 1143 {
1145 outip->ip_p = IPPROTO_UDP; 1144 outip->ip_p = IPPROTO_UDP;
1146 1145
1147 outudp = (struct udphdr *)outp; 1146 outudp = (struct udphdr *)outp;
1148 outudp->source = htons(ident); 1147 outudp->source = htons(ident);
1149 outudp->len = 1148 outudp->len = htons((uint16_t)(packlen - (sizeof(*outip) + optlen)));
1150 htons((u_short)(packlen - (sizeof(*outip) + optlen)));
1151 outdata = (struct outdata *)(outudp + 1); 1149 outdata = (struct outdata *)(outudp + 1);
1152 } 1150 }
1153 1151