ReactOS  0.4.13-dev-257-gfabbd7c
icmp.c File Reference
#include "iphlpapi_private.h"
#include "ip.h"
#include "ip_icmp.h"
Include dependency graph for icmp.c:

Go to the source code of this file.

Classes

struct  icmp_t
 

Macros

#define BIG_ENDIAN   4321
 
#define LITTLE_ENDIAN   1234
 
#define BYTE_ORDER   LITTLE_ENDIAN
 
#define u_int16_t   WORD
 
#define u_int32_t   DWORD
 
#define IP_OPTS_UNKNOWN   0
 
#define IP_OPTS_DEFAULT   1
 
#define IP_OPTS_CUSTOM   2
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (icmp)
 
 WINE_DECLARE_DEBUG_CHANNEL (winediag)
 
static int in_cksum (u_short *addr, int len)
 
HANDLE WINAPI Icmp6CreateFile (VOID)
 
DWORD WINAPI Icmp6SendEcho2 (HANDLE IcmpHandle, HANDLE Event, PIO_APC_ROUTINE 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)
 
HANDLE WINAPI IcmpCreateFile (VOID)
 
BOOL WINAPI IcmpCloseHandle (HANDLE IcmpHandle)
 
static DWORD system_icmp (IPAddr DestinationAddress, LPVOID RequestData, WORD RequestSize, PIP_OPTION_INFORMATION RequestOptions, LPVOID ReplyBuffer, DWORD ReplySize, DWORD Timeout)
 
BOOL GetIPv4ByIndex (_In_ DWORD Index, _Out_ IPAddr *Address)
 
DWORD WINAPI IcmpSendEcho (HANDLE IcmpHandle, IPAddr DestinationAddress, LPVOID RequestData, WORD RequestSize, PIP_OPTION_INFORMATION RequestOptions, LPVOID ReplyBuffer, DWORD ReplySize, DWORD Timeout)
 

Variables

static LONG icmp_sequence =0
 

Macro Definition Documentation

◆ BIG_ENDIAN

#define BIG_ENDIAN   4321

Definition at line 39 of file icmp.c.

◆ BYTE_ORDER

#define BYTE_ORDER   LITTLE_ENDIAN

Definition at line 48 of file icmp.c.

◆ IP_OPTS_CUSTOM

#define IP_OPTS_CUSTOM   2

Definition at line 75 of file icmp.c.

◆ IP_OPTS_DEFAULT

#define IP_OPTS_DEFAULT   1

Definition at line 74 of file icmp.c.

◆ IP_OPTS_UNKNOWN

#define IP_OPTS_UNKNOWN   0

Definition at line 73 of file icmp.c.

◆ LITTLE_ENDIAN

#define LITTLE_ENDIAN   1234

Definition at line 42 of file icmp.c.

◆ u_int16_t

Definition at line 52 of file icmp.c.

◆ u_int32_t

Definition at line 53 of file icmp.c.

Function Documentation

◆ GetIPv4ByIndex()

BOOL GetIPv4ByIndex ( _In_ DWORD  Index,
_Out_ IPAddr Address 
)

Definition at line 500 of file icmp.c.

504 {
505  PMIB_IPADDRTABLE pIpAddrTable;
506  ULONG dwSize = 0;
507  BOOL result = FALSE;
508 
510  {
511  return result;
512  }
513  pIpAddrTable = HeapAlloc(GetProcessHeap(), 0, dwSize);
514 
515  if (GetIpAddrTable(pIpAddrTable, &dwSize, FALSE) == NO_ERROR)
516  {
517  INT i;
518 
519  for (i = 0; i < (*pIpAddrTable).dwNumEntries; i++)
520  {
521  if ((*pIpAddrTable).table[i].dwIndex == Index)
522  {
523  *Address = (IPAddr)(*pIpAddrTable).table[i].dwAddr;
524  result = TRUE;
525  break;
526  }
527  }
528  }
529  HeapFree(GetProcessHeap(), 0, pIpAddrTable);
530  return result;
531 }
#define TRUE
Definition: types.h:120
#define NO_ERROR
Definition: dderror.h:5
int32_t INT
Definition: typedefs.h:56
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
DWORD WINAPI GetIpAddrTable(PMIB_IPADDRTABLE pIpAddrTable, PULONG pdwSize, BOOL bOrder)
smooth NULL
Definition: ftsmooth.c:416
static WCHAR Address[46]
Definition: ping.c:68
ULONG IPAddr
Definition: pfhook.h:35
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
static const UCHAR Index[8]
Definition: usbohci.c:18
unsigned int ULONG
Definition: retypes.h:1
GLuint64EXT * result
Definition: glext.h:11304
#define HeapFree(x, y, z)
Definition: compat.h:394
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by IcmpSendEcho().

