Hello All,
I am trying to do a “customized mac bridge” between two lans.I
started with LWF of DDK. My project is like this. I have virtual lan
device (used from DDK).and two NIC’s on the same machine. Every
packet you receive on these two nics should be sent to Virtual NIC as
a copy.
So in the FilterReceivenetBufferlists I am cloning the each packet and
sending it to the Virtual Miniport. I have attached my function here.
But the problem I am facing is the whenever i try to file transfer or
big network load receive ,network connection is just disconnected.but
with smaller ping traffics it just works fine.After the drop of
connection I need to restart the machine(it doesn’t hang) to start the
network.
Can anybody suggest me what must be happening? I think there is some
problem with freeing the clone buffer list.What will be best place to
free this buffer?
///
…
//////////
do
{
DispatchLevel = NDIS_TEST_RECEIVE_AT_DISPATCH_LEVEL(ReceiveFlags);
ASSERT(NumberOfNetBufferLists >= 1);
{
CurrNbl = NetBufferLists;
while (CurrNbl)
{
DbgPrint(" RecvNetBufferList: CurrNbl = %p\n",
CurrNbl);
if(g_bIsVirtual==FALSE)
{
ClonedList=NdisAllocateCloneNetBufferList(CurrNbl,0,0,0);
Status =
NdisAllocateNetBufferListContext(ClonedList,sizeof(IM_NBL_ENTRY), 0,
FILTER_TAG);
if (Status != NDIS_STATUS_SUCCESS)
{
NdisFreeCloneNetBufferList(ClonedList,0);
}
else
{
CloneRecvContext = (PIM_NBL_ENTRY)
NET_BUFFER_LIST_CONTEXT_DATA_START(ClonedList);
NdisZeroMemory(CloneRecvContext, sizeof(IM_NBL_ENTRY));
// SendContext->PreviousSourceHandle =
CurrNbl->SourceHandle;
CloneRecvContext->pFilter = gpVirtual;
ClonetFilter = gpVirtual;
NdisFIndicateReceiveNetBufferLists(
ClonetFilter->FilterHandle,
ClonedList,
PortNumber,
1,
ReceiveFlags);
//NdisFreeCloneNetBufferList(ClonedList,0);
}
}//End of checking whether it is virtual or not.
/*CHEATING END*/
NetBufferLists = NET_BUFFER_LIST_NEXT_NBL(CurrNbl);
NET_BUFFER_LIST_NEXT_NBL(CurrNbl) = NULL;
{
NET_BUFFER *pNB = NET_BUFFER_LIST_FIRST_NB(CurrNbl);
DbgPrint(" Data Length:%d\n",
NET_BUFFER_DATA_LENGTH(pNB));
pEthFrame = NdisGetDataBuffer(pNB, 14, NULL, 1, 0);
}
Status = NdisAllocateNetBufferListContext(CurrNbl,
sizeof(IM_NBL_ENTRY), 0, FILTER_TAG);
if (Status != NDIS_STATUS_SUCCESS)
{
NdisFReturnNetBufferLists(
pFilter->FilterHandle, CurrNbl,
DispatchLevel ?
NDIS_SEND_COMPLETE_FLAGS_DISPATCH_LEVEL : 0);
}
else
{
RecvContext = (PIM_NBL_ENTRY)
NET_BUFFER_LIST_CONTEXT_DATA_START(CurrNbl);
NdisZeroMemory(RecvContext, sizeof(IM_NBL_ENTRY));
// SendContext->PreviousSourceHandle =
CurrNbl->SourceHandle;
RecvContext->pFilter = pFilter;
tFilter = pFilter;
DbgPrint(" toVNIC:%d\n", toVNIC);
}
DbgPrint(" LWF==>%c%c TCPIP==>%c%c\n",
pFilter->MiniportFriendlyName.Buffer[13],
pFilter->MiniportFriendlyName.Buffer[14],
tFilter->MiniportFriendlyName.Buffer[13],
tFilter->MiniportFriendlyName.Buffer[14]);
NdisFIndicateReceiveNetBufferLists(
tFilter->FilterHandle,
CurrNbl,
PortNumber,
1,
ReceiveFlags);
}
CurrNbl = NetBufferLists;
}
}
} while (FALSE);
–
Thanks
Abhijeet Kolekar