阅读:1803回复:10
passthru--PtReceive源码+++请教!!高分!!
Protocol设备由于处在中间驱动程序的下方,所以重点处理封包的接收。Miniport提供的标准接口函数有ProtocolReceive和ProtocolReceivePacket.
Protocol设备主要利用这两个函数来完成数据封包的接收操作。 请问怎么检查数据包的内容呢? 怎么把不合要求的包丢弃呢?请赐教!! 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; //----------------------------------------------------------------------------------- // 输出封包结构信息 // DBGPRINT(\"==> Passthru Protocol PtReceive\\n\"); DbgPrint(\" CurrentAdapterHandle: %u\\n\", ProtocolBindingContext); DbgPrint(\" MacReceiveHandle: %u\\n\", MacReceiveContext); DbgPrint(\" HeaderBufferPointer: %u\\n\", HeaderBuffer); DbgPrint(\" HeaderBufferSize: %u\\n\", HeaderBufferSize); DbgPrint(\" LookAheadBufferPointer: %u\\n\", LookAheadBuffer); DbgPrint(\" LookAheadBufferSize: %u\\n\", LookAheadBufferSize); DbgPrint(\" PacketSize: %u\\n\", PacketSize); if(!pAdapt->MiniportHandle) { Status = NDIS_STATUS_FAILURE; } else do { //----------------------------------------------------------------------------------- // 不应用第二设备接收数据 // if(pAdapt->isSecondary) { DBGPRINT(\"PASSTHRU GETTING RECIEVES ON SECONDARY\\n\"); ASSERT(0); } //------------------------------------------------------------------------ // 得到用来接收数据的Packet缓冲区 // Packet = NdisGetReceivedPacket(pAdapt->BindingHandle, MacReceiveContext); //------------------------------------------------------------------------ //如果成功地返回Packet,则重新封包并保存到MyPacket中,然后接收封包数据 // if(Packet != NULL) { DBGPRINT(\"==> Passthru Protocol PtReceive RePacket...\\n\"); NdisDprAllocatePacket(&Status , &MyPacket, pAdapt->RecvPacketPoolHandle); if(Status == NDIS_STATUS_SUCCESS) { MyPacket->Private.Head = Packet->Private.Head; MyPacket->Private.Tail = Packet->Private.Tail; //--------------------//------------------------------------------------------------------------ // 设置封包属性 // NDIS_SET_ORIGINAL_PACKET( MyPacket, NDIS_GET_ORIGINAL_PACKET(Packet)); NDIS_SET_PACKET_HEADER_SIZE(MyPacket, HeaderBufferSize); //--------------------//------------------------------------------------------------------------ // 设置封包状态 // NdisGetPacketFlags(MyPacket) = NdisGetPacketFlags(Packet); //--------------------//------------------------------------------------------------------------ // 确认状态,设置成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); ----------------------//------------------------------------------------------------------------ // 输出封包信息 // PrintPacket(MyPacket); NdisDprFreePacket(MyPacket); DBGPRINT(\"<== Passthru Protocol PtReceive RePacket Success...\\n\"); break; } } -----------//------------------------------------------------------------------------ // 如果没有成功地返回Packet或重新封包失败,则根据不同的介质调用 ----------// 不同的系统函数来接收数据封包 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); DBGPRINT(\"<== Passthru Protocol PtReceive\\n\"); return Status; } |
|
|
沙发#
发布于:2003-06-02 16:43
内行人请指教,外行和新手无扰!!多谢!
|
|
|
板凳#
发布于:2003-06-02 18:03
看我的noname防火墙吧,有示范的。
|
|
地板#
发布于:2003-06-02 18:07
又在骗小朋友了~
|
|
地下室#
发布于:2003-06-02 18:25
phoebus:
哎!这位小朋友,怎么这么喜欢捣乱呀! 还请去回去完完三国吧,很好玩的,也很简单的,还可以让你了解历史,甚至修改历史。 快去吧!! |
|
|
5楼#
发布于:2003-06-02 18:30
又在骗小朋友了~ 同意ing |
|
|
6楼#
发布于:2003-06-02 18:32
phoebus: 好啊好啊,不过我没有 你有吧,mail我一份 我的幽香是****@****.com :D |
|
7楼#
发布于:2003-06-02 18:34
那很想听听mikeluo的高论,请: |
|
|
8楼#
发布于:2003-06-02 18:35
有!!
很愿意效劳!! 阁下的邮箱是什么? |
|
|
9楼#
发布于:2003-06-02 18:36
phoebus :
有!! 很愿意效劳!! 阁下的邮箱是什么? |
|
|
10楼#
发布于:2003-06-02 19:09
phoebus : 霍霍,你还真是好心人,那就不逗你玩了 :D |
|