◆ 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().

◆ Icmp6SendEcho2()

DWORD WINAPI Icmp6SendEcho2 ( HANDLE  IcmpHandle,
HANDLE  Event,
PIO_APC_ROUTINE  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 
)

Definition at line 162 of file icmp.c.

176 {
177  FIXME("(%p, %p, %p, %p, %p, %p, %p, %d, %p, %p, %d, %d): stub\n", IcmpHandle, Event,
179  RequestSize, RequestOptions, ReplyBuffer, ReplySize, Timeout);
181  return 0;
182 }
_In_opt_ HANDLE _In_opt_ PIO_APC_ROUTINE _In_opt_ PVOID ApcContext
Definition: iofuncs.h:719
#define FIXME(fmt,...)
Definition: debug.h:110
#define SetLastError(x)
Definition: compat.h:409
_In_opt_ HANDLE _In_opt_ PIO_APC_ROUTINE ApcRoutine
Definition: iofuncs.h:719
_Must_inspect_result_ _In_ PFLT_PORT _In_ ULONG _Out_writes_bytes_opt_ ReplyLength PVOID ReplyBuffer
Definition: fltkernel.h:1903
static ULONG Timeout
Definition: ping.c:61
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:92
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS _Out_ PPHYSICAL_ADDRESS DestinationAddress
Definition: iotypes.h:1089
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS SourceAddress
Definition: iotypes.h:1089

Referenced by Ping(), and RunTraceRoute().

◆ 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().

◆ 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().

◆ in_cksum()

static int in_cksum ( u_short addr,
int  len 
)
static

Definition at line 82 of file icmp.c.

83 {
84  int nleft=len;
85  u_short *w = addr;
86  int sum = 0;
87  u_short answer = 0;
88 
89  while (nleft > 1) {
90  sum += *w++;
91  nleft -= 2;
92  }
93 
94  if (nleft == 1) {
95  *(u_char *)(&answer) = *(u_char *)w;
96  sum += answer;
97  }
98 
99  sum = (sum >> 16) + (sum & 0xffff);
100  sum += (sum >> 16);
101  answer = ~sum;
102  return(answer);
103 }
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
static int sum(int x_, int y_)
Definition: ptr2_test.cpp:35
unsigned short u_short
Definition: types.h:81
GLenum const GLvoid * addr
Definition: glext.h:9621
GLenum GLsizei len
Definition: glext.h:6722
UCHAR u_char
Definition: types.h:80

Referenced by IcmpSendEcho().

◆ system_icmp()

static DWORD system_icmp ( IPAddr  DestinationAddress,
LPVOID  RequestData,
WORD  RequestSize,
PIP_OPTION_INFORMATION  RequestOptions,
LPVOID  ReplyBuffer,
DWORD  ReplySize,
DWORD  Timeout 
)
static

Definition at line 266 of file icmp.c.

