Hi,
I am developing an IM filter driver using NDIS5.1. In protocol receive function, when the call from NdisGetReceivedPacket returns NULL, I am allocating a packet, and copying the data to the buffer that is chained to it but when I indicate the packet using NdisMIndicateReceivePacket, I get a fatal error. Following is the code which I have written when the call from NdisGetReceivedPacket returns NULL. Could anyone please tell me where I have gone wrong. I am new to driver development, I referred some samples and wrote this but still I am not able to fix it. Any help or guidance would be highly appreciated. Thanks in advance!
PNDIS_PACKET pRcvPacket;
//
// The miniport below us uses the old-style (not packet)
// receive indication. Fall through.
//
if (HeaderBufferSize != sizeof(EthHdr))
{
Status = NDIS_STATUS_NOT_ACCEPTED;
break;
}
NdisDprAllocatePacket(&Status, &pRcvPacket, pAdapt->RecvPacketPoolHandle);
if (Status == NDIS_STATUS_SUCCESS)
{
PRECV_RSVD RecvRsvd;
PNDIS_BUFFER pRecvNdisBfr;
PUCHAR pRcvData = NULL;
NdisAllocateMemoryWithTag(&pRcvData, PacketSize + HeaderBufferSize, TAG);
NdisAllocateBuffer(&Status, &pRecvNdisBfr, pAdapt->hRecvBufferPool, pRcvData, PacketSize + HeaderBufferSize);
if (NDIS_STATUS_SUCCESS!=Status)
{
ASSERT(0);
}
NdisChainBufferAtFront(pRcvPacket, pRecvNdisBfr);
NDIS_SET_PACKET_STATUS(pRcvPacket, 0);
if (pRcvPacket == NULL)
{
if (pRcvData != NULL)
{
NdisFreeMemory(pRcvData, PacketSize + HeaderBufferSize, 0);
pRcvData = NULL;
}
if (pRecvNdisBfr != NULL)
{
NdisFreeBuffer(pRecvNdisBfr);
}
}
NdisMoveMemory(pRcvData, HeaderBuffer, HeaderBufferSize);
if (PacketSize <= LookAheadBufferSize)
{
NdisMoveMemory(pRcvData + HeaderBufferSize, LookAheadBuffer, LookAheadBufferSize);
pRcvPacket->Private.Head->Next = NULL;
pRcvPacket->Private.Tail = NULL;
RecvRsvd = (PRECV_RSVD)(pRcvPacket->MiniportReserved);
RecvRsvd->OriginalPkt = NULL;
NDIS_SET_PACKET_HEADER_SIZE(pRcvPacket, HeaderBufferSize);
NdisMIndicateReceivePacket(pAdapt->MiniportHandle, &pRcvPacket, 1);
if(NDIS_GET_PACKET_STATUS(pRcvPacket) != NDIS_STATUS_PENDING)
{
NdisFreeBuffer(pRecvNdisBfr);
NdisFreeMemory(pRcvData, PacketSize + HeaderBufferSize, 0);
NdisDprFreePacket(pRcvPacket);
}
}
With Regards,
Subashini
DISCLAIMER:
The contents of this e-mail and any attachment(s) are confidential and intended for the named recipient(s) only.
It shall not attach any liability on the originator or HCL or its affiliates. Any views or opinions presented in
this email are solely those of the author and may not necessarily reflect the opinions of HCL or its affiliates.
Any form of reproduction, dissemination, copying, disclosure, modification, distribution and / or publication of
this message without the prior written consent of the author of this e-mail is strictly prohibited. If you have
received this email in error please delete it and notify the sender immediately. Before opening any mail and
attachments please check them for viruses and defect.