[Git][NTPsec/ntpsec][master] 3 commits: Assume the RC3493/RFC2553 IPv6 API everywhere.

Eric S. Raymond gitlab at mg.gitlab.com
Mon Sep 12 03:50:25 UTC 2016


Eric S. Raymond pushed to branch master at NTPsec / ntpsec


Commits:
c965c732 by Eric S. Raymond at 2016-09-11T17:40:36-04:00
Assume the RC3493/RFC2553 IPv6 API everywhere.

In fact, the code was already doing this via three compile-time
conditionals (ISC_PLATFORM_HAVEIPV6, ISC_PLATFORM_HAVEIN6PKTINFO,
ISC_PLATFORM_HAVESCOPEID) that were always on.  This behavior, in
turn, was inherited from the NTP Classic autoconf build.

Cleaning this up lets us drop a substantial amount of shim
code in libntp/ntp_rfc2553.[ch].

- - - - -
c9792762 by Eric S. Raymond at 2016-09-11T22:12:55-04:00
Partial update for ifdex-ignores.

- - - - -
343b07eb by Eric S. Raymond at 2016-09-11T23:49:55-04:00
Remove code conditioned on a symbol that is never defined.

- - - - -


14 changed files:

- INSTALL
- devel/hacking.txt
- devel/ifdex-ignores
- include/ntp_net.h
- include/ntp_rfc2553.h
- include/ntp_worker.h
- libisc/ifiter_ioctl.c
- libisc/interfaceiter.c
- libisc/net.c
- libisc/netaddr.c
- libntp/ntp_rfc2553.c
- ntpd/ntp_io.c
- tests/libntp/socktoa.c
- wafhelpers/configure.py


Changes:

=====================================
INSTALL
=====================================
--- a/INSTALL
+++ b/INSTALL
@@ -5,7 +5,8 @@
 This software should build on any operating system conformant to
 POSIX.1-2001 and ISO/IEC 9899:1999 (C99).  In addition, the
 operating system must have either a Linux-like adjtimex(2) call
-or a BSD-like pair of ntp_gettime(2)/ntp_adjtime(2) calls.
+or a BSD-like pair of ntp_gettime(2)/ntp_adjtime(2) calls. Also,
+it must support the IPv6 API defined in RFC2493 and RFC2553.
 
 There are some prerequisites.  Libraries need the library installed
 to run and in addition, the development headers installed to build.


=====================================
devel/hacking.txt
=====================================
--- a/devel/hacking.txt
+++ b/devel/hacking.txt
@@ -47,6 +47,9 @@ fallback implementation using native time calls.
 You can view POSIX-1.2001, with 2004 Corrigendum, online for free here:
     http://pubs.opengroup.org/onlinepubs/009695399/toc.htm
 
+You may assume Berkeley sockets and the IPv6 API defined in RFC2493
+and RFC2553.
+
 === Banned functions ===
 
 The following C99/POSIX functions are BANNED.  They are unsafe, tending to


=====================================
devel/ifdex-ignores
=====================================
--- a/devel/ifdex-ignores
+++ b/devel/ifdex-ignores
@@ -2,11 +2,11 @@
 # and filter reports about #if guards in order to locate configuration symbols
 # and plain old cruft.
 #
-# Should be ued together with waf's config.h output, which ifdex can
+# Should be used together with waf's config.h output, which ifdex can
 # interpret to exclude most of its config symbols. Thus, from the toplevel
 # directory:
 #
-# ifdex -X build/config.h devel/ifdex-ignores .
+# ifdex -X build/config.h -X devel/ifdex-ignores .
 #
 # No output from this command means all symbols are accounted for
 
@@ -25,10 +25,6 @@ NO_MAIN_ALLOWED		# Used to be set by VxWorks.
 # System capabilities that waf should detect but does not.
 # Presently they're either forced on in waf or never set at all
 OS_MISSES_SPECIFIC_ROUTE_UPDATES
-HAVE_SYSCTLBYNAME	# NTP Classic never set this.
-USE_SYSCTL_PORTRANGE	# NTP Classic never set this.
-ISC_PLATFORM_HAVEIPV6
-ISC_PLATFORM_HAVEIN6PKTINFO
 
 # Refclock-specific configuration (NTP Classic never set these)
 ENABLE_PPS720		# Enable use of PCL720 with TrueTime refclock
@@ -57,9 +53,11 @@ DEBUG_PPS720		# Only in refclock_true.c
 ISC_PLATFORM_BRACEPTHREADONCEINIT
 
 # Things WAF sets that don't get #undefs if they're not set
+ENABLE_EARLY_DROPROOT
+ENABLE_LEAP_SMEAR
+ENABLE_SECCOMP
 ENABLE_DEBUG_TIMING
 ENABLE_DNS_RETRY
-ENABLE_IPV6
 ENABLE_LOCKCLOCK
 ENABLE_MDNS_REGISTRATION
 ENABLE_MSSNTP