275 {
276 #ifdef HAVE_FORK
277  ICMP_ECHO_REPLY *reply = ReplyBuffer;
278  char ntoa_buffer[16]; /* 4*3 digits + 3 '.' + 1 '\0' */
279  char size_buffer[6]; /* 5 digits + '\0' */
280  char tos_buffer[4]; /* 3 digits + '\0' */
281  char ttl_buffer[4]; /* 3 digits + '\0' */
282  char time_buffer[11]; /* 10 digits + '\0' */
283  int i, pos, res, status, argc;
284  const char *argv[20];
285  struct in_addr addr;
286  int pipe_out[2];
287  pid_t pid, wpid;
288  char *ptr, *eol;
289  char buf[127];
290 
291  /* Assemble the ping commandline */
292  argc = 0;
293  argv[argc++] = "ping";
294  argv[argc++] = "-c"; /* only send a single ping */
295  argv[argc++] = "1";
296  argv[argc++] = "-n"; /* numeric output only */
297  argv[argc++] = "-s"; /* request size */
298  sprintf(size_buffer, "%u", (RequestSize >= 16) ? RequestSize : 16);
299  argv[argc++] = size_buffer;
300  argv[argc++] = "-W"; /* timeout */
301 #ifdef __linux__
302  /* The linux 'ping' utlity expects a time in seconds */
303  Timeout = (Timeout + 999) / 1000;
304 #endif
305  sprintf(time_buffer, "%u", Timeout);
306  argv[argc++] = time_buffer;
307 
308  if (RequestOptions)
309  {
310  #ifdef __linux__
311  argv[argc++] = "-Q"; /* tos option */
312  #else
313  argv[argc++] = "-z"; /* tos option */
314  #endif
315  sprintf(tos_buffer, "%u", RequestOptions->Tos);
316  argv[argc++] = tos_buffer;
317  #ifdef __linux__
318  /* TTL can only be specified for multicast addresses on FreeBSD/MacOS */
319  argv[argc++] = "-t"; /* ttl option */
320  sprintf(ttl_buffer, "%u", RequestOptions->Ttl);
321  argv[argc++] = ttl_buffer;
322  #endif
323  }
324 
325  addr.s_addr = DestinationAddress;
326  if (!(ptr = inet_ntoa(addr)))
327  {
329  return 0;
330  }
331  strcpy(ntoa_buffer, ptr);
332  argv[argc++] = ntoa_buffer;
333  argv[argc] = NULL;
334 
335  /* Dump commandline for debugging purposes */
336  TRACE("Ping commandline: ");
337  for (i = 0; i < argc; i++)
338  {
339  TRACE("%s ", debugstr_a(argv[i]));
340  }
341  TRACE("\n");
342 
343  /* Prefill the reply struct with fallback values */
344  memset(reply, 0, sizeof(*reply));
345  reply->Address = DestinationAddress;
346  reply->RoundTripTime = 40;
347  reply->Options.Ttl = 120;
348 
349  /* Create communication pipes */
350 #ifdef HAVE_PIPE2
351  if (pipe2(pipe_out, O_CLOEXEC) < 0)
352 #endif
353  {
354  if (pipe(pipe_out) < 0)
355  {
357  return 0;
358  }
359  fcntl(pipe_out[0], F_SETFD, FD_CLOEXEC);
360  fcntl(pipe_out[1], F_SETFD, FD_CLOEXEC);
361  }
362 
363  /* Fork child process */
364  pid = fork();
365  if (pid == -1)
366  {
367  close(pipe_out[0]);
368  close(pipe_out[1]);
370  return 0;
371  }
372 
373  /* Child process */
374  if (pid == 0)
375  {
376  static char lang_env[] = "LANG=C";
377 
378  dup2(pipe_out[1], 1);
379  close(pipe_out[0]);
380  close(pipe_out[1]);
381  close(0);
382  close(2);
383 
384  putenv(lang_env);
385  execvp(argv[0], (char **)argv);
386  _exit(1);
387  }
388 
389  close(pipe_out[1]);
390 
391  /* Wait for child and read output */
392  pos = 0;
393  do
394  {
395  if (pos >= sizeof(buf) - 1)
396  {
397  ERR("line too long, dropping buffer\n");
398  pos = 0;
399  }
400 
401  /* read next block */
402  do
403  {
404  res = read(pipe_out[0], &buf[pos], (sizeof(buf) - 1) - pos);
405  }
406  while (res < 0 && errno == EINTR);
407  if (res < 0)
408  {
409  ERR("read failed: %s\n", strerror(errno));
410  break;
411  }
412 
413  pos += res;
414  while (pos)
415  {
416  eol = memchr(buf, '\n', pos);
417  if (!eol) break;
418  *eol = 0;
419 
420  TRACE("Received line: %s\n", debugstr_a(buf));
421 
422  /* Interpret address */
423  if ((ptr = strstr(buf, "from ")))
424  {
425  int a, b, c, d;
426  if (sscanf(ptr + 5, "%u.%u.%u.%u", &a, &b, &c, &d) >= 4)
427  {
428  reply->Address = a | (b << 8) | (c << 16) | (d << 24);
429  addr.s_addr = reply->Address;
430  TRACE("Got address %s\n", inet_ntoa(addr));
431  }
432  }
433 
434  /* Interpret ttl */
435  if ((ptr = strstr(buf, "ttl=")))
436  {
437  int val;
438  if (sscanf(ptr + 4, "%u", &val) >= 1)
439  {
440  reply->Options.Ttl = val;
441  TRACE("Got ttl %u\n", val);
442  }
443  }
444 
445  /* Interpret time */
446  if ((ptr = strstr(buf, "time=")))
447  {
448  float val;
449  if (sscanf(ptr + 5, "%f", &val) >= 1)
450  {
451  reply->RoundTripTime = (unsigned int)(val + 0.5);
452  TRACE("Got rtt = %u\n", reply->RoundTripTime);
453  }
454  }
455 
456  memmove(buf, eol + 1, pos - (eol + 1 - buf));
457  pos -= (eol + 1 - buf);
458  }
459  }
460  while (res > 0);
461  close(pipe_out[0]);
462 
463  /* reap the child process */
464  do
465  {
466  wpid = waitpid(pid, &status, 0);
467  }
468  while (wpid < 0 && errno == EINTR);
469 
470  /* fill out remaining struct fields */
471  if (wpid >= 0 && WIFEXITED(status) && WEXITSTATUS(status) == 0)
472  {
473  if (ReplySize < RequestSize + sizeof(*reply))
474  {
475  reply->Status = IP_BUF_TOO_SMALL;
476  reply->DataSize = 0;
477  reply->Data = NULL;
478  }
479  else
480  {
481  reply->Status = 0;
482  reply->DataSize = RequestSize;
483  reply->Data = (char *)reply + sizeof(*reply);
484  memcpy(reply->Data, RequestData, RequestSize);
485  }
486  return 1;
487  }
488 
490  return 0;
491 #else
492  ERR("no fork support on this platform\n");
494  return 0;
495 #endif
496 }
#define IP_BUF_TOO_SMALL
Definition: ipexport.h:103
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
static int argc
Definition: ServiceArgs.c:12
_In_ ULONG_PTR _In_ ULONG _Out_ ULONG_PTR * pid
Definition: winddi.h:3835
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
_Check_return_ _CRTIMP int __cdecl putenv(_In_z_ const char *_EnvString)
#define memchr(s, c, n)
Definition: mkisofs.h:875
unsigned char Tos
Definition: ipexport.h:34
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
#define EINTR
Definition: acclib.h:80
unsigned short DataSize
Definition: ipexport.h:72
DWORD pid_t
Definition: types.h:91
int errno
#define argv
Definition: mplay32.c:18
const char * strerror(int err)
Definition: compat_str.c:23
#define sprintf(buf, format,...)
Definition: sprintf.c:55
IPAddr Address
Definition: ipexport.h:69
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
#define a
Definition: ke_i.h:78
static PVOID ptr
Definition: dispmode.c:27
smooth NULL
Definition: ftsmooth.c:416
ULONG Status
Definition: ipexport.h:70
_Check_return_ _CRTIMP int __cdecl sscanf(_In_z_ const char *_Src, _In_z_ _Scanf_format_string_ const char *_Format,...)
void _exit(int exitcode)
Definition: _exit.c:25
_Check_return_ _CRTIMP int __cdecl dup2(_In_ int _FileHandleSrc, _In_ int _FileHandleDst)
#define b
Definition: ke_i.h:79
#define inet_ntoa(addr)
Definition: inet.h:100
GLuint GLfloat * val
Definition: glext.h:7180
void * Data
Definition: ipexport.h:74
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define TRACE(s)
Definition: solgame.cpp:4
#define IP_REQ_TIMED_OUT
Definition: ipexport.h:112
#define d
Definition: ke_i.h:81
#define debugstr_a
Definition: kernel32.h:31
#define FD_CLOEXEC
Definition: fcntl.h:102
Definition: tcpip.h:125
_CRTIMP intptr_t __cdecl execvp(_In_z_ const char *_Filename, _In_z_ char *const _ArgList[])
const GLubyte * c
Definition: glext.h:8905
#define SetLastError(x)
Definition: compat.h:409
unsigned char Ttl
Definition: ipexport.h:33
_Must_inspect_result_ _In_ PFLT_PORT _In_ ULONG _Out_writes_bytes_opt_ ReplyLength PVOID ReplyBuffer
Definition: fltkernel.h:1903
GLenum const GLvoid * addr
Definition: glext.h:9621
ULONG RoundTripTime
Definition: ipexport.h:71
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define close
Definition: acwin.h:74
#define ERR(fmt,...)
Definition: debug.h:109
static ULONG Timeout
Definition: ping.c:61
#define ERROR_NOT_SUPPORTED
Definition: compat.h:90
GLuint res
Definition: glext.h:9613
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define c
Definition: ke_i.h:80
struct ip_option_information Options
Definition: ipexport.h:75
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS _Out_ PPHYSICAL_ADDRESS DestinationAddress
Definition: iotypes.h:1089
#define memset(x, y, z)
Definition: compat.h:39
static SERVICE_STATUS status
Definition: service.c:31
_CRTIMP int __cdecl read(_In_ int _FileHandle, _Out_writes_bytes_(_MaxCharCount) void *_DstBuf, _In_ unsigned int _MaxCharCount)
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
Definition: ps.c:97

Referenced by IcmpSendEcho().

◆ WINE_DECLARE_DEBUG_CHANNEL()

WINE_DECLARE_DEBUG_CHANNEL ( winediag  )

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( icmp  )

Variable Documentation

◆ icmp_sequence

LONG icmp_sequence =0
static

Definition at line 80 of file icmp.c.

Referenced by IcmpSendEcho().