From: Danny Mayer Date: Mon, 15 Aug 2005 23:41:00 +0000 (-0400) Subject: Fixes to support ntp_random on Windows and miscellaneous fixes for all platforms... X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5f0787e79c1454ca8a4db15696cdb0e3fa80987a;p=thirdparty%2Fntp.git Fixes to support ntp_random on Windows and miscellaneous fixes for all platforms to get everything in the right place bk: 4301280cOczqjLDt683bzbpV6S5L8g --- diff --git a/include/ntp.h b/include/ntp.h index 695f1794d7..036093812f 100644 --- a/include/ntp.h +++ b/include/ntp.h @@ -9,6 +9,7 @@ #ifdef OPENSSL #include "ntp_crypto.h" #endif /* OPENSSL */ +#include #include diff --git a/include/ntp_random.h b/include/ntp_random.h new file mode 100644 index 0000000000..766dcc3760 --- /dev/null +++ b/include/ntp_random.h @@ -0,0 +1,14 @@ + +#include + +long ntp_random P((void)); +void ntp_srandom P((unsigned long)); +void ntp_srandomdev P((void)); +char * ntp_initstate P((unsigned long, /* seed for R.N.G. */ + char *, /* pointer to state array */ + long /* # bytes of state info */ + )); +char * ntp_setstate P((char *)); /* pointer to state array */ + + + diff --git a/include/ntpd.h b/include/ntpd.h index 501238dd3b..c009c577c9 100644 --- a/include/ntpd.h +++ b/include/ntpd.h @@ -13,16 +13,9 @@ #ifdef SYS_WINNT #define exit ntservice_exit extern void ntservice_exit (int); -/* declare the service threads */ -void service_main (DWORD, LPTSTR *); -void service_ctrl (DWORD); -void worker_thread (void *); #define sleep(x) Sleep((DWORD) x * 1000 /* milliseconds */ ); #endif /* SYS_WINNT */ -extern void ntp_srandom P((unsigned long)); -extern int ntp_random P((void)); - /* ntp_config.c */ extern void getconfig P((int, char **)); diff --git a/libntp/Makefile.am b/libntp/Makefile.am index e2ddb76071..9047ea8e0f 100644 --- a/libntp/Makefile.am +++ b/libntp/Makefile.am @@ -11,7 +11,7 @@ libntp_a_SRCS = a_md5encrypt.c adjtime.c atoint.c atolfp.c atouint.c \ lib_strbuf.c machines.c md5c.c memmove.c mfptoa.c \ mfptoms.c mktime.c modetoa.c mstolfp.c msutotsf.c msyslog.c netof.c \ ntp_rfc2553.c numtoa.c numtohost.c octtoint.c prettydate.c \ - random.c recvbuff.c refnumtoa.c snprintf.c socktoa.c socktohost.c \ + ntp_random.c recvbuff.c refnumtoa.c snprintf.c socktoa.c socktohost.c \ statestr.c strdup.c strerror.c strstr.c \ syssignal.c tsftomsu.c tstotv.c tvtoa.c tvtots.c \ uglydate.c uinttoa.c utvtoa.c ymd2yd.c \ diff --git a/libntp/random.c b/libntp/ntp_random.c similarity index 99% rename from libntp/random.c rename to libntp/ntp_random.c index e59fc854ab..700b4ee651 100644 --- a/libntp/random.c +++ b/libntp/ntp_random.c @@ -48,6 +48,8 @@ static char sccsid[] = "@(#)random.c 8.2 (Berkeley) 5/19/95"; #include #include +#include +#include /* * random.c: @@ -218,7 +220,6 @@ static long rand_sep = SEP_3; static long *end_ptr = &randtbl[DEG_3 + 1]; static inline long good_rand P((long)); -long ntp_random P((void)); static inline long good_rand ( @@ -295,16 +296,18 @@ ntp_srandom( * state buffer are no longer derived from the LC algorithm applied to * a fixed seed. */ +#ifdef NEED_SRANDOMDEV void ntp_srandomdev( void ) { struct timeval tv; unsigned long junk; /* Purposely used uninitialized */ - gettimeofday(&tv, NULL); + GETTIMEOFDAY(&tv, NULL); ntp_srandom(getpid() ^ tv.tv_sec ^ tv.tv_usec ^ junk); return; } +#endif /* * initstate: diff --git a/ntpd/ntp_config.c b/ntpd/ntp_config.c index fe57f55793..1ebba00b67 100644 --- a/ntpd/ntp_config.c +++ b/ntpd/ntp_config.c @@ -17,6 +17,7 @@ #include "ntp_stdlib.h" #include "ntp_config.h" #include "ntp_cmdargs.h" +#include #include #include diff --git a/ntpd/ntp_crypto.c b/ntpd/ntp_crypto.c index 124887f6f7..affbeb2c4a 100644 --- a/ntpd/ntp_crypto.c +++ b/ntpd/ntp_crypto.c @@ -16,6 +16,7 @@ #include "ntp_stdlib.h" #include "ntp_unixtime.h" #include "ntp_string.h" +#include #include "openssl/asn1_mac.h" #include "openssl/bn.h" diff --git a/ntpd/ntp_monitor.c b/ntpd/ntp_monitor.c index f998dcaba3..64188f0a8c 100644 --- a/ntpd/ntp_monitor.c +++ b/ntpd/ntp_monitor.c @@ -9,6 +9,7 @@ #include "ntp_io.h" #include "ntp_if.h" #include "ntp_stdlib.h" +#include #include #include diff --git a/ntpd/ntp_peer.c b/ntpd/ntp_peer.c index 629c4bf622..868ed1927a 100644 --- a/ntpd/ntp_peer.c +++ b/ntpd/ntp_peer.c @@ -10,6 +10,7 @@ #include "ntpd.h" #include "ntp_stdlib.h" +#include #ifdef OPENSSL #include "openssl/rand.h" #endif /* OPENSSL */ diff --git a/ntpd/ntpd.c b/ntpd/ntpd.c index ac92df92b2..a4bb5b2bd1 100644 --- a/ntpd/ntpd.c +++ b/ntpd/ntpd.c @@ -10,6 +10,7 @@ #include "ntpd.h" #include "ntp_io.h" #include "ntp_stdlib.h" +#include #ifdef SIM #include "ntpsim.h" diff --git a/ports/winnt/include/config.h b/ports/winnt/include/config.h index 1ed7f877ac..8ecaf21956 100644 --- a/ports/winnt/include/config.h +++ b/ports/winnt/include/config.h @@ -75,6 +75,7 @@ * Miscellaneous functions that Microsoft maps * to other names */ +#define inline __inline #define vsnprintf _vsnprintf #define snprintf _snprintf #define stricmp _stricmp diff --git a/ports/winnt/libntp/libntp.dsp b/ports/winnt/libntp/libntp.dsp index 9cd2cb97fd..9ecdbd3062 100644 --- a/ports/winnt/libntp/libntp.dsp +++ b/ports/winnt/libntp/libntp.dsp @@ -122,10 +122,6 @@ SOURCE=..\..\..\libntp\authusekey.c # End Source File # Begin Source File -SOURCE=..\..\..\libntp\binio.c -# End Source File -# Begin Source File - SOURCE=..\..\..\libntp\buftvtots.c # End Source File # Begin Source File @@ -190,10 +186,6 @@ SOURCE=..\..\..\libntp\getopt.c # End Source File # Begin Source File -SOURCE=..\..\..\libntp\gpstolfp.c -# End Source File -# Begin Source File - SOURCE=..\..\..\libntp\hextoint.c # End Source File # Begin Source File @@ -206,10 +198,6 @@ SOURCE=..\..\..\libntp\humandate.c # End Source File # Begin Source File -SOURCE=..\..\..\libntp\ieee754io.c -# End Source File -# Begin Source File - SOURCE=..\..\..\libisc\inet_aton.c # End Source File # Begin Source File @@ -262,10 +250,6 @@ SOURCE=..\..\..\libntp\memmove.c # End Source File # Begin Source File -SOURCE=..\..\..\libntp\mfp_mul.c -# End Source File -# Begin Source File - SOURCE=..\..\..\libntp\mfptoa.c # End Source File # Begin Source File @@ -314,6 +298,10 @@ SOURCE=..\..\..\libisc\netscope.c # End Source File # Begin Source File +SOURCE=..\..\..\libntp\ntp_random.c +# End Source File +# Begin Source File + SOURCE=..\..\..\libntp\ntp_rfc2553.c # End Source File # Begin Source File @@ -342,10 +330,6 @@ SOURCE=.\randfile.c # End Source File # Begin Source File -SOURCE=..\..\..\libntp\ranny.c -# End Source File -# Begin Source File - SOURCE=..\..\..\libntp\recvbuff.c # End Source File # Begin Source File @@ -542,6 +526,10 @@ SOURCE=..\..\..\include\ntp_proto.h # End Source File # Begin Source File +SOURCE=..\..\..\include\ntp_random.h +# End Source File +# Begin Source File + SOURCE=..\..\..\include\ntp_refclock.h # End Source File # Begin Source File diff --git a/ports/winnt/ntp-keygen/ntpkeygen.dsp b/ports/winnt/ntp-keygen/ntpkeygen.dsp index b45f7995dc..1d800061be 100644 --- a/ports/winnt/ntp-keygen/ntpkeygen.dsp +++ b/ports/winnt/ntp-keygen/ntpkeygen.dsp @@ -96,6 +96,10 @@ SOURCE="..\..\..\util\ntp-keygen.c" # End Source File # Begin Source File +SOURCE=..\..\..\libntp\ntp_random.c +# End Source File +# Begin Source File + SOURCE=..\libntp\randfile.c # End Source File # Begin Source File diff --git a/ports/winnt/ntpd/ntpd.dsp b/ports/winnt/ntpd/ntpd.dsp index 43c8a27c30..df476d3026 100644 --- a/ports/winnt/ntpd/ntpd.dsp +++ b/ports/winnt/ntpd/ntpd.dsp @@ -42,7 +42,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /MD /W4 /GX /O2 /I "." /I "..\include" /I "..\..\..\include" /I "\openssl-0.9.7d\inc32" /D "NDEBUG" /D "_CONSOLE" /D "WIN32" /D "_MBCS" /D "__STDC__" /D "SYS_WINNT" /D "HAVE_CONFIG_H" /D _WIN32_WINNT=0x400 /YX"windows.h" /FD /c +# ADD CPP /nologo /MD /W4 /GX /O2 /I "." /I "..\include" /I "..\..\..\include" /I "\openssl-0.9.7d\inc32" /D "NDEBUG" /D "_CONSOLE" /D "WIN32" /D "_MBCS" /D "__STDC__" /D "SYS_WINNT" /D "HAVE_CONFIG_H" /D _WIN32_WINNT=0x400 /FR /YX"windows.h" /FD /c # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe @@ -280,6 +280,10 @@ SOURCE=..\..\..\include\ntp_proto.h # End Source File # Begin Source File +SOURCE=..\..\..\include\ntp_random.h +# End Source File +# Begin Source File + SOURCE=..\..\..\include\ntp_refclock.h # End Source File # Begin Source File