ReactOS  0.4.14-dev-583-g2a1ba2c
SendARP.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS api tests
3  * LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory
4  * PURPOSE: Test for SendARP
5  * PROGRAMMER: Pierre Schweitzer <pierre@reactos.org>
6  */
7 
8 #include <apitest.h>
9 #include <winsock2.h>
10 #include <iphlpapi.h>
11 #include <tcpioctl.h>
12 #define NTOS_MODE_USER
13 #include <ndk/iofuncs.h>
14 #include <ndk/obfuncs.h>
15 #include <ndk/rtlfuncs.h>
16 
17 static VOID TestUM(IPAddr * Source, IPAddr * Gateway)
18 {
19  DWORD Err;
20  ULONG Hw[2];
21  DWORD Size;
22  BOOL Tested = FALSE;
23  PIP_ADAPTER_ADDRESSES Addresses, Current;
24  PIP_ADAPTER_INFO Adapters, CurrentA;
25 
26  Err = SendARP(0, 0, NULL, NULL);
27  ok(Err == ERROR_INVALID_PARAMETER, "Expected error: ERROR_INVALID_PARAMETER. Got: %lx\n", Err);
28 
29  Size = 4;
30  Err = SendARP(0, 0, Hw, &Size);
31  ok(Err == ERROR_GEN_FAILURE, "Expected error: ERROR_GEN_FAILURE. Got: %lx\n", Err);
32 
33  Size = 6;
34  Err = SendARP(0, 0, Hw, &Size);
35  ok(Err == ERROR_GEN_FAILURE, "Expected error: ERROR_GEN_FAILURE. Got: %lx\n", Err);
36 
37  Size = 8;
38  Err = SendARP(0, 0, Hw, &Size);
39  ok(Err == ERROR_GEN_FAILURE, "Expected error: ERROR_GEN_FAILURE. Got: %lx\n", Err);
40 
41  Size = sizeof(IP_ADAPTER_ADDRESSES);
42  Addresses = (PIP_ADAPTER_ADDRESSES)malloc(Size);
43  if (!Addresses)
44  {
45  skip("Memory failure\n");
46  return;
47  }
48 
49  Err = GetAdaptersAddresses(AF_INET, GAA_FLAG_SKIP_FRIENDLY_NAME | GAA_FLAG_SKIP_DNS_SERVER | GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST, NULL, Addresses, &Size);
50  if (Err == ERROR_BUFFER_OVERFLOW)
51  {
52  free(Addresses);
53  Addresses = (PIP_ADAPTER_ADDRESSES)malloc(Size);
54  if (!Addresses)
55  {
56  skip("Memory failure\n");
57  return;
58  }
59 
60  Err = GetAdaptersAddresses(AF_INET, GAA_FLAG_SKIP_FRIENDLY_NAME | GAA_FLAG_SKIP_DNS_SERVER | GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST, NULL, Addresses, &Size);
61  }
62 
63  if (Err != ERROR_SUCCESS)
64  {
65  skip("GetAdaptersAddresses() failure\n");
66  free(Addresses);
67  return;
68  }
69 
70  for (Current = Addresses; Current; Current = Current->Next)
71  {
72  PSOCKADDR_IN SockAddr;
73  IPAddr IpAddr;
74 
75  if (Current->IfType == IF_TYPE_SOFTWARE_LOOPBACK)
76  continue;
77 
78  if (Current->OperStatus != IfOperStatusUp)
79  continue;
80 
81  if (!Current->FirstUnicastAddress)
82  continue;
83 
84  ok(Current->FirstUnicastAddress->Address.iSockaddrLength == sizeof(SOCKADDR_IN), "Unexpected length: %u\n", Current->FirstUnicastAddress->Address.iSockaddrLength);
85  SockAddr = (PSOCKADDR_IN)Current->FirstUnicastAddress->Address.lpSockaddr;
86  IpAddr = SockAddr->sin_addr.S_un.S_addr;
87 
88  trace("IP address found: %lu.%lu.%lu.%lu\n", IpAddr & 0xFF, (IpAddr >> 8) & 0xFF, (IpAddr >> 16) & 0xFF, (IpAddr >> 24) & 0xFF);
89 
90  Size = 4;
91  Err = SendARP(IpAddr, 0, Hw, &Size);
92  ok(Err == ERROR_NO_SYSTEM_RESOURCES, "Expected error: ERROR_NO_SYSTEM_RESOURCES. Got: %lx\n", Err);
93 
94  Size = 6;
95  Err = SendARP(IpAddr, 0, Hw, &Size);
96  ok(Err == ERROR_SUCCESS, "Expected error: ERROR_SUCCESS. Got: %lx\n", Err);
97 
98  Size = 8;
99  Err = SendARP(IpAddr, 0, Hw, &Size);
100  ok(Err == ERROR_SUCCESS, "Expected error: ERROR_SUCCESS. Got: %lx\n", Err);
101  Err = SendARP(IpAddr, 0x08080808, Hw, &Size);
102  ok(Err == ERROR_SUCCESS, "Expected error: ERROR_SUCCESS. Got: %lx\n", Err);
103 
104  Size = 4;
105  Err = SendARP(IpAddr, IpAddr, Hw, &Size);
106  ok(Err == ERROR_NO_SYSTEM_RESOURCES, "Expected error: ERROR_NO_SYSTEM_RESOURCES. Got: %lx\n", Err);
107 
108  Size = 6;
109  Err = SendARP(IpAddr, IpAddr, Hw, &Size);
110  ok(Err == ERROR_SUCCESS, "Expected error: ERROR_SUCCESS. Got: %lx\n", Err);
111 
112  Size = 8;
113  Err = SendARP(IpAddr, IpAddr, Hw, &Size);
114  ok(Err == ERROR_SUCCESS, "Expected error: ERROR_SUCCESS. Got: %lx\n", Err);
115 
116  *Source = IpAddr;
117  Tested = TRUE;
118  break;
119  }
120 
121  free(Addresses);
122 
123  if (!Tested)
124  {
125  skip("No suitable interface found\n");
126  return;
127  }
128 
129  Size = sizeof(IP_ADAPTER_INFO);
130  Adapters = (PIP_ADAPTER_INFO)malloc(Size);
131  if (!Adapters)
132  {
133  skip("Memory failure\n");
134  return;
135  }
136 
137  Err = GetAdaptersInfo(Adapters, &Size);
138  if (Err == ERROR_BUFFER_OVERFLOW)
139  {
140  free(Adapters);
141  Adapters = (PIP_ADAPTER_INFO)malloc(Size);
142  if (!Adapters)
143  {
144  skip("Memory failure\n");
145  return;
146  }
147 
148  Err = GetAdaptersInfo(Adapters, &Size);
149  }
150 
151  if (Err != ERROR_SUCCESS)
152  {
153  skip("GetAdaptersInfo() failure\n");
154  free(Adapters);
155  return;
156  }
157 
158  Tested = FALSE;
159  for (CurrentA = Adapters; CurrentA; CurrentA = CurrentA->Next)
160  {
161  IPAddr IpAddr;
163  const CHAR * Terminator;
164 
165  Status = RtlIpv4StringToAddressA(CurrentA->IpAddressList.IpAddress.String, TRUE, &Terminator, (struct in_addr *)&IpAddr);
166  if (!NT_SUCCESS(Status))
167  continue;
168 
169  if (IpAddr != *Source)
170  continue;
171 
172  Status = RtlIpv4StringToAddressA(CurrentA->GatewayList.IpAddress.String, TRUE, &Terminator, (struct in_addr *)&IpAddr);
173  if (NT_SUCCESS(Status))
174  {
175  trace("Gateway found: %lu.%lu.%lu.%lu\n", IpAddr & 0xFF, (IpAddr >> 8) & 0xFF, (IpAddr >> 16) & 0xFF, (IpAddr >> 24) & 0xFF);
176  Tested = TRUE;
177  *Gateway = IpAddr;
178  }
179 
180  break;
181  }
182 
183  free(Adapters);
184 
185  if (!Tested)
186  {
187  skip("No suitable gateway found\n");
188  return;
189  }
190 
191  Size = 4;
192  Err = SendARP(*Gateway, *Source, Hw, &Size);
193  ok(Err == ERROR_GEN_FAILURE, "Expected error: ERROR_GEN_FAILURE. Got: %lx\n", Err);
194 
195  Size = 6;
196  Err = SendARP(*Gateway, *Source, Hw, &Size);
197  ok(Err == ERROR_SUCCESS, "Expected error: ERROR_SUCCESS. Got: %lx\n", Err);
198 
199  Size = 8;
200  Err = SendARP(*Gateway, *Source, Hw, &Size);
201  ok(Err == ERROR_SUCCESS, "Expected error: ERROR_SUCCESS. Got: %lx\n", Err);
202 
203  Size = 4;
204  Err = SendARP(*Source, *Gateway, Hw, &Size);
205  ok(Err == ERROR_NO_SYSTEM_RESOURCES, "Expected error: ERROR_NO_SYSTEM_RESOURCES. Got: %lx\n", Err);
206 
207  Size = 6;
208  Err = SendARP(*Source, *Gateway, Hw, &Size);
209  ok(Err == ERROR_SUCCESS, "Expected error: ERROR_SUCCESS. Got: %lx\n", Err);
210 
211  Size = 8;
212  Err = SendARP(*Source, *Gateway, Hw, &Size);
213  ok(Err == ERROR_SUCCESS, "Expected error: ERROR_SUCCESS. Got: %lx\n", Err);
214 
215  Size = 4;
216  Err = SendARP(*Gateway, 0x08080808, Hw, &Size);
217  ok(Err == ERROR_GEN_FAILURE, "Expected error: ERROR_GEN_FAILURE. Got: %lx\n", Err);
218 
219  Size = 6;
220  Err = SendARP(*Gateway, 0x08080808, Hw, &Size);
221  ok(Err == ERROR_SUCCESS, "Expected error: ERROR_SUCCESS. Got: %lx\n", Err);
222 
223  Size = 8;
224  Err = SendARP(*Gateway, 0x08080808, Hw, &Size);
225  ok(Err == ERROR_SUCCESS, "Expected error: ERROR_SUCCESS. Got: %lx\n", Err);
226 
227  Size = 4;
228  Err = SendARP(*Source, 0x08080808, Hw, &Size);
229  ok(Err == ERROR_NO_SYSTEM_RESOURCES, "Expected error: ERROR_NO_SYSTEM_RESOURCES. Got: %lx\n", Err);
230 
231  Size = 6;
232  Err = SendARP(*Source, 0x08080808, Hw, &Size);
233  ok(Err == ERROR_SUCCESS, "Expected error: ERROR_SUCCESS. Got: %lx\n", Err);
234 
235  Size = 8;
236  Err = SendARP(*Source, 0x08080808, Hw, &Size);
237  ok(Err == ERROR_SUCCESS, "Expected error: ERROR_SUCCESS. Got: %lx\n", Err);
238 }
239 
240 static VOID TestKM(IPAddr Source, IPAddr Gateway)
241 {
242  HANDLE hDevice;
245  UNICODE_STRING DevName = RTL_CONSTANT_STRING(L"\\Device\\Ip");
247  HANDLE hEvent;
248  ULONG Hw[2];
249  ULONG Ip[2];
250 
252  &DevName,
254  NULL,
255  NULL);
256 
259  0, NULL, 0);
260  if (!NT_SUCCESS(Status))
261  {
262  skip("NtCreateFile() failed with status: %lx\n", Status);
263  return;
264  }
265 
267  if (!hEvent)
268  {
269  skip("CreateEventW() with error: %lx\n", GetLastError());
270  CloseHandle(hDevice);
271  return;
272  }
273 
277  if (Status == STATUS_PENDING)
278  {
281  }
282  ok(Status == STATUS_INVALID_BUFFER_SIZE, "NtDeviceIoControlFile() failed with unexpected status: %lx\n", Status);
283  ok(IoStatusBlock.Information == 0, "Excepted 0, got: %lu\n", IoStatusBlock.Information);
284 
285  memset(Ip, 0, sizeof(Ip));
290  if (Status == STATUS_PENDING)
291  {
294  }
295  ok(Status == STATUS_INVALID_BUFFER_SIZE, "NtDeviceIoControlFile() failed with unexpected status: %lx\n", Status);
296  ok(IoStatusBlock.Information == 0, "Excepted 0, got: %lu\n", IoStatusBlock.Information);
297 
301  Status = NtDeviceIoControlFile(hDevice, hEvent, NULL, NULL, &IoStatusBlock, IOCTL_QUERY_IP_HW_ADDRESS, Ip, sizeof(Ip), Hw, 4);
302  if (Status == STATUS_PENDING)
303  {
306  }
307  ok(Status == STATUS_UNSUCCESSFUL, "NtDeviceIoControlFile() failed with unexpected status: %lx\n", Status);
308  ok(IoStatusBlock.Information == 0, "Excepted 0, got: %lu\n", IoStatusBlock.Information);
309 
313  Status = NtDeviceIoControlFile(hDevice, hEvent, NULL, NULL, &IoStatusBlock, IOCTL_QUERY_IP_HW_ADDRESS, Ip, sizeof(Ip), Hw, 6);
314  if (Status == STATUS_PENDING)
315  {
318  }
319  ok(Status == STATUS_UNSUCCESSFUL, "NtDeviceIoControlFile() failed with unexpected status: %lx\n", Status);
320  ok(IoStatusBlock.Information == 0, "Excepted 0, got: %lu\n", IoStatusBlock.Information);
321 
325  Status = NtDeviceIoControlFile(hDevice, hEvent, NULL, NULL, &IoStatusBlock, IOCTL_QUERY_IP_HW_ADDRESS, Ip, sizeof(Ip), Hw, 8);
326  if (Status == STATUS_PENDING)
327  {
330  }
331  ok(Status == STATUS_UNSUCCESSFUL, "NtDeviceIoControlFile() failed with unexpected status: %lx\n", Status);
332  ok(IoStatusBlock.Information == 0, "Excepted 0, got: %lu\n", IoStatusBlock.Information);
333 
334  Ip[0] = Source;
339  if (Status == STATUS_PENDING)
340  {
343  }
344  ok(Status == STATUS_INVALID_BUFFER_SIZE, "NtDeviceIoControlFile() failed with unexpected status: %lx\n", Status);
345  ok(IoStatusBlock.Information == 0, "Excepted 0, got: %lu\n", IoStatusBlock.Information);
346 
350  Status = NtDeviceIoControlFile(hDevice, hEvent, NULL, NULL, &IoStatusBlock, IOCTL_QUERY_IP_HW_ADDRESS, Ip, sizeof(Ip[0]), Hw, 4);
351  if (Status == STATUS_PENDING)
352  {
355  }
356  ok(Status == STATUS_INVALID_BUFFER_SIZE, "NtDeviceIoControlFile() failed with unexpected status: %lx\n", Status);
357  ok(IoStatusBlock.Information == 0, "Excepted 0, got: %lu\n", IoStatusBlock.Information);
358 
362  Status = NtDeviceIoControlFile(hDevice, hEvent, NULL, NULL, &IoStatusBlock, IOCTL_QUERY_IP_HW_ADDRESS, Ip, sizeof(Ip[0]), Hw, 6);
363  if (Status == STATUS_PENDING)
364  {
367  }
368  ok(Status == STATUS_INVALID_BUFFER_SIZE, "NtDeviceIoControlFile() failed with status: %lx\n", Status);
369  ok(IoStatusBlock.Information == 0, "Excepted 0, got: %lu\n", IoStatusBlock.Information);
370 
374  Status = NtDeviceIoControlFile(hDevice, hEvent, NULL, NULL, &IoStatusBlock, IOCTL_QUERY_IP_HW_ADDRESS, Ip, sizeof(Ip[0]), Hw, 8);
375  if (Status == STATUS_PENDING)
376  {
379  }
380  ok(Status == STATUS_INVALID_BUFFER_SIZE, "NtDeviceIoControlFile() failed with status: %lx\n", Status);
381  ok(IoStatusBlock.Information == 0, "Excepted 0, got: %lu\n", IoStatusBlock.Information);
382 
387  if (Status == STATUS_PENDING)
388  {
391  }
392  ok(Status == STATUS_INVALID_BUFFER_SIZE, "NtDeviceIoControlFile() failed with unexpected status: %lx\n", Status);
393  ok(IoStatusBlock.Information == 0, "Excepted 0, got: %lu\n", IoStatusBlock.Information);
394 
398  Status = NtDeviceIoControlFile(hDevice, hEvent, NULL, NULL, &IoStatusBlock, IOCTL_QUERY_IP_HW_ADDRESS, Ip, sizeof(Ip), Hw, 4);
399  if (Status == STATUS_PENDING)
400  {
403  }
404  ok(Status == STATUS_INSUFFICIENT_RESOURCES, "NtDeviceIoControlFile() failed with unexpected status: %lx\n", Status);
405  ok(IoStatusBlock.Information == 0, "Excepted 0, got: %lu\n", IoStatusBlock.Information);
406 
410  Status = NtDeviceIoControlFile(hDevice, hEvent, NULL, NULL, &IoStatusBlock, IOCTL_QUERY_IP_HW_ADDRESS, Ip, sizeof(Ip), Hw, 6);
411  if (Status == STATUS_PENDING)
412  {
415  }
416  ok(Status == STATUS_SUCCESS, "NtDeviceIoControlFile() failed with status: %lx\n", Status);
417  ok(IoStatusBlock.Information == 6, "Excepted 6, got: %lu\n", IoStatusBlock.Information);
418 
422  Status = NtDeviceIoControlFile(hDevice, hEvent, NULL, NULL, &IoStatusBlock, IOCTL_QUERY_IP_HW_ADDRESS, Ip, sizeof(Ip), Hw, 8);
423  if (Status == STATUS_PENDING)
424  {
427  }
428  ok(Status == STATUS_SUCCESS, "NtDeviceIoControlFile() failed with status: %lx\n", Status);
429  ok(IoStatusBlock.Information == 6, "Excepted 6, got: %lu\n", IoStatusBlock.Information);
430 
431  Ip[1] = Source;
436  if (Status == STATUS_PENDING)
437  {
440  }
441  ok(Status == STATUS_INVALID_BUFFER_SIZE, "NtDeviceIoControlFile() failed with unexpected status: %lx\n", Status);
442  ok(IoStatusBlock.Information == 0, "Excepted 0, got: %lu\n", IoStatusBlock.Information);
443 
447  Status = NtDeviceIoControlFile(hDevice, hEvent, NULL, NULL, &IoStatusBlock, IOCTL_QUERY_IP_HW_ADDRESS, Ip, sizeof(Ip), Hw, 4);
448  if (Status == STATUS_PENDING)
449  {
452  }
453  ok(Status == STATUS_INSUFFICIENT_RESOURCES, "NtDeviceIoControlFile() failed with unexpected status: %lx\n", Status);
454  ok(IoStatusBlock.Information == 0, "Excepted 0, got: %lu\n", IoStatusBlock.Information);
455 
459  Status = NtDeviceIoControlFile(hDevice, hEvent, NULL, NULL, &IoStatusBlock, IOCTL_QUERY_IP_HW_ADDRESS, Ip, sizeof(Ip), Hw, 6);
460  if (Status == STATUS_PENDING)
461  {
464  }
465  ok(Status == STATUS_SUCCESS, "NtDeviceIoControlFile() failed with status: %lx\n", Status);
466  ok(IoStatusBlock.Information == 6, "Excepted 6, got: %lu\n", IoStatusBlock.Information);
467 
471  Status = NtDeviceIoControlFile(hDevice, hEvent, NULL, NULL, &IoStatusBlock, IOCTL_QUERY_IP_HW_ADDRESS, Ip, sizeof(Ip), Hw, 8);
472  if (Status == STATUS_PENDING)
473  {
476  }
477  ok(Status == STATUS_SUCCESS, "NtDeviceIoControlFile() failed with status: %lx\n", Status);
478  ok(IoStatusBlock.Information == 6, "Excepted 6, got: %lu\n", IoStatusBlock.Information);
479 
480  Ip[1] = 0x08080808;
484  Status = NtDeviceIoControlFile(hDevice, hEvent, NULL, NULL, &IoStatusBlock, IOCTL_QUERY_IP_HW_ADDRESS, Ip, sizeof(Ip), Hw, 8);
485  if (Status == STATUS_PENDING)
486  {
489  }
490  ok(Status == STATUS_SUCCESS, "NtDeviceIoControlFile() failed with status: %lx\n", Status);
491  ok(IoStatusBlock.Information == 6, "Excepted 6, got: %lu\n", IoStatusBlock.Information);
492 
493  if (!Gateway)
494  {
495  skip("No suitable gateway found\n");
497  CloseHandle(hDevice);
498  return;
499  }
500 
501  Ip[0] = Gateway;
502  Ip[1] = Source;
507  if (Status == STATUS_PENDING)
508  {
511  }
512  ok(Status == STATUS_INVALID_BUFFER_SIZE, "NtDeviceIoControlFile() failed with unexpected status: %lx\n", Status);
513  ok(IoStatusBlock.Information == 0, "Excepted 0, got: %lu\n", IoStatusBlock.Information);
514 
518  Status = NtDeviceIoControlFile(hDevice, hEvent, NULL, NULL, &IoStatusBlock, IOCTL_QUERY_IP_HW_ADDRESS, Ip, sizeof(Ip), Hw, 4);
519  if (Status == STATUS_PENDING)
520  {
523  }
524  ok(Status == STATUS_UNSUCCESSFUL, "NtDeviceIoControlFile() failed with unexpected status: %lx\n", Status);
525  ok(IoStatusBlock.Information == 0, "Excepted 0, got: %lu\n", IoStatusBlock.Information);
526 
530  Status = NtDeviceIoControlFile(hDevice, hEvent, NULL, NULL, &IoStatusBlock, IOCTL_QUERY_IP_HW_ADDRESS, Ip, sizeof(Ip), Hw, 6);
531  if (Status == STATUS_PENDING)
532  {
535  }
536  ok(Status == STATUS_SUCCESS, "NtDeviceIoControlFile() failed with status: %lx\n", Status);
537  ok(IoStatusBlock.Information == 6, "Excepted 6, got: %lu\n", IoStatusBlock.Information);
538 
542  Status = NtDeviceIoControlFile(hDevice, hEvent, NULL, NULL, &IoStatusBlock, IOCTL_QUERY_IP_HW_ADDRESS, Ip, sizeof(Ip), Hw, 8);
543  if (Status == STATUS_PENDING)
544  {
547  }
548  ok(Status == STATUS_SUCCESS, "NtDeviceIoControlFile() failed with status: %lx\n", Status);
549  ok(IoStatusBlock.Information == 6, "Excepted 6, got: %lu\n", IoStatusBlock.Information);
550 
551  Ip[0] = Source;
552  Ip[1] = Gateway;
557  if (Status == STATUS_PENDING)
558  {
561  }
562  ok(Status == STATUS_INVALID_BUFFER_SIZE, "NtDeviceIoControlFile() failed with unexpected status: %lx\n", Status);
563  ok(IoStatusBlock.Information == 0, "Excepted 0, got: %lu\n", IoStatusBlock.Information);
564 
568  Status = NtDeviceIoControlFile(hDevice, hEvent, NULL, NULL, &IoStatusBlock, IOCTL_QUERY_IP_HW_ADDRESS, Ip, sizeof(Ip), Hw, 4);
569  if (Status == STATUS_PENDING)
570  {
573  }
574  ok(Status == STATUS_INSUFFICIENT_RESOURCES, "NtDeviceIoControlFile() failed with unexpected status: %lx\n", Status);
575  ok(IoStatusBlock.Information == 0, "Excepted 0, got: %lu\n", IoStatusBlock.Information);
576 
580  Status = NtDeviceIoControlFile(hDevice, hEvent, NULL, NULL, &IoStatusBlock, IOCTL_QUERY_IP_HW_ADDRESS, Ip, sizeof(Ip), Hw, 6);
581  if (Status == STATUS_PENDING)
582  {
585  }
586  ok(Status == STATUS_SUCCESS, "NtDeviceIoControlFile() failed with status: %lx\n", Status);
587  ok(IoStatusBlock.Information == 6, "Excepted 6, got: %lu\n", IoStatusBlock.Information);
588 
592  Status = NtDeviceIoControlFile(hDevice, hEvent, NULL, NULL, &IoStatusBlock, IOCTL_QUERY_IP_HW_ADDRESS, Ip, sizeof(Ip), Hw, 8);
593  if (Status == STATUS_PENDING)
594  {
597  }
598  ok(Status == STATUS_SUCCESS, "NtDeviceIoControlFile() failed with status: %lx\n", Status);
599  ok(IoStatusBlock.Information == 6, "Excepted 6, got: %lu\n", IoStatusBlock.Information);
600 
601  Ip[0] = Gateway;
602  Ip[1] = 0x08080808;
607  if (Status == STATUS_PENDING)
608  {
611  }
612  ok(Status == STATUS_INVALID_BUFFER_SIZE, "NtDeviceIoControlFile() failed with unexpected status: %lx\n", Status);
613  ok(IoStatusBlock.Information == 0, "Excepted 0, got: %lu\n", IoStatusBlock.Information);
614 
618  Status = NtDeviceIoControlFile(hDevice, hEvent, NULL, NULL, &IoStatusBlock, IOCTL_QUERY_IP_HW_ADDRESS, Ip, sizeof(Ip), Hw, 4);
619  if (Status == STATUS_PENDING)
620  {
623  }
624  ok(Status == STATUS_UNSUCCESSFUL, "NtDeviceIoControlFile() failed with unexpected status: %lx\n", Status);
625  ok(IoStatusBlock.Information == 0, "Excepted 0, got: %lu\n", IoStatusBlock.Information);
626 
630  Status = NtDeviceIoControlFile(hDevice, hEvent, NULL, NULL, &IoStatusBlock, IOCTL_QUERY_IP_HW_ADDRESS, Ip, sizeof(Ip), Hw, 6);
631  if (Status == STATUS_PENDING)
632  {
635  }
636  ok(Status == STATUS_SUCCESS, "NtDeviceIoControlFile() failed with status: %lx\n", Status);
637  ok(IoStatusBlock.Information == 6, "Excepted 6, got: %lu\n", IoStatusBlock.Information);
638 
642  Status = NtDeviceIoControlFile(hDevice, hEvent, NULL, NULL, &IoStatusBlock, IOCTL_QUERY_IP_HW_ADDRESS, Ip, sizeof(Ip), Hw, 8);
643  if (Status == STATUS_PENDING)
644  {
647  }
648  ok(Status == STATUS_SUCCESS, "NtDeviceIoControlFile() failed with status: %lx\n", Status);
649  ok(IoStatusBlock.Information == 6, "Excepted 6, got: %lu\n", IoStatusBlock.Information);
650 
651  Ip[0] = Source;
656  if (Status == STATUS_PENDING)
657  {
660  }
661  ok(Status == STATUS_INVALID_BUFFER_SIZE, "NtDeviceIoControlFile() failed with unexpected status: %lx\n", Status);
662  ok(IoStatusBlock.Information == 0, "Excepted 0, got: %lu\n", IoStatusBlock.Information);
663 
667  Status = NtDeviceIoControlFile(hDevice, hEvent, NULL, NULL, &IoStatusBlock, IOCTL_QUERY_IP_HW_ADDRESS, Ip, sizeof(Ip), Hw, 4);
668  if (Status == STATUS_PENDING)
669  {
672  }
673  ok(Status == STATUS_INSUFFICIENT_RESOURCES, "NtDeviceIoControlFile() failed with unexpected status: %lx\n", Status);
674  ok(IoStatusBlock.Information == 0, "Excepted 0, got: %lu\n", IoStatusBlock.Information);
675 
679  Status = NtDeviceIoControlFile(hDevice, hEvent, NULL, NULL, &IoStatusBlock, IOCTL_QUERY_IP_HW_ADDRESS, Ip, sizeof(Ip), Hw, 6);
680  if (Status == STATUS_PENDING)
681  {
684  }
685  ok(Status == STATUS_SUCCESS, "NtDeviceIoControlFile() failed with status: %lx\n", Status);
686  ok(IoStatusBlock.Information == 6, "Excepted 6, got: %lu\n", IoStatusBlock.Information);
687 
691  Status = NtDeviceIoControlFile(hDevice, hEvent, NULL, NULL, &IoStatusBlock, IOCTL_QUERY_IP_HW_ADDRESS, Ip, sizeof(Ip), Hw, 8);
692  if (Status == STATUS_PENDING)
693  {
696  }
697  ok(Status == STATUS_SUCCESS, "NtDeviceIoControlFile() failed with status: %lx\n", Status);
698  ok(IoStatusBlock.Information == 6, "Excepted 6, got: %lu\n", IoStatusBlock.Information);
699 
701  CloseHandle(hDevice);
702 }
703 
705 {
706  IPAddr Source = 0;
707  IPAddr Gateway = 0;
708 
709  TestUM(&Source, &Gateway);
710  if (!Source)
711  {
712  skip("No suitable interface found\n");
713  return;
714  }
715 
716  TestKM(Source, Gateway);
717 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
NTSYSAPI NTSTATUS NTAPI RtlIpv4StringToAddressA(_In_ PCSTR String, _In_ BOOLEAN Strict, _Out_ PCSTR *Terminator, _Out_ struct in_addr *Addr)
Definition: network.c:338
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:406
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define FILE_OPEN_IF
Definition: from_kernel.h:56
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_BUFFER_OVERFLOW
Definition: winerror.h:185
char CHAR
Definition: xmlstorage.h:175
#define free
Definition: debug_ros.c:5
IP_ADDRESS_STRING IpAddress
Definition: iptypes.h:47
LONG NTSTATUS
Definition: precomp.h:26
START_TEST(SendARP)
Definition: SendARP.c:704
char String[4 *4]
Definition: iptypes.h:42
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
NTSYSAPI NTSTATUS NTAPI NtDeviceIoControlFile(IN HANDLE hFile, IN HANDLE hEvent OPTIONAL, IN PIO_APC_ROUTINE IoApcRoutine OPTIONAL, IN PVOID IoApcContext OPTIONAL, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG DeviceIoControlCode, IN PVOID InBuffer OPTIONAL, IN ULONG InBufferLength, OUT PVOID OutBuffer OPTIONAL, IN ULONG OutBufferLength)
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
struct _IP_ADAPTER_INFO IP_ADAPTER_INFO
#define ERROR_NO_SYSTEM_RESOURCES
Definition: winerror.h:931
#define FILE_SHARE_READ
Definition: compat.h:125
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651
static HANDLE hEvent
Definition: comm.c:54
#define GAA_FLAG_SKIP_FRIENDLY_NAME
struct _IP_ADAPTER_INFO * PIP_ADAPTER_INFO
unsigned int BOOL
Definition: ntddk_ex.h:94
#define IF_TYPE_SOFTWARE_LOOPBACK
Definition: ipifcons.h:44
smooth NULL
Definition: ftsmooth.c:416
ULONG IPAddr
Definition: pfhook.h:35
#define STATUS_INVALID_BUFFER_SIZE
Definition: ntstatus.h:636
#define trace
Definition: atltest.h:70
NTSTATUS NTAPI NtCreateFile(OUT PHANDLE FileHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK IoStatusBlock, IN PLARGE_INTEGER AllocationSize OPTIONAL, IN ULONG FileAttributes, IN ULONG ShareAccess, IN ULONG CreateDisposition, IN ULONG CreateOptions, IN PVOID EaBuffer OPTIONAL, IN ULONG EaLength)
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
Definition: tcpip.h:125
unsigned long DWORD
Definition: ntddk_ex.h:95
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
static const WCHAR L[]
Definition: oid.c:1250
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
Status
Definition: gdiplustypes.h:24
struct in_addr sin_addr
Definition: winsock.h:512
IP_ADDR_STRING GatewayList
Definition: iptypes.h:64
#define ok(value,...)
Definition: atltest.h:57
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
struct sockaddr_in * PSOCKADDR_IN
Definition: winsock.h:488
BOOL WINAPI DECLSPEC_HOTPATCH ResetEvent(IN HANDLE hEvent)
Definition: synch.c:714
#define skip(...)
Definition: atltest.h:64
static VOID TestKM(IPAddr Source, IPAddr Gateway)
Definition: SendARP.c:240
DWORD WINAPI GetAdaptersInfo(PIP_ADAPTER_INFO pAdapterInfo, PULONG pOutBufLen)
static VOID TestUM(IPAddr *Source, IPAddr *Gateway)
Definition: SendARP.c:17
unsigned int ULONG
Definition: retypes.h:1
#define AF_INET
Definition: tcpip.h:117
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define malloc
Definition: debug_ros.c:4
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3167
#define ERROR_GEN_FAILURE
Definition: winerror.h:134
#define GENERIC_EXECUTE
Definition: nt_native.h:91
return STATUS_SUCCESS
Definition: btrfs.c:2938
#define memset(x, y, z)
Definition: compat.h:39
static PIP_ADAPTER_ADDRESSES
Definition: iphlpapi.c:76
#define IOCTL_QUERY_IP_HW_ADDRESS
Definition: tcpioctl.h:40
struct _IP_ADAPTER_INFO * Next
Definition: iptypes.h:53
DWORD WINAPI SendARP(IPAddr DestIP, IPAddr SrcIP, PULONG pMacAddr, PULONG PhyAddrLen)
IP_ADDR_STRING IpAddressList
Definition: iptypes.h:63
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
NTSYSAPI NTSTATUS NTAPI NtWaitForSingleObject(IN HANDLE hObject, IN BOOLEAN bAlertable, IN PLARGE_INTEGER Timeout)