ProtocolReceivePacket works, ProtocolReceive does not

I have an NDIS IM driver that works fine when ProtocolReceivePacket is called. However, for adapters that come in through ProtocolReceive, it does not. I always receive the entire packet. I am modifying the packets and then sending them on. Here is a condensed version of the code. Any insight would be appreciated.

NDIS_STATUS
PtReceive(IN NDIS_HANDLE ProtocolBindingContext, IN NDIS_HANDLE MacReceiveContext,
IN PVOID HeaderBuffer, IN UINT HeaderBufferSize,
IN PVOID LookAheadBuffer, IN UINT LookAheadBufferSize, IN UINT PacketSize)
{
PADAPT pAdapt = (PADAPT)ProtocolBindingContext;
PNDIS_PACKET MyPacket, Packet;
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
PRECV_RSVD recvRsvd;
PNDIS_BUFFER pNewNdisBfr = NULL;

do
{
Packet = NdisGetReceivedPacket(pAdapt->BindingHandle, MacReceiveContext);
if (Packet != NULL)
{
NdisDprAllocatePacket(&Status, &MyPacket, pAdapt->RecvPacketPoolHandle);
if (Status == NDIS_STATUS_SUCCESS)
{
// Not shown - Modify existing packet - in newPayload

recvRsvd = (PRECV_RSVD)(MyPacket->MiniportReserved);
recvRsvd->OriginalPkt = Packet;

NdisAllocateBuffer(&status, &pNewNdisBfr, pAdapt->RecvBufferPoolHandle,
newPayload, newPktLen);

recvRsvd->newBuffer = TRUE; // Show new NDIS_BUFFER used.

NdisChainBufferAtFront(MyPacket, pNewNdisBfr);

NDIS_SET_ORIGINAL_PACKET(MyPacket, NDIS_GET_ORIGINAL_PACKET(Packet));
NDIS_SET_PACKET_HEADER_SIZE(MyPacket, HeaderBufferSize);

NdisGetPacketFlags(MyPacket) = NdisGetPacketFlags(Packet);
NDIS_SET_PACKET_STATUS(MyPacket, NDIS_STATUS_RESOURCES);

NdisMIndicateReceivePacket(pAdapt->MiniportHandle, &MyPacket, 1);
NdisDprFreePacket(MyPacket);

break;
}
else
{
LOGERROR((“PTReceive:NdisDprAllocatePacket Failed\n”));
}
}
else
{
// TBD
}
} while(FALSE);

return Status;
}

INT
PtReceivePacket(IN NDIS_HANDLE ProtocolBindingContext, IN PNDIS_PACKET Packet)
{
PADAPT pAdapt =(PADAPT)ProtocolBindingContext;
NDIS_STATUS status;
PNDIS_PACKET myPacket;
PRECV_RSVD recvRsvd;

NdisDprAllocatePacket(&status, &myPacket, pAdapt->RecvPacketPoolHandle);
if (status != NDIS_STATUS_SUCCESS)
{
LOGERROR((“PtReceivePacket:NdisDprAllocatePacket Failed, status=0x%08x\n”,
status));
return(0);
}

// Not shown - Modify existing packet - in newPayload

recvRsvd = (PRECV_RSVD)(MyPacket->MiniportReserved);
recvRsvd->OriginalPkt = Packet;

NdisAllocateBuffer(&status, &pNewNdisBfr, pAdapt->RecvBufferPoolHandle,
newPayload, newPktLen);

recvRsvd->newBuffer = TRUE; // Show new NDIS_BUFFER used.

NdisChainBufferAtFront(MyPacket, pNewNdisBfr);

NDIS_SET_ORIGINAL_PACKET(myPacket, NDIS_GET_ORIGINAL_PACKET(Packet));

NdisGetPacketFlags(myPacket) = NdisGetPacketFlags(Packet);

status = NDIS_GET_PACKET_STATUS(Packet);

NDIS_SET_PACKET_STATUS(myPacket, status);
NDIS_SET_PACKET_HEADER_SIZE(myPacket,
NDIS_GET_PACKET_HEADER_SIZE(Packet));

NdisMIndicateReceivePacket(pAdapt->MiniportHandle, &myPacket, 1);

return((status != NDIS_STATUS_RESOURCES) ? 1 : 0);
}

How about you tell us what it means to not work fine and not have us guess
at what the symptom is :slight_smile:
-dave

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@socket.net
Sent: Friday, August 24, 2007 1:27 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] ProtocolReceivePacket works, ProtocolReceive does not

I have an NDIS IM driver that works fine when ProtocolReceivePacket is
called. However, for adapters that come in through ProtocolReceive, it does
not. I always receive the entire packet. I am modifying the packets and
then sending them on. Here is a condensed version of the code. Any insight
would be appreciated.

NDIS_STATUS
PtReceive(IN NDIS_HANDLE ProtocolBindingContext, IN NDIS_HANDLE
MacReceiveContext,
IN PVOID HeaderBuffer, IN UINT HeaderBufferSize,
IN PVOID LookAheadBuffer, IN UINT
LookAheadBufferSize, IN UINT PacketSize) {
PADAPT pAdapt = (PADAPT)ProtocolBindingContext;
PNDIS_PACKET MyPacket, Packet;
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
PRECV_RSVD recvRsvd;
PNDIS_BUFFER pNewNdisBfr = NULL;

do
{
Packet = NdisGetReceivedPacket(pAdapt->BindingHandle,
MacReceiveContext);
if (Packet != NULL)
{
NdisDprAllocatePacket(&Status, &MyPacket,
pAdapt->RecvPacketPoolHandle);
if (Status == NDIS_STATUS_SUCCESS)
{
// Not shown - Modify existing packet - in newPayload

recvRsvd = (PRECV_RSVD)(MyPacket->MiniportReserved);
recvRsvd->OriginalPkt = Packet;

NdisAllocateBuffer(&status, &pNewNdisBfr,
pAdapt->RecvBufferPoolHandle,
newPayload, newPktLen);

recvRsvd->newBuffer = TRUE; // Show new
NDIS_BUFFER used.

NdisChainBufferAtFront(MyPacket, pNewNdisBfr);

NDIS_SET_ORIGINAL_PACKET(MyPacket,
NDIS_GET_ORIGINAL_PACKET(Packet));
NDIS_SET_PACKET_HEADER_SIZE(MyPacket, HeaderBufferSize);

NdisGetPacketFlags(MyPacket) = NdisGetPacketFlags(Packet);
NDIS_SET_PACKET_STATUS(MyPacket, NDIS_STATUS_RESOURCES);

NdisMIndicateReceivePacket(pAdapt->MiniportHandle, &MyPacket, 1);
NdisDprFreePacket(MyPacket);

break;
}
else
{
LOGERROR((“PTReceive:NdisDprAllocatePacket Failed\n”));
}
}
else
{
// TBD
}
} while(FALSE);

return Status;
}

INT
PtReceivePacket(IN NDIS_HANDLE ProtocolBindingContext, IN PNDIS_PACKET
Packet) {
PADAPT pAdapt =(PADAPT)ProtocolBindingContext;
NDIS_STATUS status;
PNDIS_PACKET myPacket;
PRECV_RSVD recvRsvd;

NdisDprAllocatePacket(&status, &myPacket, pAdapt->RecvPacketPoolHandle);
if (status != NDIS_STATUS_SUCCESS)
{
LOGERROR((“PtReceivePacket:NdisDprAllocatePacket Failed,
status=0x%08x\n”,
status));
return(0);
}

// Not shown - Modify existing packet - in newPayload

recvRsvd = (PRECV_RSVD)(MyPacket->MiniportReserved);
recvRsvd->OriginalPkt = Packet;

NdisAllocateBuffer(&status, &pNewNdisBfr, pAdapt->RecvBufferPoolHandle,
newPayload, newPktLen);

recvRsvd->newBuffer = TRUE; // Show new NDIS_BUFFER
used.

NdisChainBufferAtFront(MyPacket, pNewNdisBfr);

NDIS_SET_ORIGINAL_PACKET(myPacket, NDIS_GET_ORIGINAL_PACKET(Packet));

NdisGetPacketFlags(myPacket) = NdisGetPacketFlags(Packet);

status = NDIS_GET_PACKET_STATUS(Packet);

NDIS_SET_PACKET_STATUS(myPacket, status);
NDIS_SET_PACKET_HEADER_SIZE(myPacket,

NDIS_GET_PACKET_HEADER_SIZE(Packet));

NdisMIndicateReceivePacket(pAdapt->MiniportHandle, &myPacket, 1);

return((status != NDIS_STATUS_RESOURCES) ? 1 : 0); }


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

You say “it does not work” when ProtocolReceive path is taken.

What do you mean by “it does not work”?

Do you mean that a network monitor shows an incorrect packet being received (Perhaps bad checksum…)? No packet received by the host?

Your new packet should not have any references to the old. For example, why these lines?

NDIS_SET_ORIGINAL_PACKET(MyPacket, NDIS_GET_ORIGINAL_PACKET(Packet));
NdisGetPacketFlags(MyPacket) = NdisGetPacketFlags(Packet);

Are the old flags what you really want for your newly constructed packet?

Thomas F. Divine

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-298243-
xxxxx@lists.osr.com] On Behalf Of xxxxx@socket.net
Sent: Friday, August 24, 2007 1:27 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] ProtocolReceivePacket works, ProtocolReceive does not

I have an NDIS IM driver that works fine when ProtocolReceivePacket is
called. However, for adapters that come in through ProtocolReceive, it
does not. I always receive the entire packet. I am modifying the
packets and then sending them on. Here is a condensed version of the
code. Any insight would be appreciated.

NDIS_STATUS
PtReceive(IN NDIS_HANDLE ProtocolBindingContext, IN NDIS_HANDLE
MacReceiveContext,
IN PVOID HeaderBuffer, IN UINT HeaderBufferSize,
IN PVOID LookAheadBuffer, IN UINT
LookAheadBufferSize, IN UINT PacketSize)
{
PADAPT pAdapt = (PADAPT)ProtocolBindingContext;
PNDIS_PACKET MyPacket, Packet;
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
PRECV_RSVD recvRsvd;
PNDIS_BUFFER pNewNdisBfr = NULL;

do
{
Packet = NdisGetReceivedPacket(pAdapt->BindingHandle,
MacReceiveContext);
if (Packet != NULL)
{
NdisDprAllocatePacket(&Status, &MyPacket, pAdapt-
>RecvPacketPoolHandle);
if (Status == NDIS_STATUS_SUCCESS)
{
// Not shown - Modify existing packet - in newPayload

recvRsvd = (PRECV_RSVD)(MyPacket->MiniportReserved);
recvRsvd->OriginalPkt = Packet;

NdisAllocateBuffer(&status, &pNewNdisBfr, pAdapt-
>RecvBufferPoolHandle,
newPayload, newPktLen);

recvRsvd->newBuffer = TRUE; // Show new
NDIS_BUFFER used.

NdisChainBufferAtFront(MyPacket, pNewNdisBfr);

NDIS_SET_ORIGINAL_PACKET(MyPacket,
NDIS_GET_ORIGINAL_PACKET(Packet));
NDIS_SET_PACKET_HEADER_SIZE(MyPacket, HeaderBufferSize);

NdisGetPacketFlags(MyPacket) = NdisGetPacketFlags(Packet);
NDIS_SET_PACKET_STATUS(MyPacket, NDIS_STATUS_RESOURCES);

NdisMIndicateReceivePacket(pAdapt->MiniportHandle, &MyPacket,
1);
NdisDprFreePacket(MyPacket);

break;
}
else
{
LOGERROR((“PTReceive:NdisDprAllocatePacket Failed\n”));
}
}
else
{
// TBD
}
} while(FALSE);

return Status;
}

INT
PtReceivePacket(IN NDIS_HANDLE ProtocolBindingContext, IN PNDIS_PACKET
Packet)
{
PADAPT pAdapt =(PADAPT)ProtocolBindingContext;
NDIS_STATUS status;
PNDIS_PACKET myPacket;
PRECV_RSVD recvRsvd;

NdisDprAllocatePacket(&status, &myPacket, pAdapt-
>RecvPacketPoolHandle);
if (status != NDIS_STATUS_SUCCESS)
{
LOGERROR((“PtReceivePacket:NdisDprAllocatePacket Failed,
status=0x%08x\n”,
status));
return(0);
}

// Not shown - Modify existing packet - in newPayload

recvRsvd = (PRECV_RSVD)(MyPacket->MiniportReserved);
recvRsvd->OriginalPkt = Packet;

NdisAllocateBuffer(&status, &pNewNdisBfr, pAdapt-
>RecvBufferPoolHandle,
newPayload, newPktLen);

recvRsvd->newBuffer = TRUE; // Show new
NDIS_BUFFER used.

NdisChainBufferAtFront(MyPacket, pNewNdisBfr);

NDIS_SET_ORIGINAL_PACKET(myPacket, NDIS_GET_ORIGINAL_PACKET(Packet));

NdisGetPacketFlags(myPacket) = NdisGetPacketFlags(Packet);

status = NDIS_GET_PACKET_STATUS(Packet);

NDIS_SET_PACKET_STATUS(myPacket, status);
NDIS_SET_PACKET_HEADER_SIZE(myPacket,

NDIS_GET_PACKET_HEADER_SIZE(Packet));

NdisMIndicateReceivePacket(pAdapt->MiniportHandle, &myPacket, 1);

return((status != NDIS_STATUS_RESOURCES) ? 1 : 0);
}


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Thomas,

What do you mean by “it does not work”?

Please look at the code carefully, and you will see what the OP means - it is obvious that the bound protocols just discard his packet as invalid one…

Please compare passthru sample to the lines that the OP has provided, and you will see that he just copied passthru’s source , but applied a “small” modification to it - he chains a newly allocated buffer to the front of the packet. However, he somehow “forgets” to copy data to it , or to initialize it, or to do at least something with it. Instead, just chains a fresh buffer to the front of his packet… and then just thoughtlessly does everything the way passthru does. How on Earth the bound protocols are expected to react to such “masterpiece”, apart from discarding it???

This is just a classical example of the scenario when someone applies a “modification” to the existing sample without even trying to understand how it actually works, effectively turning a production-grade sample into a piece of crap…

Anton Bassov

I left that part out because it is common with the working path. I
did not want to
send mounds of code. The line // Not shown - Modify existing packet

  • in newPayload
    is where that is done.

At 03:18 PM 8/24/2007, you wrote:

Thomas,

> What do you mean by “it does not work”?

Please look at the code carefully, and you will see what the OP
means - it is obvious that the bound protocols just discard his
packet as invalid one…

Please compare passthru sample to the lines that the OP has
provided, and you will see that he just copied passthru’s source ,
but applied a “small” modification to it - he chains a newly
allocated buffer to the front of the packet. However, he somehow
“forgets” to copy data to it , or to initialize it, or to do at
least something with it. Instead, just chains a fresh buffer to the
front of his packet… and then just thoughtlessly does everything
the way passthru does. How on Earth the bound protocols are expected
to react to such “masterpiece”, apart from discarding it???

This is just a classical example of the scenario when someone
applies a “modification” to the existing sample without even trying
to understand how it actually works, effectively turning a
production-grade sample into a piece of crap…

Anton Bassov


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Sorry for the lack of info. It appears that the original packet is
sent up, not
the modified one. I see no error prints or crashes.

At 11:49 AM 8/24/2007, you wrote:

How about you tell us what it means to not work fine and not have us guess
at what the symptom is :slight_smile:
-dave

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@socket.net
Sent: Friday, August 24, 2007 1:27 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] ProtocolReceivePacket works, ProtocolReceive does not

I have an NDIS IM driver that works fine when ProtocolReceivePacket is
called. However, for adapters that come in through ProtocolReceive, it does
not. I always receive the entire packet. I am modifying the packets and
then sending them on. Here is a condensed version of the code. Any insight
would be appreciated.

NDIS_STATUS
PtReceive(IN NDIS_HANDLE ProtocolBindingContext, IN NDIS_HANDLE
MacReceiveContext,
IN PVOID HeaderBuffer, IN UINT HeaderBufferSize,
IN PVOID LookAheadBuffer, IN UINT
LookAheadBufferSize, IN UINT PacketSize) {
PADAPT pAdapt = (PADAPT)ProtocolBindingContext;
PNDIS_PACKET MyPacket, Packet;
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
PRECV_RSVD recvRsvd;
PNDIS_BUFFER pNewNdisBfr = NULL;

do
{
Packet = NdisGetReceivedPacket(pAdapt->BindingHandle,
MacReceiveContext);
if (Packet != NULL)
{
NdisDprAllocatePacket(&Status, &MyPacket,
pAdapt->RecvPacketPoolHandle);
if (Status == NDIS_STATUS_SUCCESS)
{
// Not shown - Modify existing packet - in newPayload

recvRsvd = (PRECV_RSVD)(MyPacket->MiniportReserved);
recvRsvd->OriginalPkt = Packet;

NdisAllocateBuffer(&status, &pNewNdisBfr,
pAdapt->RecvBufferPoolHandle,
newPayload, newPktLen);

recvRsvd->newBuffer = TRUE; // Show new
NDIS_BUFFER used.

NdisChainBufferAtFront(MyPacket, pNewNdisBfr);

NDIS_SET_ORIGINAL_PACKET(MyPacket,
NDIS_GET_ORIGINAL_PACKET(Packet));
NDIS_SET_PACKET_HEADER_SIZE(MyPacket, HeaderBufferSize);

NdisGetPacketFlags(MyPacket) = NdisGetPacketFlags(Packet);
NDIS_SET_PACKET_STATUS(MyPacket, NDIS_STATUS_RESOURCES);

NdisMIndicateReceivePacket(pAdapt->MiniportHandle, &MyPacket, 1);
NdisDprFreePacket(MyPacket);

break;
}
else
{
LOGERROR((“PTReceive:NdisDprAllocatePacket Failed\n”));
}
}
else
{
// TBD
}
} while(FALSE);

return Status;
}

INT
PtReceivePacket(IN NDIS_HANDLE ProtocolBindingContext, IN PNDIS_PACKET
Packet) {
PADAPT pAdapt =(PADAPT)ProtocolBindingContext;
NDIS_STATUS status;
PNDIS_PACKET myPacket;
PRECV_RSVD recvRsvd;

NdisDprAllocatePacket(&status, &myPacket, pAdapt->RecvPacketPoolHandle);
if (status != NDIS_STATUS_SUCCESS)
{
LOGERROR((“PtReceivePacket:NdisDprAllocatePacket Failed,
status=0x%08x\n”,
status));
return(0);
}

// Not shown - Modify existing packet - in newPayload

recvRsvd = (PRECV_RSVD)(MyPacket->MiniportReserved);
recvRsvd->OriginalPkt = Packet;

NdisAllocateBuffer(&status, &pNewNdisBfr, pAdapt->RecvBufferPoolHandle,
newPayload, newPktLen);

recvRsvd->newBuffer = TRUE; // Show new NDIS_BUFFER
used.

NdisChainBufferAtFront(MyPacket, pNewNdisBfr);

NDIS_SET_ORIGINAL_PACKET(myPacket, NDIS_GET_ORIGINAL_PACKET(Packet));

NdisGetPacketFlags(myPacket) = NdisGetPacketFlags(Packet);

status = NDIS_GET_PACKET_STATUS(Packet);

NDIS_SET_PACKET_STATUS(myPacket, status);
NDIS_SET_PACKET_HEADER_SIZE(myPacket,

NDIS_GET_PACKET_HEADER_SIZE(Packet));

NdisMIndicateReceivePacket(pAdapt->MiniportHandle, &myPacket, 1);

return((status != NDIS_STATUS_RESOURCES) ? 1 : 0); }


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Michael,

Please verify that:

  1. Your modification routine is actually modifying the data.
  2. That the data has been copied to a *new* memory block allocated
    (hopefully!) form Non-Paged Pool and attached to a *new* NDIS_BUFFER (MDL).
  3. That the packet you are indicating has just this NDIS_BUFFER (unless you
    are copying to multiple buffers but that seems unlikely).

I would guess you could set a breakpoint at the point you indicate the
packet and use !ndiskd.pkt to dump the Packet and Buffers to verify it.

Good Luck,
-dave

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Michael Grimes
Sent: Friday, August 24, 2007 7:14 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] ProtocolReceivePacket works, ProtocolReceive does not

Sorry for the lack of info. It appears that the original packet is sent up,
not
the modified one. I see no error prints or crashes.

At 11:49 AM 8/24/2007, you wrote:

How about you tell us what it means to not work fine and not have us
guess at what the symptom is :slight_smile: -dave

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@socket.net
Sent: Friday, August 24, 2007 1:27 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] ProtocolReceivePacket works, ProtocolReceive does not

I have an NDIS IM driver that works fine when ProtocolReceivePacket is
called. However, for adapters that come in through ProtocolReceive, it
does not. I always receive the entire packet. I am modifying the
packets and then sending them on. Here is a condensed version of the
code. Any insight would be appreciated.

NDIS_STATUS
PtReceive(IN NDIS_HANDLE ProtocolBindingContext, IN NDIS_HANDLE
MacReceiveContext,
IN PVOID HeaderBuffer, IN UINT HeaderBufferSize,
IN PVOID LookAheadBuffer, IN UINT
LookAheadBufferSize, IN UINT PacketSize) {
PADAPT pAdapt = (PADAPT)ProtocolBindingContext;
PNDIS_PACKET MyPacket, Packet;
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
PRECV_RSVD recvRsvd;
PNDIS_BUFFER pNewNdisBfr = NULL;

do
{
Packet = NdisGetReceivedPacket(pAdapt->BindingHandle,
MacReceiveContext);
if (Packet != NULL)
{
NdisDprAllocatePacket(&Status, &MyPacket,
pAdapt->RecvPacketPoolHandle);
if (Status == NDIS_STATUS_SUCCESS)
{
// Not shown - Modify existing packet - in newPayload

recvRsvd = (PRECV_RSVD)(MyPacket->MiniportReserved);
recvRsvd->OriginalPkt = Packet;

NdisAllocateBuffer(&status, &pNewNdisBfr,
pAdapt->RecvBufferPoolHandle,
newPayload, newPktLen);

recvRsvd->newBuffer = TRUE; // Show new
NDIS_BUFFER used.

NdisChainBufferAtFront(MyPacket, pNewNdisBfr);

NDIS_SET_ORIGINAL_PACKET(MyPacket,
NDIS_GET_ORIGINAL_PACKET(Packet));
NDIS_SET_PACKET_HEADER_SIZE(MyPacket, HeaderBufferSize);

NdisGetPacketFlags(MyPacket) = NdisGetPacketFlags(Packet);
NDIS_SET_PACKET_STATUS(MyPacket, NDIS_STATUS_RESOURCES);

NdisMIndicateReceivePacket(pAdapt->MiniportHandle, &MyPacket, 1);
NdisDprFreePacket(MyPacket);

break;
}
else
{
LOGERROR((“PTReceive:NdisDprAllocatePacket Failed\n”));
}
}
else
{
// TBD
}
} while(FALSE);

return Status;
}

INT
PtReceivePacket(IN NDIS_HANDLE ProtocolBindingContext, IN PNDIS_PACKET
Packet) {
PADAPT pAdapt =(PADAPT)ProtocolBindingContext;
NDIS_STATUS status;
PNDIS_PACKET myPacket;
PRECV_RSVD recvRsvd;

NdisDprAllocatePacket(&status, &myPacket, pAdapt->RecvPacketPoolHandle);
if (status != NDIS_STATUS_SUCCESS)
{
LOGERROR((“PtReceivePacket:NdisDprAllocatePacket Failed,
status=0x%08x\n”,
status));
return(0);
}

// Not shown - Modify existing packet - in newPayload

recvRsvd = (PRECV_RSVD)(MyPacket->MiniportReserved);
recvRsvd->OriginalPkt = Packet;

NdisAllocateBuffer(&status, &pNewNdisBfr, pAdapt->RecvBufferPoolHandle,
newPayload, newPktLen);

recvRsvd->newBuffer = TRUE; // Show new NDIS_BUFFER
used.

NdisChainBufferAtFront(MyPacket, pNewNdisBfr);

NDIS_SET_ORIGINAL_PACKET(myPacket,
NDIS_GET_ORIGINAL_PACKET(Packet));

NdisGetPacketFlags(myPacket) = NdisGetPacketFlags(Packet);

status = NDIS_GET_PACKET_STATUS(Packet);

NDIS_SET_PACKET_STATUS(myPacket, status);
NDIS_SET_PACKET_HEADER_SIZE(myPacket,

NDIS_GET_PACKET_HEADER_SIZE(Packet));

NdisMIndicateReceivePacket(pAdapt->MiniportHandle, &myPacket, 1);

return((status != NDIS_STATUS_RESOURCES) ? 1 : 0); }


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer