NdisSend from ptReceive failure

Discussion in 'Windows Vista Drivers' started by Kumar, Nov 9, 2004.

  1. Kumar

    Kumar Guest

    Hi All,

    I am writting an NDIS IM driver, in which I have to resend all the received
    packets. So when i receive the packets, I modify the destination IP of the
    received packet and resend it using NdisSend
    I do all these in both ptReceive and ptReceivePacket functions.

    But as soon as I try to send packets from ptReceivePacket the computer shuts
    down after installation of the driver.

    So can anyone tell what is wrong.
    My resending code inside ptReceivePackets is as follows.

    //testing send
    {
    PNDIS_PACKET OurPacket = NULL;
    NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
    PNDIS_BUFFER pNdisBuffer,pOurBuffer, pdataBuffer;
    ULONG PacketLength = 0;
    ULONG bytescopied = 0;
    PVOID virtualaddr = NULL, virtualaddr2 = NULL;
    PSEND_RSVD SendRsvd;


    NdisDprAllocatePacket(&Status, &OurPacket, pAdapt->SendPacketPoolHandle);
    NdisQueryPacket(Packet, NULL, NULL,&pNdisBuffer,&PacketLength );
    NdisAllocateMemoryWithTag(&virtualaddr,PacketLength,'DMSA')
    NdisAllocateBuffer(&Status,&pOurBuffer,pAdapt->bufferPool,virtualaddr,PacketLength);
    pOurBuffer->Next = NULL;
    NdisChainBufferAtFront(OurPacket,pOurBuffer);
    NdisCopyFromPacketToPacket(OurPacket,0,PacketLength,Packet,0,&bytescopied);


    NdisSend(&Status, pAdapt->BindingHandle, OurPacket);


    if(Status != NDIS_STATUS_PENDING)
    {
    NdisDprFreePacket(OurPacket);
    }

    }


    Thanks in advance,
    Kumar
     
    Kumar, Nov 9, 2004
    #1
    1. Advertisements

  2. There are lots of possibilities for problems with what you are doing.
    Hopefully you can use a debugger to sort them out.

    One area you need to think about is your ProtocolSendComplete
    handler.PtSendComplete will be called when the lower-level miniport has
    completed sending a packet that you have previously sent using NdisSend. In
    normal PassThru mode PtSendComplete will essentially just call
    NdisMSendComplete on the packet that was originally sent from a higher-level
    protocol.

    When you inject packets the way you mention below you must add logic in
    PtSendComplete to differentiate between two cases:

    1.) Packets Sent From Higher-Level Protocol - Handle a susual
    2.) Packets That You Injected - Do NOT call NdisMSendComplete for these.

    Thomas F. Divine
     
    Thomas F. Divine [DDK MVP], Nov 9, 2004
    #2
    1. Advertisements

  3. Kumar

    Kumar Guest

    Thanks for the help.

    I tried what you said.
    I did handle the two types of send differently as mentioned.
    Unfortunately the problems still remains.

    I have a doubt in the line
    NdisSend(&Status, pAdapt->BindingHandle, OurPacket);

    is pAdapt->BindingHandle correct or should it be pAdapt->MiniportHandle
    OR do you have a any order idea.

    Hoping to solve this problem
    Thanks again.
     
    Kumar, Nov 10, 2004
    #3
  4. Examine the sample code. Find other places where NdisSend is called.

    Examine the DDK documentation for NdisSend. It says that the handle:

    "Specifies the handle returned by NdisOpenAdapter that identifies the target
    NIC or the virtual adapter of the next-lower driver to which the caller is
    bound."

    So, lookup your call to NdisOpenAdapter to verify where you stashed the
    handle needed to call NdisSend.

    You can answer this one yourself...

    Thomas F. Divine, Windows DDK MVP
    http://www.pcausa.com
     
    Thomas F. Divine [DDK MVP], Nov 10, 2004
    #4
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.