summaryrefslogtreecommitdiff
path: root/package/ndisc/patches/patch-src_traceroute_c.orig
blob: a7ff0cd444153e669be5c2aedf0b484e30344470 (plain)
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
127
128
$Id: update-patches 24 2008-08-31 14:56:13Z wbx $
--- ndisc6-0.9.8.orig/src/traceroute.c	2008-05-01 14:52:28.000000000 +0200
+++ ndisc6-0.9.8/src/traceroute.c	2009-05-10 19:29:37.000000000 +0200
@@ -149,6 +149,7 @@ static ssize_t
 recv_payload (int fd, void *buf, size_t len,
               struct sockaddr_in6 *addr, int *hlim)
 {
+	struct cmsghdr *cmsg;
 	char cbuf[CMSG_SPACE (sizeof (int))];
 	struct iovec iov =
 	{
@@ -170,7 +171,7 @@ recv_payload (int fd, void *buf, size_t 
 		return val;
 
 	/* ensures the hop limit is 255 */
-	for (struct cmsghdr *cmsg = CMSG_FIRSTHDR (&hdr);
+	for (cmsg = CMSG_FIRSTHDR (&hdr);
 	     cmsg != NULL;
 	     cmsg = CMSG_NXTHDR (&hdr, cmsg))
 		if ((cmsg->cmsg_level == IPPROTO_IPV6)
@@ -625,14 +626,16 @@ static void
 display (const tracetest_t *tab, unsigned min_ttl, unsigned max_ttl,
          unsigned retries)
 {
-	for (unsigned ttl = min_ttl; ttl <= max_ttl; ttl++)
+	unsigned int ttl, col;
+
+	for (ttl = min_ttl; ttl <= max_ttl; ttl++)
 	{
 		struct sockaddr_in6 hop = { .sin6_family = AF_UNSPEC };
 		const tracetest_t *line = tab + retries * (ttl - min_ttl);
 
 		printf ("%2d ", ttl);
 
-		for (unsigned col = 0; col < retries; col++)
+		for (col = 0; col < retries; col++)
 		{
 			const tracetest_t *test = line + col;
 			if (test->result == TRACE_TIMEOUT)
@@ -821,6 +824,7 @@ static void setup_socket (int fd)
 
 static int setsock_rth (int fd, int type, const char **segv, int segc)
 {
+	int i;
 	uint8_t hdr[inet6_rth_space (type, segc)];
 	inet6_rth_init (hdr, sizeof (hdr), type, segc);
 
@@ -829,7 +833,7 @@ static int setsock_rth (int fd, int type
 	hints.ai_family = AF_INET6;
 	hints.ai_flags = AI_IDN;
 
-	for (int i = 0; i < segc; i++)
+	for (i = 0; i < segc; i++)
 	{
 		struct addrinfo *res;
 
@@ -868,7 +872,8 @@ static struct
 
 static int prepare_sockets (void)
 {
-	for (unsigned i = 0; i < sizeof (protofd) / sizeof (protofd[0]); i++)
+	unsigned int i;
+	for (i = 0; i < sizeof (protofd) / sizeof (protofd[0]); i++)
 	{
 		protofd[i].fd = socket (AF_INET6, SOCK_RAW, protofd[i].protocol);
 		if (protofd[i].fd == -1)
@@ -883,8 +888,9 @@ static int prepare_sockets (void)
 
 static int get_socket (int protocol)
 {
+	unsigned int i;
 	errno = EPROTONOSUPPORT;
-	for (unsigned i = 0; i < sizeof (protofd) / sizeof (protofd[0]); i++)
+	for (i = 0; i < sizeof (protofd) / sizeof (protofd[0]); i++)
 		if (protofd[i].protocol == protocol)
 		{
 			int fd = protofd[i].fd;
@@ -902,7 +908,8 @@ static int get_socket (int protocol)
 
 static void drop_sockets (void)
 {
-	for (unsigned i = 0; i < sizeof (protofd) / sizeof (protofd[0]); i++)
+	unsigned int i;
+	for (i = 0; i < sizeof (protofd) / sizeof (protofd[0]); i++)
 		if (protofd[i].fd != -1)
 			close (protofd[i].fd);
 }
@@ -914,6 +921,8 @@ traceroute (const char *dsthost, const c
             unsigned timeout, unsigned delay, unsigned retries,
             size_t packet_len, int min_ttl, int max_ttl)
 {
+	unsigned int i, j, step;
+
 	/* Creates ICMPv6 socket to collect error packets */
 	int icmpfd = get_socket (IPPROTO_ICMPV6);
 	if (icmpfd == -1)
@@ -1020,7 +1029,7 @@ traceroute (const char *dsthost, const c
 			.filter = f,
 		};
 
-		for (unsigned i = 0; i < 4; i++)
+		for (i = 0; i < 4; i++)
 		{
 			/* A = icmp->ip6_dst.s6_addr32[i]; */
 			pc->code = BPF_LD + BPF_W + BPF_ABS;
@@ -1076,7 +1085,7 @@ traceroute (const char *dsthost, const c
 		tracetest_t tab[(1 + max_ttl - min_ttl) * retries];
 		memset (tab, 0, sizeof (tab));
 
-		for (unsigned step = 1, progress = 0;
+		for (step = 1, progress = 0;
 		     step < (1 + max_ttl - min_ttl) + retries;
 		     step++)
 		{
@@ -1093,10 +1102,10 @@ traceroute (const char *dsthost, const c
 				mono_nanosleep (&delay_ts);
 
 			/* Sends requests */
-			for (unsigned i = 0; i < retries; i++)
+			for (j = 0; j < retries; j++)
 			{
-				int attempt = (retries - 1) - i;
-				int hlim = min_ttl + step + i - retries;
+				int attempt = (retries - 1) - j;
+				int hlim = min_ttl + step + j - retries;
 
 				if ((hlim > max_ttl) || (hlim < min_ttl))
 					continue;