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

Harlan Stenn stenn at whimsy.udel.edu
Mon Jul 25 22:11:52 UTC 2005


This BitKeeper patch contains the following changesets:
mayer at pogo.udel.edu|ChangeSet|20050724195024|42565
mayer at pogo.udel.edu|ChangeSet|20050716213055|41129
stenn at whimsy.udel.edu|ChangeSet|20050725220952|53784
mayer at pogo.udel.edu|ChangeSet|20050724204143|42529
mayer at pogo.udel.edu|ChangeSet|20050725164600|42546
mayer at pogo.udel.edu|ChangeSet|20050716212955|41367

# 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.8/include/recvbuff.h	2004-11-06 21:42:39 -05:00
#+++ 1.9/include/recvbuff.h	2005-07-24 15:48:34 -04:00
#@@ -56,9 +56,7 @@
# #define	recv_srcclock	X_from_where.X_recv_srcclock
# #define recv_peer	X_from_where.X_recv_peer
# #if defined HAVE_IO_COMPLETION_PORT
#-        IoCompletionInfo	iocompletioninfo;
# 	WSABUF		wsabuff;
#-	DWORD		AddressLength;
# #else
# 	struct sockaddr_storage srcadr;	/* where packet came from */
# #endif
#
#--- 1.10/libntp/recvbuff.c	2004-10-06 21:17:00 -04:00
#+++ 1.11/libntp/recvbuff.c	2005-07-24 15:48:34 -04:00
#@@ -24,12 +24,18 @@
# static	struct recvbuf *volatile beginlist; /* fifo buffers with data */
# 	
# #if defined(HAVE_IO_COMPLETION_PORT)
#-static CRITICAL_SECTION RecvCritSection;
#-# define RECV_BLOCK_IO()	EnterCriticalSection(&RecvCritSection)
#-# define RECV_UNBLOCK_IO()	LeaveCriticalSection(&RecvCritSection)
#+
#+/*
#+ * For Windows we need to set up a lock to manipulate the
#+ * recv buffers to prevent corruption. We keep it lock for as
#+ * short a time as possible
#+ */
#+static CRITICAL_SECTION RecvLock;
#+# define LOCK()		EnterCriticalSection(&RecvLock)
#+# define UNLOCK()	LeaveCriticalSection(&RecvLock)
# #else
#-# define RECV_BLOCK_IO()	
#-# define RECV_UNBLOCK_IO()	
#+# define LOCK()	
#+# define UNLOCK()	
# #endif
# 
# u_long
#@@ -62,7 +68,6 @@
# 	memset((char *) buff, 0, sizeof(struct recvbuf));
# 
# #if defined HAVE_IO_COMPLETION_PORT
#-	buff->iocompletioninfo.overlapped.hEvent = CreateEvent(NULL, FALSE,FALSE, NULL);
# 	buff->wsabuff.len = RX_BUFF_SIZE;
# 	buff->wsabuff.buf = (char *) buff->recv_buffer;
# #endif
#@@ -114,7 +119,7 @@
# 	full_recvbufs = lowater_adds = 0;
# 
# #if defined(HAVE_IO_COMPLETION_PORT)
#-	InitializeCriticalSection(&RecvCritSection);
#+	InitializeCriticalSection(&RecvLock);
# #endif
# 
# }
#@@ -131,7 +136,7 @@
# {
# 	struct recvbuf *rb = NULL; /* nothing has arrived */;
# 
#-	RECV_BLOCK_IO();
#+	LOCK();
# 	if (full_recvbufs == 0)
# 	{
# #ifdef DEBUG
#@@ -166,7 +171,7 @@
# 			}
# 		}
# 	}
#-	RECV_UNBLOCK_IO();
#+	UNLOCK();
# 
# 	/*
# 	 * Return the chain
#@@ -182,13 +187,13 @@
# 	struct recvbuf *rb
# 	)
# {
#-	RECV_BLOCK_IO();
#+	LOCK();
# 	BLOCKIO();
# 	rb->next = (struct recvbuf *) freelist;
# 	freelist = rb;
# 	free_recvbufs++;
# 	UNBLOCKIO();
#-	RECV_UNBLOCK_IO();
#+	UNLOCK();
# }
# 
# 	
#@@ -197,7 +202,7 @@
# 	struct recvbuf *rb
# 	)
# {
#-	RECV_BLOCK_IO();
#+	LOCK();
# 	if (full_recvbufs == 0)
# 	{
# 		beginlist = rb;
#@@ -211,14 +216,14 @@
# 	fulllist = rb;
# 	full_recvbufs++;
# 
#-	RECV_UNBLOCK_IO();
#+	UNLOCK();
# }
# 
# struct recvbuf *
# get_free_recv_buffer(void)
# {
# 	struct recvbuf * buffer = NULL;
#-	RECV_BLOCK_IO();
#+	LOCK();
# 	if (free_recvbufs <= RECV_LOWAT)
# 		{
# 			if (total_recvbufs >= RECV_TOOMANY) {
#@@ -239,7 +244,7 @@
# 		--free_recvbufs;
# 	}
# 
#-	RECV_UNBLOCK_IO();
#+	UNLOCK();
# 	return buffer;
# }
# 
#@@ -247,13 +252,13 @@
# get_full_recv_buffer(void)
# {
# 	struct recvbuf * buffer = NULL;
#-	RECV_BLOCK_IO();
#+	LOCK();
# 	if (full_recvbufs > 0) {
# 		--full_recvbufs;
# 		buffer = beginlist;
# 		beginlist = buffer->next;
# 		buffer->next = NULL;
# 	}
#-	RECV_UNBLOCK_IO();
#+	UNLOCK();
# 	return buffer;
# }
#
#--- 1.181/ntpd/ntp_io.c	2005-07-02 15:25:25 -04:00
#+++ 1.184/ntpd/ntp_io.c	2005-07-25 12:45:27 -04:00
#@@ -46,6 +46,19 @@
#  */
# #define ALLOW_WILDCARD_PACKETS
# 
#+/* 
#+ * Set up some macros to look for IPv6 and IPv6 multicast
#+ */
#+
#+#if defined(ISC_PLATFORM_HAVEIPV6) && !defined(DISABLE_IPV6)
#+
#+#define INCLUDE_IPV6_SUPPORT
#+
#+#if defined(INCLUDE_IPV6_SUPPORT) && defined(IPV6_JOIN_GROUP) && defined(IPV6_LEAVE_GROUP)
#+#define INCLUDE_IPV6_MULTICAST_SUPPORT
#+
#+#endif	/* IPV6 Multicast Support */
#+#endif  /* IPv6 Support */
# 
# extern int listen_to_virtual_ips;
# extern const char *specific_interface;
#@@ -148,11 +161,11 @@
# static	void	set_reuseaddr	P((int));
# static	isc_boolean_t	socket_broadcast_enable	 P((struct interface *, SOCKET, struct sockaddr_storage *));
# static	isc_boolean_t	socket_broadcast_disable P((struct interface *, int, struct sockaddr_storage *));
#+static	isc_boolean_t	addr_ismulticast	 P((struct sockaddr_storage *));
# /*
#  * Not all platforms support multicast
#  */
# #ifdef MCAST
#-static	isc_boolean_t	addr_ismulticast	 P((struct sockaddr_storage *));
# static	isc_boolean_t	socket_multicast_enable	 P((struct interface *, int, int, struct sockaddr_storage *));
# static	isc_boolean_t	socket_multicast_disable P((struct interface *, int, struct sockaddr_storage *));
# #endif
#@@ -338,7 +351,8 @@
# 
# static void
# print_interface(int ind) {
#-	printf("interface %d:  fd=%d,  bfd=%d,  name=%.8s,  flags=0x%x,  scope=%d\n",
#+
#+	printf("interface %d:  fd=%d,  bfd=%d,  name=%s,  flags=0x%x,  scope=%d\n",
# 	       ind,
# 	       inter_list[ind].fd,
# 	       inter_list[ind].bfd,
#@@ -352,7 +366,8 @@
# 	/* Only IPv4 has a network mask */
# 	if(inter_list[ind].family == AF_INET)
# 		printf(",  mask=%s", stoa((&inter_list[ind].mask)));
#-	printf("\n");
#+
#+	printf(" %s\n", inter_list[ind].ignore_packets == ISC_FALSE ? "Enabled": "Disabled");
# 	if (debug > 4)	/* in-depth debugging only */
# 		interface_dump(&inter_list[ind]);
# }
#@@ -403,7 +418,7 @@
# 		idx++;
# 	}
# 
#-#ifdef ISC_PLATFORM_HAVEIPV6
#+#ifdef INCLUDE_IPV6_SUPPORT
# 	/*
# 	 * create pseudo-interface with wildcard IPv6 address
# 	 */
#@@ -476,6 +491,7 @@
# void
# convert_isc_if(isc_interface_t *isc_if, struct interface *itf, u_short port) {
# 
#+	itf->scopeid = 0;
# 	itf->family = (short) isc_if->af;
# 	if(isc_if->af == AF_INET) {
# 		itf->sin.ss_family = (u_short) isc_if->af;
#@@ -505,7 +521,7 @@
# 			loopback_interface = itf;
# 		}
# 	}
#-#ifdef ISC_PLATFORM_HAVEIPV6
#+#ifdef INCLUDE_IPV6_SUPPORT
# 	else if (isc_if->af == AF_INET6) {
# 		itf->sin.ss_family = (u_short) isc_if->af;
# 		strcpy(itf->name, isc_if->name);
#@@ -531,7 +547,7 @@
# 		/* Copy the scopeid and the interface index */
# 		itf->ifindex = isc_if->ifindex;
# 	}
#-#endif /* ISC_PLATFORM_HAVEIPV6 */
#+#endif /* INCLUDE_IPV6_SUPPORT */
# 
# 		/* Process the rest of the flags */
# 
#@@ -576,13 +592,15 @@
# 	    printf("create_sockets(%d)\n", ntohs( (u_short) port));
# #endif
# 
#+#ifdef INCLUDE_IPV6_SUPPORT
# 	if (isc_net_probeipv6() == ISC_R_SUCCESS)
# 		scan_ipv6 = ISC_TRUE;
#-#if defined(ISC_PLATFORM_HAVEIPV6) && defined(DEBUG)
#+#if defined(DEBUG)
# 	else
# 		if(debug)
# 			netsyslog(LOG_ERR, "no IPv6 interfaces found");
# #endif
#+#endif
# 
# 	if (isc_net_probeipv4() == ISC_R_SUCCESS)
# 		scan_ipv4 = ISC_TRUE;
#@@ -659,15 +677,22 @@
# 		inter_list[i].fd = open_socket(&inter_list[i].sin,
# 		    inter_list[i].flags, 0, &inter_list[i], i);
# 		if (inter_list[i].fd != INVALID_SOCKET)
#-			msyslog(LOG_INFO, "Listening on interface %s, %s#%d",
#+			msyslog(LOG_INFO, "Listening on interface %s, %s#%d %s",
# 				inter_list[i].name,
# 				stoa((&inter_list[i].sin)),
#-				NTP_PORT);
#-		if ((inter_list[i].flags & INT_BROADCAST) &&
#+				NTP_PORT,
#+				(inter_list[i].ignore_packets == ISC_FALSE) ?
#+				"Enabled": "Disabled");
#+/*		if ((inter_list[i].flags & INT_BROADCAST) &&
# 		     inter_list[i].bfd != INVALID_SOCKET)
# 			msyslog(LOG_INFO, "Listening on broadcast address %s#%d",
# 				stoa((&inter_list[i].bcast)),
# 				NTP_PORT);
#+*/
#+	/*
#+	 * Calculate the address hash for each interface address.
#+	 */
#+		inter_list[i].addr_refid = addr2refid(&inter_list[i].sin);
# 	}
# 
# 	/*
#@@ -687,13 +712,6 @@
# 		    RESM_NTPONLY|RESM_INTERFACE, RES_IGNORE);
# 	}
# 
#-	/*
#-	 * Calculate the address hash for each interface address.
#-	 */
#-	for (i = 0; i < ninterfaces; i++) {
#-		inter_list[i].addr_refid = addr2refid(&inter_list[i].sin);
#-	}
#-
# 
# #ifdef DEBUG
# 	if (debug > 1) {
#@@ -809,23 +827,20 @@
# 
# #endif /* OPEN_BCAST_SOCKET */
# /*
#- * NOTE: Not all platforms support multicast
#- */
#-#ifdef MCAST
#-/*
#  * Check to see if the address is a multicast address
#  */
# static isc_boolean_t
# addr_ismulticast(struct sockaddr_storage *maddr)
# {
#-	u_int32 haddr = ntohl(((struct sockaddr_in*)maddr)->sin_addr.s_addr);
# 	switch (maddr->ss_family)
# 	{
# 	case AF_INET :
#-		if (!IN_CLASSD(haddr)) {
#-			netsyslog(LOG_ERR,
#-			"multicast address %s not class D",
#+		if (!IN_CLASSD(ntohl(((struct sockaddr_in*)maddr)->sin_addr.s_addr))) {
#+#ifdef DEBUG
#+			if (debug > 1)
#+				printf("multicast address %s not class D\n",
# 				stoa(maddr));
#+#endif
# 			return (ISC_FALSE);
# 		}
# 		else
#@@ -834,11 +849,13 @@
# 		}
# 	case AF_INET6 :
# 
#-#if defined(ISC_PLATFORM_HAVEIPV6) && defined(IPV6_JOIN_GROUP) && defined(IPV6_LEAVE_GROUP)
#+#ifdef INCLUDE_IPV6_MULTICAST_SUPPORT
# 		if (!IN6_IS_ADDR_MULTICAST(&((struct sockaddr_in6*)maddr)->sin6_addr)) {
#-			netsyslog(LOG_ERR,
#-			    "address %s not IPv6 multicast address",
#+#ifdef DEBUG
#+			if (debug > 1)
#+				printf("address %s not IPv6 multicast address\n",
# 				stoa(maddr));
#+#endif
# 			return (ISC_FALSE);
# 		}
# 		else
#@@ -860,6 +877,10 @@
# 	}
# }
# /*
#+ * NOTE: Not all platforms support multicast
#+ */
#+#ifdef MCAST
#+/*
#  * Add a multicast address to a given socket
#  * The socket is in the inter_list all we need to do is enable
#  * multicasting. It is not this function's job to select the socket
#@@ -867,10 +888,10 @@
# static isc_boolean_t
# socket_multicast_enable(struct interface *iface, int ind, int lscope, struct sockaddr_storage *maddr)
# {
#-#ifdef ISC_PLATFORM_HAVEIPV6
#+#ifdef INCLUDE_IPV6_MULTICAST_SUPPORT
# 	struct ipv6_mreq mreq6;
# 	struct in6_addr iaddr6;
#-#endif /* ISC_PLATFORM_HAVEIPV6 */
#+#endif /* INCLUDE_IPV6_MULTICAST_SUPPORT */
# 	struct ip_mreq mreq;
# 	memset((char *)&mreq, 0, sizeof(mreq));
# 
#@@ -905,7 +926,7 @@
# #endif
# 		break;
# 	case AF_INET6:
#-#if defined(ISC_PLATFORM_HAVEIPV6) && defined(IPV6_JOIN_GROUP) && defined(IPV6_LEAVE_GROUP)
#+#ifdef INCLUDE_IPV6_MULTICAST_SUPPORT
# 
# 		/*
# 		 * Enable reception of multicast packets
#@@ -915,12 +936,7 @@
# 		 */
# 		iaddr6 = ((struct sockaddr_in6*)maddr)->sin6_addr;
# 		mreq6.ipv6mr_multiaddr = iaddr6;
#-#ifdef ISC_PLATFORM_HAVESCOPEID
#-		if (IN6_IS_ADDR_MC_LINKLOCAL(&iaddr6))
#-			mreq6.ipv6mr_interface = lscope;
#-		else
#-#endif
#-			mreq6.ipv6mr_interface = lscope;
#+		mreq6.ipv6mr_interface = lscope;
# 
# 		if (setsockopt(iface->fd, IPPROTO_IPV6, IPV6_JOIN_GROUP,
# 			(char *)&mreq6, sizeof(mreq6)) == -1) {
#@@ -941,7 +957,7 @@
# 		break;
# #else
# 		return ISC_FALSE;
#-#endif	/* ISC_PLATFORM_HAVEIPV6 */
#+#endif	/* INCLUDE_IPV6_MULTICAST_SUPPORT */
# 	}
# 	iface->flags |= INT_MCASTOPEN;
# 	iface->num_mcast++;
#@@ -957,10 +973,10 @@
# static isc_boolean_t
# socket_multicast_disable(struct interface *iface, int ind, struct sockaddr_storage *maddr)
# {
#-#ifdef ISC_PLATFORM_HAVEIPV6
#+#ifdef INCLUDE_IPV6_MULTICAST_SUPPORT
# 	struct ipv6_mreq mreq6;
# 	struct in6_addr iaddr6;
#-#endif /* ISC_PLATFORM_HAVEIPV6 */
#+#endif /* INCLUDE_IPV6_MULTICAST_SUPPORT */
# 	struct ip_mreq mreq;
# 	memset((char *)&mreq, 0, sizeof(mreq));
# 
#@@ -980,7 +996,7 @@
# 		}
# 		break;
# 	case AF_INET6:
#-#if defined(ISC_PLATFORM_HAVEIPV6) && defined(IPV6_JOIN_GROUP) && defined(IPV6_LEAVE_GROUP)
#+#ifdef INCLUDE_IPV6_MULTICAST_SUPPORT
# 
# 		/*
# 		 * Disable reception of multicast packets
#@@ -990,12 +1006,7 @@
# 		 */
# 		iaddr6 = ((struct sockaddr_in6*)&maddr)->sin6_addr;
# 		mreq6.ipv6mr_multiaddr = iaddr6;
#-#ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID
#-		if (IN6_IS_ADDR_MC_LINKLOCAL(&iaddr6))
#-			mreq6.ipv6mr_interface = iface->scopeid;
#-		else
#-#endif
#-			mreq6.ipv6mr_interface = 0;
#+		mreq6.ipv6mr_interface = iface->scopeid;
# 
# 		if (setsockopt(iface->fd, IPPROTO_IPV6, IPV6_LEAVE_GROUP,
# 			(char *)&mreq6, sizeof(mreq6)) == -1) {
#@@ -1008,7 +1019,7 @@
# 		break;
# #else
# 		return ISC_FALSE;
#-#endif	/* ISC_PLATFORM_HAVEIPV6 */
#+#endif	/* INCLUDE_IPV6_MULTICAST_SUPPORT */
# 	}
# 	iface->num_mcast--;
# 	if (iface->num_mcast <= 0) {
#@@ -1074,17 +1085,11 @@
# 		/* Enable Broadcast on socket */
# 		jstatus = socket_broadcast_enable(&inter_list[i], fd, &inter_list[i].sin);
# 		if (jstatus == ISC_TRUE)
#+		{
# 			nif++;
#-#ifdef DEBUG
#-		if (debug) {
#-			if (jstatus == ISC_TRUE)
#-				printf("io_setbclient: Opened broadcast client on interface %d, socket: %d\n",
#+			netsyslog(LOG_INFO,"io_setbclient: Opened broadcast client on interface %d, socket: %d",
# 				i, fd);
#-			else
#-				printf("io_setbclient: Unable to Open broadcast client on interface %d\n",
#-				i);
# 		}
#-#endif
# 	}
# 	set_reuseaddr(0);
# #ifdef DEBUG
#@@ -1105,6 +1110,7 @@
# void
# io_unsetbclient(void)
# {
#+#ifdef OPEN_BCAST_SOCKET
# 	int i;
# 	isc_boolean_t lstatus;
# 
#@@ -1114,6 +1120,7 @@
# 		    continue;
# 		lstatus = socket_broadcast_disable(&inter_list[i], i, &inter_list[i].sin);
# 	}
#+#endif
# }
# 
# void
#@@ -1134,7 +1141,8 @@
# 		return;
# 
# 	/* If we already have it we can just return */
#-	if (find_flagged_addr_in_list(&addr, INT_MCASTOPEN) >= 0)
#+	ind = find_flagged_addr_in_list(&addr, INT_MCASTOPEN);
#+	if (ind >= 0)
# 	{
# 		netsyslog(LOG_INFO, "Duplicate request found for multicast address %s",
# 			stoa(&addr));
#@@ -1185,7 +1193,7 @@
# 		memset(&((struct sockaddr_in*)&inter_list[ind].mask)->sin_addr.s_addr, 0xff, sizeof(struct in_addr));
# 		break;
# 	case AF_INET6:
#-#if defined(ISC_PLATFORM_HAVEIPV6) && defined(IPV6_JOIN_GROUP) && defined(IPV6_LEAVE_GROUP)
#+#ifdef INCLUDE_IPV6_MULTICAST_SUPPORT
# 		memcpy(&(((struct sockaddr_in6 *)&inter_list[ind].sin)->sin6_addr),
# 		       &((struct sockaddr_in6*)&addr)->sin6_addr,
# 		       sizeof(struct in6_addr));
#@@ -1196,9 +1204,7 @@
# 		memset(&((struct sockaddr_in6*)&inter_list[ind].mask)->sin6_addr.s6_addr, 0xff, sizeof(struct in6_addr));
# #endif
# 		i = findlocalcastinterface(&addr, INT_MULTICAST);
#-		if (i < 0)
#-			lscope = 0;
#-		else
#+		if (i >= 0)
# 			lscope = ((struct sockaddr_in6*)&inter_list[i].sin)->sin6_scope_id;
# #ifdef DEBUG
# 	if (debug > 1)
#@@ -1249,6 +1255,9 @@
# 	}
# 
# #else
#+	/*
#+	 * For the case where we can't use a separate socket
#+	 */
# 	ind = findlocalcastinterface(&addr, INT_MULTICAST);
# #endif
# 	/*
#@@ -1264,20 +1273,16 @@
# 
# 	jstatus = socket_multicast_enable(&inter_list[ind], ind, lscope, &addr);
# 
#-#ifdef DEBUG
#-	if (debug)
#-	{
#-		if (jstatus == ISC_TRUE)
#-			printf("io_multicast_add: %s on interface %d\n", stoa(&addr), ind);
#-		else
#-			printf("io_multicast_add: Failed to add %s on interface %d\n", stoa(&addr), ind);
#-	}
#-#endif
#+	if (jstatus == ISC_TRUE)
#+		netsyslog(LOG_INFO, "Added Multicast Listener %s on interface %d\n", stoa(&addr), ind);
#+	else
#+		netsyslog(LOG_ERR, "Failed to add Multicast Listener %s\n", stoa(&addr));
# #else /* MCAST */
# 	netsyslog(LOG_ERR,
# 	    "Cannot add multicast address %s: no Multicast support",
# 	    stoa(&addr));
# #endif /* MCAST */
#+	return;
# }
# 
# /*
#@@ -1290,26 +1295,22 @@
# {
# #ifdef MCAST
# 	int i;
#-	u_int32 haddr;
# 	isc_boolean_t lstatus;
# 
#-#ifdef ISC_PLATFORM_HAVEIPV6
#-	struct in6_addr haddr6;
#-#endif /* ISC_PLATFORM_HAVEIPV6 */
#+	/*
#+	 * Check to see if this is a multicast address
#+	 */
#+	if (addr_ismulticast(&addr) == ISC_FALSE)
#+	{
#+		netsyslog(LOG_ERR,
#+			 "invalid multicast address %s", stoa(&addr));
#+		return;
#+	}
# 
# 	switch (addr.ss_family)
# 	{
# 	case AF_INET :
# 
#-		haddr = ntohl(((struct sockaddr_in*)&addr)->sin_addr.s_addr);
#-
#-		if (!IN_CLASSD(haddr))
#-		{
#-			netsyslog(LOG_ERR,
#-				 "invalid multicast address %s", stoa(&addr));
#-			return;
#-		}
#-
# 		/*
# 		 * Disable reception of multicast packets
# 		 */
#@@ -1320,16 +1321,8 @@
# 		}
# 		break;
# 
#-#if defined(ISC_PLATFORM_HAVEIPV6) && defined(IPV6_JOIN_GROUP) && defined(IPV6_LEAVE_GROUP)
#+#ifdef INCLUDE_IPV6_MULTICAST_SUPPORT
# 	case AF_INET6 :
#-		haddr6 = ((struct sockaddr_in6*)&addr)->sin6_addr;
#-
#-		if (!IN6_IS_ADDR_MULTICAST(&haddr6))
#-		{
#-			netsyslog(LOG_ERR,
#-				"invalid multicast address %s", stoa(&addr));
#-			return;
#-		}
# 
# 		/*
# 		* Disable reception of multicast packets
#@@ -1348,7 +1341,7 @@
# 			lstatus = socket_multicast_disable(&inter_list[i], i, &addr);
# 		}
# 		break;
#-#endif /* ISC_PLATFORM_HAVEIPV6 */
#+#endif /* INCLUDE_IPV6_MULTICAST_SUPPORT */
# 	}/* switch */
#         delete_addr_from_list(&addr);
# 
#@@ -1472,7 +1465,7 @@
# 				fd, addr->ss_family, (int)ntohs(((struct sockaddr_in*)addr)->sin_port),
# 				stoa(addr),
# 				IN_CLASSD(ntohl(((struct sockaddr_in*)addr)->sin_addr.s_addr)), flags);
#-#ifdef ISC_PLATFORM_HAVEIPV6
#+#ifdef INCLUDE_IPV6_SUPPORT
# 		else if(addr->ss_family == AF_INET6)
# 		                sprintf(buff,
#                                 "bind() fd %d, family %d, port %d, scope %d, addr %s, in6_is_addr_multicast=%d flags=%d fails: %%m",
#@@ -1480,7 +1473,8 @@
#                                 ((struct sockaddr_in6*)addr)->sin6_scope_id, stoa(addr),
#                                 IN6_IS_ADDR_MULTICAST(&((struct sockaddr_in6*)addr)->sin6_addr), flags);
# #endif
#-		else return INVALID_SOCKET;
#+		else 
#+			return (INVALID_SOCKET);
# 
# 		/*
# 		 * Don't log this under all conditions
#@@ -1490,22 +1484,7 @@
# 
# 		closesocket(fd);
# 
#-		/*
#-		 * soft fail if opening a multicast address
#-		 */
#- 		if(addr->ss_family == AF_INET){
#-			if(IN_CLASSD(ntohl(((struct sockaddr_in*)addr)->sin_addr.s_addr)))
#-				return (INVALID_SOCKET);
#-		}
#-		else {
#-			if(IN6_IS_ADDR_MULTICAST(&((struct sockaddr_in6*)addr)->sin6_addr))
#-				return (INVALID_SOCKET);
#-		}
#-#if 0
#-		exit(1);
#-#else
#-		return INVALID_SOCKET;
#-#endif
#+		return (INVALID_SOCKET);
# 	}
# #ifdef DEBUG
# 	if (debug)
#@@ -1635,6 +1614,9 @@
# {
# 	SOCKET i, newmax;
# 
#+	if (fd < 0)
#+		return;
#+
# 	(void) closesocket(fd);
# 
# 	/*
#@@ -1668,6 +1650,9 @@
# {
# 	int i, newmax;
# 
#+	if (fd < 0)
#+		return;
#+
# 	(void) close(fd);
# 
# #ifndef HAVE_IO_COMPLETION_PORT
#@@ -1718,26 +1703,26 @@
# 		struct	in_addr addr;
# 	};
# 
#-#ifdef ISC_PLATFORM_HAVEIPV6
#+#ifdef INCLUDE_IPV6_SUPPORT
# 	struct cache6 {
# 		u_short port;
# 		struct in6_addr addr;
# 	};
#-#endif /* ISC_PLATFORM_HAVEIPV6 */
#+#endif /* INCLUDE_IPV6_SUPPORT */
# 
# #ifndef ERRORCACHESIZE
# #define ERRORCACHESIZE 8
# #endif
# #if ERRORCACHESIZE > 0
# 	static struct cache badaddrs[ERRORCACHESIZE];
#-#ifdef ISC_PLATFORM_HAVEIPV6
#+#ifdef INCLUDE_IPV6_SUPPORT
# 	static struct cache6 badaddrs6[ERRORCACHESIZE];
#-#endif /* ISC_PLATFORM_HAVEIPV6 */
#+#endif /* INCLUDE_IPV6_SUPPORT */
# #else
# #define badaddrs ((struct cache *)0)		/* Only used in empty loops! */
#-#ifdef ISC_PLATFORM_HAVEIPV6
#+#ifdef INCLUDE_IPV6_SUPPORT
# #define badaddrs6 ((struct cache6 *)0)		/* Only used in empty loops! */
#-#endif /* ISC_PLATFORM_HAVEIPV6 */
#+#endif /* INCLUDE_IPV6_SUPPORT */
# #endif
# #ifdef DEBUG
# 	if (debug > 1)
#@@ -1772,7 +1757,7 @@
# 		}
# 		break;
# 
#-#ifdef ISC_PLATFORM_HAVEIPV6
#+#ifdef INCLUDE_IPV6_SUPPORT
# 	case AF_INET6 :
# 
# 	 	/*
#@@ -1793,7 +1778,7 @@
# 	                        inter->last_ttl = ttl;
# 	        }
# 	        break;
#-#endif /* ISC_PLATFORM_HAVEIPV6 */
#+#endif /* INCLUDE_IPV6_SUPPORT */
# 
# 	default :
# 		exit(1);
#@@ -1809,13 +1794,13 @@
# 				badaddrs[slot].addr.s_addr == ((struct sockaddr_in*)dest)->sin_addr.s_addr)
# 			break;
# 		}
#-#ifdef ISC_PLATFORM_HAVEIPV6
#+#ifdef INCLUDE_IPV6_SUPPORT
# 		else if (dest->ss_family == AF_INET6) {
# 			if (badaddrs6[slot].port == ((struct sockaddr_in6*)dest)->sin6_port &&
# 				badaddrs6[slot].addr.s6_addr == ((struct sockaddr_in6*)dest)->sin6_addr.s6_addr)
# 			break;
# 		}
#-#endif /* ISC_PLATFORM_HAVEIPV6 */
#+#endif /* INCLUDE_IPV6_SUPPORT */
# 		else exit(1);  /* address family not supported yet */
# 
# #if defined(HAVE_IO_COMPLETION_PORT)
#@@ -1856,7 +1841,7 @@
# 					}
# 				break;
# 
#-#ifdef ISC_PLATFORM_HAVEIPV6
#+#ifdef INCLUDE_IPV6_SUPPORT
# 			case AF_INET6 :
# 
# 				for (slot = ERRORCACHESIZE; --slot >= 0; )
#@@ -1867,7 +1852,7 @@
#                                     		break;
#                             		}
#                 		break;
#-#endif /* ISC_PLATFORM_HAVEIPV6 */
#+#endif /* INCLUDE_IPV6_SUPPORT */
# 
# 			default :
# 				exit(1);
#@@ -1891,11 +1876,11 @@
# 			case AF_INET :
# 				badaddrs[slot].port = 0;
# 				break;
#-#ifdef ISC_PLATFORM_HAVEIPV6
#+#ifdef INCLUDE_IPV6_SUPPORT
# 			case AF_INET6 :
# 				badaddrs6[slot].port = 0;
# 				break;
#-#endif /* ISC_PLATFORM_HAVEIPV6 */
#+#endif /* INCLUDE_IPV6_SUPPORT */
# 			}
# 		}
# 	}
#@@ -1996,6 +1981,13 @@
# 	{
# 		nonzeroreads = 0;
# 		n = select(maxactivefd+1, &fds, (fd_set *)0, (fd_set *)0, &tvzero);
#+
#+		/*
#+		 * If there are no packets waiting just return
#+		 */
#+		if (n <= 0)
#+			return;
#+
# 		++select_count;
# 		++handler_pkts;
# 
#@@ -2280,7 +2272,6 @@
# 		--handler_count;
# 		return;
# 	}
#-	msyslog(LOG_ERR, "input_handler: fell out of infinite for(;;) loop!");
# 	--handler_count;
# 	return;
# }
#@@ -2342,7 +2333,7 @@
# 		memcpy(&((struct sockaddr_in*)&saddr)->sin_addr, &((struct sockaddr_in*)addr)->sin_addr, sizeof(struct in_addr));
# 		((struct sockaddr_in*)&saddr)->sin_port = htons(2000);
# 	}
#-#ifdef ISC_PLATFORM_HAVEIPV6
#+#ifdef INCLUDE_IPV6_SUPPORT
# 	else if(addr->ss_family == AF_INET6) {
# 		memcpy(&((struct sockaddr_in6*)&saddr)->sin6_addr, &((struct sockaddr_in6*)addr)->sin6_addr, sizeof(struct in6_addr));
# 		((struct sockaddr_in6*)&saddr)->sin6_port = htons(2000);
#@@ -2412,7 +2403,7 @@
# 	int i;
# 	int nif = -1;
# 
#-#if defined(ISC_PLATFORM_HAVEIPV6) && defined(IPV6_JOIN_GROUP) && defined(IPV6_LEAVE_GROUP)
#+#ifdef INCLUDE_IPV6_MULTICAST_SUPPORT
# 	isc_boolean_t want_linklocal = ISC_FALSE; 
# 	if (addr_ismulticast(addr) && flags == INT_MULTICAST)
# 	{
#@@ -2438,7 +2429,7 @@
# 			continue;
# 
# 		/* Skip if different family */
#-		if(inter_list[i].family != addr->ss_family)
#+		if(inter_list[i].sin.ss_family != addr->ss_family)
# 			continue;
# 
# 		/* Is this it one of these based on flags? */
#@@ -2446,8 +2437,8 @@
# 			continue;
# 
# 		/* for IPv6 multicast check the address for linklocal */
#-#if defined(ISC_PLATFORM_HAVEIPV6) && defined(IPV6_JOIN_GROUP) && defined(IPV6_LEAVE_GROUP)
#-		if (flags == INT_MULTICAST &&
#+#ifdef INCLUDE_IPV6_MULTICAST_SUPPORT
#+		if (flags == INT_MULTICAST && inter_list[i].sin.ss_family == AF_INET6 &&
# 		   (IN6_IS_ADDR_LINKLOCAL(&((struct sockaddr_in6*)&inter_list[i].sin)->sin6_addr))
# 		   && want_linklocal == ISC_TRUE)
# 		{
#@@ -2481,28 +2472,13 @@
# 	)
# {
# #if !defined(MPE) && (defined(SIOCGIFCONF) || defined(SYS_WINNT))
#-	int i;
#-	int flag;
#+	int i = -1;
# 	
# #ifdef DEBUG
# 	if (debug>2)
# 	    printf("Finding broadcast interface for addr %s in list of addresses\n",
# 		   stoa(addr));
# #endif
#-	if (addr_ismulticast(addr))
#-		flag = INT_MULTICAST;
#-	else
#-		flag = INT_BROADCAST;
#-	i = findlocalcastinterface(addr, flag);
#-
#-	if (i >= 0) {
#-#ifdef DEBUG
#-		if (debug > 1)
#-			printf("Found bcastinter index %d\n", i);
#-#endif
#-		return (&inter_list[i]);
#-	}
#-	/* Didn't find it, so try something else */
# 
# 	i = find_flagged_addr_in_list(addr, INT_BCASTOPEN|INT_MCASTOPEN);
# #ifdef DEBUG
#@@ -2520,9 +2496,8 @@
# 		return (&inter_list[i]);
# 	}
# */
#-
# 	for (i = nwilds; i < ninterfaces; i++) {
#-		/* Don't both with ignore interfaces */
#+		/* Don't bother with ignored interfaces */
# 		if (inter_list[i].ignore_packets == ISC_TRUE)
# 			continue;
# 		/*
#@@ -2530,14 +2505,34 @@
# 		 */
# 		if(inter_list[i].sin.ss_family != addr->ss_family)
# 	  		continue;
#+
#+		/* Skip the loopback addresses */
#+		if (inter_list[i].flags & INT_LOOPBACK)
#+			continue;
#+
#+		/* for IPv6 multicast check the address for linklocal */
#+#ifdef INCLUDE_IPV6_SUPPORT
#+		if (inter_list[i].sin.ss_family == AF_INET6 &&
#+		   (IN6_IS_ADDR_LINKLOCAL(&((struct sockaddr_in6*)&inter_list[i].sin)->sin6_addr)))
#+		{
#+			continue;
#+		}
#+#endif
#+		/*
#+		 * If we are looking to match a multicast address grab it.
#+		 * We must not do this before we have eliminated any linklocal
#+		 * addresses
#+		 */
#+		if (addr_ismulticast(addr) == ISC_TRUE && inter_list[i].flags & INT_MULTICAST)
#+		{
#+			return (&inter_list[i]);
#+		}
# 		/*
# 		 * We match only those interfaces marked as
# 		 * broadcastable and either the explicit broadcast
# 		 * address or the network portion of the IP address.
# 		 * Sloppy.
# 		 */
#-		if (!(inter_list[i].flags & INT_BCASTOPEN))
#-			continue;
# 		if(addr->ss_family == AF_INET) {
# 			if (SOCKCMP(&inter_list[i].bcast, addr))
# 				return (&inter_list[i]);
#@@ -2546,12 +2541,14 @@
# 			    	NSRCADR(&inter_list[i].mask)))
# 				return (&inter_list[i]);
# 		}
#+#ifdef INCLUDE_IPV6_SUPPORT
# 		else if(addr->ss_family == AF_INET6) {
# 			if (SOCKCMP(&inter_list[i].bcast, addr))
# 				return (&inter_list[i]);
# 			if (SOCKCMP(netof(&inter_list[i].sin), netof(addr)))
# 				return (&inter_list[i]);
#-		     }
#+		}
#+#endif
# 	}
# #endif /* SIOCGIFCONF */
#  	return ANY_INTERFACE_CHOOSE(addr);
#
#--- 1.75/ntpd/ntp_peer.c	2005-04-18 01:01:04 -04:00
#+++ 1.76/ntpd/ntp_peer.c	2005-07-16 17:30:35 -04:00
#@@ -575,6 +575,11 @@
# 		peer->dstadr = loopback_interface;
# 	else if (cast_flags & (MDF_BCLNT | MDF_ACAST | MDF_MCAST | MDF_BCAST)) {
# 		peer->dstadr = findbcastinter(srcadr);
#+#ifdef DEBUG
#+		if (debug > 1)
#+			printf("Found broadcast interface address %s, for address %s\n",
#+				stoa(&(peer->dstadr)->sin), stoa(srcadr));
#+#endif
# 		/*
# 		 * If it was a multicast packet, findbcastinter() may not
# 		 * find it, so try a little harder.
#
#--- 1.8/ports/winnt/include/ntp_iocompletionport.h	2004-11-06 21:28:49 -05:00
#+++ 1.9/ports/winnt/include/ntp_iocompletionport.h	2005-07-24 15:48:34 -04:00
#@@ -8,10 +8,22 @@
# struct IoCompletionInfo;
# struct refclockio;
# 
#+/*
#+ * Request types
#+ */
#+enum {
#+	SOCK_RECV,
#+	SOCK_SEND,
#+	CLOCK_READ,
#+	CLOCK_WRITE
#+};
#+
# typedef int IoCompletionInfoFunction(DWORD Key, struct IoCompletionInfo *, DWORD Bytes);
# 
# typedef struct IoCompletionInfo {
# 	OVERLAPPED			overlapped;
#+	int				request_type;
#+	LPVOID				buff;
# 	IoCompletionInfoFunction *	iofunction;
# } IoCompletionInfo;
# 
#@@ -26,12 +38,13 @@
# 
# extern	HANDLE get_io_event (void);
# 
#-static int OnSocketRecv(DWORD, struct IoCompletionInfo *, DWORD);
#-
# struct recvbuf *GetReceivedBuffers(void);
# 
# static int QueueIORead( struct refclockio * );
#-static int OnIoReadComplete(DWORD, struct IoCompletionInfo *, DWORD);
#+
#+static int OnSocketRecv(DWORD, IoCompletionInfo *, DWORD);
#+static int OnIoReadComplete(DWORD, IoCompletionInfo *, DWORD);
#+static int OnWriteComplete(DWORD, IoCompletionInfo *, DWORD);
# # endif
# 
# #endif
#
#--- 1.3/ports/winnt/include/transmitbuff.h	2001-10-08 21:18:29 -04:00
#+++ 1.4/ports/winnt/include/transmitbuff.h	2005-07-24 15:48:34 -04:00
#@@ -6,8 +6,6 @@
# # include "ntp_iocompletionport.h"
# #endif
# 
#-#define TRANSMIT_BUF_LENGTH 1024
#-
# /*
#  * Format of a transmitbuf.  These are used by the asynchronous receive
#  * routine to store incoming packets and related information.
#@@ -16,10 +14,8 @@
# typedef struct transmitbuf {
# 	struct transmitbuf *next;		/* next buffer in chain */
# 
#-#if defined HAVE_IO_COMPLETION_PORT
#-        IoCompletionInfo	iocompletioninfo;
#-	WSABUF			wsabuf;
#-#endif
#+	WSABUF	wsabuf;
#+	time_t	ts;		/* Time stamp for the request */
# 
# 	/*
# 	 * union {
#@@ -37,7 +33,7 @@
# 
# /* freetransmitbuf - make a single transmitbuf available for reuse
#  */
#-extern	void	free_transmit_buffer P((struct transmitbuf *));
#+extern	void	free_transmit_buffer	P((transmitbuf *));
# 
# /*  Get a free buffer (typically used so an async
#  *  read can directly place data into the buffer
#@@ -45,13 +41,7 @@
#  *  The buffer is removed from the free list. Make sure
#  *  you put it back with freetransmitbuf() or 
#  */
#-extern	struct transmitbuf *get_free_transmit_buffer P((void));
#-
#-
#-
#-
#-
#-
#+extern transmitbuf *get_free_transmit_buffer P((void));
# 
# #endif /* defined __transmitbuff_h */
# 
#
#--- 1.4/ports/winnt/libntp/transmitbuff.c	2001-10-08 21:18:27 -04:00
#+++ 1.5/ports/winnt/libntp/transmitbuff.c	2005-07-24 15:48:34 -04:00
#@@ -8,6 +8,7 @@
# #include "ntp_stdlib.h"
# #include "ntp_syslog.h"
# 
#+#include <isc/list.h>
# #include "transmitbuff.h"
# 
# /*
#@@ -19,44 +20,50 @@
# #define TRANSMIT_TOOMANY	40	/* this is way too many buffers */
# 
# /*
#+ * Maximum time in seconds to allow transmit request to complete
#+ * After that we are free to delete it if we need the buffer
#+ */
#+
#+#define	MAX_TRANSMIT_SEND_TIME	60.0	
#+
#+/*
#  * Memory allocation
#  */
# static volatile u_long full_transmitbufs = 0;		/* number of transmitbufs on fulllist */
# static volatile u_long free_transmitbufs = 0;		/* number of transmitbufs on freelist */
# 
#-static	struct transmitbuf *volatile freelist = NULL;  /* free buffers */
#-static	struct transmitbuf *volatile fulllist = NULL;  /* lifo buffers with data */
#-static	struct transmitbuf *volatile beginlist = NULL; /* fifo buffers with data */
#+typedef struct transmitb transmitb_t;
#+
#+struct transmitb {
#+	transmitbuf			*tb;
#+	ISC_LINK(transmitb_t)		link;
#+};
#+
#+ISC_LIST(transmitb_t)	fulllist;		/* Currently used transmit buffers */
#+
#+static	transmitbuf *volatile freelist = NULL;  /* free buffers */
#+static	transmitbuf *volatile beginlist = NULL; /* fifo buffers with data */
# 
# static u_long total_transmitbufs = 0;		/* total transmitbufs currently in use */
# static u_long lowater_additions = 0;	/* number of times we have added memory */
# 
#-static	struct transmitbuf initial_bufs[TRANSMIT_INIT]; /* initial allocation */
#+static	transmitbuf initial_bufs[TRANSMIT_INIT]; /* initial allocation */
# 
# 
#-#if defined(HAVE_SIGNALED_IO)
#-# define TRANSMIT_BLOCK_IO()	BLOCKIO()
#-# define TRANSMIT_UNBLOCK_IO()	UNBLOCKIO()
#-#elif defined(HAVE_IO_COMPLETION_PORT)
#-static CRITICAL_SECTION TransmitCritSection;
#-# define TRANSMIT_BLOCK_IO()	EnterCriticalSection(&TransmitCritSection)
#-# define TRANSMIT_UNBLOCK_IO()	LeaveCriticalSection(&TransmitCritSection)
#-#else
#-# define TRANSMIT_BLOCK_IO()
#-# define TRANSMIT_UNBLOCK_IO()
#-#endif
#+static CRITICAL_SECTION TransmitLock;
#+# define LOCK(lock)	EnterCriticalSection(lock)
#+# define UNLOCK(lock)	LeaveCriticalSection(lock)
# 
#+static	struct transmitbuf initial_bufs[TRANSMIT_INIT]; /* initial allocation */
#+static	int eventid = 0;
# 
# static void 
#-initialise_buffer(struct transmitbuf *buff)
#+initialise_buffer(transmitbuf *buff)
# {
#-	memset((char *) buff, 0, sizeof(struct transmitbuf));
#+	memset((char *) buff, 0, sizeof(transmitbuf));
# 
#-#if defined HAVE_IO_COMPLETION_PORT
#-	buff->iocompletioninfo.overlapped.hEvent = CreateEvent(NULL, FALSE,FALSE, NULL);
# 	buff->wsabuf.len = 0;
# 	buff->wsabuf.buf = (char *) &buff->pkt;
#-#endif
# }
# 
# 
#@@ -67,36 +74,97 @@
# 	/*
# 	 * Init buffer free list and stat counters
# 	 */
#-	freelist = 0;
#+	freelist = NULL;
# 	for (i = 0; i < TRANSMIT_INIT; i++)
# 	{
# 		initialise_buffer(&initial_bufs[i]);
#-		initial_bufs[i].next = (struct transmitbuf *) freelist;
#+		initial_bufs[i].next = (transmitbuf *) freelist;
# 		freelist = &initial_bufs[i];
# 	}
# 
#-	fulllist = 0;
#+	ISC_LIST_INIT(fulllist);
# 	free_transmitbufs = total_transmitbufs = TRANSMIT_INIT;
# 	full_transmitbufs = lowater_additions = 0;
# 
#-#if defined(HAVE_IO_COMPLETION_PORT)
#-	InitializeCriticalSection(&TransmitCritSection);
#-#endif
#+	InitializeCriticalSection(&TransmitLock);
#+}
#+
#+static void
#+add_buffer_to_freelist(transmitbuf *tb)
#+{
#+	tb->next = freelist;
#+	freelist = tb;
#+	free_transmitbufs++;
#+}
#+
#+static void
#+delete_buffer_from_full_list(transmitbuf *tb) {
#+
#+	transmitb_t *next;
#+	transmitb_t *lbuf = ISC_LIST_HEAD(fulllist);
#+
#+	while(lbuf != NULL) {
#+		next = ISC_LIST_NEXT(lbuf, link);
#+		if(lbuf->tb == tb) {
#+			ISC_LIST_DEQUEUE_TYPE(fulllist, lbuf, link, transmitb_t);
#+			free(lbuf);
#+			break;
#+		}
#+		else
#+			lbuf = next;
#+	}
# }
# 
#+/*
#+ * routine to free up any buffer that has not been freed up
#+ * after MAX_TRANSMIT_SEND_TIME seconds. Note that we are not being
#+ * too careful here about the correct value of time since we just need
#+ * and approximate measure of how much time has elapsed since the
#+ * packet was sent and this routine is only called if we run out
#+ * of tranmit buffers.
#+ */
#+static int
#+free_unsent_buffers()
#+{
#+	int tot_freed = 0;
#+	double elapsed_time;
#+	time_t ct;
#+	transmitbuf *buf;
#+	transmitb_t *next;
#+	transmitb_t *lbuf = ISC_LIST_HEAD(fulllist);
#+
#+	time(&ct);	/* Current Time */
#+
#+	LOCK(&TransmitLock);
#+	while(lbuf != NULL) {
#+		next = ISC_LIST_NEXT(lbuf, link);
#+		elapsed_time = difftime(ct, lbuf->tb->ts);
#+		if (elapsed_time > MAX_TRANSMIT_SEND_TIME) {
#+			ISC_LIST_DEQUEUE_TYPE(fulllist, lbuf, link, transmitb_t);
#+			free(lbuf);
#+			add_buffer_to_freelist(lbuf->tb);
#+			tot_freed++;
#+		}
#+		else
#+			lbuf = next;
#+	}
#+	UNLOCK(&TransmitLock);
#+	return (tot_freed);
#+}
# 
# static void
# create_buffers(void)
# {
#-	register struct transmitbuf *buf;
#+	transmitbuf *buf;
# 	int i;
#+	if (free_unsent_buffers() > 0)
#+		return;
# 
#-	buf = (struct transmitbuf *)
#-	    emalloc(TRANSMIT_INC*sizeof(struct transmitbuf));
#+	buf = (transmitbuf *) emalloc(TRANSMIT_INC*sizeof(transmitbuf));
# 	for (i = 0; i < TRANSMIT_INC; i++)
# 	{
# 		initialise_buffer(buf);
#-		buf->next = (struct transmitbuf *) freelist;
#+		buf->next = (transmitbuf *) freelist;
# 		freelist = buf;
# 		buf++;
# 	}
#@@ -108,31 +176,33 @@
# 
# 
# extern void
#-free_transmit_buffer(
#-	struct transmitbuf *rb
#-	)
#-{
#-	TRANSMIT_BLOCK_IO();
#-	rb->next = freelist;
#-	freelist = rb;
#-	free_transmitbufs++;
#-	TRANSMIT_UNBLOCK_IO();
#+free_transmit_buffer(transmitbuf *rb)
#+{
#+	LOCK(&TransmitLock);
#+	add_buffer_to_freelist(rb);
#+	delete_buffer_from_full_list(rb);
#+	UNLOCK(&TransmitLock);
# }
# 
# 
#-extern struct transmitbuf *
#+extern transmitbuf *
# get_free_transmit_buffer(void)
# {
#-	struct transmitbuf * buffer = NULL;
#-	TRANSMIT_BLOCK_IO();
#+	transmitb_t *lbuf = (transmitb_t *)malloc(sizeof(transmitb_t));
#+
#+	transmitbuf * buffer = NULL;
#+	LOCK(&TransmitLock);
# 	if (free_transmitbufs <= 0) {
# 		create_buffers();
# 	}
# 	buffer = freelist;
# 	freelist = buffer->next;
# 	buffer->next = NULL;
#+	time(&buffer->ts);	/* Time we gave out the transmit buffer */
#+	lbuf->tb = buffer;
#+	ISC_LIST_APPEND(fulllist, lbuf, link);
# 	--free_transmitbufs;
#-	TRANSMIT_UNBLOCK_IO();
#+	UNLOCK(&TransmitLock);
# 	return buffer;
# }
# 
#
#--- 1.17/ports/winnt/ntpd/nt_clockstuff.c	2005-04-16 23:20:47 -04:00
#+++ 1.18/ports/winnt/ntpd/nt_clockstuff.c	2005-07-24 15:48:34 -04:00
#@@ -430,7 +430,7 @@
# 
# 	/* init sync objects */
# 	InitializeCriticalSection(&TimerCritialSection);
#-	TimerThreadExitRequest = CreateEvent(NULL, FALSE, FALSE, NULL);
#+	TimerThreadExitRequest = CreateEvent(NULL, FALSE, FALSE, "TimerThreadExitRequest");
# 
# 	ClockThreadHandle = CreateThread(NULL, 0, ClockThread, NULL, 0, &tid);
# 	if (ClockThreadHandle != NULL) {
#
#--- 1.14/ports/winnt/ntpd/ntp_iocompletionport.c	2005-03-30 23:07:23 -05:00
#+++ 1.15/ports/winnt/ntpd/ntp_iocompletionport.c	2005-07-24 15:48:34 -04:00
#@@ -18,10 +18,18 @@
# #include "transmitbuff.h"
# 
# 
#+#define BUFCHECK_SECS	10
#+static void	TransmitCheckThread(void *NotUsed);
#+static BOOL	bExit;
#+static HANDLE	TimerHandle;
#+static HANDLE hHeapHandle = NULL;
#+
# static HANDLE hIoCompletionPort = NULL;
# 
# static HANDLE WaitableIoEventHandle = NULL;
#-HANDLE WaitHandles[3] = { NULL, NULL, NULL };
#+
#+#define MAXHANDLES 3
#+HANDLE WaitHandles[MAXHANDLES] = { NULL, NULL, NULL };
# 
# HANDLE
# get_io_event()
#@@ -29,38 +37,24 @@
# 	return( WaitableIoEventHandle );
# }
# 
#-
#-static int 
#-OnExitRequest(DWORD Key, struct IoCompletionInfo *Info, DWORD Bytes)
#-{
#-  (void) Info;
#-  (void) Bytes;
#-  (void) Key;
#-  return 0; /* auto-fail to request an exit */
#-}
#-
#-static IoCompletionInfo ExitRequest;
# /*  This function will add an entry to the I/O completion port
#  *  that will signal the I/O thread to exit (gracefully)
#  */
# static void
# signal_io_completion_port_exit()
# {
#-	ExitRequest.iofunction = OnExitRequest;
#-	if (!PostQueuedCompletionStatus(hIoCompletionPort, 0, 0, &ExitRequest.overlapped)) {
#+	if (!PostQueuedCompletionStatus(hIoCompletionPort, 0, 0, 0)) {
# 		msyslog(LOG_ERR, "Can't request service thread to exit: %m");
# 		exit(1);
# 	}
# }
# 
#-
#-static void __cdecl 
#+static void
# iocompletionthread(void *NotUsed)
# {
# 	DWORD BytesTransferred = 0;
# 	DWORD Key = 0;
#-	IoCompletionInfo * Overlapped = NULL;
#-	(void) NotUsed;
#+	IoCompletionInfo * lpo = NULL;
# 
# 	/*	Set the thread priority high enough so I/O will
# 	 *	preempt normal recv packet processing, but not
#@@ -70,17 +64,43 @@
# 		msyslog(LOG_ERR, "Can't set thread priority: %m");
# 	}
# 
#-	for (;;) {
#-		while (GetQueuedCompletionStatus(hIoCompletionPort, &BytesTransferred, &Key, & (LPOVERLAPPED) Overlapped, INFINITE)) {
#-			if (Overlapped != NULL && 
#-				Overlapped->iofunction != NULL) {
#-				if (!Overlapped->iofunction(Key, Overlapped, BytesTransferred)) {
#+	while (TRUE) {
#+		GetQueuedCompletionStatus(hIoCompletionPort, 
#+					  &BytesTransferred, 
#+					  &Key, 
#+					  & (LPOVERLAPPED) lpo, 
#+					  INFINITE);
#+		if (lpo == NULL)
#+		{
# #ifdef DEBUG
# 			msyslog(LOG_INFO, "Overlapped IO Thread Exits: %m");	
# #endif
#-				return ; /* fail */
#-				}
#+			break; /* fail */
#+		}
#+
#+		/*
#+		 * Invoke the appropriate function based on
#+		 * the value of the request_type
#+		 */
#+		switch(lpo->request_type)
#+		{
#+		case CLOCK_READ:
#+			OnIoReadComplete(Key, lpo, BytesTransferred);
#+			break;
#+		case SOCK_RECV:
#+			OnSocketRecv(Key, lpo, BytesTransferred);
#+			break;
#+		case SOCK_SEND:
#+		case CLOCK_WRITE:
#+			OnWriteComplete(Key, lpo, BytesTransferred);
#+			break;
#+		default:
#+#if DEBUG
#+			if (debug > 3) {
#+				printf("Unknown request type %d found in completion port\n",
#+					lpo->request_type);
# 			}
#+#endif
# 		}
# 	}
# }
#@@ -93,9 +113,21 @@
# 	)
# {
# 
#+	/*
#+	 * Create a handle to the Heap
#+	 */
#+	hHeapHandle = HeapCreate(0, 20*sizeof(IoCompletionInfo), 0);
#+
#+	/* Set the exit flag */
#+	bExit = FALSE;
#+	/*
#+	 * Initialize the timer watch section
#+	 */
#+//	_beginthread(TransmitCheckThread, 0, NULL);
#+
# 	/* Create the event used to signal an IO event
# 	 */
#-	WaitableIoEventHandle = CreateEvent(NULL, FALSE, FALSE, NULL);
#+	WaitableIoEventHandle = CreateEvent(NULL, FALSE, FALSE, "WaitableIoEventHandle");
# 	if (WaitableIoEventHandle == NULL) {
# 		msyslog(LOG_ERR, "Can't create I/O event handle: %m");
# 		exit(1);
#@@ -112,7 +144,7 @@
# 	/*
# 	 * Initialize the Wait Handles
# 	 */
#-	WaitHandles[0] = CreateEvent(NULL, FALSE, FALSE, NULL); /* exit request */
#+	WaitHandles[0] = CreateEvent(NULL, FALSE, FALSE, "WaitHandles0"); /* exit request */
# 	WaitHandles[1] = get_timer_handle();
# 	WaitHandles[2] = get_io_event();
# 
#@@ -128,6 +160,12 @@
# 	void
# 	)
# {
#+	/*
#+	 * Tell the timer handle to exit
#+	 */
#+	bExit = TRUE;
#+	SetEvent(TimerHandle);
#+
# 	if (hIoCompletionPort != NULL) {
# 		/*  Get each of the service threads to exit
# 		*/
#@@ -139,15 +177,21 @@
# static int QueueIORead( struct refclockio *rio ) {
# 
# 	struct recvbuf *buff;
#+	IoCompletionInfo *lpo;
# 
#+	lpo = (IoCompletionInfo *) HeapAlloc(hHeapHandle,
#+					     HEAP_ZERO_MEMORY,
#+					     sizeof(IoCompletionInfo));
# 	buff = get_free_recv_buffer();
# 	
# 	if (buff == NULL)
# 		return 0;
# 	
#+	lpo->request_type = CLOCK_READ;
#+	lpo->buff = buff;
#+
# 	buff->fd = rio->fd;
#-	buff->iocompletioninfo.iofunction = OnIoReadComplete;
#-	if (!ReadFile((HANDLE) buff->fd, &buff->recv_buffer, sizeof(buff->recv_buffer), NULL, &buff->iocompletioninfo.overlapped)) {
#+	if (!ReadFile((HANDLE) buff->fd, &buff->recv_buffer, sizeof(buff->recv_buffer), NULL, (LPOVERLAPPED) lpo)) {
# 			DWORD Result = GetLastError();
# 			switch (Result) {				
# 					case NO_ERROR :
#@@ -158,6 +202,9 @@
# 				default:
# 					msyslog(LOG_ERR, "Can't read from Refclock: %m");
# 					freerecvbuf(buff);
#+					/* Clear the heap */
#+					if (lpo != NULL)
#+						HeapFree(hHeapHandle, 0, lpo);
# 					return 0;
# 			}
# 	}
#@@ -168,15 +215,14 @@
# 
# /* Return 1 on Successful Read */
# static int 
#-OnIoReadComplete(DWORD i, struct IoCompletionInfo *Info, DWORD Bytes)
#+OnIoReadComplete(DWORD i, IoCompletionInfo *lpo, DWORD Bytes)
# {
# 	struct recvbuf *buff = NULL;
# 	struct refclockio * rio = (struct refclockio *) i;
# 
# 	/*  Convert the overlapped pointer back to a recvbuf pointer.
# 	*/
#-	buff = (struct recvbuf *) ( ((char *) Info) - offsetof(struct recvbuf, iocompletioninfo));
#-
#+	buff = (struct recvbuf *) lpo->buff;
# 	if (Bytes > 0) { /* ignore 0 bytes read due to timeout's */
# 		get_systime(&buff->recv_time);
# 		buff->recv_length = (int) Bytes;
#@@ -196,6 +242,10 @@
# 	else 
#  		freerecvbuf(buff);
# 
#+	/* Clear the heap */
#+	if (lpo != NULL)
#+		HeapFree(hHeapHandle, 0, lpo);
#+
# 	QueueIORead( rio );
# 	return 1;
# }
#@@ -221,19 +271,27 @@
# static unsigned long QueueSocketRecv(SOCKET s) {
# 	
# 	struct recvbuf *buff;
#+	IoCompletionInfo *lpo;
#+	int AddrLen;
#+
#+	lpo = (IoCompletionInfo *) HeapAlloc(hHeapHandle,
#+					     HEAP_ZERO_MEMORY,
#+					     sizeof(IoCompletionInfo));
# 	buff = get_free_recv_buffer();
# 
#+	lpo->request_type = SOCK_RECV;
#+	lpo->buff = buff;
#+
# 	if (buff != NULL) {
# 		DWORD BytesReceived = 0;
# 		DWORD Flags = 0;
#-		buff->iocompletioninfo.iofunction = OnSocketRecv;
# 		buff->fd = s;
#-		buff->AddressLength = sizeof(struct sockaddr_in);
#+		AddrLen = sizeof(struct sockaddr_in);
# 
# 		if (SOCKET_ERROR == WSARecvFrom(buff->fd, &buff->wsabuff, 1, 
# 						&BytesReceived, &Flags, 
#-						(struct sockaddr *) &buff->recv_srcadr, (LPINT) &buff->AddressLength, 
#-						&buff->iocompletioninfo.overlapped, NULL)) {
#+						(struct sockaddr *) &buff->recv_srcadr, (LPINT) &AddrLen, 
#+						(LPOVERLAPPED) lpo, NULL)) {
# 			DWORD Result = WSAGetLastError();
# 			switch (Result) {
# 				case NO_ERROR :
#@@ -245,11 +303,17 @@
# 				case WSAENOTSOCK :
# 					netsyslog(LOG_ERR, "Can't read from socket, because it isn't a socket: %m");
# 					freerecvbuf(buff);
#+					/* Clear the heap */
#+					if (lpo != NULL)
#+						HeapFree(hHeapHandle, 0, lpo);
# 					return 0;
# 					break;
# 
# 				case WSAEFAULT :
# 					netsyslog(LOG_ERR, "The buffers parameter is incorrect: %m");
#+					/* Clear the heap */
#+					if (lpo != NULL)
#+						HeapFree(hHeapHandle, 0, lpo);
# 					freerecvbuf(buff);
# 					return 0;
# 				break;
#@@ -267,7 +331,7 @@
# 
# /* Returns 0 if any Error */
# static int 
#-OnSocketRecv(DWORD i, struct IoCompletionInfo *Info, DWORD Bytes)
#+OnSocketRecv(DWORD i, IoCompletionInfo *lpo, DWORD Bytes)
# {
# 	struct recvbuf *buff = NULL;
# 	struct interface * inter = (struct interface *) i;
#@@ -275,7 +339,7 @@
# 	/*  Convert the overlapped pointer back to a recvbuf pointer.
# 	*/
# 	
#-	buff = (struct recvbuf *) ( ((char *) Info) - offsetof(struct recvbuf, iocompletioninfo));
#+	buff = (struct recvbuf *) lpo->buff;
# 	get_systime(&buff->recv_time);	
# 	
# 	if (Bytes > 0 && inter->ignore_packets == ISC_FALSE) {	
#@@ -283,12 +347,8 @@
# 		buff->receiver = receive; 
# 		buff->dstadr = inter;
# #ifdef DEBUG
#-		if (debug > 3) {
#-		char  strbuffer[256];
#-		DWORD strlength = sizeof(strbuffer);
#-		if (0 == WSAAddressToString((struct sockaddr *) &buff->recv_srcadr, buff->AddressLength, NULL, strbuffer, &strlength)) 
#-  			printf("Received %d bytes from %s\n", Bytes, strbuffer);
#-	}
#+		if (debug > 3)
#+  			printf("Received %d bytes from %s\n", stoa(&buff->recv_srcadr));
# #endif
# 		add_full_recv_buffer(buff);
# 		if( !SetEvent( WaitableIoEventHandle ) ) {
#@@ -302,6 +362,10 @@
# 	else {
# 		freerecvbuf(buff);
# 	}
#+	/* Clear the heap */
#+	if (lpo != NULL)
#+		HeapFree(hHeapHandle, 0, lpo);
#+
# 	QueueSocketRecv(inter->fd);
# 	return 1;
# }
#@@ -327,29 +391,35 @@
# 
# 
# static int 
#-OnSendToComplete(DWORD Key, struct IoCompletionInfo *Info, DWORD Bytes)
#+OnSendToComplete(DWORD Key, IoCompletionInfo *lpo, DWORD Bytes)
# {
# 	transmitbuf *buff = NULL;
# 	(void) Bytes;
# 	(void) Key;
# 
#-	buff = (struct transmitbuf *) ( ((char *) Info) - offsetof(struct transmitbuf, iocompletioninfo));
#+	buff = (struct transmitbuf *) lpo->buff;
# 
# 	free_transmit_buffer(buff);
#+	/* Clear the heap */
#+	if (lpo != NULL)
#+		HeapFree(hHeapHandle, 0, lpo);
# 	return 1;
# }
# 
# 
# static int 
#-OnWriteComplete(DWORD Key, struct IoCompletionInfo *Info, DWORD Bytes)
#+OnWriteComplete(DWORD Key, IoCompletionInfo *lpo, DWORD Bytes)
# {
# 	transmitbuf *buff = NULL;
# 	(void) Bytes;
# 	(void) Key;
# 
#-	buff = (struct transmitbuf *) ( ((char *) Info) - offsetof(struct transmitbuf, iocompletioninfo));
#+	buff = (struct transmitbuf *) lpo->buff;
# 
# 	free_transmit_buffer(buff);
#+	/* Clear the heap */
#+	if (lpo != NULL)
#+		HeapFree(hHeapHandle, 0, lpo);
# 	return 1;
# }
# 
#@@ -364,6 +434,12 @@
# 	transmitbuf *buff = NULL;
# 	DWORD Result = ERROR_SUCCESS;
# 	int errval;
#+	int AddrLen;
#+	IoCompletionInfo *lpo;
#+
#+	lpo = (IoCompletionInfo *) HeapAlloc(hHeapHandle,
#+					     HEAP_ZERO_MEMORY,
#+					     sizeof(IoCompletionInfo));
# 
# 	if (len <= sizeof(buff->pkt)) {
# 		buff = get_free_transmit_buffer();
#@@ -375,8 +451,11 @@
# 			buff->wsabuf.buf = buff->pkt;
# 			buff->wsabuf.len = len;
# 
#-			buff->iocompletioninfo.iofunction = OnSendToComplete;
#-			Result = WSASendTo(inter->fd, &buff->wsabuf, 1, &BytesSent, Flags, (struct sockaddr *) dest, sizeof(struct sockaddr_in), &buff->iocompletioninfo.overlapped, NULL);
#+			AddrLen = sizeof(struct sockaddr_in);
#+			lpo->request_type = SOCK_SEND;
#+			lpo->buff = buff;
#+
#+			Result = WSASendTo(inter->fd, &buff->wsabuf, 1, &BytesSent, Flags, (struct sockaddr *) dest, AddrLen, (LPOVERLAPPED) lpo, NULL);
# 
# 			if(Result == SOCKET_ERROR)
# 			{
#@@ -392,16 +471,13 @@
# 
# 				default :
# 					netsyslog(LOG_ERR, "WSASendTo - error sending message: %m");
#+					free_transmit_buffer(buff);
# 					break;
# 				}
# 			}
# #ifdef DEBUG
#-			if (debug > 2) {
#-				char  strbuffer[256];
#-				DWORD strlength = sizeof(strbuffer);
#-				if (0 == WSAAddressToString((LPSOCKADDR) dest, sizeof(*dest), NULL, strbuffer, &strlength)) 
#-  					printf("WSASendTo - %d bytes to %s : %d\n", len, strbuffer, Result);
#-			}
#+			if (debug > 3)
#+				printf("WSASendTo - %d bytes to %s : %d\n", len, stoa(dest), Result);
# #endif
# 			return (Result);
# 		}
#@@ -431,22 +507,47 @@
# 	char *pkt,	
# 	int len)
# {
#+	DWORD errval;
# 	transmitbuf *buff = NULL;
# 	DWORD lpNumberOfBytesWritten;
# 	DWORD Result = ERROR_INSUFFICIENT_BUFFER;
#+	IoCompletionInfo *lpo;
#+
#+	lpo = (IoCompletionInfo *) HeapAlloc(hHeapHandle,
#+					     HEAP_ZERO_MEMORY,
#+					     sizeof(IoCompletionInfo));
# 
# 	if (len <= sizeof(buff->pkt)) {
# 		buff = get_free_transmit_buffer();
# 		if (buff != NULL) {
# 
#+			lpo->request_type = CLOCK_WRITE;
#+			lpo->buff = buff;
# 			memcpy(&buff->pkt, pkt, len);
#-			buff->iocompletioninfo.iofunction = OnWriteComplete;
# 
#-			Result = WriteFile(fd, buff->pkt, len, &lpNumberOfBytesWritten, &buff->iocompletioninfo.overlapped);
#+			Result = WriteFile(fd, buff->pkt, len, &lpNumberOfBytesWritten, (LPOVERLAPPED) lpo);
#+
#+			if(Result == SOCKET_ERROR)
#+			{
#+				errval = WSAGetLastError();
#+				switch (errval) {
# 
#+				case NO_ERROR :
#+				case WSA_IO_INCOMPLETE :
#+				case WSA_WAIT_IO_COMPLETION :
#+				case WSA_IO_PENDING :
#+					Result = ERROR_SUCCESS;
#+					break ;
#+
#+				default :
#+					netsyslog(LOG_ERR, "WriteFile - error sending message: %m");
#+					free_transmit_buffer(buff);
#+					break;
#+				}
#+			}
# #ifdef DEBUG
# 			if (debug > 2) {
#-				printf("SendTo - %d bytes %d\n", len, Result);
#+				printf("WriteFile - %d bytes %d\n", len, Result);
# 			}
# #endif
# 			if (Result) return len;
#@@ -467,10 +568,14 @@
# 	return Result;
# }
# 
#+/*
#+ * GetReceivedBuffers
#+ * Note that this is in effect the main loop for processing requests
#+ * both send and receive. This should be reimplemented
#+ */
# struct recvbuf *GetReceivedBuffers()
# {
#-
#-	DWORD Index = WaitForMultipleObjectsEx(sizeof(WaitHandles)/sizeof(WaitHandles[0]), WaitHandles, FALSE, 1000, TRUE);
#+	DWORD Index = WaitForMultipleObjectsEx(MAXHANDLES, WaitHandles, FALSE, INFINITE, TRUE);
# 	switch (Index) {
# 	case WAIT_OBJECT_0 + 0 : /* exit request */
# 		exit(0);
#@@ -501,7 +606,23 @@
# 		break;		
# 				
# 	} /* switch */
#+
# 	return (getrecvbufs());	/* get received buffers */
#+}
#+static void
#+TransmitCheckThread(void *NotUsed)
#+{
#+
#+	int SleepSecs = BUFCHECK_SECS;
#+	while (TRUE) 
#+	{
#+		Sleep(SleepSecs*1000);
#+
#+		/* If we are done we exit */
#+		if (bExit)
#+			return;
#+				
#+	} /* while */
# }
# 
# #else
#