@@ -67,13 +65,16 @@ HAVE_LINUX_CAPABILITY
 HAVE_SOLARIS_PRIVS
 WORDS_BIGENDIAN
 
-# These things should be deduced, but are currently either forced in waf
-# or never set at all
-OS_MISSES_SPECIFIC_ROUTE_UPDATES
-HAVE_SYSCTLBYNAME	# NTP Classic never set this.
-USE_SYSCTL_PORTRANGE	# NTP Classic never set this.
-ISC_PLATFORM_HAVEIPV6
-ISC_PLATFORM_HAVEIN6PKTINFO
+# libsodium
+SODIUM_DLL_EXPORT
+SODIUM_STATIC
+sodium_H
+sodium_core_H
+sodium_export_H
+sodium_utils_H
+SYS_getrandom
+randombytes_H
+randombytes_sysrandom_H
 
 # Overrides
 OVERRIDE_BINTIME_CTLMSGBUF_SIZE
@@ -118,8 +119,6 @@ ISC_CHECK_NONE
 ISC_CHECK_REQUIRE
 ISC_FIX_TV_USEC
 ISC_MUTEX_PROFTABLESIZE
-ISC_NET_PORTRANGEHIGH
-ISC_NET_PORTRANGELOW
 JSMN_PARENT_LINKS
 JSMN_STRICT
 LIB_BUFLENGTH		# Only referenced by #if as a sanity check
@@ -128,6 +127,8 @@ MIN			# Minimum macro
 MRU_MAXDEPTH_DEF	# Exposed from ntp_monitor.c for hysterical raisins
 NEOCLOCK4X_FIRMWARE_VERSION_A	# Only used in the Neoclock4x driver
 NMEA_WRITE_SUPPORT	# Only used in the NMEA refclock
+NTIME_MSG
+OTIME_MSG
 FLASH_CODES_UNUSED
 NOTUSED
 ONCORE_VERBOSE_.*	# Debugging symbols internal to the OnCore refclock
@@ -135,7 +136,7 @@ PI			# Math constant used by the sim code
 RUN_TEST		# Internal to Unity
 SETSOCKOPT_ARG_CAST	# Can probably go away when the Windows port is cleaned up.
 THREAD_MINSTACKSIZE
-UINTPTR_MAX		# Unity and Windowa
+UINTPTR_MAX		# Unity
 UINTPTR_MAX0		# Unity
 INTPTR_MAX0		# Unity
 UNITY_.*		# Unity test framework internal macros
@@ -154,7 +155,6 @@ USE_WORK_PIPE		# Set in ntp_workimpl.h
 USE_WORK_THREAD
 
 
-USE_IPV6_SUPPORT
 USE_IPV6_MULTICAST_SUPPORT
 USE_LE_EDITLINE
 USE_LE_READLINE


