#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
-#ifndef WIN32_IO_H
-#define WIN32_IO_H
+#ifndef _TERMIOS_H
+#define _TERMIOS_H
/* Flag definitions for compatibility
* ==================================
extern int tcsetattr (int, int, const struct termios *);
extern int tcgetattr (int, struct termios *);
-#endif /* defined WIN32_IO_H */
+#endif
--- /dev/null
+#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 */
+;
#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"
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);
- }
-}
--- /dev/null
+/* 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));
+ }
+}
+
/>
<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"
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>
-
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}"
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
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>
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"
>
/>
</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"