ReactOS  0.4.14-dev-41-g31d7680
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 
479  PIRP Irp)
480 /*
481  * FUNCTION: Dispatch routine for IRP_MJ_DEVICE_CONTROL requests
482  * ARGUMENTS:
483  * DeviceObject = Pointer to a device object for this driver
484  * Irp = Pointer to a I/O request packet
485  * RETURNS:
486  * Status of the operation
487  */
488 {
491 
493 
494  TI_DbgPrint(DEBUG_IRP, ("[TCPIP, TiDispatch] Called. IRP is at (0x%X).\n", Irp));
495 
496  Irp->IoStatus.Information = 0;
497 
498 #if 0
500  if (NT_SUCCESS(Status)) {
503  } else {
504 #else
505  if (TRUE) {
506 #endif
507  /* See if this request is TCP/IP specific */
508  switch (IrpSp->Parameters.DeviceIoControl.IoControlCode) {
510  TI_DbgPrint(MIN_TRACE, ("TCP_QUERY_INFORMATION_EX\n"));
512  break;
513 
515  TI_DbgPrint(MIN_TRACE, ("TCP_SET_INFORMATION_EX\n"));
517  break;
518 
520  TI_DbgPrint(MIN_TRACE, ("SET_IP_ADDRESS\n"));
522  break;
523 
525  TI_DbgPrint(MIN_TRACE, ("DELETE_IP_ADDRESS\n"));
527  break;
528 
530  TI_DbgPrint(MIN_TRACE, ("QUERY_IP_HW_ADDRESS\n"));
532  break;
533 
534  default:
535  TI_DbgPrint(MIN_TRACE, ("Unknown IOCTL 0x%X\n",
536  IrpSp->Parameters.DeviceIoControl.IoControlCode));
538  break;
539  }
540  }
541 
542  TI_DbgPrint(DEBUG_IRP, ("[TCPIP, TiDispatch] Leaving. Status = (0x%X).\n", Status));
543 
544  return IRPFinish( Irp, Status );
545 }
546 
547 
550 /*
551  * FUNCTION: Unloads the driver
552  * ARGUMENTS:
553  * DriverObject = Pointer to driver object created by the system
554  */
555 {
556 #if DBG
557  KIRQL OldIrql;
558 
561  TI_DbgPrint(MIN_TRACE, ("[TCPIP, TiUnload] Called. Open address file objects exists.\n"));
562  }
564 #endif
565  /* Cancel timer */
567 
568  /* Unregister loopback adapter */
570 
571  /* Unregister protocol with NDIS */
573 
574  /* Shutdown transport level protocol subsystems */
575  TCPShutdown();
576  UDPShutdown();
577  RawIPShutdown();
578  ICMPShutdown();
579 
580  /* Shutdown network level protocol subsystem */
581  IPShutdown();
582 
583  /* Free NDIS buffer descriptors */
584  if (GlobalBufferPool)
586 
587  /* Free NDIS packet descriptors */
588  if (GlobalPacketPool)
590 
591  /* Release all device objects */
592 
593  if (TCPDeviceObject)
595 
596  if (UDPDeviceObject)
598 
599  if (RawIPDeviceObject)
601 
602  if (IPDeviceObject) {
603  ChewShutdown();
605  }
606 
607  if (EntityList)
609 
610  TI_DbgPrint(MAX_TRACE, ("[TCPIP, TiUnload] Leaving.\n"));
611 }
612 
617 /*
618  * FUNCTION: Main driver entry point
619  * ARGUMENTS:
620  * DriverObject = Pointer to a driver object for this driver
621  * RegistryPath = Registry node for configuration parameters
622  * RETURNS:
623  * Status of driver initialization
624  */
625 {
632  NDIS_STATUS NdisStatus;
634 
635  TI_DbgPrint(MAX_TRACE, ("[TCPIP, DriverEntry] Called\n"));
636 
637  /* TdiInitialize() ? */
638 
639  /* FIXME: Create symbolic links in Win32 namespace */
640 
641  /* Initialize our periodic timer and its associated DPC object. When the
642  timer expires, the IPTimeout deferred procedure call (DPC) is queued */
645 
646  /* Create IP device object */
647  Status = IoCreateDevice(DriverObject, 0, &strIpDeviceName,
649  if (!NT_SUCCESS(Status)) {
650  TI_DbgPrint(MIN_TRACE, ("Failed to create IP device object. Status (0x%X).\n", Status));
652  return Status;
653  }
654 
656 
657  /* Create RawIP device object */
658  Status = IoCreateDevice(DriverObject, 0, &strRawDeviceName,
660  if (!NT_SUCCESS(Status)) {
661  TI_DbgPrint(MIN_TRACE, ("Failed to create RawIP device object. Status (0x%X).\n", Status));
663  return Status;
664  }
665 
666  /* Create UDP device object */
667  Status = IoCreateDevice(DriverObject, 0, &strUdpDeviceName,
669  if (!NT_SUCCESS(Status)) {
670  TI_DbgPrint(MIN_TRACE, ("Failed to create UDP device object. Status (0x%X).\n", Status));
672  return Status;
673  }
674 
675  /* Create TCP device object */
676  Status = IoCreateDevice(DriverObject, 0, &strTcpDeviceName,
678  if (!NT_SUCCESS(Status)) {
679  TI_DbgPrint(MIN_TRACE, ("Failed to create TCP device object. Status (0x%X).\n", Status));
681  return Status;
682  }
683 
684  /* Setup network layer and transport layer entities */
687  sizeof(TDIEntityID) * MAX_TDI_ENTITIES,
688  TDI_ENTITY_TAG );
689  if (!EntityList) {
690  TI_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
693  }
694 
695  EntityCount = 0;
697 
698  /* Allocate NDIS packet descriptors */
699  NdisAllocatePacketPoolEx(&NdisStatus, &GlobalPacketPool, 500, 1500, sizeof(PACKET_CONTEXT));
700  if (NdisStatus != NDIS_STATUS_SUCCESS) {
703  }
704 
705  /* Allocate NDIS buffer descriptors */
706  NdisAllocateBufferPool(&NdisStatus, &GlobalBufferPool, 2000);
707  if (NdisStatus != NDIS_STATUS_SUCCESS) {
710  }
711 
712  /* Initialize address file list and protecting spin lock */
715 
716  /* Initialize connection endpoint list and protecting spin lock */
719 
720  /* Initialize interface list and protecting spin lock */
723 
724  /* Initialize network level protocol subsystem */
726 
727  /* Initialize transport level protocol subsystems */
728  Status = RawIPStartup();
729  if( !NT_SUCCESS(Status) ) {
731  return Status;
732  }
733 
734  Status = UDPStartup();
735  if( !NT_SUCCESS(Status) ) {
737  return Status;
738  }
739 
740  Status = TCPStartup();
741  if( !NT_SUCCESS(Status) ) {
743  return Status;
744  }
745 
746  Status = ICMPStartup();
747  if( !NT_SUCCESS(Status) ) {
749  return Status;
750  }
751 
752  /* Use direct I/O */
757 
758  /* Initialize the driver object with this driver's entry points */
763 
765 
766  /* Open loopback adapter */
768  if (!NT_SUCCESS(Status)) {
769  TI_DbgPrint(MIN_TRACE, ("Failed to create loopback adapter. Status (0x%X).\n", Status));
771  return Status;
772  }
773 
774  /* Register protocol with NDIS */
775  /* This used to be IP_DEVICE_NAME but the DDK says it has to match your entry in the SCM */
776  Status = LANRegisterProtocol(&strNdisDeviceName);
777  if (!NT_SUCCESS(Status)) {
778  TI_DbgPrint(MIN_TRACE,("Failed to register protocol with NDIS; status 0x%x\n", Status));
780  DriverObject,
783  Status,
784  NULL,
785  0,
786  NULL);
788  return Status;
789  }
790 
791  /* Start the periodic timer with an initial and periodic
792  relative expiration time of IP_TIMEOUT milliseconds */
793  DueTime.QuadPart = -(LONGLONG)IP_TIMEOUT * 10000;
795 
796  TI_DbgPrint(MAX_TRACE, ("[TCPIP, DriverEntry] Finished\n"));
797 
798 
799  return STATUS_SUCCESS;
800 }
801 
802 VOID NTAPI
804  ULONG Unknown0,
805  ULONG Unknown1,
806  ULONG Unknown2,
807  ULONG Unknown3,
808  ULONG Unknown4)
809 {
811 }
812 
813 
814 VOID NTAPI
816  ULONG Unknown0)
817 {
819 }
820 
821 
822 VOID NTAPI
824  ULONG Unknown0,
825  ULONG Unknown1)
826 {
828 }
829 
830 /* 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:1117
#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:38
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
#define TRUE
Definition: types.h:120
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:225
#define TDI_ASSOCIATE_ADDRESS
Definition: tdikrnl.h:47
#define EVENT_TRANSPORT_REGISTER_FAILED
Definition: netevent.h:531
NTSTATUS FinalStatus
Definition: iotypes.h:1966
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_In_ LARGE_INTEGER DueTime
Definition: kefuncs.h:524
uint16_t * PWSTR
Definition: typedefs.h:54
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:136
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
#define IOCTL_TCP_QUERY_INFORMATION_EX
Definition: ticonsts.h:42
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:548
int NDIS_STATUS
Definition: ntddndis.h:471
uint32_t ULONG_PTR
Definition: typedefs.h:63
_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:803
UCHAR KIRQL
Definition: env_spec_w32.h:591
NTSTATUS ErrorCode
Definition: iotypes.h:1964
#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 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:823
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:251
#define IOCTL_TCP_SET_INFORMATION_EX
Definition: ticonsts.h:45
#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:1999
static WCHAR Address[46]
Definition: ping.c:68
#define TDI_SET_EVENT_HANDLER
Definition: tdikrnl.h:57
#define TI_ERROR_DRIVERENTRY
Definition: ticonsts.h:55
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 IOCTL_DELETE_IP_ADDRESS
Definition: ticonsts.h:51
#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
PDEVICE_OBJECT UDPDeviceObject
Definition: main.c:17
NTSTATUS TiGetProtocolNumber(PUNICODE_STRING FileName, PULONG Protocol)
Definition: proto.c:3
int64_t LONGLONG
Definition: typedefs.h:66
#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
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:1961
__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)
Definition: main.c:477
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
VOID NTAPI IPDelInterface(ULONG Unknown0)
Definition: main.c:815
#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
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:803
Definition: ketypes.h:687
PDRIVER_UNLOAD DriverUnload
Definition: iotypes.h:2180
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
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
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
NTSTATUS TCPStartup(VOID)
Definition: tcp.c:183
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
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:2813
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:4157
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 IOCTL_SET_IP_ADDRESS
Definition: ticonsts.h:48
#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:2181
NTSTATUS IRPFinish(PIRP Irp, NTSTATUS Status)
Definition: dispatch.c:26
struct tagContext Context
Definition: acpixf.h:1024
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:114
NTSTATUS DispTdiDisassociateAddress(PIRP Irp)
Definition: dispatch.c:447
#define MIN_TRACE
Definition: debug.h:14
#define TDI_DISASSOCIATE_ADDRESS
Definition: tdikrnl.h:48
_In_ PUNICODE_STRING RegistryPath
Definition: wmip.h:27
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:2772
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:2966
VOID ChewInit(PDEVICE_OBJECT DeviceObject)
Definition: workqueue.c:32
NDIS_STATUS LoopRegisterAdapter(PNDIS_STRING AdapterName, PLAN_ADAPTER *Adapter)
Definition: loopback.c:89
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:112
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