# Diff checksum=4ecbb35a


# Patch vers:	1.3
# Patch type:	REGULAR

== ChangeSet ==
stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
mayer at pogo.udel.edu|ChangeSet|20050703123038|41346
D 1.1388 05/07/16 17:29:55-04:00 mayer at pogo.udel.edu +1 -0
B stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
C
c Fix read loop to skip out if nothing to do and not complain about it
K 41367
P ChangeSet
------------------------------------------------

0a0
> stenn at whimsy.udel.edu|ntpd/ntp_io.c|19990526004817|01635|3aed0663 mayer at pogo.udel.edu|ntpd/ntp_io.c|20050716212939|27998

mayer at pogo.udel.edu|ChangeSet|20050716212955|41367
D 1.1389 05/07/16 17:30:55-04:00 mayer at pogo.udel.edu +1 -0
B stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
C
c Add debug code to print the broadcast interface used
K 41129
P ChangeSet
------------------------------------------------

0a0
> stenn at whimsy.udel.edu|ntpd/ntp_peer.c|19990526004817|01635|3aed0663 mayer at pogo.udel.edu|ntpd/ntp_peer.c|20050716213035|26884

mayer at pogo.udel.edu|ChangeSet|20050716213055|41129
D 1.1390 05/07/24 15:50:24-04:00 mayer at pogo.udel.edu +7 -0
B stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
C
c Revamp of I/O Completion ports for Windows
K 42565
P ChangeSet
------------------------------------------------

