]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
Use the Win32InitSockets code now in port/winnt/libisc/net.c so we use common code.
authorDanny Mayer <mayer@ntp.org>
Thu, 7 Aug 2003 02:15:52 +0000 (22:15 -0400)
committerDanny Mayer <mayer@ntp.org>
Thu, 7 Aug 2003 02:15:52 +0000 (22:15 -0400)
Need to force the isc headers to not include the isc/ipv6.h code.

bk: 3f31b6584omMweWn4QlMhiYYsZpqdA

ntpd/ntp_io.c
ntpdc/ntpdc.c
ntpq/ntpq.c
ports/winnt/include/isc/net.h
ports/winnt/libisc/net.c

index 68ee2fafb70372ae2b85add360fccd820ad5efad..8ecc9320d74353600d653d697cf808910176ff28 100644 (file)
@@ -187,8 +187,6 @@ void
 init_io(void)
 {
 #ifdef SYS_WINNT
-       WORD wVersionRequested;
-       WSADATA wsaData;
        init_transmitbuff();
 #endif /* SYS_WINNT */
 
@@ -214,8 +212,7 @@ init_io(void)
 #endif
 
 #ifdef SYS_WINNT
-       wVersionRequested = MAKEWORD(2,0);
-       if (WSAStartup(wVersionRequested, &wsaData))
+       if (!Win32InitSockets())
        {
                netsyslog(LOG_ERR, "No useable winsock.dll: %m");
                exit(1);
index a49df1681ff44fa7d24a6156d072c8113afe9d94..294b88da2dbcc6b493113f7b260404beaf3033fc 100644 (file)
@@ -8,6 +8,8 @@
 #include "ntp_select.h"
 #include "ntp_io.h"
 #include "ntp_stdlib.h"
+/* Don't include ISC's version of IPv6 variables and structures */
+#define ISC_IPV6_H 1
 #include "isc/net.h"
 #include "isc/result.h"
 
@@ -176,8 +178,6 @@ char password[9];
 #endif /* SYS_WINNT || SYS_VXWORKS */
 
 #ifdef SYS_WINNT
-WORD wVersionRequested;
-WSADATA wsaData;
 DWORD NumberOfBytesWritten;
 
 HANDLE TimerThreadHandle = NULL;       /* 1998/06/03 - Used in ntplib/machines.c */
@@ -301,6 +301,15 @@ ntpdcmain(
        taskPrioritySet(taskIdSelf(), 100 );
 #endif
 
+#ifdef SYS_WINNT
+       if (!Win32InitSockets())
+       {
+               fprintf(stderr, "No useable winsock.dll:");
+               exit(1);
+       }
+#endif /* SYS_WINNT */
+
+       /* Check to see if we have IPv6. Otherwise force the -4 flag */
        if (isc_net_probeipv6() != ISC_R_SUCCESS) {
                ai_fam_default = AF_INET;
        }
@@ -373,14 +382,6 @@ ntpdcmain(
        }
        pktdatasize = INITDATASIZE;
 
-#ifdef SYS_WINNT
-       wVersionRequested = MAKEWORD(1,1);
-       if (WSAStartup(wVersionRequested, &wsaData)) {
-               fprintf(stderr, "No useable winsock.dll");
-               exit(1);
-       }
-#endif /* SYS_WINNT */
-
        if (numcmds == 0) {
                (void) openhost(chosts[0]);
                getcmds();
index 5ba7f23f673a92e6b1878addbfd9b30e3a8752df..e45a4af74827fd1bebe20f9f9ffd6756fb75a9f6 100644 (file)
@@ -10,6 +10,8 @@
 #include "ntp_io.h"
 #include "ntp_select.h"
 #include "ntp_stdlib.h"
+/* Don't include ISC's version of IPv6 variables and structures */
+#define ISC_IPV6_H 1
 #include "isc/net.h"
 #include "isc/result.h"
 
@@ -375,8 +377,6 @@ int s_port = 0;
 struct servent *server_entry = NULL;           /* server entry for ntp */
 
 #ifdef SYS_WINNT
-WORD wVersionRequested;
-WSADATA wsaData;
 DWORD NumberOfBytesWritten;
 
 HANDLE TimerThreadHandle = NULL;       /* 1998/06/03 - Used in ntplib/machines.c */
@@ -501,6 +501,15 @@ ntpqmain(
        delay_time.l_ui = 0;
        delay_time.l_uf = DEFDELAY;
 
+#ifdef SYS_WINNT
+       if (!Win32InitSockets())
+       {
+               fprintf(stderr, "No useable winsock.dll:");
+               exit(1);
+       }
+#endif /* SYS_WINNT */
+
+       /* Check to see if we have IPv6. Otherwise force the -4 flag */
        if (isc_net_probeipv6() != ISC_R_SUCCESS) {
                ai_fam_default = AF_INET;
        }
@@ -557,14 +566,6 @@ ntpqmain(
            (void) signal_no_reset(SIGINT, abortcmd);
 #endif /* SYS_WINNT */
 
-#ifdef SYS_WINNT
-       wVersionRequested = MAKEWORD(1,1);
-       if (WSAStartup(wVersionRequested, &wsaData)) {
-               fprintf(stderr, "No useable winsock.dll");
-               exit(1);
-       }
-#endif /* SYS_WINNT */
-
        if (numcmds == 0) {
                (void) openhost(chosts[0]);
                getcmds();
index 43e54fbe366fa6deded2bf25455f429592c645f9..462a7a3f3bf5d31db304a6f5534eed9fdc641307 100644 (file)
@@ -265,6 +265,11 @@ isc_net_aton(const char *cp, struct in_addr *addr);
 #define inet_aton isc_net_aton
 #endif
 
+/* Socket Initialization Code */
+
+BOOL
+Win32InitSockets();
+
 ISC_LANG_ENDDECLS
 
 #endif /* ISC_NET_H */
index dd23549674dda89ec316ce74b38dfb39b85ed2fd..34a62887b058315978919e6638daaf2658e1dca7 100644 (file)
@@ -117,3 +117,21 @@ isc_net_probeipv6(void) {
        initialize();
        return (ipv6_result);
 }
+/*
+ * Initialize socket services
+ */
+BOOL Win32InitSockets() {
+       WORD wVersionRequested;
+       WSADATA wsaData;
+       int err;
+
+       /* Need Winsock 2.0 or better */
+       wVersionRequested = MAKEWORD(2, 0);
+       err = WSAStartup(wVersionRequested, &wsaData);
+       if ( err != 0 ) {
+               /* Tell the user that we could not find a usable Winsock DLL */
+               return(FALSE);
+       }
+       return(TRUE);
+}