NDIS数据包环回
原创翻译,欢迎转载,转载时请注明来源。
Looping Back NDIS Packets
NDIS数据包环回
If the NDIS_NBL_FLAGS_IS_LOOPBACK_PACKET flag in the NblFlags member of the NET_BUFFER_LISTstructure is set, the packet is a loopback packet. Protocol drivers and filter drivers can check this flag to determine if a packet is a loopback packet.
如果置位了NET_BUFFER_LIST结构体中的NblFlags成员的NDIS_NBL_FLAGS_IS_LOOPBACK_PACKET标志,那么这个包是一个loopback包。协议驱动和过滤驱动可以检查这个标志来判断数据包是不是一个loopback包。
NDIS loops packets back if all of the following three conditions are satisfied:
如果以下三个条件全部满足,NDIS会环回这个包:
-
The underlying miniport adapter media type is NdisMedium802_3 or NdisMedium802_5.
下层小端口适配器媒体类型为NdisMedium802_3或NdisMedium802_5 -
Any one of the following three conditions is satisfied:
满足以下三个(a,b,c)条件其中之一:-
A protocol binding set the NDIS_PACKET_TYPE_PROMISCUOUS setting with the OID_GEN_CURRENT_PACKET_FILTER OID to specify its packet filter (and, for Windows 8 and later, did not set NDIS_PACKET_TYPE_NO_LOCAL in the same OID) and either of the following is true:
一个协议绑定,通过OID_GEN_CURRENT_PACKET_FILTER设置NDIS_PACKET_TYPE_PROMISCUOUS来指定包过滤器(在Windows8和之后版本中,不能通过这个OID来设置NDIS_PACKET_TYPE_NO_LOCAL),并且以下两个条件之一为TRUE:- There is more than one binding to the miniport adapter.
有多于一个绑定,到小端口适配器上。
- There is a filter module attached to the miniport adapter and the filter module registered a receive handler.
有过滤模块附加到小端口适配器上并且过滤模块注册了接收处理函数。
- There is more than one binding to the miniport adapter.
-
A protocol binding set the NDIS_PACKET_TYPE_ALL_LOCAL setting with the OID_GEN_CURRENT_PACKET_FILTER OID to specify its packet filter and either of the following is true.
一个协议驱动绑定,通过OID_GEN_CURRENT_PACKET_FILTER设置NDIS_PACKET_TYPE_ALL_LOCAL来指定包过滤器,并且以下两个条件之一为TRUE:- There is more than one binding to the miniport adapter.
有多于一个绑定,到小端口适配器上。
- There is a filter module attached to the miniport adapter and the filter module registered a receive handler.
有过滤模块附加到小端口适配器上并且过滤模块注册了接收处理函数。
- There is more than one binding to the miniport adapter.
-
The caller sets the NDIS_SEND_FLAGS_CHECK_FOR_LOOPBACK flag in the SendFlags parameter of the NdisSendNetBufferLists function.
调用者在调用NdisSendNetBufferLists函数时置位了的SendFlags参数中的NDIS_SEND_FLAGS_CHECK_FOR_LOOPBACK标志。
-
-
The packet is acceptable as determined by the packet filter set with the OID_GEN_CURRENT_PACKET_FILTER OID for the miniport adapter. The following are some examples:
根据通过OID_GEN_CURRENT_PACKET_FILTER为小端口适配器设置的包过滤器判断数据包是可接受的。举例如下:- If the packet is a direct packet, the destination address in the packet must match the MAC address of the miniport adapter.
如果是一个单播包,包中目标地址必须和小端口适配器的MAC地址相符。
- If the packet is a multicast packet, the packet filter must have NDIS_PACKET_TYPE_ALL_MULTICAST set or the destination address matches one of the multicast address in the miniport adapter's multicast address list and
the packet filter has NDIS_PACKET_TYPE_MULTICAST set.
如果是一个多播包,包过滤器必须设置了NDIS_PACKET_TYPE_ALL_MULTICAST,或者目标地址和小端口适配器的多播地址列表中的一个相符且包过滤器设置了NDIS_PACKET_TYPE_MULTICAST。
- If the packet is a broadcast packet, the miniport adapter's packet filter must haveNDIS_PACKET_TYPE_BROADCAST set.
如果是一个广播包,小端口适配器的包过滤器必须设置了NDIS_PACKET_TYPE_BROADCAST。
- The miniport adapter's packet filter has NDIS_PACKET_TYPE_PROMISCUOUS or NDIS_PACKET_TYPE_ALL_LOCAL set.
小端口适配器的包过滤器设置了NDIS_PACKET_TYPE_PROMISCUOUS或NDIS_PACKET_TYPE_ALL_LOCAL 。
- If the packet is a direct packet, the destination address in the packet must match the MAC address of the miniport adapter.
A protocol binding receives loopback packets if either of the following is true:
如果下列两个条件之一为TRUE,协议绑定将接收环回包:
-
The protocol binding is the original sender of the packet and NDIS_SEND_FLAGS_CHECK_FOR_LOOPBACK is set.
协议绑定是包的原始发送者,并且置位了NDIS_SEND_FLAGS_CHECK_FOR_LOOPBACK。 -
The protocol binding does not set NDIS_PACKET_TYPE_NO_LOCAL in the packet filter.
协议绑定未设置包过滤器的NDIS_PACKET_TYPE_NO_LOCAL标志。
A protocol binding will not receive loopback packets if either of the following is true:
如果以下两个条件之一为TRUE,协议绑定将不会接收环回包:
-
The protocol binding sets NDIS_PACKET_TYPE_NO_LOCAL in the packet filter and it is not the original sender for the packet.
协议绑定设置了包过滤器的NDIS_PACKET_TYPE_NO_LOCAL标志,并且不是包的原始发送者。 -
The protocol binding is the original sender but NDIS_SEND_FLAGS_CHECK_FOR_LOOPBACK is not set in the SendFlags parameter in a call to the NdisSendNetBufferLists function.
协议绑定是包的原始发送者,但调用NdisSendNetBufferLists函数时未置位SendFlags参数的NDIS_SEND_FLAGS_CHECK_FOR_LOOPBACK标志。
The following figure shows the loopback algorithm logic flow.
下图描述了环回算法的逻辑流程:
英文原文地址: https://docs.microsoft.com/zh-cn/windows-hardware/drivers/network/looping-back-ndis-packets