Looping Back NDIS Packets
If the NDIS_NBL_FLAGS_IS_LOOPBACK_PACKET flag in the NblFlags member of the NET_BUFFER_LIST structure 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.
NDIS loops packets back if all of the following three conditions are satisfied:
The underlying miniport adapter media type is NdisMedium802_3 or NdisMedium802_5.
Any one of the following three conditions is satisfied:
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:
- 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.
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.
- 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.
The caller sets the NDIS_SEND_FLAGS_CHECK_FOR_LOOPBACK flag in the SendFlags parameter of the NdisSendNetBufferLists function.
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:
- If the packet is a direct packet, the destination address in the packet must match the MAC address of the miniport adapter.
- 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.
- If the packet is a broadcast packet, the miniport adapter's packet filter must have NDIS_PACKET_TYPE_BROADCAST set.
- The miniport adapter's packet filter has NDIS_PACKET_TYPE_PROMISCUOUS or NDIS_PACKET_TYPE_ALL_LOCAL set.
A protocol binding receives loopback packets if either of the following is true:
The protocol binding is the original sender of the packet and NDIS_SEND_FLAGS_CHECK_FOR_LOOPBACK is set.
The protocol binding does not set NDIS_PACKET_TYPE_NO_LOCAL in the packet filter.
A protocol binding will not receive loopback packets if either of the following is true:
The protocol binding sets NDIS_PACKET_TYPE_NO_LOCAL in the packet filter and it is not the original sender for the packet.
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.
The following figure shows the loopback algorithm logic flow.