[ntp:bk-ntp-dev-send] BitKeeper patch

Harlan Stenn stenn at whimsy.udel.edu
Mon May 8 08:57:21 UTC 2006


This BitKeeper patch contains the following changesets:
mayer at pogo.udel.edu|ChangeSet|20060505124859|57177
mayer at pogo.udel.edu|ChangeSet|20060415223257|32376
mayer at pogo.udel.edu|ChangeSet|20060505120051|43747
mayer at pogo.udel.edu|ChangeSet|20060415223329|32397
mayer at pogo.udel.edu|ChangeSet|20060505204034|57176

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# ID:	stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
# User:	stenn
# Host:	whimsy.udel.edu
# Root:	/deacon/backroom/ntp-dev

#
#--- 1.27/libntp/ntp_rfc2553.c	2005-11-01 23:40:06 -05:00
#+++ 1.28/libntp/ntp_rfc2553.c	2006-05-05 08:42:45 -04:00
#@@ -101,6 +101,30 @@
# 	"Unknown error", 				/* EAI_MAX        */
# };
# 
#+
#+int
#+DNSlookup_name(
#+	const char FAR *name,
#+	int ai_family,
#+	struct hostent **Addresses
#+);
#+
#+#ifndef SYS_WINNT
#+/*
#+ * Encapsulate gethostbyname to control the error code
#+ */
#+int
#+DNSlookup_name(
#+	const char FAR *name,
#+	int ai_family,
#+	struct hostent **Addresses
#+)
#+{
#+	*Addresses = gethostbyname(name);
#+	return (h_errno);
#+}
#+#endif
#+
# static	int do_nodename P((const char *nodename, struct addrinfo *ai,
#     const struct addrinfo *hints));
# 
#@@ -244,10 +268,17 @@
# 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
#@@ -288,9 +319,10 @@
# 	struct addrinfo *ai,
# 	const struct addrinfo *hints)
# {
#-	struct hostent *hp;
#+	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)
#@@ -355,11 +387,13 @@
# 	/*
# 	 * Look for a name
# 	 */
#-	hp = gethostbyname(nodename);
#+
#+	errval = DNSlookup_name(nodename, AF_INET, &hp);
#+
# 	if (hp == NULL) {
#-		if (h_errno == TRY_AGAIN)
#+		if (errval == TRY_AGAIN || errval == EAI_AGAIN)
# 			return (EAI_AGAIN);
#-		else {
#+		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;
#@@ -367,7 +401,11 @@
# 				ai->ai_addrlen = sizeof(struct sockaddr_in);
# 				return (0);
# 			}
#-			return (EAI_FAIL);
#+			return (errval);
#+		}
#+		else
#+		{
#+			return (errval);
# 		}
# 	}
# 	ai->ai_family = hp->h_addrtype;
#--- New file ---
#+++ ports/winnt/libntp/dnslookup.c	06/05/05 08:36:40
#/*
# * Copyright (C) 2006  Internet Systems Consortium, Inc. ("ISC")
# *
# * Permission to use, copy, modify, and distribute this software for any
# * purpose with or without fee is hereby granted, provided that the above
# * copyright notice and this permission notice appear in all copies.
# *
# * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
# * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
# * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
# * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
# * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# * PERFORMANCE OF THIS SOFTWARE.
# */
#
#/*
# * This module uses Windows lookup facilities to get the address information
# * wherever it resides. This avoids calling the Internet standard funcction
# * gethostbyname and gives us more control over the results since the
# * Microsoft implementation seems to return the wrong error code for some
# * conditions.
# */
#
##include <config.h>
##include <ws2tcpip.h>
##include <nspapi.h>
##include <svcguid.h>
##include <ntp_rfc2553.h>
##include <malloc.h>
##include <ntp_stdlib.h>
##include <syslog.h>
#
#/*
# * Set this Macro to force retries even if it fails
# * the lookup
# */
##ifdef FORCE_DNSRETRY
#
##undef EAI_NONAME
##define EAI_NONAME EAI_AGAIN
#
##endif
#
#typedef struct hostent hostent_t;
#
#int ReturnCode(int errcode)
#{
#	int retcode;
#
#	switch (errcode)
#	{
#	case 0:
#		return (0);
#	case WSAEINVAL:
#		return (EAI_BADHINTS);
#	case WSANO_DATA:
#		return (EAI_NONAME);
#	case WSANOTINITIALISED:
#	case WSASERVICE_NOT_FOUND:
#		return (EAI_FAIL);
#	case WSA_NOT_ENOUGH_MEMORY:
#		return (EAI_MEMORY);
#	default:
#		return (EAI_SYSTEM);
#	}
#}
#
#int
#AddToAddresses(char **Addresses, int *cnt, CSADDR_INFO *csaddr)
#{
#
#	int csize;
#	struct in_addr *sinaddr;
#	char *addr;
#	struct in_addr *addr_list;
#	struct sockaddr_in *sin;
#	sin = (struct sockaddr_in *) csaddr->RemoteAddr.lpSockaddr;
#	if (*Addresses != NULL)
#	{
#		csize = _msize(*Addresses);
#		addr_list = realloc(*Addresses, csize + sizeof(struct in_addr));
#	}
#	else
#	{
#		csize = 0;
#		addr_list = malloc(sizeof(struct in_addr));
#	}
#	addr = (char *) addr_list;
#	sinaddr = &((struct in_addr*) addr)[(*cnt)];
#	memset(sinaddr, 0, sizeof(sinaddr));
#	memcpy(sinaddr, &sin->sin_addr, sizeof(struct in_addr));
#	
#	(*cnt)++;
#	*Addresses = addr;
#	return 0;
#}
#
#int
#DNSlookup_name(
#	const char FAR *name,
#	int ai_family,
#	struct hostent **Addresses
#)
#{
#	char buffer[sizeof(WSAQUERYSET) + 2048];
#	WSAQUERYSET query;
#	hostent_t *addr = NULL;
#	char *bufaddr = NULL;
#	char ** addrlist = &bufaddr;
#	int addrcnt = 0;
#	WSAQUERYSET *results = (WSAQUERYSET *) buffer;
#	GUID	HostnameGUID = SVCID_INET_HOSTADDRBYNAME;
#	HANDLE	handle;
#	DWORD dwLength;
#	int err = 0;
#	int retcode = 0;
#	int errcode = 0;
#	DWORD i;
#
#	/*
#	 * First we must create a query set
#	 */
#	memset(&query, 0, sizeof(query));
#	query.dwSize = sizeof(query);
#	query.lpszServiceInstanceName = (char *)name;
#	query.dwNameSpace = NS_DNS;
#	query.lpServiceClassId = &HostnameGUID;
#
#	err = WSALookupServiceBegin(&query,
#                                 LUP_RETURN_NAME | LUP_RETURN_BLOB | LUP_RETURN_ADDR,
#                                 &handle);
#
#	if(err == SOCKET_ERROR)
#	{
#		/*
#		 * Convert the error code and return
#		 */
#		return (ReturnCode(WSAGetLastError()));
#	}
#
#	/*
#	 * Initially none
#	 * Change if we get something
#	 */
#	retcode = EAI_NONAME;
#	dwLength = sizeof(buffer);
#	*addrlist = NULL;
#
#	while(err == 0)		/* Drop out when error */
#	{
#		memset(&buffer, 0, dwLength);
#		err = WSALookupServiceNext(
#			                handle,
#			                0,
#			                &dwLength,
#			                results);
#		errcode = WSAGetLastError();
#		if (results->dwNumberOfCsAddrs > 0)
#		{
#			if (addr == NULL)
#			{
#				addr = (struct hostent *) malloc(sizeof(struct hostent));
#				memset(addr, 0, sizeof(struct hostent));
#				addr->h_addrtype = (short) results->lpcsaBuffer->iSocketType;
#				addr->h_length = (short) results->lpcsaBuffer->RemoteAddr.iSockaddrLength;
#			}
#			for (i = 0; i < results->dwNumberOfCsAddrs; i++)
#			{
#				AddToAddresses(addrlist, &addrcnt, &results->lpcsaBuffer[i]);
#			}
#		}
#
#	}
#	if (addr != NULL)
#	{
#		addr->h_name = (char *) name;
#		addr->h_addr_list = addrlist;
#		retcode = 0;
#	}
#	else
#	{
##ifdef FORCE_DNSRETRY
#		/*
#		 * We do this or the error would never be logged
#		 */
#		if (errcode == WSANO_DATA)
#			msyslog(LOG_ERR, "Address not found for %s", name);
##endif
#		retcode = ReturnCode(errcode);
#	}
#	*Addresses = addr;
#	WSALookupServiceEnd(handle);
#	return (retcode);
#}
#
#
#
#--- 1.20/libntp/recvbuff.c	2006-04-15 18:33:18 -04:00
#+++ 1.22/libntp/recvbuff.c	2006-05-05 16:39:46 -04:00
#@@ -122,7 +122,6 @@
# void
# freerecvbuf(recvbuf_t *rb)
# {
#-	BLOCKIO();
# 	LOCK();
# 	ISC_LIST_APPEND(free_list, rb, link);
# #if defined SYS_WINNT
#@@ -131,26 +130,22 @@
# #endif
# 	free_recvbufs++;
# 	UNLOCK();
#-	UNBLOCKIO();
# }
# 
# 	
# void
# add_full_recv_buffer(recvbuf_t *rb)
# {
#-	BLOCKIO();
# 	LOCK();
# 	ISC_LIST_APPEND(full_list, rb, link);
# 	full_recvbufs++;
# 	UNLOCK();
#-	UNBLOCKIO();
# }
# 
# recvbuf_t *
# get_free_recv_buffer(void)
# {
# 	recvbuf_t * buffer = NULL;
#-	BLOCKIO();
# 	LOCK();
# 	buffer = ISC_LIST_HEAD(free_list);
# 	if (buffer == NULL)
#@@ -162,7 +157,6 @@
# 		{
# 			msyslog(LOG_ERR, "No more memory for recvufs");
# 			UNLOCK();
#-			UNBLOCKIO();
# 			return (NULL);
# 		}
# 		buffer = ISC_LIST_HEAD(free_list);
#@@ -170,7 +164,6 @@
# 		{
# 			msyslog(LOG_ERR, "Failed to obtain more memory for recvbufs");
# 			UNLOCK();
#-			UNBLOCKIO();
# 			return (NULL);
# 		}
# 	}
#@@ -178,7 +171,6 @@
# 	free_recvbufs--;
# 	initialise_buffer(buffer);
# 	UNLOCK();
#-	UNBLOCKIO();
# 	return (buffer);
# }
# 
#@@ -186,7 +178,6 @@
# get_full_recv_buffer(void)
# {
# 	recvbuf_t *rbuf;
#-	BLOCKIO();
# 	LOCK();
# 	rbuf = ISC_LIST_HEAD(full_list);
# 	if (rbuf != NULL)
#@@ -202,7 +193,6 @@
# 		full_recvbufs = 0;
# 	}
# 	UNLOCK();
#-	UNBLOCKIO();
# 	return (rbuf);
# }
# 
#
#--- 1.42/ntpd/ntp_intres.c	2005-11-03 23:39:56 -05:00
#+++ 1.43/ntpd/ntp_intres.c	2006-05-05 08:45:32 -04:00
#@@ -509,6 +509,10 @@
# 				entry->ce_config.v6_flag = 1;
# 			}
# 		}
#+		else if (error == EAI_NONAME)
#+		{
#+			msyslog(LOG_ERR, "host name not found: %s", entry->ce_name);
#+		}
# 	} else {
# #ifdef DEBUG
# 		if (debug > 2)
#@@ -522,14 +526,24 @@
# 				   NULL, 0, 0);
# 	}
# 
#+	/*
#+	 * If the resolver failed, see if the failure is
#+	 * temporary.  If so, return success.
#+	 */
# 	if (error != 0) {
#-		/*
#-		 * If the resolver is in use, see if the failure is
#-		 * temporary.  If so, return success.
#-		 */
#-		if (error == EAI_AGAIN)
#-		    return (1);
#-		return (0);
#+		switch (error)
#+		{
#+		case EAI_AGAIN:
#+			return (1);
#+		case EAI_NONAME:
#+			return (0);
#+		case EAI_NODATA:
#+		case EAI_FAIL:
#+		case EAI_SYSTEM:
#+			return (1);
#+		default:
#+			return (0);
#+		}
# 	}
# 
# 	if (entry->ce_name) {
#@@ -558,7 +572,7 @@
# 	struct addrinfo *addrResult;
# 	const char *localhost = "127.0.0.1";	/* Use IPv6 loopback */
# 
#-	if (sockfd >= 0)
#+	if (sockfd != INVALID_SOCKET)
# 	    return;
# 
# 	memset(&hints, 0, sizeof(hints));
#
#--- 1.81/ntpd/ntpd.c	2006-04-15 18:32:25 -04:00
#+++ 1.82/ntpd/ntpd.c	2006-05-05 08:00:45 -04:00
#@@ -889,14 +889,13 @@
# 		block_io_and_alarm();
# # endif
# 
#-		tot_full_recvbufs = full_recvbuffs();	/* get received buffers */
# 		if (alarm_flag) 	/* alarmed? */
# 		{
# 			was_alarmed = 1;
# 			alarm_flag = 0;
# 		}
# 
#-		if (!was_alarmed && tot_full_recvbufs == 0)
#+		if (!was_alarmed && has_full_recv_buffer() == ISC_FALSE)
# 		{
# 			/*
# 			 * Nothing to do.  Wait for something.
#@@ -939,44 +938,56 @@
# 				was_alarmed = 1;
# 				alarm_flag = 0;
# 			}
#-			tot_full_recvbufs = full_recvbuffs();  /* get received buffers */
# 		}
#-# ifdef HAVE_SIGNALED_IO
#-		unblock_io_and_alarm();
#-# endif /* HAVE_SIGNALED_IO */
# 
#-		/*
#-		 * Out here, signals are unblocked.  Call timer routine
#-		 * to process expiry.
#-		 */
# 		if (was_alarmed)
# 		{
#+# ifdef HAVE_SIGNALED_IO
#+			unblock_io_and_alarm();
#+# endif /* HAVE_SIGNALED_IO */
#+			/*
#+			 * Out here, signals are unblocked.  Call timer routine
#+			 * to process expiry.
#+			 */
# 			timer();
# 			was_alarmed = 0;
#+# ifdef HAVE_SIGNALED_IO
#+                        block_io_and_alarm();
#+# endif /* HAVE_SIGNALED_IO */
# 		}
# 
# #endif /* HAVE_IO_COMPLETION_PORT */
# 
#-		while (1)
#+		rbuf = get_full_recv_buffer();
#+		while (rbuf != NULL)
# 		{
#+# ifdef HAVE_SIGNALED_IO
#+			unblock_io_and_alarm();
#+# endif /* HAVE_SIGNALED_IO */
# 			/*
# 			 * Call the data procedure to handle each received
# 			 * packet.
# 			 */
#-			rbuf = get_full_recv_buffer();
# 			if (rbuf != NULL)	/* This should always be true */
# 			{
# 				(rbuf->receiver)(rbuf);
# 				freerecvbuf(rbuf);
#+			} else {
#+				 msyslog(LOG_ERR, "receive buffer corruption - receiver found to be NULL - ABORTING");
#+				 abort();
# 			}
#-			else
#-				break;
#+# ifdef HAVE_SIGNALED_IO
#+                        block_io_and_alarm();
#+# endif /* HAVE_SIGNALED_IO */
# 		}
# 
# 		/*
# 		 * Go around again
# 		 */
# 	}
#+# ifdef HAVE_SIGNALED_IO
#+	unblock_io_and_alarm();
#+# endif /* HAVE_SIGNALED_IO */
# 	return 1;
# }
# 
#
#--- 1.27/ports/winnt/libntp/libntp.dsp	2005-10-27 22:11:51 -04:00
#+++ 1.28/ports/winnt/libntp/libntp.dsp	2006-05-05 08:44:04 -04:00
#@@ -150,6 +150,10 @@
# # End Source File
# # Begin Source File
# 
#+SOURCE=.\dnslookup.c
#+# End Source File
#+# Begin Source File
#+
# SOURCE=..\..\..\libntp\dofptoa.c
# # End Source File
# # Begin Source File
#

