diff options
author | Paul Fox <pgf@brightstareng.com> | 2005-07-20 15:55:08 +0400 |
---|---|---|
committer | Paul Fox <pgf@brightstareng.com> | 2005-07-20 15:55:08 +0400 |
commit | 28069404a4ef3ba2dcf31ff167877c11268409e7 (patch) | |
tree | 6560aee7032c3fa3460aa44c5f0ba1a470fb3733 /networking/traceroute.c | |
parent | 3c12ff7c894d930b1c431954f645087724017995 (diff) |
much more concise fix for bug #45. just align the packet...
Diffstat (limited to 'networking/traceroute.c')
-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 @@ #define MAXPACKET 65535 /* max ip packet size */ -#define MAXPACKET_ICMP 512 #ifndef MAXHOSTNAMELEN #define MAXHOSTNAMELEN 64 #endif @@ -102,6 +101,8 @@ struct opacket { #include "busybox.h" + /* last inbound (icmp) packet */ +static u_char packet[512] __attribute__ ((aligned)); static struct opacket *outpacket; /* last output (udp) packet */ static int s; /* receive (icmp) socket file descriptor */ @@ -185,7 +186,7 @@ deltaT(struct timeval *t1p, struct timeval *t2p) } static inline int -wait_for_reply(int sock, struct sockaddr_in *from, int reset_timer, u_char *packet, int size) +wait_for_reply(int sock, struct sockaddr_in *from, int reset_timer) { fd_set fds; static struct timeval wait; @@ -212,7 +213,7 @@ wait_for_reply(int sock, struct sockaddr_in *from, int reset_timer, u_char *pack } if (select(sock+1, &fds, (fd_set *)0, (fd_set *)0, &wait) > 0) - cc=recvfrom(s, (char *)packet, size, 0, + cc=recvfrom(s, (char *)packet, sizeof(packet), 0, (struct sockaddr *)from, &fromlen); return(cc); @@ -339,12 +340,10 @@ traceroute_main(int argc, char *argv[]) struct hostent *hp; struct sockaddr_in from, *to; int ch, i, on, probe, seq, tos, ttl; - u_char *packet; int options = 0; /* socket options */ char *source = 0; int nprobes = 3; - packet = xmalloc (MAXPACKET_ICMP); on = 1; seq = tos = 0; @@ -496,7 +495,7 @@ traceroute_main(int argc, char *argv[]) (void) gettimeofday(&t1, &tz); send_probe(++seq, ttl); reset_timer = 1; - while ((cc = wait_for_reply(s, &from, reset_timer, packet, MAXPACKET_ICMP)) != 0) { + while ((cc = wait_for_reply(s, &from, reset_timer)) != 0) { (void) gettimeofday(&t2, &tz); if ((i = packet_ok(packet, cc, &from, seq))) { reset_timer = 1; |