]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 1442] Move functions into libntp files
authorDanny Mayer <mayer@ntp.org>
Sun, 27 Dec 2009 20:52:30 +0000 (20:52 +0000)
committerDanny Mayer <mayer@ntp.org>
Sun, 27 Dec 2009 20:52:30 +0000 (20:52 +0000)
bk: 4b37c90eBMU2RV2Ls0tyT_ZsaoEA2Q

ports/winnt/include/config.h
ports/winnt/include/termios.h
ports/winnt/include/win32_io.h [new file with mode: 0644]
ports/winnt/libntp/setpriority.c
ports/winnt/libntp/win32_io.c [new file with mode: 0644]
ports/winnt/vs2005/Instsrv.vcproj
ports/winnt/vs2005/libntp.vcproj
ports/winnt/vs2005/ntp.sln
ports/winnt/vs2005/ntpd.vcproj
ports/winnt/vs2008/libntp/libntp.vcproj
ports/winnt/vs2008/ntpd/ntpd.vcproj

index d67968b3b998f42bf66465040136da8365cb1f71..e44c5a3a2c8d38cc2fa6765276ff5ebacbfeb5e0 100644 (file)
@@ -173,19 +173,6 @@ typedef int socklen_t;
 #define SO_EXCLUSIVEADDRUSE ((int)(~SO_REUSEADDR))
 #endif
 
-/*
- * Define this macro to control the behavior of connection
- * resets on UDP sockets.  See Microsoft KnowledgeBase Article Q263823
- * for details.
- * Based on that article, it is surprising that a much newer winsock2.h
- * does not define SIO_UDP_CONNRESET (the one that comes with VS 2008).
- * NOTE: This requires that Windows 2000 systems install Service Pack 2
- * or later.
- */
-#ifndef SIO_UDP_CONNRESET 
-#define SIO_UDP_CONNRESET _WSAIOW(IOC_VENDOR,12) 
-#endif
-
 #if defined _MSC_VER && _MSC_VER < 1400
 /*
  * Use 32-bit time definitions for versions prior to VS 2005
index 8c241436f29de50e82cc13a104a3427ac0f098a6..91be2e5ad1a63dbcc8ae24cb5ed25bd8ad39d56a 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef WIN32_IO_H
-#define WIN32_IO_H
+#ifndef _TERMIOS_H
+#define _TERMIOS_H
 
 /*  Flag definitions for compatibility
  *  ==================================
@@ -213,4 +213,4 @@ extern      int     ioctl           (int, int, int *);
 extern int     tcsetattr       (int, int, const struct termios *);
 extern int     tcgetattr       (int, struct termios *);
 
-#endif /* defined WIN32_IO_H */
+#endif
diff --git a/ports/winnt/include/win32_io.h b/ports/winnt/include/win32_io.h
new file mode 100644 (file)
index 0000000..129c8ff
--- /dev/null
@@ -0,0 +1,8 @@
+#ifndef WIN32_IO_H
+#define WIN32_IO_H
+
+extern void    InitSockets(void);
+void connection_reset_fix(SOCKET fd, sockaddr_u *addr)
+
+#endif /* defined WIN32_IO_H */
+;
index 2e648f0add079a0522f35afb158f805af3a54ed4..c57269ad32f6de9161d14fa73d00459d5f257e38 100644 (file)
@@ -1,8 +1,6 @@
 #include <config.h>
-#include <windows.h>
 #include <stdio.h>
 #include <sys/resource.h>      /* our private version */
-#include "ntp_machine.h"
 #include "ntp_stdlib.h"
 #include "ntp_syslog.h"
 #include "ntp_debug.h"
@@ -77,31 +75,3 @@ int setpriority(
 
        return 0; 
 }
-
-/*
- * InitSockets -- once known as Win32InitSockets()
- *
- * This doesn't have much to do with setpriority but we
- * want the routine in libntp and this is a convenient
- * existing Windows-only libntp source file.
- */
-void
-InitSockets(
-       void
-       )
-{
-       WORD wVersionRequested;
-       WSADATA wsaData;
-       int err;
-
-       /* Need Winsock 2.0 or better */
-       wVersionRequested = MAKEWORD(2, 0);
-       err = WSAStartup(wVersionRequested, &wsaData);
-       if ( err != 0 ) {
-               fprintf(stderr, "No useable winsock.dll: %s\n", strerror(err));
-               SetLastError(err);
-               msyslog(LOG_ERR, "No usable winsock.dll: %m");
-               exit(1);
-       }
-}
diff --git a/ports/winnt/libntp/win32_io.c b/ports/winnt/libntp/win32_io.c
new file mode 100644 (file)
index 0000000..9bc0a66
--- /dev/null
@@ -0,0 +1,80 @@
+/* This file implements i/o calls that are specific to Windows */
+
+#include <config.h>
+#include <stdio.h>
+#include "ntp_fp.h"
+#include "ntp_net.h"
+#include "ntp_stdlib.h"
+#include "ntp_syslog.h"
+#include "win32_io.h"
+#include <isc/win32os.h>
+
+/*
+ * Define this macro to control the behavior of connection
+ * resets on UDP sockets.  See Microsoft KnowledgeBase Article Q263823
+ * for details.
+ * Based on that article, it is surprising that a much newer winsock2.h
+ * does not define SIO_UDP_CONNRESET (the one that comes with VS 2008).
+ * NOTE: This requires that Windows 2000 systems install Service Pack 2
+ * or later.
+ */
+#ifndef SIO_UDP_CONNRESET 
+#define SIO_UDP_CONNRESET _WSAIOW(IOC_VENDOR,12) 
+#endif
+
+void
+InitSockets(
+       void
+       )
+{
+       WORD wVersionRequested;
+       WSADATA wsaData;
+       int err;
+
+       /* Need Winsock 2.0 or better */
+       wVersionRequested = MAKEWORD(2, 0);
+       err = WSAStartup(wVersionRequested, &wsaData);
+       if ( err != 0 ) {
+               fprintf(stderr, "No useable winsock.dll: %s\n", strerror(err));
+               SetLastError(err);
+               msyslog(LOG_ERR, "No usable winsock.dll: %m");
+               exit(1);
+       }
+}
+
+/*
+ * Windows 2000 systems incorrectly cause UDP sockets using WASRecvFrom
+ * to not work correctly, returning a WSACONNRESET error when a WSASendTo
+ * fails with an "ICMP port unreachable" response and preventing the
+ * socket from using the WSARecvFrom in subsequent operations.
+ * The function below fixes this, but requires that Windows 2000
+ * Service Pack 2 or later be installed on the system.  NT 4.0
+ * systems are not affected by this and work correctly.
+ * See Microsoft Knowledge Base Article Q263823 for details of this.
+ */
+void
+connection_reset_fix(
+       SOCKET          fd,
+       sockaddr_u *    addr
+       )
+{
+       DWORD dw;
+       BOOL  bNewBehavior = FALSE;
+       DWORD status;
+
+       /*
+        * disable bad behavior using IOCTL: SIO_UDP_CONNRESET
+        * NT 4.0 has no problem
+        */
+       if (isc_win32os_majorversion() >= 5) {
+               status = WSAIoctl(fd, SIO_UDP_CONNRESET, &bNewBehavior,
+                                 sizeof(bNewBehavior), NULL, 0,
+                                 &dw, NULL, NULL);
+               if (SOCKET_ERROR == status)
+                       msyslog(LOG_ERR,
+                               "connection_reset_fix() failed for address %s: %m", 
+                               stoa(addr));
+       }
+}
+
index 1691ebf703078b45a1f80d1054ede8ac9e375960..1a1726ed4471d54f616cc5d85099afe51cb0e45f 100644 (file)
@@ -70,7 +70,7 @@
                        />
                        <Tool
                                Name="VCLinkerTool"
-                               OutputFile="../bin/Debug/Instsrv.exe"
+                               OutputFile="bin/Debug/Instsrv.exe"
                                LinkIncremental="2"
                                SuppressStartupBanner="true"
                                GenerateDebugInformation="true"
                        />
                        <Tool
                                Name="VCLinkerTool"
-                               OutputFile="../bin/Release/Instsrv.exe"
+                               OutputFile="bin/Release/Instsrv.exe"
                                LinkIncremental="1"
                                SuppressStartupBanner="true"
                                ProgramDatabaseFile=".\instsrv\Release/Instsrv.pdb"
index 67e5378df2c4a6256557398d4de536c193e1f2fe..196a3b870fb53e0b6efb6be490343c50a8e5ee0b 100644 (file)
@@ -3,7 +3,7 @@
        ProjectType="Visual C++"
        Version="8.00"
        Name="libntp"
-       ProjectGUID="{D696D740-D243-47C4-AFF8-151FB54D33CA}"
+       ProjectGUID="{ECDDC7EE-5805-4603-B38D-804C09BDC910}"
        >
        <Platforms>
                <Platform
                                RelativePath="..\..\..\lib\isc\task.c"
                                >
                        </File>
+                       <File
+                               RelativePath="..\libntp\termios.c"
+                               >
+                       </File>
                        <File
                                RelativePath="..\..\..\lib\isc\win32\thread.c"
                                >
                                        />
                                </FileConfiguration>
                        </File>
+                       <File
+                               RelativePath="..\libntp\win32_io.c"
+                               >
+                       </File>
                        <File
                                RelativePath="..\..\..\lib\isc\win32\win32os.c"
                                >
                                >
                        </File>
                        <File
