Re: MiniportSendPackets by soviet_bloke
soviet_bloke
Sun Oct 15 22:05:21 CDT 2006
Hi mate
First of all, I don't see that you check whether BytesCopied equals
TotalPacketLength, i.e. whether NdisCopyFromPacketToPacketSafe()call
was successfull......
Even if it was, don't forget that NdisCopyFromPacketToPacketSafe()
does not copy out-of-band data - you have to
get a pointer to it with NDIS_OOB_DATA_FROM_PACKET and then copy it
with NdisCopyMemory(). Furthermore,
the packet may have media-specific info, so that you have to check it
with NDIS_GET_PACKET_MEDIA_SPECIFIC_INFO, and, if necessary, copy it
with NDIS_SET_PACKET_MEDIA_SPECIFIC_INFO
Furthermore, you make a single-buffer packet - you allocate a buffer
the size of the packet, attach it at the front, and then copy all
packet data to it with NdisCopyFromPacketToPacketSafe(). To give you an
idea, any IP packet that comes from TCPIP.SYS has at least 4 buffers -
ARP header, IP header, protocol header and packet data are in separate
buffers
First of all, try to copy each buffer buffer, and chain them to your
packet. It does not make sense to do it in non-modifying driver (all
you have to do in non-modifying driver is to set your packet's head and
tail to those of the original packet), but, as far as I understand, you
final goal is modifying one. In such case, probably, at some later
stage it will make sense to re-construct the whole IP packet from NDIS
buffers, then break it into separate buffers again, and chain them to
your packet
All the above applies only to packets that are being sent - when it
comes to the ones that you indicate to TCPIP,
make sure that the very first buffer describes both MAC header and
LookaheadData . Otherwise, TCPIP will ignore the packet
Anton Bassov
szymonas_82@go2.pl wrote:
> Hi, I need to send modified packets in NDIS IM driver. First of all I
> try to simply send my not modified packet in MiniportSendPackets to
> check if this works. Before NdisSend I do the following :
>
> NdisQueryPacketLength(Packet,&TotalPacketLength);
> NdisAllocateMemoryWithTag(&pStartVa, TotalPacketLength,
> TAG);
> NdisAllocateBuffer(&Status,
> &pNdisBuffer,pAdapt->SendBufferPoolHandle,
> pStartVa, TotalPacketLength );
>
> NdisChainBufferAtFront( MyPacket, pNdisBuffer );
> NdisCopyFromPacketToPacketSafe(MyPacket, 0,
> TotalPacketLength,
> Packet, 0,
> &BytesCopied, NormalPagePriority);
>
> and not all packets are being sent (the bigger ones I suppose). What I
> do wrong? Should I add some code to ProtocolSendComplete function? I'll
> appreciate any help.