심층 검사를 위해 콜아웃 사용

설명선이 심층 검사를 수행하는 경우 classifyFn 설명선 함수는 고정 데이터 필드, 메타데이터 필드 및 전달된 원시 패킷 데이터와 필터 또는 데이터 흐름과 연결된 컨텍스트에 저장된 모든 관련 데이터의 조합을 검사할 수 있습니다.

예:

// 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
    )
{
  PNET_BUFFER_LIST rawData;
  ...

  // Test for the FWPS_RIGHT_ACTION_WRITE flag to check the rights
  // for this callout to return an action. If this flag is not set,
  // a callout can still return a BLOCK action in order to VETO a
  // PERMIT action that was returned by a previous filter. In this
  // example the function just exits if the flag is not set.
 if (!(classifyOut->rights & FWPS_RIGHT_ACTION_WRITE))
  {
    // Return without specifying an action
 return;
  }

  // Get the data fields from inFixedValues
  ...

  // Get any metadata fields from inMetaValues
  ...

  // Get the pointer to the raw data
 rawData = (PNET_BUFFER_LIST)layerData;

  // Get any filter context data from filter->context
  ...

  // Get any flow context data from flowContext
  ...

  // Inspect the various data sources to determine
  // the action to be taken on the data
  ...

  // If the data should be permitted...
 if (...) {

    // Set the action to permit the data
 classifyOut->actionType = FWP_ACTION_PERMIT;

    // Check whether the FWPS_RIGHT_ACTION_WRITE flag should be cleared
 if (filter->flags & FWPS_FILTER_FLAG_CLEAR_ACTION_RIGHT)
    {
       // Clear the FWPS_RIGHT_ACTION_WRITE flag
 classifyOut->rights &= ~FWPS_RIGHT_ACTION_WRITE;
    }

 return;
  }

  ...

  // If the data should be blocked...
 if (...) {

    // Set the action to block the data
 classifyOut->actionType = FWP_ACTION_BLOCK;

    // Clear the FWPS_RIGHT_ACTION_WRITE flag
 classifyOut->rights &= ~FWPS_RIGHT_ACTION_WRITE;

 return;
  }

  ...

  // If the decision to permit or block should be passed
  // to the next filter in the filter engine...
 if (...) {

    // Set the action to continue with the next filter
 classifyOut->actionType = FWP_ACTION_CONTINUE;

 return;
  }

  ...
}

filter-action.type>의 값은 classifyOut 매개 변수가 가리키는 구조체의 actionType 멤버에서 설명선의 classifyFn 설명선 함수가 반환해야 하는 작업을 결정합니다. 이러한 작업에 대한 자세한 내용은 FWPS_ACTION0 구조를 참조하세요.

콜아웃이 해당 classifyFn 콜아웃 함수 외부의 패킷 데이터를 추가로 처리해야 데이터를 허용할지 차단할지 여부를 결정할 수 있는 경우 데이터 처리가 완료될 때까지 패킷 데이터를 보류해야 합니다. 패킷 데이터를 보류하는 방법에 대한 자세한 내용은 설명선 유형FwpsPendOperation0을 참조하세요.

일부 필터링 계층에서 필터 엔진이 설명선의 classifyFn 설명선 함수에 전달하는 layerData 매개 변수는 NULL입니다.

스트림 데이터의 심층 검사를 수행하는 방법에 대한 자세한 내용은 스트림 데이터의 심층 검사를 위해 설명선 사용을 참조하세요.