# Diff checksum=8a81148a


# Patch vers:	1.3
# Patch type:	REGULAR

== ChangeSet ==
stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
stenn at whimsy.udel.edu|ChangeSet|20060413081426|32579
D 1.1496 06/04/15 18:32:57-04:00 mayer at pogo.udel.edu +1 -0
B stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
C
c Fix Bug #596 and #572 to deal with polling restrictions
K 32376
P ChangeSet
------------------------------------------------

0a0
> stenn at whimsy.udel.edu|ntpd/ntpd.c|19990526004817|01635|3aed0663 mayer at pogo.udel.edu|ntpd/ntpd.c|20060415223225|48280

mayer at pogo.udel.edu|ChangeSet|20060415223257|32376
D 1.1497 06/04/15 18:33:29-04:00 mayer at pogo.udel.edu +1 -0
B stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
C
c Fix Bug #596 and #572 to deal with polling restrictions
K 32397
P ChangeSet
------------------------------------------------

0a0
> stenn at whimsy.udel.edu|libntp/recvbuff.c|19990721005052|03868|06470f1c mayer at pogo.udel.edu|libntp/recvbuff.c|20060415223318|48579

mayer at pogo.udel.edu|ChangeSet|20060415223329|32397
D 1.1498 06/05/05 08:00:51-04:00 mayer at pogo.udel.edu +2 -0
B stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
C
c Merge bk://www.ntp.org/home/bk/ntp-dev
c into  pogo.udel.edu:/pogo/users/mayer/ntp-dev
i stenn at whimsy.udel.edu|ChangeSet|20060418095813|32572
i stenn at whimsy.udel.edu|ChangeSet|20060421035956|32627
i stenn at whimsy.udel.edu|ChangeSet|20060421040943|32614
i kardel at pogo.udel.edu|ChangeSet|20060501182754|32600
i kardel at pogo.udel.edu|ChangeSet|20060502091340|32599
i stenn at pogo.udel.edu|ChangeSet|20060504094213|43943
i stenn at deacon.udel.edu|ChangeSet|20060504095417|43886
i stenn at whimsy.udel.edu|ChangeSet|20060504110318|43884
i stenn at whimsy.udel.edu|ChangeSet|20060504235054|43892
i stenn at whimsy.udel.edu|ChangeSet|20060505022816|43925
i stenn at whimsy.udel.edu|ChangeSet|20060505043738|43926
i stenn at whimsy.udel.edu|ChangeSet|20060505044227|43921
i stenn at whimsy.udel.edu|ChangeSet|20060505044724|43930
i stenn at whimsy.udel.edu|ChangeSet|20060505045213|43924
K 43747
M stenn at whimsy.udel.edu|ChangeSet|20060505045213|43924
P ChangeSet
------------------------------------------------

