From 85f7a4054d96689307c9c10e8e7e1aad4f11eb24 Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Mon, 12 Oct 2015 11:22:27 +0200 Subject: [PATCH] configure: include IPV6_PKTINFO in struct in6_pktinfo check --- configure | 4 ++-- ntp_io.c | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/configure b/configure index c33c2a5..453c4e5 100755 --- a/configure +++ b/configure @@ -528,12 +528,12 @@ if [ $feat_ipv6 = "1" ] && \ then add_def FEAT_IPV6 if test_code 'in6_pktinfo' 'sys/socket.h netinet/in.h' '' '' ' - return sizeof(struct in6_pktinfo);' + return sizeof (struct in6_pktinfo) + IPV6_PKTINFO;' then add_def HAVE_IN6_PKTINFO else if test_code 'in6_pktinfo with _GNU_SOURCE' 'sys/socket.h netinet/in.h' \ - '-D_GNU_SOURCE' '' 'return sizeof(struct in6_pktinfo);' + '-D_GNU_SOURCE' '' 'return sizeof (struct in6_pktinfo) + IPV6_PKTINFO;' then add_def _GNU_SOURCE add_def HAVE_IN6_PKTINFO diff --git a/ntp_io.c b/ntp_io.c index 68d677d..68741ec 100644 --- a/ntp_io.c +++ b/ntp_io.c @@ -206,14 +206,16 @@ prepare_socket(int family, int port_number, int client_only) } #endif +#ifdef HAVE_IN6_PKTINFO #ifdef IPV6_RECVPKTINFO if (setsockopt(sock_fd, IPPROTO_IPV6, IPV6_RECVPKTINFO, (char *)&on_off, sizeof(on_off)) < 0) { LOG(LOGS_ERR, LOGF_NtpIO, "Could not set IPv6 packet info socket option"); } -#elif defined(IPV6_PKTINFO) +#else if (setsockopt(sock_fd, IPPROTO_IPV6, IPV6_PKTINFO, (char *)&on_off, sizeof(on_off)) < 0) { LOG(LOGS_ERR, LOGF_NtpIO, "Could not set IPv6 packet info socket option"); } +#endif #endif } #endif @@ -541,7 +543,7 @@ read_from_socket(void *anything) } #endif -#if defined(IPV6_PKTINFO) && defined(HAVE_IN6_PKTINFO) +#ifdef HAVE_IN6_PKTINFO if (cmsg->cmsg_level == IPPROTO_IPV6 && cmsg->cmsg_type == IPV6_PKTINFO) { struct in6_pktinfo ipi; @@ -647,7 +649,7 @@ send_packet(void *packet, int packetlen, NTP_Remote_Address *remote_addr, NTP_Lo } #endif -#if defined(IPV6_PKTINFO) && defined(HAVE_IN6_PKTINFO) +#ifdef HAVE_IN6_PKTINFO if (local_addr->ip_addr.family == IPADDR_INET6) { struct cmsghdr *cmsg; struct in6_pktinfo *ipi;