0a0
> stenn at whimsy.udel.edu|include/recvbuff.h|19990721005034|03868|06470f1c mayer at pogo.udel.edu|include/recvbuff.h|20050724194834|06336
> stenn at whimsy.udel.edu|libntp/recvbuff.c|19990721005052|03868|06470f1c mayer at pogo.udel.edu|libntp/recvbuff.c|20050724194834|37652
> stenn at whimsy.udel.edu|ports/winnt/include/ntp_iocompletionport.h|19990728020335|01289|29080509 mayer at pogo.udel.edu|ports/winnt/include/ntp_iocompletionport.h|20050724194834|37480
> stenn at whimsy.udel.edu|ports/winnt/include/transmitbuff.h|19990728020335|01289|29080509 mayer at pogo.udel.edu|ports/winnt/include/transmitbuff.h|20050724194834|22410
> stenn at whimsy.udel.edu|ports/winnt/libntp/transmitbuff.c|19990728020416|01289|29080509 mayer at pogo.udel.edu|ports/winnt/libntp/transmitbuff.c|20050724194834|05103
> stenn at whimsy.udel.edu|ports/winnt/ntpd/nt_clockstuff.c|19991016040804|07763|8b711e53 mayer at pogo.udel.edu|ports/winnt/ntpd/nt_clockstuff.c|20050724194834|01217
> stenn at whimsy.udel.edu|ports/winnt/ntpd/ntp_iocompletionport.c|19990728020426|01289|29080509 mayer at pogo.udel.edu|ports/winnt/ntpd/ntp_iocompletionport.c|20050724194834|46171

