ReactOS  0.4.15-dev-1033-gd7d716a
main.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS TCP/IP protocol driver
4  * FILE: tcpip/main.c
5  * PURPOSE: Driver entry point
6  * PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
7  * REVISIONS:
8  * CSH 01/08-2000 Created
9  */
10 
11 #include "precomp.h"
12 
13 #include <dispatch.h>
14 #include <fileobjs.h>
15 
27 
28 /* Network timers */
31 
36  NTSTATUS FinalStatus,
37  PWSTR String,
38  ULONG DumpDataCount,
40 /*
41  * FUNCTION: Writes an error log entry
42  * ARGUMENTS:
43  * DriverContext = Pointer to the driver or device object
44  * ErrorCode = An error code to put in the log entry
45  * UniqueErrorValue = UniqueErrorValue in the error log packet
46  * FinalStatus = FinalStatus in the error log packet
47  * String = If not NULL, a pointer to a string to put in log
48  * entry
49  * DumpDataCount = Number of ULONGs of dump data
50  * DumpData = Pointer to dump data for the log entry
51  */
52 {
53  PIO_ERROR_LOG_PACKET LogEntry;
55  ULONG StringSize;
56  PUCHAR pString;
57  static WCHAR DriverName[] = L"TCP/IP";
58 
59  EntrySize = sizeof(IO_ERROR_LOG_PACKET) +
60  (DumpDataCount * sizeof(ULONG)) + sizeof(DriverName);
61 
62  if (String) {
63  StringSize = (wcslen(String) * sizeof(WCHAR)) + sizeof(UNICODE_NULL);
64  EntrySize += (UCHAR)StringSize;
65  }
66 
67  /* Fail if the required error log entry is too large */
69  return;
70 
72  if (!LogEntry)
73  return;
74 
75  LogEntry->MajorFunctionCode = -1;
76  LogEntry->RetryCount = -1;
77  LogEntry->DumpDataSize = (USHORT)(DumpDataCount * sizeof(ULONG));
78  LogEntry->NumberOfStrings = (String == NULL) ? 1 : 2;
79  LogEntry->StringOffset = sizeof(IO_ERROR_LOG_PACKET) + (DumpDataCount * sizeof(ULONG));
80  LogEntry->EventCategory = 0;
81  LogEntry->ErrorCode = ErrorCode;
83  LogEntry->FinalStatus = FinalStatus;
84  LogEntry->SequenceNumber = -1;
85  LogEntry->IoControlCode = 0;
86 
87  if (DumpDataCount)
88  RtlCopyMemory(LogEntry->DumpData, DumpData, DumpDataCount * sizeof(ULONG));
89 
90  pString = ((PUCHAR)LogEntry) + LogEntry->StringOffset;
91  RtlCopyMemory(pString, DriverName, sizeof(DriverName));
92  pString += sizeof(DriverName);
93 
94  if (String)
95  RtlCopyMemory(pString, String, StringSize);
96 
97  IoWriteErrorLogEntry(LogEntry);
98 }
99 
100 /*
101  * FUNCTION: Creates a file object
102  * ARGUMENTS:
103  * DeviceObject = Pointer to a device object for this driver
104  * Irp = Pointer to a I/O request packet
105  * RETURNS:
106  * Status of the operation
107  */
108 
111  PIRP Irp)
112 {
120  ULONG Protocol;
121  BOOLEAN Shared;
122 
123  TI_DbgPrint(DEBUG_IRP, ("Called. DeviceObject is at (0x%X), IRP is at (0x%X).\n", DeviceObject, Irp));
124 
125  EaInfo = Irp->AssociatedIrp.SystemBuffer;
126 
127  /* Parameter check */
128  /* No EA information means that we're opening for SET/QUERY_INFORMATION
129  * style calls. */
130 
131  /* Allocate resources here. We release them again if something failed */
134  if (!Context)
135  {
136  TI_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
138  }
139 
140  Context->CancelIrps = FALSE;
141 
143  IrpSp->FileObject->FsContext = Context;
144  Request.RequestContext = Irp;
145 
146  /* Branch to the right handler */
147  if (EaInfo &&
151  {
152  /* This is a request to open an address */
153 
154 
155  /* XXX This should probably be done in IoCreateFile() */
156  /* Parameter checks */
157 
158  Address = (PTA_IP_ADDRESS)(EaInfo->EaName + EaInfo->EaNameLength + 1); //0-term
159 
160  if ((EaInfo->EaValueLength < sizeof(TA_IP_ADDRESS)) ||
161  (Address->TAAddressCount != 1) ||
162  (Address->Address[0].AddressLength < TDI_ADDRESS_LENGTH_IP) ||
163  (Address->Address[0].AddressType != TDI_ADDRESS_TYPE_IP))
164  {
165  TI_DbgPrint(MIN_TRACE, ("Parameters are invalid:\n"));
166  TI_DbgPrint(MIN_TRACE, ("AddressCount: %d\n", Address->TAAddressCount));
167  if( Address->TAAddressCount == 1 )
168  {
169  TI_DbgPrint(MIN_TRACE, ("AddressLength: %u\n",
170  Address->Address[0].AddressLength));
171  TI_DbgPrint(MIN_TRACE, ("AddressType: %u\n",
172  Address->Address[0].AddressType));
173  }
174 
177  }
178 
179  /* Open address file object */
180 
181  /* Protocol depends on device object so find the protocol */
184  else if (DeviceObject == UDPDeviceObject)
186  else if (DeviceObject == IPDeviceObject)
188  else if (DeviceObject == RawIPDeviceObject)
189  {
191  if (!NT_SUCCESS(Status))
192  {
193  TI_DbgPrint(MIN_TRACE, ("Raw IP protocol number is invalid.\n"));
196  }
197  }
198  else
199  {
200  TI_DbgPrint(MIN_TRACE, ("Invalid device object at (0x%X).\n", DeviceObject));
203  }
204 
205  Shared = (IrpSp->Parameters.Create.ShareAccess != 0);
206 
208  if (NT_SUCCESS(Status))
209  {
211  Context->Handle.AddressHandle = Request.Handle.AddressHandle;
212  }
213 
214  }
215  else if (EaInfo &&
218  (&EaInfo->EaName, TdiConnectionContext,
221  {
222  /* This is a request to open a connection endpoint */
223 
224  /* Parameter checks */
225 
226  if (EaInfo->EaValueLength < sizeof(PVOID))
227  {
228  TI_DbgPrint(MIN_TRACE, ("Parameters are invalid.\n"));
231  }
232 
233  /* Can only do connection oriented communication using TCP */
234 
236  {
237  TI_DbgPrint(MIN_TRACE, ("Bad device object.\n"));
240  }
241 
242  ClientContext = *((PVOID*)(EaInfo->EaName + EaInfo->EaNameLength));
243 
244  /* Open connection endpoint file object */
245 
247  if (NT_SUCCESS(Status))
248  {
249  IrpSp->FileObject->FsContext2 = (PVOID)TDI_CONNECTION_FILE;
250  Context->Handle.ConnectionContext = Request.Handle.ConnectionContext;
251  }
252  }
253  else
254  {
255  /* This is a request to open a control connection */
257  if (NT_SUCCESS(Status))
258  {
260  Context->Handle.ControlChannel = Request.Handle.ControlChannel;
261  }
262  }
263 
264  if (!NT_SUCCESS(Status))
266 
267  TI_DbgPrint(DEBUG_IRP, ("Leaving. Status = (0x%X).\n", Status));
268 
269  Irp->IoStatus.Status = Status;
270  return Status;
271 }
272 
273 
274 /*
275  * FUNCTION: Releases resources used by a file object
276  * ARGUMENTS:
277  * DeviceObject = Pointer to a device object for this driver
278  * Irp = Pointer to a I/O request packet
279  * RETURNS:
280  * Status of the operation
281  * NOTES:
282  * This function does not pend
283  */
286  PIRP Irp)
287 {
292 
294  Context = IrpSp->FileObject->FsContext;
295  if (!Context)
296  {
297  TI_DbgPrint(MIN_TRACE, ("Parameters are invalid.\n"));
299  }
300 
301  switch ((ULONG_PTR)IrpSp->FileObject->FsContext2)
302  {
304  Request.Handle.AddressHandle = Context->Handle.AddressHandle;
306  break;
307 
308  case TDI_CONNECTION_FILE:
309  Request.Handle.ConnectionContext = Context->Handle.ConnectionContext;
311  break;
312 
314  Request.Handle.ControlChannel = Context->Handle.ControlChannel;
316  break;
317 
318  default:
320  break;
321  }
322 
323  if (NT_SUCCESS(Status))
325 
326  Irp->IoStatus.Status = Status;
327 
328  return Irp->IoStatus.Status;
329 }
330 
331 
335  IN PIRP Irp)
336 /*
337  * FUNCTION: Main dispath routine
338  * ARGUMENTS:
339  * DeviceObject = Pointer to a device object for this driver
340  * Irp = Pointer to a I/O request packet
341  * RETURNS:
342  * Status of the operation
343  */
344 {
347 
348 // DbgPrint("Called. DeviceObject is at (0x%X), IRP is at (0x%X).\n", DeviceObject, Irp);
349 
351 
352  switch (IrpSp->MajorFunction) {
353  /* Open an address file, connection endpoint, or control connection */
354  case IRP_MJ_CREATE:
356  break;
357 
358  /* Close an address file, connection endpoint, or control connection */
359  case IRP_MJ_CLOSE:
361  break;
362 
363  default:
365  }
366 
367  //DbgPrint("Leaving. Status is (0x%X)\n", Status);
368 
369  return IRPFinish( Irp, Status );
370 }
371 
372 
376  PIRP Irp)
377 /*
378  * FUNCTION: Internal IOCTL dispatch routine
379  * ARGUMENTS:
380  * DeviceObject = Pointer to a device object for this driver
381  * Irp = Pointer to a I/O request packet
382  * RETURNS:
383  * Status of the operation
384  */
385 {
387  BOOLEAN Complete = TRUE;
389 
391 
392  TI_DbgPrint(DEBUG_IRP, ("[TCPIP, TiDispatchInternal] Called. DeviceObject is at (0x%X), IRP is at (0x%X) MN (%d).\n",
394 
395  Irp->IoStatus.Status = STATUS_SUCCESS;
396  Irp->IoStatus.Information = 0;
397 
398  switch (IrpSp->MinorFunction) {
399  case TDI_RECEIVE:
401  Complete = FALSE;
402  break;
403 
406  Complete = FALSE;
407  break;
408 
409  case TDI_SEND:
411  Complete = FALSE; /* Completed in DispTdiSend */
412  break;
413 
414  case TDI_SEND_DATAGRAM:
416  Complete = FALSE;
417  break;
418 
419  case TDI_ACCEPT:
421  break;
422 
423  case TDI_LISTEN:
425  Complete = FALSE;
426  break;
427 
428  case TDI_CONNECT:
430  Complete = FALSE; /* Completed by the TCP event handler */
431  break;
432 
433  case TDI_DISCONNECT:
435  Complete = FALSE;
436  break;
437 
440  break;
441 
444  break;
445 
448  break;
449 
450  case TDI_SET_INFORMATION:
452  break;
453 
456  break;
457 
458  case TDI_ACTION:
460  break;
461 
462  /* An unsupported IOCTL code was submitted */
463  default:
465  }
466 
467  TI_DbgPrint(DEBUG_IRP, ("[TCPIP, TiDispatchInternal] Leaving. Status = (0x%X).\n", Status));
468 
469  if( Complete )
470  IRPFinish( Irp, Status );
471 
472  return Status;
473 }
474 
475 
490  PIRP Irp)
491 {
494 
496 
497  TI_DbgPrint(DEBUG_IRP, ("[TCPIP, TiDispatch] Called. IRP is at (0x%X).\n", Irp));
498 
499  Irp->IoStatus.Information = 0;
500 
501 #if 0
503  if (NT_SUCCESS(Status))
504  {
507  }
508  else
509  {
510 #else
511  if (TRUE) {
512 #endif
513  /* See if this request is TCP/IP specific */
514  switch (IrpSp->Parameters.DeviceIoControl.IoControlCode)
515  {
517  TI_DbgPrint(MIN_TRACE, ("TCP_QUERY_INFORMATION_EX\n"));
519  break;
520 
522  TI_DbgPrint(MIN_TRACE, ("TCP_SET_INFORMATION_EX\n"));
524  break;
525 
527  TI_DbgPrint(MIN_TRACE, ("SET_IP_ADDRESS\n"));
529  break;
530 
532  TI_DbgPrint(MIN_TRACE, ("DELETE_IP_ADDRESS\n"));
534  break;
535 
537  TI_DbgPrint(MIN_TRACE, ("QUERY_IP_HW_ADDRESS\n"));
539  break;
540 
542  TI_DbgPrint(MIN_TRACE, ("ICMP_ECHO_REQUEST\n"));
544  break;
545 
546  default:
547  TI_DbgPrint(MIN_TRACE, ("Unknown IOCTL 0x%X\n",
548  IrpSp->Parameters.DeviceIoControl.IoControlCode));
550  break;
551  }
552  }
553 
554  TI_DbgPrint(DEBUG_IRP, ("[TCPIP, TiDispatch] Leaving. Status = (0x%X).\n", Status));
555 
556  return IRPFinish(Irp, Status);
557 }
558 
559 
562 /*
563  * FUNCTION: Unloads the driver
564  * ARGUMENTS:
565  * DriverObject = Pointer to driver object created by the system
566  */
567 {
568 #if DBG
569  KIRQL OldIrql;
570 
573  TI_DbgPrint(MIN_TRACE, ("[TCPIP, TiUnload] Called. Open address file objects exists.\n"));
574  }
576 #endif
577  /* Cancel timer */
579 
580  /* Unregister loopback adapter */
582 
583  /* Unregister protocol with NDIS */
585 
586  /* Shutdown transport level protocol subsystems */
587  TCPShutdown();
588  UDPShutdown();
589  RawIPShutdown();
590  ICMPShutdown();
591 
592  /* Shutdown network level protocol subsystem */
593  IPShutdown();
594 
595  /* Free NDIS buffer descriptors */
596  if (GlobalBufferPool)
598 
599  /* Free NDIS packet descriptors */
600  if (GlobalPacketPool)
602 
603  /* Release all device objects */
604 
605  if (TCPDeviceObject)
607 
608  if (UDPDeviceObject)
610 
611  if (RawIPDeviceObject)
613 
614  if (IPDeviceObject) {
615  ChewShutdown();
617  }
618 
619  if (EntityList)
621 
622  TI_DbgPrint(MAX_TRACE, ("[TCPIP, TiUnload] Leaving.\n"));
623 }
624 
629 /*
630  * FUNCTION: Main driver entry point
631  * ARGUMENTS:
632  * DriverObject = Pointer to a driver object for this driver
633  * RegistryPath = Registry node for configuration parameters
634  * RETURNS:
635  * Status of driver initialization
636  */
637 {
644  NDIS_STATUS NdisStatus;
646 
647  TI_DbgPrint(MAX_TRACE, ("[TCPIP, DriverEntry] Called\n"));
648 
649  /* TdiInitialize() ? */
650 
651  /* FIXME: Create symbolic links in Win32 namespace */
652 
653  /* Initialize our periodic timer and its associated DPC object. When the
654  timer expires, the IPTimeout deferred procedure call (DPC) is queued */
657 
658  /* Create IP device object */
659  Status = IoCreateDevice(DriverObject, 0, &strIpDeviceName,
661  if (!NT_SUCCESS(Status)) {
662  TI_DbgPrint(MIN_TRACE, ("Failed to create IP device object. Status (0x%X).\n", Status));
664  return Status;
665  }
666 
668 
669  /* Create RawIP device object */
670  Status = IoCreateDevice(DriverObject, 0, &strRawDeviceName,
672  if (!NT_SUCCESS(Status)) {
673  TI_DbgPrint(MIN_TRACE, ("Failed to create RawIP device object. Status (0x%X).\n", Status));
675  return Status;
676  }
677 
678  /* Create UDP device object */
679  Status = IoCreateDevice(DriverObject, 0, &strUdpDeviceName,
681  if (!NT_SUCCESS(Status)) {
682  TI_DbgPrint(MIN_TRACE, ("Failed to create UDP device object. Status (0x%X).\n", Status));
684  return Status;
685  }
686 
687  /* Create TCP device object */
688  Status = IoCreateDevice(DriverObject, 0, &strTcpDeviceName,
690  if (!NT_SUCCESS(Status)) {
691  TI_DbgPrint(MIN_TRACE, ("Failed to create TCP device object. Status (0x%X).\n", Status));
693  return Status;
694  }
695 
696  /* Setup network layer and transport layer entities */
699  sizeof(TDIEntityID) * MAX_TDI_ENTITIES,
700  TDI_ENTITY_TAG );
701  if (!EntityList) {
702  TI_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
705  }
706 
707  EntityCount = 0;
709 
710  /* Allocate NDIS packet descriptors */
711  NdisAllocatePacketPoolEx(&NdisStatus, &GlobalPacketPool, 500, 1500, sizeof(PACKET_CONTEXT));
712  if (NdisStatus != NDIS_STATUS_SUCCESS) {
715  }
716 
717  /* Allocate NDIS buffer descriptors */
718  NdisAllocateBufferPool(&NdisStatus, &GlobalBufferPool, 2000);
719  if (NdisStatus != NDIS_STATUS_SUCCESS) {
722  }
723 
724  /* Initialize address file list and protecting spin lock */
727 
728  /* Initialize connection endpoint list and protecting spin lock */
731 
732  /* Initialize interface list and protecting spin lock */
735 
736  /* Initialize network level protocol subsystem */
738 
739  /* Initialize transport level protocol subsystems */
740  Status = RawIPStartup();
741  if( !NT_SUCCESS(Status) ) {
743  return Status;
744  }
745 
746  Status = UDPStartup();
747  if( !NT_SUCCESS(Status) ) {
749  return Status;
750  }
751 
752  Status = TCPStartup();
753  if( !NT_SUCCESS(Status) ) {
755  return Status;
756  }
757 
758  Status = ICMPStartup();
759  if( !NT_SUCCESS(Status) ) {
761  return Status;
762  }
763 
764  /* Use direct I/O */
769 
770  /* Initialize the driver object with this driver's entry points */
775 
777 
778  /* Open loopback adapter */
780  if (!NT_SUCCESS(Status)) {
781  TI_DbgPrint(MIN_TRACE, ("Failed to create loopback adapter. Status (0x%X).\n", Status));
783  return Status;
784  }
785 
786  /* Register protocol with NDIS */
787  /* This used to be IP_DEVICE_NAME but the DDK says it has to match your entry in the SCM */
788  Status = LANRegisterProtocol(&strNdisDeviceName);
789  if (!NT_SUCCESS(Status)) {
790  TI_DbgPrint(MIN_TRACE,("Failed to register protocol with NDIS; status 0x%x\n", Status));
792  DriverObject,
795  Status,
796  NULL,
797  0,
798  NULL);
800  return Status;
801  }
802 
803  /* Start the periodic timer with an initial and periodic
804  relative expiration time of IP_TIMEOUT milliseconds */
805  DueTime.QuadPart = -(LONGLONG)IP_TIMEOUT * 10000;
807 
808  TI_DbgPrint(MAX_TRACE, ("[TCPIP, DriverEntry] Finished\n"));
809 
810 
811  return STATUS_SUCCESS;
812 }
813 
814 VOID NTAPI
816  ULONG Unknown0,
817  ULONG Unknown1,
818  ULONG Unknown2,
819  ULONG Unknown3,
820  ULONG Unknown4)
821 {
823 }
824 
825 
826 VOID NTAPI
828  ULONG Unknown0)
829 {
831 }
832 
833 
834 VOID NTAPI
836  ULONG Unknown0,
837  ULONG Unknown1)
838 {
840 }
841 
842 /* EOF */
NTSTATUS FileCloseConnection(PTDI_REQUEST Request)
Definition: fileobjs.c:656
KDPC IPTimeoutDpc
Definition: main.c:30
_In_ ULONG _In_ BOOLEAN _In_ ULONG UniqueErrorValue
Definition: classpnp.h:1310
#define TI_DbgPrint(_t_, _x_)
Definition: debug.h:45
NTSTATUS DispTdiSetInformation(PIRP Irp)
Definition: dispatch.c:1257
NTSTATUS DispTdiSetIPAddress(PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: dispatch.c:1552
VOID NTAPI IPTimeoutDpcFn(PKDPC Dpc, PVOID DeferredContext, PVOID SystemArgument1, PVOID SystemArgument2)
Definition: ip.c:112
#define IN
Definition: typedefs.h:39
NTSTATUS DispTdiDisconnect(PIRP Irp)
Definition: dispatch.c:485
#define MAX_TDI_ENTITIES
Definition: tdiinfo.h:35
NDIS_HANDLE GlobalPacketPool
Definition: main.c:20
NTSTATUS FileCloseAddress(PTDI_REQUEST Request)
Definition: fileobjs.c:580
NTSTATUS IPShutdown(VOID)
Definition: ip.c:477
NTSTATUS DispTdiSend(PIRP Irp)
Definition: dispatch.c:935
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES IN DWORD Unknown3
Definition: conport.c:35
NTSTATUS DispTdiQueryIpHwAddress(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: dispatch.c:1672
NTSTATUS DispTdiQueryInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: dispatch.c:664
#define TDI_LISTEN
Definition: tdikrnl.h:50
#define FILE_DEVICE_NETWORK
Definition: winioctl.h:123
NTSTATUS RawIPShutdown(VOID)
Definition: rawip.c:356
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239
#define IOCTL_ICMP_ECHO_REQUEST
Definition: tcpioctl.h:49
#define TDI_ASSOCIATE_ADDRESS
Definition: tdikrnl.h:47
#define EVENT_TRANSPORT_REGISTER_FAILED
Definition: netevent.h:531
NTSTATUS FinalStatus
Definition: iotypes.h:1973
_In_ PIRP Irp
Definition: csq.h:116
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_In_ LARGE_INTEGER DueTime
Definition: kefuncs.h:511
uint16_t * PWSTR
Definition: typedefs.h:56
NTSTATUS DispTdiConnect(PIRP Irp)
Definition: dispatch.c:383
LIST_ENTRY ConnectionEndpointListHead
Definition: fileobjs.c:25
NTSTATUS UDPShutdown(VOID)
Definition: udp.c:364
unsigned char * PUCHAR
Definition: retypes.h:3
struct _TA_ADDRESS_IP * PTA_IP_ADDRESS
NDIS_STATUS LoopUnregisterAdapter(PLAN_ADAPTER Adapter)
Definition: loopback.c:143
KSPIN_LOCK InterfaceListLock
Definition: ip.c:18
NTSTATUS FileCloseControlChannel(PTDI_REQUEST Request)
Definition: fileobjs.c:727
VOID TiWriteErrorLog(PDRIVER_OBJECT DriverContext, NTSTATUS ErrorCode, ULONG UniqueErrorValue, NTSTATUS FinalStatus, PWSTR String, ULONG DumpDataCount, PULONG DumpData)
Definition: main.c:32
LONG NTSTATUS
Definition: precomp.h:26
#define DD_TCP_DEVICE_NAME
Definition: wshtcpip.h:27
_In_ USHORT _In_ ULONG Protocol
Definition: wsk.h:182
#define TDI_CONNECTION_FILE
Definition: tdikrnl.h:66
NTSTATUS RawIPStartup(VOID)
Definition: rawip.c:338
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
Irp Tail Overlay DriverContext[3]
#define TDI_CONNECTION_CONTEXT_LENGTH
Definition: tdi.h:373
static WCHAR String[]
Definition: stringtable.c:55
BOOLEAN NTAPI KeSetTimerEx(IN OUT PKTIMER Timer, IN LARGE_INTEGER DueTime, IN LONG Period, IN PKDPC Dpc OPTIONAL)
Definition: timerobj.c:294
#define TDI_ACCEPT
Definition: tdikrnl.h:51
NTSTATUS NTAPI TiDispatchInternal(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: main.c:374
NTSTATUS TiCreateFileObject(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: main.c:109
_In_ UCHAR EntrySize
Definition: iofuncs.h:640
VOID TcpipReleaseSpinLock(PKSPIN_LOCK SpinLock, KIRQL Irql)
Definition: lock.c:26
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
ULONG EntityCount
Definition: main.c:24
VOID NTAPI IoWriteErrorLogEntry(IN PVOID ElEntry)
Definition: error.c:620
VOID TcpipAcquireSpinLock(PKSPIN_LOCK SpinLock, PKIRQL Irql)
Definition: lock.c:18
#define TDI_SET_INFORMATION
Definition: tdikrnl.h:59
#define DO_DIRECT_IO
Definition: env_spec_w32.h:396
#define TRANS_CONTEXT_TAG
Definition: tags.h:13
VOID NTAPI TiUnload(PDRIVER_OBJECT DriverObject)
Definition: main.c:560
int NDIS_STATUS
Definition: ntddndis.h:471
uint32_t ULONG_PTR
Definition: typedefs.h:65
_In_ NDIS_HANDLE _In_ PNDIS_REQUEST Request
Definition: ndis.h:5173
VOID NTAPI IPAddInterface(ULONG Unknown0, ULONG Unknown1, ULONG Unknown2, ULONG Unknown3, ULONG Unknown4)
Definition: main.c:815
UCHAR KIRQL
Definition: env_spec_w32.h:591
NTSTATUS ErrorCode
Definition: iotypes.h:1971
#define TDI_DISCONNECT
Definition: tdikrnl.h:52
NTSTATUS DispTdiSetInformationEx(PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: dispatch.c:1493
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
#define FALSE
Definition: types.h:117
#define UNICODE_NULL
#define TDI_ACTION
Definition: tdikrnl.h:60
NTSTATUS UDPStartup(VOID)
Definition: udp.c:337
PRTL_UNICODE_STRING_BUFFER PULONG PULONG Unknown4
VOID NTAPI LookupRoute(ULONG Unknown0, ULONG Unknown1)
Definition: main.c:835
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:238
#define TDI_CONNECT
Definition: tdikrnl.h:49
unsigned char BOOLEAN
NTSTATUS DispTdiQueryInformationEx(PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: dispatch.c:1310
#define TCPIP_PROTOCOL_NAME
Definition: ticonsts.h:32
smooth NULL
Definition: ftsmooth.c:416
struct _IO_ERROR_LOG_PACKET IO_ERROR_LOG_PACKET
#define ERROR_LOG_MAXIMUM_SIZE
Definition: iotypes.h:2006
static WCHAR Address[46]
Definition: ping.c:68
#define TDI_SET_EVENT_HANDLER
Definition: tdikrnl.h:57
#define TI_ERROR_DRIVERENTRY
Definition: ticonsts.h:36
NTSTATUS DispTdiDeleteIPAddress(PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: dispatch.c:1600
static PDRIVER_OBJECT DriverObject
Definition: template.c:42
VOID NTAPI KeInitializeTimer(OUT PKTIMER Timer)
Definition: timerobj.c:233
#define DD_IP_DEVICE_NAME
Definition: ticonsts.h:26
#define TDI_RECEIVE_DATAGRAM
Definition: tdikrnl.h:56
VOID ChewShutdown(VOID)
Definition: workqueue.c:40
NTSTATUS ICMPShutdown(VOID)
#define DEBUG_IRP
Definition: debug.h:19
NTSTATUS DispTdiSendDatagram(PIRP Irp)
Definition: dispatch.c:1008
PVOID NTAPI IoAllocateErrorLogEntry(IN PVOID IoObject, IN UCHAR EntrySize)
Definition: error.c:520
NTSTATUS DispEchoRequest(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
PDEVICE_OBJECT UDPDeviceObject
Definition: main.c:17
#define IOCTL_DELETE_IP_ADDRESS
Definition: tcpioctl.h:46
NTSTATUS TiGetProtocolNumber(PUNICODE_STRING FileName, PULONG Protocol)
Definition: proto.c:3
int64_t LONGLONG
Definition: typedefs.h:68
#define TDI_RECEIVE
Definition: tdikrnl.h:54
#define TDI_ENTITY_TAG
Definition: tags.h:14
NTSTATUS DispTdiListen(PIRP Irp)
Definition: dispatch.c:551
NDIS_HANDLE GlobalBufferPool
Definition: main.c:21
_In_z_ PWSTR RegistryPath
Definition: classp.h:1930
PDEVICE_OBJECT TCPDeviceObject
Definition: main.c:16
BOOLEAN NTAPI KeCancelTimer(IN OUT PKTIMER Timer)
Definition: timerobj.c:206
ULONG EntityMax
Definition: main.c:25
PDEVICE_OBJECT IPDeviceObject
Definition: main.c:18
USHORT NumberOfStrings
Definition: iotypes.h:1968
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
_In_ PVOID ClientContext
Definition: netioddk.h:55
NTSTATUS NTAPI TiDispatch(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Dispatch routine for IRP_MJ_DEVICE_CONTROL requests.
Definition: main.c:488
KTIMER IPTimer
Definition: main.c:29
NTSTATUS DispTdiReceiveDatagram(PIRP Irp)
Definition: dispatch.c:860
#define DD_UDP_DEVICE_NAME
Definition: wshtcpip.h:28
#define IRP_MJ_INTERNAL_DEVICE_CONTROL
#define IOCTL_SET_IP_ADDRESS
Definition: tcpioctl.h:43
VOID NTAPI IPDelInterface(ULONG Unknown0)
Definition: main.c:827
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
unsigned char UCHAR
Definition: xmlstorage.h:181
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
Status
Definition: gdiplustypes.h:24
static const WCHAR L[]
Definition: oid.c:1250
NTSTATUS DispTdiSetEventHandler(PIRP Irp)
Definition: dispatch.c:1093
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
Definition: ketypes.h:687
PDRIVER_UNLOAD DriverUnload
Definition: iotypes.h:2187
PDEVICE_OBJECT RawIPDeviceObject
Definition: main.c:19
#define TDI_TRANSPORT_ADDRESS_FILE
Definition: tdikrnl.h:65
#define TDI_ADDRESS_TYPE_IP
Definition: tdi.h:345
#define IOCTL_TCP_QUERY_INFORMATION_EX
Definition: tditest.h:110
NTSTATUS NTAPI TdiMapUserRequest(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PIO_STACK_LOCATION IrpSp)
Definition: stubs.c:83
#define TDI_QUERY_INFORMATION
Definition: tdikrnl.h:58
#define IOCTL_TCP_SET_INFORMATION_EX
Definition: tditest.h:112
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1569
NTSTATUS TCPStartup(VOID)
Definition: tcp.c:183
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
LIST_ENTRY AddressFileListHead
Definition: fileobjs.c:21
LIST_ENTRY InterfaceListHead
Definition: ip.c:17
PFILE_OBJECT FileObject
Definition: iotypes.h:2820
NTSTATUS NTAPI TiDispatchOpenClose(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: main.c:333
#define TDI_SEND
Definition: tdikrnl.h:53
#define MAX_TRACE
Definition: debug.h:16
NTSTATUS TiCloseFileObject(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: main.c:284
unsigned short USHORT
Definition: pedump.c:61
NTSTATUS IPStartup(PUNICODE_STRING RegistryPath)
Definition: ip.c:411
NTSTATUS NTAPI DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
Definition: main.c:690
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
NTSTATUS DispTdiAssociateAddress(PIRP Irp)
Definition: dispatch.c:270
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
ULONG KSPIN_LOCK
Definition: env_spec_w32.h:72
VOID EXPORT NdisFreeBufferPool(IN NDIS_HANDLE PoolHandle)
Definition: buffer.c:775
unsigned int * PULONG
Definition: retypes.h:1
#define TdiTransportAddress
Definition: tdi.h:370
NTSTATUS LANRegisterProtocol(PNDIS_STRING Name)
Registers this protocol driver with NDIS.
Definition: lan.c:893
VOID EXPORT NdisAllocatePacketPoolEx(OUT PNDIS_STATUS Status, OUT PNDIS_HANDLE PoolHandle, IN UINT NumberOfDescriptors, IN UINT NumberOfOverflowDescriptors, IN UINT ProtocolReservedLength)
Definition: buffer.c:447
VOID EXPORT NdisFreePacketPool(IN NDIS_HANDLE PoolHandle)
Definition: buffer.c:791
#define TdiConnectionContext
Definition: tdi.h:371
KSPIN_LOCK AddressFileListLock
Definition: fileobjs.c:22
NTSTATUS FileOpenAddress(PTDI_REQUEST Request, PTA_IP_ADDRESS AddrList, USHORT Protocol, BOOLEAN Shared, PVOID Options)
Definition: fileobjs.c:391
NTSTATUS ICMPStartup(VOID)
#define TDI_TRANSPORT_ADDRESS_LENGTH
Definition: tdi.h:372
#define TDI_SEND_DATAGRAM
Definition: tdikrnl.h:55
struct _IO_ERROR_LOG_PACKET * PIO_ERROR_LOG_PACKET
PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION+1]
Definition: iotypes.h:2188
NTSTATUS IRPFinish(PIRP Irp, NTSTATUS Status)
Definition: dispatch.c:26
struct tagContext Context
Definition: acpixf.h:1034
unsigned int ULONG
Definition: retypes.h:1
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1031
#define UNIMPLEMENTED
Definition: debug.h:115
NTSTATUS DispTdiDisassociateAddress(PIRP Irp)
Definition: dispatch.c:447
#define MIN_TRACE
Definition: debug.h:14
#define TDI_DISASSOCIATE_ADDRESS
Definition: tdikrnl.h:48
KSPIN_LOCK EntityListLock
Definition: main.c:22
NTSTATUS DispTdiReceive(PIRP Irp)
Definition: dispatch.c:792
#define DD_RAWIP_DEVICE_NAME
Definition: ticonsts.h:27
NTSTATUS FileOpenControlChannel(PTDI_REQUEST Request)
Definition: fileobjs.c:683
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
NTSTATUS TCPShutdown(VOID)
Definition: tcp.c:218
#define TDI_ADDRESS_LENGTH_IP
Definition: tdi.h:413
TDIEntityInfo * EntityList
Definition: main.c:23
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2779
VOID NTAPI KeInitializeDpc(IN PKDPC Dpc, IN PKDEFERRED_ROUTINE DeferredRoutine, IN PVOID DeferredContext)
Definition: dpc.c:711
NTSTATUS FileOpenConnection(PTDI_REQUEST Request, PVOID ClientContext)
Definition: fileobjs.c:621
KSPIN_LOCK ConnectionEndpointListLock
Definition: fileobjs.c:26
return STATUS_SUCCESS
Definition: btrfs.c:3014
VOID ChewInit(PDEVICE_OBJECT DeviceObject)
Definition: workqueue.c:32
NDIS_STATUS LoopRegisterAdapter(PNDIS_STRING AdapterName, PLAN_ADAPTER *Adapter)
Definition: loopback.c:96
VOID LANUnregisterProtocol(VOID)
Unregisters this protocol driver with NDIS.
Definition: lan.c:943
VOID EXPORT NdisAllocateBufferPool(OUT PNDIS_STATUS Status, OUT PNDIS_HANDLE PoolHandle, IN UINT NumberOfDescriptors)
Definition: buffer.c:370
static PSecPkgInfoA *static SEC_CHAR PVOID
Definition: main.c:37
HRESULT Create([out]ITransactionReceiver **ppReceiver)
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
UDP_STATISTICS UDPStats
Definition: main.c:26
#define IOCTL_QUERY_IP_HW_ADDRESS
Definition: tcpioctl.h:40
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465
#define IP_TIMEOUT
Definition: ip.h:200
LONGLONG QuadPart
Definition: typedefs.h:114
NTSTATUS DispTdiAccept(PIRP Irp)
Definition: dispatch.c:254
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
#define TDI_CONTROL_CHANNEL_FILE
Definition: tdikrnl.h:67