-/* $OpenBSD: ping.c,v 1.101 2014/04/23 12:27:31 florian Exp $ */
+/* $OpenBSD: ping.c,v 1.102 2014/04/23 18:16:36 jca Exp $ */
/* $NetBSD: ping.c,v 1.20 1995/08/11 22:37:58 cgd Exp $ */
/*
{
struct hostent *hp;
struct sockaddr_in *to;
- struct pollfd fdmaskp[1];
struct in_addr saddr;
- int i, ch, hold = 1, packlen, preload, maxsize, df = 0, tos = 0;
- int timeout;
+ int ch, hold = 1, i, packlen, preload, maxsize, df = 0, tos = 0;
u_char *datap, *packet, ttl = MAXTTL, loop = 1;
char *target, hnamebuf[MAXHOSTNAMELEN];
#ifdef IP_OPTIONS
catcher(0); /* start things going */
for (;;) {
- struct sockaddr_in from;
- sigset_t omask, nmask;
- socklen_t fromlen;
- int cc;
+ struct sockaddr_in from;
+ sigset_t omask, nmask;
+ socklen_t fromlen;
+ struct pollfd pfd;
+ ssize_t cc;
+ int ret, timeout;
if (options & F_FLOOD) {
pinger();
timeout = 10;
} else
timeout = INFTIM;
- fdmaskp[0].fd = s;
- fdmaskp[0].events = POLLIN;
- cc = poll(fdmaskp, 1, timeout);
- if (cc < 0) {
+
+ pfd.fd = s;
+ pfd.events = POLLIN;
+
+ ret = poll(&pfd, 1, timeout);
+ if (ret < 0) {
if (errno != EINTR) {
warn("poll");
sleep(1);
}
continue;
- } else if (cc == 0)
+ } else if (ret == 0)
continue;
+
fromlen = sizeof(from);
if ((cc = recvfrom(s, packet, packlen, 0,
(struct sockaddr *)&from, &fromlen)) < 0) {
-/* $OpenBSD: ping6.c,v 1.88 2014/01/10 21:57:44 florian Exp $ */
+/* $OpenBSD: ping6.c,v 1.89 2014/04/23 18:16:36 jca Exp $ */
/* $KAME: ping6.c,v 1.163 2002/10/25 02:19:06 itojun Exp $ */
/*
{
struct itimerval itimer;
struct sockaddr_in6 from;
- int timeout;
struct addrinfo hints;
- struct pollfd fdmaskp[1];
- int cc, i;
- int ch, hold, packlen, preload, optval, ret_ga;
+ int ch, hold, i, packlen, preload, optval, ret_ga;
u_char *datap, *packet;
char *e, *target, *ifname = NULL, *gateway = NULL;
const char *errstr;
#endif
for (;;) {
- struct msghdr m;
+ struct msghdr m;
union {
struct cmsghdr hdr;
u_char buf[CMSG_SPACE(1024)];
- } cmsgbuf;
- struct iovec iov[2];
+ } cmsgbuf;
+ struct iovec iov[2];
+ struct pollfd pfd;
+ ssize_t cc;
+ int ret, timeout;
/* signal handling */
if (seenalrm) {
timeout = 10;
} else
timeout = INFTIM;
- fdmaskp[0].fd = s;
- fdmaskp[0].events = POLLIN;
- cc = poll(fdmaskp, 1, timeout);
- if (cc < 0) {
+
+ pfd.fd = s;
+ pfd.events = POLLIN;
+
+ ret = poll(&pfd, 1, timeout);
+ if (ret < 0) {
if (errno != EINTR) {
warn("poll");
sleep(1);
}
continue;
- } else if (cc == 0)
+ } else if (ret == 0)
continue;
m.msg_name = &from;