1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
--- traceroute-2.0.19.orig/traceroute/mod-tcp.c 2012-03-27 16:01:15.000000000 +0200
+++ traceroute-2.0.19/traceroute/mod-tcp.c 2013-12-29 20:16:23.000000000 +0100
@@ -18,6 +18,24 @@
#include <netinet/ip6.h>
#include <netinet/tcp.h>
+#if !defined(__GLIBC__)
+# define TCPOPT_EOL 0
+# define TCPOPT_NOP 1
+# define TCPOPT_MAXSEG 2
+# define TCPOLEN_MAXSEG 4
+# define TCPOPT_WINDOW 3
+# define TCPOLEN_WINDOW 3
+# define TCPOPT_SACK_PERMITTED 4 /* Experimental */
+# define TCPOLEN_SACK_PERMITTED 2
+# define TCPOPT_SACK 5 /* Experimental */
+# define TCPOPT_TIMESTAMP 8
+# define TCPOLEN_TIMESTAMP 10
+# define TCPOLEN_TSTAMP_APPA (TCPOLEN_TIMESTAMP+2) /* appendix A */
+
+# define TCPOPT_TSTAMP_HDR \
+ (TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_TIMESTAMP<<8|TCPOLEN_TIMESTAMP)
+#endif
+
#include "traceroute.h"
@@ -33,11 +51,11 @@ static unsigned int dest_port = 0;
static int raw_sk = -1;
static int last_ttl = 0;
-static u_int8_t buf[1024]; /* enough, enough... */
+static uint8_t buf[1024]; /* enough, enough... */
static size_t csum_len = 0;
static struct tcphdr *th = NULL;
-#define TH_FLAGS(TH) (((u_int8_t *) (TH))[13])
+#define TH_FLAGS(TH) (((uint8_t *) (TH))[13])
#define TH_FIN 0x01
#define TH_SYN 0x02
#define TH_RST 0x04
@@ -164,7 +182,7 @@ static CLIF_option tcp_options[] = {
static int check_sysctl (const char *name) {
int fd, res;
char buf[sizeof (SYSCTL_PREFIX) + strlen (name) + 1];
- u_int8_t ch;
+ uint8_t ch;
strcpy (buf, SYSCTL_PREFIX);
strcat (buf, name);
@@ -191,8 +209,8 @@ static int tcp_init (const sockaddr_any
sockaddr_any src;
int mtu;
socklen_t len;
- u_int8_t *ptr;
- u_int16_t *lenp;
+ uint8_t *ptr;
+ uint16_t *lenp;
dest_addr = *dest;
@@ -286,10 +304,10 @@ static int tcp_init (const sockaddr_any
ptr += len;
}
- lenp = (u_int16_t *) ptr;
- ptr += sizeof (u_int16_t);
- *((u_int16_t *) ptr) = htons ((u_int16_t) IPPROTO_TCP);
- ptr += sizeof (u_int16_t);
+ lenp = (uint16_t *) ptr;
+ ptr += sizeof (uint16_t);
+ *((uint16_t *) ptr) = htons ((uint16_t) IPPROTO_TCP);
+ ptr += sizeof (uint16_t);
/* Construct TCP header */
@@ -309,13 +327,13 @@ static int tcp_init (const sockaddr_any
/* Build TCP options */
- ptr = (u_int8_t *) (th + 1);
+ ptr = (uint8_t *) (th + 1);
if (flags & TH_SYN) {
*ptr++ = TCPOPT_MAXSEG; /* 2 */
*ptr++ = TCPOLEN_MAXSEG; /* 4 */
- *((u_int16_t *) ptr) = htons (mss ? mss : mtu);
- ptr += sizeof (u_int16_t);
+ *((uint16_t *) ptr) = htons (mss ? mss : mtu);
+ ptr += sizeof (uint16_t);
}
if (flags & FL_TSTAMP) {
@@ -330,10 +348,10 @@ static int tcp_init (const sockaddr_any
*ptr++ = TCPOPT_TIMESTAMP; /* 8 */
*ptr++ = TCPOLEN_TIMESTAMP; /* 10 */
- *((u_int32_t *) ptr) = random_seq (); /* really! */
- ptr += sizeof (u_int32_t);
- *((u_int32_t *) ptr) = (flags & TH_ACK) ? random_seq () : 0;
- ptr += sizeof (u_int32_t);
+ *((uint32_t *) ptr) = random_seq (); /* really! */
+ ptr += sizeof (uint32_t);
+ *((uint32_t *) ptr) = (flags & TH_ACK) ? random_seq () : 0;
+ ptr += sizeof (uint32_t);
}
else if (flags & FL_SACK) {
*ptr++ = TCPOPT_NOP; /* 1 */
@@ -355,7 +373,7 @@ static int tcp_init (const sockaddr_any
if (csum_len > sizeof (buf))
error ("impossible"); /* paranoia */
- len = ptr - (u_int8_t *) th;
+ len = ptr - (uint8_t *) th;
if (len & 0x03) error ("impossible"); /* as >>2 ... */
*lenp = htons (len);
@@ -436,7 +454,7 @@ static probe *tcp_check_reply (int sk, i
char *buf, size_t len) {
probe *pb;
struct tcphdr *tcp = (struct tcphdr *) buf;
- u_int16_t sport, dport;
+ uint16_t sport, dport;
if (len < 8) return NULL; /* too short */
|