0a0
> stenn at whimsy.udel.edu|libntp/recvbuff.c|19990721005052|03868|06470f1c mayer at pogo.udel.edu|libntp/recvbuff.c|20060505120026|48579
> stenn at whimsy.udel.edu|ntpd/ntpd.c|19990526004817|01635|3aed0663 mayer at pogo.udel.edu|ntpd/ntpd.c|20060505120045|06371

mayer at pogo.udel.edu|ChangeSet|20060505120051|43747
D 1.1499 06/05/05 08:48:59-04:00 mayer at pogo.udel.edu +4 -0
B stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
C
c Bug #504 Collection of changes to retry DNS in case unable to get definitive answer
K 57177
P ChangeSet
------------------------------------------------

0a0
> jhay at angel.cids.org.za|libntp/ntp_rfc2553.c|20011004194249|12627|ba0e411f8e42699a mayer at pogo.udel.edu|libntp/ntp_rfc2553.c|20060505124245|45809
> stenn at whimsy.udel.edu|ntpd/ntp_intres.c|19990526004817|01635|3aed0663 mayer at pogo.udel.edu|ntpd/ntp_intres.c|20060505124532|08576
> mayer at pogo.udel.edu|ports/winnt/libntp/dnslookup.c|20060505123640|29554|96398d4d3428670 mayer at pogo.udel.edu|ports/winnt/libntp/dnslookup.c|20060505124726|33160
> stenn at whimsy.udel.edu|ports/winnt/libntp/libntp.dsp|19990728020416|01289|29080509 mayer at pogo.udel.edu|ports/winnt/libntp/libntp.dsp|20060505124404|25582

