阅读:2127回复:7
Passthru中为什么要不直接把Packet发送或接收,而另外再建一个MyPacket用来发送和接收?
Passthru中为什么要不直接把Packet发送或接收,而另外再建一个MyPacket用来发送和接收?
另外NDIS_SET_ORIGINAL_PACKET、NDIS_SET_PACKET_STATUS、NDIS_SET_PACKET_HEADER_SIZE这三个函数都分别起什么作用?我看了半天MSDN也没明白是什么意思。我是个新手,还望斑竹和各位牛人不吝赐教! |
|
沙发#
发布于:2005-08-05 16:21
谁来救救我呀?
|
|
板凳#
发布于:2005-08-05 18:22
MS为我们程序员尽可能做更多的事情呀。
完全可以直接发,但是我们处理包的时候就要多加几行了。 |
|
地板#
发布于:2005-08-05 20:58
下面是引用asmsys于2005-08-05 18:22发表的: 我还是毕业前看过passthru,记得如此就是为了方便我们处理包 |
|
|
地下室#
发布于:2007-01-10 23:22
NDIS4.0及5.0中的中间层驱动必须分配新的包描述符,即使不对包做任何修改(如同Passthru那样)。NDIS5.1支持Packet stack方式
看DDK的说明: NDIS 4.0 and 5.0 intermediate drivers must allocate a new NDIS_PACKET to encapsulate data that they pass on. These intermediate drivers must also copy any out-of-band (OOB) data to the new packet. Even if the intermediate driver does nothing other than simply pass on incoming packets — for example, if it simply counts the packets — it must allocate a fresh packet descriptor and manage some or all of a new packet structure. NDIS 5.1 intermediate drivers that support packet stacking avoid this extra data handling in most common cases. Each NDIS_PACKET allocated includes "stacks", where each stack is defined as: typedef struct _NDIS_PACKET_STACK { ULONG_PTR IMReserved[2]; ULONG_PTR NdisReserved[4]; } NDIS_PACKET_STACK, *PNDIS_PACKET_STACK; NDIS 5.1 intermediate drivers call the NdisIMGetCurrentPacketStack function to access the IMReserved member in the NDIS_PACKET_STACK structure. This member can be used by an NDIS 5.1 intermediate driver to store its context information, if any, for the packet. NDIS 4.0 and 5.0 intermediate drivers use the ProtocolReserved and MiniportReserved members, for sent and received packets, in the NDIS_PACKET structure. If a call to NdisIMGetCurrentPacketStack indicates *StacksRemaining is FALSE, the NDIS 5.1 intermediate driver must revert to the NDIS 5.0 packet handling model. Every NDIS 4.0 and 5.0 intermediate driver must allocate new packet descriptors to replace those of the overlying driver. If an intermediate driver converts the packet from one format to another, it also can allocate buffer descriptors to map intermediate-allocated buffers into which the converted data is copied. If there is OOB data associated with the packet descriptor being copied, this data can be copied to the new OOB block associated with the intermediate-allocated packet descriptor, using the macro NDIS_OOB_DATA_FROM_PACKET, to obtain a pointer to the OOB data area and, then, calling NdisMoveMemory to move the contents into the OOB area associated with the new packet descriptor. Alternatively, such an intermediate driver can use the NDIS_GET_PACKET_XXX and NDIS_SET_PACKET_XXX macros to read specific items from the OOB data associated with the old packet descriptor and to write the OOB data for the new packet descriptor. |
|
5楼#
发布于:2007-02-01 11:12
感觉微软这样做的另一个目的就是便于管理所分配的内存,哪一层申请的内存还由哪一层来释放。
|
|
|
6楼#
发布于:2007-02-05 01:28
原因很简单,因为某些情况下你并没有收到完整的包,或包堆栈已满,或其它情况, 这时你就必须构造一个新PACKET然后上指;
但也有直接上指这些包的时候, 这在passthru里的ptreceive和ptreceivepacket的某些情况下都使用了. |
|
7楼#
发布于:2007-05-07 13:51
直接用Packet会蓝屏,而用MyPacket则不会蓝屏,不懂原因。。。。。。
|
|