Querying a Packet's Extensible Switch Source Port Data

The Hyper-V extensible switch source port is specified by the SourcePortId member in the NDIS_SWITCH_FORWARDING_DETAIL_NET_BUFFER_LIST_INFO structure. This structure is contained in the out-of-band (OOB) forwarding context of the packet's NET_BUFFER_LIST structure. For more information on this context, see Hyper-V Extensible Switch Forwarding Context.

The extensible switch extension accesses the NDIS_SWITCH_FORWARDING_DETAIL_NET_BUFFER_LIST_INFO structure by using the NET_BUFFER_LIST_SWITCH_FORWARDING_DETAIL macro. The following example shows how the driver can obtain the source port identifier from the packet's NDIS_SWITCH_FORWARDING_DETAIL_NET_BUFFER_LIST_INFO structure.

PNDIS_SWITCH_FORWARDING_DETAIL_NET_BUFFER_LIST_INFO fwdDetail;
NDIS_SWITCH_PORT_ID sourcePortId;

fwdDetail = NET_BUFFER_LIST_SWITCH_FORWARDING_DETAIL(NetBufferList);
sourcePortId = fwdDetail->SourcePortId;