데이터 로깅

기록해야 하는 데이터를 확인하기 위해 설명선의 classifyFn 설명선 함수는 데이터 필드, 메타데이터 필드 및 전달된 원시 데이터와 필터 또는 데이터 흐름과 연결된 컨텍스트에 저장된 모든 관련 데이터의 조합을 검사할 수 있습니다.

예를 들어 설명선이 네트워크 계층의 필터에 의해 삭제되는 들어오는(인바운드) IPv4 패킷 수를 추적하는 경우 설명선은 FWPM_LAYER_INBOUND_IPPACKET_V4_DISCARD 계층의 필터 엔진에 추가됩니다. 이 경우 설명선의 classifyFn 설명선 함수는 다음 예제와 유사할 수 있습니다.

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;
}

classifyFn