suricata
util-reference-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  SCRConfReference_
 Holds a reference from the file - reference.config. More...
 

Macros

#define REFERENCE_SYSTEM_NAME_MAX   64
 
#define REFERENCE_CONTENT_NAME_MAX   1024
 

Typedefs

typedef struct SCRConfReference_ SCRConfReference
 Holds a reference from the file - reference.config. More...
 

Functions

SCRConfReferenceSCRConfAllocSCRConfReference (const char *, const char *)
 Returns a new SCRConfReference instance. The reference string is converted into lowercase, before being assigned to the instance. More...
 
void SCRConfDeAllocSCRConfReference (SCRConfReference *)
 Frees a SCRConfReference instance. More...
 
int SCRConfLoadReferenceConfigFile (DetectEngineCtx *, FILE *)
 Loads the Reference info from the reference.config file. More...
 
void SCRConfDeInitContext (DetectEngineCtx *)
 Releases de_ctx resources related to Reference Config API. More...
 
SCRConfReferenceSCRConfGetReference (const char *, DetectEngineCtx *)
 Gets the refernce config from the corresponding hash table stored in the Detection Engine Context's reference conf ht, given the reference name. More...
 
int SCRConfAddReference (DetectEngineCtx *de_ctx, const char *line)
 Parses a line from the reference config file and adds it to Reference Config hash table DetectEngineCtx->reference_conf_ht. More...
 
void SCRConfRegisterTests (void)
 This function registers unit tests for Reference Config API. More...
 
FILE * SCRConfGenerateValidDummyReferenceConfigFD01 (void)
 Creates a dummy reference config, with all valid references, for testing purposes. More...
 
FILE * SCRConfGenerateInValidDummyReferenceConfigFD02 (void)
 Creates a dummy reference config, with some valid references and a couple of invalid references, for testing purposes. More...
 
FILE * SCRConfGenerateInValidDummyReferenceConfigFD03 (void)
 Creates a dummy reference config, with all invalid references, for testing purposes. More...
 
void SCReferenceConfInit (void)
 
void SCReferenceConfDeinit (void)
 

Detailed Description

Macro Definition Documentation

#define REFERENCE_CONTENT_NAME_MAX   1024

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

Referenced by DetectReferenceFree(), and SCRConfAddReference().

#define REFERENCE_SYSTEM_NAME_MAX   64

Definition at line 27 of file util-reference-config.h.

Referenced by DetectReferenceFree(), and SCRConfAddReference().

Typedef Documentation

Holds a reference from the file - reference.config.

Function Documentation

int SCRConfAddReference ( DetectEngineCtx de_ctx,
const char *  line 
)

Parses a line from the reference config file and adds it to Reference Config hash table DetectEngineCtx->reference_conf_ht.

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

Definition at line 233 of file util-reference-config.c.

References HashTable_::count, HashTableAdd(), HashTableLookup(), MAX_SUBSTRINGS, DetectEngineCtx_::reference_conf_ht, REFERENCE_CONTENT_NAME_MAX, REFERENCE_SYSTEM_NAME_MAX, SC_ERR_PCRE_GET_SUBSTRING, SC_ERR_REFERENCE_CONFIG, SCLogDebug, SCLogError, SCLogInfo, SCRConfAddReference(), SCRConfAllocSCRConfReference(), and SCRConfDeAllocSCRConfReference().

Referenced by DetectReferenceFree(), and SCRConfAddReference().

Here is the call graph for this function:

Here is the caller graph for this function:

SCRConfReference* SCRConfAllocSCRConfReference ( const char *  system,
const char *  url 
)

Returns a new SCRConfReference instance. The reference string is converted into lowercase, before being assigned to the instance.

Parameters
systemPointer to the system.
urlPointer to the reference url.
Return values
refPointer to the new instance of SCRConfReference.

Definition at line 354 of file util-reference-config.c.

References SC_ERR_INVALID_SIGNATURE, SCFree, SCLogError, SCMalloc, SCStrdup, SCRConfReference_::system, and SCRConfReference_::url.

Referenced by SCRConfAddReference(), and SCRConfGetReference().

Here is the caller graph for this function:

void SCRConfDeAllocSCRConfReference ( SCRConfReference ref)

Frees a SCRConfReference instance.

Parameters
Pointerto the SCRConfReference instance that has to be freed.

Definition at line 388 of file util-reference-config.c.

References SCFree, SCRConfReference_::system, and SCRConfReference_::url.

Referenced by SCRConfAddReference(), SCRConfGetReference(), and SCRConfReferenceHashFree().

Here is the caller graph for this function:

void SCRConfDeInitContext ( DetectEngineCtx )

Releases de_ctx resources related to Reference Config API.

Definition at line 190 of file util-reference-config.c.

References HashTableFree(), DetectEngineCtx_::reference_conf_ht, SCStrdup, and str.

Referenced by DetectEngineCtxFree().

Here is the call graph for this function:

Here is the caller graph for this function:

FILE* SCRConfGenerateInValidDummyReferenceConfigFD02 ( void  )

Creates a dummy reference config, with some valid references and a couple of invalid references, for testing purposes.

Definition at line 566 of file util-reference-config.c.

References SCFmemopen, and SCLogDebug.

Referenced by SCRConfGenerateInValidDummyReferenceConfigFD03().

Here is the caller graph for this function:

FILE* SCRConfGenerateInValidDummyReferenceConfigFD03 ( void  )
FILE* SCRConfGenerateValidDummyReferenceConfigFD01 ( void  )

Creates a dummy reference config, with all valid references, for testing purposes.

Definition at line 546 of file util-reference-config.c.

References SCFmemopen, and SCLogDebug.

Referenced by DetectReferenceFree(), and SCRConfGenerateInValidDummyReferenceConfigFD03().

Here is the caller graph for this function:

SCRConfReference* SCRConfGetReference ( const char *  rconf_name,
DetectEngineCtx de_ctx 
)

Gets the refernce config from the corresponding hash table stored in the Detection Engine Context's reference conf ht, given the reference name.

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

Definition at line 524 of file util-reference-config.c.

References HashTableLookup(), DetectEngineCtx_::reference_conf_ht, SCRConfAllocSCRConfReference(), and SCRConfDeAllocSCRConfReference().

Referenced by DetectReferenceFree(), and SCRConfGenerateInValidDummyReferenceConfigFD03().

Here is the call graph for this function:

Here is the caller graph for this function:

int SCRConfLoadReferenceConfigFile ( DetectEngineCtx de_ctx,
FILE *  fd 
)

Loads the Reference info from the reference.config file.

The reference.config file contains references that can be used in Signatures. Each line of the file should have the following format - config reference: system_name, reference_url.

Parameters
de_ctxPointer to the Detection Engine Context that should be updated with reference information.
Return values
0On success.
-1On failure.

Definition at line 493 of file util-reference-config.c.

References RunmodeIsUnittests(), SC_ERR_OPENING_FILE, and SCLogError.

Referenced by DetectEngineInspectPktBufferGeneric(), DetectReferenceFree(), and SCRConfGenerateInValidDummyReferenceConfigFD03().

Here is the call graph for this function:

Here is the caller graph for this function:

void SCRConfRegisterTests ( void  )

This function registers unit tests for Reference Config API.

Definition at line 783 of file util-reference-config.c.

References UtRegisterTest().

Here is the call graph for this function:

void SCReferenceConfInit ( void  )

Definition at line 56 of file util-reference-config.c.

References SC_RCONF_REGEX, and SCLogDebug.

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

Here is the caller graph for this function: