Signed-off-by: Alex Henrie alexhenrie24@gmail.com --- v3: Use %Iu instead of %zu --- dlls/ws2_32/tests/sock.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index 8cbb393b542..ec8a3b0481b 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -2032,11 +2032,11 @@ static void test_ipv6_cmsg(void) ok(rc == sizeof(payload), "send failed, error %u\n", WSAGetLastError()); rc = pWSARecvMsg(server, &msg, &count, NULL, NULL); ok(!rc, "WSARecvMsg failed, error %u\n", WSAGetLastError()); - ok(count == sizeof(payload), "expected length %i, got %i\n", (INT)sizeof(payload), count); + ok(count == sizeof(payload), "expected length %Iu, got %u\n", sizeof(payload), count); ok(header->cmsg_level == IPPROTO_IPV6, "expected IPPROTO_IPV6, got %i\n", header->cmsg_level); ok(header->cmsg_type == IPV6_HOPLIMIT, "expected IPV6_HOPLIMIT, got %i\n", header->cmsg_type); ok(header->cmsg_len == sizeof(*header) + sizeof(INT), - "expected length %i, got %i\n", (INT)(sizeof(*header) + sizeof(INT)), (INT)header->cmsg_len); + "expected length %Iu, got %Iu\n", sizeof(*header) + sizeof(INT), header->cmsg_len); ok(*int_data >= 32, "expected at least 32, got %i\n", *int_data); setsockopt(server, IPPROTO_IPV6, IPV6_HOPLIMIT, (const char *)&off, sizeof(off)); ok(!rc, "failed to clear IPV6_HOPLIMIT, error %u\n", WSAGetLastError()); @@ -2054,11 +2054,11 @@ static void test_ipv6_cmsg(void) ok(rc == sizeof(payload), "send failed, error %u\n", WSAGetLastError()); rc = pWSARecvMsg(server, &msg, &count, NULL, NULL); ok(!rc, "WSARecvMsg failed, error %u\n", WSAGetLastError()); - ok(count == sizeof(payload), "expected length %i, got %i\n", (INT)sizeof(payload), count); + ok(count == sizeof(payload), "expected length %Iu, got %u\n", sizeof(payload), count); ok(header->cmsg_level == IPPROTO_IPV6, "expected IPPROTO_IPV6, got %i\n", header->cmsg_level); ok(header->cmsg_type == IPV6_PKTINFO, "expected IPV6_PKTINFO, got %i\n", header->cmsg_type); ok(header->cmsg_len == sizeof(*header) + sizeof(IN6_PKTINFO), - "expected length %i, got %i\n", (INT)(sizeof(*header) + sizeof(IN6_PKTINFO)), (INT)header->cmsg_len); + "expected length %Iu, got %Iu\n", sizeof(*header) + sizeof(IN6_PKTINFO), header->cmsg_len); ok(!memcmp(&pkt_info->ipi6_addr, &localhost.sin6_addr, sizeof(IN6_ADDR)), "expected ::1\n"); rc = setsockopt(server, IPPROTO_IPV6, IPV6_PKTINFO, (const char *)&off, sizeof(off)); ok(!rc, "failed to clear IPV6_PKTINFO, error %u\n", WSAGetLastError()); @@ -2076,11 +2076,11 @@ static void test_ipv6_cmsg(void) ok(rc == sizeof(payload), "send failed, error %u\n", WSAGetLastError()); rc = pWSARecvMsg(server, &msg, &count, NULL, NULL); ok(!rc, "WSARecvMsg failed, error %u\n", WSAGetLastError()); - ok(count == sizeof(payload), "expected length %i, got %i\n", (INT)sizeof(payload), count); + ok(count == sizeof(payload), "expected length %Iu, got %u\n", sizeof(payload), count); ok(header->cmsg_level == IPPROTO_IPV6, "expected IPPROTO_IPV6, got %i\n", header->cmsg_level); ok(header->cmsg_type == IPV6_TCLASS, "expected IPV6_TCLASS, got %i\n", header->cmsg_type); ok(header->cmsg_len == sizeof(*header) + sizeof(INT), - "expected length %i, got %i\n", (INT)(sizeof(*header) + sizeof(INT)), (INT)header->cmsg_len); + "expected length %Iu, got %Iu\n", sizeof(*header) + sizeof(INT), header->cmsg_len); ok(*int_data == 0, "expected 0, got %i\n", *int_data); rc = setsockopt(server, IPPROTO_IPV6, IPV6_RECVTCLASS, (const char *)&off, sizeof(off)); ok(!rc, "failed to clear IPV6_RECVTCLASS, error %u\n", WSAGetLastError());
IP_PKTINFO already had tests, but it doesn't hurt to add a few more. IP_RECVTTL and IP_RECVTCLASS didn't have any tests.
Signed-off-by: Alex Henrie alexhenrie24@gmail.com --- v3: Use %Iu instead of %zu --- dlls/ws2_32/tests/sock.c | 120 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+)
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index ec8a3b0481b..d42c1c1ffbc 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -1984,6 +1984,125 @@ static void test_ip_pktinfo(void) CloseHandle(ov.hEvent); }
+static void test_ipv4_cmsg(void) +{ + static const DWORD off = 0; + static const DWORD on = 1; + SOCKADDR_IN localhost = {0}; + SOCKET client, server; + char payload[] = "HELLO"; + char control[100]; + WSABUF payload_buf = {sizeof(payload), payload}; + WSAMSG msg = {NULL, 0, &payload_buf, 1, {sizeof(control), control}, 0}; + WSACMSGHDR *header = (WSACMSGHDR *)control; + LPFN_WSARECVMSG pWSARecvMsg; + INT *int_data = (INT *)WSA_CMSG_DATA(header); + IN_PKTINFO *pkt_info = (IN_PKTINFO *)WSA_CMSG_DATA(header); + DWORD count, state; + int rc; + + localhost.sin_family = AF_INET; + localhost.sin_port = htons(SERVERPORT); + inet_pton(AF_INET, "127.0.0.1", &localhost.sin_addr); + + client = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); + ok(client != INVALID_SOCKET, "failed to create socket, error %u\n", WSAGetLastError()); + server = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); + ok(server != INVALID_SOCKET, "failed to create socket, error %u\n", WSAGetLastError()); + + rc = bind(server, (SOCKADDR *)&localhost, sizeof(localhost)); + ok(rc != SOCKET_ERROR, "bind failed, error %u\n", WSAGetLastError()); + rc = connect(client, (SOCKADDR *)&localhost, sizeof(localhost)); + ok(rc != SOCKET_ERROR, "connect failed, error %u\n", WSAGetLastError()); + + rc = WSAIoctl(server, SIO_GET_EXTENSION_FUNCTION_POINTER, &WSARecvMsg_GUID, sizeof(WSARecvMsg_GUID), + &pWSARecvMsg, sizeof(pWSARecvMsg), &count, NULL, NULL); + ok(!rc, "failed to get WSARecvMsg, error %u\n", WSAGetLastError()); + + memset(control, 0, sizeof(control)); + msg.Control.len = sizeof(control); + rc = setsockopt(server, IPPROTO_IP, IP_RECVTTL, (const char *)&on, sizeof(on)); +todo_wine + ok(!rc, "failed to set IP_RECVTTL, error %u\n", WSAGetLastError()); + state = 0; + count = sizeof(state); + rc = getsockopt(server, IPPROTO_IP, IP_RECVTTL, (char *)&state, (INT *)&count); +todo_wine + ok(!rc, "failed to get IP_RECVTTL, error %u\n", WSAGetLastError()); +todo_wine + ok(state == 1, "expected 1, got %u\n", state); + rc = send(client, payload, sizeof(payload), 0); + ok(rc == sizeof(payload), "send failed, error %u\n", WSAGetLastError()); + rc = pWSARecvMsg(server, &msg, &count, NULL, NULL); + ok(!rc, "WSARecvMsg failed, error %u\n", WSAGetLastError()); + ok(count == sizeof(payload), "expected length %Iu, got %u\n", sizeof(payload), count); + ok(header->cmsg_level == IPPROTO_IP, "expected IPPROTO_IP, got %i\n", header->cmsg_level); +todo_wine + ok(header->cmsg_type == IP_TTL || broken(header->cmsg_type == IP_HOPLIMIT) /* <= win10 v1607 */, + "expected IP_TTL, got %i\n", header->cmsg_type); +todo_wine + ok(header->cmsg_len == sizeof(*header) + sizeof(INT), + "expected length %Iu, got %Iu\n", sizeof(*header) + sizeof(INT), header->cmsg_len); +todo_wine + ok(*int_data >= 32, "expected at least 32, got %i\n", *int_data); + setsockopt(server, IPPROTO_IP, IP_RECVTTL, (const char *)&off, sizeof(off)); + ok(!rc, "failed to clear IP_RECVTTL, error %u\n", WSAGetLastError()); + + memset(control, 0, sizeof(control)); + msg.Control.len = sizeof(control); + rc = setsockopt(server, IPPROTO_IP, IP_PKTINFO, (const char *)&on, sizeof(on)); + ok(!rc, "failed to set IP_PKTINFO, error %u\n", WSAGetLastError()); + state = 0; + count = sizeof(state); + rc = getsockopt(server, IPPROTO_IP, IP_PKTINFO, (char *)&state, (INT *)&count); + ok(!rc, "failed to get IP_PKTINFO, error %u\n", WSAGetLastError()); + ok(state == 1, "expected 1, got %u\n", state); + rc = send(client, payload, sizeof(payload), 0); + ok(rc == sizeof(payload), "send failed, error %u\n", WSAGetLastError()); + rc = pWSARecvMsg(server, &msg, &count, NULL, NULL); + ok(!rc, "WSARecvMsg failed, error %u\n", WSAGetLastError()); + ok(count == sizeof(payload), "expected length %Iu, got %u\n", sizeof(payload), count); + ok(header->cmsg_level == IPPROTO_IP, "expected IPPROTO_IP, got %i\n", header->cmsg_level); + ok(header->cmsg_type == IP_PKTINFO, "expected IP_PKTINFO, got %i\n", header->cmsg_type); + ok(header->cmsg_len == sizeof(*header) + sizeof(IN_PKTINFO), + "expected length %Iu, got %Iu\n", sizeof(*header) + sizeof(IN_PKTINFO), header->cmsg_len); + ok(!memcmp(&pkt_info->ipi_addr, &localhost.sin_addr, sizeof(IN_ADDR)), "expected 127.0.0.1\n"); + rc = setsockopt(server, IPPROTO_IP, IP_PKTINFO, (const char *)&off, sizeof(off)); + ok(!rc, "failed to clear IP_PKTINFO, error %u\n", WSAGetLastError()); + + memset(control, 0, sizeof(control)); + msg.Control.len = sizeof(control); + rc = setsockopt(server, IPPROTO_IP, IP_RECVTCLASS, (const char *)&on, sizeof(on)); +todo_wine + ok(!rc, "failed to set IP_RECVTCLASS, error %u\n", WSAGetLastError()); + state = 0; + count = sizeof(state); + rc = getsockopt(server, IPPROTO_IP, IP_RECVTCLASS, (char *)&state, (INT *)&count); +todo_wine + ok(!rc, "failed to get IP_RECVTCLASS, error %u\n", WSAGetLastError()); +todo_wine + ok(state == 1, "expected 1, got %u\n", state); + rc = send(client, payload, sizeof(payload), 0); + ok(rc == sizeof(payload), "send failed, error %u\n", WSAGetLastError()); + rc = pWSARecvMsg(server, &msg, &count, NULL, NULL); + ok(!rc, "WSARecvMsg failed, error %u\n", WSAGetLastError()); + ok(count == sizeof(payload), "expected length %Iu, got %u\n", sizeof(payload), count); + ok(header->cmsg_level == IPPROTO_IP, "expected IPPROTO_IP, got %i\n", header->cmsg_level); +todo_wine + ok(header->cmsg_type == IP_TOS || broken(header->cmsg_type == IP_TCLASS) /* <= win10 v1607 */, + "expected IP_TOS, got %i\n", header->cmsg_type); +todo_wine + ok(header->cmsg_len == sizeof(*header) + sizeof(INT), + "expected length %Iu, got %Iu\n", sizeof(*header) + sizeof(INT), header->cmsg_len); + ok(*int_data == 0, "expected 0, got %i\n", *int_data); + rc = setsockopt(server, IPPROTO_IP, IP_RECVTCLASS, (const char *)&off, sizeof(off)); +todo_wine + ok(!rc, "failed to clear IP_RECVTCLASS, error %u\n", WSAGetLastError()); + + closesocket(server); + closesocket(client); +} + static void test_ipv6_cmsg(void) { static const DWORD off = 0; @@ -11767,6 +11886,7 @@ START_TEST( sock ) test_set_getsockopt(); test_so_reuseaddr(); test_ip_pktinfo(); + test_ipv4_cmsg(); test_ipv6_cmsg(); test_extendedSocketOptions(); test_so_debug();
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=99024
Your paranoid android.
=== debiant2 (32 bit Japanese:Japan report) ===
ws2_32: sock.c:1135: Test failed: wait failed, error 258 sock: Timeout
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
Signed-off-by: Alex Henrie alexhenrie24@gmail.com --- SkyDNS and DJI Flight Simulator use this option, see:
https://forum.winehq.org/viewtopic.php?t=32375
https://www.reddit.com/r/macgaming/comments/f9u80m/help_error_install_a_driv...
v3: Rebase without changes --- dlls/ntdll/unix/socket.c | 27 +++++++++++++++++++++++++++ dlls/ws2_32/socket.c | 7 +++++++ dlls/ws2_32/tests/sock.c | 12 +++--------- include/wine/afd.h | 2 ++ 4 files changed, 39 insertions(+), 9 deletions(-)
diff --git a/dlls/ntdll/unix/socket.c b/dlls/ntdll/unix/socket.c index 2be4f2b52a3..f9576a44eef 100644 --- a/dlls/ntdll/unix/socket.c +++ b/dlls/ntdll/unix/socket.c @@ -425,6 +425,17 @@ static int convert_control_headers(struct msghdr *hdr, WSABUF *control) break; } #endif /* IP_PKTINFO */ + +#if defined(IP_TTL) + case IP_TTL: + { + ptr = fill_control_message( WS_IPPROTO_IP, WS_IP_TTL, ptr, &ctlsize, + CMSG_DATA(cmsg_unix), sizeof(INT) ); + if (!ptr) goto error; + break; + } +#endif /* IP_TTL */ + default: FIXME("Unhandled IPPROTO_IP message header type %d\n", cmsg_unix->cmsg_type); break; @@ -1834,6 +1845,22 @@ NTSTATUS sock_ioctl( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc } #endif
+#ifdef IP_RECVTTL + case IOCTL_AFD_WINE_GET_IP_RECVTTL: + { + int sock_type = get_sock_type( handle ); + if (sock_type != SOCK_DGRAM && sock_type != SOCK_RAW) return STATUS_INVALID_PARAMETER; + return do_getsockopt( handle, io, IPPROTO_IP, IP_RECVTTL, out_buffer, out_size ); + } + + case IOCTL_AFD_WINE_SET_IP_RECVTTL: + { + int sock_type = get_sock_type( handle ); + if (sock_type != SOCK_DGRAM && sock_type != SOCK_RAW) return STATUS_INVALID_PARAMETER; + return do_setsockopt( handle, io, IPPROTO_IP, IP_RECVTTL, in_buffer, in_size ); + } +#endif + case IOCTL_AFD_WINE_GET_IP_TOS: return do_getsockopt( handle, io, IPPROTO_IP, IP_TOS, out_buffer, out_size );
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index bf87e7824e5..8085a1c2d35 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -295,6 +295,7 @@ static inline const char *debugstr_sockopt(int level, int optname) DEBUG_SOCKOPT(IP_OPTIONS); DEBUG_SOCKOPT(IP_PKTINFO); DEBUG_SOCKOPT(IP_RECEIVE_BROADCAST); + DEBUG_SOCKOPT(IP_RECVTTL); DEBUG_SOCKOPT(IP_TOS); DEBUG_SOCKOPT(IP_TTL); DEBUG_SOCKOPT(IP_UNICAST_IF); @@ -1693,6 +1694,9 @@ int WINAPI getsockopt( SOCKET s, int level, int optname, char *optval, int *optl case IP_PKTINFO: return server_getsockopt( s, IOCTL_AFD_WINE_GET_IP_PKTINFO, optval, optlen );
+ case IP_RECVTTL: + return server_getsockopt( s, IOCTL_AFD_WINE_GET_IP_RECVTTL, optval, optlen ); + case IP_TOS: return server_getsockopt( s, IOCTL_AFD_WINE_GET_IP_TOS, optval, optlen );
@@ -2908,6 +2912,9 @@ int WINAPI setsockopt( SOCKET s, int level, int optname, const char *optval, int case IP_PKTINFO: return server_setsockopt( s, IOCTL_AFD_WINE_SET_IP_PKTINFO, optval, optlen );
+ case IP_RECVTTL: + return server_setsockopt( s, IOCTL_AFD_WINE_SET_IP_RECVTTL, optval, optlen ); + case IP_TOS: return server_setsockopt( s, IOCTL_AFD_WINE_SET_IP_TOS, optval, optlen );
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index d42c1c1ffbc..7ab96c830b9 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -2022,14 +2022,11 @@ static void test_ipv4_cmsg(void) memset(control, 0, sizeof(control)); msg.Control.len = sizeof(control); rc = setsockopt(server, IPPROTO_IP, IP_RECVTTL, (const char *)&on, sizeof(on)); -todo_wine ok(!rc, "failed to set IP_RECVTTL, error %u\n", WSAGetLastError()); state = 0; count = sizeof(state); rc = getsockopt(server, IPPROTO_IP, IP_RECVTTL, (char *)&state, (INT *)&count); -todo_wine ok(!rc, "failed to get IP_RECVTTL, error %u\n", WSAGetLastError()); -todo_wine ok(state == 1, "expected 1, got %u\n", state); rc = send(client, payload, sizeof(payload), 0); ok(rc == sizeof(payload), "send failed, error %u\n", WSAGetLastError()); @@ -2037,13 +2034,10 @@ todo_wine ok(!rc, "WSARecvMsg failed, error %u\n", WSAGetLastError()); ok(count == sizeof(payload), "expected length %Iu, got %u\n", sizeof(payload), count); ok(header->cmsg_level == IPPROTO_IP, "expected IPPROTO_IP, got %i\n", header->cmsg_level); -todo_wine ok(header->cmsg_type == IP_TTL || broken(header->cmsg_type == IP_HOPLIMIT) /* <= win10 v1607 */, "expected IP_TTL, got %i\n", header->cmsg_type); -todo_wine ok(header->cmsg_len == sizeof(*header) + sizeof(INT), "expected length %Iu, got %Iu\n", sizeof(*header) + sizeof(INT), header->cmsg_len); -todo_wine ok(*int_data >= 32, "expected at least 32, got %i\n", *int_data); setsockopt(server, IPPROTO_IP, IP_RECVTTL, (const char *)&off, sizeof(off)); ok(!rc, "failed to clear IP_RECVTTL, error %u\n", WSAGetLastError()); @@ -11614,7 +11608,7 @@ static void test_sockopt_validity(void) { IP_DROP_MEMBERSHIP, WSAENOPROTOOPT }, { IP_DONTFRAGMENT }, { IP_PKTINFO, WSAEINVAL }, - { IP_RECVTTL, WSAEINVAL, 0, TRUE }, + { IP_RECVTTL, WSAEINVAL }, { IP_RECEIVE_BROADCAST, WSAEINVAL, 0, TRUE }, { IP_RECVIF, WSAEINVAL, 0, TRUE }, { IP_RECVDSTADDR, WSAEINVAL, 0, TRUE }, @@ -11649,7 +11643,7 @@ static void test_sockopt_validity(void) { IP_DROP_MEMBERSHIP, WSAENOPROTOOPT }, { IP_DONTFRAGMENT }, { IP_PKTINFO }, - { IP_RECVTTL, 0, 0, TRUE }, + { IP_RECVTTL }, { IP_RECEIVE_BROADCAST, 0, 0, TRUE }, { IP_RECVIF, 0, 0, TRUE }, { IP_RECVDSTADDR, 0, 0, TRUE }, @@ -11684,7 +11678,7 @@ static void test_sockopt_validity(void) { IP_DROP_MEMBERSHIP, WSAENOPROTOOPT }, { IP_DONTFRAGMENT }, { IP_PKTINFO }, - { IP_RECVTTL, 0, 0, TRUE }, + { IP_RECVTTL }, { IP_RECEIVE_BROADCAST, 0, 0, TRUE }, { IP_RECVIF, 0, 0, TRUE }, { IP_RECVDSTADDR, 0, 0, TRUE }, diff --git a/include/wine/afd.h b/include/wine/afd.h index f4682f464e8..8ffce81ab6f 100644 --- a/include/wine/afd.h +++ b/include/wine/afd.h @@ -234,6 +234,8 @@ struct afd_get_events_params #define IOCTL_AFD_WINE_GET_IPV6_RECVTCLASS WINE_AFD_IOC(290) #define IOCTL_AFD_WINE_SET_IPV6_RECVTCLASS WINE_AFD_IOC(291) #define IOCTL_AFD_WINE_GET_SO_CONNECT_TIME WINE_AFD_IOC(292) +#define IOCTL_AFD_WINE_GET_IP_RECVTTL WINE_AFD_IOC(293) +#define IOCTL_AFD_WINE_SET_IP_RECVTTL WINE_AFD_IOC(294)
struct afd_create_params {
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
Signed-off-by: Alex Henrie alexhenrie24@gmail.com --- v3: Rebase without changes --- dlls/ntdll/unix/socket.c | 26 ++++++++++++++++++++++++++ dlls/ws2_32/socket.c | 7 +++++++ dlls/ws2_32/tests/sock.c | 24 +++++++++--------------- include/wine/afd.h | 2 ++ 4 files changed, 44 insertions(+), 15 deletions(-)
diff --git a/dlls/ntdll/unix/socket.c b/dlls/ntdll/unix/socket.c index f9576a44eef..480d8b4f490 100644 --- a/dlls/ntdll/unix/socket.c +++ b/dlls/ntdll/unix/socket.c @@ -426,6 +426,16 @@ static int convert_control_headers(struct msghdr *hdr, WSABUF *control) } #endif /* IP_PKTINFO */
+#if defined(IP_TOS) + case IP_TOS: + { + ptr = fill_control_message( WS_IPPROTO_IP, WS_IP_TOS, ptr, &ctlsize, + CMSG_DATA(cmsg_unix), sizeof(INT) ); + if (!ptr) goto error; + break; + } +#endif /* IP_TOS */ + #if defined(IP_TTL) case IP_TTL: { @@ -1845,6 +1855,22 @@ NTSTATUS sock_ioctl( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc } #endif
+#ifdef IP_RECVTOS + case IOCTL_AFD_WINE_GET_IP_RECVTOS: + { + int sock_type = get_sock_type( handle ); + if (sock_type != SOCK_DGRAM && sock_type != SOCK_RAW) return STATUS_INVALID_PARAMETER; + return do_getsockopt( handle, io, IPPROTO_IP, IP_RECVTOS, out_buffer, out_size ); + } + + case IOCTL_AFD_WINE_SET_IP_RECVTOS: + { + int sock_type = get_sock_type( handle ); + if (sock_type != SOCK_DGRAM && sock_type != SOCK_RAW) return STATUS_INVALID_PARAMETER; + return do_setsockopt( handle, io, IPPROTO_IP, IP_RECVTOS, in_buffer, in_size ); + } +#endif + #ifdef IP_RECVTTL case IOCTL_AFD_WINE_GET_IP_RECVTTL: { diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index 8085a1c2d35..9cbe7908226 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -295,6 +295,7 @@ static inline const char *debugstr_sockopt(int level, int optname) DEBUG_SOCKOPT(IP_OPTIONS); DEBUG_SOCKOPT(IP_PKTINFO); DEBUG_SOCKOPT(IP_RECEIVE_BROADCAST); + DEBUG_SOCKOPT(IP_RECVTOS); DEBUG_SOCKOPT(IP_RECVTTL); DEBUG_SOCKOPT(IP_TOS); DEBUG_SOCKOPT(IP_TTL); @@ -1694,6 +1695,9 @@ int WINAPI getsockopt( SOCKET s, int level, int optname, char *optval, int *optl case IP_PKTINFO: return server_getsockopt( s, IOCTL_AFD_WINE_GET_IP_PKTINFO, optval, optlen );
+ case IP_RECVTOS: + return server_getsockopt( s, IOCTL_AFD_WINE_GET_IP_RECVTOS, optval, optlen ); + case IP_RECVTTL: return server_getsockopt( s, IOCTL_AFD_WINE_GET_IP_RECVTTL, optval, optlen );
@@ -2912,6 +2916,9 @@ int WINAPI setsockopt( SOCKET s, int level, int optname, const char *optval, int case IP_PKTINFO: return server_setsockopt( s, IOCTL_AFD_WINE_SET_IP_PKTINFO, optval, optlen );
+ case IP_RECVTOS: + return server_setsockopt( s, IOCTL_AFD_WINE_SET_IP_RECVTOS, optval, optlen ); + case IP_RECVTTL: return server_setsockopt( s, IOCTL_AFD_WINE_SET_IP_RECVTTL, optval, optlen );
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index 7ab96c830b9..2bb219d7c0e 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -2066,15 +2066,12 @@ static void test_ipv4_cmsg(void)
memset(control, 0, sizeof(control)); msg.Control.len = sizeof(control); - rc = setsockopt(server, IPPROTO_IP, IP_RECVTCLASS, (const char *)&on, sizeof(on)); -todo_wine - ok(!rc, "failed to set IP_RECVTCLASS, error %u\n", WSAGetLastError()); + rc = setsockopt(server, IPPROTO_IP, IP_RECVTOS, (const char *)&on, sizeof(on)); + ok(!rc, "failed to set IP_RECVTOS, error %u\n", WSAGetLastError()); state = 0; count = sizeof(state); - rc = getsockopt(server, IPPROTO_IP, IP_RECVTCLASS, (char *)&state, (INT *)&count); -todo_wine - ok(!rc, "failed to get IP_RECVTCLASS, error %u\n", WSAGetLastError()); -todo_wine + rc = getsockopt(server, IPPROTO_IP, IP_RECVTOS, (char *)&state, (INT *)&count); + ok(!rc, "failed to get IP_RECVTOS, error %u\n", WSAGetLastError()); ok(state == 1, "expected 1, got %u\n", state); rc = send(client, payload, sizeof(payload), 0); ok(rc == sizeof(payload), "send failed, error %u\n", WSAGetLastError()); @@ -2082,16 +2079,13 @@ todo_wine ok(!rc, "WSARecvMsg failed, error %u\n", WSAGetLastError()); ok(count == sizeof(payload), "expected length %Iu, got %u\n", sizeof(payload), count); ok(header->cmsg_level == IPPROTO_IP, "expected IPPROTO_IP, got %i\n", header->cmsg_level); -todo_wine ok(header->cmsg_type == IP_TOS || broken(header->cmsg_type == IP_TCLASS) /* <= win10 v1607 */, "expected IP_TOS, got %i\n", header->cmsg_type); -todo_wine ok(header->cmsg_len == sizeof(*header) + sizeof(INT), "expected length %Iu, got %Iu\n", sizeof(*header) + sizeof(INT), header->cmsg_len); ok(*int_data == 0, "expected 0, got %i\n", *int_data); - rc = setsockopt(server, IPPROTO_IP, IP_RECVTCLASS, (const char *)&off, sizeof(off)); -todo_wine - ok(!rc, "failed to clear IP_RECVTCLASS, error %u\n", WSAGetLastError()); + rc = setsockopt(server, IPPROTO_IP, IP_RECVTOS, (const char *)&off, sizeof(off)); + ok(!rc, "failed to clear IP_RECVTOS, error %u\n", WSAGetLastError());
closesocket(server); closesocket(client); @@ -11617,7 +11611,7 @@ static void test_sockopt_validity(void) { IP_RTHDR, 0, 0, TRUE }, { IP_GET_IFLIST, WSAEINVAL, 0, TRUE }, { IP_RECVRTHDR, WSAEINVAL, 0, TRUE }, - { IP_RECVTCLASS, WSAEINVAL, 0, TRUE }, + { IP_RECVTOS, WSAEINVAL }, { IP_ORIGINAL_ARRIVAL_IF, WSAEINVAL, 0, TRUE }, { IP_ECN, WSAEINVAL, 0, TRUE }, { IP_PKTINFO_EX, WSAEINVAL, 0, TRUE }, @@ -11652,7 +11646,7 @@ static void test_sockopt_validity(void) { IP_RTHDR, 0, 0, TRUE }, { IP_GET_IFLIST, WSAEINVAL, 0, TRUE }, { IP_RECVRTHDR, 0, 0, TRUE }, - { IP_RECVTCLASS, 0, 0, TRUE }, + { IP_RECVTOS }, { IP_ORIGINAL_ARRIVAL_IF, 0, 0, TRUE }, { IP_ECN, 0, 0, TRUE }, { IP_PKTINFO_EX, 0, 0, TRUE }, @@ -11687,7 +11681,7 @@ static void test_sockopt_validity(void) { IP_RTHDR, 0, 0, TRUE }, { IP_GET_IFLIST, WSAEINVAL, 0, TRUE }, { IP_RECVRTHDR, 0, 0, TRUE }, - { IP_RECVTCLASS, 0, 0, TRUE }, + { IP_RECVTOS }, { IP_ORIGINAL_ARRIVAL_IF, 0, 0, TRUE }, { IP_ECN, 0, 0, TRUE }, { IP_PKTINFO_EX, 0, 0, TRUE }, diff --git a/include/wine/afd.h b/include/wine/afd.h index 8ffce81ab6f..3b8bdcb9e5d 100644 --- a/include/wine/afd.h +++ b/include/wine/afd.h @@ -236,6 +236,8 @@ struct afd_get_events_params #define IOCTL_AFD_WINE_GET_SO_CONNECT_TIME WINE_AFD_IOC(292) #define IOCTL_AFD_WINE_GET_IP_RECVTTL WINE_AFD_IOC(293) #define IOCTL_AFD_WINE_SET_IP_RECVTTL WINE_AFD_IOC(294) +#define IOCTL_AFD_WINE_GET_IP_RECVTOS WINE_AFD_IOC(295) +#define IOCTL_AFD_WINE_SET_IP_RECVTOS WINE_AFD_IOC(296)
struct afd_create_params {
Signed-off-by: Zebediah Figura zfigura@codeweavers.com