ReactOS  0.4.15-dev-1201-gb2cf5a4
protocol.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS NDIS User I/O driver
4  * FILE: protocol.c
5  * PURPOSE: Protocol stuff
6  * PROGRAMMERS: Cameron Gutman (cameron.gutman@reactos.org)
7  */
8 
9 #include "ndisuio.h"
10 
11 #define NDEBUG
12 #include <debug.h>
13 
14 VOID
15 NTAPI
19 {
21 
22  DPRINT("Asynchronous adapter open completed\n");
23 
24  /* Store the final status and signal the event */
25  AdapterContext->AsyncStatus = Status;
26  KeSetEvent(&AdapterContext->AsyncEvent, IO_NO_INCREMENT, FALSE);
27 }
28 
29 VOID
30 NTAPI
33 {
35 
36  DPRINT("Asynchronous adapter close completed\n");
37 
38  /* Store the final status and signal the event */
39  AdapterContext->AsyncStatus = Status;
40  KeSetEvent(&AdapterContext->AsyncEvent, IO_NO_INCREMENT, FALSE);
41 }
42 
44 NTAPI
47 {
49 
50  DPRINT("NetPnPEvent\n");
51 
52  switch (NetPnPEvent->NetEvent)
53  {
55  /* Nothing to do */
56  DPRINT1("NetPnPEvent: QueryRemoveDevice\n");
57  return NDIS_STATUS_SUCCESS;
58 
59  case NetEventSetPower:
60  ASSERT(NetPnPEvent->BufferLength >= sizeof(*PowerState));
61 
62  PowerState = NetPnPEvent->Buffer;
63  switch (*PowerState)
64  {
65  case NdisDeviceStateD0:
66  DPRINT1("NetPnPEvent: SetPower D0\n");
67  return NDIS_STATUS_SUCCESS;
68 
69  default:
70  DPRINT1("NetPnPEvent: SetPower state %d not supported\n", *PowerState);
71  return NDIS_STATUS_FAILURE;
72  }
73 
74  case NetEventQueryPower:
75  DPRINT1("NetPnPEvent: QueryPower\n");
76  return NDIS_STATUS_SUCCESS;
77 
79  DPRINT1("NetPnPEvent: CancelRemoveDevice\n");
80  return NDIS_STATUS_SUCCESS;
81 
83  DPRINT1("NetPnPEvent: Reconfigure\n");
84  return NDIS_STATUS_SUCCESS;
85 
86  case NetEventBindList:
87  DPRINT1("NetPnPEvent: BindList\n");
88  return NDIS_STATUS_SUCCESS;
89 
91  DPRINT("NetPnPEvent: BindsComplete\n");
92  return NDIS_STATUS_SUCCESS;
93 
95  DPRINT1("NetPnPEvent: PnPCapabilities\n");
96  return NDIS_STATUS_SUCCESS;
97 
98  default:
99  DPRINT1("NetPnPEvent unimplemented for net event 0x%x\n", NetPnPEvent->NetEvent);
100  return NDIS_STATUS_FAILURE;
101  }
102 }
103 
104 VOID
105 NTAPI
109 {
111 
112  DPRINT("Asynchronous adapter send completed\n");
113 
114  /* Store the final status and signal the event */
115  AdapterContext->AsyncStatus = Status;
116  KeSetEvent(&AdapterContext->AsyncEvent, IO_NO_INCREMENT, FALSE);
117 }
118 
119 VOID
120 NTAPI
124  UINT BytesTransferred)
125 {
127 
128  DPRINT("Asynchronous adapter transfer completed\n");
129 
130  /* Store the final status and signal the event */
131  AdapterContext->AsyncStatus = Status;
132  KeSetEvent(&AdapterContext->AsyncEvent, IO_NO_INCREMENT, FALSE);
133 }
134 
135 VOID
136 NTAPI
139 {
141 
142  DPRINT("Asynchronous adapter reset completed\n");
143 
144  /* Store the final status and signal the event */
145  AdapterContext->AsyncStatus = Status;
146  KeSetEvent(&AdapterContext->AsyncEvent, IO_NO_INCREMENT, FALSE);
147 }
148 
149 VOID
150 NTAPI
154 {
156 
157  DPRINT("Asynchronous adapter request completed\n");
158 
159  /* Store the final status and signal the event */
160  AdapterContext->AsyncStatus = Status;
161  KeSetEvent(&AdapterContext->AsyncEvent, IO_NO_INCREMENT, FALSE);
162 }
163 
165 NTAPI
167  NDIS_HANDLE MacReceiveContext,
168  PVOID HeaderBuffer,
169  UINT HeaderBufferSize,
170  PVOID LookAheadBuffer,
171  UINT LookaheadBufferSize,
173 {
175  PNDISUIO_PACKET_ENTRY PacketEntry;
176  PVOID PacketBuffer;
179  UINT BytesTransferred;
180 
181  DPRINT("Received a %d byte packet\n", PacketSize);
182 
183  /* Discard if nobody is waiting for it */
184  if (AdapterContext->OpenCount == 0)
186 
187  /* Allocate a buffer to hold the packet data and header */
188  PacketBuffer = ExAllocatePool(NonPagedPool, PacketSize + HeaderBufferSize);
189  if (!PacketBuffer)
191 
192  /* Allocate the packet descriptor and buffer */
193  Packet = CreatePacketFromPoolBuffer(AdapterContext,
194  (PUCHAR)PacketBuffer + HeaderBufferSize,
195  PacketSize);
196  if (!Packet)
197  {
198  ExFreePool(PacketBuffer);
200  }
201 
202  /* Transfer the packet data into our data buffer */
203  if (LookaheadBufferSize == PacketSize)
204  {
205  NdisCopyLookaheadData((PVOID)((PUCHAR)PacketBuffer + HeaderBufferSize),
206  LookAheadBuffer,
207  PacketSize,
208  AdapterContext->MacOptions);
209  BytesTransferred = PacketSize;
210  }
211  else
212  {
214  AdapterContext->BindingHandle,
215  MacReceiveContext,
216  0,
217  PacketSize,
218  Packet,
219  &BytesTransferred);
221  {
222  KeWaitForSingleObject(&AdapterContext->AsyncEvent,
223  Executive,
224  KernelMode,
225  FALSE,
226  NULL);
227  Status = AdapterContext->AsyncStatus;
228  }
230  {
231  DPRINT1("Failed to transfer data with status 0x%x\n", Status);
233  ExFreePool(PacketBuffer);
235  }
236  }
237 
238  /* Copy the header data */
239  RtlCopyMemory(PacketBuffer, HeaderBuffer, HeaderBufferSize);
240 
241  /* Free the packet descriptor and buffers
242  but not the pool because we still need it */
244 
245  /* Allocate a packet entry from pool */
246  PacketEntry = ExAllocatePool(NonPagedPool, sizeof(NDISUIO_PACKET_ENTRY) + BytesTransferred + HeaderBufferSize - 1);
247  if (!PacketEntry)
248  {
249  ExFreePool(PacketBuffer);
250  return NDIS_STATUS_RESOURCES;
251  }
252 
253  /* Initialize the packet entry and copy in packet data */
254  PacketEntry->PacketLength = BytesTransferred + HeaderBufferSize;
255  RtlCopyMemory(PacketEntry->PacketData, PacketBuffer, PacketEntry->PacketLength);
256 
257  /* Free the old buffer */
258  ExFreePool(PacketBuffer);
259 
260  /* Insert the packet on the adapter's packet list */
261  ExInterlockedInsertTailList(&AdapterContext->PacketList,
262  &PacketEntry->ListEntry,
263  &AdapterContext->Spinlock);
264 
265  /* Signal the read event */
266  KeSetEvent(&AdapterContext->PacketReadEvent,
268  FALSE);
269 
270  return NDIS_STATUS_SUCCESS;
271 }
272 
273 VOID
274 NTAPI
276 {
277  /* No op */
278 }
279 
280 VOID
281 NTAPI
286 {
287  /* FIXME: Implement status tracking */
288 }
289 
290 VOID
291 NTAPI
293 {
294  /* FIXME: Implement status tracking */
295 }
296 
297 static
300 {
301  KIRQL OldIrql;
302  PLIST_ENTRY CurrentEntry;
303  PNDISUIO_OPEN_ENTRY OpenEntry;
304  PNDISUIO_PACKET_ENTRY PacketEntry;
306 
307  DPRINT("Unbinding adapter %wZ\n", &AdapterContext->DeviceName);
308 
309  /* FIXME: We don't do anything with outstanding reads */
310 
311  /* Remove the adapter context from the global list */
313  RemoveEntryList(&AdapterContext->ListEntry);
315 
316  /* Free the device name string */
317  RtlFreeUnicodeString(&AdapterContext->DeviceName);
318 
319  /* Invalidate all handles to this adapter */
320  CurrentEntry = AdapterContext->OpenEntryList.Flink;
321  while (CurrentEntry != &AdapterContext->OpenEntryList)
322  {
323  OpenEntry = CONTAINING_RECORD(CurrentEntry, NDISUIO_OPEN_ENTRY, ListEntry);
324 
325  /* Make sure the entry is sane */
326  ASSERT(OpenEntry->FileObject);
327 
328  /* Remove the adapter context pointer */
329  ASSERT(AdapterContext == OpenEntry->FileObject->FsContext);
330  OpenEntry->FileObject->FsContext = NULL;
331  AdapterContext->OpenCount--;
332 
333  /* Remove the open entry pointer */
334  ASSERT(OpenEntry == OpenEntry->FileObject->FsContext2);
335  OpenEntry->FileObject->FsContext2 = NULL;
336 
337  /* Move to the next entry */
338  CurrentEntry = CurrentEntry->Flink;
339 
340  /* Free the open entry */
341  ExFreePool(OpenEntry);
342  }
343 
344  /* If this fails, we have a refcount mismatch somewhere */
345  ASSERT(AdapterContext->OpenCount == 0);
346 
347  /* Free all pending packet entries */
348  CurrentEntry = AdapterContext->PacketList.Flink;
349  while (CurrentEntry != &AdapterContext->PacketList)
350  {
351  PacketEntry = CONTAINING_RECORD(CurrentEntry, NDISUIO_PACKET_ENTRY, ListEntry);
352 
353  /* Move to the next entry */
354  CurrentEntry = CurrentEntry->Flink;
355 
356  /* Free the packet entry */
357  ExFreePool(PacketEntry);
358  }
359 
360  /* Send the close request */
362  AdapterContext->BindingHandle);
363 
364  /* Wait for a pending close */
366  {
367  KeWaitForSingleObject(&AdapterContext->AsyncEvent,
368  Executive,
369  KernelMode,
370  FALSE,
371  NULL);
372  Status = AdapterContext->AsyncStatus;
373  }
374 
375  /* Free the context */
376  ExFreePool(AdapterContext);
377 
378  return Status;
379 }
380 
381 static
384 {
386  PNDISUIO_ADAPTER_CONTEXT AdapterContext;
387  NDIS_MEDIUM SupportedMedia[1] = {NdisMedium802_3};
388  UINT SelectedMedium;
391 
392  /* Allocate the adapter context */
393  AdapterContext = ExAllocatePool(NonPagedPool, sizeof(*AdapterContext));
394  if (!AdapterContext)
395  {
396  return NDIS_STATUS_RESOURCES;
397  }
398 
399  /* Set up the adapter context */
400  RtlZeroMemory(AdapterContext, sizeof(*AdapterContext));
403  KeInitializeSpinLock(&AdapterContext->Spinlock);
404  InitializeListHead(&AdapterContext->PacketList);
405  InitializeListHead(&AdapterContext->OpenEntryList);
406  AdapterContext->OpenCount = 0;
407 
408  AdapterContext->DeviceName.Length =
409  AdapterContext->DeviceName.MaximumLength = DeviceName->Length;
410  AdapterContext->DeviceName.Buffer = ExAllocatePool(NonPagedPool, DeviceName->Length);
411  if (!AdapterContext->DeviceName.Buffer)
412  {
413  ExFreePool(AdapterContext);
414  return NDIS_STATUS_RESOURCES;
415  }
416 
417  /* Copy the device name into the adapter context */
418  RtlCopyMemory(AdapterContext->DeviceName.Buffer, DeviceName->Buffer, DeviceName->Length);
419 
420  DPRINT("Binding adapter %wZ\n", &AdapterContext->DeviceName);
421 
422  /* Create the buffer pool */
424  &AdapterContext->BufferPoolHandle,
425  50);
427  {
428  DPRINT1("Failed to allocate buffer pool with status 0x%x\n", Status);
429  RtlFreeUnicodeString(&AdapterContext->DeviceName);
430  ExFreePool(AdapterContext);
431  return Status;
432  }
433 
434  /* Create the packet pool */
436  &AdapterContext->PacketPoolHandle,
437  25,
440  {
441  DPRINT1("Failed to allocate packet pool with status 0x%x\n", Status);
442  NdisFreeBufferPool(AdapterContext->BufferPoolHandle);
443  RtlFreeUnicodeString(&AdapterContext->DeviceName);
444  ExFreePool(AdapterContext);
445  return Status;
446  }
447 
448  /* Send the open request */
451  &AdapterContext->BindingHandle,
452  &SelectedMedium,
453  SupportedMedia,
454  1,
456  AdapterContext,
457  DeviceName,
458  0,
459  NULL);
460 
461  /* Wait for a pending open */
463  {
464  KeWaitForSingleObject(&AdapterContext->AsyncEvent,
465  Executive,
466  KernelMode,
467  FALSE,
468  NULL);
469  Status = AdapterContext->AsyncStatus;
470  }
471 
472  /* Check the final status */
474  {
475  DPRINT1("Failed to open adapter for bind with status 0x%x\n", Status);
476  NdisFreePacketPool(AdapterContext->PacketPoolHandle);
477  NdisFreeBufferPool(AdapterContext->BufferPoolHandle);
478  RtlFreeUnicodeString(&AdapterContext->DeviceName);
479  ExFreePool(AdapterContext);
480  return Status;
481  }
482 
483  /* Get the MAC options */
484  Request.RequestType = NdisRequestQueryInformation;
485  Request.DATA.QUERY_INFORMATION.Oid = OID_GEN_MAC_OPTIONS;
486  Request.DATA.QUERY_INFORMATION.InformationBuffer = &AdapterContext->MacOptions;
487  Request.DATA.QUERY_INFORMATION.InformationBufferLength = sizeof(ULONG);
489  AdapterContext->BindingHandle,
490  &Request);
491 
492  /* Wait for a pending request */
494  {
495  KeWaitForSingleObject(&AdapterContext->AsyncEvent,
496  Executive,
497  KernelMode,
498  FALSE,
499  NULL);
500  Status = AdapterContext->AsyncStatus;
501  }
502 
503  /* Check the final status */
505  {
506  NDIS_STATUS CloseStatus;
507 
508  DPRINT1("Failed to get MAC options with status 0x%x\n", Status);
509 
510  NdisCloseAdapter(&CloseStatus,
511  AdapterContext->BindingHandle);
512  if (CloseStatus == NDIS_STATUS_PENDING)
513  {
514  KeWaitForSingleObject(&AdapterContext->AsyncEvent,
515  Executive,
516  KernelMode,
517  FALSE,
518  NULL);
519  }
520 
521  NdisFreePacketPool(AdapterContext->PacketPoolHandle);
522  NdisFreeBufferPool(AdapterContext->BufferPoolHandle);
523  RtlFreeUnicodeString(&AdapterContext->DeviceName);
524  ExFreePool(AdapterContext);
525  return Status;
526  }
527 
528  /* Add the adapter context to the global list */
530  &AdapterContext->ListEntry,
532 
533  return STATUS_SUCCESS;
534 }
535 
536 VOID
537 NTAPI
539  NDIS_HANDLE BindContext,
541  PVOID SystemSpecific1,
543 {
544  /* Use our helper function to create a context for this adapter */
546 }
547 
548 VOID
549 NTAPI
552  NDIS_HANDLE UnbindContext)
553 {
554  /* This is forced unbind. UnbindAdapterByContext() will take care of
555  * invalidating file handles pointer to this adapter for us */
557 }
_Must_inspect_result_ _Out_ PNDIS_STATUS _Out_ PNDIS_STATUS _Out_ PNDIS_HANDLE _Out_ PUINT _In_ UINT _In_ NDIS_HANDLE _In_ NDIS_HANDLE ProtocolBindingContext
Definition: ndis.h:6013
Definition: ndisuio.h:65
VOID EXPORT NdisAllocatePacketPool(OUT PNDIS_STATUS Status, OUT PNDIS_HANDLE PoolHandle, IN UINT NumberOfDescriptors, IN UINT ProtocolReservedLength)
Definition: buffer.c:419
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
_In_ UCHAR _In_ POWER_STATE PowerState
Definition: pofuncs.h:42
_In_ WDFREQUEST Request
Definition: cdrom.h:1234
NDIS_HANDLE BufferPoolHandle
Definition: ndisuio.h:34
_Must_inspect_result_ _Out_ PNDIS_STATUS _Out_ PNDIS_STATUS OpenErrorStatus
Definition: ndis.h:6008
_In_ NDIS_HANDLE _In_ PNDIS_PACKET Packet
Definition: ndis.h:1548
enum _NDIS_MEDIUM NDIS_MEDIUM
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define NDIS_STATUS_PENDING
Definition: ndis.h:347
_In_ NDIS_STATUS _In_ NDIS_STATUS OpenStatus
Definition: ndis.h:6034
unsigned char * PUCHAR
Definition: retypes.h:3
PLIST_ENTRY NTAPI ExInterlockedInsertTailList(IN OUT PLIST_ENTRY ListHead, IN OUT PLIST_ENTRY ListEntry, IN OUT PKSPIN_LOCK Lock)
Definition: interlocked.c:140
#define OID_GEN_MAC_OPTIONS
Definition: ntddndis.h:251
* PNDIS_STATUS
Definition: ndis.h:45
KSPIN_LOCK Spinlock
Definition: ndisuio.h:50
enum _NDIS_DEVICE_POWER_STATE * PNDIS_DEVICE_POWER_STATE
_In_opt_ NDIS_HANDLE _In_ NDIS_STATUS GeneralStatus
Definition: ndis.h:1555
VOID CleanupAndFreePacket(PNDIS_PACKET Packet, BOOLEAN FreePool)
Definition: misc.c:83
WCHAR DeviceName[]
Definition: adapter.cpp:21
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
_In_ NDIS_HANDLE _In_ PNET_PNP_EVENT NetPnPEvent
Definition: ndis.h:6081
VOID NTAPI NduTransferDataComplete(NDIS_HANDLE ProtocolBindingContext, PNDIS_PACKET Packet, NDIS_STATUS Status, UINT BytesTransferred)
Definition: protocol.c:121
int NDIS_STATUS
Definition: ntddndis.h:471
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
UCHAR KIRQL
Definition: env_spec_w32.h:591
VOID NTAPI NduSendComplete(NDIS_HANDLE ProtocolBindingContext, PNDIS_PACKET Packet, NDIS_STATUS Status)
Definition: protocol.c:106
static NDIS_STATUS UnbindAdapterByContext(PNDISUIO_ADAPTER_CONTEXT AdapterContext)
Definition: protocol.c:299
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
#define FALSE
Definition: types.h:117
NDIS_STATUS NTAPI NduReceive(NDIS_HANDLE ProtocolBindingContext, NDIS_HANDLE MacReceiveContext, PVOID HeaderBuffer, UINT HeaderBufferSize, PVOID LookAheadBuffer, UINT LookaheadBufferSize, UINT PacketSize)
Definition: protocol.c:166
VOID NTAPI NduRequestComplete(NDIS_HANDLE ProtocolBindingContext, PNDIS_REQUEST NdisRequest, NDIS_STATUS Status)
Definition: protocol.c:151
VOID EXPORT NdisRequest(OUT PNDIS_STATUS Status, IN NDIS_HANDLE NdisBindingHandle, IN PNDIS_REQUEST NdisRequest)
Definition: protocol.c:1239
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:238
Definition: ndisuio.h:53
VOID NTAPI NduReceiveComplete(NDIS_HANDLE ProtocolBindingContext)
Definition: protocol.c:275
smooth NULL
Definition: ftsmooth.c:416
UCHAR PacketData[1]
Definition: ndisuio.h:74
void DPRINT(...)
Definition: polytest.cpp:61
VOID NTAPI NduResetComplete(NDIS_HANDLE ProtocolBindingContext, NDIS_STATUS Status)
Definition: protocol.c:137
NDIS_HANDLE PacketPoolHandle
Definition: ndisuio.h:33
NDIS_STATUS NTAPI NduNetPnPEvent(NDIS_HANDLE ProtocolBindingContext, PNET_PNP_EVENT NetPnPEvent)
Definition: protocol.c:45
VOID NTAPI NduStatusComplete(NDIS_HANDLE ProtocolBindingContext)
Definition: protocol.c:292
KSPIN_LOCK GlobalAdapterListLock
Definition: main.c:16
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define IO_NETWORK_INCREMENT
Definition: tcpip.h:43
#define PROTOCOL_RESERVED_SIZE_IN_PACKET
Definition: ndis.h:1540
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define NDIS_STATUS_NOT_ACCEPTED
Definition: ndis.h:350
#define NdisCopyLookaheadData(Destination, Source, Length, MacOptions)
Definition: ndis.h:3289
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
VOID NTAPI NduOpenAdapterComplete(NDIS_HANDLE ProtocolBindingContext, NDIS_STATUS Status, NDIS_STATUS OpenStatus)
Definition: protocol.c:16
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
PFILE_OBJECT FileObject
Definition: ndisuio.h:56
UNICODE_STRING DeviceName
Definition: ndisuio.h:44
NDIS_STATUS AsyncStatus
Definition: ndisuio.h:22
PNDIS_PACKET CreatePacketFromPoolBuffer(PNDISUIO_ADAPTER_CONTEXT AdapterContext, PVOID Buffer, ULONG BufferSize)
Definition: misc.c:52
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
Status
Definition: gdiplustypes.h:24
VOID NTAPI NduCloseAdapterComplete(NDIS_HANDLE ProtocolBindingContext, NDIS_STATUS Status)
Definition: protocol.c:31
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
_In_ PVOID _In_ PVOID SystemSpecific2
Definition: ndis.h:637
Definition: typedefs.h:119
NDIS_HANDLE BindingHandle
Definition: ndisuio.h:26
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
_In_opt_ NDIS_HANDLE _In_ NDIS_STATUS _In_ PVOID _In_ UINT StatusBufferSize
Definition: ndis.h:1555
_In_ USHORT PacketSize
Definition: iofuncs.h:1056
LIST_ENTRY ListEntry
Definition: ndisuio.h:47
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
VOID EXPORT NdisOpenAdapter(OUT PNDIS_STATUS Status, OUT PNDIS_STATUS OpenErrorStatus, OUT PNDIS_HANDLE NdisBindingHandle, OUT PUINT SelectedMediumIndex, IN PNDIS_MEDIUM MediumArray, IN UINT MediumArraySize, IN NDIS_HANDLE NdisProtocolHandle, IN NDIS_HANDLE ProtocolBindingContext, IN PNDIS_STRING AdapterName, IN UINT OpenOptions, IN PSTRING AddressingInformation OPTIONAL)
Definition: protocol.c:764
VOID EXPORT NdisFreeBufferPool(IN NDIS_HANDLE PoolHandle)
Definition: buffer.c:775
LIST_ENTRY GlobalAdapterList
Definition: main.c:17
unsigned int UINT
Definition: ndis.h:50
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
_In_opt_ NDIS_HANDLE _In_ NDIS_STATUS _In_ PVOID StatusBuffer
Definition: ndis.h:1555
VOID EXPORT NdisFreePacketPool(IN NDIS_HANDLE PoolHandle)
Definition: buffer.c:791
#define DPRINT1
Definition: precomp.h:8
VOID EXPORT NdisCloseAdapter(OUT PNDIS_STATUS Status, IN NDIS_HANDLE NdisBindingHandle)
Definition: protocol.c:703
VOID NTAPI NduStatus(NDIS_HANDLE ProtocolBindingContext, NDIS_STATUS GeneralStatus, PVOID StatusBuffer, UINT StatusBufferSize)
Definition: protocol.c:282
#define NDIS_STATUS_RESOURCES
Definition: ndis.h:466
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:581
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
LIST_ENTRY OpenEntryList
Definition: ndisuio.h:30
VOID NTAPI NduUnbindAdapter(PNDIS_STATUS Status, NDIS_HANDLE ProtocolBindingContext, NDIS_HANDLE UnbindContext)
Definition: protocol.c:550
ULONG PacketLength
Definition: ndisuio.h:68
VOID NTAPI NduBindAdapter(PNDIS_STATUS Status, NDIS_HANDLE BindContext, PNDIS_STRING DeviceName, PVOID SystemSpecific1, PVOID SystemSpecific2)
Definition: protocol.c:538
return STATUS_SUCCESS
Definition: btrfs.c:3014
VOID EXPORT NdisTransferData(OUT PNDIS_STATUS Status, IN NDIS_HANDLE NdisBindingHandle, IN NDIS_HANDLE MacReceiveContext, IN UINT ByteOffset, IN UINT BytesToTransfer, IN OUT PNDIS_PACKET Packet, OUT PUINT BytesTransferred)
Definition: protocol.c:1307
NDIS_HANDLE GlobalProtocolHandle
Definition: main.c:15
VOID EXPORT NdisAllocateBufferPool(OUT PNDIS_STATUS Status, OUT PNDIS_HANDLE PoolHandle, IN UINT NumberOfDescriptors)
Definition: buffer.c:370
LIST_ENTRY PacketList
Definition: ndisuio.h:37
#define NDIS_STATUS_FAILURE
Definition: ndis.h:465
LIST_ENTRY ListEntry
Definition: ndisuio.h:71
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
static NDIS_STATUS BindAdapterByName(PNDIS_STRING DeviceName)
Definition: protocol.c:383