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

Harlan Stenn stenn at whimsy.udel.edu
Fri Dec 19 22:04:48 PST 2003


This BitKeeper patch contains the following changesets:
stenn at whimsy.udel.edu|ChangeSet|20031220060329|16051

# 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:	/backroom/ntp-stable

#
#--- 1.43/ntpdate/ntpdate.c	Wed May 21 22:42:55 2003
#+++ 1.45/ntpdate/ntpdate.c	Sat Dec 20 01:02:39 2003
#@@ -71,8 +71,8 @@
# 
# #ifdef SYS_WINNT
# #define EPROTONOSUPPORT WSAEPROTONOSUPPORT
#-#define EAFNOSUPPORT    WSAEAFNOSUPPORT
#-#define EPFNOSUPPORT    WSAEPFNOSUPPORT
#+#define EAFNOSUPPORT	WSAEAFNOSUPPORT
#+#define EPFNOSUPPORT	WSAEPFNOSUPPORT
# #define TARGET_RESOLUTION 1  /* Try for 1-millisecond accuracy
# 				on Windows NT timers. */
# #pragma comment(lib, "winmm")
#@@ -324,7 +324,7 @@
# 	l_fp tmp;
# 	int errflg;
# 	int c;
#-        int nfound;
#+	int nfound;
# 
# #ifdef HAVE_NETINFO
# 	ni_namelist *netinfoservers;
#@@ -573,11 +573,11 @@
# 
# 	while (complete_servers < sys_numservers) {
# #ifdef HAVE_POLL_H
#-                struct pollfd* rdfdes;
#-                rdfdes = fdmask;
#+		struct pollfd* rdfdes;
#+		rdfdes = fdmask;
# #else
# 		fd_set rdfdes;
#-                rdfdes = fdmask;
#+		rdfdes = fdmask;
# #endif
# 
# 		if (alarm_flag) {		/* alarmed? */
#@@ -591,10 +591,10 @@
# 			 * Nothing to do.	 Wait for something.
# 			 */
# #ifdef HAVE_POLL_H
#-                        nfound = poll(rdfdes, (unsigned int)nbsock, timeout.tv_sec * 1000);
#+			nfound = poll(rdfdes, (unsigned int)nbsock, timeout.tv_sec * 1000);
# 
# #else
#-                        nfound = select(maxfd, &rdfdes, (fd_set *)0,
#+			nfound = select(maxfd, &rdfdes, (fd_set *)0,
# 					(fd_set *)0, &timeout);
# #endif
# 			if (nfound > 0)
#@@ -676,8 +676,8 @@
# 
# /*
#  * transmit - transmit a packet to the given server, or mark it completed.
#- *		  This is called by the timeout routine and by the receive
#- *		  procedure.
#+ *		This is called by the timeout routine and by the receive
#+ *		procedure.
#  */
# static void
# transmit(
#@@ -710,7 +710,7 @@
# 	}
# 
# 	/*
#-	 * If we're here, send another message to the server.    Fill in
#+	 * If we're here, send another message to the server.  Fill in
# 	 * the packet and let 'er rip.
# 	 */
# 	xpkt.li_vn_mode = PKT_LI_VN_MODE(LEAP_NOTINSYNC,
#@@ -779,7 +779,7 @@
# 	int is_authentic;
# 
# 	if (debug)
#-                printf("receive(%s)\n", stoa(&rbufp->recv_srcadr));
#+		printf("receive(%s)\n", stoa(&rbufp->recv_srcadr));
# 	/*
# 	 * Check to see if the packet basically looks like something
# 	 * intended for us.
#@@ -1060,29 +1060,29 @@
# 		if (server->delay == 0) {
# 			if (debug)
# 				printf("%s: Server dropped: no data\n", ntoa(&server->srcadr));
#-			continue;   /* no data */
#+			continue;	/* no data */
# 		}
# 		if (server->stratum > NTP_INFIN) {
# 			if (debug)
# 				printf("%s: Server dropped: strata too high\n", ntoa(&server->srcadr));
#-			continue;   /* stratum no good */
#+			continue;	/* stratum no good */
# 		}
# 		if (server->delay > NTP_MAXWGT) {
# 			if (debug)
# 				printf("%s: Server dropped: server too far away\n", 
#-				       ntoa(&server->srcadr));
#-			continue;   /* too far away */
#+					ntoa(&server->srcadr));
#+			continue;	/* too far away */
# 		}
# 		if (server->leap == LEAP_NOTINSYNC) {
# 			if (debug)
# 				printf("%s: Server dropped: Leap not in sync\n", ntoa(&server->srcadr));
#-			continue;   /* he's in trouble */
#+			continue;	/* he's in trouble */
# 		}
# 		if (!L_ISHIS(&server->org, &server->reftime)) {
# 			if (debug)
# 				printf("%s: Server dropped: server is very broken\n", 
# 				       ntoa(&server->srcadr));
#-			continue;   /* very broken host */
#+			continue;	/* very broken host */
# 		}
# 		if ((server->org.l_ui - server->reftime.l_ui)
# 		    >= NTP_MAXAGE) {
#@@ -1239,7 +1239,7 @@
# 	}
# 
# 	/*
#-	 * That's it.    Return our server.
#+	 * That's it.  Return our server.
# 	 */
# 	return sys_server;
# }
#@@ -1316,7 +1316,7 @@
# /* XXX ELIMINATE: merge BIG slew into adj_systime in lib/systime.c */
# /*
#  * addserver - determine a server's address and allocate a new structure
#- *		   for it.
#+ *		for it.
#  */
# static void
# addserver(
#@@ -1324,39 +1324,44 @@
# 	)
# {
# 	register struct server *server;
#-        /* Address infos structure to store result of getaddrinfo */
#-        struct addrinfo *addrResult;
#-        /* Address infos structure to store hints for getaddrinfo */
#-        struct addrinfo hints;
#-        /* Error variable for getaddrinfo */
#-        int error;
#-        /* Service name */
#-        char service[5];
#+	/* Address infos structure to store result of getaddrinfo */
#+	struct addrinfo *addrResult;
#+	/* Address infos structure to store hints for getaddrinfo */
#+	struct addrinfo hints;
#+	/* Error variable for getaddrinfo */
#+	int error;
#+	/* Service name */
#+	char service[5];
# 	strcpy(service, "ntp");
# 
#-        /* Get host address. Looking for UDP datagram connection. */
#-        memset(&hints, 0, sizeof(hints));
#-        hints.ai_family = ai_fam_templ;
#-        hints.ai_socktype = SOCK_DGRAM;
#-
#-        printf("Looking for host %s and service %s\n", serv, service);
#-
#-        error = getaddrinfo(serv, service, &hints, &addrResult);
#-        if (error != 0) {
#-                fprintf(stderr, "Error : %s\n", gai_strerror(error));
#+	/* Get host address. Looking for UDP datagram connection. */
#+	memset(&hints, 0, sizeof(hints));
#+	hints.ai_family = ai_fam_templ;
#+	hints.ai_socktype = SOCK_DGRAM;
#+
#+#ifdef DEBUG
#+	if (debug)
#+		printf("Looking for host %s and service %s\n", serv, service);
#+#endif
#+
#+	error = getaddrinfo(serv, service, &hints, &addrResult);
#+	if (error != 0) {
#+		fprintf(stderr, "Error : %s\n", gai_strerror(error));
# 		msyslog(LOG_ERR, "can't find host %s\n", serv);
# 		return;
# 	}
#-        else {
#-                fprintf(stderr, "host found : %s\n", stohost((struct sockaddr_storage*)addrResult->ai_addr));
#-        }
#+#ifdef DEBUG
#+	else if (debug) {
#+		fprintf(stderr, "host found : %s\n", stohost((struct sockaddr_storage*)addrResult->ai_addr));
#+	}
#+#endif
# 
# 	server = (struct server *)emalloc(sizeof(struct server));
# 	memset((char *)server, 0, sizeof(struct server));
# 
#-        /* For now we only get the first returned server of the addrinfo list */
#-        memset(&(server->srcadr), 0, sizeof(struct sockaddr_storage));
#-        memcpy(&(server->srcadr), addrResult->ai_addr, addrResult->ai_addrlen);
#+	/* For now we only get the first returned server of the addrinfo list */
#+	memset(&(server->srcadr), 0, sizeof(struct sockaddr_storage));
#+	memcpy(&(server->srcadr), addrResult->ai_addr, addrResult->ai_addrlen);
# 	server->event_time = ++sys_numservers;
# 	if (sys_servers == NULL)
# 		sys_servers = server;
#@@ -1389,21 +1394,21 @@
# 	for (server = sys_servers; server != NULL; 
# 	     server = server->next_server) {
# 		
#-                if (memcmp(addr, &server->srcadr, SOCKLEN(addr))==0)
#+		if (memcmp(addr, &server->srcadr, SOCKLEN(addr))==0)
# 			return server;
#-                /* Multicast compatibility to verify here... I'm not sure it's working */
#-                if(addr->ss_family == AF_INET) {
#-                        if (IN_MULTICAST(ntohl(((struct sockaddr_in*)addr)->sin_addr.s_addr)))
#-                                mc_server = server;
#-                }
#-                else {
#+		/* Multicast compatibility to verify here... I'm not sure it's working */
#+		if(addr->ss_family == AF_INET) {
#+			if (IN_MULTICAST(ntohl(((struct sockaddr_in*)addr)->sin_addr.s_addr)))
#+				mc_server = server;
#+		}
#+		else {
# #ifdef AF_INET6
#-                        if (IN6_IS_ADDR_MULTICAST(&((struct sockaddr_in6*)(&server->srcadr))->sin6_addr))
#+			if (IN6_IS_ADDR_MULTICAST(&((struct sockaddr_in6*)(&server->srcadr))->sin6_addr))
# 			mc_server = server;
# #else
#-                        return 0;
#+			return 0;
# #endif
#-                }
#+		}
# 	}
# 
# 	if (mc_server != NULL) {	
#@@ -1418,7 +1423,7 @@
# 		server = (struct server *)emalloc(sizeof(struct server));
# 		memset((char *)server, 0, sizeof(struct server));
# 
#-                memcpy(&server->srcadr, &addr, sizeof(struct sockaddr_storage));
#+		memcpy(&server->srcadr, &addr, sizeof(struct sockaddr_storage));
# 
# 		server->event_time = ++sys_numservers;
# 
#@@ -1559,7 +1564,7 @@
# 	}
# 	/* get the LUID for system-time privilege. */
# 	LookupPrivilegeValue(NULL, SE_SYSTEMTIME_NAME, &tkp.Privileges[0].Luid);
#-	tkp.PrivilegeCount = 1;  /* one privilege to set */
#+	tkp.PrivilegeCount = 1;		/* one privilege to set */
# 	tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
# 	/* get set-time privilege for this process. */
# 	AdjustTokenPrivileges(hToken, FALSE, &tkp, 0,(PTOKEN_PRIVILEGES) NULL, 0);
#@@ -1581,7 +1586,7 @@
# 	}
# 	/* get the LUID for system-time privilege. */
# 	LookupPrivilegeValue(NULL, SE_SYSTEMTIME_NAME, &tkp.Privileges[0].Luid);
#-	tkp.PrivilegeCount = 1;  /* one privilege to set */
#+	tkp.PrivilegeCount = 1;		/* one privilege to set */
# 	tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
# 	/* get set-time privilege for this process. */
# 	AdjustTokenPrivileges(hToken, FALSE, &tkp, 0,(PTOKEN_PRIVILEGES) NULL, 0);
#@@ -1607,11 +1612,11 @@
# 
# 	/* start the timer event */
# 	wTimerID = timeSetEvent(
#-		(UINT) (1000/TIMER_HZ),    /* Delay */
#-		wTimerRes,			 /* Resolution */
#-		(LPTIMECALLBACK) alarming, /* Callback function */
#-		(DWORD) dwUser, 	 /* User data */
#-		TIME_PERIODIC); 	 /* Event type (periodic) */
#+		(UINT) (1000/TIMER_HZ),		/* Delay */
#+		wTimerRes,			/* Resolution */
#+		(LPTIMECALLBACK) alarming,	/* Callback function */
#+		(DWORD) dwUser,			/* User data */
#+		TIME_PERIODIC);			/* Event type (periodic) */
# 	if (wTimerID == 0) {
# 		msyslog(LOG_ERR, "timeSetEvent failed: %m");
# 		exit(1);
#@@ -1642,10 +1647,10 @@
# static void
# init_io(void)
# {
#-        struct addrinfo *res, *ressave;
#-        struct addrinfo hints;
#+	struct addrinfo *res, *ressave;
#+	struct addrinfo hints;
# 	char service[5];
#-        int optval = 1;
#+	int optval = 1;
# 
# 	/*
# 	 * Init buffer free list and stat counters
#@@ -1658,53 +1663,53 @@
# 
# 	strcpy(service, "ntp");
# 
#-        /*
#-         * Init hints addrinfo structure
#-         */
#-        memset(&hints, 0, sizeof(hints));
#-        hints.ai_flags = AI_PASSIVE;
#-        hints.ai_socktype = SOCK_DGRAM;
#-
#-        if(getaddrinfo(NULL, service, &hints, &res) != 0) {
#-               msyslog(LOG_ERR, "getaddrinfo() failed: %m");
#-               exit(1);
#-               /*NOTREACHED*/
#-        }
#-
#-        /* Remember the address of the addrinfo structure chain */
#-        ressave = res;
#-
#-        /*
#-         * For each structure returned, open and bind socket
#-         */
#-        for(nbsock = 0; (nbsock < MAX_AF) && res ; res = res->ai_next) {
#+	/*
#+	 * Init hints addrinfo structure
#+	 */
#+	memset(&hints, 0, sizeof(hints));
#+	hints.ai_flags = AI_PASSIVE;
#+	hints.ai_socktype = SOCK_DGRAM;
#+
#+	if(getaddrinfo(NULL, service, &hints, &res) != 0) {
#+	       msyslog(LOG_ERR, "getaddrinfo() failed: %m");
#+	       exit(1);
#+	       /*NOTREACHED*/
#+	}
#+
#+	/* Remember the address of the addrinfo structure chain */
#+	ressave = res;
#+
#+	/*
#+	 * For each structure returned, open and bind socket
#+	 */
#+	for(nbsock = 0; (nbsock < MAX_AF) && res ; res = res->ai_next) {
# 	/* create a datagram (UDP) socket */
#-           if ((fd[nbsock] = socket(res->ai_family, res->ai_socktype, res->ai_protocol)) < 0) {
#+	   if ((fd[nbsock] = socket(res->ai_family, res->ai_socktype, res->ai_protocol)) < 0) {
# 		if (errno == EPROTONOSUPPORT || errno == EAFNOSUPPORT ||
# 		    errno == EPFNOSUPPORT)
# 			continue;
# 		netsyslog(LOG_ERR, "socket() failed: %m");
# 		exit(1);
# 		/*NOTREACHED*/
#-	}
#-           /* set socket to reuse address */
#-           if (setsockopt(fd[nbsock], SOL_SOCKET, SO_REUSEADDR, (void*) &optval, sizeof(optval)) < 0) {
#-   		   netsyslog(LOG_ERR, "setsockopt() SO_REUSEADDR failed: %m");
#-   		   exit(1);
#+	   }
#+	   /* set socket to reuse address */
#+	   if (setsockopt(fd[nbsock], SOL_SOCKET, SO_REUSEADDR, (void*) &optval, sizeof(optval)) < 0) {
#+		   netsyslog(LOG_ERR, "setsockopt() SO_REUSEADDR failed: %m");
#+		   exit(1);
# 		   /*NOTREACHED*/
#-    	   }
#+	   }
# #ifdef IPV6_V6ONLY
#-           /* Restricts AF_INET6 socket to IPv6 communications (see RFC 2553bis-03) */
#-           if (res->ai_family == AF_INET6)
#-                if (setsockopt(fd[nbsock], IPPROTO_IPV6, IPV6_V6ONLY, (void*) &optval, sizeof(optval)) < 0) {
#-   		           netsyslog(LOG_ERR, "setsockopt() IPV6_V6ONLY failed: %m");
#-   		           exit(1);
#-		           /*NOTREACHED*/
#-    	        }
#+	   /* Restricts AF_INET6 socket to IPv6 communications (see RFC 2553bis-03) */
#+	   if (res->ai_family == AF_INET6)
#+		if (setsockopt(fd[nbsock], IPPROTO_IPV6, IPV6_V6ONLY, (void*) &optval, sizeof(optval)) < 0) {
#+			   netsyslog(LOG_ERR, "setsockopt() IPV6_V6ONLY failed: %m");
#+			   exit(1);
#+			   /*NOTREACHED*/
#+		}
# #endif
# 
#-           /* Remember the socket family in fd_family structure */
#-           fd_family[nbsock] = res->ai_family;
#+	   /* Remember the socket family in fd_family structure */
#+	   fd_family[nbsock] = res->ai_family;
# 
# 	/*
# 	 * bind the socket to the NTP port
#@@ -1729,9 +1734,9 @@
# 	    fdmask[nbsock].events = POLLIN;
# #else
# 	    FD_SET(fd[nbsock], &fdmask);
#-            if ((SOCKET) maxfd < fd[nbsock]+1) {
#-                maxfd = fd[nbsock]+1;
#-            }
#+	    if ((SOCKET) maxfd < fd[nbsock]+1) {
#+		maxfd = fd[nbsock]+1;
#+	    }
# #endif
# 
# 	/*
#@@ -1742,7 +1747,7 @@
#   {
# 	int on = TRUE;
# 
#-	   if (ioctl(fd[nbsock],FIONBIO, &on) == ERROR) {
#+	if (ioctl(fd[nbsock],FIONBIO, &on) == ERROR) {
# 	  netsyslog(LOG_ERR, "ioctl(FIONBIO) fails: %m");
# 	  exit(1);
# 	}
#@@ -1772,7 +1777,7 @@
# 		exit(1);
# 	}
# #endif /* SYS_WINNT */
#-   	nbsock++;
#+	nbsock++;
#     }
#     freeaddrinfo(ressave);
# }
#@@ -1787,27 +1792,27 @@
# 	int len
# 	)
# {
#-        int i;
#+	int i;
# 	int cc;
#-        SOCKET sock = 0;
#+	SOCKET sock = 0;
# 
# #ifdef SYS_WINNT
# 	DWORD err;
# #endif /* SYS_WINNT */
# 
#-        /* Find a local family compatible socket to send ntp packet to ntp server */
#-        for(i = 0; (i < MAX_AF); i++) {
#-                if(dest->ss_family == fd_family[i]) {
#-                        sock = fd[i];
#-                break;
#-                }
#-        }
#-
#-        if ( sock == 0 ) {
#-                netsyslog(LOG_ERR, "cannot find family compatible socket to send ntp packet");
#-                exit(1);
#-                /*NOTREACHED*/
#-        }
#+	/* Find a local family compatible socket to send ntp packet to ntp server */
#+	for(i = 0; (i < MAX_AF); i++) {
#+		if(dest->ss_family == fd_family[i]) {
#+			sock = fd[i];
#+		break;
#+		}
#+	}
#+
#+	if ( sock == 0 ) {
#+		netsyslog(LOG_ERR, "cannot find family compatible socket to send ntp packet");
#+		exit(1);
#+		/*NOTREACHED*/
#+	}
# 
# 	cc = sendto(sock, (char *)pkt, len, 0, (struct sockaddr *)dest,
# 			SOCKLEN(dest));
#@@ -1820,7 +1825,7 @@
# 		err = WSAGetLastError();
# 		if (err != WSAEWOULDBLOCK && err != WSAENOBUFS)
# #endif /* SYS_WINNT */
#-                        netsyslog(LOG_ERR, "sendto(%s): %m", stohost(dest));
#+			netsyslog(LOG_ERR, "sendto(%s): %m", stohost(dest));
# 	}
# }
# 
#@@ -1836,13 +1841,13 @@
# 	struct timeval tvzero;
# 	int fromlen;
# 	l_fp ts;
#-        int i;
#+	int i;
# #ifdef HAVE_POLL_H
# 	struct pollfd fds[MAX_AF];
# #else
# 	fd_set fds;
# #endif
#-        int fdc = 0;
#+	int fdc = 0;
# 
# 	/*
# 	 * Do a poll to see if we have data
#@@ -1851,33 +1856,33 @@
# 		tvzero.tv_sec = tvzero.tv_usec = 0;
# #ifdef HAVE_POLL_H
# 		memcpy(fds, fdmask, sizeof(fdmask));
#-                n = poll(fds, (unsigned int)nbsock, tvzero.tv_sec * 1000);
#+		n = poll(fds, (unsigned int)nbsock, tvzero.tv_sec * 1000);
# 
#-                /*
#-                 * Determine which socket received data
#-                 */
#-
#-                 for(i=0; i < nbsock; i++) {
#-                        if(fds[i].revents & POLLIN) {
#-                                fdc = fd[i];
#-                                break;
#-                        }
#-                 }
#+		/*
#+		 * Determine which socket received data
#+		 */
#+
#+		for(i=0; i < nbsock; i++) {
#+			if(fds[i].revents & POLLIN) {
#+				fdc = fd[i];
#+				break;
#+			}
#+		}
# 
# #else
# 		fds = fdmask;
#-                n = select(maxfd, &fds, (fd_set *)0, (fd_set *)0, &tvzero);
#+		n = select(maxfd, &fds, (fd_set *)0, (fd_set *)0, &tvzero);
# 
#-                /*
#-                 * Determine which socket received data
#-                 */
#-
#-                for(i=0; i < maxfd; i++) {
#-                        if(FD_ISSET(fd[i], &fds)) {
#-                                 fdc = fd[i];
#-                                 break;
#-                        }
#-                }
#+		/*
#+		 * Determine which socket received data
#+		 */
#+
#+		for(i=0; i < maxfd; i++) {
#+			if(FD_ISSET(fd[i], &fds)) {
#+				 fdc = fd[i];
#+				 break;
#+			}
#+		}
# 
# #endif
# 
#@@ -2052,7 +2057,7 @@
# 	l_adj_systime(ts);
# 	return 1;
# #endif
#-#else /* SLEWALWAYS  */
#+#else /* SLEWALWAYS */
# 	if (debug)
# 		return 1;
# 	LFPTOD(ts, dtemp);
#

# Diff checksum=c3a99c3a


# Patch vers:	1.3
# Patch type:	REGULAR

== ChangeSet ==
stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
stenn at whimsy.udel.edu|ChangeSet|20031130012238|16250
D 1.1181 03/12/20 01:03:29-05:00 stenn at whimsy.udel.edu +1 -0
B stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
C
c [Bug 263] (NetBSD PR bin/23707)
K 16051
P ChangeSet
------------------------------------------------

0a0
> stenn at whimsy.udel.edu|ntpdate/ntpdate.c|19990526004819|01635|3aed0663 stenn at whimsy.udel.edu|ntpdate/ntpdate.c|20031220060239|12768

== ntpdate/ntpdate.c ==
stenn at whimsy.udel.edu|ntpdate/ntpdate.c|19990526004819|01635|3aed0663
mayer at tecotoo.myibg.com|ntpdate/ntpdate.c|20030522024255|55387
D 1.44 03/12/20 00:49:05-05:00 stenn at whimsy.udel.edu +69 -68
B stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
c [Bug 263] Mattias Karlsson: ntpdate -s is not silent.  From NetBSD PR bin/23707
K 37350
O -rw-rw-r--
P ntpdate/ntpdate.c
------------------------------------------------

D74 2
I75 2
#define EAFNOSUPPORT	WSAEAFNOSUPPORT
#define EPFNOSUPPORT	WSAEPFNOSUPPORT
D327 1
I327 1
	int nfound;
