Please help with NDIS5 intermediate driver: receiving and creating packets

Strange things happen. NdisGetReceivedPacket returns NULL (NDIS version is 5.0, Win2K), but partial receive (with lookahead buffer) receives all packet’s contents in lookahead buffer (I checked the huge-size packets too). To modify packet I need to create it from scratch, copy data into it and drop original packet. However, when I call NdisTransferData to make framework flush packet’s data in my newly created packet I get IRQL_IS_NOT_LESS_OR_EQUAL. I was trying to switch with NdisIMSwitchToMiniport/RevertBack and perform receiving there. But same thing happens. I allocate buffer(s) for packets and it is OK with packet descriptors.
When I create packet and call NdisMIndicateReceivePacket, I get my packet recycle request and packet not forwarded up. What was wrong? Can anybody share a source code of example? It is for me only, I’m not working in any organizations and, therefore, will not sell your code. I wasted two weeks trying to solve this problem. I read mailing list archive and found no answers. Please, help.

Best regards,
Dan E. Barvitsky.

In your ReceiveHandler you do not need to call NdisTransferData if
LookaheadBufferSize >= PacketSize. In fact, you shouldn't cann
NdisTransferData in this case.

First, allocate VM for packet data from non-paged pool. The VM array should
be HeaderBufferSize + PacketSize in length.

Then copy HeaderBuffer to your VM, and then copy LookaheadBuffer to VM (at
offset of HeaderBufferSize). These are ordinary array operations. You are
just making a byte array that contains HeaderBuffer and LookaheadBuffer. You
can make modifications to the data as you copy it to your own VM.

Then allocate a NDIS_BUFFER for your VM.

Finally, allocate a NDIS_PACKET and chain your NDIS_BUFFER to it.

Here are some additional URLs that may be helpful:

NDIS_PACKET Discussion: http://www.ndis.com/papers/default.htm

Notes About NDIS IM Drivers and NDIS Task Offload:
http://www.ndis.com/pcakb/KB05280101.htm

Good luck,

Thomas F. Divine

PCAUSA - Toolkits & Resources For Network Software Developers
NDIS Protocol - NDIS Intermediate - TDI Client/Filter
http: - http:

"Dan E. Barvitsky" wrote in message
news:xxxxx@ntdev...
Strange things happen. NdisGetReceivedPacket returns NULL (NDIS version is
5.0, Win2K), but partial receive (with lookahead buffer) receives all
packet's contents in lookahead buffer (I checked the huge-size packets too).

To modify packet I need to create it from scratch, copy data into it and
drop original packet. However, when I call NdisTransferData to make
framework flush packet's data in my newly created packet I get
IRQL_IS_NOT_LESS_OR_EQUAL. I was trying to switch with
NdisIMSwitchToMiniport/RevertBack and perform receiving there. But same
thing happens. I allocate buffer(s) for packets and it is OK with packet
descriptors.

When I create packet and call NdisMIndicateReceivePacket, I get my packet
recycle request and packet not forwarded up. What was wrong? Can anybody
share a source code of example? It is for me only, I'm not working in any
organizations and, therefore, will not sell your code. I wasted two weeks
trying to solve this problem. I read mailing list archive and found no
answers. Please, help.

Best regards,
Dan E. Barvitsky.</http:></http:>

Thanks a lot. I tried to do so, but packets still do not go to the upper
drivers. Maybe it is
a problem of OOB data or packet flags? Or maybe I should set HEADER_SIZE to
something? However receiving does not causes DRIVER_IRQL… messages any
more. These packets just disappear when I forward them up through
IndicateReceivePackets.

If I set packet’s status to NDIS_STATUS_RESOURCES they start forwarding, but
I don’t know when
I can free them. Freeing packets just after IndicateReceive returns causes
same situation - packets just return not passing to upper protocols. Ok, I
have the URL, and, therefore I can find out things myself (I hope).

Thanks for help,
Best Regards,
Dan.
----- Original Message -----
From: “Thomas F. Divine”
Newsgroups: ntdev
To: “NT Developers Interest List”
Sent: Friday, January 17, 2003 8:14 PM
Subject: [ntdev] Re: Please help with NDIS5 intermediate driver: receiving
and creating packets

> In your ReceiveHandler you do not need to call NdisTransferData if
> LookaheadBufferSize >= PacketSize. In fact, you shouldn’t cann
> NdisTransferData in this case.
>
> First, allocate VM for packet data from non-paged pool. The VM array
should
> be HeaderBufferSize + PacketSize in length.
>
> Then copy HeaderBuffer to your VM, and then copy LookaheadBuffer to VM (at
> offset of HeaderBufferSize). These are ordinary array operations. You are
> just making a byte array that contains HeaderBuffer and LookaheadBuffer.
You
> can make modifications to the data as you copy it to your own VM.
>
> Then allocate a NDIS_BUFFER for your VM.
>
> Finally, allocate a NDIS_PACKET and chain your NDIS_BUFFER to it.
>
> Here are some additional URLs that may be helpful:
>
> NDIS_PACKET Discussion: http://www.ndis.com/papers/default.htm
>
> Notes About NDIS IM Drivers and NDIS Task Offload:
> http://www.ndis.com/pcakb/KB05280101.htm
>
> Good luck,
> –
> Thomas F. Divine
>
> PCAUSA - Toolkits & Resources For Network Software Developers
> NDIS Protocol - NDIS Intermediate - TDI Client/Filter
> http: - http:
>
>
> “Dan E. Barvitsky” wrote in message
> news:xxxxx@ntdev…
> Strange things happen. NdisGetReceivedPacket returns NULL (NDIS version is
> 5.0, Win2K), but partial receive (with lookahead buffer) receives all
> packet’s contents in lookahead buffer (I checked the huge-size packets
too).
>
> To modify packet I need to create it from scratch, copy data into it and
> drop original packet. However, when I call NdisTransferData to make
> framework flush packet’s data in my newly created packet I get
> IRQL_IS_NOT_LESS_OR_EQUAL. I was trying to switch with
> NdisIMSwitchToMiniport/RevertBack and perform receiving there. But same
> thing happens. I allocate buffer(s) for packets and it is OK with packet
> descriptors.
>
> When I create packet and call NdisMIndicateReceivePacket, I get my packet
> recycle request and packet not forwarded up. What was wrong? Can anybody
> share a source code of example? It is for me only, I’m not working in any
> organizations and, therefore, will not sell your code. I wasted two weeks
> trying to solve this problem. I read mailing list archive and found no
> answers. Please, help.
>
> Best regards,
> Dan E. Barvitsky.
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@hotmail.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
></http:></http:>