#include "ntp_stdlib.h"
#include "ntp_config.h"
#include "ntp_cmdargs.h"
+#include <isc/boolean.h>
+#include <isc/net.h>
#include <stdio.h>
#include <ctype.h>
hints.ai_family = addr->ss_family;
else
hints.ai_family = AF_UNSPEC;
+ /*
+ * If we don't have an IPv6 stack, just look up IPv4 addresses
+ */
+ if (isc_net_probeipv6() != ISC_TRUE)
+ hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_DGRAM;
#ifdef DEBUG
# include <sys/param.h> /* MAXHOSTNAMELEN (often) */
#endif
+#include <isc/boolean.h>
+#include <isc/net.h>
+
#define STREQ(a, b) (*(a) == *(b) && strcmp((a), (b)) == 0)
/*
)
{
struct addrinfo *addr;
+ struct addrinfo hints;
int error;
checkparent(); /* make sure our guy is still running */
msyslog(LOG_INFO, "findhostaddr: Resolving <%s>",
entry->ce_name);
#endif /* DEBUG */
- error = getaddrinfo(entry->ce_name, NULL, NULL, &addr);
+
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_family = AF_UNSPEC;
+ /*
+ * If the IPv6 stack is not available look only for IPv4 addresses
+ */
+ if (isc_net_probeipv6() == ISC_FALSE)
+ hints.ai_family = AF_INET;
+
+ error = getaddrinfo(entry->ce_name, NULL, &hints, &addr);
if (error == 0) {
entry->peer_store = *((struct sockaddr_storage*)(addr->ai_addr));
if (entry->peer_store.ss_family == AF_INET) {
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_UNSPEC;
+
+ /*
+ * If the IPv6 stack is not available look only for IPv4 addresses
+ */
+ if (isc_net_probeipv6() == ISC_FALSE)
+ hints.ai_family = AF_INET;
+
hints.ai_socktype = SOCK_DGRAM;
if (getaddrinfo(NULL, "ntp", &hints, &addrResult)!=0) {
msyslog(LOG_ERR, "getaddrinfo failed: %m");