|
suricata
|
#include "suricata-common.h"#include "detect.h"#include "detect-engine.h"#include "util-hash.h"#include "util-reference-config.h"#include "conf.h"#include "util-unittest.h"#include "util-debug.h"#include "util-fmemopen.h"
Go to the source code of this file.
Macros | |
| #define | SC_RCONF_REGEX "^\\s*config\\s+reference\\s*:\\s*([a-zA-Z][a-zA-Z0-9-_]*)\\s+(.+)\\s*$" |
| #define | SC_RCONF_DEFAULT_FILE_PATH CONFIG_DIR "/reference.config" |
Functions | |
| uint32_t | SCRConfReferenceHashFunc (HashTable *ht, void *data, uint16_t datalen) |
| Hashing function to be used to hash the Reference name. Would be supplied as an argument to the HashTableInit function for DetectEngineCtx->reference_conf_ht. More... | |
| char | SCRConfReferenceHashCompareFunc (void *data1, uint16_t datalen1, void *data2, uint16_t datalen2) |
| Used to compare two References that have been stored in the HashTable. This function is supplied as an argument to the HashTableInit function for DetectionEngineCtx->reference_conf_ct. More... | |
| void | SCRConfReferenceHashFree (void *data) |
| Used to free the Reference Config Hash Data that was stored in DetectEngineCtx->reference_conf_ht Hashtable. More... | |
| void | SCReferenceSCConfInit (DetectEngineCtx *de_ctx) |
| void | SCReferenceConfDeinit (DetectEngineCtx *de_ctx) |
| void | SCRConfDeInitContext (DetectEngineCtx *de_ctx) |
| Releases de_ctx resources related to Reference Config API. 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... | |
| 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. More... | |
| void | SCRConfDeAllocSCRConfReference (SCRConfReference *ref) |
| Frees a SCRConfReference instance. More... | |
| int | SCRConfLoadReferenceConfigFile (DetectEngineCtx *de_ctx, FILE *fd) |
| Loads the Reference info from the reference.config file. More... | |
| SCRConfReference * | SCRConfGetReference (const char *rconf_name, DetectEngineCtx *de_ctx) |
| Gets the reference config from the corresponding hash table stored in the Detection Engine Context's reference conf ht, given the reference name. 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 | SCRConfRegisterTests (void) |
| This function registers unit tests for Reference Config API. More... | |
Definition in file util-reference-config.c.
| #define SC_RCONF_DEFAULT_FILE_PATH CONFIG_DIR "/reference.config" |
Definition at line 42 of file util-reference-config.c.
| #define SC_RCONF_REGEX "^\\s*config\\s+reference\\s*:\\s*([a-zA-Z][a-zA-Z0-9-_]*)\\s+(.+)\\s*$" |
Definition at line 39 of file util-reference-config.c.
| 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.
| rawstr | Pointer to the string to be parsed. |
| de_ctx | Pointer to the Detection Engine Context. |
| 0 | On success. |
| -1 | On failure. |
Definition at line 220 of file util-reference-config.c.
References de_ctx, HashTableAdd(), HashTableLookup(), DetectEngineCtx_::reference_conf_ht, DetectEngineCtx_::reference_conf_regex, DetectEngineCtx_::reference_conf_regex_match, REFERENCE_CONTENT_NAME_MAX, REFERENCE_SYSTEM_NAME_MAX, SCLogDebug, SCLogError, SCRConfAllocSCRConfReference(), and SCRConfDeAllocSCRConfReference().

| 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.
| system | Pointer to the system. |
| url | Pointer to the reference url. |
| ref | Pointer to the new instance of SCRConfReference. |
Definition at line 351 of file util-reference-config.c.
References SCCalloc, SCLogError, and SCRConfReference_::system.
Referenced by SCRConfAddReference(), and SCRConfGetReference().

| void SCRConfDeAllocSCRConfReference | ( | SCRConfReference * | ref | ) |
Frees a SCRConfReference instance.
| Pointer | to the SCRConfReference instance that has to be freed. |
Definition at line 384 of file util-reference-config.c.
References SCFree, SCRConfReference_::system, and SCRConfReference_::url.
Referenced by SCRConfAddReference(), SCRConfGetReference(), and SCRConfReferenceHashFree().