=====================================
include/ntp_net.h
=====================================
--- a/include/ntp_net.h
+++ b/include/ntp_net.h
@@ -64,7 +64,6 @@ typedef union {
 /* sockaddr_u v6 scope */
 #define SCOPE_VAR(psau)		((psau)->sa6.sin6_scope_id)
 
-#ifdef ISC_PLATFORM_HAVESCOPEID
 /* v4/v6 scope (always zero for v4) */
 # define SCOPE(psau)		(IS_IPV4(psau)			\
 				    ? 0				\
@@ -80,11 +79,6 @@ typedef union {
 		if (IS_IPV6(psau))				\
 			SCOPE_VAR(psau) = (s);			\
 	while (0)
-#else	/* ISC_PLATFORM_HAVESCOPEID not defined */
-# define SCOPE(psau)		(0)
-# define SCOPE_EQ(psau1, psau2)	(1)
-# define SET_SCOPE(psau, s)	do { } while (0)
-#endif	/* ISC_PLATFORM_HAVESCOPEID */
 
 /* v4/v6 is multicast address */
 #define IS_MCAST(psau)						\


=====================================
include/ntp_rfc2553.h
=====================================
--- a/include/ntp_rfc2553.h
+++ b/include/ntp_rfc2553.h
@@ -100,11 +100,6 @@ struct addrinfo *copy_addrinfo_list_impl(const struct addrinfo *
  * If various macros are not defined we need to define them
  */
 
-#ifndef AF_INET6
-# define AF_INET6	AF_MAX
-# define PF_INET6	AF_INET6
-#endif
-
 #if !defined(_SS_MAXSIZE) && !defined(_SS_ALIGNSIZE)
 
 # define	_SS_MAXSIZE	128
@@ -155,76 +150,13 @@ struct addrinfo *copy_addrinfo_list_impl(const struct addrinfo *
 # define Z_AI_NUMERICSERV	AI_NUMERICSERV
 #endif
 
-#ifndef ISC_PLATFORM_HAVEIPV6
-
-struct addrinfo {
-	int	ai_flags;	/* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */
-	int	ai_family;	/* PF_xxx */
-	int	ai_socktype;	/* SOCK_xxx */
-	int	ai_protocol;	/* 0 or IPPROTO_xxx for IPv4 and IPv6 */
-	size_t	ai_addrlen;	/* length of ai_addr */
-	char	*ai_canonname;	/* canonical name for hostname */
-	struct	sockaddr *ai_addr;	/* binary address */
-	struct	addrinfo *ai_next;	/* next structure in linked list */
-};
-
-/*
- * Error return codes from getaddrinfo()
- */
-#define	EAI_ADDRFAMILY	 1	/* address family for hostname not supported */
-#define	EAI_AGAIN	 2	/* temporary failure in name resolution */
-#define	EAI_BADFLAGS	 3	/* invalid value for ai_flags */
-#define	EAI_FAIL	 4	/* non-recoverable failure in name resolution */
-#define	EAI_FAMILY	 5	/* ai_family not supported */
-#define	EAI_MEMORY	 6	/* memory allocation failure */
-#define	EAI_NODATA	 7	/* no address associated with hostname */
-#define	EAI_NONAME	 8	/* hostname nor servname provided, or not known */
-#define	EAI_SERVICE	 9	/* servname not supported for ai_socktype */
-#define	EAI_SOCKTYPE	10	/* ai_socktype not supported */
-#define	EAI_SYSTEM	11	/* system error returned in errno */
-#define	EAI_BADHINTS	12
-#define	EAI_PROTOCOL	13
-#define	EAI_MAX		14
-
-
-int	getaddrinfo (const char *, const char *,
-			 const struct addrinfo *, struct addrinfo **);
-int	getnameinfo (const struct sockaddr *, u_int, char *,
-			 size_t, char *, size_t, int);
-void	freeaddrinfo (struct addrinfo *);
-char	*gai_strerror (int);
-
-/*
- * Constants for getnameinfo()
- */
-#ifndef NI_MAXHOST
-#define	NI_MAXHOST	1025
-#define	NI_MAXSERV	32
-#endif
-
-/*
- * Flag values for getnameinfo()
- */
-#ifndef NI_NUMERICHOST
-#define	NI_NOFQDN	0x00000001
-#define	NI_NUMERICHOST	0x00000002
-#define	NI_NAMEREQD	0x00000004
-#define	NI_NUMERICSERV	0x00000008
-#define	NI_DGRAM	0x00000010
-#define NI_WITHSCOPEID	0x00000020
-#endif
-
-#endif /* !ISC_PLATFORM_HAVEIPV6 */
 
 /* 
  * Set up some macros to look for IPv6 and IPv6 multicast
  */
 
-#ifdef ISC_PLATFORM_HAVEIPV6
-# define USE_IPV6_SUPPORT
-# if defined(IPV6_JOIN_GROUP) && defined(IPV6_LEAVE_GROUP)
+#if defined(IPV6_JOIN_GROUP) && defined(IPV6_LEAVE_GROUP)
 #  define USE_IPV6_MULTICAST_SUPPORT
-# endif	/* IPV6 Multicast Support */
-#endif  /* IPv6 Support */
+#endif	/* IPV6 Multicast Support */
 
 #endif /* GUARD_!NTP_RFC2553_H */


=====================================
include/ntp_worker.h
=====================================
--- a/include/ntp_worker.h
+++ b/include/ntp_worker.h
@@ -7,11 +7,6 @@
 
 #include "ntp_workimpl.h"
 
-/* XXX: Why does OpenBSD need pthread.h here? */
-#ifdef PLATFORM_OPENBSD
-#include <pthread.h>
-#endif
-
 #ifdef USE_WORKER
 # if defined(USE_WORK_THREAD) && defined(USE_WORK_PIPE)
 #  ifdef HAVE_SEMAPHORE_H


=====================================
libisc/ifiter_ioctl.c
=====================================
--- a/libisc/ifiter_ioctl.c
+++ b/libisc/ifiter_ioctl.c
@@ -401,11 +401,7 @@ internal_current4(isc_interfaceiter_t *iter) {
 	memcpy(&ifreq, ifrp, sizeof(ifreq));
 
 	family = ifreq.ifr_addr.sa_family;
-#if defined(ISC_PLATFORM_HAVEIPV6)
 	if (family != AF_INET && family != AF_INET6)
-#else
-	if (family != AF_INET)
-#endif
 		return (ISC_R_IGNORE);
 
 	memset(&iter->current, 0, sizeof(iter->current));
@@ -601,11 +597,7 @@ internal_current6(isc_interfaceiter_t *iter) {
 	memcpy(&lifreq, ifrp, sizeof(lifreq));
 
 	family = lifreq.lifr_addr.ss_family;
-#ifdef ISC_PLATFORM_HAVEIPV6
 	if (family != AF_INET && family != AF_INET6)
-#else
-	if (family != AF_INET)
-#endif
 		return (ISC_R_IGNORE);
 
 	memset(&iter->current, 0, sizeof(iter->current));


=====================================
libisc/interfaceiter.c
=====================================
--- a/libisc/interfaceiter.c
+++ b/libisc/interfaceiter.c
@@ -55,10 +55,6 @@ get_addr(unsigned int family, isc_netaddr_t *dst, struct sockaddr *src,
 {
 	struct sockaddr_in6 *sa6;
 
-#if !defined(ISC_PLATFORM_HAVESCOPEID)
-	UNUSED(ifname);
-#endif
-
 	/* clear any remaining value for safety */
 	memset(dst, 0, sizeof(*dst));
 
@@ -73,7 +69,6 @@ get_addr(unsigned int family, isc_netaddr_t *dst, struct sockaddr *src,
 		sa6 = (struct sockaddr_in6 *)(void *)src;
 		memcpy(&dst->type.in6, &sa6->sin6_addr,
 		       sizeof(struct in6_addr));
-#ifdef ISC_PLATFORM_HAVESCOPEIDS
 		if (sa6->sin6_scope_id != 0)
 			isc_netaddr_setzone(dst, sa6->sin6_scope_id);
 		else {
@@ -117,7 +112,6 @@ get_addr(unsigned int family, isc_netaddr_t *dst, struct sockaddr *src,
 				}
 			}
 		}
-#endif
 		break;
 	default:
 		INSIST(0);


=====================================
libisc/net.c
=====================================
--- a/libisc/net.c
+++ b/libisc/net.c
@@ -21,16 +21,8 @@
 #include <isc/net.h>
 #include <isc/util.h>
 
-#if defined(ISC_PLATFORM_HAVEIPV6)
-
-# if defined(ISC_PLATFORM_HAVEIPV6)
 static bool 	once_ipv6only = false;
-# endif
-
-# if defined(ISC_PLATFORM_HAVEIPV6) && defined(ISC_PLATFORM_HAVEIN6PKTINFO)
 static bool 	once_ipv6pktinfo = false;
-# endif
-#endif /* ISC_PLATFORM_HAVEIPV6 */
 
 static bool 	once = false;
 
@@ -66,8 +58,6 @@ try_proto(int domain) {
 		}
 	}
 
-#ifdef ISC_PLATFORM_HAVEIPV6
-#ifdef ISC_PLATFORM_HAVEIN6PKTINFO
 	if (domain == PF_INET6) {
 		struct sockaddr_in6 sin6;
 		GETSOCKNAME_SOCKLEN_TYPE len;	/* NTP local change */
@@ -107,8 +97,6 @@ try_proto(int domain) {
 			}
 		}
 	}
-#endif
-#endif
 
 	(void)close(s);
 
@@ -118,11 +106,7 @@ try_proto(int domain) {
 static void
 initialize_action(void) {
 	ipv4_result = try_proto(PF_INET);
-#ifdef ISC_PLATFORM_HAVEIPV6
-#ifdef ISC_PLATFORM_HAVEIN6PKTINFO
 	ipv6_result = try_proto(PF_INET6);
-#endif
-#endif
 }
 
 static void
@@ -146,13 +130,13 @@ bool
 isc_net_probeipv6_bool(void) {
   return (ISC_R_SUCCESS == isc_net_probeipv6());
 }
+
 isc_result_t
 isc_net_probeipv6(void) {
 	initialize();
 	return (ipv6_result);
 }
 
-#ifdef ISC_PLATFORM_HAVEIPV6
 static void
 try_ipv6only(void) {
 #ifdef IPV6_V6ONLY
@@ -220,7 +204,6 @@ initialize_ipv6only(void) {
 	try_ipv6only();
 }
 
-#ifdef ISC_PLATFORM_HAVEIN6PKTINFO
 static void
 try_ipv6pktinfo(void) {
 	int s, on;
@@ -268,28 +251,21 @@ initialize_ipv6pktinfo(void) {
 	once_ipv6pktinfo = true;
 	try_ipv6pktinfo();
 }
-#endif /* ISC_PLATFORM_HAVEIN6PKTINFO */
-#endif /* ISC_PLATFORM_HAVEIPV6 */
 
 bool
 isc_net_probe_ipv6only_bool(void) {
     return (ISC_R_SUCCESS == isc_net_probe_ipv6only());
 }
+
 isc_result_t
 isc_net_probe_ipv6only(void) {
-#ifdef ISC_PLATFORM_HAVEIPV6
 	initialize_ipv6only();
-#endif
 	return (ipv6only_result);
 }
 
 isc_result_t
 isc_net_probe_ipv6pktinfo(void) {
-#ifdef ISC_PLATFORM_HAVEIPV6
-#ifdef ISC_PLATFORM_HAVEIN6PKTINFO
 	initialize_ipv6pktinfo();
-#endif
-#endif
 	return (ipv6pktinfo_result);
 }
 


=====================================
libisc/netaddr.c
=====================================
--- a/libisc/netaddr.c
+++ b/libisc/netaddr.c
@@ -185,11 +185,7 @@ isc_netaddr_fromsockaddr(isc_netaddr_t *t, const isc_sockaddr_t *s) {
 		break;
 	case AF_INET6:
 		memcpy(&t->type.in6, &s->type.sin6.sin6_addr, 16);
-#ifdef ISC_PLATFORM_HAVESCOPEID
 		t->zone = s->type.sin6.sin6_scope_id;
-#else
-		t->zone = 0;
-#endif
 		break;
 	default:
 		INSIST(0);


=====================================
libntp/ntp_rfc2553.c
=====================================
--- a/libntp/ntp_rfc2553.c
+++ b/libntp/ntp_rfc2553.c
@@ -44,9 +44,6 @@
  * In keeping with the rest of the NTP distribution, sockaddr_u is used
  * in preference to struct sockaddr_storage, which is a member of the
  * former union and so compatible.
- *
- * The rest of ntp_rfc2553.c is conditioned on ISC_PLATFORM_HAVEIPV6
- * not being defined, copy_addrinfo_*() are exceptions.
  */
 struct addrinfo * copy_addrinfo_common(const struct addrinfo *, int
 #ifdef EREALLOC_CALLSITE
@@ -168,348 +165,3 @@ copy_addrinfo_common(
 }
 
 
-#ifndef ISC_PLATFORM_HAVEIPV6
-
-static char *ai_errlist[] = {
-	"Success",
-	"Address family for hostname not supported",	/* EAI_ADDRFAMILY */
-	"Temporary failure in name resolution",		/* EAI_AGAIN      */
-	"Invalid value for ai_flags",		       	/* EAI_BADFLAGS   */
-	"Non-recoverable failure in name resolution", 	/* EAI_FAIL       */
-	"ai_family not supported",			/* EAI_FAMILY     */
-	"Memory allocation failure", 			/* EAI_MEMORY     */
-	"No address associated with hostname", 		/* EAI_NODATA     */
-	"hostname nor servname provided, or not known",	/* EAI_NONAME     */
-	"servname not supported for ai_socktype",	/* EAI_SERVICE    */
-	"ai_socktype not supported", 			/* EAI_SOCKTYPE   */
-	"System error returned in errno", 		/* EAI_SYSTEM     */
-	"Invalid value for hints",			/* EAI_BADHINTS	  */
-	"Resolved protocol is unknown",			/* EAI_PROTOCOL   */
-	"Unknown error", 				/* EAI_MAX        */
-};
-
-/*
- * Local declaration
- */
-int
-DNSlookup_name(
-	const char *name,
-	int ai_family,
-	struct hostent **Addresses
-);
-
-/*
- * Encapsulate gethostbyname to control the error code
- */
-int
-DNSlookup_name(
-	const char *name,
-	int ai_family,
-	struct hostent **Addresses
-)
-{
-	*Addresses = gethostbyname(name);
-	return (h_errno);
-}
-
-static	int do_nodename (const char *nodename, struct addrinfo *ai,
-    const struct addrinfo *hints);
-
-int
-getaddrinfo (const char *nodename, const char *servname,
-	const struct addrinfo *hints, struct addrinfo **res)
-{
-	int rval;
-	struct servent *sp;
-	struct addrinfo *ai = NULL;
-	int port;
-	const char *proto = NULL;
-	int family, socktype, flags, protocol;
-
-
-	/*
-	 * If no name is provide just return an error
-	 */
-	if (nodename == NULL && servname == NULL)
-		return (EAI_NONAME);
-	
-	ai = calloc(sizeof(struct addrinfo), 1);
-	if (ai == NULL)
-		return (EAI_MEMORY);
-
-	/*
-	 * Copy default values from hints, if available
-	 */
-	if (hints != NULL) {
-		ai->ai_flags = hints->ai_flags;
-		ai->ai_family = hints->ai_family;
-		ai->ai_socktype = hints->ai_socktype;
-		ai->ai_protocol = hints->ai_protocol;
-
-		family = hints->ai_family;
-		socktype = hints->ai_socktype;
-		protocol = hints->ai_protocol;
-		flags = hints->ai_flags;
-
-		switch (family) {
-		case AF_UNSPEC:
-			switch (hints->ai_socktype) {
-			case SOCK_STREAM:
-				proto = "tcp";
-				break;
-			case SOCK_DGRAM:
-				proto = "udp";
-				break;
-			}
-			break;
-		case AF_INET:
-		case AF_INET6:
-			switch (hints->ai_socktype) {
-			case 0:
-				break;
-			case SOCK_STREAM:
-				proto = "tcp";
-				break;
-			case SOCK_DGRAM:
-				proto = "udp";
-				break;
-			case SOCK_RAW:
-				break;
-			default:
-				return (EAI_SOCKTYPE);
-			}
-			break;
-#ifdef	AF_LOCAL
-		case AF_LOCAL:
-			switch (hints->ai_socktype) {
-			case 0:
-				break;
-			case SOCK_STREAM:
-				break;
-			case SOCK_DGRAM:
-				break;
-			default:
-				return (EAI_SOCKTYPE);
-			}
-			break;
-#endif
-		default:
-			return (EAI_FAMILY);
-		}
-	} else {
-		protocol = 0;
-		family = 0;
-		socktype = 0;
-		flags = 0;
-	}
-
-	rval = do_nodename(nodename, ai, hints);
-	if (rval != 0) {
-		freeaddrinfo(ai);
-		return (rval);
-	}
-
-	/*
-	 * First, look up the service name (port) if it was
-	 * requested.  If the socket type wasn't specified, then
-	 * try and figure it out.
-	 */
-	if (servname != NULL) {
-		char *e;
-
-		port = strtol(servname, &e, 10);
-		if (*e == '\0') {
-			if (socktype == 0)
-				return (EAI_SOCKTYPE);
-			if (port < 0 || port > 65535)
-				return (EAI_SERVICE);
-			port = htons((unsigned short) port);
-		} else {
-			sp = getservbyname(servname, proto);
-			if (sp == NULL)
-				return (EAI_SERVICE);
-			port = sp->s_port;
-			if (socktype == 0) {
-				if (strcmp(sp->s_proto, "tcp") == 0)
-					socktype = SOCK_STREAM;
-				else if (strcmp(sp->s_proto, "udp") == 0)
-					socktype = SOCK_DGRAM;
-			}
-		}
-	} else
-		port = 0;
-
-	/*
-	 *
-	 * Set up the port number
-	 */
-	if (ai->ai_family == AF_INET)
-		((struct sockaddr_in *)ai->ai_addr)->sin_port = (unsigned short) port;
-	else if (ai->ai_family == AF_INET6)
-		((struct sockaddr_in6 *)ai->ai_addr)->sin6_port = (unsigned short) port;
-	*res = ai;
-	return (0);
-}
-
-void
-freeaddrinfo(struct addrinfo *ai)
-{
-	if (ai->ai_canonname != NULL)
-	{
-		free(ai->ai_canonname);
-		ai->ai_canonname = NULL;
-	}
-	if (ai->ai_addr != NULL)
-	{
-		free(ai->ai_addr);
-		ai->ai_addr = NULL;
-	}
-	free(ai);
-	ai = NULL;
-}
-
-int
-getnameinfo (const struct sockaddr *sa, u_int salen, char *host,
-	size_t hostlen, char *serv, size_t servlen, int flags)
-{
-	struct hostent *hp;
-
-	if (sa->sa_family != AF_INET)
-		return (EAI_FAMILY);
-	hp = gethostbyaddr(
-	    (const char *)&((const struct sockaddr_in *)sa)->sin_addr,
-	    4, AF_INET);
-	if (hp == NULL) {
-		if (h_errno == TRY_AGAIN)
-			return (EAI_AGAIN);
-		else
-			return (EAI_FAIL);
-	}
-	if (host != NULL && hostlen > 0)
-		strlcpy(host, hp->h_name, hostlen);
-	return (0);
-}
-
-char *
-gai_strerror(int ecode)
-{
-	if (ecode < 0 || ecode > EAI_MAX)
-		ecode = EAI_MAX;
-	return ai_errlist[ecode];
-}
-
-static int
-do_nodename(
-	const char *nodename,
-	struct addrinfo *ai,
-	const struct addrinfo *hints)
-{
-	struct hostent *hp = NULL;
-	struct sockaddr_in *sockin;
-	struct sockaddr_in6 *sockin6;
-	int errval;
-
-	ai->ai_addr = calloc(sizeof(struct sockaddr_storage), 1);
-	if (ai->ai_addr == NULL)
-		return (EAI_MEMORY);
-
-	/*
-	 * For an empty node name just use the wildcard.
-	 * NOTE: We need to assume that the address family is
-	 * set elsewhere so that we can set the appropriate wildcard
-	 */
-	if (nodename == NULL) {
-		ai->ai_addrlen = sizeof(struct sockaddr_storage);
-		if (ai->ai_family == AF_INET)
-		{
-			sockin = (struct sockaddr_in *)ai->ai_addr;
-			sockin->sin_family = (short) ai->ai_family;
-			sockin->sin_addr.s_addr = htonl(INADDR_ANY);
-		}
-		else
-		{
-			sockin6 = (struct sockaddr_in6 *)ai->ai_addr;
-			sockin6->sin6_family = (short) ai->ai_family;
-			/*
-			 * we have already zeroed out the address
-			 * so we don't actually need to do this
-			 * This assignment is causing problems so
-			 * we don't do what this would do.
-			 sockin6->sin6_addr = in6addr_any;
-			 */
-		}
-#ifdef ISC_PLATFORM_HAVESALEN
-		ai->ai_addr->sa_len = SOCKLEN(ai->ai_addr);
-#endif
-
-		return (0);
-	}
-
-	/*
-	 * See if we have an IPv6 address
-	 */
-	if(strchr(nodename, ':') != NULL) {
-		if (inet_pton(AF_INET6, nodename,
-		    &((struct sockaddr_in6 *)ai->ai_addr)->sin6_addr) == 1) {
-			((struct sockaddr_in6 *)ai->ai_addr)->sin6_family = AF_INET6;
-			ai->ai_family = AF_INET6;
-			ai->ai_addrlen = sizeof(struct sockaddr_in6);
-			return (0);
-		}
-	}
-
-	/*
-	 * See if we have an IPv4 address
-	 */
-	if (inet_pton(AF_INET, nodename,
-	    &((struct sockaddr_in *)ai->ai_addr)->sin_addr) == 1) {
-		((struct sockaddr *)ai->ai_addr)->sa_family = AF_INET;
-		ai->ai_family = AF_INET;
-		ai->ai_addrlen = sizeof(struct sockaddr_in);
-		return (0);
-	}
-
-	/*
-	 * If the numeric host flag is set, don't attempt resolution
-	 */
-	if (hints != NULL && (hints->ai_flags & AI_NUMERICHOST))
-		return (EAI_NONAME);
-
-	/*
-	 * Look for a name
-	 */
-
-	errval = DNSlookup_name(nodename, AF_INET, &hp);
-
-	if (hp == NULL) {
-		if (errval == TRY_AGAIN || errval == EAI_AGAIN)
-			return (EAI_AGAIN);
-		else if (errval == EAI_NONAME) {
-			if (inet_pton(AF_INET, nodename,
-			    &((struct sockaddr_in *)ai->ai_addr)->sin_addr) == 1) {
-				((struct sockaddr *)ai->ai_addr)->sa_family = AF_INET;
-				ai->ai_family = AF_INET;
-				ai->ai_addrlen = sizeof(struct sockaddr_in);
-				return (0);
-			}
-			return (errval);
-		}
-		else
-		{
-			return (errval);
-		}
-	}
-	ai->ai_family = hp->h_addrtype;
-	ai->ai_addrlen = sizeof(struct sockaddr);
-	sockin = (struct sockaddr_in *)ai->ai_addr;
-	memcpy(&sockin->sin_addr, hp->h_addr, hp->h_length);
-	ai->ai_addr->sa_family = hp->h_addrtype;
-#ifdef ISC_PLATFORM_HAVESALEN
-	ai->ai_addr->sa_len = sizeof(struct sockaddr);
-#endif
-	if (hints != NULL && (hints->ai_flags & AI_CANONNAME))
-		ai->ai_canonname = estrdup(hp->h_name);
-	return (0);
-}
-
-#endif /* !ISC_PLATFORM_HAVEIPV6 */


=====================================
ntpd/ntp_io.c
=====================================
--- a/ntpd/ntp_io.c
+++ b/ntpd/ntp_io.c
@@ -1080,9 +1080,7 @@ create_wildcards(
 	)
 {
 	bool			v4wild;
-#ifdef USE_IPV6_SUPPORT
 	bool			v6wild;
-#endif
 	sockaddr_u		wildaddr;
 	nic_rule_action		action;
 	struct interface *	wildif;
@@ -1096,7 +1094,6 @@ create_wildcards(
 	action = ACTION_LISTEN;
 	ZERO(wildaddr);
 
-#ifdef USE_IPV6_SUPPORT
 	/*
 	 * create pseudo-interface with wildcard IPv6 address
 	 */
@@ -1141,7 +1138,6 @@ create_wildcards(
 		}
 		DPRINT_INTERFACE(2, (wildif, "created ", "\n"));
 	}
-#endif
 
 	/*
 	 * create pseudo-interface with wildcard IPv4 address
@@ -1439,15 +1435,12 @@ convert_isc_if(
 			    isc_if->broadcast.type.in.s_addr;
 		}
 	}
-#ifdef USE_IPV6_SUPPORT
 	else if (IS_IPV6(&itf->sin)) {
 		SET_ADDR6N(&itf->sin, isc_if->address.type.in6);
 		SET_ADDR6N(&itf->mask, isc_if->netmask.type.in6);
 
 		SET_SCOPE(&itf->sin, isc_if->address.zone);
 	}
-#endif /* USE_IPV6_SUPPORT */
-
 
 	/* Process the rest of the flags */
 
@@ -1582,10 +1575,8 @@ is_wildcard_addr(
 	if (IS_IPV4(psau) && !NSRCADR(psau))
 		return true;
 
-#ifdef USE_IPV6_SUPPORT
 	if (IS_IPV6(psau) && S_ADDR6_EQ(psau, &in6addr_any))
 		return true;
-#endif
 
 	return false;
 }
@@ -1630,7 +1621,7 @@ check_flags6(
 	uint32_t flags6
 	)
 {
-#if defined(USE_IPV6_SUPPORT) && defined(SIOCGIFAFLAG_IN6)
+#if defined(SIOCGIFAFLAG_IN6)
 	struct in6_ifreq ifr6;
 	int fd;
 
@@ -1652,7 +1643,7 @@ check_flags6(
 	UNUSED_ARG(psau);
 	UNUSED_ARG(name);
 	UNUSED_ARG(flags6);
-#endif	/* USE_IPV6_SUPPORT && SIOCGIFAFLAG_IN6 */
+#endif	/* SIOCGIFAFLAG_IN6 */
 	return false;
 }
 
@@ -3045,14 +3036,12 @@ sendpkt(
 						sizeof(cttl));
 				break;
 
-# ifdef USE_IPV6_SUPPORT
 			case AF_INET6 :
 				rc = setsockopt(src->fd, IPPROTO_IPV6,
 						 IPV6_MULTICAST_HOPS,
 						 (void *)&ttl,
 						 sizeof(ttl));
 				break;
-# endif	/* USE_IPV6_SUPPORT */
 
 			default:
 				rc = 0;
@@ -4106,7 +4095,6 @@ findbcastinter(
 		 */
 		if (addr_ismulticast(addr)
 		    && (iface->flags & INT_MULTICAST)) {
-#ifdef USE_IPV6_SUPPORT
 			/*
 			 * ...it is the winner unless we're looking for
 			 * an interface to use for link-local multicast
@@ -4116,7 +4104,6 @@ findbcastinter(
 			    && IN6_IS_ADDR_MC_LINKLOCAL(PSOCK_ADDR6(addr))
 			    && !IN6_IS_ADDR_LINKLOCAL(PSOCK_ADDR6(&iface->sin)))
 				continue;
-#endif
 			break;
 		}
 
@@ -4134,7 +4121,6 @@ findbcastinter(
 			    == (NSRCADR(addr)	  & NSRCADR(&iface->mask)))
 				break;
 		}
-#ifdef USE_IPV6_SUPPORT
 		else if (IS_IPV6(addr)) {
 			if (SOCK_EQ(&iface->bcast, addr))
 				break;
@@ -4142,7 +4128,6 @@ findbcastinter(
 			if (SOCK_EQ(netof(&iface->sin), netof(addr)))
 				break;
 		}
-#endif
 	}
 #endif /* SIOCGIFCONF */
 	if (NULL == iface) {


=====================================
tests/libntp/socktoa.c
=====================================
--- a/tests/libntp/socktoa.c
+++ b/tests/libntp/socktoa.c
@@ -43,7 +43,6 @@ TEST(socktoa, IPv6AddressWithPort) {
 	TEST_ASSERT_EQUAL_STRING(expected_port, sockporttoa(&input));
 }
 
-#ifdef ISC_PLATFORM_HAVESCOPEID
 TEST(socktoa, ScopedIPv6AddressWithPort) {
 	const struct in6_addr address = {{{
 		0xfe, 0x80, 0x00, 0x00,
@@ -67,7 +66,6 @@ TEST(socktoa, ScopedIPv6AddressWithPort) {
 	TEST_ASSERT_EQUAL_STRING(expected, socktoa(&input));
 	TEST_ASSERT_EQUAL_STRING(expected_port, sockporttoa(&input));
 }
-#endif	/* ISC_PLATFORM_HAVESCOPEID */
 
 TEST(socktoa, HashEqual) {
 	sockaddr_u input1 = CreateSockaddr4("192.00.2.2", 123);


=====================================
wafhelpers/configure.py
=====================================
--- a/wafhelpers/configure.py
+++ b/wafhelpers/configure.py
@@ -471,9 +471,6 @@ def cmd_configure(ctx, config):
         # XXX: Hack that needs to be fixed properly for all platforms
         ctx.define("ISC_PLATFORM_NORETURN_PRE", "", quote=False)
         ctx.define("ISC_PLATFORM_NORETURN_POST", "__attribute__((__noreturn__))", quote=False)
-        ctx.define("ISC_PLATFORM_HAVEIN6PKTINFO", 1)
-        ctx.define("ISC_PLATFORM_HAVEIPV6", 1)
-        ctx.define("ISC_PLATFORM_HAVESCOPEID", 1)
 
         if ctx.get_define("HAVE_SYS_SYSCTL_H"):
                 ctx.define("HAVE_IFLIST_SYSCTL", 1, comment="Whether sysctl interface exists")



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/0b82dbaa372facf7801287dcd5469b9826705735...343b07eba5bfe63ebaf92f84c82682803c294646
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20160912/44c7ae1f/attachment.html>


More information about the vc mailing list