detect: cleanup built-in list id's

pull/2559/head
Victor Julien 8 years ago
parent 40851eecf0
commit 49fbd28ceb

@ -161,7 +161,7 @@ int DetectEngineAppInspectionEngine2Signature(Signature *s)
/* convert lists to SigMatchData arrays */
int i = 0;
for (i = DETECT_SM_LIST_BUILTIN_MAX; i < nlists; i++) {
for (i = DETECT_SM_LIST_DYNAMIC_START; i < nlists; i++) {
if (s->init_data->smlists[i] == NULL)
continue;
@ -267,7 +267,7 @@ void DetectEngineAppInspectionEngineSignatureFree(Signature *s)
#include "util-hash-lookup3.h"
static HashListTable *g_buffer_type_hash = NULL;
static int g_buffer_type_id = DETECT_SM_LIST_MAX; // past DETECT_SM_LIST_NOTSET
static int g_buffer_type_id = DETECT_SM_LIST_DYNAMIC_START;
static int g_buffer_type_reg_closed = 0;
typedef struct DetectBufferType_ {
@ -515,6 +515,7 @@ void DetectBufferTypeFinalizeRegistration(void)
g_buffer_type_map = SCCalloc(size, sizeof(DetectBufferType *));
BUG_ON(!g_buffer_type_map);
SCLogDebug("DETECT_SM_LIST_DYNAMIC_START %u", DETECT_SM_LIST_DYNAMIC_START);
HashListTableBucket *b = HashListTableGetListHead(g_buffer_type_hash);
while (b) {
DetectBufferType *map = HashListTableGetListData(b);
@ -2816,11 +2817,8 @@ const char *DetectSigmatchListEnumToString(enum DetectSigmatchListEnum type)
case DETECT_SM_LIST_THRESHOLD:
return "threshold";
case DETECT_SM_LIST_BUILTIN_MAX:
case DETECT_SM_LIST_MAX:
return "max (internal)";
case DETECT_SM_LIST_NOTSET:
return "not set (internal)";
}
return "error";
}

@ -148,7 +148,6 @@ const char *DetectListToHumanString(int list)
CASE_CODE_STRING(DETECT_SM_LIST_SUPPRESS, "suppress");
CASE_CODE_STRING(DETECT_SM_LIST_THRESHOLD, "threshold");
CASE_CODE_STRING(DETECT_SM_LIST_MAX, "max (internal)");
CASE_CODE_STRING(DETECT_SM_LIST_NOTSET, "not set (internal)");
}
#undef CASE_CODE_STRING
return "unknown";
@ -167,7 +166,6 @@ const char *DetectListToString(int list)
CASE_CODE(DETECT_SM_LIST_SUPPRESS);
CASE_CODE(DETECT_SM_LIST_THRESHOLD);
CASE_CODE(DETECT_SM_LIST_MAX);
CASE_CODE(DETECT_SM_LIST_NOTSET);
}
return "unknown";
}
@ -1117,7 +1115,7 @@ static void SigMatchFreeArrays(Signature *s, int ctxs)
{
if (s != NULL) {
int type;
for (type = 0; type < DETECT_SM_LIST_BUILTIN_MAX; type++) {
for (type = 0; type < DETECT_SM_LIST_MAX; type++) {
if (s->sm_arrays[type] != NULL) {
if (ctxs) {
SigMatchData *smd = s->sm_arrays[type];

@ -3780,8 +3780,9 @@ static int SigMatchPrepare(DetectEngineCtx *de_ctx)
/* set up inspect engines */
DetectEngineAppInspectionEngine2Signature(s);
/* built-ins */
int type;
for (type = 0; type < DETECT_SM_LIST_BUILTIN_MAX; type++) {
for (type = 0; type < DETECT_SM_LIST_MAX; type++) {
SigMatch *sm = s->init_data->smlists[type];
s->sm_arrays[type] = SigMatchList2DataArray(sm);
}

@ -108,17 +108,17 @@ enum DetectSigmatchListEnum {
DETECT_SM_LIST_SUPPRESS,
DETECT_SM_LIST_THRESHOLD,
/* used for Signature->list, which indicates which list
* we're adding keywords to in cases of sticky buffers like
* file_data */
DETECT_SM_LIST_NOTSET,
DETECT_SM_LIST_BUILTIN_MAX,
DETECT_SM_LIST_MAX,
/* start of dynamically registered lists */
DETECT_SM_LIST_DYNAMIC_START = DETECT_SM_LIST_MAX,
};
/* used for Signature->list, which indicates which list
* we're adding keywords to in cases of sticky buffers like
* file_data */
#define DETECT_SM_LIST_NOTSET INT_MAX
/* a is ... than b */
enum {
ADDRESS_ER = -1, /**< error e.g. compare ipv4 and ipv6 */
@ -446,7 +446,7 @@ typedef struct Signature_ {
/* Matching structures for the built-ins. The others are in
* their inspect engines. */
SigMatchData *sm_arrays[DETECT_SM_LIST_BUILTIN_MAX];
SigMatchData *sm_arrays[DETECT_SM_LIST_MAX];
/* memory is still owned by the sm_lists/sm_arrays entry */
const struct DetectFilestoreData_ *filestore_ctx;

Loading…
Cancel
Save