src/liboping.c: Do not reset recv_ttl in ping_receive_one().
[liboping.git] / src / liboping.c
index 0cff9f4..2ccbf4d 100644 (file)
@@ -145,7 +145,7 @@ struct pingobj
 /* Even though Posix requires "strerror_r" to return an "int",
  * some systems (e.g. the GNU libc) return a "char *" _and_
  * ignore the second argument ... -tokkee */
-char *sstrerror (int errnum, char *buf, size_t buflen)
+static char *sstrerror (int errnum, char *buf, size_t buflen)
 {
        buf[0] = 0;
 
@@ -478,7 +478,6 @@ static int ping_receive_one (int fd, pinghost_t *ph, struct timeval *now)
 
        /* Iterate over all auxiliary data in msghdr */
        recv_ttl = -1;
-       ph->recv_ttl = -1;
        for (cmsg = CMSG_FIRSTHDR (&msghdr); /* {{{ */
                        cmsg != NULL;
                        cmsg = CMSG_NXTHDR (&msghdr, cmsg))
@@ -592,7 +591,10 @@ static int ping_receive_all (pingobj_t *obj)
        ret = 0;
 
        for (ptr = ph; ptr != NULL; ptr = ptr->next)
-               ptr->latency = -1.0;
+       {
+               ptr->latency  = -1.0;
+               ptr->recv_ttl = -1;
+       }
 
        if (gettimeofday (&nowtime, NULL) == -1)
        {
@@ -1352,6 +1354,7 @@ int ping_host_add (pingobj_t *obj, const char *host)
                        setsockopt (ph->fd, IPPROTO_IP, IP_RECVTTL,
                                        &opt, sizeof (opt));
                }
+#if defined(IPPROTO_IPV6) && defined(IPV6_RECVHOPLIMIT)
                else if (ph->addrfamily == AF_INET6)
                {
                        int opt = 1;
@@ -1359,6 +1362,7 @@ int ping_host_add (pingobj_t *obj, const char *host)
                        setsockopt (ph->fd, IPPROTO_IPV6, IPV6_RECVHOPLIMIT,
                                        &opt, sizeof (opt));
                }
+#endif
 
                break;
        }