Dropping a packet in a DriverNetworks NDIS intermediate driver

0 Likes

Problem:

In my intermediate driver OnReceive(const KNdisPacket& Original, KNdisPacket& Repackaged) function, I want to drop a packet by returning NDIS_STATUS_NOT_ACCEPTED. However the driver will eventually crashes my system. Why?

Resolution:

This is an confirmed bug in DriverNetworks framework. To workaround this problem, return NDIS_STATUS_FAILURE instead of NDIS_STATUS_NOT_ACCEPTED. The following is an example:

NDIS_STATUS myIMAdapter::OnReceive 
(const KNdisPacket& Original, KNdisPacket& Repackaged) 
{ struct EthHdr 
{ 
unsigned char DstDevil; 
unsigned char SrcDevil; 
unsigned short Prot; 
} *Eth; 
int Prot = 0; 
KNdisBuffer Buf; 
Buf = Original.QueryFirstBuffer(); 
if(Buf.IsValid()) 
{ 
Eth = (EthHdr *)Buf.Address(); 
if(Eth) 
{ 
Prot = Eth->Prot; 
if (Prot == 0x88) 
{ 
return NDIS_STATUS_FAILURE; 
} 
} 
} 
Repackaged.CloneUp(Original); 
return NDIS_STATUS_SUCCESS; 
} 
Old KB# 11053
Comment List
Anonymous
Related Discussions
Recommended