Fix definion of udphdr and use it.
Modified: trunk/reactos/apps/utils/net/tracert/tracert.c

Modified: trunk/reactos/apps/utils/net/tracert/tracert.c
--- trunk/reactos/apps/utils/net/tracert/tracert.c	2005-01-12 20:49:51 UTC (rev 12996)
+++ trunk/reactos/apps/utils/net/tracert/tracert.c	2005-01-12 21:02:21 UTC (rev 12997)
@@ -231,10 +231,10 @@
 #include <winsock.h>
 
 //void print(buf, cc, from);
-char * inetname(in);
-double deltaT(t1p, t2p);
+char * inetname(struct in_addr);
+double deltaT(struct timeval *, struct timeval *);
 void usage();
-void send_probe(seq, ttl);
+void send_probe(int, int);
 
 #define bzero( ptr, count ) memset( ptr, 0, count )
 #define bcopy(src,dest,len) memcpy(dest,src,len)
@@ -336,22 +336,22 @@
 #define Sprintf (void)sprintf
 #define Printf (void)printf
 
-// Define the UDP header
-//
-typedef struct udp_hdr
-{
-   unsigned short src_portno;       // Source port number
-   unsigned short dst_portno;       // Destination port number
-   unsigned short udp_length;       // UDP packet length
-   unsigned short udp_checksum;     // UDP checksum (optional)
-} UDP_HDR, *PUDP_HDR;
+/*
+ * Define the UDP header
+ */
+typedef struct udphdr {
+	u_short uh_dport;
+	u_short uh_sport;
+	u_short uh_sum;
+	u_short uh_ulen;
+} udphdr;
 
 /*
  * format of a (udp) probe packet.
  */
 struct opacket {
 	struct ip ip;
-	UDP_HDR            udp;
+	udphdr udp;
 	u_char seq;		/* sequence number of this packet */
 	u_char ttl;		/* ttl packet left with */
 	struct timeval tv;	/* time packet left */
@@ -428,12 +428,6 @@
 	WSADATA wsadata;
 	INT status;
 
-	status = WSAStartup(MAKEWORD(2, 2), &wsadata);
-	if (status != 0) {
-		printf("Could not initialize winsock dll.\n");	
-		return FALSE;
-	}
-
 	on = 1;
 	seq = tos = 0;
 	to = (struct sockaddr_in *)&whereto;
@@ -512,6 +506,12 @@
 	if (argc < 1)
 		usage();
 
+	status = WSAStartup(MAKEWORD(2, 2), &wsadata);
+	if (status != 0) {
+		printf("Could not initialize winsock dll.\n");	
+		return FALSE;
+	}
+
 	setlinebuf (stdout);
 
 	(void) bzero((char *)&whereto, sizeof(struct sockaddr));
@@ -736,10 +736,10 @@
 	ip->ip_v = IPVERSION;
 	ip->ip_id = htons(ident+seq);
 
-//	up->uh_sport = htons(ident);
-//	up->uh_dport = htons(port+seq);
-//	up->uh_ulen = htons((u_short)(datalen - sizeof(struct ip)));
-//	up->uh_sum = 0;
+	up->uh_sport = htons(ident);
+	up->uh_dport = htons(port+seq);
+	up->uh_ulen = htons((u_short)(datalen - sizeof(struct ip)));
+	up->uh_sum = 0;
 
 	op->seq = seq;
 	op->ttl = ttl;
@@ -826,9 +826,9 @@
 		hip = &icp->icmp_ip;
 		hlen = hip->ip_hl << 2;
 		up = (struct udphdr *)((u_char *)hip + hlen);
-//		if (hlen + 12 <= cc && hip->ip_p == IPPROTO_UDP &&
-//		    up->uh_sport == htons(ident) &&
-//		    up->uh_dport == htons(port+seq))
+		if (hlen + 12 <= cc && hip->ip_p == IPPROTO_UDP &&
+		    up->uh_sport == htons(ident) &&
+		    up->uh_dport == htons(port+seq))
 		if (hlen + 12 <= cc && hip->ip_p == IPPROTO_UDP)
 			return (type == ICMP_TIMXCEED? -1 : code+1);
 	}