Commit 7e6b7d21 authored by Kai Blin's avatar Kai Blin Committed by Alexandre Julliard

ws2_32: Implement SO_GET_MAX_MSG_SIZE for getsockopt.

parent d4877a32
......@@ -1828,6 +1828,19 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level,
return 0;
}
if (level == WS_SOL_SOCKET && optname == WS_SO_MAX_MSG_SIZE)
{
if(!optlen || *optlen < sizeof(int) || !optval)
{
SetLastError(WSAEFAULT);
return SOCKET_ERROR;
}
TRACE("getting global SO_MAX_MSG_SIZE = 65507\n");
*(int *)optval = 65507;
*optlen = sizeof(int);
return 0;
}
#ifdef HAVE_IPX
if(level == NSPROTO_IPX)
{
......
......@@ -1410,6 +1410,47 @@ static void test_select(void)
}
static void test_extendedSocketOptions()
{
WSADATA wsa;
SOCKET sock;
struct sockaddr_in sa;
int sa_len = sizeof(struct sockaddr_in);
int optval, optlen = sizeof(int), ret;
if(WSAStartup(MAKEWORD(2,0), &wsa)){
trace("Winsock failed: 0x%08x. Aborting test\n", WSAGetLastError());
return;
}
memset(&sa, 0, sa_len);
sa.sin_family = AF_INET;
sa.sin_port = htons(0);
sa.sin_addr.s_addr = htonl(INADDR_ANY);
if((sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP)) < 0){
trace("Creating the socket failed: 0x%08x\n", WSAGetLastError());
WSACleanup();
return;
}
if(bind(sock, (struct sockaddr *) &sa, sa_len) < 0){
trace("Failed to bind socket: 0x%08x\n", WSAGetLastError());
closesocket(sock);
WSACleanup();
return;
}
ret = getsockopt(sock, SOL_SOCKET, SO_MAX_MSG_SIZE, (char *)&optval, (int *)&optlen);
ok(ret == 0, "getsockopt failed to query SO_MAX_MSG_SIZE, return value is 0x%08x\n", ret);
ok(optval == 65507, "SO_MAX_MSG_SIZE reported %d, expected 65507\n", optval);
closesocket(sock);
WSACleanup();
}
/**************** Main program ***************/
START_TEST( sock )
......@@ -1419,6 +1460,7 @@ START_TEST( sock )
test_set_getsockopt();
test_so_reuseaddr();
test_extendedSocketOptions();
for (i = 0; i < NUM_TESTS; i++)
{
......@@ -1438,6 +1480,6 @@ START_TEST( sock )
test_WSAStringToAddressW();
test_select();
Exit();
}
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