D576 2
I577 2
		struct pollfd* rdfdes;
		rdfdes = fdmask;
D580 1
I580 1
		rdfdes = fdmask;
D594 1
I594 1
			nfound = poll(rdfdes, (unsigned int)nbsock, timeout.tv_sec * 1000);
D597 1
I597 1
			nfound = select(maxfd, &rdfdes, (fd_set *)0,
D679 2
I680 2
 *		This is called by the timeout routine and by the receive
 *		procedure.
D713 1
I713 1
	 * If we're here, send another message to the server.  Fill in
D782 1
I782 1
		printf("receive(%s)\n", stoa(&rbufp->recv_srcadr));
D1063 1
I1063 1
			continue;	/* no data */
D1068 1
I1068 1
			continue;	/* stratum no good */
D1073 2
I1074 2
					ntoa(&server->srcadr));
			continue;	/* too far away */
D1079 1
I1079 1
			continue;	/* he's in trouble */
D1085 1
I1085 1
			continue;	/* very broken host */
D1242 1
I1242 1
	 * That's it.  Return our server.
D1319 1
I1319 1
 *		for it.
D1327 8
I1334 8
	/* Address infos structure to store result of getaddrinfo */
	struct addrinfo *addrResult;
	/* Address infos structure to store hints for getaddrinfo */
	struct addrinfo hints;
	/* Error variable for getaddrinfo */
	int error;
	/* Service name */
	char service[5];
