Commit f68923dc authored by Alex Henrie's avatar Alex Henrie Committed by Alexandre Julliard

ws2_32: Hook up IPV6_RECVTCLASS.

parent 17871709
......@@ -462,6 +462,16 @@ static int convert_control_headers(struct msghdr *hdr, WSABUF *control)
}
#endif /* IPV6_PKTINFO */
#if defined(IPV6_TCLASS)
case IPV6_TCLASS:
{
ptr = fill_control_message( WS_IPPROTO_IPV6, WS_IPV6_TCLASS, ptr, &ctlsize,
CMSG_DATA(cmsg_unix), sizeof(INT) );
if (!ptr) goto error;
break;
}
#endif /* IPV6_TCLASS */
default:
FIXME("Unhandled IPPROTO_IPV6 message header type %d\n", cmsg_unix->cmsg_type);
break;
......@@ -1916,6 +1926,14 @@ NTSTATUS sock_ioctl( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc
return do_setsockopt( handle, io, IPPROTO_IPV6, IPV6_RECVPKTINFO, in_buffer, in_size );
#endif
#ifdef IPV6_RECVTCLASS
case IOCTL_AFD_WINE_GET_IPV6_RECVTCLASS:
return do_getsockopt( handle, io, IPPROTO_IPV6, IPV6_RECVTCLASS, out_buffer, out_size );
case IOCTL_AFD_WINE_SET_IPV6_RECVTCLASS:
return do_setsockopt( handle, io, IPPROTO_IPV6, IPV6_RECVTCLASS, in_buffer, in_size );
#endif
case IOCTL_AFD_WINE_GET_IPV6_UNICAST_HOPS:
return do_getsockopt( handle, io, IPPROTO_IPV6, IPV6_UNICAST_HOPS, out_buffer, out_size );
......
......@@ -311,6 +311,7 @@ static inline const char *debugstr_sockopt(int level, int optname)
DEBUG_SOCKOPT(IPV6_MULTICAST_HOPS);
DEBUG_SOCKOPT(IPV6_MULTICAST_LOOP);
DEBUG_SOCKOPT(IPV6_PKTINFO);
DEBUG_SOCKOPT(IPV6_RECVTCLASS);
DEBUG_SOCKOPT(IPV6_UNICAST_HOPS);
DEBUG_SOCKOPT(IPV6_V6ONLY);
DEBUG_SOCKOPT(IPV6_UNICAST_IF);
......@@ -1734,6 +1735,9 @@ int WINAPI getsockopt( SOCKET s, int level, int optname, char *optval, int *optl
case IPV6_PKTINFO:
return server_getsockopt( s, IOCTL_AFD_WINE_GET_IPV6_RECVPKTINFO, optval, optlen );
case IPV6_RECVTCLASS:
return server_getsockopt( s, IOCTL_AFD_WINE_GET_IPV6_RECVTCLASS, optval, optlen );
case IPV6_UNICAST_HOPS:
return server_getsockopt( s, IOCTL_AFD_WINE_GET_IPV6_UNICAST_HOPS, optval, optlen );
......@@ -2942,6 +2946,9 @@ int WINAPI setsockopt( SOCKET s, int level, int optname, const char *optval, int
FIXME("IPV6_PROTECTION_LEVEL is ignored!\n");
return 0;
case IPV6_RECVTCLASS:
return server_setsockopt( s, IOCTL_AFD_WINE_SET_IPV6_RECVTCLASS, optval, optlen );
case IPV6_UNICAST_HOPS:
return server_setsockopt( s, IOCTL_AFD_WINE_SET_IPV6_UNICAST_HOPS, optval, optlen );
......
......@@ -2002,7 +2002,7 @@ static void test_ipv6_cmsg(void)
WSAMSG msg = {NULL, 0, &payload_buf, 1, {sizeof(control), control}, 0};
WSACMSGHDR *header = (WSACMSGHDR *)control;
LPFN_WSARECVMSG pWSARecvMsg;
INT *hop_limit = (INT *)WSA_CMSG_DATA(header);
INT *int_data = (INT *)WSA_CMSG_DATA(header);
IN6_PKTINFO *pkt_info = (IN6_PKTINFO *)WSA_CMSG_DATA(header);
DWORD count, state;
int rc;
......@@ -2043,7 +2043,7 @@ static void test_ipv6_cmsg(void)
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);
ok(*hop_limit >= 32, "expected at least 32, got %i\n", *hop_limit);
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());
......@@ -2069,6 +2069,28 @@ static void test_ipv6_cmsg(void)
rc = setsockopt(server, IPPROTO_IPV6, IPV6_PKTINFO, (const char *)&off, sizeof(off));
ok(!rc, "failed to clear IPV6_PKTINFO, error %u\n", WSAGetLastError());
memset(control, 0, sizeof(control));
msg.Control.len = sizeof(control);
rc = setsockopt(server, IPPROTO_IPV6, IPV6_RECVTCLASS, (const char *)&on, sizeof(on));
ok(!rc, "failed to set IPV6_RECVTCLASS, error %u\n", WSAGetLastError());
state = 0;
count = sizeof(state);
rc = getsockopt(server, IPPROTO_IPV6, IPV6_RECVTCLASS, (char *)&state, (INT *)&count);
ok(!rc, "failed to get IPV6_RECVTCLASS, 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 %i, got %i\n", (INT)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);
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());
closesocket(server);
closesocket(client);
}
......
......@@ -231,6 +231,8 @@ struct afd_get_events_params
#define IOCTL_AFD_WINE_SET_IPV6_RECVHOPLIMIT WINE_AFD_IOC(287)
#define IOCTL_AFD_WINE_GET_IPV6_RECVPKTINFO WINE_AFD_IOC(288)
#define IOCTL_AFD_WINE_SET_IPV6_RECVPKTINFO WINE_AFD_IOC(289)
#define IOCTL_AFD_WINE_GET_IPV6_RECVTCLASS WINE_AFD_IOC(290)
#define IOCTL_AFD_WINE_SET_IPV6_RECVTCLASS WINE_AFD_IOC(291)
struct afd_create_params
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment