2 * PROJECT: ReactOS kernel-mode tests
3 * LICENSE: GPLv2+ - See COPYING in the top level directory
4 * PURPOSE: User mode part of the TcpIp.sys test suite
5 * PROGRAMMER: Jérôme Gardou <jerome.gardou@reactos.org>
13 #include <tcpip_undoc.h>
15 START_TEST(InterfaceInfo
)
17 IP_INTERFACE_INFO
* pInterfaceInfo
;
18 IP_INTERFACE_INFO InterfaceInfo
;
24 /* Open a control channel file for TCP */
25 FileHandle
= CreateFileW(
27 FILE_READ_DATA
| FILE_WRITE_DATA
,
28 FILE_SHARE_READ
| FILE_SHARE_WRITE
,
33 ok(FileHandle
!= INVALID_HANDLE_VALUE
, "CreateFile failed, GLE %lu\n", GetLastError());
37 pInterfaceInfo
= &InterfaceInfo
;
38 Result
= DeviceIoControl(
40 IOCTL_IP_INTERFACE_INFO
,
44 sizeof(InterfaceInfo
),
47 ok(!Result
, "DeviceIoControl succeeded.\n");
48 ok_long(GetLastError(), ERROR_INVALID_FUNCTION
);
49 ok_long(BufferSize
, 0);
51 CloseHandle(FileHandle
);
53 /* This IOCTL only works with \Device\Ip */
54 FileHandle
= CreateFileW(
56 FILE_READ_DATA
| FILE_WRITE_DATA
,
57 FILE_SHARE_READ
| FILE_SHARE_WRITE
,
62 ok(FileHandle
!= INVALID_HANDLE_VALUE
, "CreateFile failed, GLE %lu\n", GetLastError());
64 /* Get the buffer size. */
66 pInterfaceInfo
= &InterfaceInfo
;
67 Result
= DeviceIoControl(
69 IOCTL_IP_INTERFACE_INFO
,
73 sizeof(InterfaceInfo
),
76 ok(Result
, "DeviceIoControl failed.\n");
77 ok(BufferSize
!= 0, "Buffer size is zero.\n");
78 trace("Buffer size is %lu.\n", BufferSize
);
80 if (BufferSize
> sizeof(InterfaceInfo
))
82 pInterfaceInfo
= HeapAlloc(GetProcessHeap(), 0, BufferSize
);
83 ok(pInterfaceInfo
!= NULL
, "HeapAlloc failed.\n");
85 /* Send IOCTL to fill the buffer in. */
86 Result
= DeviceIoControl(
88 IOCTL_IP_INTERFACE_INFO
,
95 ok(Result
, "DeviceIoControl failed.\n");
98 /* Nothing much to test. Just print out the adapters we got */
99 trace("We got %ld adapters.\n", pInterfaceInfo
->NumAdapters
);
100 for (i
= 0; i
< pInterfaceInfo
->NumAdapters
; i
++)
102 trace("\tIndex %lu, name %S\n", pInterfaceInfo
->Adapter
[i
].Index
, pInterfaceInfo
->Adapter
[i
].Name
);
105 if (pInterfaceInfo
!= &InterfaceInfo
)
106 HeapFree(GetProcessHeap(), 0, pInterfaceInfo
);
107 CloseHandle(FileHandle
);