共用方式為


封包插入函式

圖說文字驅動程式可以呼叫下列 WFP 函式,將擱置或修改的封包數據插入 TCP/IP 堆疊。 下表列出可從中插入資料的適用層,以及可能的目的地。

Injection function Applicable layer Destination

FwpsInjectForwardAsync0

network layer

轉送資料路徑

FwpsInjectNetworkReceiveAsync0

network layer

接收資料路徑

FwpsInjectNetworkSendAsync0

network layer

傳送資料路徑

FwpsInjectTransportReceiveAsync0

來自傳輸、資料包資料、ICMP 錯誤或 ALE 層的封包資料

接收資料路徑

FwpsInjectTransportSendAsync0

來自傳輸、資料包資料、ICMP 錯誤或 ALE 層的封包資料

傳送資料路徑

FwpsStreamInjectAsync0

TCP 資料區段

資料串流

In addition, the FwpsQueryPacketInjectionState0 function is used to inspect the injection history of packet data.

如果標說可以提供注入函數所需的所有必要資訊,且網路緩衝區清單具有注入函數預期的格式,則會啟用跨層注入。 For example, a callout can capture a packet at the forward path, modify its destination address to that of the local computer, and call FwpsInjectTransportReceiveAsync0 to redirect the packet into the local computer's TCP/IP stack.

除了流(TCP資料)注入之外,注入的傳入封包從堆疊和WFP層的「底部」重新進入,而注入的傳出封包從堆疊和WFP層的「頂部」重新進入。 例如,從傳入資料包資料層插入的 UDP 封包將重新進入堆疊並遍歷網路層、傳輸層、ALE 接收或接受層 (選擇性),然後返回資料包資料層。 從傳出網路層注入的另一個 UDP 封包將重新進入堆疊並遍歷 ALE(可選)、資料包資料和傳輸層,然後返回網路層。

FwpsInjectTransportReceiveAsync0 automatically bypasses IPsec processing for the reinjected packet because it had previously gone through IPsec verification.

WFP 圖說文字驅動程式插入的封包將會重新指出至圖說文字,除非修改封包會導致它遺漏原始篩選條件。 WFP provides the FwpsQueryPacketInjectionState0 function for callouts to query whether the packet was injected (or injected earlier) by the callout. 為了防止無限迴圈,標註應該允許自我插入的封包。

圖說文字必須在修改 IP 封包之後調整 IP 或傳輸層總和檢查碼,或兩者。 圖說文字可以將 UDP over IPv4 封包的總和檢查碼設定為 0。 若要與傳輸層總和檢查碼卸載相容,並據以調整完整總和檢查碼與虛擬總和檢查碼計算,圖說文字可以使用下列邏輯:

NDIS_TCP_IP_CHECKSUM_PACKET_INFO ChecksumInfo;
 ChecksumInfo.Value = 
 (ULONG) (ULONG_PTR)NET_BUFFER_LIST_INFO(
 NetBufferList,TcpIpChecksumNetBufferListInfo);

If ChecksumInfo.Transmit.NdisPacketTcpChecksum is TRUE, the TCP send operation will be offloaded. If ChecksumInfo.Transmit.NdisPacketUdpChecksum is TRUE, the UDP send operation will be offloaded.

在具有 Service Pack 1 (SP1) 和 Windows Server 2008 的 Windows Vista 中,如果 inMetaValues-headerIncludeHeaderLength> 大於 0,則傳出封包是包含 IP 標頭的 RAW 傳送重新插入。 若要執行包含 Windows Vista SP1 和 Windows Server 2008 的 IP 標頭的 RAW 傳送重新插入,您必須將複製的封包撤回 inMetaValues-headerIncludeHeaderLength> 中的數量,並將 inMetaValues-headerIncludeHeader> 複製到新擴充的空間上。 Then, use FwpsInjectTransportSendAsync0 with the net buffer list for the packet and leave the FWPS_TRANSPORT_SEND_PARAMS0 parameter set to NULL. 如需網路緩衝區清單撤退作業的詳細資訊,請參閱 撤退和進階作業

Note For raw send operations, the net buffer list must contain only a single net buffer. 如果您的網路緩衝區清單包含多個網路緩衝區,您必須將網路緩衝區清單轉換為一系列網路緩衝區清單,且序列中的每個緩衝區清單都必須包含單一網路緩衝區。 For more information about net buffer list management, see NET_BUFFER Architecture.