mayer at pogo.udel.edu|ChangeSet|20050724195024|42565
D 1.1391 05/07/24 16:41:43-04:00 mayer at pogo.udel.edu +1 -0
B stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
C
c Fix isaddr_multicast to not be dependent on whether or not MCAST is supported
K 42529
P ChangeSet
------------------------------------------------

0a0
> stenn at whimsy.udel.edu|ntpd/ntp_io.c|19990526004817|01635|3aed0663 mayer at pogo.udel.edu|ntpd/ntp_io.c|20050724204120|28313

mayer at pogo.udel.edu|ChangeSet|20050724204143|42529
D 1.1392 05/07/25 12:46:00-04:00 mayer at pogo.udel.edu +1 -0
B stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
C
c Always provide the addr_ismulticast function
K 42546
P ChangeSet
------------------------------------------------

0a0
> stenn at whimsy.udel.edu|ntpd/ntp_io.c|19990526004817|01635|3aed0663 mayer at pogo.udel.edu|ntpd/ntp_io.c|20050725164527|28313

mayer at pogo.udel.edu|ChangeSet|20050725164600|42546
D 1.1393 05/07/25 18:09:52-04:00 stenn at whimsy.udel.edu +0 -0
B stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
C
c Merge pogo:/usa/mayer/ntp-dev
c into  whimsy.udel.edu:/deacon/backroom/ntp-dev
i stenn at whimsy.udel.edu|ChangeSet|20050720002529|41341
i stenn at whimsy.udel.edu|ChangeSet|20050720021332|41070
i kardel at pogo.udel.edu|ChangeSet|20050721194337|52580
i stenn at pogo.udel.edu|ChangeSet|20050723003247|52584
K 53784
M stenn at pogo.udel.edu|ChangeSet|20050723003247|52584
P ChangeSet
------------------------------------------------


