ReactOS  0.4.13-dev-66-gc714b7f
icmp.c File Reference
#include <apitest.h>
#include <ws2tcpip.h>
#include <iphlpapi.h>
#include <icmpapi.h>
Include dependency graph for icmp.c:

Go to the source code of this file.

Functions

static void test_IcmpCreateFile (void)
 
static void test_Icmp6CreateFile (void)
 
static void test_IcmpCloseHandle (void)
 
static void test_IcmpSendEcho (void)
 
 START_TEST (icmp)
 

Function Documentation

◆ START_TEST()

START_TEST ( icmp  )

Definition at line 129 of file icmp.c.

130 {
135 }
static void test_IcmpSendEcho(void)
Definition: icmp.c:87
static void test_IcmpCloseHandle(void)
Definition: icmp.c:51
static void test_Icmp6CreateFile(void)
Definition: icmp.c:29
static void test_IcmpCreateFile(void)
Definition: icmp.c:15

◆ test_Icmp6CreateFile()

static void test_Icmp6CreateFile ( void  )
static

Definition at line 29 of file icmp.c.

30 {
31  HANDLE hIcmp;
32 
33  SetLastError(0xDEADBEEF);
34  hIcmp = Icmp6CreateFile();
35 
37  {
38  /* On Windows Server 2003, the IPv6 protocol must be installed. */
39  skip("IPv6 is not available.\n");
40  return;
41  }
42 
43  ok(hIcmp != INVALID_HANDLE_VALUE, "Icmp6CreateFile failed unexpectedly: %lu\n", GetLastError());
44 
45  if (hIcmp != INVALID_HANDLE_VALUE)
46  IcmpCloseHandle(hIcmp);
47 }
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define ok(value,...)
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
HANDLE WINAPI Icmp6CreateFile(VOID)
Definition: icmp.c:114
#define SetLastError(x)
Definition: compat.h:409
BOOL WINAPI IcmpCloseHandle(HANDLE IcmpHandle)
Definition: icmp.c:243
#define skip(...)

Referenced by START_TEST().

◆ test_IcmpCloseHandle()

static void test_IcmpCloseHandle ( void  )
static

Definition at line 51 of file icmp.c.

52 {
53  HANDLE hIcmp;
54  BOOL bRet;
55 
56  SetLastError(0xDEADBEEF);
57  hIcmp = IcmpCreateFile();
58  if (hIcmp != INVALID_HANDLE_VALUE)
59  {
60  bRet = IcmpCloseHandle(hIcmp);
61  ok(bRet, "IcmpCloseHandle failed unexpectedly: %lu\n", GetLastError());
62  }
63 
64  SetLastError(0xDEADBEEF);
65  hIcmp = Icmp6CreateFile();
66  if (hIcmp != INVALID_HANDLE_VALUE)
67  {
68  bRet = IcmpCloseHandle(hIcmp);
69  ok(bRet, "IcmpCloseHandle failed unexpectedly: %lu\n", GetLastError());
70  }
71 
72  hIcmp = INVALID_HANDLE_VALUE;
73  SetLastError(0xDEADBEEF);
74  bRet = IcmpCloseHandle(hIcmp);
75  ok(!bRet, "IcmpCloseHandle succeeded unexpectedly\n");
77 
78  hIcmp = NULL;
79  SetLastError(0xDEADBEEF);
80  bRet = IcmpCloseHandle(hIcmp);
81  ok(!bRet, "IcmpCloseHandle succeeded unexpectedly\n");
83 }
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define ok_err(error)
Definition: FindFiles.c:39
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
HANDLE WINAPI Icmp6CreateFile(VOID)
Definition: icmp.c:114
#define SetLastError(x)
Definition: compat.h:409
BOOL WINAPI IcmpCloseHandle(HANDLE IcmpHandle)
Definition: icmp.c:243
HANDLE WINAPI IcmpCreateFile(VOID)
Definition: icmp.c:188

Referenced by START_TEST().

◆ test_IcmpCreateFile()

static void test_IcmpCreateFile ( void  )
static

Definition at line 15 of file icmp.c.