| void SCRConfDeInitContext | ( | DetectEngineCtx * | de_ctx | ) |
Releases de_ctx resources related to Reference Config API.
Definition at line 179 of file util-reference-config.c.
References de_ctx, HashTableFree(), and DetectEngineCtx_::reference_conf_ht.
Referenced by DetectEngineCtxFree().


| FILE* SCRConfGenerateInvalidDummyReferenceConfigFD02 | ( | void | ) |
Creates a dummy reference config, with some valid references and a couple of invalid references, for testing purposes.
Definition at line 558 of file util-reference-config.c.
References SCFmemopen, and SCLogDebug.
| FILE* SCRConfGenerateInvalidDummyReferenceConfigFD03 | ( | void | ) |
Creates a dummy reference config, with all invalid references, for testing purposes.
Definition at line 578 of file util-reference-config.c.
References SCFmemopen, and SCLogDebug.
| FILE* SCRConfGenerateValidDummyReferenceConfigFD01 | ( | void | ) |
Creates a dummy reference config, with all valid references, for testing purposes.
Definition at line 538 of file util-reference-config.c.
References SCFmemopen, and SCLogDebug.
| SCRConfReference* SCRConfGetReference | ( | const char * | rconf_name, |
| DetectEngineCtx * | de_ctx | ||
| ) |
Gets the reference config from the corresponding hash table stored in the Detection Engine Context's reference conf ht, given the reference name.
| ct_name | Pointer to the reference name that has to be looked up. |
| de_ctx | Pointer to the Detection Engine Context. |
| lookup_rconf_info | Pointer to the SCRConfReference instance from the hash table on success; NULL on failure. |
Definition at line 516 of file util-reference-config.c.
References de_ctx, HashTableLookup(), DetectEngineCtx_::reference_conf_ht, SCRConfAllocSCRConfReference(), and SCRConfDeAllocSCRConfReference().

| 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.
| de_ctx | Pointer to the Detection Engine Context that should be updated with reference information. |
| 0 | On success. |
| -1 | On failure. |
Definition at line 485 of file util-reference-config.c.
| char SCRConfReferenceHashCompareFunc | ( | void * | data1, |
| uint16_t | datalen1, | ||
| void * | data2, | ||
| uint16_t | datalen2 | ||
| ) |
Used to compare two References that have been stored in the HashTable. This function is supplied as an argument to the HashTableInit function for DetectionEngineCtx->reference_conf_ct.
| data1 | Pointer to the first SCRConfReference to be compared. |
| len1 | Not used by this function. |
| data2 | Pointer to the second SCRConfReference to be compared. |
| len2 | Not used by this function. |
| 1 | On data1 and data2 being equal. |
| 0 | On data1 and data2 not being equal. |
Definition at line 436 of file util-reference-config.c.
References SCLogDebug, and SCRConfReference_::system.
| void SCRConfReferenceHashFree | ( | void * | data | ) |
Used to free the Reference Config Hash Data that was stored in DetectEngineCtx->reference_conf_ht Hashtable.
| data | Pointer to the data that has to be freed. |
Definition at line 467 of file util-reference-config.c.
References SCRConfDeAllocSCRConfReference().

| uint32_t SCRConfReferenceHashFunc | ( | HashTable * | ht, |
| void * | data, | ||
| uint16_t | datalen | ||
| ) |
Hashing function to be used to hash the Reference name. Would be supplied as an argument to the HashTableInit function for DetectEngineCtx->reference_conf_ht.
| ht | Pointer to the HashTable. |
| data | Pointer to the data to be hashed. In this case, the data would be a pointer to a SCRConfReference instance. |
| datalen | Not used by this function. |
Definition at line 407 of file util-reference-config.c.
References HashTable_::array_size, len, SCRConfReference_::system, and u8_tolower.
| void SCRConfRegisterTests | ( | void | ) |
This function registers unit tests for Reference Config API.
Definition at line 781 of file util-reference-config.c.
References UtRegisterTest().

| void SCReferenceConfDeinit | ( | DetectEngineCtx * | de_ctx | ) |
Definition at line 72 of file util-reference-config.c.
References de_ctx, DetectEngineCtx_::reference_conf_regex, and DetectEngineCtx_::reference_conf_regex_match.
| void SCReferenceSCConfInit | ( | DetectEngineCtx * | de_ctx | ) |
Definition at line 52 of file util-reference-config.c.
References de_ctx, DetectEngineCtx_::reference_conf_regex, DetectEngineCtx_::reference_conf_regex_match, SC_RCONF_REGEX, and SCLogWarning.