From: Danny Mayer Date: Thu, 22 May 2003 02:43:30 +0000 (-0400) Subject: Miscellaneous updates and cosmetic changes. X-Git-Tag: NTP_4_1_80_RC1~21^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b94e1a7793f55db24d0a498593c6695f55fc6844;p=thirdparty%2Fntp.git Miscellaneous updates and cosmetic changes. Updates to ntptrace to get it to build properly. bk: 3ecc3952BF1Bbz1kkvD_Q2yMXR_LNA --- diff --git a/html/hints/winnt.html b/html/hints/winnt.html index 1f722e1ee..2ff893df2 100644 --- a/html/hints/winnt.html +++ b/html/hints/winnt.html @@ -11,17 +11,24 @@

NTP 4.x for Windows NT

-

Do not try to compile NTP-4.0.99i under WINNT, it will not work. Fixed NTP-4.0.99i; look for next release to be functional. Sven - May 11 2000

-

Download NTP-4.0.99g for the last stable WINNT port. I am working on adapting the major changes starting with 99i and getting things running again. Sven - April 25 2000

+

Introduction

- The NTP 4 distribution runs as service on (i386) Windows NT 4.0 and Windows 2000. The binaries work on dual processor systems. This port has not been tested on the Alpha platform. + The NTP 4 distribution runs as service on Windows NT 4.0, Windows 2000, Windows XP, + Windows .NET Server 2003. It will NOT run on Windows 95, 98, ME, etc. + The binaries work on dual processor systems. This port has not been tested + on the Alpha platform. This release now uses OpenSSL for authentication.

Refer to System Requirements and Instructions for how to compile the program.

Reference Clocks

- Refernce clock support under Windows NT is tricky because the IO functions are so much different. The following reference clocks are supported by Windows NT: + Reference clock support under Windows NT is tricky because the IO functions are + so much different. Most of the clock types have been built into the ntpd executable + and should work but have not been tested by the ntp project. The following reference + clocks are known to work and are supported by Windows NT:

Type 1 Undisciplined Local Clock (LOCAL)
Type 29 Trimble Navigation Palisade GPS (GPS_PALISADE)

Functions Supported

All NTP functions are supported with some constraints. See the TODO list below. + Note that the ntptrace executable is not supported and you should use the PERL script + version instead.

Accuracy

Greg Brackley has implemented a fantastic interpolation scheme that improves the precision of the NTP clock using a realtime thread (is that poetic or what!) which captures a tick count from the 8253 counter after each OS tick. The count is used to interpolate the time between operating system ticks.

On a typical 200+ MHz system NTP achieves a precision of about 5 microseconds and synchronizes the clock to +/-500 microseconds using the Trimble Palisade as UTC reference. This allows distributed applications to use the 10 milliseconds ticks available to them with high confidence.

@@ -30,22 +37,27 @@ http://www.trimble.com/oem/ntp and http://www.five-ten-sg.com/

ToDo

Compiling Requirements

Compiling Instructions

    +
  1. Unpack and build OpenSSL according to the OpenSSL instructions for building on + Windows. Currently the NTP build requires OpenSSL 0.9.6g as it looks for the path + to that build for the include and libeay32.lib files.
  2. Unpack the NTP-4.x.tar.gz
  3. Open the .\ports\winnt\ntp.dsw Visual C workspace
  4. Batch build all projects +
  5. The built binaries can be found in the port\winnt\bin\Release subdirectory +
  6. In addition you will need to install the OpenSSL libeay32.dll

Configuration File

The default NTP configuration file path is %SystemRoot%\system32\drivers\etc\. (%SystemRoot% is an environmental variable that can be determined by typing "set" at the "Command Prompt" or from the "System" icon in the "Control Panel").
@@ -67,8 +79,18 @@

Use the registry editor to edit the value for the ntpd executable under LocalMachine\System\CurrentControlSet\Services\NTP.

Add the -g option to the ImagePath key, behind "%INSTALLDIR>\ntpd.exe". This will force NTP to accept large time errors (including 1.1.1980 00:00)

Bug Reports

- Send bug reports to news://comp.protocols.time.ntp and Sven_Dietrich@Trimble.COM + Send questions to news://comp.protocols.time.ntp + and bug reports should be entered in Bugzilla on the + NTP Web site.

Change Log

+

Last revision 22 May 2003  Version 4.2.0

+ by Danny Mayer (mayer@ntp.org>) +

Significant Changes:

+ This latest release of NTP constitutes a major upgrade to its ability to build and + run on Windows platforms and should now build and run cleanly. More importantly it + is now able to support all authentication in the same way as Unix boxes. This does + require the usage of OpenSSL which is now a prerequisite for build on Windows. +

Last revision 16 February 1999  Version 4.0.99e.

by Sven Dietrich (sven_dietrich@trimble.com)

Significant Changes:

@@ -192,4 +214,4 @@ Sven_Dietrich@Trimble.COM

- \ No newline at end of file + diff --git a/ntpd/ntp_io.c b/ntpd/ntp_io.c index 897665e45..8947fba6a 100644 --- a/ntpd/ntp_io.c +++ b/ntpd/ntp_io.c @@ -425,6 +425,16 @@ create_sockets( for (i = 0; i < ninterfaces; i++) { inter_list[i].fd = open_socket(&inter_list[i].sin, inter_list[i].flags & INT_BROADCAST, 0); + if (inter_list[i].bfd != INVALID_SOCKET) + msyslog(LOG_INFO, "Listening on interface %s, %s#%d", + inter_list[i].name, + stoa((&inter_list[i].sin)), + NTP_PORT); + 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); } /* @@ -449,15 +459,6 @@ create_sockets( */ for (i = 0; i < ninterfaces; i++) { inter_list[i].addr_refid = addr2refid(&inter_list[i].sin); - msyslog(LOG_INFO, "Listening on %s interface, %s#%d", - inter_list[i].name, - stoa((&inter_list[i].sin)), - NTP_PORT); - 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); } diff --git a/ntpdate/ntpdate.c b/ntpdate/ntpdate.c index 08a0b6c2c..398d19466 100644 --- a/ntpdate/ntpdate.c +++ b/ntpdate/ntpdate.c @@ -115,7 +115,7 @@ volatile int debug = 0; int ai_fam_templ; int nbsock; SOCKET fd[MAX_AF]; /* support up to 2 sockets */ -SOCKET fd_family[MAX_AF]; /* to remember the socket family */ +int fd_family[MAX_AF]; /* to remember the socket family */ #ifdef HAVE_POLL_H struct pollfd fdmask[MAX_AF]; #else @@ -334,7 +334,7 @@ ntpdatemain ( wVersionRequested = MAKEWORD(1,1); if (WSAStartup(wVersionRequested, &wsaData)) { - msyslog(LOG_ERR, "No useable winsock.dll: %m"); + netsyslog(LOG_ERR, "No useable winsock.dll: %m"); exit(1); } @@ -609,7 +609,7 @@ ntpdatemain ( #ifndef SYS_WINNT if (errno != EINTR) #endif - msyslog(LOG_ERR, + netsyslog(LOG_ERR, #ifdef HAVE_POLL_H "poll() error: %m" #else @@ -618,7 +618,7 @@ ntpdatemain ( ); } else { #ifndef SYS_VXWORKS - msyslog(LOG_DEBUG, + netsyslog(LOG_DEBUG, #ifdef HAVE_POLL_H "poll(): nfound = %d, error: %m", #else @@ -1683,13 +1683,13 @@ init_io(void) if (errno == EPROTONOSUPPORT || errno == EAFNOSUPPORT || errno == EPFNOSUPPORT) continue; - msyslog(LOG_ERR, "socket() failed: %m"); + 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) { - msyslog(LOG_ERR, "setsockopt() SO_REUSEADDR failed: %m"); + netsyslog(LOG_ERR, "setsockopt() SO_REUSEADDR failed: %m"); exit(1); /*NOTREACHED*/ } @@ -1697,7 +1697,7 @@ init_io(void) /* 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) { - msyslog(LOG_ERR, "setsockopt() IPV6_V6ONLY failed: %m"); + netsyslog(LOG_ERR, "setsockopt() IPV6_V6ONLY failed: %m"); exit(1); /*NOTREACHED*/ } @@ -1716,10 +1716,10 @@ init_io(void) #else if (WSAGetLastError() == WSAEADDRINUSE) #endif /* SYS_WINNT */ - msyslog(LOG_ERR, + netsyslog(LOG_ERR, "the NTP socket is in use, exiting"); else - msyslog(LOG_ERR, "bind() fails: %m"); + netsyslog(LOG_ERR, "bind() fails: %m"); exit(1); } } @@ -1729,7 +1729,7 @@ init_io(void) fdmask[nbsock].events = POLLIN; #else FD_SET(fd[nbsock], &fdmask); - if (maxfd < fd[nbsock]+1) { + if ((SOCKET) maxfd < fd[nbsock]+1) { maxfd = fd[nbsock]+1; } #endif @@ -1743,21 +1743,21 @@ init_io(void) int on = TRUE; if (ioctl(fd[nbsock],FIONBIO, &on) == ERROR) { - msyslog(LOG_ERR, "ioctl(FIONBIO) fails: %m"); + netsyslog(LOG_ERR, "ioctl(FIONBIO) fails: %m"); exit(1); } } # else /* not SYS_VXWORKS */ # if defined(O_NONBLOCK) if (fcntl(fd[nbsock], F_SETFL, O_NONBLOCK) < 0) { - msyslog(LOG_ERR, "fcntl(FNDELAY|FASYNC) fails: %m"); + netsyslog(LOG_ERR, "fcntl(FNDELAY|FASYNC) fails: %m"); exit(1); /*NOTREACHED*/ } # else /* not O_NONBLOCK */ # if defined(FNDELAY) if (fcntl(fd[nbsock], F_SETFL, FNDELAY) < 0) { - msyslog(LOG_ERR, "fcntl(FNDELAY|FASYNC) fails: %m"); + netsyslog(LOG_ERR, "fcntl(FNDELAY|FASYNC) fails: %m"); exit(1); /*NOTREACHED*/ } @@ -1768,7 +1768,7 @@ init_io(void) # endif /* SYS_VXWORKS */ #else /* SYS_WINNT */ if (ioctlsocket(fd[nbsock], FIONBIO, (u_long *) &on) == SOCKET_ERROR) { - msyslog(LOG_ERR, "ioctlsocket(FIONBIO) fails: %m"); + netsyslog(LOG_ERR, "ioctlsocket(FIONBIO) fails: %m"); exit(1); } #endif /* SYS_WINNT */ @@ -1804,7 +1804,7 @@ sendpkt( } if ( sock == 0 ) { - msyslog(LOG_ERR, "cannot find family compatible socket to send ntp packet"); + netsyslog(LOG_ERR, "cannot find family compatible socket to send ntp packet"); exit(1); /*NOTREACHED*/ } @@ -1820,7 +1820,7 @@ sendpkt( err = WSAGetLastError(); if (err != WSAEWOULDBLOCK && err != WSAENOBUFS) #endif /* SYS_WINNT */ - msyslog(LOG_ERR, "sendto(%s): %m", stohost(dest)); + netsyslog(LOG_ERR, "sendto(%s): %m", stohost(dest)); } } @@ -1890,7 +1890,7 @@ input_handler(void) return; else if (n == -1) { if (errno != EINTR) - msyslog(LOG_ERR, + netsyslog(LOG_ERR, #ifdef HAVE_POLL_H "poll() error: %m" #else diff --git a/ntptrace/ntptrace.c b/ntptrace/ntptrace.c index 8115c50a0..8e45e3448 100644 --- a/ntptrace/ntptrace.c +++ b/ntptrace/ntptrace.c @@ -74,7 +74,7 @@ int sys_version = NTP_OLDVERSION; /* version to poll with */ /* * File descriptor masks etc. for call to select */ -int fd; +SOCKET fd; fd_set fdmask; /* @@ -91,7 +91,7 @@ static int ReceiveBuf P((struct server *, struct recvbuf *)); static struct server *addserver P((struct in_addr *)); static struct server *addservbyname P((const char *)); static void setup_io P((void)); -static void sendpkt P((struct sockaddr_in *, struct pkt *, int)); +static void sendpkt P((struct sockaddr_storage *, struct pkt *, int)); static int getipaddr P((const char *, u_int32 *)); static int decodeipaddr P((const char *, u_int32 *)); static void printserver P((struct server *, FILE *)); @@ -199,7 +199,7 @@ ntptracemain( #ifdef SYS_WINNT wVersionRequested = MAKEWORD(1,1); if (WSAStartup(wVersionRequested, &wsaData)) { - msyslog(LOG_ERR, "No useable winsock.dll: %m"); + netsyslog(LOG_ERR, "No useable winsock.dll: %m"); exit(1); } #endif /* SYS_WINNT */ @@ -250,7 +250,7 @@ DoTrace( { int retries = sys_retries; - if (!server->srcadr.sin_addr.s_addr) { + if (!GET_INADDR(server->srcadr)) { if (nonames) printf("%s:\t*Not Synchronized*\n", ntoa(&server->srcadr)); else @@ -351,7 +351,7 @@ DoReceive( return(0); } else if (n == -1) { - msyslog(LOG_ERR, "select() error: %m"); + netsyslog(LOG_ERR, "select() error: %m"); return(0); } get_systime(&ts); @@ -422,7 +422,7 @@ ReceiveBuf( rbufp->recv_length); return(0); /* funny length packet */ } - if (rbufp->recv_srcadr.sin_addr.s_addr != server->srcadr.sin_addr.s_addr) { + if (GET_INADDR(rbufp->recv_srcadr) != GET_INADDR(server->srcadr)) { if (debug) printf("receive: wrong server\n"); return(0); /* funny length packet */ @@ -552,9 +552,9 @@ addserver( server = (struct server *)emalloc(sizeof(struct server)); memset((char *)server, 0, sizeof(struct server)); - server->srcadr.sin_family = AF_INET; - server->srcadr.sin_addr = *iap; - server->srcadr.sin_port = htons(NTP_PORT); + server->srcadr.ss_family = AF_INET; + ((struct sockaddr_in *)&server->srcadr)->sin_addr = *iap; + ((struct sockaddr_in *)&server->srcadr)->sin_port = htons(NTP_PORT); sys_servers[sys_numservers++] = server; @@ -600,7 +600,7 @@ setup_io(void) == INVALID_SOCKET #endif ) { - msyslog(LOG_ERR, "socket() failed: %m"); + netsyslog(LOG_ERR, "socket() failed: %m"); exit(1); /*NOTREACHED*/ } @@ -617,7 +617,7 @@ setup_io(void) */ static void sendpkt( - struct sockaddr_in *dest, + struct sockaddr_storage *dest, struct pkt *pkt, int len ) @@ -625,18 +625,19 @@ sendpkt( int cc; cc = sendto(fd, (char *)pkt, (size_t)len, 0, (struct sockaddr *)dest, - sizeof(struct sockaddr_in)); - if (cc == -1) { + SOCKLEN(dest)); + if (cc == SOCKET_ERROR) { #ifndef SYS_WINNT if (errno != EWOULDBLOCK && errno != ENOBUFS) #else /* SYS_WINNT */ int iSockErr = WSAGetLastError(); if (iSockErr != WSAEWOULDBLOCK && iSockErr != WSAENOBUFS) #endif /* SYS_WINNT */ - msyslog(LOG_ERR, "sendto(%s): %m", ntoa(dest)); + netsyslog(LOG_ERR, "sendto(%s): %m", ntoa(dest)); } } + /* * getipaddr - given a host name, return its host address */ @@ -728,7 +729,7 @@ printserver( } (void) fprintf(fp, "server %s, port %d\n", ntoa(&pp->srcadr), - ntohs(pp->srcadr.sin_port)); + SRCPORT(&pp->srcadr)); (void) fprintf(fp, "stratum %d, precision %d, leap %c%c\n", pp->stratum, pp->precision, pp->leap & 0x2 ? '1' : '0', diff --git a/ntptrace/ntptrace.h b/ntptrace/ntptrace.h index 53cbe0107..3bf97fdc5 100644 --- a/ntptrace/ntptrace.h +++ b/ntptrace/ntptrace.h @@ -10,7 +10,7 @@ * remember about the server. */ struct server { - struct sockaddr_in srcadr; /* address of remote host */ + struct sockaddr_storage srcadr; /* address of remote host */ u_char leap; /* leap indicator */ u_char stratum; /* stratum of remote server */ s_char precision; /* server's clock precision */ diff --git a/ports/winnt/ntpdate/ntpdate.dsp b/ports/winnt/ntpdate/ntpdate.dsp index 9d0a24c81..1b3bb364b 100644 --- a/ports/winnt/ntpdate/ntpdate.dsp +++ b/ports/winnt/ntpdate/ntpdate.dsp @@ -66,7 +66,7 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W4 /Gm /GX /ZI /Od /I "." /I "..\include" /I "..\..\..\include" /I "\openssl-0.9.6g\inc32" /D "_DEBUG" /D "_CONSOLE" /D "WIN32" /D "_MBCS" /D "__STDC__" /D "SYS_WINNT" /D "HAVE_CONFIG_H" /D _WIN32_WINNT=0x400 /YX"windows.h" /FD /GZ /c +# ADD CPP /nologo /MTd /W4 /Gm /GX /ZI /Od /I "." /I "..\include" /I "..\..\..\include" /I "\openssl-0.9.6g\inc32" /D "_DEBUG" /D "_CONSOLE" /D "WIN32" /D "_MBCS" /D "__STDC__" /D "SYS_WINNT" /D "HAVE_CONFIG_H" /D _WIN32_WINNT=0x400 /FR /YX"windows.h" /FD /GZ /c # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe