diff options
author | Paul Fox <pgf@brightstareng.com> | 2005-07-20 11:55:08 +0000 |
---|---|---|
committer | Paul Fox <pgf@brightstareng.com> | 2005-07-20 11:55:08 +0000 |
commit | 28069404a4ef3ba2dcf31ff167877c11268409e7 (patch) | |
tree | 6560aee7032c3fa3460aa44c5f0ba1a470fb3733 | |
parent | 3c12ff7c894d930b1c431954f645087724017995 (diff) | |
download | busybox-w32-28069404a4ef3ba2dcf31ff167877c11268409e7.tar.gz busybox-w32-28069404a4ef3ba2dcf31ff167877c11268409e7.tar.bz2 busybox-w32-28069404a4ef3ba2dcf31ff167877c11268409e7.zip |
much more concise fix for bug #45. just align the packet...
-rw-r--r-- | networking/traceroute.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/networking/traceroute.c b/networking/traceroute.c index c691551cd..cf90ec088 100644 --- a/networking/traceroute.c +++ b/networking/traceroute.c | |||
@@ -77,7 +77,6 @@ | |||
77 | 77 | ||
78 | 78 | ||
79 | #define MAXPACKET 65535 /* max ip packet size */ | 79 | #define MAXPACKET 65535 /* max ip packet size */ |
80 | #define MAXPACKET_ICMP 512 | ||
81 | #ifndef MAXHOSTNAMELEN | 80 | #ifndef MAXHOSTNAMELEN |
82 | #define MAXHOSTNAMELEN 64 | 81 | #define MAXHOSTNAMELEN 64 |
83 | #endif | 82 | #endif |
@@ -102,6 +101,8 @@ struct opacket { | |||
102 | 101 | ||
103 | #include "busybox.h" | 102 | #include "busybox.h" |
104 | 103 | ||
104 | /* last inbound (icmp) packet */ | ||
105 | static u_char packet[512] __attribute__ ((aligned)); | ||
105 | static struct opacket *outpacket; /* last output (udp) packet */ | 106 | static struct opacket *outpacket; /* last output (udp) packet */ |
106 | 107 | ||
107 | static int s; /* receive (icmp) socket file descriptor */ | 108 | static int s; /* receive (icmp) socket file descriptor */ |
@@ -185,7 +186,7 @@ deltaT(struct timeval *t1p, struct timeval *t2p) | |||
185 | } | 186 | } |
186 | 187 | ||
187 | static inline int | 188 | static inline int |
188 | wait_for_reply(int sock, struct sockaddr_in *from, int reset_timer, u_char *packet, int size) | 189 | wait_for_reply(int sock, struct sockaddr_in *from, int reset_timer) |
189 | { | 190 | { |
190 | fd_set fds; | 191 | fd_set fds; |
191 | static struct timeval wait; | 192 | static struct timeval wait; |
@@ -212,7 +213,7 @@ wait_for_reply(int sock, struct sockaddr_in *from, int reset_timer, u_char *pack | |||
212 | } | 213 | } |
213 | 214 | ||
214 | if (select(sock+1, &fds, (fd_set *)0, (fd_set *)0, &wait) > 0) | 215 | if (select(sock+1, &fds, (fd_set *)0, (fd_set *)0, &wait) > 0) |
215 | cc=recvfrom(s, (char *)packet, size, 0, | 216 | cc=recvfrom(s, (char *)packet, sizeof(packet), 0, |
216 | (struct sockaddr *)from, &fromlen); | 217 | (struct sockaddr *)from, &fromlen); |
217 | 218 | ||
218 | return(cc); | 219 | return(cc); |
@@ -339,12 +340,10 @@ traceroute_main(int argc, char *argv[]) | |||
339 | struct hostent *hp; | 340 | struct hostent *hp; |
340 | struct sockaddr_in from, *to; | 341 | struct sockaddr_in from, *to; |
341 | int ch, i, on, probe, seq, tos, ttl; | 342 | int ch, i, on, probe, seq, tos, ttl; |
342 | u_char *packet; | ||
343 | 343 | ||
344 | int options = 0; /* socket options */ | 344 | int options = 0; /* socket options */ |
345 | char *source = 0; | 345 | char *source = 0; |
346 | int nprobes = 3; | 346 | int nprobes = 3; |
347 | packet = xmalloc (MAXPACKET_ICMP); | ||
348 | 347 | ||
349 | on = 1; | 348 | on = 1; |
350 | seq = tos = 0; | 349 | seq = tos = 0; |
@@ -496,7 +495,7 @@ traceroute_main(int argc, char *argv[]) | |||
496 | (void) gettimeofday(&t1, &tz); | 495 | (void) gettimeofday(&t1, &tz); |
497 | send_probe(++seq, ttl); | 496 | send_probe(++seq, ttl); |
498 | reset_timer = 1; | 497 | reset_timer = 1; |
499 | while ((cc = wait_for_reply(s, &from, reset_timer, packet, MAXPACKET_ICMP)) != 0) { | 498 | while ((cc = wait_for_reply(s, &from, reset_timer)) != 0) { |
500 | (void) gettimeofday(&t2, &tz); | 499 | (void) gettimeofday(&t2, &tz); |
501 | if ((i = packet_ok(packet, cc, &from, seq))) { | 500 | if ((i = packet_ok(packet, cc, &from, seq))) { |
502 | reset_timer = 1; | 501 | reset_timer = 1; |