Updates to ntptrace to get it to build properly.
bk: 3ecc3952BF1Bbz1kkvD_Q2yMXR_LNA
<body>
<h1>NTP 4.x for Windows NT</h1>
- <h2>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</h2>
- <h2>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</h2>
+
<h2>Introduction</h2>
- 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.
<p>Refer to System Requirements and Instructions for how to compile the program.</p>
<h2>Reference Clocks</h2>
- 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:
<p><a href="../driver1.html">Type 1</a> Undisciplined Local Clock (LOCAL)<br>
<a href="../driver29.html">Type 29</a> Trimble Navigation Palisade GPS (GPS_PALISADE)</p>
<h2>Functions Supported</h2>
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.
<h2>Accuracy</h2>
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.
<p>On a typical 200+ MHz system NTP achieves a precision of about 5 microseconds and synchronizes the clock to +/-500 microseconds using the <a href="http://www.trimble.com/products/ntp">Trimble Palisade</a> as UTC reference. This allows distributed applications to use the 10 milliseconds ticks available to them with high confidence.</p>
<a href="http://www.trimble.com/oem/ntp">http://www.trimble.com/oem/ntp</a> and <a href="http://www.five-ten-sg.com/">http://www.five-ten-sg.com/</a>
<h2>ToDo</h2>
<ul>
- <li>MD5 authentication causes problems with DNS. If you use encryption/authentication, you have to use IP numbers in <tt>ntp.conf.</tt>
- <li>NMEA refclock support is in development.
<li>See if precision can be improved by using CPU cycle counter for tick interpolation.
<li>Make precision time available to applications using NTP_GETTIME API
</ul>
<h2>Compiling Requirements</h2>
<ul>
- <li><tt>Windows NT 4.0 or 5.0 (2000)</tt>
- <li><tt>Microsoft Visual C++ 6.0</tt>
- <li>Some version of the archiving program <tt>ZIP</tt>.
+ <li>Windows NT 4.0 Windows 2000, Windows XP, or Windows.NET Server 2003
+ <li>Microsoft Visual C++ 6.0
+ <li>Some way of uncompressing and untarring the gzipped tar file.
+ <li>OpenSSL must be built on the box before building NTP. Additional steps would
+ be required to not use OpenSSL.
</ul>
<h2>Compiling Instructions</h2>
<ol>
+ <li>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.
<li>Unpack the NTP-4.x.tar.gz
<li>Open the .\ports\winnt\ntp.dsw Visual C workspace
<li>Batch build all projects
+ <li>The built binaries can be found in the port\winnt\bin\Release subdirectory
+ <li>In addition you will need to install the OpenSSL libeay32.dll
</ol>
<h2>Configuration File</h2>
The default NTP configuration file path is %SystemRoot%<tt>\system32\drivers\etc\. </tt>(%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").<br>
<p>Use the registry editor to edit the value for the ntpd executable under LocalMachine\System\CurrentControlSet\Services\NTP.</p>
<p>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)</p>
<h2>Bug Reports</h2>
- Send bug reports to <a href="news://comp.protocols.time.ntp">news://comp.protocols.time.ntp</a> and Sven_Dietrich@Trimble.COM
+ Send questions to <a href="news://comp.protocols.time.ntp">news://comp.protocols.time.ntp</a>
+ and bug reports should be entered in <a href="http://bugzilla.ntp.org/">Bugzilla</a> on the
+ NTP Web site.
<h2>Change Log</h2>
+ <h3>Last revision 22 May 2003 Version 4.2.0</h3>
+ <b>by Danny Mayer (mayer@ntp.org>)</b>
+ <h3>Significant Changes:</h3>
+ 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.
+
<h3>Last revision 16 February 1999 Version 4.0.99e.</h3>
<b>by Sven Dietrich (sven_dietrich@trimble.com)</b>
<p><b>Significant Changes:</b></p>
<a href="mailto://sven_dietrich@trimble.com">Sven_Dietrich@Trimble.COM</a></p>
</body>
-</html>
\ No newline at end of file
+</html>
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);
}
/*
*/
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);
}
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
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);
}
#ifndef SYS_WINNT
if (errno != EINTR)
#endif
- msyslog(LOG_ERR,
+ netsyslog(LOG_ERR,
#ifdef HAVE_POLL_H
"poll() error: %m"
#else
);
} else {
#ifndef SYS_VXWORKS
- msyslog(LOG_DEBUG,
+ netsyslog(LOG_DEBUG,
#ifdef HAVE_POLL_H
"poll(): nfound = %d, error: %m",
#else
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*/
}
/* 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*/
}
#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);
}
}
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
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*/
}
# 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 */
}
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*/
}
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));
}
}
return;
else if (n == -1) {
if (errno != EINTR)
- msyslog(LOG_ERR,
+ netsyslog(LOG_ERR,
#ifdef HAVE_POLL_H
"poll() error: %m"
#else
/*
* File descriptor masks etc. for call to select
*/
-int fd;
+SOCKET fd;
fd_set fdmask;
/*
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 *));
#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 */
{
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
return(0);
}
else if (n == -1) {
- msyslog(LOG_ERR, "select() error: %m");
+ netsyslog(LOG_ERR, "select() error: %m");
return(0);
}
get_systime(&ts);
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 */
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;
== INVALID_SOCKET
#endif
) {
- msyslog(LOG_ERR, "socket() failed: %m");
+ netsyslog(LOG_ERR, "socket() failed: %m");
exit(1);
/*NOTREACHED*/
}
*/
static void
sendpkt(
- struct sockaddr_in *dest,
+ struct sockaddr_storage *dest,
struct pkt *pkt,
int len
)
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
*/
}
(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',
* 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 */
# 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