共用方式為


數據記錄

若要判斷應該記錄哪些數據,呼叫的 classifyFn 函數可以檢查數據欄位、元數據欄位以及傳遞給它的任何原始數據,還有任何儲存在與篩選器或數據流相關聯的上下文中的相關數據。

例如,如果呼叫會追蹤在網路層被篩選捨棄的傳入(輸入)IPv4 封包數量,則會將呼叫添加到FWPM_LAYER_INBOUND_IPPACKET_V4_DISCARD層的篩選引擎。 在此情況下,註解的 分類功能 註解函式可能類似下列範例:

ULONG TotalDiscardCount = 0;
ULONG FilterDiscardCount = 0;

// classifyFn callout function
VOID NTAPI
 ClassifyFn(
    IN const FWPS_INCOMING_VALUES0  *inFixedValues,
    IN const FWPS_INCOMING_METADATA_VALUES0  *inMetaValues,
    IN OUT VOID  *layerData,
    IN const FWPS_FILTER0  *filter,
    IN UINT64  flowContext,
    IN OUT FWPS_CLASSIFY_OUT  *classifyOut
    )
{
  // Increment the total count of discarded packets
 InterlockedIncrement(&TotalDiscardCount);


  // Check whether a discard reason metadata field is present
 if (FWPS_IS_METADATA_FIELD_PRESENT(
 inMetaValues,
        FWPS_METADATA_FIELD_DISCARD_REASON))
  {
    // Check whether it is a general discard reason
 if (inMetaValues->discardMetadata.discardModule ==
        FWPS_DISCARD_MODULE_GENERAL)
    {
      // Check whether discarded by a filter
 if (inMetaValues->discardMetadata.discardReason ==
          FWPS_DISCARD_FIREWALL_POLICY)
      {
        // Increment the count of packets discarded by a filter
 InterlockedIncrement(&FilterDiscardCount);
      }
    }
  }

  // Take no action on the data
 classifyOut->actionType = FWP_ACTION_CONTINUE;
}

分類Fn