[PATCH] Add SIO_KEEPALIVE_VALS support to winsock

Couriousous couriousous at mandriva.org
Sun May 4 07:50:33 CDT 2008


Hello

When Altium 6 is used with a license server, it need the WSAIoctl() with 
SIO_KEEPALIVE_VALS control code to succeed, otherwise it cannot connect 
to the license server.

The following patch implement the missing parts and allow altium 6 to 
works perfectly with wine !

Regards,
Philippe

---

Index: dlls/ws2_32/socket.c
===================================================================
--- dlls/ws2_32/socket.c
+++ dlls/ws2_32/socket.c	2008-05-04 13:53:50.000000000 +0200
@@ -2292,6 +2292,48 @@
        WSASetLastError(WSAEOPNOTSUPP);
        return SOCKET_ERROR;
 
+   case WS_SIO_KEEPALIVE_VALS:
+       if(lpvInBuffer) {
+	       int fd;
+	       struct tcp_keepalive  *d = lpvInBuffer;
+	       int idle = d->keepalivetime / 1000;
+	       int interv = d->keepaliveinterval / 1000;
+	       int enable = d->onoff ? 1: 0;
+	       TRACE("socket %04lx, keepalivetime: %d, keepaliveinterval: %d\n", s, idle, interv);
+	       if(idle == 0 || interv == 0) {
+		       WSASetLastError(WSAEINVAL);
+		       return SOCKET_ERROR;
+	       }
+	       fd = get_sock_fd( s, 0, NULL );
+	       if(setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (void *) &enable, 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 *) &idle, sizeof(int)) == -1) {
+		       release_sock_fd( s, fd );
+		       WSASetLastError(WSAEINVAL);
+		       return SOCKET_ERROR;
+	       }
+
+	       if(setsockopt(fd, IPPROTO_TCP, TCP_KEEPINTVL, (void *) &interv, sizeof(int)) == -1) {
+		       release_sock_fd( s, fd );
+		       WSASetLastError(WSAEINVAL);
+		       return SOCKET_ERROR;
+	       }
+#else
+	       FIXME("Ignoreing keepalive interval and timeout");
+#endif
+	       release_sock_fd( s, fd );
+	       break;
+       } else {
+	       WSASetLastError(WSAEINVAL);
+               return SOCKET_ERROR;
+       }
+
+       break;
+
    default:
        FIXME("unsupported WS_IOCTL cmd (%08x)\n", dwIoControlCode);
        WSASetLastError(WSAEOPNOTSUPP);
Index: include/winsock2.h
===================================================================
--- include/winsock2.h
+++ include/winsock2.h	2008-05-03 22:45:08.000000000 +0200
@@ -142,6 +142,7 @@
 #define WS_SIO_ADDRESS_LIST_CHANGE            _WSAIO(WS_IOC_WS2,23)
 #define WS_SIO_QUERY_TARGET_PNP_HANDLE        _WSAIOR(WS_IOC_WS2,24)
 #define WS_SIO_GET_INTERFACE_LIST             WS__IOR('t', 127, WS_u_long)
+#define WS_SIO_KEEPALIVE_VALS 		      _WSAIOW(WS_IOC_VENDOR,4) 
 #else /* USE_WS_PREFIX */
 #undef IOC_VOID
 #undef IOC_IN
@@ -178,8 +179,16 @@
 #define SIO_ADDRESS_LIST_CHANGE    _WSAIO(IOC_WS2,23)
 #define SIO_QUERY_TARGET_PNP_HANDLE _WSAIOR(IOC_WS2,24)
 #define SIO_GET_INTERFACE_LIST     _IOR ('t', 127, u_long)
+#define SIO_KEEPALIVE_VALS 	   _WSAIOW(IOC_VENDOR,4) 
 #endif /* USE_WS_PREFIX */
 
+/* Argument structure for SIO_KEEPALIVE_VALS */
+struct tcp_keepalive {
+	u_long  onoff;
+	u_long  keepalivetime;
+	u_long  keepaliveinterval;
+};
+
 /* Constants for WSAIoctl() */
 #define WSA_FLAG_OVERLAPPED        0x01
 #define WSA_FLAG_MULTIPOINT_C_ROOT 0x02




More information about the wine-devel mailing list