From 3165470b21eef51bf214f474d4b167c2151276a9 Mon Sep 17 00:00:00 2001 From: Clayton O'Neill Date: Sun, 30 Oct 2011 19:36:46 -0400 Subject: [PATCH] Mac OX S 10.7 compile fixes. 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 --- src/liboping.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/liboping.c b/src/liboping.c index 76a7d53..74122a8 100644 --- a/src/liboping.c +++ b/src/liboping.c @@ -17,6 +17,10 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#ifdef __APPLE__ +#define __APPLE_USE_RFC_3542 +#endif + #if HAVE_CONFIG_H # include #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); -- 2.11.0