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
;
25 /* Open a control channel file for TCP */
26 FileHandle
= CreateFileW(
28 FILE_READ_DATA
| FILE_WRITE_DATA
,
29 FILE_SHARE_READ
| FILE_SHARE_WRITE
,
34 ok(FileHandle
!= INVALID_HANDLE_VALUE
, "CreateFile failed, GLE %lu\n", GetLastError());
38 pInterfaceInfo
= &InterfaceInfo
;
39 Result
= DeviceIoControl(
41 IOCTL_IP_INTERFACE_INFO
,
45 sizeof(InterfaceInfo
),
48 Error
= GetLastError();
49 ok(!Result
, "DeviceIoControl succeeded.\n");
50 ok_long(Error
, ERROR_INVALID_FUNCTION
);
51 ok_long(BufferSize
, 0);
53 CloseHandle(FileHandle
);
55 /* This IOCTL only works with \Device\Ip */
56 FileHandle
= CreateFileW(
58 FILE_READ_DATA
| FILE_WRITE_DATA
,
59 FILE_SHARE_READ
| FILE_SHARE_WRITE
,
64 ok(FileHandle
!= INVALID_HANDLE_VALUE
, "CreateFile failed, GLE %lu\n", GetLastError());
66 /* Get the buffer size. */
68 pInterfaceInfo
= &InterfaceInfo
;
69 Result
= DeviceIoControl(
71 IOCTL_IP_INTERFACE_INFO
,
75 sizeof(InterfaceInfo
),
78 ok(Result
, "DeviceIoControl failed, GLE %lu.\n", GetLastError());
79 ok(BufferSize
!= 0, "Buffer size is zero.\n");
80 trace("Buffer size is %lu.\n", BufferSize
);
82 if (BufferSize
> sizeof(InterfaceInfo
))
84 pInterfaceInfo
= HeapAlloc(GetProcessHeap(), 0, BufferSize
);
85 ok(pInterfaceInfo
!= NULL
, "HeapAlloc failed.\n");
87 /* Send IOCTL to fill the buffer in. */
88 Result
= DeviceIoControl(
90 IOCTL_IP_INTERFACE_INFO
,
97 ok(Result
, "DeviceIoControl failed, GLE %lu.\n", GetLastError());
100 if (Result
&& BufferSize
>= RTL_SIZEOF_THROUGH_FIELD(IP_INTERFACE_INFO
, NumAdapters
))
102 /* Nothing much to test. Just print out the adapters we got */
103 trace("We got %ld adapters.\n", pInterfaceInfo
->NumAdapters
);
104 for (i
= 0; i
< pInterfaceInfo
->NumAdapters
; i
++)
106 trace("\tIndex %lu, name %S\n", pInterfaceInfo
->Adapter
[i
].Index
, pInterfaceInfo
->Adapter
[i
].Name
);
110 if (pInterfaceInfo
!= &InterfaceInfo
)
111 HeapFree(GetProcessHeap(), 0, pInterfaceInfo
);
112 CloseHandle(FileHandle
);