cyk119
驱动牛犊
驱动牛犊
  • 注册日期2005-07-12
  • 最后登录2010-10-01
  • 粉丝0
  • 关注0
  • 积分2分
  • 威望14点
  • 贡献值0点
  • 好评度8点
  • 原创分0分
  • 专家分0分
阅读:2127回复:7

Passthru中为什么要不直接把Packet发送或接收,而另外再建一个MyPacket用来发送和接收?

楼主#
更多 发布于:2005-08-05 13:28
  Passthru中为什么要不直接把Packet发送或接收,而另外再建一个MyPacket用来发送和接收?
另外NDIS_SET_ORIGINAL_PACKET、NDIS_SET_PACKET_STATUS、NDIS_SET_PACKET_HEADER_SIZE这三个函数都分别起什么作用?我看了半天MSDN也没明白是什么意思。我是个新手,还望斑竹和各位牛人不吝赐教!
cyk119
驱动牛犊
驱动牛犊
  • 注册日期2005-07-12
  • 最后登录2010-10-01
  • 粉丝0
  • 关注0
  • 积分2分
  • 威望14点
  • 贡献值0点
  • 好评度8点
  • 原创分0分
  • 专家分0分
沙发#
发布于:2005-08-05 16:21
谁来救救我呀?
asmsys
驱动老牛
驱动老牛
  • 注册日期2002-03-29
  • 最后登录2016-01-09
  • 粉丝0
  • 关注0
  • 积分5分
  • 威望17点
  • 贡献值0点
  • 好评度8点
  • 原创分0分
  • 专家分0分
板凳#
发布于:2005-08-05 18:22
MS为我们程序员尽可能做更多的事情呀。
完全可以直接发,但是我们处理包的时候就要多加几行了。
zhang_jiaqi
驱动小牛
驱动小牛
  • 注册日期2002-05-17
  • 最后登录2006-05-25
  • 粉丝0
  • 关注0
  • 积分164分
  • 威望22点
  • 贡献值0点
  • 好评度5点
  • 原创分0分
  • 专家分0分
地板#
发布于:2005-08-05 20:58
下面是引用asmsys于2005-08-05 18:22发表的:
MS为我们程序员尽可能做更多的事情呀。
完全可以直接发,但是我们处理包的时候就要多加几行了。

我还是毕业前看过passthru,记得如此就是为了方便我们处理包
毛主席语录:看看它的过去和现在,就知道它的将来。
rangzh
驱动小牛
驱动小牛
  • 注册日期2005-04-24
  • 最后登录2016-01-09
  • 粉丝0
  • 关注0
  • 积分8分
  • 威望150点
  • 贡献值0点
  • 好评度115点
  • 原创分0分
  • 专家分0分
地下室#
发布于: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.
shenhui
驱动小牛
驱动小牛
  • 注册日期2006-05-11
  • 最后登录2023-02-10
  • 粉丝14
  • 关注11
  • 积分142分
  • 威望1314点
  • 贡献值1点
  • 好评度146点
  • 原创分0分
  • 专家分1分
  • 社区居民
5楼#
发布于:2007-02-01 11:12
感觉微软这样做的另一个目的就是便于管理所分配的内存,哪一层申请的内存还由哪一层来释放。
作一名真实,诚实,优秀的科技工作者!
ajy
ajy
驱动牛犊
驱动牛犊
  • 注册日期2002-07-09
  • 最后登录2012-12-12
  • 粉丝0
  • 关注0
  • 积分101分
  • 威望20点
  • 贡献值0点
  • 好评度10点
  • 原创分0分
  • 专家分0分
6楼#
发布于:2007-02-05 01:28
原因很简单,因为某些情况下你并没有收到完整的包,或包堆栈已满,或其它情况, 这时你就必须构造一个新PACKET然后上指;
但也有直接上指这些包的时候, 这在passthru里的ptreceive和ptreceivepacket的某些情况下都使用了.
killerzhu
驱动牛犊
驱动牛犊
  • 注册日期2007-05-01
  • 最后登录2007-09-28
  • 粉丝0
  • 关注0
  • 积分50分
  • 威望6点
  • 贡献值0点
  • 好评度5点
  • 原创分0分
  • 专家分0分
7楼#
发布于:2007-05-07 13:51
直接用Packet会蓝屏,而用MyPacket则不会蓝屏,不懂原因。。。。。。
游客

返回顶部