ReactOS  0.4.13-dev-259-g5ca9c9c
icmpapi.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

HANDLE WINAPI IcmpCreateFile (VOID)
 
HANDLE WINAPI Icmp6CreateFile (VOID)
 
BOOL WINAPI IcmpCloseHandle (HANDLE IcmpHandle)
 
DWORD WINAPI IcmpSendEcho (HANDLE IcmpHandle, IPAddr DestinationAddress, LPVOID RequestData, WORD RequestSize, PIP_OPTION_INFORMATION RequestOptions, LPVOID ReplyBuffer, DWORD ReplySize, DWORD Timeout)
 
DWORD WINAPI IcmpSendEcho2 (HANDLE IcmpHandle, HANDLE Event, FARPROC ApcRoutine, PVOID ApcContext, IPAddr DestinationAddress, LPVOID RequestData, WORD RequestSize, PIP_OPTION_INFORMATION RequestOptions, LPVOID ReplyBuffer, DWORD ReplySize, DWORD Timeout)
 
DWORD WINAPI Icmp6SendEcho2 (HANDLE IcmpHandle, HANDLE Event, FARPROC ApcRoutine, PVOID ApcContext, struct sockaddr_in6 *SourceAddress, struct sockaddr_in6 *DestinationAddress, LPVOID RequestData, WORD RequestSize, PIP_OPTION_INFORMATION RequestOptions, LPVOID ReplyBuffer, DWORD ReplySize, DWORD Timeout)
 
DWORD WINAPI IcmpParseReplies (LPVOID ReplyBuffer, DWORD ReplySize)
 
DWORD WINAPI Icmp6ParseReplies (LPVOID ReplyBuffer, DWORD ReplySize)
 

Function Documentation

◆ Icmp6CreateFile()

HANDLE WINAPI Icmp6CreateFile ( VOID  )

Definition at line 114 of file icmp.c.

115 {
116  icmp_t* icp;
117  int sid;
118 #ifdef __REACTOS__
119  WSADATA wsaData;
120 
121  if (WSAStartup(MAKEWORD(2, 2), &wsaData) != ERROR_SUCCESS)
122  {
123  ERR_(winediag)("Failed to use ICMPV6 (network ping), this requires special permissions.\n");
124  return INVALID_HANDLE_VALUE;
125  }
126 #endif
127 
128  sid=socket(AF_INET6,SOCK_RAW,IPPROTO_ICMPV6);
129 #ifndef __REACTOS__
130  if (sid < 0)
131  {
132  /* Mac OS X supports non-privileged ICMP via SOCK_DGRAM type. */
133  sid=socket(AF_INET6,SOCK_DGRAM,IPPROTO_ICMPV6);
134  }
135 #endif
136  if (sid < 0) {
137  ERR_(winediag)("Failed to use ICMPV6 (network ping), this requires special permissions.\n");
139  return INVALID_HANDLE_VALUE;
140  }
141 
142  icp=HeapAlloc(GetProcessHeap(), 0, sizeof(*icp));
143  if (icp==NULL) {
144 #ifdef __REACTOS__
145  closesocket(sid);
146  WSACleanup();
147 #else
148  close(sid);
149 #endif
151  return INVALID_HANDLE_VALUE;
152  }
153  icp->sid=sid;
155  return (HANDLE)icp;
156 }
SOCKET WSAAPI socket(IN INT af, IN INT type, IN INT protocol)
Definition: socklife.c:143
#define ERROR_SUCCESS
Definition: deptool.c:10
#define MAKEWORD(a, b)
Definition: typedefs.h:247
#define ERR_(ch,...)
Definition: debug.h:156
INT WSAAPI WSACleanup(VOID)
Definition: startup.c:60
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
FT_UInt sid
Definition: cffcmap.c:139
#define IP_NO_RESOURCES
Definition: ticonsts.h:59
#define SOCK_RAW
Definition: winsock.h:337
#define closesocket
Definition: main.c:39
#define ERROR_ACCESS_DENIED
Definition: compat.h:87
INT WINAPI WSAStartup(IN WORD wVersionRequested, OUT LPWSADATA lpWSAData)
Definition: startup.c:113
smooth NULL
Definition: ftsmooth.c:416
#define AF_INET6
Definition: winsock.h:369
unsigned char OptionsSize
Definition: ipexport.h:36
Definition: icmp.c:68
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define IP_OPTS_UNKNOWN
Definition: icmp.c:73
#define SetLastError(x)
Definition: compat.h:409
#define close
Definition: acwin.h:74
int sid
Definition: icmp.c:69
IP_OPTION_INFORMATION default_opts
Definition: icmp.c:70
#define SOCK_DGRAM
Definition: winsock.h:336

Referenced by RunTraceRoute(), test_Icmp6CreateFile(), test_IcmpCloseHandle(), and wmain().

◆ Icmp6ParseReplies()

DWORD WINAPI Icmp6ParseReplies ( LPVOID  ReplyBuffer,
DWORD  ReplySize 
)

◆ Icmp6SendEcho2()

DWORD WINAPI Icmp6SendEcho2 ( HANDLE  IcmpHandle,
HANDLE  Event,
FARPROC  ApcRoutine,
PVOID  ApcContext,
struct sockaddr_in6 SourceAddress,
struct sockaddr_in6 DestinationAddress,
LPVOID  RequestData,
WORD  RequestSize,
PIP_OPTION_INFORMATION  RequestOptions,
LPVOID  ReplyBuffer,
DWORD  ReplySize,
DWORD  Timeout 
)

◆ IcmpCloseHandle()

BOOL WINAPI IcmpCloseHandle ( HANDLE  IcmpHandle)

Definition at line 243 of file icmp.c.

244 {
245  icmp_t* icp=(icmp_t*)IcmpHandle;
246  // REACTOS: Added a check for NULL handle, CORE-10707
247  if (IcmpHandle==INVALID_HANDLE_VALUE || IcmpHandle==NULL) {
248  /* FIXME: in fact win98 seems to ignore the handle value !!! */
250  return FALSE;
251  }
252 
253 #ifdef __REACTOS__
254  shutdown(icp->sid,2);
255 #else
256  if (icp->sid >= 0) close(icp->sid);
257 #endif
258  HeapFree(GetProcessHeap (), 0, icp);
259 #ifdef __REACTOS__
260  WSACleanup();
261 #endif
262  return TRUE;
263 }
#define TRUE
Definition: types.h:120
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
INT WSAAPI WSACleanup(VOID)
Definition: startup.c:60
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
smooth NULL
Definition: ftsmooth.c:416
Definition: icmp.c:68
#define GetProcessHeap()
Definition: compat.h:395
INT WSAAPI shutdown(IN SOCKET s, IN INT how)
Definition: sockctrl.c:506
#define SetLastError(x)
Definition: compat.h:409
#define close
Definition: acwin.h:74
int sid
Definition: icmp.c:69
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by RunTraceRoute(), test_Icmp6CreateFile(), test_IcmpCloseHandle(), test_IcmpCreateFile(), test_IcmpSendEcho(), and wmain().

◆ IcmpCreateFile()

HANDLE WINAPI IcmpCreateFile ( VOID  )

Definition at line 188 of file icmp.c.

189 {
190 #ifndef __REACTOS__
191  static int once;
192 #endif
193  icmp_t* icp;
194  int sid;
195 #ifdef __REACTOS__
196  WSADATA wsaData;
197 
198  if (WSAStartup(MAKEWORD(2, 2), &wsaData) != ERROR_SUCCESS)
199  {
200  ERR_(winediag)("Failed to use ICMPV6 (network ping), this requires special permissions.\n");
201  return INVALID_HANDLE_VALUE;
202  }
203 #endif
205 #ifdef __REACTOS__
206  if (sid < 0) {
207  ERR_(winediag)("Failed to use ICMP (network ping), this requires special permissions.\n");
209  return INVALID_HANDLE_VALUE;
210  }
211 #else
212  if (sid < 0)
213  {
214  /* Mac OS X supports non-privileged ICMP via SOCK_DGRAM type. */
216  }
217  if (sid < 0 && !once++) {
218  FIXME_(winediag)("Failed to use ICMP (network ping), this requires special permissions.\n");
219  FIXME_(winediag)("Falling back to system 'ping' command as a workaround.\n");
220  }
221 #endif
222 
223  icp=HeapAlloc(GetProcessHeap(), 0, sizeof(*icp));
224  if (icp==NULL) {
225 #ifdef __REACTOS__
226  closesocket(sid);
227  WSACleanup();
228 #else
229  if (sid >= 0) close(sid);
230 #endif
232  return INVALID_HANDLE_VALUE;
233  }
234  icp->sid=sid;
236  return (HANDLE)icp;
237 }
SOCKET WSAAPI socket(IN INT af, IN INT type, IN INT protocol)
Definition: socklife.c:143
#define ERROR_SUCCESS
Definition: deptool.c:10
#define MAKEWORD(a, b)
Definition: typedefs.h:247
#define ERR_(ch,...)
Definition: debug.h:156
INT WSAAPI WSACleanup(VOID)
Definition: startup.c:60
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
FT_UInt sid
Definition: cffcmap.c:139
#define IP_NO_RESOURCES
Definition: ticonsts.h:59
#define SOCK_RAW
Definition: winsock.h:337
#define closesocket
Definition: main.c:39
#define ERROR_ACCESS_DENIED
Definition: compat.h:87
#define FIXME_(x)
Definition: compat.h:67
INT WINAPI WSAStartup(IN WORD wVersionRequested, OUT LPWSADATA lpWSAData)
Definition: startup.c:113
smooth NULL
Definition: ftsmooth.c:416
unsigned char OptionsSize
Definition: ipexport.h:36
Definition: icmp.c:68
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define IP_OPTS_UNKNOWN
Definition: icmp.c:73
#define SetLastError(x)
Definition: compat.h:409
#define close
Definition: acwin.h:74
int sid
Definition: icmp.c:69
IP_OPTION_INFORMATION default_opts
Definition: icmp.c:70
#define AF_INET
Definition: tcpip.h:117
#define SOCK_DGRAM
Definition: winsock.h:336

Referenced by RunTraceRoute(), test_IcmpCloseHandle(), test_IcmpCreateFile(), test_IcmpSendEcho(), and wmain().

◆ IcmpParseReplies()

DWORD WINAPI IcmpParseReplies ( LPVOID  ReplyBuffer,
DWORD  ReplySize 
)

◆ IcmpSendEcho()

DWORD WINAPI IcmpSendEcho ( HANDLE  IcmpHandle,
IPAddr  DestinationAddress,
LPVOID  RequestData,
WORD  RequestSize,
PIP_OPTION_INFORMATION  RequestOptions,
LPVOID  ReplyBuffer,
DWORD  ReplySize,
DWORD  Timeout 
)

Definition at line 536 of file icmp.c.

Referenced by IcmpSendEcho(), and test_IcmpSendEcho().

◆ IcmpSendEcho2()

DWORD WINAPI IcmpSendEcho2 ( HANDLE  IcmpHandle,
HANDLE  Event,
FARPROC  ApcRoutine,
PVOID  ApcContext,
IPAddr  DestinationAddress,
LPVOID  RequestData,
WORD  RequestSize,
PIP_OPTION_INFORMATION  RequestOptions,
LPVOID  ReplyBuffer,
DWORD  ReplySize,
DWORD  Timeout 
)

Referenced by IcmpSendEcho(), Ping(), and RunTraceRoute().