suricata
util-classification-config.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  SCClassConfClasstype_
 Container for a Classtype from the Classification.config file. More...
 

Macros

#define CLASSTYPE_NAME_MAX_LEN   64
 
#define CLASSTYPE_DESC_MAX_LEN   512
 

Typedefs

typedef struct SCClassConfClasstype_ SCClassConfClasstype
 Container for a Classtype from the Classification.config file. More...
 

Functions

void SCClassConfLoadClassficationConfigFile (DetectEngineCtx *, FILE *fd)
 Loads the Classtype info from the classification.config file. More...
 
int SCClassConfAddClasstype (DetectEngineCtx *de_ctx, char *rawstr, uint16_t index)
 Parses a line from the classification file and adds it to Classtype hash table in DetectEngineCtx, i.e. DetectEngineCtx->class_conf_ht. More...
 
SCClassConfClasstypeSCClassConfGetClasstype (const char *, DetectEngineCtx *)
 Gets the classtype from the corresponding hash table stored in the Detection Engine Context's class conf ht, given the classtype name. More...
 
void SCClassConfDeInitContext (DetectEngineCtx *)
 Releases resources used by the Classification Config API. More...
 
void SCClassConfInit (void)
 
void SCClassConfDeinit (void)
 
void SCClassConfRegisterTests (void)
 This function registers unit tests for Classification Config API. More...
 
FILE * SCClassConfGenerateValidDummyClassConfigFD01 (void)
 Creates a dummy classification file, with all valid Classtypes, for testing purposes. More...
 
FILE * SCClassConfGenerateInValidDummyClassConfigFD02 (void)
 Creates a dummy classification file, with some valid Classtypes and a couple of invalid Classtypes, for testing purposes. More...
 
FILE * SCClassConfGenerateInValidDummyClassConfigFD03 (void)
 Creates a dummy classification file, with all invalid Classtypes, for testing purposes. More...
 

Detailed Description

Macro Definition Documentation

#define CLASSTYPE_DESC_MAX_LEN   512

Definition at line 28 of file util-classification-config.h.

Referenced by SCClassConfAddClasstype().

#define CLASSTYPE_NAME_MAX_LEN   64

Typedef Documentation

Container for a Classtype from the Classification.config file.

Function Documentation

int SCClassConfAddClasstype ( DetectEngineCtx de_ctx,
char *  rawstr,
uint16_t  index 
)

Parses a line from the classification file and adds it to Classtype hash table in DetectEngineCtx, i.e. DetectEngineCtx->class_conf_ht.

Parameters
rawstrPointer to the string to be parsed.
indexRelative index of the string to be parsed.
de_ctxPointer to the Detection Engine Context.
Return values
0On success.
-1On failure.

Definition at line 242 of file util-classification-config.c.

References DetectEngineCtx_::class_conf_ht, SCClassConfClasstype_::classtype, SCClassConfClasstype_::classtype_desc, CLASSTYPE_DESC_MAX_LEN, SCClassConfClasstype_::classtype_id, CLASSTYPE_NAME_MAX_LEN, HashTable_::count, HashTableAdd(), HashTableLookup(), MAX_SUBSTRINGS, SCClassConfClasstype_::priority, SC_ERR_INVALID_SIGNATURE, SC_ERR_MEM_ALLOC, SCClassConfAddClasstype(), SCFree, SCLogDebug, SCLogError, SCLogInfo, SCMalloc, and SCStrdup.

Referenced by DetectClasstypeRegister(), and SCClassConfAddClasstype().

Here is the call graph for this function:

Here is the caller graph for this function:

void SCClassConfDeInitContext ( DetectEngineCtx )

Releases resources used by the Classification Config API.

Definition at line 197 of file util-classification-config.c.

References DetectEngineCtx_::class_conf_ht, HashTableFree(), SC_ERR_MEM_ALLOC, SCLogError, SCStrdup, and str.

Referenced by DetectEngineCtxFree().

Here is the call graph for this function:

Here is the caller graph for this function:

FILE* SCClassConfGenerateInValidDummyClassConfigFD02 ( void  )

Creates a dummy classification file, with some valid Classtypes and a couple of invalid Classtypes, for testing purposes.

Pointer to the file_path for the dummy classification file.

Definition at line 605 of file util-classification-config.c.

References SCFmemopen, and SCLogDebug.

Referenced by SCClassConfGenerateInValidDummyClassConfigFD03().

Here is the caller graph for this function:

FILE* SCClassConfGenerateInValidDummyClassConfigFD03 ( void  )

Creates a dummy classification file, with all invalid Classtypes, for testing purposes.

Pointer to the file_path for the dummy classification file.

Definition at line 629 of file util-classification-config.c.

References DetectEngineCtx_::class_conf_ht, HashTable_::count, DetectEngineCtxFree(), DetectEngineCtxInit(), SCClassConfGenerateInValidDummyClassConfigFD02(), SCClassConfGenerateInValidDummyClassConfigFD03(), SCClassConfGenerateValidDummyClassConfigFD01(), SCClassConfGetClasstype(), SCClassConfLoadClassficationConfigFile(), SCFmemopen, and SCLogDebug.

Referenced by SCClassConfGenerateInValidDummyClassConfigFD03().

Here is the call graph for this function:

Here is the caller graph for this function:

FILE* SCClassConfGenerateValidDummyClassConfigFD01 ( void  )

Creates a dummy classification file, with all valid Classtypes, for testing purposes.

Pointer to the file_path for the dummy classification file.

Definition at line 585 of file util-classification-config.c.

References SCFmemopen, and SCLogDebug.

Referenced by AlertFastLogInitCtx(), DetectClasstypeRegister(), DetectMsgRegister(), DetectSetupParseRegexes(), and SCClassConfGenerateInValidDummyClassConfigFD03().

Here is the caller graph for this function:

SCClassConfClasstype* SCClassConfGetClasstype ( const char *  ct_name,
DetectEngineCtx de_ctx 
)

Gets the classtype from the corresponding hash table stored in the Detection Engine Context's class conf ht, given the classtype name.

Parameters
ct_namePointer to the classtype name that has to be looked up.
de_ctxPointer to the Detection Engine Context.
Return values
lookup_ct_infoPointer to the SCClassConfClasstype instance from the hash table on success; NULL on failure.

Definition at line 559 of file util-classification-config.c.

References DetectEngineCtx_::class_conf_ht, and HashTableLookup().

Referenced by DetectClasstypeRegister(), and SCClassConfGenerateInValidDummyClassConfigFD03().

Here is the call graph for this function:

Here is the caller graph for this function:

void SCClassConfInit ( void  )

Definition at line 63 of file util-classification-config.c.

References DETECT_CLASSCONFIG_REGEX, and SCLogDebug.

Referenced by DetectSetupParseRegexes(), PostRunDeinit(), and RunUnittests().

Here is the caller graph for this function:

void SCClassConfLoadClassficationConfigFile ( DetectEngineCtx de_ctx,
FILE *  fd 
)

Loads the Classtype info from the classification.config file.

The classification.config file contains the different classtypes, that can be used to label Signatures. Each line of the file should have the following format - classtype_name, classtype_description, priority None of the above parameters should hold a quote inside the file.

Parameters
de_ctxPointer to the Detection Engine Context that should be updated with Classtype information.

Definition at line 528 of file util-classification-config.c.

References RunmodeIsUnittests(), SC_ERR_OPENING_FILE, and SCLogError.

Referenced by AlertFastLogInitCtx(), DetectClasstypeRegister(), DetectEngineInspectPktBufferGeneric(), DetectMsgRegister(), DetectSetupParseRegexes(), and SCClassConfGenerateInValidDummyClassConfigFD03().

Here is the call graph for this function:

Here is the caller graph for this function:

void SCClassConfRegisterTests ( void  )

This function registers unit tests for Classification Config API.

Definition at line 820 of file util-classification-config.c.

References UtRegisterTest().

Here is the call graph for this function: