Formatting, no code change

This commit is contained in:
Ged Murphy 2018-01-20 18:22:44 +00:00
parent 63775c3215
commit 37a39f1843

View file

@ -107,8 +107,8 @@ VOID TiWriteErrorLog(
*/ */
NTSTATUS TiCreateFileObject( NTSTATUS TiCreateFileObject(
PDEVICE_OBJECT DeviceObject, PDEVICE_OBJECT DeviceObject,
PIRP Irp) PIRP Irp)
{ {
PFILE_FULL_EA_INFORMATION EaInfo; PFILE_FULL_EA_INFORMATION EaInfo;
PTRANSPORT_CONTEXT Context; PTRANSPORT_CONTEXT Context;
@ -166,10 +166,10 @@ NTSTATUS TiCreateFileObject(
TI_DbgPrint(MIN_TRACE, ("AddressCount: %d\n", Address->TAAddressCount)); TI_DbgPrint(MIN_TRACE, ("AddressCount: %d\n", Address->TAAddressCount));
if( Address->TAAddressCount == 1 ) if( Address->TAAddressCount == 1 )
{ {
TI_DbgPrint(MIN_TRACE, ("AddressLength: %u\n", TI_DbgPrint(MIN_TRACE, ("AddressLength: %u\n",
Address->Address[0].AddressLength)); Address->Address[0].AddressLength));
TI_DbgPrint(MIN_TRACE, ("AddressType: %u\n", TI_DbgPrint(MIN_TRACE, ("AddressType: %u\n",
Address->Address[0].AddressType)); Address->Address[0].AddressType));
} }
ExFreePoolWithTag(Context, TRANS_CONTEXT_TAG); ExFreePoolWithTag(Context, TRANS_CONTEXT_TAG);
@ -213,11 +213,11 @@ NTSTATUS TiCreateFileObject(
} }
else if (EaInfo && else if (EaInfo &&
(EaInfo->EaNameLength == TDI_CONNECTION_CONTEXT_LENGTH) && (EaInfo->EaNameLength == TDI_CONNECTION_CONTEXT_LENGTH) &&
(RtlCompareMemory (RtlCompareMemory
(&EaInfo->EaName, TdiConnectionContext, (&EaInfo->EaName, TdiConnectionContext,
TDI_CONNECTION_CONTEXT_LENGTH) == TDI_CONNECTION_CONTEXT_LENGTH) ==
TDI_CONNECTION_CONTEXT_LENGTH)) TDI_CONNECTION_CONTEXT_LENGTH))
{ {
/* This is a request to open a connection endpoint */ /* This is a request to open a connection endpoint */
@ -282,8 +282,8 @@ NTSTATUS TiCreateFileObject(
* This function does not pend * This function does not pend
*/ */
NTSTATUS TiCloseFileObject( NTSTATUS TiCloseFileObject(
PDEVICE_OBJECT DeviceObject, PDEVICE_OBJECT DeviceObject,
PIRP Irp) PIRP Irp)
{ {
PIO_STACK_LOCATION IrpSp; PIO_STACK_LOCATION IrpSp;
PTRANSPORT_CONTEXT Context; PTRANSPORT_CONTEXT Context;
@ -331,8 +331,8 @@ NTSTATUS TiCloseFileObject(
NTSTATUS NTAPI NTSTATUS NTAPI
TiDispatchOpenClose( TiDispatchOpenClose(
IN PDEVICE_OBJECT DeviceObject, IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp) IN PIRP Irp)
/* /*
* FUNCTION: Main dispath routine * FUNCTION: Main dispath routine
* ARGUMENTS: * ARGUMENTS:
@ -342,38 +342,38 @@ TiDispatchOpenClose(
* Status of the operation * Status of the operation
*/ */
{ {
PIO_STACK_LOCATION IrpSp; PIO_STACK_LOCATION IrpSp;
NTSTATUS Status; NTSTATUS Status;
// DbgPrint("Called. DeviceObject is at (0x%X), IRP is at (0x%X).\n", DeviceObject, Irp); // DbgPrint("Called. DeviceObject is at (0x%X), IRP is at (0x%X).\n", DeviceObject, Irp);
IrpSp = IoGetCurrentIrpStackLocation(Irp); IrpSp = IoGetCurrentIrpStackLocation(Irp);
switch (IrpSp->MajorFunction) { switch (IrpSp->MajorFunction) {
/* Open an address file, connection endpoint, or control connection */ /* Open an address file, connection endpoint, or control connection */
case IRP_MJ_CREATE: case IRP_MJ_CREATE:
Status = TiCreateFileObject(DeviceObject, Irp); Status = TiCreateFileObject(DeviceObject, Irp);
break; break;
/* Close an address file, connection endpoint, or control connection */ /* Close an address file, connection endpoint, or control connection */
case IRP_MJ_CLOSE: case IRP_MJ_CLOSE:
Status = TiCloseFileObject(DeviceObject, Irp); Status = TiCloseFileObject(DeviceObject, Irp);
break; break;
default: default:
Status = STATUS_INVALID_DEVICE_REQUEST; Status = STATUS_INVALID_DEVICE_REQUEST;
} }
//DbgPrint("Leaving. Status is (0x%X)\n", Status); //DbgPrint("Leaving. Status is (0x%X)\n", Status);
return IRPFinish( Irp, Status ); return IRPFinish( Irp, Status );
} }
NTSTATUS NTAPI NTSTATUS NTAPI
TiDispatchInternal( TiDispatchInternal(
PDEVICE_OBJECT DeviceObject, PDEVICE_OBJECT DeviceObject,
PIRP Irp) PIRP Irp)
/* /*
* FUNCTION: Internal IOCTL dispatch routine * FUNCTION: Internal IOCTL dispatch routine
* ARGUMENTS: * ARGUMENTS:
@ -383,100 +383,100 @@ TiDispatchInternal(
* Status of the operation * Status of the operation
*/ */
{ {
NTSTATUS Status; NTSTATUS Status;
BOOLEAN Complete = TRUE; BOOLEAN Complete = TRUE;
PIO_STACK_LOCATION IrpSp; PIO_STACK_LOCATION IrpSp;
IrpSp = IoGetCurrentIrpStackLocation(Irp); IrpSp = IoGetCurrentIrpStackLocation(Irp);
TI_DbgPrint(DEBUG_IRP, ("[TCPIP, TiDispatchInternal] Called. DeviceObject is at (0x%X), IRP is at (0x%X) MN (%d).\n", TI_DbgPrint(DEBUG_IRP, ("[TCPIP, TiDispatchInternal] Called. DeviceObject is at (0x%X), IRP is at (0x%X) MN (%d).\n",
DeviceObject, Irp, IrpSp->MinorFunction)); DeviceObject, Irp, IrpSp->MinorFunction));
Irp->IoStatus.Status = STATUS_SUCCESS; Irp->IoStatus.Status = STATUS_SUCCESS;
Irp->IoStatus.Information = 0; Irp->IoStatus.Information = 0;
switch (IrpSp->MinorFunction) { switch (IrpSp->MinorFunction) {
case TDI_RECEIVE: case TDI_RECEIVE:
Status = DispTdiReceive(Irp); Status = DispTdiReceive(Irp);
Complete = FALSE; Complete = FALSE;
break; break;
case TDI_RECEIVE_DATAGRAM: case TDI_RECEIVE_DATAGRAM:
Status = DispTdiReceiveDatagram(Irp); Status = DispTdiReceiveDatagram(Irp);
Complete = FALSE; Complete = FALSE;
break; break;
case TDI_SEND: case TDI_SEND:
Status = DispTdiSend(Irp); Status = DispTdiSend(Irp);
Complete = FALSE; /* Completed in DispTdiSend */ Complete = FALSE; /* Completed in DispTdiSend */
break; break;
case TDI_SEND_DATAGRAM: case TDI_SEND_DATAGRAM:
Status = DispTdiSendDatagram(Irp); Status = DispTdiSendDatagram(Irp);
Complete = FALSE; Complete = FALSE;
break; break;
case TDI_ACCEPT: case TDI_ACCEPT:
Status = DispTdiAccept(Irp); Status = DispTdiAccept(Irp);
break; break;
case TDI_LISTEN: case TDI_LISTEN:
Status = DispTdiListen(Irp); Status = DispTdiListen(Irp);
Complete = FALSE; Complete = FALSE;
break; break;
case TDI_CONNECT: case TDI_CONNECT:
Status = DispTdiConnect(Irp); Status = DispTdiConnect(Irp);
Complete = FALSE; /* Completed by the TCP event handler */ Complete = FALSE; /* Completed by the TCP event handler */
break; break;
case TDI_DISCONNECT: case TDI_DISCONNECT:
Status = DispTdiDisconnect(Irp); Status = DispTdiDisconnect(Irp);
Complete = FALSE; Complete = FALSE;
break; break;
case TDI_ASSOCIATE_ADDRESS: case TDI_ASSOCIATE_ADDRESS:
Status = DispTdiAssociateAddress(Irp); Status = DispTdiAssociateAddress(Irp);
break; break;
case TDI_DISASSOCIATE_ADDRESS: case TDI_DISASSOCIATE_ADDRESS:
Status = DispTdiDisassociateAddress(Irp); Status = DispTdiDisassociateAddress(Irp);
break; break;
case TDI_QUERY_INFORMATION: case TDI_QUERY_INFORMATION:
Status = DispTdiQueryInformation(DeviceObject, Irp); Status = DispTdiQueryInformation(DeviceObject, Irp);
break; break;
case TDI_SET_INFORMATION: case TDI_SET_INFORMATION:
Status = DispTdiSetInformation(Irp); Status = DispTdiSetInformation(Irp);
break; break;
case TDI_SET_EVENT_HANDLER: case TDI_SET_EVENT_HANDLER:
Status = DispTdiSetEventHandler(Irp); Status = DispTdiSetEventHandler(Irp);
break; break;
case TDI_ACTION: case TDI_ACTION:
Status = STATUS_SUCCESS; Status = STATUS_SUCCESS;
break; break;
/* An unsupported IOCTL code was submitted */ /* An unsupported IOCTL code was submitted */
default: default:
Status = STATUS_INVALID_DEVICE_REQUEST; Status = STATUS_INVALID_DEVICE_REQUEST;
} }
TI_DbgPrint(DEBUG_IRP, ("[TCPIP, TiDispatchInternal] Leaving. Status = (0x%X).\n", Status)); TI_DbgPrint(DEBUG_IRP, ("[TCPIP, TiDispatchInternal] Leaving. Status = (0x%X).\n", Status));
if( Complete ) if( Complete )
IRPFinish( Irp, Status ); IRPFinish( Irp, Status );
return Status; return Status;
} }
NTSTATUS NTAPI NTSTATUS NTAPI
TiDispatch( TiDispatch(
PDEVICE_OBJECT DeviceObject, PDEVICE_OBJECT DeviceObject,
PIRP Irp) PIRP Irp)
/* /*
* FUNCTION: Dispatch routine for IRP_MJ_DEVICE_CONTROL requests * FUNCTION: Dispatch routine for IRP_MJ_DEVICE_CONTROL requests
* ARGUMENTS: * ARGUMENTS:
@ -486,62 +486,62 @@ TiDispatch(
* Status of the operation * Status of the operation
*/ */
{ {
NTSTATUS Status; NTSTATUS Status;
PIO_STACK_LOCATION IrpSp; PIO_STACK_LOCATION IrpSp;
IrpSp = IoGetCurrentIrpStackLocation(Irp); IrpSp = IoGetCurrentIrpStackLocation(Irp);
TI_DbgPrint(DEBUG_IRP, ("[TCPIP, TiDispatch] Called. IRP is at (0x%X).\n", Irp)); TI_DbgPrint(DEBUG_IRP, ("[TCPIP, TiDispatch] Called. IRP is at (0x%X).\n", Irp));
Irp->IoStatus.Information = 0; Irp->IoStatus.Information = 0;
#if 0 #if 0
Status = TdiMapUserRequest(DeviceObject, Irp, IrpSp); Status = TdiMapUserRequest(DeviceObject, Irp, IrpSp);
if (NT_SUCCESS(Status)) { if (NT_SUCCESS(Status)) {
TiDispatchInternal(DeviceObject, Irp); TiDispatchInternal(DeviceObject, Irp);
Status = STATUS_PENDING; Status = STATUS_PENDING;
} else { } else {
#else #else
if (TRUE) { if (TRUE) {
#endif #endif
/* See if this request is TCP/IP specific */ /* See if this request is TCP/IP specific */
switch (IrpSp->Parameters.DeviceIoControl.IoControlCode) { switch (IrpSp->Parameters.DeviceIoControl.IoControlCode) {
case IOCTL_TCP_QUERY_INFORMATION_EX: case IOCTL_TCP_QUERY_INFORMATION_EX:
TI_DbgPrint(MIN_TRACE, ("TCP_QUERY_INFORMATION_EX\n")); TI_DbgPrint(MIN_TRACE, ("TCP_QUERY_INFORMATION_EX\n"));
Status = DispTdiQueryInformationEx(Irp, IrpSp); Status = DispTdiQueryInformationEx(Irp, IrpSp);
break; break;
case IOCTL_TCP_SET_INFORMATION_EX: case IOCTL_TCP_SET_INFORMATION_EX:
TI_DbgPrint(MIN_TRACE, ("TCP_SET_INFORMATION_EX\n")); TI_DbgPrint(MIN_TRACE, ("TCP_SET_INFORMATION_EX\n"));
Status = DispTdiSetInformationEx(Irp, IrpSp); Status = DispTdiSetInformationEx(Irp, IrpSp);
break; break;
case IOCTL_SET_IP_ADDRESS: case IOCTL_SET_IP_ADDRESS:
TI_DbgPrint(MIN_TRACE, ("SET_IP_ADDRESS\n")); TI_DbgPrint(MIN_TRACE, ("SET_IP_ADDRESS\n"));
Status = DispTdiSetIPAddress(Irp, IrpSp); Status = DispTdiSetIPAddress(Irp, IrpSp);
break; break;
case IOCTL_DELETE_IP_ADDRESS: case IOCTL_DELETE_IP_ADDRESS:
TI_DbgPrint(MIN_TRACE, ("DELETE_IP_ADDRESS\n")); TI_DbgPrint(MIN_TRACE, ("DELETE_IP_ADDRESS\n"));
Status = DispTdiDeleteIPAddress(Irp, IrpSp); Status = DispTdiDeleteIPAddress(Irp, IrpSp);
break; break;
case IOCTL_QUERY_IP_HW_ADDRESS: case IOCTL_QUERY_IP_HW_ADDRESS:
TI_DbgPrint(MIN_TRACE, ("QUERY_IP_HW_ADDRESS\n")); TI_DbgPrint(MIN_TRACE, ("QUERY_IP_HW_ADDRESS\n"));
Status = DispTdiQueryIpHwAddress(DeviceObject, Irp, IrpSp); Status = DispTdiQueryIpHwAddress(DeviceObject, Irp, IrpSp);
break; break;
default: default:
TI_DbgPrint(MIN_TRACE, ("Unknown IOCTL 0x%X\n", TI_DbgPrint(MIN_TRACE, ("Unknown IOCTL 0x%X\n",
IrpSp->Parameters.DeviceIoControl.IoControlCode)); IrpSp->Parameters.DeviceIoControl.IoControlCode));
Status = STATUS_NOT_IMPLEMENTED; Status = STATUS_NOT_IMPLEMENTED;
break; break;
}
} }
}
TI_DbgPrint(DEBUG_IRP, ("[TCPIP, TiDispatch] Leaving. Status = (0x%X).\n", Status)); TI_DbgPrint(DEBUG_IRP, ("[TCPIP, TiDispatch] Leaving. Status = (0x%X).\n", Status));
return IRPFinish( Irp, Status ); return IRPFinish( Irp, Status );
} }
@ -556,64 +556,64 @@ VOID NTAPI TiUnload(
#if DBG #if DBG
KIRQL OldIrql; KIRQL OldIrql;
TcpipAcquireSpinLock(&AddressFileListLock, &OldIrql); TcpipAcquireSpinLock(&AddressFileListLock, &OldIrql);
if (!IsListEmpty(&AddressFileListHead)) { if (!IsListEmpty(&AddressFileListHead)) {
TI_DbgPrint(MIN_TRACE, ("[TCPIP, TiUnload] Called. Open address file objects exists.\n")); TI_DbgPrint(MIN_TRACE, ("[TCPIP, TiUnload] Called. Open address file objects exists.\n"));
} }
TcpipReleaseSpinLock(&AddressFileListLock, OldIrql); TcpipReleaseSpinLock(&AddressFileListLock, OldIrql);
#endif #endif
/* Cancel timer */ /* Cancel timer */
KeCancelTimer(&IPTimer); KeCancelTimer(&IPTimer);
/* Unregister loopback adapter */ /* Unregister loopback adapter */
LoopUnregisterAdapter(NULL); LoopUnregisterAdapter(NULL);
/* Unregister protocol with NDIS */ /* Unregister protocol with NDIS */
LANUnregisterProtocol(); LANUnregisterProtocol();
/* Shutdown transport level protocol subsystems */ /* Shutdown transport level protocol subsystems */
TCPShutdown(); TCPShutdown();
UDPShutdown(); UDPShutdown();
RawIPShutdown(); RawIPShutdown();
ICMPShutdown(); ICMPShutdown();
/* Shutdown network level protocol subsystem */ /* Shutdown network level protocol subsystem */
IPShutdown(); IPShutdown();
/* Free NDIS buffer descriptors */ /* Free NDIS buffer descriptors */
if (GlobalBufferPool) if (GlobalBufferPool)
NdisFreeBufferPool(GlobalBufferPool); NdisFreeBufferPool(GlobalBufferPool);
/* Free NDIS packet descriptors */ /* Free NDIS packet descriptors */
if (GlobalPacketPool) if (GlobalPacketPool)
NdisFreePacketPool(GlobalPacketPool); NdisFreePacketPool(GlobalPacketPool);
/* Release all device objects */ /* Release all device objects */
if (TCPDeviceObject) if (TCPDeviceObject)
IoDeleteDevice(TCPDeviceObject); IoDeleteDevice(TCPDeviceObject);
if (UDPDeviceObject) if (UDPDeviceObject)
IoDeleteDevice(UDPDeviceObject); IoDeleteDevice(UDPDeviceObject);
if (RawIPDeviceObject) if (RawIPDeviceObject)
IoDeleteDevice(RawIPDeviceObject); IoDeleteDevice(RawIPDeviceObject);
if (IPDeviceObject) { if (IPDeviceObject) {
ChewShutdown(); ChewShutdown();
IoDeleteDevice(IPDeviceObject); IoDeleteDevice(IPDeviceObject);
} }
if (EntityList) if (EntityList)
ExFreePoolWithTag(EntityList, TDI_ENTITY_TAG); ExFreePoolWithTag(EntityList, TDI_ENTITY_TAG);
TI_DbgPrint(MAX_TRACE, ("[TCPIP, TiUnload] Leaving.\n")); TI_DbgPrint(MAX_TRACE, ("[TCPIP, TiUnload] Leaving.\n"));
} }
NTSTATUS NTAPI NTSTATUS NTAPI
DriverEntry( DriverEntry(
PDRIVER_OBJECT DriverObject, PDRIVER_OBJECT DriverObject,
PUNICODE_STRING RegistryPath) PUNICODE_STRING RegistryPath)
/* /*
* FUNCTION: Main driver entry point * FUNCTION: Main driver entry point
* ARGUMENTS: * ARGUMENTS:
@ -623,189 +623,189 @@ DriverEntry(
* Status of driver initialization * Status of driver initialization
*/ */
{ {
NTSTATUS Status; NTSTATUS Status;
UNICODE_STRING strIpDeviceName = RTL_CONSTANT_STRING(DD_IP_DEVICE_NAME); UNICODE_STRING strIpDeviceName = RTL_CONSTANT_STRING(DD_IP_DEVICE_NAME);
UNICODE_STRING strRawDeviceName = RTL_CONSTANT_STRING(DD_RAWIP_DEVICE_NAME); UNICODE_STRING strRawDeviceName = RTL_CONSTANT_STRING(DD_RAWIP_DEVICE_NAME);
UNICODE_STRING strUdpDeviceName = RTL_CONSTANT_STRING(DD_UDP_DEVICE_NAME); UNICODE_STRING strUdpDeviceName = RTL_CONSTANT_STRING(DD_UDP_DEVICE_NAME);
UNICODE_STRING strTcpDeviceName = RTL_CONSTANT_STRING(DD_TCP_DEVICE_NAME); UNICODE_STRING strTcpDeviceName = RTL_CONSTANT_STRING(DD_TCP_DEVICE_NAME);
UNICODE_STRING strNdisDeviceName = RTL_CONSTANT_STRING(TCPIP_PROTOCOL_NAME); UNICODE_STRING strNdisDeviceName = RTL_CONSTANT_STRING(TCPIP_PROTOCOL_NAME);
NDIS_STATUS NdisStatus; NDIS_STATUS NdisStatus;
LARGE_INTEGER DueTime; LARGE_INTEGER DueTime;
TI_DbgPrint(MAX_TRACE, ("[TCPIP, DriverEntry] Called\n")); TI_DbgPrint(MAX_TRACE, ("[TCPIP, DriverEntry] Called\n"));
/* TdiInitialize() ? */ /* TdiInitialize() ? */
/* FIXME: Create symbolic links in Win32 namespace */ /* FIXME: Create symbolic links in Win32 namespace */
/* Initialize our periodic timer and its associated DPC object. When the /* Initialize our periodic timer and its associated DPC object. When the
timer expires, the IPTimeout deferred procedure call (DPC) is queued */ timer expires, the IPTimeout deferred procedure call (DPC) is queued */
KeInitializeDpc(&IPTimeoutDpc, IPTimeoutDpcFn, NULL); KeInitializeDpc(&IPTimeoutDpc, IPTimeoutDpcFn, NULL);
KeInitializeTimer(&IPTimer); KeInitializeTimer(&IPTimer);
/* Create IP device object */ /* Create IP device object */
Status = IoCreateDevice(DriverObject, 0, &strIpDeviceName, Status = IoCreateDevice(DriverObject, 0, &strIpDeviceName,
FILE_DEVICE_NETWORK, 0, FALSE, &IPDeviceObject); FILE_DEVICE_NETWORK, 0, FALSE, &IPDeviceObject);
if (!NT_SUCCESS(Status)) { if (!NT_SUCCESS(Status)) {
TI_DbgPrint(MIN_TRACE, ("Failed to create IP device object. Status (0x%X).\n", Status)); TI_DbgPrint(MIN_TRACE, ("Failed to create IP device object. Status (0x%X).\n", Status));
TiUnload(DriverObject); TiUnload(DriverObject);
return Status; return Status;
} }
ChewInit( IPDeviceObject ); ChewInit( IPDeviceObject );
/* Create RawIP device object */ /* Create RawIP device object */
Status = IoCreateDevice(DriverObject, 0, &strRawDeviceName, Status = IoCreateDevice(DriverObject, 0, &strRawDeviceName,
FILE_DEVICE_NETWORK, 0, FALSE, &RawIPDeviceObject); FILE_DEVICE_NETWORK, 0, FALSE, &RawIPDeviceObject);
if (!NT_SUCCESS(Status)) { if (!NT_SUCCESS(Status)) {
TI_DbgPrint(MIN_TRACE, ("Failed to create RawIP device object. Status (0x%X).\n", Status)); TI_DbgPrint(MIN_TRACE, ("Failed to create RawIP device object. Status (0x%X).\n", Status));
TiUnload(DriverObject); TiUnload(DriverObject);
return Status; return Status;
} }
/* Create UDP device object */ /* Create UDP device object */
Status = IoCreateDevice(DriverObject, 0, &strUdpDeviceName, Status = IoCreateDevice(DriverObject, 0, &strUdpDeviceName,
FILE_DEVICE_NETWORK, 0, FALSE, &UDPDeviceObject); FILE_DEVICE_NETWORK, 0, FALSE, &UDPDeviceObject);
if (!NT_SUCCESS(Status)) { if (!NT_SUCCESS(Status)) {
TI_DbgPrint(MIN_TRACE, ("Failed to create UDP device object. Status (0x%X).\n", Status)); TI_DbgPrint(MIN_TRACE, ("Failed to create UDP device object. Status (0x%X).\n", Status));
TiUnload(DriverObject); TiUnload(DriverObject);
return Status; return Status;
} }
/* Create TCP device object */ /* Create TCP device object */
Status = IoCreateDevice(DriverObject, 0, &strTcpDeviceName, Status = IoCreateDevice(DriverObject, 0, &strTcpDeviceName,
FILE_DEVICE_NETWORK, 0, FALSE, &TCPDeviceObject); FILE_DEVICE_NETWORK, 0, FALSE, &TCPDeviceObject);
if (!NT_SUCCESS(Status)) { if (!NT_SUCCESS(Status)) {
TI_DbgPrint(MIN_TRACE, ("Failed to create TCP device object. Status (0x%X).\n", Status)); TI_DbgPrint(MIN_TRACE, ("Failed to create TCP device object. Status (0x%X).\n", Status));
TiUnload(DriverObject); TiUnload(DriverObject);
return Status; return Status;
} }
/* Setup network layer and transport layer entities */ /* Setup network layer and transport layer entities */
KeInitializeSpinLock(&EntityListLock); KeInitializeSpinLock(&EntityListLock);
EntityList = ExAllocatePoolWithTag(NonPagedPool, EntityList = ExAllocatePoolWithTag(NonPagedPool,
sizeof(TDIEntityID) * MAX_TDI_ENTITIES, sizeof(TDIEntityID) * MAX_TDI_ENTITIES,
TDI_ENTITY_TAG ); TDI_ENTITY_TAG );
if (!EntityList) { if (!EntityList) {
TI_DbgPrint(MIN_TRACE, ("Insufficient resources.\n")); TI_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
TiUnload(DriverObject); TiUnload(DriverObject);
return STATUS_INSUFFICIENT_RESOURCES; return STATUS_INSUFFICIENT_RESOURCES;
} }
EntityCount = 0; EntityCount = 0;
EntityMax = MAX_TDI_ENTITIES; EntityMax = MAX_TDI_ENTITIES;
/* Allocate NDIS packet descriptors */ /* Allocate NDIS packet descriptors */
NdisAllocatePacketPoolEx(&NdisStatus, &GlobalPacketPool, 500, 1500, sizeof(PACKET_CONTEXT)); NdisAllocatePacketPoolEx(&NdisStatus, &GlobalPacketPool, 500, 1500, sizeof(PACKET_CONTEXT));
if (NdisStatus != NDIS_STATUS_SUCCESS) { if (NdisStatus != NDIS_STATUS_SUCCESS) {
TiUnload(DriverObject); TiUnload(DriverObject);
return STATUS_INSUFFICIENT_RESOURCES; return STATUS_INSUFFICIENT_RESOURCES;
} }
/* Allocate NDIS buffer descriptors */ /* Allocate NDIS buffer descriptors */
NdisAllocateBufferPool(&NdisStatus, &GlobalBufferPool, 2000); NdisAllocateBufferPool(&NdisStatus, &GlobalBufferPool, 2000);
if (NdisStatus != NDIS_STATUS_SUCCESS) { if (NdisStatus != NDIS_STATUS_SUCCESS) {
TiUnload(DriverObject); TiUnload(DriverObject);
return STATUS_INSUFFICIENT_RESOURCES; return STATUS_INSUFFICIENT_RESOURCES;
} }
/* Initialize address file list and protecting spin lock */ /* Initialize address file list and protecting spin lock */
InitializeListHead(&AddressFileListHead); InitializeListHead(&AddressFileListHead);
KeInitializeSpinLock(&AddressFileListLock); KeInitializeSpinLock(&AddressFileListLock);
/* Initialize connection endpoint list and protecting spin lock */ /* Initialize connection endpoint list and protecting spin lock */
InitializeListHead(&ConnectionEndpointListHead); InitializeListHead(&ConnectionEndpointListHead);
KeInitializeSpinLock(&ConnectionEndpointListLock); KeInitializeSpinLock(&ConnectionEndpointListLock);
/* Initialize interface list and protecting spin lock */ /* Initialize interface list and protecting spin lock */
InitializeListHead(&InterfaceListHead); InitializeListHead(&InterfaceListHead);
KeInitializeSpinLock(&InterfaceListLock); KeInitializeSpinLock(&InterfaceListLock);
/* Initialize network level protocol subsystem */ /* Initialize network level protocol subsystem */
IPStartup(RegistryPath); IPStartup(RegistryPath);
/* Initialize transport level protocol subsystems */ /* Initialize transport level protocol subsystems */
Status = RawIPStartup(); Status = RawIPStartup();
if( !NT_SUCCESS(Status) ) { if( !NT_SUCCESS(Status) ) {
TiUnload(DriverObject); TiUnload(DriverObject);
return Status; return Status;
} }
Status = UDPStartup(); Status = UDPStartup();
if( !NT_SUCCESS(Status) ) { if( !NT_SUCCESS(Status) ) {
TiUnload(DriverObject); TiUnload(DriverObject);
return Status; return Status;
} }
Status = TCPStartup(); Status = TCPStartup();
if( !NT_SUCCESS(Status) ) { if( !NT_SUCCESS(Status) ) {
TiUnload(DriverObject); TiUnload(DriverObject);
return Status; return Status;
} }
Status = ICMPStartup(); Status = ICMPStartup();
if( !NT_SUCCESS(Status) ) { if( !NT_SUCCESS(Status) ) {
TiUnload(DriverObject); TiUnload(DriverObject);
return Status; return Status;
} }
/* Use direct I/O */ /* Use direct I/O */
IPDeviceObject->Flags |= DO_DIRECT_IO; IPDeviceObject->Flags |= DO_DIRECT_IO;
RawIPDeviceObject->Flags |= DO_DIRECT_IO; RawIPDeviceObject->Flags |= DO_DIRECT_IO;
UDPDeviceObject->Flags |= DO_DIRECT_IO; UDPDeviceObject->Flags |= DO_DIRECT_IO;
TCPDeviceObject->Flags |= DO_DIRECT_IO; TCPDeviceObject->Flags |= DO_DIRECT_IO;
/* Initialize the driver object with this driver's entry points */ /* Initialize the driver object with this driver's entry points */
DriverObject->MajorFunction[IRP_MJ_CREATE] = TiDispatchOpenClose; DriverObject->MajorFunction[IRP_MJ_CREATE] = TiDispatchOpenClose;
DriverObject->MajorFunction[IRP_MJ_CLOSE] = TiDispatchOpenClose; DriverObject->MajorFunction[IRP_MJ_CLOSE] = TiDispatchOpenClose;
DriverObject->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = TiDispatchInternal; DriverObject->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = TiDispatchInternal;
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = TiDispatch; DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = TiDispatch;
DriverObject->DriverUnload = TiUnload; DriverObject->DriverUnload = TiUnload;
/* Open loopback adapter */ /* Open loopback adapter */
Status = LoopRegisterAdapter(NULL, NULL); Status = LoopRegisterAdapter(NULL, NULL);
if (!NT_SUCCESS(Status)) { if (!NT_SUCCESS(Status)) {
TI_DbgPrint(MIN_TRACE, ("Failed to create loopback adapter. Status (0x%X).\n", Status)); TI_DbgPrint(MIN_TRACE, ("Failed to create loopback adapter. Status (0x%X).\n", Status));
TiUnload(DriverObject); TiUnload(DriverObject);
return Status; return Status;
} }
/* Register protocol with NDIS */ /* Register protocol with NDIS */
/* This used to be IP_DEVICE_NAME but the DDK says it has to match your entry in the SCM */ /* This used to be IP_DEVICE_NAME but the DDK says it has to match your entry in the SCM */
Status = LANRegisterProtocol(&strNdisDeviceName); Status = LANRegisterProtocol(&strNdisDeviceName);
if (!NT_SUCCESS(Status)) { if (!NT_SUCCESS(Status)) {
TI_DbgPrint(MIN_TRACE,("Failed to register protocol with NDIS; status 0x%x\n", Status)); TI_DbgPrint(MIN_TRACE,("Failed to register protocol with NDIS; status 0x%x\n", Status));
TiWriteErrorLog( TiWriteErrorLog(
DriverObject, DriverObject,
EVENT_TRANSPORT_REGISTER_FAILED, EVENT_TRANSPORT_REGISTER_FAILED,
TI_ERROR_DRIVERENTRY, TI_ERROR_DRIVERENTRY,
Status, Status,
NULL, NULL,
0, 0,
NULL); NULL);
TiUnload(DriverObject); TiUnload(DriverObject);
return Status; return Status;
} }
/* Start the periodic timer with an initial and periodic /* Start the periodic timer with an initial and periodic
relative expiration time of IP_TIMEOUT milliseconds */ relative expiration time of IP_TIMEOUT milliseconds */
DueTime.QuadPart = -(LONGLONG)IP_TIMEOUT * 10000; DueTime.QuadPart = -(LONGLONG)IP_TIMEOUT * 10000;
KeSetTimerEx(&IPTimer, DueTime, IP_TIMEOUT, &IPTimeoutDpc); KeSetTimerEx(&IPTimer, DueTime, IP_TIMEOUT, &IPTimeoutDpc);
TI_DbgPrint(MAX_TRACE, ("[TCPIP, DriverEntry] Finished\n")); TI_DbgPrint(MAX_TRACE, ("[TCPIP, DriverEntry] Finished\n"));
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
VOID NTAPI VOID NTAPI
IPAddInterface( IPAddInterface(
ULONG Unknown0, ULONG Unknown0,
ULONG Unknown1, ULONG Unknown1,
ULONG Unknown2, ULONG Unknown2,
ULONG Unknown3, ULONG Unknown3,
ULONG Unknown4) ULONG Unknown4)
{ {
UNIMPLEMENTED; UNIMPLEMENTED;
} }
@ -813,7 +813,7 @@ IPAddInterface(
VOID NTAPI VOID NTAPI
IPDelInterface( IPDelInterface(
ULONG Unknown0) ULONG Unknown0)
{ {
UNIMPLEMENTED; UNIMPLEMENTED;
} }
@ -821,8 +821,8 @@ IPDelInterface(
VOID NTAPI VOID NTAPI
LookupRoute( LookupRoute(
ULONG Unknown0, ULONG Unknown0,
ULONG Unknown1) ULONG Unknown1)
{ {
UNIMPLEMENTED; UNIMPLEMENTED;
} }