/* Siggroup mpm context profile */
enum {
- ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL,
+ ENGINE_SGH_MPM_FACTORY_CONTEXT_FULL = 0,
ENGINE_SGH_MPM_FACTORY_CONTEXT_SINGLE,
- ENGINE_SGH_MPM_FACTORY_CONTEXT_AUTO
+ ENGINE_SGH_MPM_FACTORY_CONTEXT_AUTO,
+#define ENGINE_SGH_MPM_FACTORY_CONTEXT_START_ID_RANGE (ENGINE_SGH_MPM_FACTORY_CONTEXT_AUTO + 1)
};
typedef struct HttpReassembledBody_ {
FatalError(SC_ERR_FATAL, "Error allocating memory");
}
memset(de_ctx->mpm_ctx_factory_container, 0, sizeof(MpmCtxFactoryContainer));
+ de_ctx->mpm_ctx_factory_container->max_id = ENGINE_SGH_MPM_FACTORY_CONTEXT_START_ID_RANGE;
MpmCtxFactoryItem *item = SCMalloc(sizeof(MpmCtxFactoryItem));
if (unlikely(item == NULL)) {
}
memset(item[0].mpm_ctx_tc, 0, sizeof(MpmCtx));
item[0].mpm_ctx_tc->flags |= MPMCTX_FLAGS_GLOBAL;
-
- /* our id starts from 0 always. Helps us with the ctx retrieval from
- * the array */
- item[0].id = 0;
+ item[0].id = de_ctx->mpm_ctx_factory_container->max_id++;
/* store the newly created item */
de_ctx->mpm_ctx_factory_container->items = item;
memset(new_item[0].mpm_ctx_tc, 0, sizeof(MpmCtx));
new_item[0].mpm_ctx_tc->flags |= MPMCTX_FLAGS_GLOBAL;
- new_item[0].id = de_ctx->mpm_ctx_factory_container->no_of_items;
+ new_item[0].id = de_ctx->mpm_ctx_factory_container->max_id++;
de_ctx->mpm_ctx_factory_container->no_of_items++;
/* the newly created id */
} else if (id < -1) {
SCLogError(SC_ERR_INVALID_ARGUMENTS, "Invalid argument - %d\n", id);
return NULL;
- } else if (id >= de_ctx->mpm_ctx_factory_container->no_of_items) {
+ } else if (id >= de_ctx->mpm_ctx_factory_container->max_id) {
/* this id does not exist */
return NULL;
} else {
- return (direction == 0) ?
- de_ctx->mpm_ctx_factory_container->items[id].mpm_ctx_ts :
- de_ctx->mpm_ctx_factory_container->items[id].mpm_ctx_tc;
+ for (int i = 0; i < de_ctx->mpm_ctx_factory_container->no_of_items; i++) {
+ if (id == de_ctx->mpm_ctx_factory_container->items[i].id) {
+ return (direction == 0) ? de_ctx->mpm_ctx_factory_container->items[i].mpm_ctx_ts
+ : de_ctx->mpm_ctx_factory_container->items[i].mpm_ctx_tc;
+ }
+ }
+ return NULL;
}
}