-                               RelativePath="..\include\sys\time.h"
+                               RelativePath="..\..\..\lib\isc\win32\include\isc\time.h"
                                >
                        </File>
                        <File
-                               RelativePath="..\..\..\lib\isc\win32\include\isc\time.h"
+                               RelativePath="..\include\sys\time.h"
                                >
                        </File>
                        <File
                                >
                        </File>
                        <File
-                               RelativePath="..\..\..\lib\isc\include\isc\win32os.h"
+                               RelativePath="..\..\..\lib\isc\win32\include\isc\win32os.h"
                                >
                        </File>
                </Filter>
index 32b5e5ddb721ddb542dbba62945893a73e31cf33..6b840bed78b1d9f9a5576566dc877d9b1ceecc00 100644 (file)
@@ -1,4 +1,3 @@
-
 Microsoft Visual Studio Solution File, Format Version 9.00
 # Visual Studio 2005
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "instsrv", "Instsrv.vcproj", "{EAA8D0C8-A8AF-4C40-BF14-4A94570DE033}"
@@ -21,6 +20,9 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ntpdc", "ntpdc.vcproj", "{C
        EndProjectSection
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ntpkeygen", "ntpkeygen.vcproj", "{9B768B99-2BC8-4A4C-AC0D-A7DA9C695825}"
+       ProjectSection(ProjectDependencies) = postProject
+               {ECDDC7EE-5805-4603-B38D-804C09BDC910} = {ECDDC7EE-5805-4603-B38D-804C09BDC910}
+       EndProjectSection
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ntpq", "ntpq.vcproj", "{EA10E04E-946B-44A6-B0AB-B5B93A160744}"
        ProjectSection(ProjectDependencies) = postProject
index a417c1a9ddc7b7da1ea3de207a9edfcc16ab147f..19e0ef2f21c717bd5a101522829b2b71b99176a6 100644 (file)
@@ -3,7 +3,7 @@
        ProjectType="Visual C++"
        Version="8.00"
        Name="ntpd"
-       ProjectGUID="{DDAB6ECD-E9DF-46B2-8737-6DEF96ADA59A}"
+       ProjectGUID="{F6F7E7C0-AE5E-4D7C-A17E-A3043FE68664}"
        >
        <Platforms>
                <Platform
                                        />
                                </FileConfiguration>
                        </File>
-                       <File
-                               RelativePath="..\ntpd\win32_io.c"
-                               >
-                               <FileConfiguration
-                                       Name="Release|Win32"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               AdditionalIncludeDirectories=""
-                                               PreprocessorDefinitions=""
-                                       />
-                               </FileConfiguration>
-                               <FileConfiguration
-                                       Name="Debug|Win32"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               AdditionalIncludeDirectories=""
-                                               PreprocessorDefinitions=""
-                                       />
-                               </FileConfiguration>
-                       </File>
                </Filter>
                <Filter
                        Name="Header Files"
                                >
                        </File>
                        <File
-                               RelativePath="..\include\isc\win32os.h"
+                               RelativePath="..\..\..\lib\isc\win32\include\isc\win32os.h"
                                >
                        </File>
                </Filter>
index f91d1bcff8343a0f1aa233f4bf9e72764a2e4105..9a826398a26457263955d5fdd74a7c8d76a1fb6a 100644 (file)
                                RelativePath="..\..\libntp\util_clockstuff.c"
                                >
                        </File>
+                       <File
+                               RelativePath="..\..\..\..\libntp\win32\win32_io.c"
+                               >
+                       </File>
                        <File
                                RelativePath="..\..\..\..\lib\isc\win32\win32os.c"
                                >
                        </File>
+                       <File
+                               RelativePath="..\..\..\..\libntp\termios.c"
+                               >
+                       </File>
                        <File
                                RelativePath="..\..\..\..\libntp\ymd2yd.c"
                                >
index 23bccd44c8c17d8c9782c4e9bb94e8897e18fed4..b04ebfd47c47a2f49e1a0e3e006198acdacecfd9 100644 (file)
                                        />
                                </FileConfiguration>
                        </File>
-                       <File
-                               RelativePath="..\..\ntpd\win32_io.c"
-                               >
-                               <FileConfiguration
-                                       Name="Release|Win32"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               AdditionalIncludeDirectories=""
-                                               PreprocessorDefinitions=""
-                                       />
-                               </FileConfiguration>
-                               <FileConfiguration
-                                       Name="Debug|Win32"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               AdditionalIncludeDirectories=""
-                                               PreprocessorDefinitions=""
-                                       />
-                               </FileConfiguration>
-                       </File>
                </Filter>
                <Filter
                        Name="Header Files"