ws2_32: Implement WSAIoctl(SIO_KEEPALIVE_VALS).
Hans Leidekker
hans at codeweavers.com
Mon Dec 8 07:27:24 CST 2008
Based on a patch by Philippe Rétornaz.
-Hans
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index bc971f1..6a32555 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -132,6 +132,7 @@
#include "ws2tcpip.h"
#include "ws2spi.h"
#include "wsipx.h"
+#include "mstcpip.h"
#include "winnt.h"
#include "iphlpapi.h"
#include "wine/server.h"
@@ -2317,6 +2318,49 @@ INT WINAPI WSAIoctl(SOCKET s,
WSASetLastError(WSAEOPNOTSUPP);
return SOCKET_ERROR;
+ case WS_SIO_KEEPALIVE_VALS:
+ {
+ int fd;
+ struct tcp_keepalive *k = lpvInBuffer;
+ int keepalive = k->onoff ? 1 : 0;
+ int keepidle = k->keepalivetime / 1000;
+ int keepintvl = k->keepaliveinterval / 1000;
+
+ if (!lpvInBuffer)
+ {
+ WSASetLastError(WSAEINVAL);
+ return SOCKET_ERROR;
+ }
+
+ TRACE("onoff: %d, keepalivetime: %d, keepaliveinterval: %d\n", keepalive, keepidle, keepintvl);
+
+ fd = get_sock_fd(s, 0, NULL);
+ if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (void *)&keepalive, sizeof(int)) == -1)
+ {
+ release_sock_fd(s, fd);
+ WSASetLastError(WSAEINVAL);
+ return SOCKET_ERROR;
+ }
+#if defined(TCP_KEEPIDLE) && defined(TCP_KEEPINTVL)
+ if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, (void *)&keepidle, sizeof(int)) == -1)
+ {
+ release_sock_fd(s, fd);
+ WSASetLastError(WSAEINVAL);
+ return SOCKET_ERROR;
+ }
+ if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPINTVL, (void *)&keepintvl, sizeof(int)) == -1)
+ {
+ release_sock_fd(s, fd);
+ WSASetLastError(WSAEINVAL);
+ return SOCKET_ERROR;
+ }
+#else
+ FIXME("ignoring keepalive interval and timeout\n");
+#endif
+
+ release_sock_fd(s, fd);
+ break;
+ }
default:
FIXME("unsupported WS_IOCTL cmd (%08x)\n", dwIoControlCode);
WSASetLastError(WSAEOPNOTSUPP);
diff --git a/include/mstcpip.h b/include/mstcpip.h
new file mode 100644
index 0000000..25dcfe1
--- /dev/null
+++ b/include/mstcpip.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2008 Hans Leidekker for CodeWeavers.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+struct tcp_keepalive
+{
+ u_long onoff;
+ u_long keepalivetime;
+ u_long keepaliveinterval;
+};
+
+#ifndef USE_WS_PREFIX
+
+#define SIO_RCVALL _WSAIOW(IOC_VENDOR, 1)
+#define SIO_RCVALL_MCAST _WSAIOW(IOC_VENDOR, 2)
+#define SIO_RCVALL_IGMPMCAST _WSAIOW(IOC_VENDOR, 3)
+#define SIO_KEEPALIVE_VALS _WSAIOW(IOC_VENDOR, 4)
+#define SIO_ABSORB_RTRALERT _WSAIOW(IOC_VENDOR, 5)
+#define SIO_UCAST_IF _WSAIOW(IOC_VENDOR, 6)
+#define SIO_LIMIT_BROADCASTS _WSAIOW(IOC_VENDOR, 7)
+#define SIO_INDEX_BIND _WSAIOW(IOC_VENDOR, 8)
+#define SIO_INDEX_MCASTIF _WSAIOW(IOC_VENDOR, 9)
+#define SIO_INDEX_ADD_MCAST _WSAIOW(IOC_VENDOR, 10)
+#define SIO_INDEX_DEL_MCAST _WSAIOW(IOC_VENDOR, 11)
+
+#define RCVALL_OFF 0
+#define RCVALL_ON 1
+#define RCVALL_SOCKETLEVELONLY 2
+
+#else
+
+#define WS_SIO_RCVALL _WSAIOW(WS_IOC_VENDOR, 1)
+#define WS_SIO_RCVALL_MCAST _WSAIOW(WS_IOC_VENDOR, 2)
+#define WS_SIO_RCVALL_IGMPMCAST _WSAIOW(WS_IOC_VENDOR, 3)
+#define WS_SIO_KEEPALIVE_VALS _WSAIOW(WS_IOC_VENDOR, 4)
+#define WS_SIO_ABSORB_RTRALERT _WSAIOW(WS_IOC_VENDOR, 5)
+#define WS_SIO_UCAST_IF _WSAIOW(WS_IOC_VENDOR, 6)
+#define WS_SIO_LIMIT_BROADCASTS _WSAIOW(WS_IOC_VENDOR, 7)
+#define WS_SIO_INDEX_BIND _WSAIOW(WS_IOC_VENDOR, 8)
+#define WS_SIO_INDEX_MCASTIF _WSAIOW(WS_IOC_VENDOR, 9)
+#define WS_SIO_INDEX_ADD_MCAST _WSAIOW(WS_IOC_VENDOR, 10)
+#define WS_SIO_INDEX_DEL_MCAST _WSAIOW(WS_IOC_VENDOR, 11)
+
+#define WS_RCVALL_OFF 0
+#define WS_RCVALL_ON 1
+#define WS_RCVALL_SOCKETLEVELONLY 2
+
+#endif /* USE_WS_PREFIX */
More information about the wine-patches
mailing list