Author: cgutman
Date: Fri Jan 6 05:59:56 2012
New Revision: 54849
URL:
http://svn.reactos.org/svn/reactos?rev=54849&view=rev
Log:
[NDISUIO]
- Build fixes
Added:
branches/wlan-bringup/include/reactos/drivers/ndisuio/
branches/wlan-bringup/include/reactos/drivers/ndisuio/nuiouser.h (with props)
Modified:
branches/wlan-bringup/drivers/network/CMakeLists.txt
branches/wlan-bringup/drivers/network/directory.rbuild
branches/wlan-bringup/drivers/network/ndisuio/CMakeLists.txt
branches/wlan-bringup/drivers/network/ndisuio/createclose.c
branches/wlan-bringup/drivers/network/ndisuio/ioctl.c
branches/wlan-bringup/drivers/network/ndisuio/main.c
branches/wlan-bringup/drivers/network/ndisuio/misc.c
branches/wlan-bringup/drivers/network/ndisuio/ndisuio.h
branches/wlan-bringup/drivers/network/ndisuio/protocol.c
branches/wlan-bringup/drivers/network/ndisuio/readwrite.c
Modified: branches/wlan-bringup/drivers/network/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/drivers/network/CM…
==============================================================================
--- branches/wlan-bringup/drivers/network/CMakeLists.txt [iso-8859-1] (original)
+++ branches/wlan-bringup/drivers/network/CMakeLists.txt [iso-8859-1] Fri Jan 6 05:59:56
2012
@@ -2,5 +2,6 @@
add_subdirectory(afd)
add_subdirectory(dd)
add_subdirectory(ndis)
+add_subdirectory(ndisuio)
add_subdirectory(tcpip)
add_subdirectory(tdi)
Modified: branches/wlan-bringup/drivers/network/directory.rbuild
URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/drivers/network/di…
==============================================================================
--- branches/wlan-bringup/drivers/network/directory.rbuild [iso-8859-1] (original)
+++ branches/wlan-bringup/drivers/network/directory.rbuild [iso-8859-1] Fri Jan 6
05:59:56 2012
@@ -10,6 +10,9 @@
<directory name="ndis">
<xi:include href="ndis/ndis.rbuild" />
</directory>
+<directory name="ndisuio">
+ <xi:include href="ndisuio/ndisuio.rbuild" />
+</directory>
<directory name="tcpip">
<xi:include href="tcpip/tcpip.rbuild" />
</directory>
Modified: branches/wlan-bringup/drivers/network/ndisuio/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/drivers/network/nd…
==============================================================================
--- branches/wlan-bringup/drivers/network/ndisuio/CMakeLists.txt [iso-8859-1] (original)
+++ branches/wlan-bringup/drivers/network/ndisuio/CMakeLists.txt [iso-8859-1] Fri Jan 6
05:59:56 2012
@@ -1,6 +1,10 @@
add_definitions(
-DNDIS50
-D_NTDRIVER_)
+
+include_directories(
+ BEFORE include
+ ${REACTOS_SOURCE_DIR}/include/reactos/drivers/ndisuio)
list(APPEND SOURCE
createclose.c
Modified: branches/wlan-bringup/drivers/network/ndisuio/createclose.c
URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/drivers/network/nd…
==============================================================================
--- branches/wlan-bringup/drivers/network/ndisuio/createclose.c [iso-8859-1] (original)
+++ branches/wlan-bringup/drivers/network/ndisuio/createclose.c [iso-8859-1] Fri Jan 6
05:59:56 2012
@@ -41,7 +41,6 @@
PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation(Irp);
PNDISUIO_ADAPTER_CONTEXT AdapterContext = IrpSp->FileObject->FsContext;
PNDISUIO_OPEN_ENTRY OpenEntry = IrpSp->FileObject->FsContext2;
- KIRQL OldIrql;
ASSERT(DeviceObject == GlobalDeviceObject);
Modified: branches/wlan-bringup/drivers/network/ndisuio/ioctl.c
URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/drivers/network/nd…
==============================================================================
--- branches/wlan-bringup/drivers/network/ndisuio/ioctl.c [iso-8859-1] (original)
+++ branches/wlan-bringup/drivers/network/ndisuio/ioctl.c [iso-8859-1] Fri Jan 6 05:59:56
2012
@@ -11,7 +11,7 @@
#define NDEBUG
#include <debug.h>
-
+static
NTSTATUS
WaitForBind(PIRP Irp, PIO_STACK_LOCATION IrpSp)
{
@@ -28,6 +28,7 @@
return STATUS_SUCCESS;
}
+static
NTSTATUS
QueryBinding(PIRP Irp, PIO_STACK_LOCATION IrpSp)
{
@@ -96,6 +97,8 @@
return Status;
}
+#if 0
+static
NTSTATUS
CancelPacketRead(PIRP Irp, PIO_STACK_LOCATION IrpSp)
{
@@ -129,13 +132,15 @@
return Status;
}
-
+#endif
+
+static
NTSTATUS
SetAdapterOid(PIRP Irp, PIO_STACK_LOCATION IrpSp)
{
PNDISUIO_ADAPTER_CONTEXT AdapterContext = IrpSp->FileObject->FsContext;
PNDISUIO_SET_OID SetOidRequest;
- NDIS_REQUEST NdisRequest;
+ NDIS_REQUEST Request;
ULONG RequestLength;
NDIS_STATUS Status;
@@ -143,18 +148,18 @@
SetOidRequest = IrpSp->Parameters.DeviceIoControl.Type3InputBuffer;
RequestLength = IrpSp->Parameters.DeviceIoControl.InputBufferLength;
- if (QueryOidRequest && RequestLength >= sizeof(NDIS_OID))
+ if (SetOidRequest && RequestLength >= sizeof(NDIS_OID))
{
/* Setup the NDIS request */
- NdisRequest.RequestType = NdisRequestSetInformation;
- NdisRequest.Oid = SetOidRequest->Oid;
- NdisRequest.InformationBuffer = SetOidRequest->Data;
- NdisRequest.InformationBufferLength = RequestLength - sizeof(NDIS_OID);
+ Request.RequestType = NdisRequestSetInformation;
+ Request.DATA.SET_INFORMATION.Oid = SetOidRequest->Oid;
+ Request.DATA.SET_INFORMATION.InformationBuffer = SetOidRequest->Data;
+ Request.DATA.SET_INFORMATION.InformationBufferLength = RequestLength -
sizeof(NDIS_OID);
/* Dispatch the request */
NdisRequest(&Status,
AdapterContext->BindingHandle,
- &NdisRequest);
+ &Request);
/* Wait for the request */
if (Status == NDIS_STATUS_PENDING)
@@ -168,7 +173,7 @@
}
/* Return the bytes read */
- if (NT_SUCCESS(Status)) Irp->IoStatus.Information = NdisRequest.BytesRead;
+ if (NT_SUCCESS(Status)) Irp->IoStatus.Information =
Request.DATA.SET_INFORMATION.BytesRead;
}
else
{
@@ -183,12 +188,13 @@
return Status;
}
+static
NTSTATUS
QueryAdapterOid(PIRP Irp, PIO_STACK_LOCATION IrpSp)
{
PNDISUIO_ADAPTER_CONTEXT AdapterContext = IrpSp->FileObject->FsContext;
PNDISUIO_QUERY_OID QueryOidRequest;
- NDIS_REQUEST NdisRequest;
+ NDIS_REQUEST Request;
ULONG RequestLength;
NDIS_STATUS Status;
@@ -199,15 +205,15 @@
if (QueryOidRequest && RequestLength >= sizeof(NDIS_OID))
{
/* Setup the NDIS request */
- NdisRequest.RequestType = NdisRequestQueryInformation;
- NdisRequest.Oid = QueryOidRequest->Oid;
- NdisRequest.InformationBuffer = QueryOidRequest->Data;
- NdisRequest.InformationBufferLength = RequestLength - sizeof(NDIS_OID);
+ Request.RequestType = NdisRequestQueryInformation;
+ Request.DATA.QUERY_INFORMATION.Oid = QueryOidRequest->Oid;
+ Request.DATA.QUERY_INFORMATION.InformationBuffer = QueryOidRequest->Data;
+ Request.DATA.QUERY_INFORMATION.InformationBufferLength = RequestLength -
sizeof(NDIS_OID);
/* Dispatch the request */
NdisRequest(&Status,
AdapterContext->BindingHandle,
- &NdisRequest);
+ &Request);
/* Wait for the request */
if (Status == NDIS_STATUS_PENDING)
@@ -221,7 +227,7 @@
}
/* Return the bytes written */
- if (NT_SUCCESS(Status)) Irp->IoStatus.Information = NdisRequest.BytesWritten;
+ if (NT_SUCCESS(Status)) Irp->IoStatus.Information =
Request.DATA.QUERY_INFORMATION.BytesWritten;
}
else
{
@@ -236,6 +242,7 @@
return Status;
}
+static
NTSTATUS
OpenDeviceReadWrite(PIRP Irp, PIO_STACK_LOCATION IrpSp)
{
@@ -307,7 +314,7 @@
{
/* Remove the reference we added */
KeReleaseSpinLock(&AdapterContext->Spinlock, OldIrql);
- DereferenceAdapterContext(AdapterContext, NULL);
+ DereferenceAdapterContextWithOpenEntry(AdapterContext, NULL);
Status = STATUS_NO_MEMORY;
}
}
@@ -326,6 +333,8 @@
return Status;
}
+#if 0
+static
NTSTATUS
OpenDeviceWrite(PIRP Irp, PIO_STACK_LOCATION IrpSp)
{
@@ -404,6 +413,7 @@
return Status;
}
+#endif
NTSTATUS
NTAPI
@@ -420,10 +430,10 @@
{
case IOCTL_NDISUIO_OPEN_DEVICE:
return OpenDeviceReadWrite(Irp, IrpSp);
-
+#if 0
case IOCTL_NDISUIO_OPEN_WRITE_DEVICE:
return OpenDeviceWrite(Irp, IrpSp);
-
+#endif
case IOCTL_NDISUIO_BIND_WAIT:
return WaitForBind(Irp, IrpSp);
@@ -461,8 +471,10 @@
switch (IrpSp->Parameters.DeviceIoControl.IoControlCode)
{
+#if 0
case IOCTL_CANCEL_READ:
return CancelPacketRead(Irp, IrpSp);
+#endif
case IOCTL_NDISUIO_QUERY_OID_VALUE:
return QueryAdapterOid(Irp, IrpSp);
@@ -472,7 +484,7 @@
Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED;
Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
- break;
+ return STATUS_NOT_IMPLEMENTED;
}
}
break;
Modified: branches/wlan-bringup/drivers/network/ndisuio/main.c
URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/drivers/network/nd…
==============================================================================
--- branches/wlan-bringup/drivers/network/ndisuio/main.c [iso-8859-1] (original)
+++ branches/wlan-bringup/drivers/network/ndisuio/main.c [iso-8859-1] Fri Jan 6 05:59:56
2012
@@ -13,12 +13,16 @@
PDEVICE_OBJECT GlobalDeviceObject;
NDIS_HANDLE GlobalProtocolHandle;
+KSPIN_LOCK GlobalAdapterListLock;
+LIST_ENTRY GlobalAdapterList;
+NDIS_HANDLE GlobalPacketPoolHandle;
+NDIS_HANDLE GlobalBufferPoolHandle;
+
+NDIS_STRING ProtocolName = RTL_CONSTANT_STRING(L"NDISUIO");
VOID NTAPI NduUnload(PDRIVER_OBJECT DriverObject)
-{
- IoDeleteDevice(GlobalDeviceObject);
-
- DPRINT("NDISUIO: Unloaded\n");
+{
+ DPRINT1("NDISUIO: Unloaded\n");
}
NTSTATUS
@@ -26,8 +30,10 @@
DriverEntry(PDRIVER_OBJECT DriverObject,
PUNICODE_STRING RegistryPath)
{
- NTSTATUS Status;
+ NDIS_STATUS Status;
NDIS_PROTOCOL_CHARACTERISTICS Chars;
+ UNICODE_STRING NtDeviceName = RTL_CONSTANT_STRING(NDISUIO_DEVICE_NAME_NT);
+ UNICODE_STRING DosDeviceName = RTL_CONSTANT_STRING(NDISUIO_DEVICE_NAME_DOS);
/* Setup dispatch functions */
DriverObject->MajorFunction[IRP_MJ_CREATE] = NduDispatchCreate;
@@ -36,13 +42,17 @@
DriverObject->MajorFunction[IRP_MJ_READ] = NduDispatchRead;
DriverObject->MajorFunction[IRP_MJ_WRITE] = NduDispatchWrite;
DriverObject->DriverUnload = NduUnload;
+
+ /* Setup global state */
+ InitializeListHead(&GlobalAdapterList);
+ KeInitializeSpinLock(&GlobalAdapterListLock);
/* Create the NDISUIO device object */
Status = IoCreateDevice(DriverObject,
0,
- NULL, // FIXME
- NDISUIO_DEVICE_NAME,
+ &NtDeviceName,
FILE_DEVICE_SECURE_OPEN,
+ 0,
FALSE,
&GlobalDeviceObject);
if (!NT_SUCCESS(Status))
@@ -51,6 +61,41 @@
return Status;
}
+ /* Create a symbolic link into the DOS devices namespace */
+ Status = IoCreateSymbolicLink(&DosDeviceName, &NtDeviceName);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("Failed to create symbolic link with status 0x%x\n", Status);
+ IoDeleteDevice(GlobalDeviceObject);
+ return Status;
+ }
+
+ /* Create the buffer pool */
+ NdisAllocateBufferPool(&Status,
+ &GlobalBufferPoolHandle,
+ 100);
+ if (Status != NDIS_STATUS_SUCCESS)
+ {
+ DPRINT1("Failed to allocate buffer pool with status 0x%x\n", Status);
+ IoDeleteSymbolicLink(&DosDeviceName);
+ IoDeleteDevice(GlobalDeviceObject);
+ return Status;
+ }
+
+ /* Create the packet pool */
+ NdisAllocatePacketPool(&Status,
+ &GlobalPacketPoolHandle,
+ 50,
+ 0);
+ if (Status != NDIS_STATUS_SUCCESS)
+ {
+ DPRINT1("Failed to allocate packet pool with status 0x%x\n", Status);
+ NdisFreeBufferPool(GlobalBufferPoolHandle);
+ IoDeleteSymbolicLink(&DosDeviceName);
+ IoDeleteDevice(GlobalDeviceObject);
+ return Status;
+ }
+
/* Register the protocol with NDIS */
RtlZeroMemory(&Chars, sizeof(Chars));
Chars.MajorNdisVersion = NDIS_MAJOR_VERSION;
@@ -62,14 +107,12 @@
Chars.ResetCompleteHandler = NduResetComplete;
Chars.RequestCompleteHandler = NduRequestComplete;
Chars.ReceiveHandler = NduReceive;
- Chars.ReceiveComplete = NduReceiveComplete;
+ Chars.ReceiveCompleteHandler = NduReceiveComplete;
Chars.StatusHandler = NduStatus;
Chars.StatusCompleteHandler = NduStatusComplete;
- Chars.Name = NULL; //FIXME
- Chars.ReceivePacketHandler = NULL; //NduReceivePacket
+ Chars.Name = ProtocolName;
Chars.BindAdapterHandler = NduBindAdapter;
Chars.UnbindAdapterHandler = NduUnbindAdapter;
- Chars.PnPEventHandler = NduPnPEvent;
NdisRegisterProtocol(&Status,
&GlobalProtocolHandle,
@@ -78,11 +121,14 @@
if (Status != NDIS_STATUS_SUCCESS)
{
DPRINT1("Failed to register protocol with status 0x%x\n", Status);
+ NdisFreePacketPool(GlobalPacketPoolHandle);
+ NdisFreeBufferPool(GlobalBufferPoolHandle);
+ IoDeleteSymbolicLink(&DosDeviceName);
IoDeleteDevice(GlobalDeviceObject);
return Status;
}
- DPRINT("NDISUIO: Loaded\n");
+ DPRINT1("NDISUIO: Loaded\n");
return STATUS_SUCCESS;
}
Modified: branches/wlan-bringup/drivers/network/ndisuio/misc.c
URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/drivers/network/nd…
==============================================================================
--- branches/wlan-bringup/drivers/network/ndisuio/misc.c [iso-8859-1] (original)
+++ branches/wlan-bringup/drivers/network/ndisuio/misc.c [iso-8859-1] Fri Jan 6 05:59:56
2012
@@ -15,13 +15,14 @@
AllocateAndChainBuffer(PNDIS_PACKET Packet, PVOID Buffer, ULONG BufferSize, BOOLEAN
Front)
{
NDIS_STATUS Status;
+ PNDIS_BUFFER NdisBuffer;
/* Allocate the NDIS buffer mapping the pool */
NdisAllocateBuffer(&Status,
- &Buffer,
+ &NdisBuffer,
GlobalBufferPoolHandle,
Buffer,
- Length);
+ BufferSize);
if (Status != NDIS_STATUS_SUCCESS)
{
DPRINT1("No free buffer descriptors\n");
@@ -31,12 +32,12 @@
if (Front)
{
/* Chain the buffer to front */
- NdisChainBufferAtFront(Packet, Buffer);
+ NdisChainBufferAtFront(Packet, NdisBuffer);
}
else
{
/* Chain the buffer to back */
- NdisChainBufferAtBack(Packet, Buffer);
+ NdisChainBufferAtBack(Packet, NdisBuffer);
}
/* Return success */
Modified: branches/wlan-bringup/drivers/network/ndisuio/ndisuio.h
URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/drivers/network/nd…
==============================================================================
--- branches/wlan-bringup/drivers/network/ndisuio/ndisuio.h [iso-8859-1] (original)
+++ branches/wlan-bringup/drivers/network/ndisuio/ndisuio.h [iso-8859-1] Fri Jan 6
05:59:56 2012
@@ -9,11 +9,16 @@
#include <wdm.h>
#include <ndis.h>
-//#include <nuiouser.h>
-#include <ndistapi.h>
-#include <ndisguid.h>
-
-struct _NDISUIO_ADAPTER_CONTEXT
+#include <nuiouser.h>
+
+extern PDEVICE_OBJECT GlobalDeviceObject;
+extern NDIS_HANDLE GlobalProtocolHandle;
+extern LIST_ENTRY GlobalAdapterList;
+extern KSPIN_LOCK GlobalAdapterListLock;
+extern NDIS_HANDLE GlobalPacketPoolHandle;
+extern NDIS_HANDLE GlobalBufferPoolHandle;
+
+typedef struct _NDISUIO_ADAPTER_CONTEXT
{
/* Asynchronous completion */
NDIS_STATUS AsyncStatus;
@@ -30,6 +35,9 @@
LIST_ENTRY PacketList;
KEVENT PacketReadEvent;
+ /* Device name */
+ UNICODE_STRING DeviceName;
+
/* Global list entry */
LIST_ENTRY ListEntry;
@@ -37,7 +45,7 @@
KSPIN_LOCK Spinlock;
} NDISUIO_ADAPTER_CONTEXT, *PNDISUIO_ADAPTER_CONTEXT;
-struct _NDISUIO_OPEN_ENTRY
+typedef struct _NDISUIO_OPEN_ENTRY
{
/* File object */
PFILE_OBJECT FileObject;
@@ -49,7 +57,7 @@
LIST_ENTRY ListEntry;
} NDISUIO_OPEN_ENTRY, *PNDISUIO_OPEN_ENTRY;
-struct _NDISUIO_PACKET_ENTRY
+typedef struct _NDISUIO_PACKET_ENTRY
{
/* Length of data at the end of the struct */
ULONG PacketLength;
@@ -62,7 +70,134 @@
} NDISUIO_PACKET_ENTRY, *PNDISUIO_PACKET_ENTRY;
/* NDIS version info */
-#define NDIS_MAJOR_VERISON 5
+#define NDIS_MAJOR_VERSION 5
#define NDIS_MINOR_VERSION 0
+/* createclose.c */
+NTSTATUS
+NTAPI
+NduDispatchCreate(PDEVICE_OBJECT DeviceObject,
+ PIRP Irp);
+
+NTSTATUS
+NTAPI
+NduDispatchClose(PDEVICE_OBJECT DeviceObject,
+ PIRP Irp);
+
+/* ioctl.c */
+NTSTATUS
+NTAPI
+NduDispatchDeviceControl(PDEVICE_OBJECT DeviceObject,
+ PIRP Irp);
+
+/* misc.c */
+NDIS_STATUS
+AllocateAndChainBuffer(PNDIS_PACKET Packet,
+ PVOID Buffer,
+ ULONG BufferSize,
+ BOOLEAN Front);
+
+PNDIS_PACKET
+CreatePacketFromPoolBuffer(PVOID Buffer,
+ ULONG BufferSize);
+
+VOID
+CleanupAndFreePacket(PNDIS_PACKET Packet,
+ BOOLEAN FreePool);
+
+PNDISUIO_ADAPTER_CONTEXT
+FindAdapterContextByName(PNDIS_STRING DeviceName);
+
+VOID
+ReferenceAdapterContext(PNDISUIO_ADAPTER_CONTEXT AdapterContext);
+
+VOID
+DereferenceAdapterContextWithOpenEntry(PNDISUIO_ADAPTER_CONTEXT AdapterContext,
+ PNDISUIO_OPEN_ENTRY OpenEntry);
+
+/* protocol.c */
+VOID
+NTAPI
+NduOpenAdapterComplete(NDIS_HANDLE ProtocolBindingContext,
+ NDIS_STATUS Status,
+ NDIS_STATUS OpenStatus);
+
+VOID
+NTAPI
+NduCloseAdapterComplete(NDIS_HANDLE ProtocolBindingContext,
+ NDIS_STATUS Status);
+
+VOID
+NTAPI
+NduSendComplete(NDIS_HANDLE ProtocolBindingContext,
+ PNDIS_PACKET Packet,
+ NDIS_STATUS Status);
+
+VOID
+NTAPI
+NduTransferDataComplete(NDIS_HANDLE ProtocolBindingContext,
+ PNDIS_PACKET Packet,
+ NDIS_STATUS Status,
+ UINT BytesTransferred);
+
+VOID
+NTAPI
+NduResetComplete(NDIS_HANDLE ProtocolBindingContext,
+ NDIS_STATUS Status);
+
+VOID
+NTAPI
+NduRequestComplete(NDIS_HANDLE ProtocolBindingContext,
+ PNDIS_REQUEST NdisRequest,
+ NDIS_STATUS Status);
+
+NDIS_STATUS
+NTAPI
+NduReceive(NDIS_HANDLE ProtocolBindingContext,
+ NDIS_HANDLE MacReceiveContext,
+ PVOID HeaderBuffer,
+ UINT HeaderBufferSize,
+ PVOID LookAheadBuffer,
+ UINT LookaheadBufferSize,
+ UINT PacketSize);
+
+VOID
+NTAPI
+NduReceiveComplete(NDIS_HANDLE ProtocolBindingContext);
+
+VOID
+NTAPI
+NduStatus(NDIS_HANDLE ProtocolBindingContext,
+ NDIS_STATUS GeneralStatus,
+ PVOID StatusBuffer,
+ UINT StatusBufferSize);
+
+VOID
+NTAPI
+NduStatusComplete(NDIS_HANDLE ProtocolBindingContext);
+
+VOID
+NTAPI
+NduBindAdapter(PNDIS_STATUS Status,
+ NDIS_HANDLE BindContext,
+ PNDIS_STRING DeviceName,
+ PVOID SystemSpecific1,
+ PVOID SystemSpecific2);
+
+VOID
+NTAPI
+NduUnbindAdapter(PNDIS_STATUS Status,
+ NDIS_HANDLE ProtocolBindingContext,
+ NDIS_HANDLE UnbindContext);
+
+/* readwrite.c */
+NTSTATUS
+NTAPI
+NduDispatchRead(PDEVICE_OBJECT DeviceObject,
+ PIRP Irp);
+
+NTSTATUS
+NTAPI
+NduDispatchWrite(PDEVICE_OBJECT DeviceObject,
+ PIRP Irp);
#endif /* __NDISUIO_H */
Modified: branches/wlan-bringup/drivers/network/ndisuio/protocol.c
URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/drivers/network/nd…
==============================================================================
--- branches/wlan-bringup/drivers/network/ndisuio/protocol.c [iso-8859-1] (original)
+++ branches/wlan-bringup/drivers/network/ndisuio/protocol.c [iso-8859-1] Fri Jan 6
05:59:56 2012
@@ -113,10 +113,11 @@
UINT PacketSize)
{
PNDISUIO_ADAPTER_CONTEXT AdapterContext = ProtocolBindingContext;
+ PNDISUIO_PACKET_ENTRY PacketEntry;
PVOID PacketBuffer;
PNDIS_PACKET Packet;
NDIS_STATUS Status;
- ULONG BytesTransferred;
+ UINT BytesTransferred;
/* Allocate a buffer to hold the packet data and header */
PacketBuffer = ExAllocatePool(NonPagedPool, PacketSize);
@@ -138,6 +139,7 @@
MacReceiveContext,
0,
PacketSize,
+ Packet,
&BytesTransferred);
if (Status == NDIS_STATUS_PENDING)
{
@@ -214,12 +216,14 @@
/* FIXME: Implement status tracking */
}
+static
NDIS_STATUS
UnbindAdapterByContext(PNDISUIO_ADAPTER_CONTEXT AdapterContext)
{
KIRQL OldIrql;
PLIST_ENTRY CurrentOpenEntry;
PNDISUIO_OPEN_ENTRY OpenEntry;
+ NDIS_STATUS Status;
/* Remove the adapter context from the global list */
KeAcquireSpinLock(&GlobalAdapterListLock, &OldIrql);
@@ -255,27 +259,29 @@
ASSERT(AdapterContext->OpenCount == 0);
/* Send the close request */
- NdisCloseAdapter(Status,
+ NdisCloseAdapter(&Status,
AdapterContext->BindingHandle);
/* Wait for a pending close */
- if (*Status == NDIS_STATUS_PENDING)
+ if (Status == NDIS_STATUS_PENDING)
{
KeWaitForSingleObject(&AdapterContext->AsyncEvent,
Executive,
KernelMode,
FALSE,
NULL);
- *Status = AdapterContext->AsyncStatus;
+ Status = AdapterContext->AsyncStatus;
}
/* Free the context */
ExFreePool(AdapterContext);
-}
-
-
+
+ return Status;
+}
+
+static
NDIS_STATUS
-BindAdapterByName(PNDIS_STRING DeviceName, PNDISUIO_ADAPTER_CONTEXT *Context)
+BindAdapterByName(PNDIS_STRING DeviceName)
{
NDIS_STATUS OpenErrorStatus;
PNDISUIO_ADAPTER_CONTEXT AdapterContext;
@@ -298,6 +304,17 @@
InitializeListHead(&AdapterContext->OpenEntryList);
AdapterContext->OpenCount = 0;
+ AdapterContext->DeviceName.Length =
+ AdapterContext->DeviceName.MaximumLength = DeviceName->Length;
+ AdapterContext->DeviceName.Buffer = ExAllocatePool(NonPagedPool,
DeviceName->Length);
+ if (!AdapterContext->DeviceName.Buffer)
+ {
+ ExFreePool(AdapterContext);
+ return NDIS_STATUS_RESOURCES;
+ }
+
+ RtlCopyMemory(AdapterContext->DeviceName.Buffer, DeviceName->Buffer,
DeviceName->Length);
+
/* Send the open request */
NdisOpenAdapter(&Status,
&OpenErrorStatus,
@@ -325,18 +342,16 @@
/* Check the final status */
if (Status != NDIS_STATUS_SUCCESS)
{
- DPRINT1("Failed to open adapter for bind with status 0x%x\n",
*Status);
+ DPRINT1("Failed to open adapter for bind with status 0x%x\n", Status);
ExFreePool(AdapterContext);
- return;
+ return Status;
}
/* Add the adapter context to the global list */
ExInterlockedInsertTailList(&GlobalAdapterList,
&AdapterContext->ListEntry,
&GlobalAdapterListLock);
-
- /* Return the context */
- *Context = AdapterContext;
+
return STATUS_SUCCESS;
}
Modified: branches/wlan-bringup/drivers/network/ndisuio/readwrite.c
URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/drivers/network/nd…
==============================================================================
--- branches/wlan-bringup/drivers/network/ndisuio/readwrite.c [iso-8859-1] (original)
+++ branches/wlan-bringup/drivers/network/ndisuio/readwrite.c [iso-8859-1] Fri Jan 6
05:59:56 2012
@@ -11,10 +11,12 @@
#define NDEBUG
#include <debug.h>
+static
VOID
NTAPI
ReadIrpCancel(PDEVICE_OBJECT DeviceObject, PIRP Irp)
{
+ PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation(Irp);
PNDISUIO_ADAPTER_CONTEXT AdapterContext = IrpSp->FileObject->FsContext;
PNDISUIO_PACKET_ENTRY PacketEntry;
@@ -22,7 +24,7 @@
IoReleaseCancelSpinLock(Irp->CancelIrql);
/* Indicate a 0-byte packet on the queue to cancel the read */
- PacketEntry = ExAllocatePool(PagedPool, sizeof(NDISUIO_PACKET_ENTRY));
+ PacketEntry = ExAllocatePool(NonPagedPool, sizeof(NDISUIO_PACKET_ENTRY));
if (PacketEntry)
{
PacketEntry->PacketLength = 0;
@@ -131,7 +133,7 @@
/* Copy the packet */
RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer,
- &PacketEntry->PacketBuffer[0],
+ &PacketEntry->PacketData[0],
BytesCopied);
/* Free the packet entry */
@@ -189,7 +191,7 @@
if (Status == NDIS_STATUS_SUCCESS)
BytesCopied = IrpSp->Parameters.Write.Length;
- CleanupAndFreePacket(Packet);
+ CleanupAndFreePacket(Packet, TRUE);
}
else
{
Added: branches/wlan-bringup/include/reactos/drivers/ndisuio/nuiouser.h
URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/include/reactos/dr…
==============================================================================
--- branches/wlan-bringup/include/reactos/drivers/ndisuio/nuiouser.h (added)
+++ branches/wlan-bringup/include/reactos/drivers/ndisuio/nuiouser.h [iso-8859-1] Fri Jan
6 05:59:56 2012
@@ -1,0 +1,59 @@
+#ifndef __NUIOUSER_H
+#define __NUIOUSER_H
+
+/* Device names (NT and DOS style) */
+#define NDISUIO_DEVICE_NAME_NT L"\\Device\\Ndisuio"
+#define NDISUIO_DEVICE_NAME_DOS L"\\DosDevices\\Ndisuio"
+
+/* Device name for user apps */
+#define NDISUIO_DEVICE_NAME L"\\\\.\\\\Ndisuio"
+
+/* Links a file handle with a bound NIC */
+#define IOCTL_NDISUIO_OPEN_DEVICE \
+ CTL_CODE(FILE_DEVICE_NETWORK, 0x200, METHOD_BUFFERED, FILE_ANY_ACCESS)
+
+/* Queries an OID for the bound NIC */
+#define IOCTL_NDISUIO_QUERY_OID_VALUE \
+ CTL_CODE(FILE_DEVICE_NETWORK, 0x201, METHOD_BUFFERED, FILE_ANY_ACCESS)
+
+#define IOCTL_NDISUIO_SET_ETHER_TYPE \
+ CTL_CODE(FILE_DEVICE_NETWORK, 0x202, METHOD_BUFFERED, FILE_ANY_ACCESS)
+
+/* Queries binding information during enumeration */
+#define IOCTL_NDISUIO_QUERY_BINDING \
+ CTL_CODE(FILE_DEVICE_NETWORK, 0x203, METHOD_BUFFERED, FILE_ANY_ACCESS)
+
+/* Waits for any pending bindings */
+#define IOCTL_NDISUIO_BIND_WAIT \
+ CTL_CODE(FILE_DEVICE_NETWORK, 0x204, METHOD_BUFFERED, FILE_ANY_ACCESS)
+
+/* Sets an OID for a bound NIC */
+#define IOCTL_NDISUIO_SET_OID_VALUE \
+ CTL_CODE(FILE_DEVICE_NETWORK, 0x205, METHOD_BUFFERED, FILE_ANY_ACCESS)
+
+/* Passed as a parameter to IOCTL_NDISUIO_QUERY_OID_VALUE */
+typedef struct _NDISUIO_QUERY_OID
+{
+ NDIS_OID Oid;
+ UCHAR Data[sizeof(ULONG)];
+} NDISUIO_QUERY_OID, *PNDISUIO_QUERY_OID;
+
+/* Passed as a parameter to IOCTL_NDISUIO_SET_OID_VALUE */
+typedef struct _NDISUIO_SET_OID
+{
+ NDIS_OID Oid;
+ UCHAR Data[sizeof(ULONG)];
+} NDISUIO_SET_OID, *PNDISUIO_SET_OID;
+
+/* Passed as a parameter to IOCTL_NDISUIO_QUERY_BINDING */
+typedef struct _NDISUIO_QUERY_BINDING
+{
+ ULONG BindingIndex;
+ ULONG DeviceNameOffset;
+ ULONG DeviceNameLength;
+ ULONG DeviceDescrOffset;
+ ULONG DeviceDescrLength;
+} NDISUIO_QUERY_BINDING, *PNDISUIO_QUERY_BINDING;
+
+#endif
+
Propchange: branches/wlan-bringup/include/reactos/drivers/ndisuio/nuiouser.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: branches/wlan-bringup/include/reactos/drivers/ndisuio/nuiouser.h
------------------------------------------------------------------------------
svn:executable = *