Lines 66-72
Link Here
|
66 |
int progress = -1; |
66 |
int progress = -1; |
67 |
int broken_router; |
67 |
int broken_router; |
68 |
|
68 |
|
69 |
restart: |
69 |
while (1) { |
70 |
memset(&rcvbuf, -1, sizeof(rcvbuf)); |
70 |
memset(&rcvbuf, -1, sizeof(rcvbuf)); |
71 |
iov.iov_base = &rcvbuf; |
71 |
iov.iov_base = &rcvbuf; |
72 |
iov.iov_len = sizeof(rcvbuf); |
72 |
iov.iov_len = sizeof(rcvbuf); |
Lines 83-89
Link Here
|
83 |
if (res < 0) { |
83 |
if (res < 0) { |
84 |
if (errno == EAGAIN) |
84 |
if (errno == EAGAIN) |
85 |
return progress; |
85 |
return progress; |
86 |
goto restart; |
86 |
continue; |
87 |
} |
87 |
} |
88 |
|
88 |
|
89 |
progress = 2; |
89 |
progress = 2; |
Lines 222-255
Link Here
|
222 |
perror("NET ERROR"); |
222 |
perror("NET ERROR"); |
223 |
return 0; |
223 |
return 0; |
224 |
} |
224 |
} |
225 |
goto restart; |
225 |
} |
226 |
} |
226 |
} |
227 |
|
227 |
|
228 |
int probe_ttl(int fd, int ttl) |
228 |
int probe_ttl(int fd, int ttl) |
229 |
{ |
229 |
{ |
230 |
int i; |
230 |
int i=0, res; |
231 |
char sndbuf[mtu]; |
231 |
char sndbuf[mtu]; |
232 |
struct probehdr *hdr = (struct probehdr*)sndbuf; |
232 |
struct probehdr *hdr = (struct probehdr*)sndbuf; |
233 |
|
233 |
|
234 |
restart: |
234 |
while (i<10) { |
235 |
|
235 |
for (i=0; i<10; i++) { |
236 |
for (i=0; i<10; i++) { |
236 |
hdr->ttl = ttl; |
237 |
int res; |
237 |
gettimeofday(&hdr->tv, NULL); |
238 |
|
238 |
if (send(fd, sndbuf, mtu-overhead, 0) > 0) |
239 |
hdr->ttl = ttl; |
239 |
break; |
240 |
gettimeofday(&hdr->tv, NULL); |
240 |
res = recverr(fd, ttl); |
241 |
if (send(fd, sndbuf, mtu-overhead, 0) > 0) |
241 |
if (res==0) |
242 |
break; |
242 |
return 0; |
243 |
res = recverr(fd, ttl); |
243 |
if (res > 0) { |
244 |
if (res==0) |
244 |
i = 0; |
245 |
return 0; |
245 |
continue; |
246 |
if (res > 0) |
246 |
} |
247 |
goto restart; |
247 |
} |
248 |
} |
|
|
249 |
|
250 |
if (i<10) { |
251 |
int res; |
252 |
|
253 |
data_wait(fd); |
248 |
data_wait(fd); |
254 |
if (recv(fd, sndbuf, sizeof(sndbuf), MSG_DONTWAIT) > 0) { |
249 |
if (recv(fd, sndbuf, sizeof(sndbuf), MSG_DONTWAIT) > 0) { |
255 |
printf("%2d?: reply received 8)\n", ttl); |
250 |
printf("%2d?: reply received 8)\n", ttl); |
Lines 257-263
Link Here
|
257 |
} |
252 |
} |
258 |
res = recverr(fd, ttl); |
253 |
res = recverr(fd, ttl); |
259 |
if (res == 1) |
254 |
if (res == 1) |
260 |
goto restart; |
255 |
continue; |
261 |
return res; |
256 |
return res; |
262 |
} |
257 |
} |
263 |
|
258 |
|