ReactOS  0.4.13-dev-1148-g9b75b67
InterfaceInfo.c File Reference
#include <apitest.h>
#include <ipexport.h>
#include <winioctl.h>
#include <tcpioctl.h>
#include <tcpip_undoc.h>
Include dependency graph for InterfaceInfo.c:

Go to the source code of this file.

Functions

 START_TEST (InterfaceInfo)
 

Function Documentation

◆ START_TEST()

START_TEST ( InterfaceInfo  )

Definition at line 15 of file InterfaceInfo.c.

16 {
17  IP_INTERFACE_INFO* pInterfaceInfo;
18  IP_INTERFACE_INFO InterfaceInfo;
21  BOOL Result;
22  DWORD Error;
23  ULONG i;
24 
25  /* Open a control channel file for TCP */
27  L"\\\\.\\Tcp",
30  NULL,
33  NULL);
34  ok(FileHandle != INVALID_HANDLE_VALUE, "CreateFile failed, GLE %lu\n", GetLastError());
35 
36  /* Try the IOCTL */
37  BufferSize = 0;
38  pInterfaceInfo = &InterfaceInfo;
40  FileHandle,
42  NULL,
43  0,
44  pInterfaceInfo,
45  sizeof(InterfaceInfo),
46  &BufferSize,
47  NULL);
48  Error = GetLastError();
49  ok(!Result, "DeviceIoControl succeeded.\n");
51  ok_long(BufferSize, 0);
52 
54 
55  /* This IOCTL only works with \Device\Ip */
57  L"\\\\.\\Ip",
60  NULL,
63  NULL);
64  ok(FileHandle != INVALID_HANDLE_VALUE, "CreateFile failed, GLE %lu\n", GetLastError());
65 
66  /* Get the buffer size. */
67  BufferSize = 0;
68  pInterfaceInfo = &InterfaceInfo;
70  FileHandle,
72  NULL,
73  0,
74  pInterfaceInfo,
75  sizeof(InterfaceInfo),
76  &BufferSize,
77  NULL);
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);
81 
82  if (BufferSize > sizeof(InterfaceInfo))
83  {
84  pInterfaceInfo = HeapAlloc(GetProcessHeap(), 0, BufferSize);
85  ok(pInterfaceInfo != NULL, "HeapAlloc failed.\n");
86 
87  /* Send IOCTL to fill the buffer in. */
89  FileHandle,
91  NULL,
92  0,
93  pInterfaceInfo,
94  BufferSize,
95  &BufferSize,
96  NULL);
97  ok(Result, "DeviceIoControl failed, GLE %lu.\n", GetLastError());
98  }
99 
101  {
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++)
105  {
106  trace("\tIndex %lu, name %S\n", pInterfaceInfo->Adapter[i].Index, pInterfaceInfo->Adapter[i].Name);
107  }
108  }
109 
110  if (pInterfaceInfo != &InterfaceInfo)
111  HeapFree(GetProcessHeap(), 0, pInterfaceInfo);
113 }
IP_ADAPTER_INDEX_MAP Adapter[1]
Definition: ipexport.h:141
#define CloseHandle
Definition: compat.h:398
#define ERROR_INVALID_FUNCTION
Definition: dderror.h:6
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define ok_long(expression, result)
Definition: atltest.h:133
#define FILE_SHARE_READ
Definition: compat.h:125
HANDLE FileHandle
Definition: stats.c:38
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FILE_READ_DATA
Definition: nt_native.h:628
#define IOCTL_IP_INTERFACE_INFO
Definition: tcpip_undoc.h:5
smooth NULL
Definition: ftsmooth.c:416
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
WCHAR Name[MAX_ADAPTER_NAME]
Definition: ipexport.h:136
#define FILE_WRITE_DATA
Definition: nt_native.h:631
#define OPEN_EXISTING
Definition: compat.h:426
#define GetProcessHeap()
Definition: compat.h:395
#define trace
Definition: atltest.h:70
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define BufferSize
Definition: classpnp.h:419
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL Error
Definition: chkdsk.c:66
#define RTL_SIZEOF_THROUGH_FIELD(type, field)
Definition: ntbasedef.h:679
static const WCHAR L[]
Definition: oid.c:1250
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136
#define ok(value,...)
Definition: atltest.h:57
#define CreateFileW
Definition: compat.h:400
unsigned int ULONG
Definition: retypes.h:1
#define FILE_FLAG_OVERLAPPED
Definition: disk.h:46
#define HeapFree(x, y, z)
Definition: compat.h:394