Usando um texto explicativo para inspeção profunda
Quando um texto explicativo está executando uma inspeção profunda, sua função de texto explicativo classifyFn pode inspecionar qualquer combinação dos campos de dados fixos, os campos de metadados e quaisquer dados brutos de pacote que são passados para ele e quaisquer dados relevantes que foram armazenados em um contexto associado ao filtro ou ao fluxo de dados.
Por exemplo:
// 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;
}
...
}
O valor em filter-action.type> determina quais ações a função de texto explicativo classifyFn do texto explicativo deve retornar no membro actionType da estrutura apontada pelo parâmetro classifyOut. Para obter mais informações sobre essas ações, consulte a estrutura FWPS_ACTION0 .
Se um texto explicativo precisar executar processamento adicional de dados de pacote fora de sua função de texto explicativo classifyFn antes de determinar se os dados devem ser permitidos ou bloqueados, ele deverá aguardar os dados do pacote até que o processamento dos dados seja concluído. Para obter informações sobre como aguardar dados de pacote, consulte Tipos de textos explicativos e FwpsPendOperation0.
Em algumas camadas de filtragem, o parâmetro layerData passado pelo mecanismo de filtro para a função de texto explicativo classifyFn de um texto explicativo é NULL.
Para obter informações sobre como executar uma inspeção profunda de dados de fluxo, consulte Usando um texto explicativo para inspeção profunda de dados de fluxo.