Extending Packet Data During Send Operations

Important  The Native 802.11 Wireless LAN interface is deprecated in Windows 10 and later. Please use the WLAN Device Driver Interface (WDI) instead. For more information about WDI, see WLAN Universal Windows driver model.

 

If the miniport driver needs to add fields to the 802.11 media access control (MAC) header or payload data of a packet, the driver should use the data backfill area allocated within each NET_BUFFER structure.

The miniport driver defines the maximum amount of data backfill area to reserve in each NET_BUFFER through the DataBackFillSize member of the NDIS_MINIPORT_ADAPTER_GENERAL_ATTRIBUTES structure. The miniport driver passes this structure in a call to the NdisMSetMiniportAttributes function during driver initialization. For more information about driver initialization, see Native 802.11 Miniport Driver Initialization.

Note  Native 802.11 miniport drivers must not set the DataBackFillSize member to a value greater than 256.

 

The miniport driver sends packets when its MiniportSendNetBufferLists function is called. Each packet is accessed through a NET_BUFFER_LIST structure, which is referenced through the NetBufferLists parameter. If the miniport driver specifies a nonzero value for the data backfill area, NDIS allocates additional space for the backfill area within a NET_BUFFER that is linked within a NET_BUFFER_LIST structure.

For Native 802.11 miniport drivers, the data backfill area precedes the MAC header or payload data within the buffer described in the NET_BUFFER structure. For the NET_BUFFER structure within the NET_BUFFER_LIST in a send packet, the operating system formats the buffer in the following order:

For each NET_BUFFER_LIST structure referenced through the NetBufferLists parameter of MiniportSendNetBufferLists, the miniport driver must follow these guidelines when inserting fields or headers within the 802.11 packet data:

  • The miniport driver must call NdisRetreatNetBufferDataStart to move the start of the packet data, referenced through a NET_BUFFER structure, in which fields or headers are being added. The DataOffsetDelta parameter of NdisRetreatNetBufferDataStart defines the number of bytes to retreat the start of the packet data into the unused data backfill area of the NET_BUFFER structure.

    For more information about retreating the start of packet data, see Retreat Operations.

  • The miniport driver determines the new start of the packet data within the NET_BUFFER structure through the NET_BUFFER_DATA_OFFSET macro. The miniport driver can then move data to align on the new offset when adding extensions to the packet data.

  • Before completing the send of the NET_BUFFER_LIST structure through a call to NdisMSendNetBufferListsComplete, the miniport driver must first restore the start of the packet data to its original value for each NET_BUFFER modified by the driver. In this situation, the miniport driver calls NdisAdvanceNetBufferDataStart and sets the DataOffsetDelta parameter to the number of bytes required to move the start of the packet data.

    For more information about advancing the start of packet data, see Advance Operations.

    Note  When extending packet data, the miniport driver must use the same value for the DataOffsetDelta parameter when the driver calls NdisRetreatNetBufferDataStart and NdisAdvanceNetBufferDataStart.