== include/recvbuff.h ==
stenn at whimsy.udel.edu|include/recvbuff.h|19990721005034|03868|06470f1c
mayer at tecotoo.|include/recvbuff.h|20041107024239|11826
D 1.9 05/07/24 15:48:34-04:00 mayer at pogo.udel.edu +0 -2
B stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
C
c Revamp of I/O Completion ports for Windows
K 6336
O -rw-rw-r--
P include/recvbuff.h
------------------------------------------------

D59 1
D61 1

== libntp/recvbuff.c ==
stenn at whimsy.udel.edu|libntp/recvbuff.c|19990721005052|03868|06470f1c
mayer at tecotoo.|libntp/recvbuff.c|20041007011700|44243
D 1.11 05/07/24 15:48:34-04:00 mayer at pogo.udel.edu +22 -17
B stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
C
c Revamp of I/O Completion ports for Windows
K 37652
O -rw-rw-r--
P libntp/recvbuff.c
------------------------------------------------

D27 3
I29 9
\
/*
 * For Windows we need to set up a lock to manipulate the
 * recv buffers to prevent corruption. We keep it lock for as
 * short a time as possible
 */
static CRITICAL_SECTION RecvLock;
# define LOCK()		EnterCriticalSection(&RecvLock)
# define UNLOCK()	LeaveCriticalSection(&RecvLock)
D31 2
I32 2
# define LOCK()	
# define UNLOCK()	
D65 1
D117 1
I117 1
	InitializeCriticalSection(&RecvLock);
