diff --git a/src/liboping.c b/src/liboping.c
index 83ca9c242c072cb61622ede4c0058d51c9036f69..40a0ba21b570bab19fea04fc71d8c69231125173 100644 (file)
--- a/src/liboping.c
+++ b/src/liboping.c
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#ifdef __APPLE__
+#define __APPLE_USE_RFC_3542
+#endif
+
#if HAVE_CONFIG_H
# include <config.h>
#endif
sizeof (recv_qos));
dprintf ("TOSv6 = 0x%02"PRIx8";\n", recv_qos);
} else
+#ifdef IPV6_HOPLIMIT
if (cmsg->cmsg_type == IPV6_HOPLIMIT)
{
memcpy (&recv_ttl, CMSG_DATA (cmsg),
dprintf ("TTLv6 = %i;\n", recv_ttl);
}
else
+#endif
+#ifdef IPV6_UNICAST_HOPS
+ if (cmsg->cmsg_type == IPV6_UNICAST_HOPS)
+ {
+ memcpy (&recv_ttl, CMSG_DATA (cmsg),
+ sizeof (recv_ttl));
+ dprintf ("TTLv6 = %i;\n", recv_ttl);
+ }
+ else
+#endif
+#ifdef IPV6_MULTICAST_HOPS
+ if (cmsg->cmsg_type == IPV6_MULTICAST_HOPS)
+ {
+ memcpy (&recv_ttl, CMSG_DATA (cmsg),
+ sizeof (recv_ttl));
+ dprintf ("TTLv6 = %i;\n", recv_ttl);
+ }
+ else
+#endif
{
dprintf ("Not handling option %i.\n",
cmsg->cmsg_type);
return (0);
}
+/* Blocks until a packet was received from all hosts or the timeout is reached.
+ * When interrupted, (-EINTR) is returned. On error, -1 is returned. On
+ * success, returns zero. */
static int ping_receive_all (pingobj_t *obj)
{
fd_set read_fds;
if ((status == -1) && (errno == EINTR))
{
dprintf ("select was interrupted by signal..\n");
- continue;
+ ping_set_errno (obj, EINTR);
+ return (-EINTR);
}
else if (status < 0)
{
} /* while (1) */
return (ret);
-}
+} /* int ping_receive_all */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Sending functions: *
int ping_send (pingobj_t *obj)
{
- int ret;
-
if (obj == NULL)
return (-1);
if (ping_send_all (obj) < 0)
return (-1);
- if ((ret = ping_receive_all (obj)) < 0)
- return (-2);
-
- return (ret);
+ return (ping_receive_all (obj));
}
static pinghost_t *ping_host_search (pinghost_t *ph, const char *host)
{
int opt;
+#ifdef IP_RECVTOS
/* Enable receiving the TOS field */
opt = 1;
setsockopt (ph->fd, IPPROTO_IP, IP_RECVTOS,
&opt, sizeof (opt));
+#endif /* IP_RECVTOS */
/* Enable receiving the TTL field */
opt = 1;