ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

efilter.c
Go to the documentation of this file.
00001 /*
00002  * COPYRIGHT:   See COPYING in the top level directory
00003  * PROJECT:     ReactOS NDIS library
00004  * FILE:        ndis/efilter.c
00005  * PURPOSE:     Ethernet filter functions
00006  * PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
00007  *              Vizzini (vizzini@plasmic.com)
00008  * REVISIONS:
00009  *   CSH 01/08-2000 Created
00010  */
00011 
00012 #include "ndissys.h"
00013 
00014 BOOLEAN
00015 NTAPI
00016 EthCreateFilter(
00017     IN  UINT                MaximumMulticastAddresses,
00018     IN  PUCHAR              AdapterAddress,
00019     OUT PETH_FILTER         * Filter)
00020 /*
00021  * FUNCTION: Construct an ethernet filter
00022  * ARGUMENTS:
00023  *     MaximumMulticastAddresses: Maximum number of multicast adderesses.
00024  *     AdapterAddress: Current ethernet address of the adapter.
00025  *     Filter: The created filter on successful return.
00026  * RETURNS:
00027  *     TRUE if the filter was created
00028  *     FALSE otherwise
00029  * NOTE:
00030  *     - This function is no longer exported and intentionally doesn't
00031  *       follow the W2K prototype. It was deprecated since NDIS 4 so it
00032  *       shouldn't be problem.
00033  */
00034 {
00035   PETHI_FILTER NewFilter;
00036 
00037   NewFilter = ExAllocatePool(NonPagedPool, sizeof(ETHI_FILTER));
00038   if (NewFilter != NULL)
00039     {
00040       RtlZeroMemory(NewFilter, sizeof(ETHI_FILTER));
00041       NewFilter->MaxMulticastAddresses = MaximumMulticastAddresses;
00042       RtlCopyMemory(NewFilter->AdapterAddress, AdapterAddress, ETH_LENGTH_OF_ADDRESS);
00043       *Filter = (PETH_FILTER)NewFilter;
00044       return TRUE;
00045     }
00046   else
00047     {
00048       NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
00049       *Filter = NULL;
00050       return FALSE;
00051     }
00052 }
00053 
00054 
00055 VOID
00056 EXPORT
00057 EthDeleteFilter(
00058     IN  PETH_FILTER Filter)
00059 {
00060     ExFreePool(Filter);
00061 }
00062 
00063 
00064 /*
00065  * @implemented
00066  */
00067 VOID
00068 EXPORT
00069 EthFilterDprIndicateReceive(
00070     IN  PETH_FILTER Filter,
00071     IN  NDIS_HANDLE MacReceiveContext,
00072     IN  PCHAR       Address,
00073     IN  PVOID       HeaderBuffer,
00074     IN  UINT        HeaderBufferSize,
00075     IN  PVOID       LookaheadBuffer,
00076     IN  UINT        LookaheadBufferSize,
00077     IN  UINT        PacketSize)
00078 /*
00079  * FUNCTION: Receive indication function for Ethernet devices
00080  * ARGUMENTS:
00081  *     MiniportAdapter     = Miniport Adapter Handle (PLOGICAL_ADAPTER)
00082  *     MacReceiveContext   = MAC receive context handle
00083  *     Address             = Pointer to destination Ethernet address
00084  *     HeaderBuffer        = Pointer to Ethernet header buffer
00085  *     HeaderBufferSize    = Size of Ethernet header buffer
00086  *     LookaheadBuffer     = Pointer to lookahead buffer
00087  *     LookaheadBufferSize = Size of lookahead buffer
00088  *     PacketSize          = Total size of received packet
00089  */
00090 {
00091     /* Not sure if this is a valid thing to do, but we do arrive here early
00092      * in the boot process with Filter NULL.  We need to investigate whether
00093      * this should be handled or not allowed. */
00094     if( !Filter ) {
00095         NDIS_DbgPrint(MIN_TRACE, ("Filter is NULL\n"));
00096         return;
00097     }
00098     MiniIndicateData((PLOGICAL_ADAPTER)((PETHI_FILTER)Filter)->Miniport,
00099              MacReceiveContext,
00100              HeaderBuffer,
00101              HeaderBufferSize,
00102              LookaheadBuffer,
00103              LookaheadBufferSize,
00104              PacketSize);
00105 }
00106 
00107 
00108 /*
00109  * @implemented
00110  */
00111 VOID
00112 EXPORT
00113 EthFilterDprIndicateReceiveComplete(
00114     IN  PETH_FILTER Filter)
00115 /*
00116  * FUNCTION: Receive indication complete function for Ethernet devices
00117  * ARGUMENTS:
00118  *     Filter = Pointer to Ethernet filter
00119  */
00120 {
00121   PLIST_ENTRY CurrentEntry;
00122   PLOGICAL_ADAPTER Adapter;
00123   PADAPTER_BINDING AdapterBinding;
00124 
00125   NDIS_DbgPrint(DEBUG_MINIPORT, ("Called.\n"));
00126 
00127   if( !Filter ) {
00128       NDIS_DbgPrint(MIN_TRACE, ("Filter is NULL\n"));
00129       return;
00130   }
00131 
00132   Adapter = (PLOGICAL_ADAPTER)((PETHI_FILTER)Filter)->Miniport;
00133 
00134   NDIS_DbgPrint(MAX_TRACE, ("acquiring miniport block lock\n"));
00135   KeAcquireSpinLockAtDpcLevel(&Adapter->NdisMiniportBlock.Lock);
00136     {
00137       CurrentEntry = Adapter->ProtocolListHead.Flink;
00138 
00139       while (CurrentEntry != &Adapter->ProtocolListHead)
00140         {
00141           AdapterBinding = CONTAINING_RECORD(CurrentEntry, ADAPTER_BINDING, AdapterListEntry);
00142 
00143           (*AdapterBinding->ProtocolBinding->Chars.ReceiveCompleteHandler)(
00144               AdapterBinding->NdisOpenBlock.ProtocolBindingContext);
00145 
00146           CurrentEntry = CurrentEntry->Flink;
00147         }
00148     }
00149   KeReleaseSpinLockFromDpcLevel(&Adapter->NdisMiniportBlock.Lock);
00150 }
00151 
00152 /* EOF */

Generated on Sat May 26 2012 04:26:38 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.