ReactOS  0.4.15-dev-499-g1f31905
icmp.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS TCP/IP protocol driver
3  * LICENCE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4  * PURPOSE: ICMP functions implementation
5  * COPYRIGHT: 2019 Victor Perevertkin (victor.perevertkin@reactos.org)
6  */
7 
8 #include "precomp.h"
9 #include <checksum.h>
10 
11 
12 #define UINT16_MAX (65535U)
13 
14 typedef struct _ICMP_PACKET_CONTEXT
15 {
29 
30 static volatile INT16 IcmpSequence = 0;
31 
32 static
33 UINT32
35 {
36  switch (IcmpHeader->Type)
37  {
39  return IP_SUCCESS;
41  switch (IcmpHeader->Code)
42  {
54  return IP_BAD_ROUTE;
55  default:
57  }
59  return IP_SOURCE_QUENCH;
61  if (IcmpHeader->Code == ICMP_CODE_TE_REASSEMBLY)
63  else
66  return IP_PARAM_PROBLEM;
67  default:
68  return IP_REQ_TIMED_OUT;
69  }
70 }
71 
72 static
73 VOID
75  _In_ PADDRESS_FILE AddrFile)
76 {
77  KIRQL OldIrql;
78 
79  LockObject(AddrFile, &OldIrql);
80  AddrFile->RegisteredReceiveDatagramHandler = FALSE;
81  UnlockObject(AddrFile, OldIrql);
82 }
83 
84 IO_WORKITEM_ROUTINE EndRequestHandler;
85 
86 VOID
87 NTAPI
90  PVOID _Context)
91 {
93  PIO_STACK_LOCATION CurrentStack;
94  PIRP Irp;
95  UINT32 nReplies;
96  KIRQL OldIrql;
97 
98  KeWaitForSingleObject(&Context->DatagramProcessedEvent, Executive, KernelMode, FALSE, NULL);
99 
100  TI_DbgPrint(DEBUG_ICMP, ("Finishing request Context: %p\n", Context));
101 
102  Irp = Context->Irp;
103  CurrentStack = IoGetCurrentIrpStackLocation(Irp);
104 
105  if (Context->nReplies > 0)
106  {
107  ((PICMP_ECHO_REPLY)Irp->AssociatedIrp.SystemBuffer)->Reserved = Context->nReplies;
108  Irp->IoStatus.Status = STATUS_SUCCESS;
109  Irp->IoStatus.Information = CurrentStack->Parameters.DeviceIoControl.OutputBufferLength;
110  }
111  else
112  {
113  PICMP_ECHO_REPLY ReplyBuffer = (PICMP_ECHO_REPLY)Irp->AssociatedIrp.SystemBuffer;
115  ReplyBuffer->Status = IP_REQ_TIMED_OUT;
116 
117  Irp->IoStatus.Status = STATUS_TIMEOUT;
118  Irp->IoStatus.Information = sizeof(*ReplyBuffer);
119  }
120 
121  // for debugging
122  nReplies = ((PICMP_ECHO_REPLY)Irp->AssociatedIrp.SystemBuffer)->Reserved;
123 
124  // taken from dispatch.c:IRPFinish
129 
130  {
131  NTSTATUS _Status = FileCloseAddress(&Context->TdiRequest);
132  ASSERT(NT_SUCCESS(_Status));
133  }
134 
135  IoFreeWorkItem(Context->FinishWorker);
137 
138  TI_DbgPrint(DEBUG_ICMP, ("Leaving, nReplies: %u\n", nReplies));
139 }
140 
141 NTSTATUS
142 NTAPI
144  _In_opt_ PVOID TdiEventContext,
145  _In_ LONG SourceAddressLength,
146  _In_reads_bytes_(SourceAddressLength) PVOID SourceAddress,
147  _In_ LONG OptionsLength,
148  _In_reads_bytes_opt_(OptionsLength) PVOID Options,
149  _In_ ULONG ReceiveDatagramFlags,
150  _In_ ULONG BytesIndicated,
151  _In_ ULONG BytesAvailable,
152  _Out_ ULONG *OutBytesTaken,
153  _In_ PVOID Tsdu,
154  _Out_opt_ PIRP *IoRequestPacket)
155 {
156  PICMP_PACKET_CONTEXT Context = TdiEventContext;
157  PIPv4_HEADER IpHeader = Tsdu;
158  UINT16 IpHeaderSize = sizeof(IPv4_HEADER) + OptionsLength;
159  PICMP_HEADER IcmpHeader = (PICMP_HEADER)((PUCHAR)Tsdu + IpHeaderSize);
160 
161  PVOID DataBuffer = (PUCHAR)Tsdu + IpHeaderSize + sizeof(ICMP_HEADER);
162  INT32 DataSize = min(BytesAvailable, UINT16_MAX) - IpHeaderSize - sizeof(ICMP_HEADER);
163 
164  INT64 CurrentTime;
165  UINT32 RoundTripTime;
166  PICMP_ECHO_REPLY CurrentReply;
167  PUCHAR CurrentUserBuffer;
168 
169  // do not handle echo requests
170  if (DataSize >= 0 && IcmpHeader->Type == ICMP_TYPE_ECHO_REQUEST)
171  {
172  return STATUS_SUCCESS;
173  }
174 
175  KeWaitForSingleObject(&Context->InitializationFinishedEvent, Executive, KernelMode, FALSE, NULL);
176  KeClearEvent(&Context->DatagramProcessedEvent);
177 
178  ASSERT(SourceAddressLength == sizeof(IPAddr));
179  TI_DbgPrint(DEBUG_ICMP, ("Received datagram Context: 0x%p\n", TdiEventContext));
180 
181  CurrentTime = KeQueryPerformanceCounter(NULL).QuadPart;
182  RoundTripTime = (CurrentTime - Context->StartTicks) * 1000 / Context->TimerResolution.QuadPart;
183  CurrentReply = (PICMP_ECHO_REPLY)Context->CurrentReply;
184 
185  if (Context->RemainingSize >= sizeof(ICMP_ECHO_REPLY) && DataSize >= 0)
186  {
187  TI_DbgPrint(DEBUG_ICMP, ("RemainingSize: %u, RoundTripTime: %u\n", Context->RemainingSize, RoundTripTime));
188 
189  memcpy(&CurrentReply->Address, SourceAddress, sizeof(CurrentReply->Address));
190  CurrentReply->Status = GetReplyStatus(IcmpHeader);
191  CurrentReply->RoundTripTime = RoundTripTime;
192  CurrentReply->Reserved = 0;
193  CurrentReply->Data = NULL;
194  CurrentReply->DataSize = 0;
195  CurrentReply->Options.Ttl = IpHeader->Ttl;
196  CurrentReply->Options.Tos = IpHeader->Tos;
197  CurrentReply->Options.Flags = IpHeader->FlagsFragOfs >> 13;
198  CurrentReply->Options.OptionsData = NULL;
199  CurrentReply->Options.OptionsSize = 0;
200 
201  Context->RemainingSize -= sizeof(ICMP_ECHO_REPLY);
202  Context->CurrentReply += sizeof(ICMP_ECHO_REPLY);
203  }
204 
205  CurrentUserBuffer = (PUCHAR)Context->Irp->UserBuffer + (Context->CurrentReply - (PUCHAR)Context->Irp->AssociatedIrp.SystemBuffer);
206 
207  if (DataSize > 0 && Context->RemainingSize > 0)
208  {
209  UINT32 _DataSize = min(Context->RemainingSize, DataSize);
210 
211  memcpy(Context->CurrentReply + Context->RemainingSize - _DataSize, DataBuffer, _DataSize);
212  CurrentReply->Data = CurrentUserBuffer + Context->RemainingSize - _DataSize;
213  CurrentReply->DataSize = _DataSize;
214 
215  Context->RemainingSize -= _DataSize;
216  // Context->ReplyBuffer += _DataSize;
217  }
218  else
219  {
220  TI_DbgPrint(DEBUG_ICMP, ("RemainingSize: %u, DataSize: %d\n", Context->RemainingSize, DataSize));
221  }
222 
223  if (OptionsLength > 0 && Context->RemainingSize > 0)
224  {
225  UINT32 _OptSize = min(Context->RemainingSize, OptionsLength);
226 
227  memcpy(Context->CurrentReply + Context->RemainingSize + _OptSize, Options, _OptSize);
228  CurrentReply->Options.OptionsData = CurrentUserBuffer + Context->RemainingSize + _OptSize;
229  CurrentReply->Options.OptionsSize = _OptSize;
230 
231  Context->RemainingSize -= _OptSize;
232  // Context->ReplyBuffer += _OptSize;
233  }
234  else
235  {
236  TI_DbgPrint(DEBUG_ICMP, ("RemainingSize: %u, OptSize: %d\n", Context->RemainingSize, OptionsLength));
237  }
238 
239  Context->nReplies++;
240 
241  if (Context->RemainingSize < sizeof(ICMP_ECHO_REPLY))
242  {
243  TI_DbgPrint(DEBUG_ICMP, ("The space is over: %u\n", Context->RemainingSize));
244 
245  // if the timer was inserted, that means DPC has not been queued yet
246  if (KeCancelTimer(&Context->TimeoutTimer))
247  {
248  PADDRESS_FILE AddrFile = (PADDRESS_FILE)Context->TdiRequest.Handle.AddressHandle;
249  ClearReceiveHandler(AddrFile);
250 
252  }
253  }
254 
255  KeSetEvent(&Context->DatagramProcessedEvent, IO_NO_INCREMENT, FALSE);
256  return STATUS_SUCCESS;
257 }
258 
259 KDEFERRED_ROUTINE TimeoutHandler;
260 
261 VOID
262 NTAPI
264  _In_ PKDPC Dpc,
265  _In_opt_ PVOID _Context,
268 {
270  PADDRESS_FILE AddrFile = (PADDRESS_FILE)Context->TdiRequest.Handle.AddressHandle;
271  ClearReceiveHandler(AddrFile);
272 
273  IoQueueWorkItem(Context->FinishWorker, &EndRequestHandler, DelayedWorkQueue, _Context);
274 }
275 
276 NTSTATUS
279  _In_ PIRP Irp,
281 {
282  PICMP_ECHO_REQUEST Request = Irp->AssociatedIrp.SystemBuffer;
283  UINT32 OutputBufferLength = IrpSp->Parameters.DeviceIoControl.OutputBufferLength;
284  UINT32 InputBufferLength = IrpSp->Parameters.DeviceIoControl.InputBufferLength;
286  TDI_CONNECTION_INFORMATION ConnectionInfo;
287  TA_IP_ADDRESS RemoteAddressTa, LocalAddressTa;
288  PADDRESS_FILE AddrFile;
289  ULONG DataUsed;
290  PUCHAR Buffer;
292  PICMP_PACKET_CONTEXT SendContext;
293  KIRQL OldIrql;
294  LARGE_INTEGER RequestTimeout;
295  UINT8 SavedTtl;
296 
297  TI_DbgPrint(DEBUG_ICMP, ("About to send datagram, OutputBufferLength: %u, SystemBuffer: %p\n", OutputBufferLength, Irp->AssociatedIrp.SystemBuffer));
298 
299  // check buffers
301  {
303  }
304 
305  // check request parameters
306  if ((Request->DataSize > UINT16_MAX - sizeof(ICMP_HEADER) - sizeof(IPv4_HEADER)) ||
307  ((UINT32)Request->DataOffset + Request->DataSize > InputBufferLength) ||
308  ((UINT32)Request->OptionsOffset + Request->OptionsSize > InputBufferLength))
309  {
311  }
312 
313  SendContext = ExAllocatePoolWithTag(NonPagedPool, sizeof(*SendContext), OUT_DATA_TAG);
314  if (!SendContext)
315  {
317  }
318 
319  RtlZeroMemory(&SendContext->TdiRequest, sizeof(SendContext->TdiRequest));
320  SendContext->TdiRequest.RequestContext = Irp;
321 
322  // setting up everything needed for sending the packet
323 
324  RtlZeroMemory(&RemoteAddressTa, sizeof(RemoteAddressTa));
325  RtlZeroMemory(&LocalAddressTa, sizeof(LocalAddressTa));
326  RtlZeroMemory(&ConnectionInfo, sizeof(ConnectionInfo));
327 
328  RemoteAddressTa.TAAddressCount = 1;
329  RemoteAddressTa.Address[0].AddressLength = TDI_ADDRESS_LENGTH_IP;
330  RemoteAddressTa.Address[0].AddressType = TDI_ADDRESS_TYPE_IP;
331  RemoteAddressTa.Address[0].Address[0].in_addr = Request->Address;
332 
333  LocalAddressTa.TAAddressCount = 1;
334  LocalAddressTa.Address[0].AddressLength = TDI_ADDRESS_LENGTH_IP;
335  LocalAddressTa.Address[0].AddressType = TDI_ADDRESS_TYPE_IP;
336  LocalAddressTa.Address[0].Address[0].in_addr = 0;
337 
338  Status = FileOpenAddress(&SendContext->TdiRequest, &LocalAddressTa, IPPROTO_ICMP, FALSE, NULL);
339 
340  if (!NT_SUCCESS(Status))
341  {
342  TI_DbgPrint(DEBUG_ICMP, ("Failed to open address file status: 0x%x\n", Status));
343 
344  ExFreePoolWithTag(SendContext, OUT_DATA_TAG);
345 
346  return Status;
347  }
348 
349  AddrFile = (PADDRESS_FILE)SendContext->TdiRequest.Handle.AddressHandle;
350 
351  // setting up the context
352 
354  SendContext->Irp = Irp;
355  SendContext->CurrentReply = Irp->AssociatedIrp.SystemBuffer;
356  SendContext->RemainingSize = OutputBufferLength;
357  SendContext->nReplies = 0;
361 
362  KeInitializeDpc(&SendContext->TimeoutDpc, &TimeoutHandler, SendContext);
364 
365  RequestTimeout.QuadPart = (-1LL) * 10 * 1000 * Request->Timeout;
366 
367  ConnectionInfo.RemoteAddress = &RemoteAddressTa;
368  ConnectionInfo.RemoteAddressLength = sizeof(RemoteAddressTa);
369 
370  RequestSize = sizeof(ICMP_HEADER) + Request->DataSize;
371 
372  // making up the request packet
374 
375  if (!Buffer)
376  {
377  ExFreePoolWithTag(SendContext, OUT_DATA_TAG);
378 
380  }
381 
384  ((PICMP_HEADER)Buffer)->Checksum = 0;
387  memcpy(Buffer + sizeof(ICMP_HEADER), (PUCHAR)Request + Request->DataOffset, Request->DataSize);
388  ((PICMP_HEADER)Buffer)->Checksum = IPv4Checksum(Buffer, RequestSize, 0);
389  SavedTtl = Request->Ttl;
390 
391  RtlZeroMemory(Irp->AssociatedIrp.SystemBuffer, OutputBufferLength);
392 
393  LockObject(AddrFile, &OldIrql);
394 
395  AddrFile->TTL = SavedTtl;
396  AddrFile->ReceiveDatagramHandlerContext = SendContext;
399 
400  UnlockObject(AddrFile, OldIrql);
401 
402  Status = AddrFile->Send(AddrFile, &ConnectionInfo, (PCHAR)Buffer, RequestSize, &DataUsed);
403 
404  // From this point we may receive a reply packet.
405  // But we are not ready for it thus InitializationFinishedEvent is needed (see below)
406 
408 
410 
411  if (!NT_SUCCESS(Status))
412  {
413  NTSTATUS _Status;
414 
415  ClearReceiveHandler(AddrFile);
416  _Status = FileCloseAddress(&SendContext->TdiRequest);
417  ASSERT(NT_SUCCESS(_Status));
418 
419  IoFreeWorkItem(SendContext->FinishWorker);
420  ExFreePoolWithTag(SendContext, OUT_DATA_TAG);
421 
422  TI_DbgPrint(DEBUG_ICMP, ("Failed to send a datagram: 0x%x\n", Status));
423  return Status;
424  }
425 
427  KeSetTimer(&SendContext->TimeoutTimer, RequestTimeout, &SendContext->TimeoutDpc);
429 
430  return STATUS_PENDING;
431 }
KEVENT DatagramProcessedEvent
Definition: icmp.c:19
#define ICMP_CODE_TE_REASSEMBLY
Definition: icmp.h:49
signed char * PCHAR
Definition: retypes.h:7
unsigned __int3264 UINT_PTR
Definition: activex.cpp:275
#define TI_DbgPrint(_t_, _x_)
Definition: debug.h:45
LONG TAAddressCount
Definition: tdi.h:523
UINT8 Type
Definition: icmp.h:12
NTSTATUS NTAPI ReceiveDatagram(_In_opt_ PVOID TdiEventContext, _In_ LONG SourceAddressLength, _In_reads_bytes_(SourceAddressLength) PVOID SourceAddress, _In_ LONG OptionsLength, _In_reads_bytes_opt_(OptionsLength) PVOID Options, _In_ ULONG ReceiveDatagramFlags, _In_ ULONG BytesIndicated, _In_ ULONG BytesAvailable, _Out_ ULONG *OutBytesTaken, _In_ PVOID Tsdu, _Out_opt_ PIRP *IoRequestPacket)
Definition: icmp.c:143
NTSTATUS FileCloseAddress(PTDI_REQUEST Request)
Definition: fileobjs.c:580
LARGE_INTEGER NTAPI KeQueryPerformanceCounter(IN PLARGE_INTEGER PerformanceFreq)
Definition: timer.c:138
#define TRUE
Definition: types.h:120
BOOLEAN RegisteredReceiveDatagramHandler
Definition: titypes.h:183
#define LL
Definition: tui.h:84
BOOLEAN NTAPI KeSetTimer(IN OUT PKTIMER Timer, IN LARGE_INTEGER DueTime, IN PKDPC Dpc OPTIONAL)
Definition: timerobj.c:281
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
UINT32 RoundTripTime
Definition: ipexport.h:86
PVOID RequestContext
Definition: tdi.h:55
#define ICMP_CODE_DU_HOST_UNREACH
Definition: icmp.h:35
struct ICMP_HEADER ICMP_HEADER
UCHAR Tos
Definition: ip.h:39
unsigned char Tos
Definition: ipexport.h:34
UCHAR TTL
Definition: titypes.h:141
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
TDI_REQUEST TdiRequest
Definition: icmp.c:16
struct icmp_echo_reply * PICMP_ECHO_REPLY
#define ICMP_CODE_DU_SOURCE_ROUTE_FAILED
Definition: icmp.h:39
unsigned char * PUCHAR
Definition: retypes.h:3
PUCHAR CurrentReply
Definition: icmp.c:23
#define _In_reads_bytes_opt_(size)
Definition: no_sal2.h:230
union _TDI_REQUEST::@3153 Handle
KDEFERRED_ROUTINE TimeoutHandler
Definition: icmp.c:259
DATAGRAM_SEND_ROUTINE Send
Definition: titypes.h:148
LONG NTSTATUS
Definition: precomp.h:26
VOID NTAPI IoAcquireCancelSpinLock(OUT PKIRQL Irql)
Definition: util.c:56
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG _In_ ULONG _In_ ULONG OutputBufferLength
Definition: fltkernel.h:1374
INT64 StartTicks
Definition: icmp.c:21
#define IP_TTL_EXPIRED_TRANSIT
Definition: ipexport.h:126
IoSetCancelRoutine(Irp, CancelRoutine)
PIO_WORKITEM NTAPI IoAllocateWorkItem(IN PDEVICE_OBJECT DeviceObject)
Definition: iowork.c:75
enum OPTION_FLAGS Options
Definition: stats.c:44
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
VOID NTAPI IoFreeWorkItem(IN PIO_WORKITEM IoWorkItem)
Definition: iowork.c:64
#define IP_PARAM_PROBLEM
Definition: ipexport.h:128
#define ICMP_TYPE_PARAMETER
Definition: icmp.h:27
static VOID ClearReceiveHandler(_In_ PADDRESS_FILE AddrFile)
Definition: icmp.c:74
#define _In_opt_
Definition: no_sal2.h:213
#define LockObject(Object, Irql)
Definition: titypes.h:34
_In_ NDIS_HANDLE _In_ PNDIS_REQUEST Request
Definition: ndis.h:5173
#define STATUS_TIMEOUT
Definition: ntstatus.h:81
UINT32 RemainingSize
Definition: icmp.c:24
UCHAR KIRQL
Definition: env_spec_w32.h:591
IPAddr Address
Definition: ipexport.h:84
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
USHORT FlagsFragOfs
Definition: ip.h:42
unsigned int UINT32
static volatile INT16 IcmpSequence
Definition: icmp.c:30
long LONG
Definition: pedump.c:60
#define UnlockObject(Object, OldIrql)
Definition: titypes.h:54
#define IP_DEST_PORT_UNREACHABLE
Definition: ipexport.h:118
#define IPv4Checksum(Data, Count, Seed)
Definition: checksum.h:30
struct _ADDRESS_FILE * PADDRESS_FILE
smooth NULL
Definition: ftsmooth.c:416
#define ICMP_TYPE_TIME_EXCEEDED
Definition: icmp.h:26
#define ICMP_CODE_DU_PROTOCOL_UNREACH
Definition: icmp.h:36
#define _Out_
Definition: no_sal2.h:323
#define IoCompleteRequest
Definition: irp.c:1240
#define DEBUG_ICMP
Definition: debug.h:29
Definition: bufpool.h:45
struct _TA_ADDRESS_IP::_AddrIp Address[1]
UCHAR Ttl
Definition: ip.h:43
unsigned char OptionsSize
Definition: ipexport.h:36
struct IPv4_HEADER IPv4_HEADER
ULONG IPAddr
Definition: pfhook.h:35
UINT16 Reserved
Definition: ipexport.h:88
PTDI_IND_RECEIVE_DATAGRAM ReceiveDatagramHandler
Definition: titypes.h:181
#define IO_NETWORK_INCREMENT
Definition: tcpip.h:43
#define ICMP_TYPE_ECHO_REQUEST
Definition: icmp.h:25
IP_OPTION_INFORMATION Options
Definition: ipexport.h:90
PVOID ReceiveDatagramHandlerContext
Definition: titypes.h:182
_In_opt_ PVOID _In_opt_ PVOID SystemArgument1
Definition: ketypes.h:675
#define _Out_opt_
Definition: no_sal2.h:339
_In_ LARGE_INTEGER _In_opt_ PKDPC Dpc
Definition: kefuncs.h:511
#define UINT16_MAX
Definition: icmp.c:12
BOOLEAN NTAPI KeCancelTimer(IN OUT PKTIMER Timer)
Definition: timerobj.c:206
#define IP_REQ_TIMED_OUT
Definition: ipexport.h:123
#define IP_BAD_ROUTE
Definition: ipexport.h:125
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
#define IP_DEST_NET_UNREACHABLE
Definition: ipexport.h:115
#define ICMP_TYPE_ECHO_REPLY
Definition: icmp.h:21
UINT8 Code
Definition: icmp.h:13
#define InterlockedIncrement16
Definition: interlocked.h:206
HANDLE AddressHandle
Definition: tdi.h:50
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
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
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
Definition: ketypes.h:687
struct _ICMP_PACKET_CONTEXT * PICMP_PACKET_CONTEXT
unsigned char Flags
Definition: ipexport.h:35
signed long long INT64
#define TDI_ADDRESS_TYPE_IP
Definition: tdi.h:345
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
unsigned char * OptionsData
Definition: ipexport.h:37
NTSTATUS DispEchoRequest(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp, _In_ PIO_STACK_LOCATION IrpSp)
Definition: icmp.c:277
#define ICMP_TYPE_DEST_UNREACH
Definition: icmp.h:22
#define ICMP_CODE_DU_PORT_UNREACH
Definition: icmp.h:37
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG _In_ ULONG InputBufferLength
Definition: fltkernel.h:1372
#define _In_reads_bytes_(size)
Definition: no_sal2.h:229
VOID NTAPI IoReleaseCancelSpinLock(IN KIRQL Irql)
Definition: util.c:150
Status
Definition: gdiplustypes.h:24
_In_opt_ PVOID _In_opt_ PVOID _In_opt_ PVOID SystemArgument2
Definition: ketypes.h:675
VOID NTAPI IoQueueWorkItem(IN PIO_WORKITEM IoWorkItem, IN PIO_WORKITEM_ROUTINE WorkerRoutine, IN WORK_QUEUE_TYPE QueueType, IN PVOID Context)
Definition: iowork.c:40
#define _In_
Definition: no_sal2.h:204
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1569
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
UINT16 DataSize
Definition: ipexport.h:87
LARGE_INTEGER TimerResolution
Definition: icmp.c:20
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
struct _ICMP_PACKET_CONTEXT ICMP_PACKET_CONTEXT
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
#define ICMP_CODE_DU_NET_UNREACH
Definition: icmp.h:34
PIO_WORKITEM FinishWorker
Definition: icmp.c:26
unsigned short UINT16
#define min(a, b)
Definition: monoChain.cc:55
HANDLE NTAPI PsGetCurrentProcessId(VOID)
Definition: process.c:1123
struct ICMP_HEADER * PICMP_HEADER
Definition: ip.h:37
#define ICMP_TYPE_SOURCE_QUENCH
Definition: icmp.h:23
KTIMER TimeoutTimer
Definition: icmp.c:27
UINT32 Status
Definition: ipexport.h:85
NTSTATUS FileOpenAddress(PTDI_REQUEST Request, PTA_IP_ADDRESS AddrList, USHORT Protocol, BOOLEAN Shared, PVOID Options)
Definition: fileobjs.c:391
#define IP_SUCCESS
Definition: ipexport.h:113
KEVENT InitializationFinishedEvent
Definition: icmp.c:18
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:568
#define ICMP_CODE_DU_FRAG_DF_SET
Definition: icmp.h:38
signed int INT32
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define IP_DEST_PROT_UNREACHABLE
Definition: ipexport.h:117
static UINT32 GetReplyStatus(PICMP_HEADER IcmpHeader)
Definition: icmp.c:34
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define OUT_DATA_TAG
Definition: tags.h:39
#define TDI_ADDRESS_LENGTH_IP
Definition: tdi.h:413
IO_WORKITEM_ROUTINE EndRequestHandler
Definition: icmp.c:84
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2774
VOID NTAPI KeInitializeDpc(IN PKDPC Dpc, IN PKDEFERRED_ROUTINE DeferredRoutine, IN PVOID DeferredContext)
Definition: dpc.c:711
VOID NTAPI KeClearEvent(IN PKEVENT Event)
Definition: eventobj.c:22
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
#define IP_DEST_HOST_UNREACHABLE
Definition: ipexport.h:116
return STATUS_SUCCESS
Definition: btrfs.c:3014
IoMarkIrpPending(Irp)
unsigned char UINT8
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS SourceAddress
Definition: iotypes.h:1092
struct icmp_echo_reply ICMP_ECHO_REPLY
_In_ NDIS_STATUS _In_ ULONG _In_ USHORT _In_opt_ PVOID _In_ ULONG DataSize
Definition: ndis.h:4751
#define IP_SOURCE_QUENCH
Definition: ipexport.h:129
VOID NTAPI KeInitializeTimerEx(OUT PKTIMER Timer, IN TIMER_TYPE Type)
Definition: timerobj.c:244
#define IP_TTL_EXPIRED_REASSEM
Definition: ipexport.h:127
LONGLONG QuadPart
Definition: typedefs.h:113
signed short INT16