From 55dbbab5ebbf17bd6cf08d0dfd62ed1fec1e835e Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Mon, 12 Oct 2015 11:44:21 +0200 Subject: [PATCH] configure: check for struct in_pktinfo with ipi_spec_dst On NetBSD there is a struct in_pktinfo, but it doesn't have the ipi_spec_dst field and it breaks compilation. --- configure | 7 +++++++ ntp_io.c | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/configure b/configure index 4498e0f..3142149 100755 --- a/configure +++ b/configure @@ -519,6 +519,13 @@ if test_code '' 'inttypes.h' '' '' ''; then add_def HAVE_INTTYPES_H fi +if test_code 'struct in_pktinfo' 'sys/socket.h netinet/in.h' '' '' ' + struct in_pktinfo ipi; + return sizeof (ipi.ipi_spec_dst.s_addr) + IP_PKTINFO;' +then + add_def HAVE_IN_PKTINFO +fi + if [ $feat_ipv6 = "1" ] && \ test_code 'IPv6 support' 'arpa/inet.h sys/socket.h netinet/in.h' '' "$EXTRA_LIBS" ' struct sockaddr_in6 n; diff --git a/ntp_io.c b/ntp_io.c index 68741ec..24b1190 100644 --- a/ntp_io.c +++ b/ntp_io.c @@ -189,7 +189,7 @@ prepare_socket(int family, int port_number, int client_only) #endif if (family == AF_INET) { -#ifdef IP_PKTINFO +#ifdef HAVE_IN_PKTINFO /* We want the local IP info on server sockets */ if (setsockopt(sock_fd, IPPROTO_IP, IP_PKTINFO, (char *)&on_off, sizeof(on_off)) < 0) { LOG(LOGS_ERR, LOGF_NtpIO, "Could not set packet info socket option"); @@ -533,7 +533,7 @@ read_from_socket(void *anything) local_addr.sock_fd = sock_fd; for (cmsg = CMSG_FIRSTHDR(&msg); cmsg; cmsg = CMSG_NXTHDR(&msg, cmsg)) { -#ifdef IP_PKTINFO +#ifdef HAVE_IN_PKTINFO if (cmsg->cmsg_level == IPPROTO_IP && cmsg->cmsg_type == IP_PKTINFO) { struct in_pktinfo ipi; @@ -631,7 +631,7 @@ send_packet(void *packet, int packetlen, NTP_Remote_Address *remote_addr, NTP_Lo msg.msg_flags = 0; cmsglen = 0; -#ifdef IP_PKTINFO +#ifdef HAVE_IN_PKTINFO if (local_addr->ip_addr.family == IPADDR_INET4) { struct cmsghdr *cmsg; struct in_pktinfo *ipi;