D1337 10
I1346 11
	/* Get host address. Looking for UDP datagram connection. */
	memset(&hints, 0, sizeof(hints));
	hints.ai_family = ai_fam_templ;
	hints.ai_socktype = SOCK_DGRAM;
\
	if (debug)
		printf("Looking for host %s and service %s\n", serv, service);
\
	error = getaddrinfo(serv, service, &hints, &addrResult);
	if (error != 0) {
		fprintf(stderr, "Error : %s\n", gai_strerror(error));
D1350 3
I1352 3
	else if (debug) {
		fprintf(stderr, "host found : %s\n", stohost((struct sockaddr_storage*)addrResult->ai_addr));
	}
D1357 3
I1359 3
	/* For now we only get the first returned server of the addrinfo list */
	memset(&(server->srcadr), 0, sizeof(struct sockaddr_storage));
	memcpy(&(server->srcadr), addrResult->ai_addr, addrResult->ai_addrlen);
D1392 1
I1392 1
		if (memcmp(addr, &server->srcadr, SOCKLEN(addr))==0)
D1394 6
I1399 6
		/* Multicast compatibility to verify here... I'm not sure it's working */
		if(addr->ss_family == AF_INET) {
			if (IN_MULTICAST(ntohl(((struct sockaddr_in*)addr)->sin_addr.s_addr)))
				mc_server = server;
		}
		else {
D1401 1
I1401 1
			if (IN6_IS_ADDR_MULTICAST(&((struct sockaddr_in6*)(&server->srcadr))->sin6_addr))
D1404 1
I1404 1
			return 0;
D1406 1
I1406 1
		}
D1421 1
I1421 1
		memcpy(&server->srcadr, &addr, sizeof(struct sockaddr_storage));
D1610 5
I1614 5
		(UINT) (1000/TIMER_HZ),		/* Delay */
		wTimerRes,			/* Resolution */
		(LPTIMECALLBACK) alarming,	/* Callback function */
		(DWORD) dwUser,			/* User data */
		TIME_PERIODIC);			/* Event type (periodic) */
