|
|
int progress = -1; | int progress = -1; |
int broken_router; | int broken_router; |
| |
restart: |
while (1) { |
memset(&rcvbuf, -1, sizeof(rcvbuf)); | memset(&rcvbuf, -1, sizeof(rcvbuf)); |
iov.iov_base = &rcvbuf; | iov.iov_base = &rcvbuf; |
iov.iov_len = sizeof(rcvbuf); | iov.iov_len = sizeof(rcvbuf); |
|
|
if (res < 0) { | if (res < 0) { |
if (errno == EAGAIN) | if (errno == EAGAIN) |
return progress; | return progress; |
goto restart; |
continue; |
} | } |
| |
progress = 2; | progress = 2; |
|
|
perror("NET ERROR"); | perror("NET ERROR"); |
return 0; | return 0; |
} | } |
goto restart; |
} |
} | } |
| |
int probe_ttl(int fd, int ttl) | int probe_ttl(int fd, int ttl) |
{ | { |
int i; |
int i=0, res; |
char sndbuf[mtu]; | char sndbuf[mtu]; |
struct probehdr *hdr = (struct probehdr*)sndbuf; | struct probehdr *hdr = (struct probehdr*)sndbuf; |
| |
restart: |
while (i<10) { |
|
for (i=0; i<10; i++) { |
for (i=0; i<10; i++) { |
hdr->ttl = ttl; |
int res; |
gettimeofday(&hdr->tv, NULL); |
|
if (send(fd, sndbuf, mtu-overhead, 0) > 0) |
hdr->ttl = ttl; |
break; |
gettimeofday(&hdr->tv, NULL); |
res = recverr(fd, ttl); |
if (send(fd, sndbuf, mtu-overhead, 0) > 0) |
if (res==0) |
break; |
return 0; |
res = recverr(fd, ttl); |
if (res > 0) { |
if (res==0) |
i = 0; |
return 0; |
continue; |
if (res > 0) |
} |
goto restart; |
} |
} |
|
|
|
if (i<10) { |
|
int res; |
|
|
|
data_wait(fd); | data_wait(fd); |
if (recv(fd, sndbuf, sizeof(sndbuf), MSG_DONTWAIT) > 0) { | if (recv(fd, sndbuf, sizeof(sndbuf), MSG_DONTWAIT) > 0) { |
printf("%2d?: reply received 8)\n", ttl); | printf("%2d?: reply received 8)\n", ttl); |
|
|
} | } |
res = recverr(fd, ttl); | res = recverr(fd, ttl); |
if (res == 1) | if (res == 1) |
goto restart; |
continue; |
return res; | return res; |
} | } |
| |