Changeset View
Changeset View
Standalone View
Standalone View
sbin/ping/ping.c
Show First 20 Lines • Show All 869 Lines • ▼ Show 20 Lines | if (sigaction(SIGALRM, &si_sa, 0) == -1) | ||||
} | } | ||||
bzero(&msg, sizeof(msg)); | bzero(&msg, sizeof(msg)); | ||||
msg.msg_name = (caddr_t)&from; | msg.msg_name = (caddr_t)&from; | ||||
msg.msg_iov = &iov; | msg.msg_iov = &iov; | ||||
msg.msg_iovlen = 1; | msg.msg_iovlen = 1; | ||||
#ifdef SO_TIMESTAMP | #ifdef SO_TIMESTAMP | ||||
msg.msg_control = (caddr_t)ctrl; | msg.msg_control = (caddr_t)ctrl; | ||||
msg.msg_controllen = sizeof(ctrl); | |||||
#endif | #endif | ||||
iov.iov_base = packet; | iov.iov_base = packet; | ||||
iov.iov_len = IP_MAXPACKET; | iov.iov_len = IP_MAXPACKET; | ||||
if (preload == 0) | if (preload == 0) | ||||
pinger(); /* send the first ping */ | pinger(); /* send the first ping */ | ||||
else { | else { | ||||
if (npackets != 0 && preload > npackets) | if (npackets != 0 && preload > npackets) | ||||
Show All 29 Lines | while (!finish_up) { | ||||
if (timeout.tv_sec < 0) | if (timeout.tv_sec < 0) | ||||
timespecclear(&timeout); | timespecclear(&timeout); | ||||
n = pselect(srecv + 1, &rfds, NULL, NULL, &timeout, NULL); | n = pselect(srecv + 1, &rfds, NULL, NULL, &timeout, NULL); | ||||
if (n < 0) | if (n < 0) | ||||
continue; /* Must be EINTR. */ | continue; /* Must be EINTR. */ | ||||
if (n == 1) { | if (n == 1) { | ||||
struct timespec *tv = NULL; | struct timespec *tv = NULL; | ||||
#ifdef SO_TIMESTAMP | #ifdef SO_TIMESTAMP | ||||
struct cmsghdr *cmsg = (struct cmsghdr *)&ctrl; | struct cmsghdr *cmsg = CMSG_FIRSTHDR(&msg); | ||||
msg.msg_controllen = sizeof(ctrl); | |||||
#endif | #endif | ||||
msg.msg_namelen = sizeof(from); | msg.msg_namelen = sizeof(from); | ||||
if ((cc = recvmsg(srecv, &msg, 0)) < 0) { | if ((cc = recvmsg(srecv, &msg, 0)) < 0) { | ||||
if (errno == EINTR) | if (errno == EINTR) | ||||
continue; | continue; | ||||
warn("recvmsg"); | warn("recvmsg"); | ||||
continue; | continue; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 833 Lines • Show Last 20 Lines |