From: Zebediah Figura z.figura12@gmail.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/ntdll/unix/socket.c | 22 ++++++++++++++++++++++ dlls/ws2_32/socket.c | 27 ++++----------------------- include/wine/afd.h | 1 + 3 files changed, 27 insertions(+), 23 deletions(-)
diff --git a/dlls/ntdll/unix/socket.c b/dlls/ntdll/unix/socket.c index 24090c1a17b..c2cbaff24e1 100644 --- a/dlls/ntdll/unix/socket.c +++ b/dlls/ntdll/unix/socket.c @@ -1922,6 +1922,28 @@ NTSTATUS sock_ioctl( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc return ret ? sock_errno_to_status( errno ) : STATUS_SUCCESS; }
+#ifdef SOL_IPX + case IOCTL_AFD_WINE_GET_IPX_PTYPE: + return do_getsockopt( handle, io, SOL_IPX, IPX_TYPE, out_buffer, out_size ); +#elif defined(SO_DEFAULT_HEADERS) + case IOCTL_AFD_WINE_GET_IPX_PTYPE: + { + int fd, needs_close = FALSE; + struct ipx value; + socklen_t len = sizeof(value); + int ret; + + if ((status = server_get_unix_fd( handle, 0, &fd, &needs_close, NULL, NULL ))) + return status; + + ret = getsockopt( fd, 0, SO_DEFAULT_HEADERS, &value, &len ); + if (needs_close) close( fd ); + if (ret) return sock_errno_to_status( errno ); + *(DWORD *)out_buffer = value.ipx_pt; + return STATUS_SUCCESS; + } +#endif + default: { if ((code >> 16) == FILE_DEVICE_NETWORK) diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index a28c25ec697..71b5e9a8658 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -2158,7 +2158,7 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level, return SOCKET_ERROR; } /* end switch(optname) */ }/* end case WS_SOL_SOCKET */ -#ifdef HAS_IPX + case WS_NSPROTO_IPX: { struct WS_sockaddr_ipx addr; @@ -2166,27 +2166,6 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level, int namelen; switch(optname) { - case WS_IPX_PTYPE: - if ((fd = get_sock_fd( s, 0, NULL )) == -1) return SOCKET_ERROR; -#ifdef SOL_IPX - if(getsockopt(fd, SOL_IPX, IPX_TYPE, optval, (socklen_t *)optlen) == -1) - { - ret = SOCKET_ERROR; - } -#else - { - struct ipx val; - socklen_t len=sizeof(struct ipx); - if(getsockopt(fd, 0, SO_DEFAULT_HEADERS, &val, &len) == -1 ) - ret = SOCKET_ERROR; - else - *optval = (int)val.ipx_pt; - } -#endif - TRACE("ptype: %d (fd: %d)\n", *(int*)optval, fd); - release_sock_fd( s, fd ); - return ret; - case WS_IPX_ADDRESS: /* * On a Win2000 system with one network card there are usually @@ -2217,12 +2196,14 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level, *(int*)optval = 1; /* As noted under IPX_ADDRESS we have just one card. */ return 0;
+ case WS_IPX_PTYPE: + return server_getsockopt( s, IOCTL_AFD_WINE_GET_IPX_PTYPE, optval, optlen ); + default: FIXME("IPX optname:%x\n", optname); return SOCKET_ERROR; }/* end switch(optname) */ } /* end case WS_NSPROTO_IPX */ -#endif
#ifdef HAS_IRDA #define MAX_IRDA_DEVICES 10 diff --git a/include/wine/afd.h b/include/wine/afd.h index 9a1edb1fda6..6630a6402fc 100644 --- a/include/wine/afd.h +++ b/include/wine/afd.h @@ -223,6 +223,7 @@ struct afd_get_events_params #define IOCTL_AFD_WINE_SET_IPV6_UNICAST_IF WINE_AFD_IOC(278) #define IOCTL_AFD_WINE_GET_IPV6_V6ONLY WINE_AFD_IOC(279) #define IOCTL_AFD_WINE_SET_IPV6_V6ONLY WINE_AFD_IOC(280) +#define IOCTL_AFD_WINE_GET_IPX_PTYPE WINE_AFD_IOC(281)
struct afd_create_params {
From: Zebediah Figura z.figura12@gmail.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/ntdll/unix/socket.c | 12 ++++++++++++ dlls/ws2_32/socket.c | 40 +--------------------------------------- include/wine/afd.h | 1 + 3 files changed, 14 insertions(+), 39 deletions(-)
diff --git a/dlls/ntdll/unix/socket.c b/dlls/ntdll/unix/socket.c index c2cbaff24e1..a63209e6ae6 100644 --- a/dlls/ntdll/unix/socket.c +++ b/dlls/ntdll/unix/socket.c @@ -1925,6 +1925,9 @@ NTSTATUS sock_ioctl( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc #ifdef SOL_IPX case IOCTL_AFD_WINE_GET_IPX_PTYPE: return do_getsockopt( handle, io, SOL_IPX, IPX_TYPE, out_buffer, out_size ); + + case IOCTL_AFD_WINE_SET_IPX_PTYPE: + return do_setsockopt( handle, io, SOL_IPX, IPX_TYPE, in_buffer, in_size ); #elif defined(SO_DEFAULT_HEADERS) case IOCTL_AFD_WINE_GET_IPX_PTYPE: { @@ -1942,6 +1945,15 @@ NTSTATUS sock_ioctl( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc *(DWORD *)out_buffer = value.ipx_pt; return STATUS_SUCCESS; } + + case IOCTL_AFD_WINE_SET_IPX_PTYPE: + { + struct ipx value = {0}; + + /* FIXME: should we retrieve SO_DEFAULT_HEADERS first and modify it? */ + value.ipx_pt = *(DWORD *)in_buffer; + return do_setsockopt( handle, io, 0, SO_DEFAULT_HEADERS, &value, sizeof(value) ); + } #endif
default: diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index 71b5e9a8658..da45734803c 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -825,42 +825,6 @@ convert_socktype_u2w(int unixsocktype) { return -1; }
-static int set_ipx_packettype(int sock, int ptype) -{ -#ifdef HAS_IPX - int fd = get_sock_fd( sock, 0, NULL ), ret = 0; - TRACE("trying to set IPX_PTYPE: %d (fd: %d)\n", ptype, fd); - - if (fd == -1) return SOCKET_ERROR; - - /* We try to set the ipx type on ipx socket level. */ -#ifdef SOL_IPX - if(setsockopt(fd, SOL_IPX, IPX_TYPE, &ptype, sizeof(ptype)) == -1) - { - ERR("IPX: could not set ipx option type; expect weird behaviour\n"); - ret = SOCKET_ERROR; - } -#else - { - struct ipx val; - /* Should we retrieve val using a getsockopt call and then - * set the modified one? */ - val.ipx_pt = ptype; - setsockopt(fd, 0, SO_DEFAULT_HEADERS, &val, sizeof(struct ipx)); - } -#endif - release_sock_fd( sock, fd ); - return ret; -#else - WARN("IPX support is not enabled, can't set packet type\n"); - return SOCKET_ERROR; -#endif -} - -/* ----------------------------------- API ----- - * - * Init / cleanup / error checking. - */
/*********************************************************************** * WSAStartup (WS2_32.115) @@ -3453,12 +3417,11 @@ int WINAPI WS_setsockopt(SOCKET s, int level, int optname, } break; /* case WS_SOL_SOCKET */
-#ifdef HAS_IPX case WS_NSPROTO_IPX: switch(optname) { case WS_IPX_PTYPE: - return set_ipx_packettype(s, *(int*)optval); + return server_setsockopt( s, IOCTL_AFD_WINE_SET_IPX_PTYPE, optval, optlen );
case WS_IPX_FILTERPTYPE: /* Sets the receive filter packet type, at the moment we don't support it */ @@ -3471,7 +3434,6 @@ int WINAPI WS_setsockopt(SOCKET s, int level, int optname, return SOCKET_ERROR; } break; /* case WS_NSPROTO_IPX */ -#endif
/* Levels WS_IPPROTO_TCP and WS_IPPROTO_IP convert directly */ case WS_IPPROTO_TCP: diff --git a/include/wine/afd.h b/include/wine/afd.h index 6630a6402fc..4db6525a7d8 100644 --- a/include/wine/afd.h +++ b/include/wine/afd.h @@ -224,6 +224,7 @@ struct afd_get_events_params #define IOCTL_AFD_WINE_GET_IPV6_V6ONLY WINE_AFD_IOC(279) #define IOCTL_AFD_WINE_SET_IPV6_V6ONLY WINE_AFD_IOC(280) #define IOCTL_AFD_WINE_GET_IPX_PTYPE WINE_AFD_IOC(281) +#define IOCTL_AFD_WINE_SET_IPX_PTYPE WINE_AFD_IOC(282)
struct afd_create_params {
From: Zebediah Figura z.figura12@gmail.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/ntdll/unix/socket.c | 43 ++++++++++++++++++++++++++++ dlls/ws2_32/socket.c | 60 +--------------------------------------- include/wine/afd.h | 1 + 3 files changed, 45 insertions(+), 59 deletions(-)
diff --git a/dlls/ntdll/unix/socket.c b/dlls/ntdll/unix/socket.c index a63209e6ae6..7fc41ff9f1a 100644 --- a/dlls/ntdll/unix/socket.c +++ b/dlls/ntdll/unix/socket.c @@ -1956,6 +1956,49 @@ NTSTATUS sock_ioctl( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc } #endif
+#ifdef HAS_IRDA +#define MAX_IRDA_DEVICES 10 + case IOCTL_AFD_WINE_GET_IRLMP_ENUMDEVICES: + { + char buffer[offsetof( struct irda_device_list, dev[MAX_IRDA_DEVICES] )]; + struct irda_device_list *unix_list = (struct irda_device_list *)buffer; + socklen_t len = sizeof(buffer); + DEVICELIST *ws_list = out_buffer; + int fd, needs_close = FALSE; + NTSTATUS status; + unsigned int i; + int ret; + + if ((status = server_get_unix_fd( handle, 0, &fd, &needs_close, NULL, NULL ))) + return status; + + ret = getsockopt( fd, SOL_IRLMP, IRLMP_ENUMDEVICES, buffer, &len ); + if (needs_close) close( fd ); + if (ret) return sock_errno_to_status( errno ); + + io->Information = offsetof( DEVICELIST, unix_list->len ); + if (out_size < io->Information) + return STATUS_BUFFER_TOO_SMALL; + + TRACE( "IRLMP_ENUMDEVICES: got %u devices:\n", unix_list->len ); + ws_list->numDevice = unix_list->len; + for (i = 0; i < unix_list->len; ++i) + { + const struct irda_device_info *unix_dev = &unix_list->dev[i]; + IRDA_DEVICE_INFO *ws_dev = &ws_list->Device[i]; + + TRACE( "saddr %#08x, daddr %#08x, info %s, hints 0x%02x%02x\n", + unix_dev->saddr, unix_dev->daddr, unix_dev->info, unix_dev->hints[0], unix_dev->hints[1] ); + memcpy( ws_dev->irdaDeviceID, &unix_dev->daddr, sizeof(unix_dev->daddr) ); + memcpy( ws_dev->irdaDeviceName, unix_dev->info, sizeof(unix_dev->info) ); + ws_dev->irdaDeviceHints1 = unix_dev->hints[0]; + ws_dev->irdaDeviceHints2 = unix_dev->hints[1]; + ws_dev->irdaCharSet = unix_dev->charset; + } + return STATUS_SUCCESS; + } +#endif + default: { if ((code >> 16) == FILE_DEVICE_NETWORK) diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index da45734803c..7da975167ee 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -2169,75 +2169,17 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level, }/* end switch(optname) */ } /* end case WS_NSPROTO_IPX */
-#ifdef HAS_IRDA -#define MAX_IRDA_DEVICES 10 - case WS_SOL_IRLMP: switch(optname) { case WS_IRLMP_ENUMDEVICES: - { - char buf[sizeof(struct irda_device_list) + - (MAX_IRDA_DEVICES - 1) * sizeof(struct irda_device_info)]; - int res; - socklen_t len = sizeof(buf); + return server_getsockopt( s, IOCTL_AFD_WINE_GET_IRLMP_ENUMDEVICES, optval, optlen );
- if ( (fd = get_sock_fd( s, 0, NULL )) == -1) - return SOCKET_ERROR; - res = getsockopt( fd, SOL_IRLMP, IRLMP_ENUMDEVICES, buf, &len ); - release_sock_fd( s, fd ); - if (res < 0) - { - SetLastError(wsaErrno()); - return SOCKET_ERROR; - } - else - { - struct irda_device_list *src = (struct irda_device_list *)buf; - DEVICELIST *dst = (DEVICELIST *)optval; - INT needed = sizeof(DEVICELIST); - unsigned int i; - - if (src->len > 0) - needed += (src->len - 1) * sizeof(IRDA_DEVICE_INFO); - if (*optlen < needed) - { - SetLastError(WSAEFAULT); - return SOCKET_ERROR; - } - *optlen = needed; - TRACE("IRLMP_ENUMDEVICES: %d devices found:\n", src->len); - dst->numDevice = src->len; - for (i = 0; i < src->len; i++) - { - TRACE("saddr = %08x, daddr = %08x, info = %s, hints = %02x%02x\n", - src->dev[i].saddr, src->dev[i].daddr, - src->dev[i].info, src->dev[i].hints[0], - src->dev[i].hints[1]); - memcpy( dst->Device[i].irdaDeviceID, - &src->dev[i].daddr, - sizeof(dst->Device[i].irdaDeviceID) ) ; - memcpy( dst->Device[i].irdaDeviceName, - src->dev[i].info, - sizeof(dst->Device[i].irdaDeviceName) ) ; - memcpy( &dst->Device[i].irdaDeviceHints1, - &src->dev[i].hints[0], - sizeof(dst->Device[i].irdaDeviceHints1) ) ; - memcpy( &dst->Device[i].irdaDeviceHints2, - &src->dev[i].hints[1], - sizeof(dst->Device[i].irdaDeviceHints2) ) ; - dst->Device[i].irdaCharSet = src->dev[i].charset; - } - return 0; - } - } default: FIXME("IrDA optname:0x%x\n", optname); return SOCKET_ERROR; } break; /* case WS_SOL_IRLMP */ -#undef MAX_IRDA_DEVICES -#endif
/* Levels WS_IPPROTO_TCP and WS_IPPROTO_IP convert directly */ case WS_IPPROTO_TCP: diff --git a/include/wine/afd.h b/include/wine/afd.h index 4db6525a7d8..6e601f60095 100644 --- a/include/wine/afd.h +++ b/include/wine/afd.h @@ -225,6 +225,7 @@ struct afd_get_events_params #define IOCTL_AFD_WINE_SET_IPV6_V6ONLY WINE_AFD_IOC(280) #define IOCTL_AFD_WINE_GET_IPX_PTYPE WINE_AFD_IOC(281) #define IOCTL_AFD_WINE_SET_IPX_PTYPE WINE_AFD_IOC(282) +#define IOCTL_AFD_WINE_GET_IRLMP_ENUMDEVICES WINE_AFD_IOC(283)
struct afd_create_params {
From: Zebediah Figura z.figura12@gmail.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/ntdll/unix/socket.c | 3 +++ dlls/ws2_32/socket.c | 19 ++++++------------- include/wine/afd.h | 1 + 3 files changed, 10 insertions(+), 13 deletions(-)
diff --git a/dlls/ntdll/unix/socket.c b/dlls/ntdll/unix/socket.c index 7fc41ff9f1a..86e415f5dce 100644 --- a/dlls/ntdll/unix/socket.c +++ b/dlls/ntdll/unix/socket.c @@ -1999,6 +1999,9 @@ NTSTATUS sock_ioctl( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc } #endif
+ case IOCTL_AFD_WINE_GET_TCP_NODELAY: + return do_getsockopt( handle, io, IPPROTO_TCP, TCP_NODELAY, out_buffer, out_size ); + default: { if ((code >> 16) == FILE_DEVICE_NETWORK) diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index 7da975167ee..ab1578ebed4 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -1880,7 +1880,6 @@ static int server_getsockopt( SOCKET s, ULONG code, char *optval, int *optlen ) INT WINAPI WS_getsockopt(SOCKET s, INT level, INT optname, char *optval, INT *optlen) { - int fd; INT ret = 0;
TRACE("(socket %04lx, %s, optval %s, optlen %p (%d))\n", s, @@ -2186,19 +2185,13 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level, switch(optname) { case WS_TCP_NODELAY: - if ( (fd = get_sock_fd( s, 0, NULL )) == -1) - return SOCKET_ERROR; - convert_sockopt(&level, &optname); - if (getsockopt(fd, level, optname, optval, (socklen_t *)optlen) != 0 ) - { - SetLastError(wsaErrno()); - ret = SOCKET_ERROR; - } - release_sock_fd( s, fd ); - return ret; + return server_getsockopt( s, IOCTL_AFD_WINE_GET_TCP_NODELAY, optval, optlen ); + + default: + FIXME( "unrecognized TCP option %#x\n", optname ); + SetLastError( WSAENOPROTOOPT ); + return -1; } - FIXME("Unknown IPPROTO_TCP optname 0x%08x\n", optname); - return SOCKET_ERROR;
case WS_IPPROTO_IP: switch(optname) diff --git a/include/wine/afd.h b/include/wine/afd.h index 6e601f60095..c826351ff4c 100644 --- a/include/wine/afd.h +++ b/include/wine/afd.h @@ -226,6 +226,7 @@ struct afd_get_events_params #define IOCTL_AFD_WINE_GET_IPX_PTYPE WINE_AFD_IOC(281) #define IOCTL_AFD_WINE_SET_IPX_PTYPE WINE_AFD_IOC(282) #define IOCTL_AFD_WINE_GET_IRLMP_ENUMDEVICES WINE_AFD_IOC(283) +#define IOCTL_AFD_WINE_GET_TCP_NODELAY WINE_AFD_IOC(284)
struct afd_create_params {
From: Zebediah Figura z.figura12@gmail.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/ntdll/unix/socket.c | 3 + dlls/ws2_32/socket.c | 185 +-------------------------------------- include/wine/afd.h | 1 + 3 files changed, 6 insertions(+), 183 deletions(-)
diff --git a/dlls/ntdll/unix/socket.c b/dlls/ntdll/unix/socket.c index 86e415f5dce..0e52db178d8 100644 --- a/dlls/ntdll/unix/socket.c +++ b/dlls/ntdll/unix/socket.c @@ -2002,6 +2002,9 @@ NTSTATUS sock_ioctl( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc case IOCTL_AFD_WINE_GET_TCP_NODELAY: return do_getsockopt( handle, io, IPPROTO_TCP, TCP_NODELAY, out_buffer, out_size );
+ case IOCTL_AFD_WINE_SET_TCP_NODELAY: + return do_setsockopt( handle, io, IPPROTO_TCP, TCP_NODELAY, in_buffer, in_size ); + default: { if ((code >> 16) == FILE_DEVICE_NETWORK) diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index ab1578ebed4..f7996410db1 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -31,10 +31,6 @@
#include "ws2_32_private.h"
-#if defined(linux) && !defined(IP_UNICAST_IF) -#define IP_UNICAST_IF 50 -#endif - #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) # define sipx_network sipx_addr.x_net # define sipx_node sipx_addr.x_host.c_host @@ -428,80 +424,6 @@ static int ws_protocol_info(SOCKET s, int unicode, WSAPROTOCOL_INFOW *buffer, in
#define MAP_OPTION(opt) { WS_##opt, opt }
-static const int ws_sock_map[][2] = -{ - MAP_OPTION( SO_DEBUG ), - MAP_OPTION( SO_ACCEPTCONN ), - MAP_OPTION( SO_REUSEADDR ), - MAP_OPTION( SO_KEEPALIVE ), - MAP_OPTION( SO_DONTROUTE ), - MAP_OPTION( SO_BROADCAST ), - MAP_OPTION( SO_LINGER ), - MAP_OPTION( SO_OOBINLINE ), - MAP_OPTION( SO_SNDBUF ), - MAP_OPTION( SO_RCVBUF ), - MAP_OPTION( SO_ERROR ), - MAP_OPTION( SO_TYPE ), -#ifdef SO_RCVTIMEO - MAP_OPTION( SO_RCVTIMEO ), -#endif -#ifdef SO_SNDTIMEO - MAP_OPTION( SO_SNDTIMEO ), -#endif -}; - -static const int ws_tcp_map[][2] = -{ -#ifdef TCP_NODELAY - MAP_OPTION( TCP_NODELAY ), -#endif -}; - -static const int ws_ip_map[][2] = -{ - MAP_OPTION( IP_MULTICAST_IF ), - MAP_OPTION( IP_MULTICAST_TTL ), - MAP_OPTION( IP_MULTICAST_LOOP ), - MAP_OPTION( IP_ADD_MEMBERSHIP ), - MAP_OPTION( IP_DROP_MEMBERSHIP ), - MAP_OPTION( IP_ADD_SOURCE_MEMBERSHIP ), - MAP_OPTION( IP_DROP_SOURCE_MEMBERSHIP ), - MAP_OPTION( IP_BLOCK_SOURCE ), - MAP_OPTION( IP_UNBLOCK_SOURCE ), - MAP_OPTION( IP_OPTIONS ), -#ifdef IP_HDRINCL - MAP_OPTION( IP_HDRINCL ), -#endif - MAP_OPTION( IP_TOS ), - MAP_OPTION( IP_TTL ), -#if defined(IP_PKTINFO) - MAP_OPTION( IP_PKTINFO ), -#elif defined(IP_RECVDSTADDR) - { WS_IP_PKTINFO, IP_RECVDSTADDR }, -#endif -#ifdef IP_UNICAST_IF - MAP_OPTION( IP_UNICAST_IF ), -#endif -}; - -static const int ws_ipv6_map[][2] = -{ -#ifdef IPV6_ADD_MEMBERSHIP - MAP_OPTION( IPV6_ADD_MEMBERSHIP ), -#endif -#ifdef IPV6_DROP_MEMBERSHIP - MAP_OPTION( IPV6_DROP_MEMBERSHIP ), -#endif - MAP_OPTION( IPV6_MULTICAST_IF ), - MAP_OPTION( IPV6_MULTICAST_HOPS ), - MAP_OPTION( IPV6_MULTICAST_LOOP ), - MAP_OPTION( IPV6_UNICAST_HOPS ), - MAP_OPTION( IPV6_V6ONLY ), -#ifdef IPV6_UNICAST_IF - MAP_OPTION( IPV6_UNICAST_IF ), -#endif -}; - static const int ws_socktype_map[][2] = { MAP_OPTION( SOCK_DGRAM ), @@ -578,14 +500,6 @@ UINT sock_get_error( int err ) } }
-static UINT wsaErrno(void) -{ - int loc_errno = errno; - WARN("errno %d, (%s).\n", loc_errno, strerror(loc_errno)); - - return sock_get_error( loc_errno ); -} - static DWORD NtStatusToWSAError( NTSTATUS status ) { static const struct @@ -743,66 +657,6 @@ BOOL WINAPI DllMain( HINSTANCE instance, DWORD reason, void *reserved ) return TRUE; }
-/*********************************************************************** - * convert_sockopt() - * - * Converts socket flags from Windows format. - * Return 1 if converted, 0 if not (error). - */ -static int convert_sockopt(INT *level, INT *optname) -{ - unsigned int i; - switch (*level) - { - case WS_SOL_SOCKET: - *level = SOL_SOCKET; - for(i = 0; i < ARRAY_SIZE(ws_sock_map); i++) { - if( ws_sock_map[i][0] == *optname ) - { - *optname = ws_sock_map[i][1]; - return 1; - } - } - FIXME("Unknown SOL_SOCKET optname 0x%x\n", *optname); - break; - case WS_IPPROTO_TCP: - *level = IPPROTO_TCP; - for(i = 0; i < ARRAY_SIZE(ws_tcp_map); i++) { - if ( ws_tcp_map[i][0] == *optname ) - { - *optname = ws_tcp_map[i][1]; - return 1; - } - } - FIXME("Unknown IPPROTO_TCP optname 0x%x\n", *optname); - break; - case WS_IPPROTO_IP: - *level = IPPROTO_IP; - for(i = 0; i < ARRAY_SIZE(ws_ip_map); i++) { - if (ws_ip_map[i][0] == *optname ) - { - *optname = ws_ip_map[i][1]; - return 1; - } - } - FIXME("Unknown IPPROTO_IP optname 0x%x\n", *optname); - break; - case WS_IPPROTO_IPV6: - *level = IPPROTO_IPV6; - for(i = 0; i < ARRAY_SIZE(ws_ipv6_map); i++) { - if (ws_ipv6_map[i][0] == *optname ) - { - *optname = ws_ipv6_map[i][1]; - return 1; - } - } - FIXME("Unknown IPPROTO_IPV6 optname 0x%x\n", *optname); - break; - default: FIXME("Unimplemented or unknown socket level\n"); - } - return 0; -} - int convert_socktype_w2u(int windowssocktype) { unsigned int i; @@ -3219,9 +3073,6 @@ static int server_setsockopt( SOCKET s, ULONG code, const char *optval, int optl int WINAPI WS_setsockopt(SOCKET s, int level, int optname, const char *optval, int optlen) { - int fd; - int woptval; - TRACE("(socket %04lx, %s, optval %s, optlen %d)\n", s, debugstr_sockopt(level, optname), debugstr_optval(optval, optlen), optlen); @@ -3370,13 +3221,12 @@ int WINAPI WS_setsockopt(SOCKET s, int level, int optname, } break; /* case WS_NSPROTO_IPX */
- /* Levels WS_IPPROTO_TCP and WS_IPPROTO_IP convert directly */ case WS_IPPROTO_TCP: switch(optname) { case WS_TCP_NODELAY: - convert_sockopt(&level, &optname); - break; + return server_setsockopt( s, IOCTL_AFD_WINE_SET_TCP_NODELAY, optval, optlen ); + default: FIXME("Unknown IPPROTO_TCP optname 0x%08x\n", optname); return SOCKET_ERROR; @@ -3485,37 +3335,6 @@ int WINAPI WS_setsockopt(SOCKET s, int level, int optname, SetLastError(WSAEINVAL); return SOCKET_ERROR; } /* end switch(level) */ - - /* avoid endianness issues if argument is a 16-bit int */ - if (optval && optlen < sizeof(int)) - { - woptval= *((const INT16 *) optval); - optval= (char*) &woptval; - woptval&= (1 << optlen * 8) - 1; - optlen=sizeof(int); - } - fd = get_sock_fd( s, 0, NULL ); - if (fd == -1) return SOCKET_ERROR; - - if (setsockopt(fd, level, optname, optval, optlen) == 0) - { -#ifdef __APPLE__ - if (level == SOL_SOCKET && optname == SO_REUSEADDR && - setsockopt(fd, level, SO_REUSEPORT, optval, optlen) != 0) - { - SetLastError(wsaErrno()); - release_sock_fd( s, fd ); - return SOCKET_ERROR; - } -#endif - release_sock_fd( s, fd ); - return 0; - } - TRACE("Setting socket error, %d\n", wsaErrno()); - SetLastError(wsaErrno()); - release_sock_fd( s, fd ); - - return SOCKET_ERROR; }
diff --git a/include/wine/afd.h b/include/wine/afd.h index c826351ff4c..1c5f8020c2c 100644 --- a/include/wine/afd.h +++ b/include/wine/afd.h @@ -227,6 +227,7 @@ struct afd_get_events_params #define IOCTL_AFD_WINE_SET_IPX_PTYPE WINE_AFD_IOC(282) #define IOCTL_AFD_WINE_GET_IRLMP_ENUMDEVICES WINE_AFD_IOC(283) #define IOCTL_AFD_WINE_GET_TCP_NODELAY WINE_AFD_IOC(284) +#define IOCTL_AFD_WINE_SET_TCP_NODELAY WINE_AFD_IOC(285)
struct afd_create_params {