mayer at pogo.udel.edu|ChangeSet|20060505124859|57177
D 1.1500 06/05/05 16:40:34-04:00 mayer at pogo.udel.edu +1 -0
B stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
C
c Bug #596/527 updates to remove [UN]BLOCKIO() and keep initialization for Windows
K 57176
P ChangeSet
------------------------------------------------

0a0
> stenn at whimsy.udel.edu|libntp/recvbuff.c|19990721005052|03868|06470f1c mayer at pogo.udel.edu|libntp/recvbuff.c|20060505203946|40825

== libntp/ntp_rfc2553.c ==
jhay at angel.cids.org.za|libntp/ntp_rfc2553.c|20011004194249|12627|ba0e411f8e42699a
mayer at pogo.udel.edu|libntp/ntp_rfc2553.c|20051102044006|04434
D 1.28 06/05/05 08:42:45-04:00 mayer at pogo.udel.edu +43 -5
B stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
C
c Bug #504 Move lookup call to dnslookup() function
K 45809
O -rw-rw-r--
P libntp/ntp_rfc2553.c
------------------------------------------------

I103 24
\
int
DNSlookup_name(
	const char FAR *name,
	int ai_family,
	struct hostent **Addresses
);
\
#ifndef SYS_WINNT
/*
 * Encapsulate gethostbyname to control the error code
 */