16 {
17  HANDLE hIcmp;
18 
19  SetLastError(0xDEADBEEF);
20  hIcmp = IcmpCreateFile();
21  ok(hIcmp != INVALID_HANDLE_VALUE, "IcmpCreateFile failed unexpectedly: %lu\n", GetLastError());
22 
23  if (hIcmp != INVALID_HANDLE_VALUE)
24  IcmpCloseHandle(hIcmp);
25 }
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define ok(value,...)
#define SetLastError(x)
Definition: compat.h:409
BOOL WINAPI IcmpCloseHandle(HANDLE IcmpHandle)
Definition: icmp.c:243
HANDLE WINAPI IcmpCreateFile(VOID)
Definition: icmp.c:188

Referenced by START_TEST().

◆ test_IcmpSendEcho()

static void test_IcmpSendEcho ( void  )
static

Definition at line 87 of file icmp.c.

88 {
89  HANDLE hIcmp;
90  unsigned long ipaddr = INADDR_NONE;
91  DWORD bRet = 0, error = 0;
92  char SendData[32] = "Data Buffer";
94  DWORD ReplySize = 0;
95 
96  SetLastError(0xDEADBEEF);
97  hIcmp = IcmpCreateFile();
98  if (hIcmp == INVALID_HANDLE_VALUE)
99  {
100  skip("IcmpCreateFile failed unexpectedly: %lu\n", GetLastError());
101  return;
102  }
103 
104  ipaddr = 0x08080808; // 8.8.8.8
105  ReplyBuffer = malloc(sizeof(ICMP_ECHO_REPLY) + sizeof(SendData));
106 
107  ReplySize = sizeof(ICMP_ECHO_REPLY);
108  SetLastError(0xDEADBEEF);
109  bRet = IcmpSendEcho(hIcmp, ipaddr, SendData, sizeof(SendData),
110  NULL, ReplyBuffer, ReplySize, 5000);
111 
112  ok(!bRet, "IcmpSendEcho succeeded unexpectedly\n");
113  error = GetLastError();
114  ok(error == IP_BUF_TOO_SMALL /* Win2003 */ ||
115  error == IP_GENERAL_FAILURE /* Win10 */,
116  "IcmpSendEcho returned unexpected error: %lu\n", error);
117 
118  ReplySize = sizeof(ICMP_ECHO_REPLY) + sizeof(SendData);
119  SetLastError(0xDEADBEEF);
120  bRet = IcmpSendEcho(hIcmp, ipaddr, SendData, sizeof(SendData),
121  NULL, ReplyBuffer, ReplySize, 5000);
122 
123  ok(bRet, "IcmpSendEcho failed unexpectedly: %lu\n", GetLastError());
124 
125  free(ReplyBuffer);
126  IcmpCloseHandle(hIcmp);
127 }
#define IP_BUF_TOO_SMALL
Definition: ipexport.h:103
DWORD WINAPI IcmpSendEcho(HANDLE IcmpHandle, IPAddr DestinationAddress, LPVOID RequestData, WORD RequestSize, PIP_OPTION_INFORMATION RequestOptions, LPVOID ReplyBuffer, DWORD ReplySize, DWORD Timeout)
Definition: icmp.c:536
#define error(str)
Definition: mkdosfs.c:1605
#define free
Definition: debug_ros.c:5
#define INADDR_NONE
Definition: tcp.c:42
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
#define IP_GENERAL_FAILURE
Definition: ipexport.h:127
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
_Must_inspect_result_ _In_ PFLT_PORT _In_ ULONG _Out_writes_bytes_opt_ ReplyLength PVOID ReplyBuffer
Definition: fltkernel.h:1903
BOOL WINAPI IcmpCloseHandle(HANDLE IcmpHandle)
Definition: icmp.c:243
#define skip(...)
static BOOL SendData(PINFO pInfo)
Definition: ntpclient.c:78
struct icmp_echo_reply ICMP_ECHO_REPLY
Definition: ipexport.h:80
HANDLE WINAPI IcmpCreateFile(VOID)
Definition: icmp.c:188
#define malloc
Definition: debug_ros.c:4

Referenced by START_TEST().