https://git.reactos.org/?p=reactos.git;a=commitdiff;h=6bf5a8a43dca1672a84a8…
commit 6bf5a8a43dca1672a84a8e519edc2ba7d4c354e6
Author: Pierre Schweitzer <pierre(a)reactos.org>
AuthorDate: Mon Feb 25 22:28:18 2019 +0100
Commit: Pierre Schweitzer <pierre(a)reactos.org>
CommitDate: Mon Feb 25 22:34:28 2019 +0100
[AFD_APITEST] Add apitest for AFD window size options
---
modules/rostests/apitests/afd/AfdHelpers.c | 124 +++++++++++
modules/rostests/apitests/afd/AfdHelpers.h | 17 ++
modules/rostests/apitests/afd/CMakeLists.txt | 1 +
modules/rostests/apitests/afd/testlist.c | 2 +
modules/rostests/apitests/afd/windowsize.c | 306 +++++++++++++++++++++++++++
5 files changed, 450 insertions(+)
diff --git a/modules/rostests/apitests/afd/AfdHelpers.c
b/modules/rostests/apitests/afd/AfdHelpers.c
index ad7793efd7..702a8f0cfb 100644
--- a/modules/rostests/apitests/afd/AfdHelpers.c
+++ b/modules/rostests/apitests/afd/AfdHelpers.c
@@ -3,6 +3,7 @@
* LICENSE: LGPL-2.1+ (
https://spdx.org/licenses/LGPL-2.1+)
* PURPOSE: Utility function definitions for calling AFD
* COPYRIGHT: Copyright 2015-2018 Thomas Faber (thomas.faber(a)reactos.org)
+ * Copyright 2019 Pierre Schweitzer (pierre(a)reactos.org)
*/
#include "precomp.h"
@@ -382,3 +383,126 @@ AfdSendTo(
return Status;
}
+
+NTSTATUS
+AfdSetInformation(
+ _In_ HANDLE SocketHandle,
+ _In_ ULONG InformationClass,
+ _In_opt_ PBOOLEAN Boolean,
+ _In_opt_ PULONG Ulong,
+ _In_opt_ PLARGE_INTEGER LargeInteger)
+{
+ NTSTATUS Status;
+ IO_STATUS_BLOCK IoStatus;
+ AFD_INFO InfoData;
+ HANDLE Event;
+
+ Status = NtCreateEvent(&Event,
+ EVENT_ALL_ACCESS,
+ NULL,
+ NotificationEvent,
+ FALSE);
+ if (!NT_SUCCESS(Status))
+ {
+ return Status;
+ }
+
+ InfoData.InformationClass = InformationClass;
+
+ if (Ulong != NULL)
+ {
+ InfoData.Information.Ulong = *Ulong;
+ }
+ if (LargeInteger != NULL)
+ {
+ InfoData.Information.LargeInteger = *LargeInteger;
+ }
+ if (Boolean != NULL)
+ {
+ InfoData.Information.Boolean = *Boolean;
+ }
+
+ Status = NtDeviceIoControlFile(SocketHandle,
+ Event,
+ NULL,
+ NULL,
+ &IoStatus,
+ IOCTL_AFD_SET_INFO,
+ &InfoData,
+ sizeof(InfoData),
+ NULL,
+ 0);
+ if (Status == STATUS_PENDING)
+ {
+ NtWaitForSingleObject(Event, FALSE, NULL);
+ Status = IoStatus.Status;
+ }
+
+ NtClose(Event);
+
+ return Status;
+}
+
+NTSTATUS
+AfdGetInformation(
+ _In_ HANDLE SocketHandle,
+ _In_ ULONG InformationClass,
+ _In_opt_ PBOOLEAN Boolean,
+ _In_opt_ PULONG Ulong,
+ _In_opt_ PLARGE_INTEGER LargeInteger)
+{
+ NTSTATUS Status;
+ IO_STATUS_BLOCK IoStatus;
+ AFD_INFO InfoData;
+ HANDLE Event;
+
+ Status = NtCreateEvent(&Event,
+ EVENT_ALL_ACCESS,
+ NULL,
+ NotificationEvent,
+ FALSE);
+ if (!NT_SUCCESS(Status))
+ {
+ return Status;
+ }
+
+ InfoData.InformationClass = InformationClass;
+
+ Status = NtDeviceIoControlFile(SocketHandle,
+ Event,
+ NULL,
+ NULL,
+ &IoStatus,
+ IOCTL_AFD_GET_INFO,
+ &InfoData,
+ sizeof(InfoData),
+ &InfoData,
+ sizeof(InfoData));
+ if (Status == STATUS_PENDING)
+ {
+ NtWaitForSingleObject(Event, FALSE, NULL);
+ Status = IoStatus.Status;
+ }
+
+ NtClose(Event);
+
+ if (Status != STATUS_SUCCESS)
+ {
+ return Status;
+ }
+
+ if (Ulong != NULL)
+ {
+ *Ulong = InfoData.Information.Ulong;
+ }
+ if (LargeInteger != NULL)
+ {
+ *LargeInteger = InfoData.Information.LargeInteger;
+ }
+ if (Boolean != NULL)
+ {
+ *Boolean = InfoData.Information.Boolean;
+ }
+
+ return Status;
+}
diff --git a/modules/rostests/apitests/afd/AfdHelpers.h
b/modules/rostests/apitests/afd/AfdHelpers.h
index fadd03d563..0afcef5231 100644
--- a/modules/rostests/apitests/afd/AfdHelpers.h
+++ b/modules/rostests/apitests/afd/AfdHelpers.h
@@ -3,6 +3,7 @@
* LICENSE: LGPL-2.1+ (
https://spdx.org/licenses/LGPL-2.1+)
* PURPOSE: Utility function declarations for calling AFD
* COPYRIGHT: Copyright 2015 Thomas Faber (thomas.faber(a)reactos.org)
+ * Copyright 2019 Pierre Schweitzer (pierre(a)reactos.org)
*/
#pragma once
@@ -39,3 +40,19 @@ AfdSendTo(
_In_ ULONG BufferLength,
_In_ const struct sockaddr *Address,
_In_ ULONG AddressLength);
+
+NTSTATUS
+AfdSetInformation(
+ _In_ HANDLE SocketHandle,
+ _In_ ULONG InformationClass,
+ _In_opt_ PBOOLEAN Boolean,
+ _In_opt_ PULONG Ulong,
+ _In_opt_ PLARGE_INTEGER LargeInteger);
+
+NTSTATUS
+AfdGetInformation(
+ _In_ HANDLE SocketHandle,
+ _In_ ULONG InformationClass,
+ _In_opt_ PBOOLEAN Boolean,
+ _In_opt_ PULONG Ulong,
+ _In_opt_ PLARGE_INTEGER LargeInteger);
diff --git a/modules/rostests/apitests/afd/CMakeLists.txt
b/modules/rostests/apitests/afd/CMakeLists.txt
index 412c27e177..d4b30b254c 100644
--- a/modules/rostests/apitests/afd/CMakeLists.txt
+++ b/modules/rostests/apitests/afd/CMakeLists.txt
@@ -5,6 +5,7 @@ include_directories(
list(APPEND SOURCE
AfdHelpers.c
send.c
+ windowsize.c
precomp.h)
add_executable(afd_apitest ${SOURCE} testlist.c)
diff --git a/modules/rostests/apitests/afd/testlist.c
b/modules/rostests/apitests/afd/testlist.c
index 17c82b9f0b..565e7db552 100644
--- a/modules/rostests/apitests/afd/testlist.c
+++ b/modules/rostests/apitests/afd/testlist.c
@@ -2,9 +2,11 @@
#include <apitest.h>
extern void func_send(void);
+extern void func_windowsize(void);
const struct test winetest_testlist[] =
{
{ "send", func_send },
+ { "windowsize", func_windowsize },
{ 0, 0 }
};
diff --git a/modules/rostests/apitests/afd/windowsize.c
b/modules/rostests/apitests/afd/windowsize.c
new file mode 100644
index 0000000000..1ebb945781
--- /dev/null
+++ b/modules/rostests/apitests/afd/windowsize.c
@@ -0,0 +1,306 @@
+/*
+ * PROJECT: ReactOS API Tests
+ * LICENSE: LGPL-2.1+ (
https://spdx.org/licenses/LGPL-2.1+)
+ * PURPOSE: Test for AFD_INFO_RECEIVE_WINDOW_SIZE/AFD_INFO_SEND_WINDOW_SIZE
+ * COPYRIGHT: Copyright 2019 Pierre Schweitzer (pierre(a)reactos.org)
+ */
+
+#include "precomp.h"
+
+static
+void
+TestTcp(void)
+{
+ NTSTATUS Status;
+ HANDLE SocketHandle;
+ struct sockaddr_in addr;
+ ULONG OrigReceiveSize, OrigSendSize, ReceiveSize, SendSize;
+
+ Status = AfdCreateSocket(&SocketHandle, AF_INET, SOCK_STREAM, IPPROTO_TCP);
+ ok(Status == STATUS_SUCCESS, "AfdCreateSocket failed with %lx\n", Status);
+
+ Status = AfdGetInformation(SocketHandle, AFD_INFO_RECEIVE_WINDOW_SIZE, NULL,
&OrigReceiveSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdGetInformation failed with %lx\n",
Status);
+ ok(OrigReceiveSize == 0x1000 || OrigReceiveSize == 0x2000, "Invalid size:
%lu\n", OrigReceiveSize);
+ Status = AfdGetInformation(SocketHandle, AFD_INFO_SEND_WINDOW_SIZE, NULL,
&OrigSendSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdGetInformation failed with %lx\n",
Status);
+ ok(OrigSendSize == 0x1000 || OrigSendSize == 0x2000, "Invalid size: %lu\n",
OrigSendSize);
+
+ ReceiveSize = 0;
+ Status = AfdSetInformation(SocketHandle, AFD_INFO_RECEIVE_WINDOW_SIZE, NULL,
&ReceiveSize, NULL);
+ ok(Status == STATUS_INVALID_PARAMETER, "AfdSetInformation failed with
%lx\n", Status);
+ SendSize = 0;
+ Status = AfdSetInformation(SocketHandle, AFD_INFO_SEND_WINDOW_SIZE, NULL,
&SendSize, NULL);
+ ok(Status == STATUS_INVALID_PARAMETER, "AfdSetInformation failed with
%lx\n", Status);
+
+ ReceiveSize = (ULONG)-1L;
+ Status = AfdSetInformation(SocketHandle, AFD_INFO_RECEIVE_WINDOW_SIZE, NULL,
&ReceiveSize, NULL);
+ ok(Status == STATUS_INVALID_PARAMETER, "AfdSetInformation failed with
%lx\n", Status);
+ SendSize = (ULONG)-1L;
+ Status = AfdSetInformation(SocketHandle, AFD_INFO_SEND_WINDOW_SIZE, NULL,
&SendSize, NULL);
+ ok(Status == STATUS_INVALID_PARAMETER, "AfdSetInformation failed with
%lx\n", Status);
+
+ Status = AfdGetInformation(SocketHandle, AFD_INFO_RECEIVE_WINDOW_SIZE, NULL,
&ReceiveSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdGetInformation failed with %lx\n",
Status);
+ ok(ReceiveSize == OrigReceiveSize, "Invalid size: %lu %lu\n", ReceiveSize,
OrigReceiveSize);
+ Status = AfdGetInformation(SocketHandle, AFD_INFO_SEND_WINDOW_SIZE, NULL,
&SendSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdGetInformation failed with %lx\n",
Status);
+ ok(SendSize == OrigSendSize, "Invalid size: %lu %lu\n", SendSize,
OrigSendSize);
+
+ ReceiveSize = OrigReceiveSize;
+ Status = AfdSetInformation(SocketHandle, AFD_INFO_RECEIVE_WINDOW_SIZE, NULL,
&ReceiveSize, NULL);
+ ok(Status == STATUS_INVALID_PARAMETER, "AfdSetInformation failed with
%lx\n", Status);
+ SendSize = OrigSendSize;
+ Status = AfdSetInformation(SocketHandle, AFD_INFO_SEND_WINDOW_SIZE, NULL,
&SendSize, NULL);
+ ok(Status == STATUS_INVALID_PARAMETER, "AfdSetInformation failed with
%lx\n", Status);
+
+ memset(&addr, 0, sizeof(addr));
+ addr.sin_family = AF_INET;
+ addr.sin_addr.s_addr = inet_addr("0.0.0.0");
+ addr.sin_port = htons(0);
+
+ Status = AfdBind(SocketHandle, (const struct sockaddr *)&addr, sizeof(addr));
+ ok(Status == STATUS_SUCCESS, "AfdBind failed with %lx\n", Status);
+
+ Status = AfdGetInformation(SocketHandle, AFD_INFO_RECEIVE_WINDOW_SIZE, NULL,
&ReceiveSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdGetInformation failed with %lx\n",
Status);
+ ok(ReceiveSize == OrigReceiveSize, "Invalid size: %lu %lu\n", ReceiveSize,
OrigReceiveSize);
+ Status = AfdGetInformation(SocketHandle, AFD_INFO_SEND_WINDOW_SIZE, NULL,
&SendSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdGetInformation failed with %lx\n",
Status);
+ ok(SendSize == OrigSendSize, "Invalid size: %lu %lu\n", SendSize,
OrigSendSize);
+
+ ReceiveSize = 0;
+ Status = AfdSetInformation(SocketHandle, AFD_INFO_RECEIVE_WINDOW_SIZE, NULL,
&ReceiveSize, NULL);
+ ok(Status == STATUS_INVALID_PARAMETER, "AfdSetInformation failed with
%lx\n", Status);
+ SendSize = 0;
+ Status = AfdSetInformation(SocketHandle, AFD_INFO_SEND_WINDOW_SIZE, NULL,
&SendSize, NULL);
+ ok(Status == STATUS_INVALID_PARAMETER, "AfdSetInformation failed with
%lx\n", Status);
+
+ ReceiveSize = (ULONG)-1L;
+ Status = AfdSetInformation(SocketHandle, AFD_INFO_RECEIVE_WINDOW_SIZE, NULL,
&ReceiveSize, NULL);
+ ok(Status == STATUS_INVALID_PARAMETER, "AfdSetInformation failed with
%lx\n", Status);
+ SendSize = (ULONG)-1L;
+ Status = AfdSetInformation(SocketHandle, AFD_INFO_SEND_WINDOW_SIZE, NULL,
&SendSize, NULL);
+ ok(Status == STATUS_INVALID_PARAMETER, "AfdSetInformation failed with
%lx\n", Status);
+
+ Status = AfdGetInformation(SocketHandle, AFD_INFO_RECEIVE_WINDOW_SIZE, NULL,
&ReceiveSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdGetInformation failed with %lx\n",
Status);
+ ok(ReceiveSize == OrigReceiveSize, "Invalid size: %lu %lu\n", ReceiveSize,
OrigReceiveSize);
+ Status = AfdGetInformation(SocketHandle, AFD_INFO_SEND_WINDOW_SIZE, NULL,
&SendSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdGetInformation failed with %lx\n",
Status);
+ ok(SendSize == OrigSendSize, "Invalid size: %lu %lu\n", SendSize,
OrigSendSize);
+
+ ReceiveSize = OrigReceiveSize;
+ Status = AfdSetInformation(SocketHandle, AFD_INFO_RECEIVE_WINDOW_SIZE, NULL,
&ReceiveSize, NULL);
+ ok(Status == STATUS_INVALID_PARAMETER, "AfdSetInformation failed with
%lx\n", Status);
+ SendSize = OrigSendSize;
+ Status = AfdSetInformation(SocketHandle, AFD_INFO_SEND_WINDOW_SIZE, NULL,
&SendSize, NULL);
+ ok(Status == STATUS_INVALID_PARAMETER, "AfdSetInformation failed with
%lx\n", Status);
+
+ memset(&addr, 0, sizeof(addr));
+ addr.sin_family = AF_INET;
+ addr.sin_addr.s_addr = inet_addr("8.8.8.8");
+ addr.sin_port = htons(53);
+
+ Status = AfdConnect(SocketHandle, (const struct sockaddr *)&addr, sizeof(addr));
+ ok(Status == STATUS_SUCCESS, "AfdConnect failed with %lx\n", Status);
+
+ Status = AfdGetInformation(SocketHandle, AFD_INFO_RECEIVE_WINDOW_SIZE, NULL,
&ReceiveSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdGetInformation failed with %lx\n",
Status);
+ ok(ReceiveSize == OrigReceiveSize, "Invalid size: %lu %lu\n", ReceiveSize,
OrigReceiveSize);
+ Status = AfdGetInformation(SocketHandle, AFD_INFO_SEND_WINDOW_SIZE, NULL,
&SendSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdGetInformation failed with %lx\n",
Status);
+ ok(SendSize == OrigSendSize, "Invalid size: %lu %lu\n", SendSize,
OrigSendSize);
+
+ ReceiveSize = 0;
+ Status = AfdSetInformation(SocketHandle, AFD_INFO_RECEIVE_WINDOW_SIZE, NULL,
&ReceiveSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdSetInformation failed with %lx\n",
Status);
+ SendSize = 0;
+ Status = AfdSetInformation(SocketHandle, AFD_INFO_SEND_WINDOW_SIZE, NULL,
&SendSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdSetInformation failed with %lx\n",
Status);
+
+ Status = AfdGetInformation(SocketHandle, AFD_INFO_RECEIVE_WINDOW_SIZE, NULL,
&ReceiveSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdGetInformation failed with %lx\n",
Status);
+ ok(ReceiveSize == OrigReceiveSize, "Invalid size: %lu %lu\n", ReceiveSize,
OrigReceiveSize);
+ Status = AfdGetInformation(SocketHandle, AFD_INFO_SEND_WINDOW_SIZE, NULL,
&SendSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdGetInformation failed with %lx\n",
Status);
+ ok(SendSize == OrigSendSize, "Invalid size: %lu %lu\n", SendSize,
OrigSendSize);
+
+ ReceiveSize = (ULONG)-1L;
+ Status = AfdSetInformation(SocketHandle, AFD_INFO_RECEIVE_WINDOW_SIZE, NULL,
&ReceiveSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdSetInformation failed with %lx\n",
Status);
+ SendSize = (ULONG)-1L;
+ Status = AfdSetInformation(SocketHandle, AFD_INFO_SEND_WINDOW_SIZE, NULL,
&SendSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdSetInformation failed with %lx\n",
Status);
+
+ Status = AfdGetInformation(SocketHandle, AFD_INFO_RECEIVE_WINDOW_SIZE, NULL,
&ReceiveSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdGetInformation failed with %lx\n",
Status);
+ ok(ReceiveSize == OrigReceiveSize, "Invalid size: %lu %lu\n", ReceiveSize,
OrigReceiveSize);
+ Status = AfdGetInformation(SocketHandle, AFD_INFO_SEND_WINDOW_SIZE, NULL,
&SendSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdGetInformation failed with %lx\n",
Status);
+ ok(SendSize == OrigSendSize, "Invalid size: %lu %lu\n", SendSize,
OrigSendSize);
+
+ ReceiveSize = OrigReceiveSize + 1;
+ Status = AfdSetInformation(SocketHandle, AFD_INFO_RECEIVE_WINDOW_SIZE, NULL,
&ReceiveSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdSetInformation failed with %lx\n",
Status);
+ SendSize = OrigSendSize + 1;
+ Status = AfdSetInformation(SocketHandle, AFD_INFO_SEND_WINDOW_SIZE, NULL,
&SendSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdSetInformation failed with %lx\n",
Status);
+
+ Status = AfdGetInformation(SocketHandle, AFD_INFO_RECEIVE_WINDOW_SIZE, NULL,
&ReceiveSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdGetInformation failed with %lx\n",
Status);
+ ok(ReceiveSize == OrigReceiveSize, "Invalid size: %lu %lu\n", ReceiveSize,
OrigReceiveSize);
+ Status = AfdGetInformation(SocketHandle, AFD_INFO_SEND_WINDOW_SIZE, NULL,
&SendSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdGetInformation failed with %lx\n",
Status);
+ ok(SendSize == OrigSendSize, "Invalid size: %lu %lu\n", SendSize,
OrigSendSize);
+
+ ReceiveSize = OrigReceiveSize - 1;
+ Status = AfdSetInformation(SocketHandle, AFD_INFO_RECEIVE_WINDOW_SIZE, NULL,
&ReceiveSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdSetInformation failed with %lx\n",
Status);
+ SendSize = OrigSendSize - 1;
+ Status = AfdSetInformation(SocketHandle, AFD_INFO_SEND_WINDOW_SIZE, NULL,
&SendSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdSetInformation failed with %lx\n",
Status);
+
+ Status = AfdGetInformation(SocketHandle, AFD_INFO_RECEIVE_WINDOW_SIZE, NULL,
&ReceiveSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdGetInformation failed with %lx\n",
Status);
+ ok(ReceiveSize == OrigReceiveSize, "Invalid size: %lu %lu\n", ReceiveSize,
OrigReceiveSize);
+ Status = AfdGetInformation(SocketHandle, AFD_INFO_SEND_WINDOW_SIZE, NULL,
&SendSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdGetInformation failed with %lx\n",
Status);
+ ok(SendSize == OrigSendSize, "Invalid size: %lu %lu\n", SendSize,
OrigSendSize);
+
+ NtClose(SocketHandle);
+}
+
+static
+void
+TestUdp(void)
+{
+ NTSTATUS Status;
+ HANDLE SocketHandle;
+ struct sockaddr_in addr;
+ ULONG OrigReceiveSize, OrigSendSize, ReceiveSize, SendSize;
+
+ Status = AfdCreateSocket(&SocketHandle, AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+ ok(Status == STATUS_SUCCESS, "AfdCreateSocket failed with %lx\n", Status);
+
+ Status = AfdGetInformation(SocketHandle, AFD_INFO_RECEIVE_WINDOW_SIZE, NULL,
&OrigReceiveSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdGetInformation failed with %lx\n",
Status);
+ ok(OrigReceiveSize == 0x1000 || OrigReceiveSize == 0x2000, "Invalid size:
%lu\n", OrigReceiveSize);
+ Status = AfdGetInformation(SocketHandle, AFD_INFO_SEND_WINDOW_SIZE, NULL,
&OrigSendSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdGetInformation failed with %lx\n",
Status);
+ ok(OrigSendSize == 0x1000 || OrigSendSize == 0x2000, "Invalid size: %lu\n",
OrigSendSize);
+
+ ReceiveSize = 0;
+ Status = AfdSetInformation(SocketHandle, AFD_INFO_RECEIVE_WINDOW_SIZE, NULL,
&ReceiveSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdSetInformation failed with %lx\n",
Status);
+ SendSize = 0;
+ Status = AfdSetInformation(SocketHandle, AFD_INFO_SEND_WINDOW_SIZE, NULL,
&SendSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdSetInformation failed with %lx\n",
Status);
+
+ Status = AfdGetInformation(SocketHandle, AFD_INFO_RECEIVE_WINDOW_SIZE, NULL,
&ReceiveSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdGetInformation failed with %lx\n",
Status);
+ ok(ReceiveSize == OrigReceiveSize, "Invalid size: %lu %lu\n", ReceiveSize,
OrigReceiveSize);
+ Status = AfdGetInformation(SocketHandle, AFD_INFO_SEND_WINDOW_SIZE, NULL,
&SendSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdGetInformation failed with %lx\n",
Status);
+ ok(SendSize == OrigSendSize, "Invalid size: %lu %lu\n", SendSize,
OrigSendSize);
+
+ ReceiveSize = (ULONG)-1L;
+ Status = AfdSetInformation(SocketHandle, AFD_INFO_RECEIVE_WINDOW_SIZE, NULL,
&ReceiveSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdSetInformation failed with %lx\n",
Status);
+ SendSize = (ULONG)-1L;
+ Status = AfdSetInformation(SocketHandle, AFD_INFO_SEND_WINDOW_SIZE, NULL,
&SendSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdSetInformation failed with %lx\n",
Status);
+
+ Status = AfdGetInformation(SocketHandle, AFD_INFO_RECEIVE_WINDOW_SIZE, NULL,
&ReceiveSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdGetInformation failed with %lx\n",
Status);
+ ok(ReceiveSize == OrigReceiveSize, "Invalid size: %lu %lu\n", ReceiveSize,
OrigReceiveSize);
+ Status = AfdGetInformation(SocketHandle, AFD_INFO_SEND_WINDOW_SIZE, NULL,
&SendSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdGetInformation failed with %lx\n",
Status);
+ ok(SendSize == OrigSendSize, "Invalid size: %lu %lu\n", SendSize,
OrigSendSize);
+
+ ReceiveSize = OrigReceiveSize;
+ Status = AfdSetInformation(SocketHandle, AFD_INFO_RECEIVE_WINDOW_SIZE, NULL,
&ReceiveSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdSetInformation failed with %lx\n",
Status);
+ SendSize = OrigSendSize;
+ Status = AfdSetInformation(SocketHandle, AFD_INFO_SEND_WINDOW_SIZE, NULL,
&SendSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdSetInformation failed with %lx\n",
Status);
+
+ memset(&addr, 0, sizeof(addr));
+ addr.sin_family = AF_INET;
+ addr.sin_addr.s_addr = inet_addr("0.0.0.0");
+ addr.sin_port = htons(0);
+
+ Status = AfdBind(SocketHandle, (const struct sockaddr *)&addr, sizeof(addr));
+ ok(Status == STATUS_SUCCESS, "AfdBind failed with %lx\n", Status);
+
+ Status = AfdGetInformation(SocketHandle, AFD_INFO_RECEIVE_WINDOW_SIZE, NULL,
&ReceiveSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdGetInformation failed with %lx\n",
Status);
+ ok(ReceiveSize == OrigReceiveSize, "Invalid size: %lu %lu\n", ReceiveSize,
OrigReceiveSize);
+ Status = AfdGetInformation(SocketHandle, AFD_INFO_SEND_WINDOW_SIZE, NULL,
&SendSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdGetInformation failed with %lx\n",
Status);
+ ok(SendSize == OrigSendSize, "Invalid size: %lu %lu\n", SendSize,
OrigSendSize);
+
+ ReceiveSize = 0;
+ Status = AfdSetInformation(SocketHandle, AFD_INFO_RECEIVE_WINDOW_SIZE, NULL,
&ReceiveSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdSetInformation failed with %lx\n",
Status);
+ SendSize = 0;
+ Status = AfdSetInformation(SocketHandle, AFD_INFO_SEND_WINDOW_SIZE, NULL,
&SendSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdSetInformation failed with %lx\n",
Status);
+
+ Status = AfdGetInformation(SocketHandle, AFD_INFO_RECEIVE_WINDOW_SIZE, NULL,
&ReceiveSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdGetInformation failed with %lx\n",
Status);
+ ok(ReceiveSize == OrigReceiveSize, "Invalid size: %lu %lu\n", ReceiveSize,
OrigReceiveSize);
+ Status = AfdGetInformation(SocketHandle, AFD_INFO_SEND_WINDOW_SIZE, NULL,
&SendSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdGetInformation failed with %lx\n",
Status);
+ ok(SendSize == OrigSendSize, "Invalid size: %lu %lu\n", SendSize,
OrigSendSize);
+
+ ReceiveSize = (ULONG)-1L;
+ Status = AfdSetInformation(SocketHandle, AFD_INFO_RECEIVE_WINDOW_SIZE, NULL,
&ReceiveSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdSetInformation failed with %lx\n",
Status);
+ SendSize = (ULONG)-1L;
+ Status = AfdSetInformation(SocketHandle, AFD_INFO_SEND_WINDOW_SIZE, NULL,
&SendSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdSetInformation failed with %lx\n",
Status);
+
+ Status = AfdGetInformation(SocketHandle, AFD_INFO_RECEIVE_WINDOW_SIZE, NULL,
&ReceiveSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdGetInformation failed with %lx\n",
Status);
+ ok(ReceiveSize == OrigReceiveSize, "Invalid size: %lu %lu\n", ReceiveSize,
OrigReceiveSize);
+ Status = AfdGetInformation(SocketHandle, AFD_INFO_SEND_WINDOW_SIZE, NULL,
&SendSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdGetInformation failed with %lx\n",
Status);
+ ok(SendSize == OrigSendSize, "Invalid size: %lu %lu\n", SendSize,
OrigSendSize);
+
+ ReceiveSize = OrigReceiveSize + 1;
+ Status = AfdSetInformation(SocketHandle, AFD_INFO_RECEIVE_WINDOW_SIZE, NULL,
&ReceiveSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdSetInformation failed with %lx\n",
Status);
+ SendSize = OrigSendSize + 1;
+ Status = AfdSetInformation(SocketHandle, AFD_INFO_SEND_WINDOW_SIZE, NULL,
&SendSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdSetInformation failed with %lx\n",
Status);
+
+ Status = AfdGetInformation(SocketHandle, AFD_INFO_RECEIVE_WINDOW_SIZE, NULL,
&ReceiveSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdGetInformation failed with %lx\n",
Status);
+ ok(ReceiveSize == OrigReceiveSize, "Invalid size: %lu %lu\n", ReceiveSize,
OrigReceiveSize);
+ Status = AfdGetInformation(SocketHandle, AFD_INFO_SEND_WINDOW_SIZE, NULL,
&SendSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdGetInformation failed with %lx\n",
Status);
+ ok(SendSize == OrigSendSize, "Invalid size: %lu %lu\n", SendSize,
OrigSendSize);
+
+ ReceiveSize = OrigReceiveSize - 1;
+ Status = AfdSetInformation(SocketHandle, AFD_INFO_RECEIVE_WINDOW_SIZE, NULL,
&ReceiveSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdSetInformation failed with %lx\n",
Status);
+ SendSize = OrigSendSize - 1;
+ Status = AfdSetInformation(SocketHandle, AFD_INFO_SEND_WINDOW_SIZE, NULL,
&SendSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdSetInformation failed with %lx\n",
Status);
+
+ Status = AfdGetInformation(SocketHandle, AFD_INFO_RECEIVE_WINDOW_SIZE, NULL,
&ReceiveSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdGetInformation failed with %lx\n",
Status);
+ ok(ReceiveSize == OrigReceiveSize, "Invalid size: %lu %lu\n", ReceiveSize,
OrigReceiveSize);
+ Status = AfdGetInformation(SocketHandle, AFD_INFO_SEND_WINDOW_SIZE, NULL,
&SendSize, NULL);
+ ok(Status == STATUS_SUCCESS, "AfdGetInformation failed with %lx\n",
Status);
+ ok(SendSize == OrigSendSize, "Invalid size: %lu %lu\n", SendSize,
OrigSendSize);
+
+ NtClose(SocketHandle);
+}
+
+START_TEST(windowsize)
+{
+ TestTcp();
+ TestUdp();
+}