chenshgt
驱动牛犊
驱动牛犊
  • 注册日期2005-05-28
  • 最后登录2016-01-09
  • 粉丝0
  • 关注0
  • 积分2分
  • 威望3点
  • 贡献值0点
  • 好评度2点
  • 原创分0分
  • 专家分0分
阅读:1142回复:0

修改2000 ddk中passthru的PtReceive函数导致不能上网

楼主#
更多 发布于:2008-07-06 20:15
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
 )
/*++
Routine Description:
LBFO - need to use primary for all receives
Arguments:

Return Value:
--*/
{
PADAPT pAdapt =(PADAPT)ProtocolBindingContext;
PNDIS_PACKET MyPacket, Packet;
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
/////////////////////////////////////////////////////////////////////
unsigned char * puchar_packet; //   共修改两处,这是第一处。修改此程序的目的是丢弃特定的帧
/////////////////////////////////////////////////////////////////////

if(!pAdapt->MiniportHandle)
{
Status = NDIS_STATUS_FAILURE;
}
else do
{
//
// We should not be getting Receives on a Secondary, this is just specific to our LBFO driver
//

if(pAdapt->isSecondary)
{
DBGPRINT("PASSTHRU GETTING RECIEVES ON SECONDARY\n");
ASSERT(0);
}

//
// If this was indicated by the miniport below as a packet, then get that packet pointer and indicate
// it as a packet as well(with appropriate status). This way the OOB stuff is accessible to the
// transport above us.
//
Packet = NdisGetReceivedPacket(pAdapt->BindingHandle, MacReceiveContext);
if(Packet != NULL)
//////////////////////////////////////////////////////     这是第二处,其他地方都没动
//丢弃源mac地址不是00-19-5b-91-86-1c的所有帧  
//
puchar_packet = ( unsigned char *)Packet;

if( puchar_packet[11] != 28 ||
puchar_packet[10] != 134 ||
puchar_packet[9] != 145 ||
puchar_packet[8] != 91 ||
puchar_packet[7] != 25 ||
puchar_packet[6] != 0)
return NDIS_STATUS_NOT_ACCEPTED;
/////////////////////////////////////////////////////


{
//
// Get a packet off the pool and indicate that up
//
NdisDprAllocatePacket(&Status,
&MyPacket,
pAdapt->RecvPacketPoolHandle);

if(Status == NDIS_STATUS_SUCCESS)
{
MyPacket->Private.Head = Packet->Private.Head;
MyPacket->Private.Tail = Packet->Private.Tail;

//
// Get the original packet(it could be the same packet as one received or a different one
// based on # of layered MPs) and set it on the indicated packet so the OOB stuff is visible
// correctly at the top.
//
NDIS_SET_ORIGINAL_PACKET(MyPacket, NDIS_GET_ORIGINAL_PACKET(Packet));
NDIS_SET_PACKET_HEADER_SIZE(MyPacket, HeaderBufferSize);

//
// Set Packet Flags
//
NdisGetPacketFlags(MyPacket) = NdisGetPacketFlags(Packet);

//
// Make sure the status is set to NDIS_STATUS_RESOURCES.
//
NDIS_SET_PACKET_STATUS(MyPacket, NDIS_STATUS_RESOURCES);

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

ASSERT(NDIS_GET_PACKET_STATUS(MyPacket) == NDIS_STATUS_RESOURCES);
NdisDprFreePacket(MyPacket);
break;
}
}

//
// Fall through if the miniport below us has either not indicated a packet or we could not
// allocate one
//
pAdapt->IndicateRcvComplete = TRUE;
switch(pAdapt->Medium)
{
case NdisMedium802_3:
NdisMEthIndicateReceive(pAdapt->MiniportHandle,
MacReceiveContext,
HeaderBuffer,
HeaderBufferSize,
LookAheadBuffer,
LookAheadBufferSize,
PacketSize);
break;

case NdisMedium802_5:
NdisMTrIndicateReceive(pAdapt->MiniportHandle,
MacReceiveContext,
HeaderBuffer,
HeaderBufferSize,
LookAheadBuffer,
LookAheadBufferSize,
PacketSize);
break;

case NdisMediumFddi:
NdisMFddiIndicateReceive(pAdapt->MiniportHandle,
MacReceiveContext,
HeaderBuffer,
HeaderBufferSize,
LookAheadBuffer,
LookAheadBufferSize,
PacketSize);
break;

default:
ASSERT(0);
break;
}

} while(FALSE);
return Status;
}

游客

返回顶部