NDIS发送网络数据

来源:互联网 发布:开淘宝店自己没有货 编辑:程序博客网 时间:2024/06/03 15:03

辛苦翻译,可以转载,注明来源即可!如有错误之处望留言指出,谢谢了!


Sending Network Data
发送网络数据


The following figure illustrates a basic send operation, which involves a protocol driver, NDIS, and a miniport driver.

下图说明了一个基本的发送操作,这涉及到协议驱动,NDIS,和小端口驱动。

Protocol drivers call the NdisSendNetBufferLists function to send NET_BUFFER_LIST structures on a binding. NDIS calls the miniport driver's MiniportSendNetBufferLists function to forward the NET_BUFFER_LIST structures to an underlying miniport driver.

协议驱动在一个绑定上调用NdisSendNetBufferLists函数以发送NET_BUFFER_LIST。NDIS调用小端口驱动的MiniportSendNetBufferLists回调函数以转发NET_BUFFER_LIST到下层的小端口驱动。

All NET_BUFFER-based send operations are asynchronous. The miniport driver calls the NdisMSendNetBufferListsComplete function with an appropriate status code when it is done. The sending of each NET_BUFFER_LIST structure can be completed individually. NDIS calls the protocol driver's ProtocolSendNetBufferListsComplete function each time the miniport driver calls NdisMSendNetBufferListsComplete.

所有基于NET_BUFFER的发送操作都是异步的。当小端口驱动处理完毕后,会调用NdisMSendNetBufferListsComplete函数并附上适当的状态码。每个NET_BUFFER_LIST的发送可以分别地完成。每当小端口驱动调用NdisMSendNetBufferListsComplete时,NDIS就会调用协议驱动的ProtocolSendNetBufferListsComplete回调函数。

Protocol drivers can reclaim the ownership of the NET_BUFFER_LIST structures and all associated structures and data as soon as the NDIS calls the protocol driver's ProtocolSendNetBufferListsComplete function.

一旦NDIS调用协议驱动的ProtocolSendNetBufferListsComplete回调函数,协议驱动就可以收回NET_BUFFER_LIST和所有关联结构体和数据的控制权。

The miniport driver or NDIS can return the NET_BUFFER_LIST structures in any order. Protocol drivers are guaranteed that the list of NET_BUFFER structures attached to each NET_BUFFER_LIST structure has not been modified.

小端口驱动或NDIS允许以任意顺序返回NET_BUFFER_LIST。协议驱动要保证链接到每个NET_BUFFER_LIST中的NET_BUFFER列表不被修改。(译注:当然,修改后再恢复原样也是可以的)

Any NDIS driver can separate the NET_BUFFER structures in a NET_BUFFER_LIST structure. Any NDIS driver can also separate the MDLs in a NET_BUFFER structure. However, the driver must always return the NET_BUFFER_LIST structures with the NET_BUFFER structures and MDLs in the original form. For example, an intermediate driver might separate a NET_BUFFER_LIST into two new NET_BUFFER_LIST structures and pass on part of the original data to the next driver. However, when the intermediate driver completes the processing of the original NET_BUFFER_LIST it must return the complete NET_BUFFER_LIST with the original NET_BUFFER structures and MDLs.

任何NDIS驱动(译注:如协议驱动,过滤驱动,小端口驱动等NDIS驱动)可以分离NET_BUFFER_LIST中的NET_BUFFER,也可以分离NET_BUFFER中的MDL。但是,驱动必须要返还带有NET_BUFFER和MDL的原始结构的NET_BUFFER_LIST。例如,中间层驱动可能分离了一个NET_BUFFER_LIST到两个新的NET_BUFFER_LIST中,并且转发了原始数据的一部分到下一驱动。但是,当中间层驱动完成对原始NET_BUFFER_LIST的处理后必须返还带有原始NET_BUFFER和MDL的NET_BUFFER_LIST。

Protocol drivers set the SourceHandle member in the NET_BUFFER_LIST structure to the NdisBindingHandle that NDIS provided in a call to the NdisOpenAdapterEx function. NDIS uses the SourceHandle member to return the NET_BUFFER_LIST structures to the protocol driver that sent the NET_BUFFER_LIST structures.

协议驱动设置NET_BUFFER_LIST的SourceHandle成员为NdisBindingHandle(调用NdisOpenAdapterEx函数得到的)。NDIS使用SourceHandle成员以返还NET_BUFFER_LIST给发送它的协议驱动。

Intermediate drivers also set the SourceHandle member in the NET_BUFFER_LIST structure to the NdisBindingHandle value that NDIS provided in a call to NdisOpenAdapterEx. If an intermediate driver forwards a send request, the driver must save the SourceHandle value that the overlying driver provided before it writes to the SourceHandle member. When NDIS returns a forwarded NET_BUFFER_LIST structure to the intermediate driver, the intermediate driver must restore the SourceHandle that it saved.

中间层驱动同样设置NET_BUFFER_LIST的SourceHandle成员为NdisBindingHandle。如果中间层驱动转发一个发送请求,那么它在写入SourceHandle成员之前必须保存既有的SourceHandle。当NDIS返还这个转发的NET_BUFFER_LIST给中间层驱动时,中间层驱动必须恢复SourceHandle为之前保存的值。



英文原文地址: https://docs.microsoft.com/zh-cn/windows-hardware/drivers/network/sending-network-data

阅读全文
0 0
原创粉丝点击