Re: NdisGetReceivedPacket doesn't work in NDIS IM ???

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



You must create a new NDIS_PACKET, the new memory area for the updated part
of the packet, the new NDIS_BUFFER describing this memory, and link the new
buffer chain.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@xxxxxxxxxxxxxxxx
http://www.storagecraft.com

"Hien Nguyen" <thuchien@xxxxxxxxx> wrote in message
news:9020DC9E-C895-4B94-B273-634C02EF6662@xxxxxxxxxxxxxxxx
> I had try the passthruex part 2, but it not work properly. It doesnt filter
> IP packet, event when I try testuiocrl to show the filter status, no IP
> packet is proccesssed.
>
> Then I try to modify it to filter ARP packet as follow. It can realize
> ARP packet, it's fields. But when I try to modify the ARP packet. The
> NdisGetReceivedPacket(pAdapt->BindingHandle, MacReceiveContext) doens't work
> well, and I always see "No packet receive!" but the network still work well
> and I can see the PtReceivePacket never work. What happens here???
> The following is my code. In this FltFilterReceive, I modified to only filt
> ARP packet, and I sure it work well. I test the driver in the ethernet
> connection with router modem ADSL, the ARP packet of that modem, always add
> 18 byte as data of ARP packet. I try to modify this packet by strip this 18
> bytes, only ARP header is encapsulate.
>
> Thank you very much.
>
> NDIS_STATUS
> PtReceive(..)
> {
> ...
> [snip]
>
> DbgPrint("===>PtReceive \n");
>
> if ((!pAdapt->MiniportHandle) || (pAdapt->MPDeviceState >
> NdisDeviceStateD0))
> {
> Status = NDIS_STATUS_FAILURE;
> }
> else do
> {
> // BEGIN_PTEX_FILTER
> ULONG RcvFltAction;
>
> RcvFltAction = FltFilterReceive(
> pAdapt,
> MacReceiveContext,
> HeaderBuffer,
> HeaderBufferSize,
> LookAheadBuffer,
> LookAheadBufferSize,
> PacketSize
> );
>
> //
> // Possibly Block (Drop) Packet
> //
> if( RcvFltAction & RCV_FLT_BLOCK_PACKET )
> {
> if (LookAheadBufferSize>sizeof(ArpHdr))
> {
> ulNewPayload=HeaderBufferSize+sizeof(ArpHdr);
>
> Stt=NdisAllocateMemoryWithTag( &pNewPayload,
> ulNewPayload,
> TAG);
> if (Stt!=NDIS_STATUS_SUCCESS)
> {
> DbgPrint("Can't Allocate memory ! Drop packet!");
> Status=NDIS_STATUS_SUCCESS;
> break;
> }
>
> memcpy( pNewPayload,
> HeaderBuffer,
> HeaderBufferSize);
>
> memcpy( pNewPayload+HeaderBufferSize,
> LookAheadBuffer,
> sizeof(ArpHdr));
>
> }
> else DbgPrint("ARP packet have no data!, the length of packet is
> %u", LookAheadBufferSize);
>
> }
> // END_PTEX_FILTER
>
> Packet = NdisGetReceivedPacket(pAdapt->BindingHandle,
> MacReceiveContext);
> if (Packet==NULL) DbgPrint("No Packet receive!");
> if (Packet != NULL)
> {
>
> DbgPrint("Have Packet!");
> ...[snip]
> NdisDprAllocatePacket(&Status,
> &MyPacket,
> pAdapt->RecvPacketPoolHandle);
>
> if (Status == NDIS_STATUS_SUCCESS)
> {
>
> PNDIS_BUFFER pNewNdisBfr;
>
> DbgPrint("Allocate a packet from pool success");
> if (pNewPayload==NULL)
> {
> DbgPrint("The payload do not need to modify");
> MyPacket->Private.Head = Packet->Private.Head;
> MyPacket->Private.Tail = Packet->Private.Tail;
> }
> else
> {
> DbgPrint("Allocate buffer for modified packet!");
> NdisAllocateBuffer( &Status,
> &pNewNdisBfr,
> pAdapt->hRecvBufferPool,
> pNewPayload,
> ulNewPayload);
>
> if (NDIS_STATUS_SUCCESS!=Status)
> {
> DbgPrint("PtReceivePacket() failed to get a buffer, drop
> it!");
> NdisFreeMemory( pNewPayload,
> ulNewPayload,
> 0);
> pNewPayload=NULL;
>
> Status=NDIS_STATUS_SUCCESS;
> break;
> }
>
> DbgPrint("Allocate buffer success!");
> NdisChainBufferAtFront( MyPacket,
> pNewNdisBfr
> );
> }
>
>
> NDIS_SET_ORIGINAL_PACKET(MyPacket,
> NDIS_GET_ORIGINAL_PACKET(Packet));
> NDIS_SET_PACKET_HEADER_SIZE(MyPacket,
> HeaderBufferSize);
>
> NdisGetPacketFlags(MyPacket)=
> NdisGetPacketFlags(Packet);
>
>
> NdisGetPacketFlags(MyPacket) = NdisGetPacketFlags(Packet);
>
> NDIS_SET_PACKET_STATUS(MyPacket, NDIS_STATUS_RESOURCES);
>
>
>
> NdisMIndicateReceivePacket(pAdapt->MiniportHandle, &MyPacket, 1);
>
> if (NULL!=pNewPayload) // Have unencapsulated payload?
> {
>
> DbgPrint("Success in set OOB data, new payload length is %u",ulNewPayload);
>
> NdisFreeBuffer(pNewNdisBfr);
> NdisFreeMemory( pNewPayload,
> ulNewPayload,
> 0);
>
> pNewPayload = NULL;
> }
> NdisDprFreePacket(MyPacket);
> break;
> }
> }
> else
> {
> //
> // The miniport below us uses the old-style (not packet)
> // receive indication. Fall through.
> //
> }
>
> //
> // Fall through if the miniport below us has either not
> // indicated a packet or we could not allocate one
> //
> pAdapt->IndicateRcvComplete = TRUE;
>
> ...[snip]


.



Relevant Pages

  • Re: NdisGetReceivedPacket doesnt work in NDIS IM ????
    ... IP packet, event when I try testuiocrl to show the filter status, no IP ... Then I try to modify it to filter ARP packet as follow. ...
    (microsoft.public.development.device.drivers)
  • NdisGetReceivedPacket doesnt work in NDIS IM ????
    ... IP packet, event when I try testuiocrl to show the filter status, no IP ... Then I try to modify it to filter ARP packet as follow. ...
    (microsoft.public.development.device.drivers)
  • NdisGetReceivedPacket doesnt work in NDIS IM ???
    ... IP packet, event when I try testuiocrl to show the filter status, no IP ... Then I try to modify it to filter ARP packet as follow. ...
    (microsoft.public.development.device.drivers)
  • Re: NdisGetReceivedPacket doesnt work in NDIS IM ???
    ... You must create a new NDIS_PACKET, the new memory area for the updated part ... IP packet, event when I try testuiocrl to show the filter status, no IP ... Then I try to modify it to filter ARP packet as follow. ... Stt=NdisAllocateMemoryWithTag(&pNewPayload, ...
    (microsoft.public.development.device.drivers)
  • Re: NdisGetReceivedPacket doesnt work in NDIS IM ????
    ... > IP packet, event when I try testuiocrl to show the filter status, no IP ... > Then I try to modify it to filter ARP packet as follow. ... But when I try to modify the ARP packet. ...
    (microsoft.public.development.device.drivers)