D1645 2
I1646 2
	struct addrinfo *res, *ressave;
	struct addrinfo hints;
D1648 1
I1648 1
	int optval = 1;
D1661 5
I1665 5
	/*
	 * Init hints addrinfo structure
	 */
	memset(&hints, 0, sizeof(hints));
	hints.ai_flags = AI_PASSIVE;

stenn at whimsy.udel.edu|ntpdate/ntpdate.c|20031220054905|37350
D 1.45 03/12/20 01:02:39-05:00 stenn at whimsy.udel.edu +82 -78
B stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
C
c Use #ifdef DEBUG where appropriate.
K 12768
O -rw-rw-r--
P ntpdate/ntpdate.c
------------------------------------------------

I1341 1
#ifdef DEBUG
I1343 1
#endif
I1350 1
#ifdef DEBUG
I1353 1
#endif
D1563 1
I1563 1
	tkp.PrivilegeCount = 1;		/* one privilege to set */
D1585 1
I1585 1
	tkp.PrivilegeCount = 1;		/* one privilege to set */
D1667 1
I1667 10
	hints.ai_socktype = SOCK_DGRAM;
\
	if(getaddrinfo(NULL, service, &hints, &res) != 0) {
	       msyslog(LOG_ERR, "getaddrinfo() failed: %m");
	       exit(1);
	       /*NOTREACHED*/
	}
