Code

Mac OX S 10.7 compile fixes.
authorClayton O'Neill <clayton@oneill.net>
Sun, 30 Oct 2011 23:36:46 +0000 (19:36 -0400)
committerFlorian Forster <octo@verplant.org>
Tue, 31 Jan 2012 15:01:07 +0000 (16:01 +0100)
I've attached a patch that's required to be able to compile liboping on
MacOS 10.7 (Lion).  The issue is that the IPv6 API's are changing from
RFC 2292 to 3542, and Apple's headers require you to state which API you
want to use by defining a constant.  I've changed it to use either based
on the presence of constants, but to prefer 3542 on MacOS.

One problem I see with this is that if you have both multicast and
unicast TTL's set, then this won't report both of them, but I'm not sure
if that's even valid and it would require more significant rework.
Also, I noticed you have fixed the IP_RECVTOS issue in head.  That patch
is also required to be able to compile on Solaris and MacOS.

Signed-off-by: Florian Forster <octo@verplant.org>
src/liboping.c

index 76a7d53456c1fd31be8fef44b87695e6f74bfb70..74122a80f63706c4c9166f30bba50f6c6e3a3073 100644 (file)
  * 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
@@ -545,6 +549,7 @@ static int ping_receive_one (pingobj_t *obj, const pinghost_t *ph,
                                                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),
@@ -552,6 +557,25 @@ static int ping_receive_one (pingobj_t *obj, const pinghost_t *ph,
                                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);