int
DNSlookup_name(
	const char FAR *name,
	int ai_family,
	struct hostent **Addresses
)
{
	*Addresses = gethostbyname(name);
	return (h_errno);
}
#endif
\
I246 1
	{
I247 2
		ai->ai_canonname = NULL;
	}
I248 1
	{
I249 2
		ai->ai_addr = NULL;
	}
I250 1
	ai = NULL;
D291 1
I291 1
	struct hostent *hp = NULL;
I293 1
	int errval;
D358 1
I358 3
\
	errval = DNSlookup_name(nodename, AF_INET, &hp);
\
D360 1
I360 1
		if (errval == TRY_AGAIN || errval == EAI_AGAIN)
D362 1
I362 1
		else if (errval == EAI_NONAME) {
D370 1
I370 5
			return (errval);
		}
		else
		{
			return (errval);

== ports/winnt/libntp/dnslookup.c ==
New file: ports/winnt/libntp/dnslookup.c
V 4

mayer at pogo.udel.edu|ports/winnt/libntp/dnslookup.c|20060505123640|29554|96398d4d3428670
D 1.0 06/05/05 08:36:40-04:00 mayer at pogo.udel.edu +0 -0
B stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
c BitKeeper file /pogo/users/mayer/ntp-dev/ports/winnt/libntp/dnslookup.c
K 29554
P ports/winnt/libntp/dnslookup.c
R 96398d4d3428670
X 0x821
------------------------------------------------


mayer at pogo.udel.edu|ports/winnt/libntp/dnslookup.c|20060505123640|29554|96398d4d3428670
D 1.1 06/05/05 08:36:40-04:00 mayer at pogo.udel.edu +197 -0
B stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
F 1
K 34953
O -rw-rw-r--
P ports/winnt/libntp/dnslookup.c
------------------------------------------------

I0 197
/*
 * Copyright (C) 2006  Internet Systems Consortium, Inc. ("ISC")
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
 * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 * PERFORMANCE OF THIS SOFTWARE.
 */
\
/*
 * This module uses Windows lookup facilities to get the address information
 * wherever it resides. This avoids calling the Internet standard funcction
 * gethostbyname and gives us more control over the results since the
 * Microsoft implementation seems to return the wrong error code for some
 * conditions.
 */
\
#include <config.h>
#include <ws2tcpip.h>
#include <nspapi.h>
#include <svcguid.h>
#include <ntp_rfc2553.h>
#include <malloc.h>
#include <ntp_stdlib.h>
#include <syslog.h>
\
/*
 * Set this Macro to force retries even if it fails
 * the lookup
 */
#define FORCE_DNSRETRY
#ifdef FORCE_DNSRETRY
\
#undef EAI_NONAME
#define EAI_NONAME EAI_AGAIN
\
#endif
\
typedef struct hostent hostent_t;
\
int ReturnCode(int errcode)
{
	int retcode;
\
	switch (errcode)
	{
	case 0:
		return (0);
	case WSAEINVAL:
		return (EAI_BADHINTS);
	case WSANO_DATA:
		return (EAI_NONAME);
	case WSANOTINITIALISED:
	case WSASERVICE_NOT_FOUND:
		return (EAI_FAIL);
	case WSA_NOT_ENOUGH_MEMORY:
		return (EAI_MEMORY);
	default:
		return (EAI_SYSTEM);
	}
}
\
int
AddToAddresses(char **Addresses, int *cnt, CSADDR_INFO *csaddr)
{
\
	int csize;
	struct in_addr *sinaddr;
	char *addr;
	struct in_addr *addr_list;
	struct sockaddr_in *sin;
	sin = (struct sockaddr_in *) csaddr->RemoteAddr.lpSockaddr;
	if (*Addresses != NULL)
	{
		csize = _msize(*Addresses);
		addr_list = realloc(*Addresses, csize + sizeof(struct in_addr));
	}
	else
	{
		csize = 0;
		addr_list = malloc(sizeof(struct in_addr));
	}
	addr = (char *) addr_list;
	sinaddr = &((struct in_addr*) addr)[(*cnt)];
	memset(sinaddr, 0, sizeof(sinaddr));
	memcpy(sinaddr, &sin->sin_addr, sizeof(struct in_addr));
	
	(*cnt)++;
	*Addresses = addr;
	return 0;
}
\
int
DNSlookup_name(
	const char FAR *name,
	int ai_family,
	struct hostent **Addresses
)
{
	char buffer[sizeof(WSAQUERYSET) + 2048];
	WSAQUERYSET query;
	hostent_t *addr = NULL;
	char *bufaddr = NULL;
	char ** addrlist = &bufaddr;
	int addrcnt = 0;
	WSAQUERYSET *results = (WSAQUERYSET *) buffer;
	GUID	HostnameGUID = SVCID_INET_HOSTADDRBYNAME;
	HANDLE	handle;
	DWORD dwLength;
	int err = 0;
	int retcode = 0;
	int errcode = 0;
	DWORD i;
\
	/*
	 * First we must create a query set
	 */
	memset(&query, 0, sizeof(query));
	query.dwSize = sizeof(query);
	query.lpszServiceInstanceName = (char *)name;
	query.dwNameSpace = NS_DNS;
	query.lpServiceClassId = &HostnameGUID;
\
	err = WSALookupServiceBegin(&query,
                                 LUP_RETURN_NAME | LUP_RETURN_BLOB | LUP_RETURN_ADDR,
                                 &handle);
\
	if(err == SOCKET_ERROR)
	{
		/*
		 * Convert the error code and return
		 */
		return (ReturnCode(WSAGetLastError()));
	}
\
	/*
	 * Initially none
	 * Change if we get something
	 */
	retcode = EAI_NONAME;
	dwLength = sizeof(buffer);
	*addrlist = NULL;
\
	while(err == 0)		/* Drop out when error */
	{
		memset(&buffer, 0, dwLength);
		err = WSALookupServiceNext(
			                handle,
			                0,
			                &dwLength,
			                results);
		errcode = WSAGetLastError();
		if (results->dwNumberOfCsAddrs > 0)
		{
			if (addr == NULL)
			{
				addr = (struct hostent *) malloc(sizeof(struct hostent));
				memset(addr, 0, sizeof(struct hostent));
				addr->h_addrtype = (short) results->lpcsaBuffer->iSocketType;
				addr->h_length = (short) results->lpcsaBuffer->RemoteAddr.iSockaddrLength;
			}
			for (i = 0; i < results->dwNumberOfCsAddrs; i++)
			{
				AddToAddresses(addrlist, &addrcnt, &results->lpcsaBuffer[i]);
			}
		}
\
	}
	if (addr != NULL)
	{
		addr->h_name = (char *) name;
		addr->h_addr_list = addrlist;
		retcode = 0;
	}
	else
	{
#ifdef FORCE_DNSRETRY
		/*
		 * We do this or the error would never be logged
		 */
		if (errcode == WSANO_DATA)
			msyslog(LOG_ERR, "Address not found for %s", name);
#endif
		retcode = ReturnCode(errcode);
	}
	*Addresses = addr;
	WSALookupServiceEnd(handle);
	return (retcode);
}
\

mayer at pogo.udel.edu|ports/winnt/libntp/dnslookup.c|20060505123641|34953
D 1.2 06/05/05 08:47:26-04:00 mayer at pogo.udel.edu +0 -1
B stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
C
c Bug #504 Windows only special lookup to fix return error codes
K 33160
O -rw-rw-r--
P ports/winnt/libntp/dnslookup.c
------------------------------------------------

D38 1

== libntp/recvbuff.c ==
stenn at whimsy.udel.edu|libntp/recvbuff.c|19990721005052|03868|06470f1c
stenn at pogo.udel.edu|libntp/recvbuff.c|20051221041613|04313
D 1.20 06/04/15 18:33:18-04:00 mayer at pogo.udel.edu +20 -18
B stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
C
c Fix Bug #596 and #572 to deal with polling restrictions
K 48579
O -rw-rw-r--
P libntp/recvbuff.c
------------------------------------------------

D20 2
I21 2
static u_long volatile total_recvbufs;	/* total recvbufs currently in use */
static u_long volatile lowater_adds;	/* number of times we have added memory */
D27 1
I27 1
#if defined(SYS_WINNT)
D71 1
I71 1
#if defined SYS_WINNT
D90 1
D114 1
I114 1
#if defined(SYS_WINNT)
I125 1
	BLOCKIO();
I127 4
#if defined SYS_WINNT
	rb->wsabuff.len = RX_BUFF_SIZE;
	rb->wsabuff.buf = (char *) rb->recv_buffer;
#endif
I129 1
	UNBLOCKIO();
I135 1
	BLOCKIO();
I139 1
	UNBLOCKIO();
I145 1
	BLOCKIO();
I156 1
			UNBLOCKIO();
I163 1
			UNBLOCKIO();
I168 1
	initialise_buffer(buffer);
I169 1
	UNBLOCKIO();
D177 10
I186 1
	BLOCKIO();
D196 2
I203 1
	UNBLOCKIO();

mayer at pogo.udel.edu|libntp/recvbuff.c|20060415223318|48579
D 1.21 06/05/05 08:00:26-04:00 mayer at pogo.udel.edu +5 -3
B stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
C
i kardel at pogo.udel.edu|libntp/recvbuff.c|20060501181825|53844
K 48579
M kardel at pogo.udel.edu|libntp/recvbuff.c|20060501181825|53844
O -rw-rw-r--
P libntp/recvbuff.c
------------------------------------------------

I188 1
	BLOCKIO();
D198 3
I200 4
		/*
		 * Make sure we reset the full count to 0
		 */
		full_recvbufs = 0;

mayer at pogo.udel.edu|libntp/recvbuff.c|20060505120026|48579
D 1.22 06/05/05 16:39:46-04:00 mayer at pogo.udel.edu +0 -10
B stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
C
c Bug #596/527 updates to remove [UN]BLOCKIO() and keep initialization for Windows
K 40825
O -rw-rw-r--
P libntp/recvbuff.c
------------------------------------------------

D125 1
D134 1
D141 1
D146 1
D153 1
D165 1
D173 1
D181 1
D189 1
D205 1

== ntpd/ntp_intres.c ==
stenn at whimsy.udel.edu|ntpd/ntp_intres.c|19990526004817|01635|3aed0663
mayer at pogo.udel.edu|ntpd/ntp_intres.c|20051104043956|56927
D 1.43 06/05/05 08:45:32-04:00 mayer at pogo.udel.edu +22 -8
B stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
C
c Bug  Retry DNS lookups if DNS unable to give a definitive answer or is unreachable
K 8576
O -rw-rw-r--
P ntpd/ntp_intres.c
------------------------------------------------

I511 4
		else if (error == EAI_NONAME)
		{
			msyslog(LOG_ERR, "host name not found: %s", entry->ce_name);
		}
I524 4
	/*
	 * If the resolver failed, see if the failure is
	 * temporary.  If so, return success.
	 */
D526 7
I532 13
		switch (error)
		{
		case EAI_AGAIN:
			return (1);
		case EAI_NONAME:
			return (0);
		case EAI_NODATA:
		case EAI_FAIL:
		case EAI_SYSTEM:
			return (1);
		default:
			return (0);
		}
D561 1
I561 1
	if (sockfd != INVALID_SOCKET)

== ntpd/ntpd.c ==
stenn at whimsy.udel.edu|ntpd/ntpd.c|19990526004817|01635|3aed0663
stenn at deacon.udel.edu|ntpd/ntpd.c|20060315072845|48724
D 1.81 06/04/15 18:32:25-04:00 mayer at pogo.udel.edu +3 -1
B stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
C
c Fix Bug #596 and #572 to deal with polling restrictions
K 48280
O -rw-rw-r--
P ntpd/ntpd.c
------------------------------------------------

D960 1
I960 1
		while (1)
I971 2
			else
				break;

mayer at pogo.udel.edu|ntpd/ntpd.c|20060415223225|48280
D 1.82 06/05/05 08:00:45-04:00 mayer at pogo.udel.edu +0 -3
B stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
C
i kardel at pogo.udel.edu|ntpd/ntpd.c|20060501182128|06371
K 6371
M kardel at pogo.udel.edu|ntpd/ntpd.c|20060501182128|06371
O -rw-rw-r--
P ntpd/ntpd.c
------------------------------------------------

D963 1
D983 2

== ports/winnt/libntp/libntp.dsp ==
stenn at whimsy.udel.edu|ports/winnt/libntp/libntp.dsp|19990728020416|01289|29080509
stenn at deacon.udel.edu|ports/winnt/libntp/libntp.dsp|20051028021151|20698
D 1.28 06/05/05 08:44:04-04:00 mayer at pogo.udel.edu +4 -0
B stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
C
c Bug #504 add Windows only dnslookup to dsp file
K 25582
O -rw-rw-r--
P ports/winnt/libntp/libntp.dsp
------------------------------------------------

I152 4
SOURCE=.\dnslookup.c
# End Source File
# Begin Source File
\

# Patch checksum=7dbaa6f2


More information about the bk-ntp-dev-send mailing list