\
	/* Remember the address of the addrinfo structure chain */
	ressave = res;
D1669 13
I1681 4
	/*
	 * For each structure returned, open and bind socket
	 */
	for(nbsock = 0; (nbsock < MAX_AF) && res ; res = res->ai_next) {
D1683 1
I1683 1
	   if ((fd[nbsock] = socket(res->ai_family, res->ai_socktype, res->ai_protocol)) < 0) {
D1690 5
I1694 5
	   }
	   /* set socket to reuse address */
	   if (setsockopt(fd[nbsock], SOL_SOCKET, SO_REUSEADDR, (void*) &optval, sizeof(optval)) < 0) {
		   netsyslog(LOG_ERR, "setsockopt() SO_REUSEADDR failed: %m");
		   exit(1);
D1696 1
I1696 1
	   }
D1698 7
I1704 7
	   /* Restricts AF_INET6 socket to IPv6 communications (see RFC 2553bis-03) */
	   if (res->ai_family == AF_INET6)
		if (setsockopt(fd[nbsock], IPPROTO_IPV6, IPV6_V6ONLY, (void*) &optval, sizeof(optval)) < 0) {
			   netsyslog(LOG_ERR, "setsockopt() IPV6_V6ONLY failed: %m");
			   exit(1);
			   /*NOTREACHED*/
		}
D1707 2
I1708 2
	   /* Remember the socket family in fd_family structure */
	   fd_family[nbsock] = res->ai_family;
D1733 3
I1735 3
	    if ((SOCKET) maxfd < fd[nbsock]+1) {
		maxfd = fd[nbsock]+1;
	    }
D1746 1
I1746 1
	if (ioctl(fd[nbsock],FIONBIO, &on) == ERROR) {
D1776 1
I1776 1
	nbsock++;
D1791 1
I1791 1
	int i;
D1793 1
I1793 1
	SOCKET sock = 0;
D1799 13
I1811 13
	/* Find a local family compatible socket to send ntp packet to ntp server */
	for(i = 0; (i < MAX_AF); i++) {
		if(dest->ss_family == fd_family[i]) {
			sock = fd[i];
		break;
		}
	}
\
	if ( sock == 0 ) {
		netsyslog(LOG_ERR, "cannot find family compatible socket to send ntp packet");
		exit(1);
		/*NOTREACHED*/
	}
D1824 1
I1824 1
			netsyslog(LOG_ERR, "sendto(%s): %m", stohost(dest));
D1840 1
I1840 1
	int i;
D1846 1
I1846 1
	int fdc = 0;
D1855 1
I1855 1
		n = poll(fds, (unsigned int)nbsock, tvzero.tv_sec * 1000);
D1857 10
I1866 10
		/*
		 * Determine which socket received data
		 */
\
		for(i=0; i < nbsock; i++) {
			if(fds[i].revents & POLLIN) {
				fdc = fd[i];
				break;
			}
		}
D1870 1
I1870 1
		n = select(maxfd, &fds, (fd_set *)0, (fd_set *)0, &tvzero);
D1872 10
I1881 10
		/*
		 * Determine which socket received data
		 */
\
		for(i=0; i < maxfd; i++) {
			if(FD_ISSET(fd[i], &fds)) {
				 fdc = fd[i];
				 break;
			}
		}
D2056 1
I2056 1
#else /* SLEWALWAYS */

# Patch checksum=f301dba8



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