D134 1
I134 1
	LOCK();
D169 1
I169 1
	UNLOCK();
D185 1
I185 1
	LOCK();
D191 1
I191 1
	UNLOCK();
D200 1
I200 1
	LOCK();
D214 1
I214 1
	UNLOCK();
D221 1
I221 1
	LOCK();
D242 1
I242 1
	UNLOCK();
D250 1
I250 1
	LOCK();
D257 1
I257 1
	UNLOCK();

== ntpd/ntp_io.c ==
stenn at whimsy.udel.edu|ntpd/ntp_io.c|19990526004817|01635|3aed0663
mayer at pogo.udel.edu|ntpd/ntp_io.c|20050702192525|53193
D 1.182 05/07/16 17:29:39-04:00 mayer at pogo.udel.edu +143 -146
B stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
C
c Fix read loop to skip out if nothing to do and not complain about it
K 27998
O -rw-rw-r--
P ntpd/ntp_io.c
------------------------------------------------

I48 13
/* 
 * Set up some macros to look for IPv6 and IPv6 multicast
 */
\
#if defined(ISC_PLATFORM_HAVEIPV6) && !defined(DISABLE_IPV6)
\
#define INCLUDE_IPV6_SUPPORT
\
#if defined(INCLUDE_IPV6_SUPPORT) && defined(IPV6_JOIN_GROUP) && defined(IPV6_LEAVE_GROUP)
#define INCLUDE_IPV6_MULTICAST_SUPPORT
\
#endif	/* IPV6 Multicast Support */
#endif  /* IPv6 Support */
D341 1
I341 2
\
	printf("interface %d:  fd=%d,  bfd=%d,  name=%s,  flags=0x%x,  scope=%d\n",
D355 1
I355 2
\
	printf(" %s\n", inter_list[ind].ignore_packets == ISC_FALSE ? "Enabled": "Disabled");
D406 1
I406 1
#ifdef INCLUDE_IPV6_SUPPORT
I478 1
	itf->scopeid = 0;
D508 1
I508 1
#ifdef INCLUDE_IPV6_SUPPORT
D534 1
I534 1
#endif /* INCLUDE_IPV6_SUPPORT */
I578 1
#ifdef INCLUDE_IPV6_SUPPORT
D581 1
I581 1
#if defined(DEBUG)
I585 1
#endif
D662 1
I662 1
			msyslog(LOG_INFO, "Listening on interface %s, %s#%d %s",
D665 2
I666 4
				NTP_PORT,
				(inter_list[i].ignore_packets == ISC_FALSE) ?
				"Enabled": "Disabled");
/*		if ((inter_list[i].flags & INT_BROADCAST) &&
I670 5
*/
	/*
	 * Calculate the address hash for each interface address.
	 */
		inter_list[i].addr_refid = addr2refid(&inter_list[i].sin);
D690 7
D821 1
D825 3
I827 4
		if (!IN_CLASSD(ntohl(((struct sockaddr_in*)maddr)->sin_addr.s_addr))) {
#ifdef DEBUG
			if (debug > 1)
				printf("multicast address %s not class D\n",
I828 1
#endif
D837 1
I837 1
#ifdef INCLUDE_IPV6_MULTICAST_SUPPORT
D839 2
I840 3
#ifdef DEBUG
			if (debug > 1)
				printf("address %s not IPv6 multicast address\n",
I841 1
#endif
D870 1
I870 1
#ifdef INCLUDE_IPV6_MULTICAST_SUPPORT
D873 1
I873 1
#endif /* INCLUDE_IPV6_MULTICAST_SUPPORT */
D908 1
I908 1
#ifdef INCLUDE_IPV6_MULTICAST_SUPPORT
D918 6
I923 1
		mreq6.ipv6mr_interface = lscope;
D944 1
I944 1
#endif	/* INCLUDE_IPV6_MULTICAST_SUPPORT */
D960 1
I960 1
#ifdef INCLUDE_IPV6_MULTICAST_SUPPORT
D963 1
I963 1
#endif /* INCLUDE_IPV6_MULTICAST_SUPPORT */
D983 1
I983 1
#ifdef INCLUDE_IPV6_MULTICAST_SUPPORT
D993 6
I998 1
		mreq6.ipv6mr_interface = iface->scopeid;
D1011 1
I1011 1
#endif	/* INCLUDE_IPV6_MULTICAST_SUPPORT */
I1076 1
		{
D1078 4
I1081 1
			netsyslog(LOG_INFO,"io_setbclient: Opened broadcast client on interface %d, socket: %d",
D1083 3
D1087 1
I1107 1
#ifdef OPEN_BCAST_SOCKET
I1116 1
#endif
D1137 1
I1137 2
	ind = find_flagged_addr_in_list(&addr, INT_MCASTOPEN);
	if (ind >= 0)
D1188 1
I1188 1
#ifdef INCLUDE_IPV6_MULTICAST_SUPPORT
D1199 3
I1201 1
		if (i >= 0)
I1251 3
	/*
	 * For the case where we can't use a separate socket
	 */
D1267 9
I1275 4
	if (jstatus == ISC_TRUE)
		netsyslog(LOG_INFO, "Added Multicast Listener %s on interface %d\n", stoa(&addr), ind);
	else
		netsyslog(LOG_ERR, "Failed to add Multicast Listener %s\n", stoa(&addr));
I1280 1
	return;
D1293 1
D1296 3
I1298 9
	/*
	 * Check to see if this is a multicast address
	 */
	if (addr_ismulticast(&addr) == ISC_FALSE)
	{
		netsyslog(LOG_ERR,
			 "invalid multicast address %s", stoa(&addr));
		return;
	}
D1304 9
D1323 1
I1323 1
#ifdef INCLUDE_IPV6_MULTICAST_SUPPORT
D1325 8
D1351 1
I1351 1
#endif /* INCLUDE_IPV6_MULTICAST_SUPPORT */
D1475 1
I1475 1
#ifdef INCLUDE_IPV6_SUPPORT
D1483 1
I1483 2
		else 
			return (INVALID_SOCKET);
D1493 16
I1508 1
		return (INVALID_SOCKET);
I1637 3
	if (fd < 0)
		return;
\
I1670 3
	if (fd < 0)
		return;
\
D1721 1
I1721 1
#ifdef INCLUDE_IPV6_SUPPORT
D1726 1
I1726 1
#endif /* INCLUDE_IPV6_SUPPORT */
D1733 1
I1733 1
#ifdef INCLUDE_IPV6_SUPPORT
D1735 1
I1735 1
#endif /* INCLUDE_IPV6_SUPPORT */
D1738 1
I1738 1
#ifdef INCLUDE_IPV6_SUPPORT
D1740 1
I1740 1
#endif /* INCLUDE_IPV6_SUPPORT */
D1775 1
I1775 1
#ifdef INCLUDE_IPV6_SUPPORT
D1796 1
I1796 1
#endif /* INCLUDE_IPV6_SUPPORT */
D1812 1
I1812 1
#ifdef INCLUDE_IPV6_SUPPORT
D1818 1
I1818 1
#endif /* INCLUDE_IPV6_SUPPORT */
D1859 1
I1859 1
#ifdef INCLUDE_IPV6_SUPPORT
D1870 1
I1870 1
#endif /* INCLUDE_IPV6_SUPPORT */
D1894 1
I1894 1
#ifdef INCLUDE_IPV6_SUPPORT
D1898 1
I1898 1
#endif /* INCLUDE_IPV6_SUPPORT */
I1998 7
\
		/*
		 * If there are no packets waiting just return
		 */
		if (n <= 0)
			return;
\
D2283 1
D2345 1
I2345 1
#ifdef INCLUDE_IPV6_SUPPORT
D2415 1
I2415 1
#ifdef INCLUDE_IPV6_MULTICAST_SUPPORT
D2441 1
I2441 1
		if(inter_list[i].sin.ss_family != addr->ss_family)
D2449 2
I2450 2
#ifdef INCLUDE_IPV6_MULTICAST_SUPPORT
		if (flags == INT_MULTICAST && inter_list[i].sin.ss_family == AF_INET6 &&
D2484 2
I2485 1
	int i = -1;
D2492 14
D2523 1
I2532 22
\
		/* Skip the loopback addresses */
		if (inter_list[i].flags & INT_LOOPBACK)
			continue;
\
		/* for IPv6 multicast check the address for linklocal */
#ifdef INCLUDE_IPV6_SUPPORT
		if (inter_list[i].sin.ss_family == AF_INET6 &&
		   (IN6_IS_ADDR_LINKLOCAL(&((struct sockaddr_in6*)&inter_list[i].sin)->sin6_addr)))
		{
			continue;
		}
#endif
		/*
		 * If we are looking to match a multicast address grab it.
		 * We must not do this before we have eliminated any linklocal
		 * addresses
		 */
		if (addr_ismulticast(addr) == ISC_TRUE && inter_list[i].flags & INT_MULTICAST)
		{
			return (&inter_list[i]);
		}
D2539 2
I2548 1
#ifdef INCLUDE_IPV6_SUPPORT
D2554 1
I2554 2
		}
#endif

mayer at pogo.udel.edu|ntpd/ntp_io.c|20050716212939|27998
D 1.183 05/07/24 16:41:20-04:00 mayer at pogo.udel.edu +5 -5
B stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
C
c Fix isaddr_multicast to not be dependent on whether or not MCAST is supported
K 28313
O -rw-rw-r--
P ntpd/ntp_io.c
------------------------------------------------

D830 4
I883 4
 * NOTE: Not all platforms support multicast
 */
#ifdef MCAST
/*
D2500 1
I2500 1
		/* Don't bother with ignored interfaces */

mayer at pogo.udel.edu|ntpd/ntp_io.c|20050724204120|28313
D 1.184 05/07/25 12:45:27-04:00 mayer at pogo.udel.edu +1 -1
B stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
C
c Always provide the addr_ismulticast function
K 28313
O -rw-rw-r--
P ntpd/ntp_io.c
------------------------------------------------

I163 1
static	isc_boolean_t	addr_ismulticast	 P((struct sockaddr_storage *));
D168 1

== ntpd/ntp_peer.c ==
stenn at whimsy.udel.edu|ntpd/ntp_peer.c|19990526004817|01635|3aed0663
stenn at whimsy.udel.edu|ntpd/ntp_peer.c|20050418050104|14866
D 1.76 05/07/16 17:30:35-04:00 mayer at pogo.udel.edu +5 -0
B stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
C
c Add debug code to print the broadcast interface used
K 26884
O -rw-rw-r--
P ntpd/ntp_peer.c
------------------------------------------------

I577 5
#ifdef DEBUG
		if (debug > 1)
			printf("Found broadcast interface address %s, for address %s\n",
				stoa(&(peer->dstadr)->sin), stoa(srcadr));
#endif

== ports/winnt/include/ntp_iocompletionport.h ==
stenn at whimsy.udel.edu|ports/winnt/include/ntp_iocompletionport.h|19990728020335|01289|29080509
mayer at tecotoo.|ports/winnt/include/ntp_iocompletionport.h|20041107022849|25083
D 1.9 05/07/24 15:48:34-04:00 mayer at pogo.udel.edu +16 -3
B stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
C
c Revamp of I/O Completion ports for Windows
K 37480
O -rw-rw-r--
P ports/winnt/include/ntp_iocompletionport.h
------------------------------------------------

I10 10
/*
 * Request types
 */
enum {
	SOCK_RECV,
	SOCK_SEND,
	CLOCK_READ,
	CLOCK_WRITE
};
\
I14 2
	int				request_type;
	LPVOID				buff;
D29 2
D34 1
I34 4
\
static int OnSocketRecv(DWORD, IoCompletionInfo *, DWORD);
static int OnIoReadComplete(DWORD, IoCompletionInfo *, DWORD);
static int OnWriteComplete(DWORD, IoCompletionInfo *, DWORD);

== ports/winnt/include/transmitbuff.h ==
stenn at whimsy.udel.edu|ports/winnt/include/transmitbuff.h|19990728020335|01289|29080509
stenn at whimsy.udel.edu|ports/winnt/include/transmitbuff.h|20011009011829|07553
D 1.4 05/07/24 15:48:34-04:00 mayer at pogo.udel.edu +4 -14
B stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
C
c Revamp of I/O Completion ports for Windows
K 22410
O -rw-rw-r--
P ports/winnt/include/transmitbuff.h
------------------------------------------------

D9 2
D19 4
I22 2
	WSABUF	wsabuf;
	time_t	ts;		/* Time stamp for the request */
D40 1
I40 1
extern	void	free_transmit_buffer	P((transmitbuf *));
D48 7
I54 1
extern transmitbuf *get_free_transmit_buffer P((void));

== ports/winnt/libntp/transmitbuff.c ==
stenn at whimsy.udel.edu|ports/winnt/libntp/transmitbuff.c|19990728020416|01289|29080509
stenn at whimsy.udel.edu|ports/winnt/libntp/transmitbuff.c|20011009011827|14891
D 1.5 05/07/24 15:48:34-04:00 mayer at pogo.udel.edu +113 -43
B stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
C
c Revamp of I/O Completion ports for Windows
K 5103
O -rw-rw-r--
P ports/winnt/libntp/transmitbuff.c
------------------------------------------------

I10 1
#include <isc/list.h>
I21 7
 * Maximum time in seconds to allow transmit request to complete
 * After that we are free to delete it if we need the buffer
 */
\
#define	MAX_TRANSMIT_SEND_TIME	60.0	
\
/*
D27 3
I29 11
typedef struct transmitb transmitb_t;
\
struct transmitb {
	transmitbuf			*tb;
	ISC_LINK(transmitb_t)		link;
};
\
ISC_LIST(transmitb_t)	fulllist;		/* Currently used transmit buffers */
\
static	transmitbuf *volatile freelist = NULL;  /* free buffers */
static	transmitbuf *volatile beginlist = NULL; /* fifo buffers with data */
D34 1
I34 1
static	transmitbuf initial_bufs[TRANSMIT_INIT]; /* initial allocation */
D37 11
I47 3
static CRITICAL_SECTION TransmitLock;
# define LOCK(lock)	EnterCriticalSection(lock)
# define UNLOCK(lock)	LeaveCriticalSection(lock)
I48 2
static	struct transmitbuf initial_bufs[TRANSMIT_INIT]; /* initial allocation */
static	int eventid = 0;
D51 1
I51 1
initialise_buffer(transmitbuf *buff)
D53 1
I53 1
	memset((char *) buff, 0, sizeof(transmitbuf));
D55 2
D59 1
D70 1
I70 1
	freelist = NULL;
D74 1
I74 1
		initial_bufs[i].next = (transmitbuf *) freelist;
D78 1
I78 1
	ISC_LIST_INIT(fulllist);
D82 3
I84 27
	InitializeCriticalSection(&TransmitLock);
}
\
static void
add_buffer_to_freelist(transmitbuf *tb)
{
	tb->next = freelist;
	freelist = tb;
	free_transmitbufs++;
}
\
static void
delete_buffer_from_full_list(transmitbuf *tb) {
\
	transmitb_t *next;
	transmitb_t *lbuf = ISC_LIST_HEAD(fulllist);
\
	while(lbuf != NULL) {
		next = ISC_LIST_NEXT(lbuf, link);
		if(lbuf->tb == tb) {
			ISC_LIST_DEQUEUE_TYPE(fulllist, lbuf, link, transmitb_t);
			free(lbuf);
			break;
		}
		else
			lbuf = next;
	}
I86 36
/*
 * routine to free up any buffer that has not been freed up
 * after MAX_TRANSMIT_SEND_TIME seconds. Note that we are not being
 * too careful here about the correct value of time since we just need
 * and approximate measure of how much time has elapsed since the
 * packet was sent and this routine is only called if we run out
 * of tranmit buffers.
 */
static int
free_unsent_buffers()
{
	int tot_freed = 0;
	double elapsed_time;
	time_t ct;
	transmitbuf *buf;
	transmitb_t *next;
	transmitb_t *lbuf = ISC_LIST_HEAD(fulllist);
\
	time(&ct);	/* Current Time */
\
	LOCK(&TransmitLock);
	while(lbuf != NULL) {
		next = ISC_LIST_NEXT(lbuf, link);
		elapsed_time = difftime(ct, lbuf->tb->ts);
		if (elapsed_time > MAX_TRANSMIT_SEND_TIME) {
			ISC_LIST_DEQUEUE_TYPE(fulllist, lbuf, link, transmitb_t);
			free(lbuf);
			add_buffer_to_freelist(lbuf->tb);
			tot_freed++;
		}
		else
			lbuf = next;
	}
	UNLOCK(&TransmitLock);
	return (tot_freed);
}
D91 1
I91 1
	transmitbuf *buf;
I92 2
	if (free_unsent_buffers() > 0)
		return;
D94 2
I95 1
	buf = (transmitbuf *) emalloc(TRANSMIT_INC*sizeof(transmitbuf));
D99 1
I99 1
		buf->next = (transmitbuf *) freelist;
D111 9
I119 6
free_transmit_buffer(transmitbuf *rb)
{
	LOCK(&TransmitLock);
	add_buffer_to_freelist(rb);
	delete_buffer_from_full_list(rb);
	UNLOCK(&TransmitLock);
D123 1
I123 1
extern transmitbuf *
D126 2
I127 4
	transmitb_t *lbuf = (transmitb_t *)malloc(sizeof(transmitb_t));
\
	transmitbuf * buffer = NULL;
	LOCK(&TransmitLock);
I133 3
	time(&buffer->ts);	/* Time we gave out the transmit buffer */
	lbuf->tb = buffer;
	ISC_LIST_APPEND(fulllist, lbuf, link);
D135 1
I135 1
	UNLOCK(&TransmitLock);

== ports/winnt/ntpd/nt_clockstuff.c ==
stenn at whimsy.udel.edu|ports/winnt/ntpd/nt_clockstuff.c|19991016040804|07763|8b711e53
mayer at tecotoo.|ports/winnt/ntpd/nt_clockstuff.c|20050417032047|64732
D 1.18 05/07/24 15:48:34-04:00 mayer at pogo.udel.edu +1 -1
B stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
C
c Revamp of I/O Completion ports for Windows
K 1217
O -rw-rw-r--
P ports/winnt/ntpd/nt_clockstuff.c
------------------------------------------------

D433 1
I433 1
	TimerThreadExitRequest = CreateEvent(NULL, FALSE, FALSE, "TimerThreadExitRequest");

== ports/winnt/ntpd/ntp_iocompletionport.c ==
stenn at whimsy.udel.edu|ports/winnt/ntpd/ntp_iocompletionport.c|19990728020426|01289|29080509
mayer at pogo.udel.edu|ports/winnt/ntpd/ntp_iocompletionport.c|20050331040723|58536
D 1.15 05/07/24 15:48:34-04:00 mayer at pogo.udel.edu +182 -61
B stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
C
c Revamp of I/O Completion ports for Windows
K 46171
O -rw-rw-r--
P ports/winnt/ntpd/ntp_iocompletionport.c
------------------------------------------------

I20 6
#define BUFCHECK_SECS	10
static void	TransmitCheckThread(void *NotUsed);
static BOOL	bExit;
static HANDLE	TimerHandle;
static HANDLE hHeapHandle = NULL;
\
D24 1
I24 3
\
#define MAXHANDLES 3
HANDLE WaitHandles[MAXHANDLES] = { NULL, NULL, NULL };
D32 11
D49 2
I50 1
	if (!PostQueuedCompletionStatus(hIoCompletionPort, 0, 0, 0)) {
D56 2
I57 1
static void
D62 2
I63 1
	IoCompletionInfo * lpo = NULL;
D73 5
I77 8
	while (TRUE) {
		GetQueuedCompletionStatus(hIoCompletionPort, 
					  &BytesTransferred, 
					  &Key, 
					  & (LPOVERLAPPED) lpo, 
					  INFINITE);
		if (lpo == NULL)
		{
D81 2
I82 24
			break; /* fail */
		}
\
		/*
		 * Invoke the appropriate function based on
		 * the value of the request_type
		 */
		switch(lpo->request_type)
		{
		case CLOCK_READ:
			OnIoReadComplete(Key, lpo, BytesTransferred);
			break;
		case SOCK_RECV:
			OnSocketRecv(Key, lpo, BytesTransferred);
			break;
		case SOCK_SEND:
		case CLOCK_WRITE:
			OnWriteComplete(Key, lpo, BytesTransferred);
			break;
		default:
#if DEBUG
			if (debug > 3) {
				printf("Unknown request type %d found in completion port\n",
					lpo->request_type);
I83 1
#endif
I95 12
	/*
	 * Create a handle to the Heap
	 */
	hHeapHandle = HeapCreate(0, 20*sizeof(IoCompletionInfo), 0);
\
	/* Set the exit flag */
	bExit = FALSE;
	/*
	 * Initialize the timer watch section
	 */
//	_beginthread(TransmitCheckThread, 0, NULL);
\
D98 1
I98 1
	WaitableIoEventHandle = CreateEvent(NULL, FALSE, FALSE, "WaitableIoEventHandle");
D115 1
I115 1
	WaitHandles[0] = CreateEvent(NULL, FALSE, FALSE, "WaitHandles0"); /* exit request */
I130 6
	/*
	 * Tell the timer handle to exit
	 */
	bExit = TRUE;
	SetEvent(TimerHandle);
\
I141 1
	IoCompletionInfo *lpo;
I142 3
	lpo = (IoCompletionInfo *) HeapAlloc(hHeapHandle,
					     HEAP_ZERO_MEMORY,
					     sizeof(IoCompletionInfo));
I147 3
	lpo->request_type = CLOCK_READ;
	lpo->buff = buff;
\
D149 2
I150 1
	if (!ReadFile((HANDLE) buff->fd, &buff->recv_buffer, sizeof(buff->recv_buffer), NULL, (LPOVERLAPPED) lpo)) {
I160 3
					/* Clear the heap */
					if (lpo != NULL)
						HeapFree(hHeapHandle, 0, lpo);
D171 1
I171 1
OnIoReadComplete(DWORD i, IoCompletionInfo *lpo, DWORD Bytes)
D178 2
I179 1
	buff = (struct recvbuf *) lpo->buff;
I198 4
	/* Clear the heap */
	if (lpo != NULL)
		HeapFree(hHeapHandle, 0, lpo);
\
I223 6
	IoCompletionInfo *lpo;
	int AddrLen;
\
	lpo = (IoCompletionInfo *) HeapAlloc(hHeapHandle,
					     HEAP_ZERO_MEMORY,
					     sizeof(IoCompletionInfo));
I225 3
	lpo->request_type = SOCK_RECV;
	lpo->buff = buff;
\
D229 1
D231 1
I231 1
		AddrLen = sizeof(struct sockaddr_in);
D235 2
I236 2
						(struct sockaddr *) &buff->recv_srcadr, (LPINT) &AddrLen, 
						(LPOVERLAPPED) lpo, NULL)) {
I247 3
					/* Clear the heap */
					if (lpo != NULL)
						HeapFree(hHeapHandle, 0, lpo);
I252 3
					/* Clear the heap */
					if (lpo != NULL)
						HeapFree(hHeapHandle, 0, lpo);
D270 1
I270 1
OnSocketRecv(DWORD i, IoCompletionInfo *lpo, DWORD Bytes)
D278 1
I278 1
	buff = (struct recvbuf *) lpo->buff;
D286 6
I291 2
		if (debug > 3)
  			printf("Received %d bytes from %s\n", stoa(&buff->recv_srcadr));
I304 4
	/* Clear the heap */
	if (lpo != NULL)
		HeapFree(hHeapHandle, 0, lpo);
\
D330 1
I330 1
OnSendToComplete(DWORD Key, IoCompletionInfo *lpo, DWORD Bytes)
D336 1
I336 1
	buff = (struct transmitbuf *) lpo->buff;
I338 3
	/* Clear the heap */
	if (lpo != NULL)
		HeapFree(hHeapHandle, 0, lpo);
D344 1
I344 1
OnWriteComplete(DWORD Key, IoCompletionInfo *lpo, DWORD Bytes)
D350 1
I350 1
	buff = (struct transmitbuf *) lpo->buff;
I352 3
	/* Clear the heap */
	if (lpo != NULL)
		HeapFree(hHeapHandle, 0, lpo);
I366 6
	int AddrLen;
	IoCompletionInfo *lpo;
\
	lpo = (IoCompletionInfo *) HeapAlloc(hHeapHandle,
					     HEAP_ZERO_MEMORY,
					     sizeof(IoCompletionInfo));
D378 2
I379 5
			AddrLen = sizeof(struct sockaddr_in);
			lpo->request_type = SOCK_SEND;
			lpo->buff = buff;
\
			Result = WSASendTo(inter->fd, &buff->wsabuf, 1, &BytesSent, Flags, (struct sockaddr *) dest, AddrLen, (LPOVERLAPPED) lpo, NULL);
I394 1
					free_transmit_buffer(buff);
D399 6
I404 2
			if (debug > 3)
				printf("WSASendTo - %d bytes to %s : %d\n", len, stoa(dest), Result);
I433 1
	DWORD errval;
I436 5
	IoCompletionInfo *lpo;
\
	lpo = (IoCompletionInfo *) HeapAlloc(hHeapHandle,
					     HEAP_ZERO_MEMORY,
					     sizeof(IoCompletionInfo));
I441 2
			lpo->request_type = CLOCK_WRITE;
			lpo->buff = buff;
D443 1
D445 1
I445 6
			Result = WriteFile(fd, buff->pkt, len, &lpNumberOfBytesWritten, (LPOVERLAPPED) lpo);
\
			if(Result == SOCKET_ERROR)
			{
				errval = WSAGetLastError();
				switch (errval) {
I446 13
				case NO_ERROR :
				case WSA_IO_INCOMPLETE :
				case WSA_WAIT_IO_COMPLETION :
				case WSA_IO_PENDING :
					Result = ERROR_SUCCESS;
					break ;
\
				default :
					netsyslog(LOG_ERR, "WriteFile - error sending message: %m");
					free_transmit_buffer(buff);
					break;
				}
			}
D449 1
I449 1
				printf("WriteFile - %d bytes %d\n", len, Result);
I469 5
/*
 * GetReceivedBuffers
 * Note that this is in effect the main loop for processing requests
 * both send and receive. This should be reimplemented
 */
D472 2
I473 1
	DWORD Index = WaitForMultipleObjectsEx(MAXHANDLES, WaitHandles, FALSE, INFINITE, TRUE);
I503 1
\
I504 15
}
static void
TransmitCheckThread(void *NotUsed)
{
\
	int SleepSecs = BUFCHECK_SECS;
	while (TRUE) 
	{
		Sleep(SleepSecs*1000);
\
		/* If we are done we exit */
		if (bExit)
			return;
				
	} /* while */

# Patch checksum=30050c58


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