Go to the documentation of this file.
67 "toserver TCP packet",
68 "toclient TCP packet",
69 "toserver TCP stream",
70 "toclient TCP stream",
71 "toserver UDP packet",
72 "toclient UDP packet",
89 static void RegisterInternal(
const char *
name,
int direction,
int priority,
94 SCLogDebug(
"registering %s/%d/%d/%p/%p/%u/%d",
name, direction, priority,
95 PrefilterRegister, GetData, alproto, tx_min_progress);
97 BUG_ON(tx_min_progress >= 48);
111 RegisterInternal(
name, direction, priority, PrefilterRegister, GetData, GetDataSingle,
120 am->
sm_list = (int16_t)sm_list;
126 if (GetData != NULL) {
127 am->
app_v2.GetData = GetData;
128 }
else if (GetDataSingle != NULL) {
129 am->
app_v2.GetDataSingle = GetDataSingle;
130 }
else if (GetMultiData != NULL) {
131 am->
app_v2.GetMultiData = GetMultiData;
133 am->
app_v2.alproto = alproto;
134 am->
app_v2.tx_min_progress = tx_min_progress;
140 while (t->
next != NULL) {
154 AppProto alproto,
int tx_min_progress)
156 RegisterInternal(
name, direction, priority, PrefilterRegister, GetData, NULL, NULL, alproto,
162 AppProto alproto,
int tx_min_progress)
164 RegisterInternal(
name, direction, priority, PrefilterRegister, NULL, GetData, NULL, alproto,
170 AppProto alproto,
int tx_min_progress)
172 RegisterInternal(
name, direction, priority, PrefilterRegister, NULL, NULL, GetData, alproto,
179 static void BuildBasicPname(
char *out,
const size_t out_size,
const char *
name,
const uint16_t
id)
192 size_t name_space = out_size - (id_space + 1);
193 char pname[name_space];
194 if (strlen(
name) >= name_space) {
199 snprintf(out, out_size,
"%s#%u", pname,
id);
207 static void AppendTransformsToPname(
210 if (transforms == NULL || transforms->
cnt == 0)
213 ssize_t left = (ssize_t)out_size - (ssize_t)strlen(out) - (ssize_t)4;
221 for (
int i = 0; i < transforms->
cnt; i++) {
223 (void)snprintf(ttstr,
sizeof(ttstr),
"%s,",
225 strlcat(xforms, ttstr,
sizeof(xforms));
227 if (strlen(xforms) == 0)
229 xforms[strlen(xforms) - 1] =
'\0';
230 SCLogDebug(
"left %d '%s' %d", (
int)left, xforms, (
int)strlen(xforms));
232 char xforms_print[out_size];
233 if ((
size_t)left >= strlen(xforms)) {
234 snprintf(xforms_print,
sizeof(xforms_print),
" (%s)", xforms);
236 char xforms_short[out_size];
238 snprintf(xforms_print,
sizeof(xforms_print),
" (%s)", xforms_short);
240 strlcat(out, xforms_print, out_size);
246 const int id,
const int parent_id,
249 SCLogDebug(
"registering %d/%d",
id, parent_id);
272 BuildBasicPname(am->
pname,
sizeof(am->
pname), am->
name, (uint16_t)
id);
274 memcpy(&am->
transforms, transforms,
sizeof(*transforms));
275 AppendTransformsToPname(am->
pname,
sizeof(am->
pname), transforms);
282 SCLogDebug(
"copied mpm registration for %s id %u "
283 "with parent %u and GetData %p",
295 while (list != NULL) {
315 char confstring[256] =
"detect.mpm.";
317 strlcat(confstring,
".shared",
sizeof(confstring));
351 if (mpm_ctx != NULL) {
371 SCLogDebug(
"registering %s/%d/%p/%s/%u",
name, priority, PrefilterRegister,
378 if (sm_list < 0 || sm_list > UINT16_MAX) {
386 am->
sm_list = (uint16_t)sm_list;
401 while (t->
next != NULL) {
417 SCLogDebug(
"registering %d/%d",
id, parent_id);
437 BuildBasicPname(am->
pname,
sizeof(am->
pname), am->
name, (uint16_t)
id);
439 memcpy(&am->
transforms, transforms,
sizeof(*transforms));
440 AppendTransformsToPname(am->
pname,
sizeof(am->
pname), transforms);
446 SCLogDebug(
"copied mpm registration for %s id %u "
448 t->
name,
id, parent_id);
461 SCLogDebug(
"registering %s/%d/%p/%s/%u",
name, priority, PrefilterRegister,
465 if (sm_list < 0 || sm_list > UINT16_MAX) {
477 am->
sm_list = (uint16_t)sm_list;
492 if (
SCConfGetBool(
"detect.mpm.frame.shared", &confshared) == 1)
506 while (t->
next != NULL) {
521 while (list != NULL) {
532 while (t->
next != NULL) {
544 char confstring[256] =
"detect.mpm.";
546 strlcat(confstring,
".shared",
sizeof(confstring));
582 if (mpm_ctx != NULL) {
604 PrefilterRegister, GetData);
621 am->
sm_list = (uint16_t)sm_list;
626 am->
pkt_v1.GetData = GetData;
632 while (t->
next != NULL) {
646 const int id,
const int parent_id,
649 SCLogDebug(
"registering %d/%d",
id, parent_id);
667 BuildBasicPname(am->
pname,
sizeof(am->
pname), am->
name, (uint16_t)
id);
669 memcpy(&am->
transforms, transforms,
sizeof(*transforms));
670 AppendTransformsToPname(am->
pname,
sizeof(am->
pname), transforms);
676 SCLogDebug(
"copied mpm registration for %s id %u "
677 "with parent %u and GetData %p",
688 while (list != NULL) {
699 while (t->
next != NULL) {
711 char confstring[256] =
"detect.mpm.";
713 strlcat(confstring,
".shared",
sizeof(confstring));
747 if (mpm_ctx != NULL) {
766 char confstring[256] =
"detect.mpm.";
768 strlcat(confstring,
".shared",
sizeof(confstring));
913 const char *mpm_algo;
917 if ((
SCConfGet(
"mpm-algo", &mpm_algo)) == 1) {
918 if (mpm_algo != NULL) {
919 #if __BYTE_ORDER == __BIG_ENDIAN
920 if (strcmp(mpm_algo,
"ac-ks") == 0) {
922 "not work on big endian systems at this time.");
925 if (strcmp(
"auto", mpm_algo) == 0) {
927 }
else if (strcmp(
"ac-bs", mpm_algo) == 0) {
928 SCLogWarning(
"mpm-algo \"ac-bs\" has been removed. See ticket #6586.");
941 #ifndef BUILD_HYPERSCAN
942 if ((strcmp(mpm_algo,
"hs") == 0)) {
943 FatalError(
"Hyperscan (hs) support for mpm-algo is "
944 "not compiled into Suricata.");
949 "in the yaml conf file: \"%s\"",
959 SCLogDebug(
"mpm_ctx %p, mpm_matcher %"PRIu16
"", mpm_ctx, mpm_matcher);
965 SCLogDebug(
"mpm_thread_ctx %p, mpm_matcher %"PRIu16
"", mpm_thread_ctx, mpm_matcher);
971 MpmCtx cum_mpm_ctx = { 0 };
976 if (ms == NULL || ms->
mpm_ctx == NULL) {
1003 memset(&a, 0 ,
sizeof(a));
1007 for (u = 0; u < patlen; u++) {
1008 if (a[pat[u]] == 0) {
1009 if (isalpha(pat[u]))
1011 else if (isprint(pat[u]) || pat[u] == 0x00 || pat[u] == 0x01 || pat[u] == 0xFF)
1028 uint16_t pat_offset = cd->
offset;
1029 uint16_t pat_depth = cd->
depth;
1032 if (chop && (pat_depth || pat_offset)) {
1044 pat_depth = pat_offset = 0;
1066 #define SGH_PROTO(sgh, p) ((sgh)->init->protos[(p)] == 1)
1067 #define SGH_DIRECTION_TS(sgh) ((sgh)->init->direction & SIG_FLAG_TOSERVER)
1068 #define SGH_DIRECTION_TC(sgh) ((sgh)->init->direction & SIG_FLAG_TOCLIENT)
1072 if (s == NULL || mpm_sm == NULL)
1098 uint16_t max_len,
bool skip_negated_content)
1113 if (mpm_sm == NULL) {
1122 }
else if (ls == ss) {
1141 for (; app != NULL; app = app->
next) {
1144 if (app->
dir == 1) {
1166 int pos_sm_list[nlists];
1167 int neg_sm_list[nlists];
1168 memset(pos_sm_list, 0, nlists *
sizeof(
int));
1169 memset(neg_sm_list, 0, nlists *
sizeof(
int));
1170 int pos_sm_list_cnt = 0;
1171 int neg_sm_list_cnt = 0;
1220 SetMpm(s, sm, list_id);
1225 neg_sm_list[list_id] = 1;
1228 pos_sm_list[list_id] = 1;
1236 SCLogDebug(
"neg_sm_list_cnt %d pos_sm_list_cnt %d", neg_sm_list_cnt, pos_sm_list_cnt);
1239 int *curr_sm_list = NULL;
1240 int skip_negated_content = 1;
1241 if (pos_sm_list_cnt > 0) {
1242 curr_sm_list = pos_sm_list;
1243 }
else if (neg_sm_list_cnt > 0) {
1244 curr_sm_list = neg_sm_list;
1245 skip_negated_content = 0;
1250 int final_sm_list[nlists];
1251 memset(&final_sm_list, 0, (nlists *
sizeof(
int)));
1253 int count_final_sm_list = 0;
1254 int count_txbidir_toclient_sm_list = 0;
1258 while (tmp != NULL) {
1260 tmp != NULL && priority == tmp->
priority;
1266 if (curr_sm_list[tmp->
list_id] == 0)
1271 if (count_final_sm_list == 0) {
1273 final_sm_list[count_txbidir_toclient_sm_list++] = tmp->
list_id;
1279 final_sm_list[count_final_sm_list++] = tmp->
list_id;
1282 if (count_final_sm_list != 0)
1288 count_final_sm_list = count_txbidir_toclient_sm_list;
1290 BUG_ON(count_final_sm_list == 0);
1291 SCLogDebug(
"count_final_sm_list %d skip_negated_content %d", count_final_sm_list,
1292 skip_negated_content);
1294 uint16_t max_len = 0;
1295 for (
int i = 0; i < count_final_sm_list; i++) {
1296 SCLogDebug(
"i %d final_sm_list[i] %d", i, final_sm_list[i]);
1319 if (final_sm_list[i] == list_id) {
1340 int mpm_sm_list = -1;
1341 for (
int i = 0; i < count_final_sm_list; i++) {
1347 skip_negated_content);
1348 if (mpm_sm != prev_mpm_sm) {
1349 mpm_sm_list = final_sm_list[i];
1356 if (final_sm_list[i] == list_id) {
1362 skip_negated_content);
1364 if (mpm_sm != prev_mpm_sm) {
1365 mpm_sm_list = list_id;
1373 if (mpm_sm != NULL) {
1374 BUG_ON(mpm_sm_list == -1);
1376 BUG_ON(check_list != mpm_sm_list);
1380 SetMpm(s, mpm_sm, mpm_sm_list);
1392 static uint32_t MpmStoreHashFunc(
HashListTable *ht,
void *data, uint16_t datalen)
1414 static char MpmStoreCompareFunc(
void *data1, uint16_t len1,
void *data2,
1444 static void MpmStoreFreeFunc(
void *ptr)
1474 MpmStoreCompareFunc,
1519 while (am != NULL) {
1527 while (am != NULL) {
1543 uint32_t appstats[app_mpms_cnt + 1];
1544 memset(&appstats, 0x00,
sizeof(appstats));
1546 uint32_t pktstats[pkt_mpms_cnt + 1];
1547 memset(&pktstats, 0x00,
sizeof(pktstats));
1549 uint32_t framestats[frame_mpms_cnt + 1];
1550 memset(&framestats, 0x00,
sizeof(framestats));
1557 if (ms == NULL || ms->
mpm_ctx == NULL) {
1567 SCLogDebug(
"%s: %u patterns. Min %u, Max %u. Ctx %p",
1575 SCLogDebug(
"%s %s %s: %u patterns. Min %u, Max %u. Ctx %p",
1596 for (
int x = 0; x <
MPMB_MAX; x++) {
1600 while (am != NULL) {
1601 if (appstats[am->
sm_list] > 0) {
1604 SCLogPerf(
"AppLayer MPM \"%s %s (%s)\": %u", direction,
name,
1610 while (pm != NULL) {
1611 if (pktstats[pm->
sm_list] > 0) {
1618 while (um != NULL) {
1619 if (framestats[um->
sm_list] > 0) {
1688 const bool mpm_supports_endswith =
1693 if (ms->
sid_array[sig / 8] & (1 << (sig % 8))) {
1713 SCLogDebug(
"not adding negated mpm as it's not 'single'");
1750 int sgh_mpm_context = 0;
1752 uint8_t *sids_array =
SCCalloc(1, max_sid);
1753 if (sids_array == NULL) {
1818 sids_array[s->
iid / 8] |= 1 << (s->
iid % 8);
1826 sids_array[s->
iid / 8] |= 1 << (s->
iid % 8);
1832 sids_array[s->
iid / 8] |= 1 << (s->
iid % 8);
1836 sids_array[s->
iid / 8] |= 1 << (s->
iid % 8);
1849 MpmStore lookup = { sids_array, max_sid, direction, buf, sm_list, 0, 0, NULL };
1852 if (result == NULL) {
1856 uint8_t *sids =
SCCalloc(1, max_sid);
1863 memcpy(sids, sids_array, max_sid);
1871 MpmStoreSetup(
de_ctx, copy);
1872 MpmStoreAdd(
de_ctx, copy);
1901 0, am->
app_v2.alproto, NULL };
1906 if (result == NULL) {
1928 MpmStoreSetup(
de_ctx, copy);
1929 MpmStoreAdd(
de_ctx, copy);
1952 if (result == NULL) {
1972 MpmStoreSetup(
de_ctx, copy);
1973 MpmStoreAdd(
de_ctx, copy);
1995 if (result == NULL) {
2016 MpmStoreSetup(
de_ctx, copy);
2017 MpmStoreAdd(
de_ctx, copy);
2038 SCLogDebug(
"rule group %p has SIG_GROUP_HEAD_HAVERAWSTREAM set", sgh);
2042 SCLogDebug(
"rule group %p does NOT have SIG_GROUP_HEAD_HAVERAWSTREAM set", sgh);
2054 static uint32_t DetectBufferInstanceHashFunc(
HashListTable *ht,
void *data, uint16_t datalen)
2061 static char DetectBufferInstanceCompareFunc(
void *data1, uint16_t len1,
void *data2, uint16_t len2)
2068 static void DetectBufferInstanceFreeFunc(
void *ptr)
2080 return HashListTableInit(4096, DetectBufferInstanceHashFunc, DetectBufferInstanceCompareFunc,
2081 DetectBufferInstanceFreeFunc);
2093 memset(engines, 0,
sizeof(engines));
2094 int engines_idx[max_buffer_id];
2095 memset(engines_idx, 0,
sizeof(engines_idx));
2096 int types[max_buffer_id];
2097 memset(types, 0,
sizeof(types));
2101 types[a->sm_list] = a->type;
2105 if (instance == NULL) {
2106 instance =
SCCalloc(1,
sizeof(*instance));
2107 BUG_ON(instance == NULL);
2108 instance->
list = a->sm_list;
2118 if (add_ts || add_tc) {
2119 types[a->sm_list] = a->type;
2120 engines[a->sm_list][engines_idx[a->sm_list]++] = a->frame_v1.alproto;
2124 if (instance == NULL) {
2125 instance =
SCCalloc(1,
sizeof(*instance));
2126 BUG_ON(instance == NULL);
2127 instance->
list = a->sm_list;
2128 instance->
alproto = a->frame_v1.alproto;
2138 if (add_ts || add_tc) {
2139 types[a->sm_list] = a->type;
2140 engines[a->sm_list][engines_idx[a->sm_list]++] = a->app_v2.alproto;
2144 if (instance == NULL) {
2145 instance =
SCCalloc(1,
sizeof(*instance));
2146 BUG_ON(instance == NULL);
2147 instance->
list = a->sm_list;
2148 instance->
alproto = a->app_v2.alproto;
2156 for (uint32_t sig = 0; sig < sh->
init->
sig_cnt; sig++) {
2168 switch (types[list]) {
2172 for (
int e = 0; e < engines_idx[list]; e++) {
2173 const AppProto alproto = engines[list][e];
2179 if (instance == NULL)
2212 if (instance == NULL)
2242 if (instance == NULL) {
2249 MpmStore *mpm_store = MpmStorePrepareBufferPkt(
de_ctx, sh, a, sa);
2250 if (mpm_store != NULL) {
2253 SCLogDebug(
"a %p a->name %s a->reg->PrefilterRegisterWithListId %p "
2254 "mpm_store->mpm_ctx %p", a, a->name,
2255 a->PrefilterRegisterWithListId, mpm_store->
mpm_ctx);
2259 if (a->PrefilterRegisterWithListId && mpm_store->
mpm_ctx) {
2262 a, a->sm_list) != 0);
2263 SCLogDebug(
"mpm %s %d set up", a->name, a->sm_list);
2272 if (instance == NULL) {
2280 SCLogDebug(
"a %s direction %d PrefilterRegisterWithListId %p", a->name, a->direction,
2281 a->PrefilterRegisterWithListId);
2282 MpmStore *mpm_store = MpmStorePrepareBufferFrame(
de_ctx, sh, a, sa);
2283 if (mpm_store != NULL) {
2286 SCLogDebug(
"a %p a->name %s a->reg->PrefilterRegisterWithListId %p "
2287 "mpm_store->mpm_ctx %p",
2288 a, a->name, a->PrefilterRegisterWithListId, mpm_store->
mpm_ctx);
2293 if (a->PrefilterRegisterWithListId && mpm_store->
mpm_ctx) {
2294 BUG_ON(a->PrefilterRegisterWithListId(
2296 SCLogDebug(
"mpm %s %d set up", a->name, a->sm_list);
2307 if (instance == NULL) {
2315 MpmStore *mpm_store = MpmStorePrepareBufferAppLayer(
de_ctx, sh, a, sa);
2316 if (mpm_store != NULL) {
2319 SCLogDebug(
"a %p a->name %s a->PrefilterRegisterWithListId %p "
2320 "mpm_store->mpm_ctx %p",
2321 a, a->name, a->PrefilterRegisterWithListId, mpm_store->
mpm_ctx);
2325 if (a->PrefilterRegisterWithListId && mpm_store->
mpm_ctx) {
2326 BUG_ON(a->PrefilterRegisterWithListId(
2328 SCLogDebug(
"mpm %s %d set up", a->name, a->sm_list);
2345 if (mpm_store != NULL) {
2350 if (mpm_store != NULL) {
2354 SetRawReassemblyFlag(
de_ctx, sh);
2358 if (mpm_store != NULL) {
2363 if (mpm_store != NULL) {
2367 SetRawReassemblyFlag(
de_ctx, sh);
2369 }
else if (
SGH_PROTO(sh, IPPROTO_UDP)) {
2372 if (mpm_store != NULL) {
2378 if (mpm_store != NULL) {
2384 if (mpm_store != NULL) {
2408 static uint32_t PatternChopHashFunc(
HashListTable *ht,
void *data, uint16_t datalen)
2411 uint32_t hash =
p->sm_list + ContentFlagsForHash(
p->cd);
2412 uint16_t content_len =
p->cd->content_len;
2413 const uint8_t *content =
p->cd->content;
2415 content +=
p->cd->fp_chop_offset;
2416 content_len =
p->cd->fp_chop_len;
2431 static uint32_t PatternNoChopHashFunc(
HashListTable *ht,
void *data, uint16_t datalen)
2434 uint32_t hash =
p->sm_list + ContentFlagsForHash(
p->cd);
2450 static char PatternChopCompareFunc(
void *data1, uint16_t len1,
void *data2, uint16_t len2)
2458 if (ContentFlagsForHash(p1->
cd) != ContentFlagsForHash(p2->
cd))
2474 if (p1_content_len != p2_content_len)
2477 if (memcmp(p1_content, p2_content, p1_content_len) != 0) {
2495 static char PatternNoChopCompareFunc(
void *data1, uint16_t len1,
void *data2, uint16_t len2)
2503 if (ContentFlagsForHash(p1->
cd) != ContentFlagsForHash(p2->
cd))
2516 static void PatternFreeFunc(
void *ptr)
2543 HashListTableInit(4096, PatternChopHashFunc, PatternChopCompareFunc, PatternFreeFunc);
2574 SCLogDebug(
"%u: add id %u cnt %u", s->
id, add->cd->id, add->cnt);
2591 4096, PatternNoChopHashFunc, PatternNoChopCompareFunc, PatternFreeFunc);
2597 switch (smd->
type) {
2627 for (; app != NULL; app = app->
next) {
2630 switch (smd->
type) {
2635 .
cd = cd, .sm_list = app->
sm_list, .cnt = 0, .mpm = 0
2660 for (; pkt != NULL; pkt = pkt->
next) {
2667 switch (smd->
type) {
2672 .
cd = cd, .sm_list = pkt->
sm_list, .cnt = 0, .mpm = 0
2697 for (; frame != NULL; frame = frame->
next) {
2704 switch (smd->
type) {
2709 .
cd = cd, .sm_list = frame->
sm_list, .cnt = 0, .mpm = 0
#define DETECT_CONTENT_NOCASE
int SignatureHasPacketContent(const Signature *s)
check if a signature has patterns that are to be inspected against a packets payload (as opposed to t...
uint32_t pkt_mpms_list_cnt
#define HashListTableGetListData(hb)
uint32_t frame_mpms_list_cnt
uint32_t max_content_list_id
int PrefilterGenericMpmPktRegister(DetectEngineCtx *de_ctx, SigGroupHead *sgh, MpmCtx *mpm_ctx, const DetectBufferMpmRegistry *mpm_reg, int list_id)
void DetectAppLayerMpmMultiRegister(const char *name, int direction, int priority, PrefilterRegisterFunc PrefilterRegister, InspectionMultiBufferGetDataPtr GetData, AppProto alproto, int tx_min_progress)
#define SGH_DIRECTION_TC(sgh)
#define DETECT_PROFILE_NAME_LEN
#define DETECT_CONTENT_FAST_PATTERN_CHOP
struct SigMatch_ * smlists[DETECT_SM_LIST_MAX]
void PatternMatchDestroy(MpmCtx *mpm_ctx, uint16_t mpm_matcher)
SigTableElmt * sigmatch_table
int32_t sgh_mpm_context_proto_tcp_packet
int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
Prepare the pattern matcher ctx in a sig group head.
struct SCFPSupportSMList_ * next
struct DetectEngineAppInspectionEngine_ * next
void MpmStoreFree(DetectEngineCtx *de_ctx)
Frees the hash table - DetectEngineCtx->mpm_hash_table, allocated by MpmStoreInit() function.
void DetectFrameMpmRegisterByParentId(DetectEngineCtx *de_ctx, const int id, const int parent_id, DetectEngineTransforms *transforms)
copy a mpm engine from parent_id, add in transforms
Container for matching data for a signature group.
HashListTable * pattern_hash_table
void MpmFactoryReClaimMpmCtx(const DetectEngineCtx *de_ctx, MpmCtx *mpm_ctx)
void MpmStoreReportStats(const DetectEngineCtx *de_ctx)
void DetectPktMpmRegister(const char *name, int priority, int(*PrefilterRegister)(DetectEngineCtx *de_ctx, SigGroupHead *sgh, MpmCtx *mpm_ctx, const DetectBufferMpmRegistry *mpm_reg, int list_id), InspectionBufferGetPktDataPtr GetData)
register a MPM engine
void DetectBufferTypeSupportsFrames(const char *name)
struct DetectBufferMpmRegistry_::@90::@92 app_v2
void DetectMpmInitializeFrameMpms(DetectEngineCtx *de_ctx)
@ DETECT_SM_LIST_DYNAMIC_START
#define DETECT_CONTENT_NO_DOUBLE_INSPECTION_REQUIRED
uint32_t PatternStrength(uint8_t *pat, uint16_t patlen)
Predict a strength value for patterns.
DetectBufferMpmRegistry * pkt_mpms_list
@ DETECT_BUFFER_MPM_TYPE_FRAME
int DetectSetFastPatternAndItsId(DetectEngineCtx *de_ctx)
Figure out the FP and their respective content ids for all the sigs in the engine.
const char * AppProtoToString(AppProto alproto)
Maps the ALPROTO_*, to its string equivalent.
main detection engine ctx
int SCConfGet(const char *name, const char **vptr)
Retrieve the value of a configuration node.
#define DETECT_CONTENT_MPM_IS_CONCLUSIVE(c)
HashListTableBucket * HashListTableGetListHead(HashListTable *ht)
#define DETECT_CONTENT_DEPTH_VAR
InspectionBuffer *(* InspectionBufferGetPktDataPtr)(struct DetectEngineThreadCtx_ *det_ctx, const DetectEngineTransforms *transforms, Packet *p, const int list_id)
const char * DetectEngineBufferTypeGetNameById(const DetectEngineCtx *de_ctx, const int id)
void DetectMpmInitializeBuiltinMpms(DetectEngineCtx *de_ctx)
struct DetectBufferMpmRegistry_ * next
#define SIG_FLAG_REQUIRE_STREAM
#define SIG_FLAG_TXBOTHDIR
int SCConfGetBool(const char *name, int *val)
Retrieve a configuration value as a boolean.
one time registration of keywords at start up
const struct DetectContentData_ * cd
#define SIG_GROUP_HEAD_HAVERAWSTREAM
uint8_t mpm_default_matcher
SigMatchData * sm_arrays[DETECT_SM_LIST_MAX]
void * HashListTableLookup(HashListTable *ht, void *data, uint16_t datalen)
#define SIG_FLAG_TOCLIENT
int32_t sgh_mpm_context_proto_udp_packet
DetectEngineTransforms transforms
void ShortenString(const char *input, char *output, size_t output_size, char c)
void DetectEngineRegisterFastPatternForId(DetectEngineCtx *de_ctx, int list_id, int priority)
void EngineAnalysisAddAllRulePatterns(DetectEngineCtx *de_ctx, const Signature *s)
add all patterns on our stats hash Used to fill the hash later used by DumpPatterns()
DetectEngineFrameInspectionEngine * frame_inspect
const char * cache_dir_path
int DetectBufferTypeGetByName(const char *name)
int HashListTableAdd(HashListTable *ht, void *data, uint16_t datalen)
struct DetectBufferMpmRegistry_::@90::@93 pkt_v1
size_t strlcpy(char *dst, const char *src, size_t siz)
void DetectAppLayerMpmRegisterByParentId(DetectEngineCtx *de_ctx, const int id, const int parent_id, DetectEngineTransforms *transforms)
copy a mpm engine from parent_id, add in transforms
void MpmInitCtx(MpmCtx *mpm_ctx, uint8_t matcher)
int32_t sgh_mpm_context_proto_other_packet
#define HashListTableGetListNext(hb)
#define SIG_FLAG_TOSERVER
HashListTable * HashListTableInit(uint32_t size, uint32_t(*Hash)(struct HashListTable_ *, void *, uint16_t), char(*Compare)(void *, uint16_t, void *, uint16_t), void(*Free)(void *))
void MpmDestroyThreadCtx(MpmThreadCtx *mpm_thread_ctx, const uint16_t matcher)
char pname[DETECT_PROFILE_NAME_LEN]
struct DetectBufferMpmRegistry_::@90::@94 frame_v1
#define DETECT_CONTENT_ENDS_WITH
MpmCtx * MpmFactoryGetMpmCtxForProfile(const DetectEngineCtx *de_ctx, int32_t id, int direction)
void DetectMpmInitializePktMpms(DetectEngineCtx *de_ctx)
#define MPM_PATTERN_CTX_OWNS_ID
size_t strlcat(char *, const char *src, size_t siz)
@ ENGINE_SGH_MPM_FACTORY_CONTEXT_SINGLE
#define DetectEngineGetMaxSigId(de_ctx)
int SCMpmAddPatternCI(MpmCtx *mpm_ctx, const uint8_t *pat, uint16_t patlen, uint16_t offset, uint16_t depth, uint32_t pid, SigIntId sid, uint8_t flags)
#define DETECT_CONTENT_DEPTH
DetectEnginePktInspectionEngine * pkt_inspect
bool(* InspectionSingleBufferGetDataPtr)(const void *txv, const uint8_t flow_flags, const uint8_t **buf, uint32_t *buf_len)
#define DETECT_CONTENT_IS_SINGLE(c)
#define DETECT_CONTENT_NEGATED
int PrefilterGenericMpmRegister(DetectEngineCtx *de_ctx, SigGroupHead *sgh, MpmCtx *mpm_ctx, const DetectBufferMpmRegistry *mpm_reg, int list_id)
#define SCLogWarning(...)
Macro used to log WARNING messages.
int DetectEngineBufferTypeRegister(DetectEngineCtx *de_ctx, const char *name)
SigGroupHeadInitData * init
void DetectAppLayerMpmRegister(const char *name, int direction, int priority, PrefilterRegisterFunc PrefilterRegister, InspectionBufferGetDataPtr GetData, AppProto alproto, int tx_min_progress)
register an app layer keyword for mpm
DetectEngineAppInspectionEngine * app_inspect
bool DetectBufferToClient(const DetectEngineCtx *de_ctx, int buf_id, AppProto alproto)
#define MPMCTX_FLAGS_GLOBAL
int(* PrefilterRegisterFunc)(DetectEngineCtx *de_ctx, SigGroupHead *sgh, MpmCtx *mpm_ctx, const DetectBufferMpmRegistry *mpm_reg, int list_id)
int32_t MpmFactoryRegisterMpmCtxProfile(DetectEngineCtx *de_ctx, const char *name, const int sm_list, const AppProto alproto)
Register a new Mpm Context.
int32_t sgh_mpm_context_stream
void PatternMatchThreadPrepare(MpmThreadCtx *mpm_thread_ctx, DetectEngineCtx *de_ctx)
void DetectEngineBufferTypeSupportsFrames(DetectEngineCtx *de_ctx, const char *name)
DetectBufferMpmRegistry * frame_mpms_list
int PrefilterPktPayloadRegister(DetectEngineCtx *de_ctx, SigGroupHead *sgh, MpmCtx *mpm_ctx)
@ DETECT_BUFFER_MPM_TYPE_PKT
SignatureInitData * init_data
int FastPatternSupportEnabledForSigMatchList(const DetectEngineCtx *de_ctx, const int list_id)
Checks if a particular buffer is in the list of lists that need to be searched for a keyword that has...
enum DetectBufferMpmType type
int MpmAddPatternCS(struct MpmCtx_ *mpm_ctx, uint8_t *pat, uint16_t patlen, uint16_t offset, uint16_t depth, uint32_t pid, SigIntId sid, uint8_t flags)
void DetectEngineBufferTypeSupportsTransformations(DetectEngineCtx *de_ctx, const char *name)
bool(* InspectionMultiBufferGetDataPtr)(struct DetectEngineThreadCtx_ *det_ctx, const void *txv, const uint8_t flow_flags, uint32_t local_id, const uint8_t **buf, uint32_t *buf_len)
#define SGH_DIRECTION_TS(sgh)
#define MPM_FEATURE_FLAG_ENDSWITH
MpmStore * MpmStorePrepareBuffer(DetectEngineCtx *de_ctx, SigGroupHead *sgh, enum MpmBuiltinBuffers buf)
Get MpmStore for a built-in buffer type.
int DetectMpmPrepareFrameMpms(DetectEngineCtx *de_ctx)
initialize mpm contexts for applayer buffers that are in "single or "shared" mode.
void DetectEngineFrameMpmRegister(DetectEngineCtx *de_ctx, const char *name, int direction, int priority, int(*PrefilterRegister)(DetectEngineCtx *de_ctx, SigGroupHead *sgh, MpmCtx *mpm_ctx, const DetectBufferMpmRegistry *mpm_reg, int list_id), AppProto alproto, uint8_t type)
int SignatureHasStreamContent(const Signature *s)
check if a signature has patterns that are to be inspected against the stream payload (as opposed to ...
enum DetectBufferMpmType type
int MpmStoreInit(DetectEngineCtx *de_ctx)
Initializes the MpmStore mpm hash table to be used by the detection engine context.
void DetectAppLayerMpmRegisterSingle(const char *name, int direction, int priority, PrefilterRegisterFunc PrefilterRegister, InspectionSingleBufferGetDataPtr GetData, AppProto alproto, int tx_min_progress)
DetectBufferMpmRegistry * app_mpms_list
@ DETECT_BUFFER_MPM_TYPE_APP
void DetectBufferTypeSupportsMpm(const char *name)
void HashListTableFree(HashListTable *ht)
void SupportFastPatternForSigMatchList(int list_id, int priority)
Lets one add a sm list id to be searched for potential fp supported keywords later.
struct DetectEngineFrameInspectionEngine * next
struct DetectEnginePktInspectionEngine * next
uint8_t PatternMatchDefaultMatcher(void)
Function to return the multi pattern matcher algorithm to be used by the engine, based on the mpm-alg...
int DetectMpmPreparePktMpms(DetectEngineCtx *de_ctx)
initialize mpm contexts for applayer buffers that are in "single or "shared" mode.
void DetectEngineBufferTypeSupportsMpm(DetectEngineCtx *de_ctx, const char *name)
uint32_t app_mpms_list_cnt
void DetectBufferTypeSupportsTransformations(const char *name)
#define MPM_PATTERN_FLAG_ENDSWITH
const char * builtin_mpms[]
SignatureInitDataBuffer * buffers
DetectEngineAppInspectionEngine * app_inspect_engines
HashListTable * mpm_hash_table
int(* Prepare)(MpmConfig *, struct MpmCtx_ *)
void(* DestroyCtx)(struct MpmCtx_ *)
int SigMatchListSMBelongsTo(const Signature *s, const SigMatch *key_sm)
#define MPM_CTX_FACTORY_UNIQUE_CONTEXT
int DetectMpmPrepareBuiltinMpms(DetectEngineCtx *de_ctx)
initialize mpm contexts for builtin buffers that are in "single or "shared" mode.
#define DETECT_CONTENT_OFFSET
int(* PrefilterRegisterWithListId)(struct DetectEngineCtx_ *de_ctx, struct SigGroupHead_ *sgh, MpmCtx *mpm_ctx, const struct DetectBufferMpmRegistry_ *mpm_reg, int list_id)
#define DETECT_CONTENT_MPM
a single match condition for a signature
void MpmInitThreadCtx(MpmThreadCtx *mpm_thread_ctx, MpmCtx *mpm_ctx, uint16_t matcher)
MpmTableElmt mpm_table[MPM_TABLE_SIZE]
void DetectMpmInitializeAppMpms(DetectEngineCtx *de_ctx)
InspectionBuffer *(* InspectionBufferGetDataPtr)(struct DetectEngineThreadCtx_ *det_ctx, const DetectEngineTransforms *transforms, Flow *f, const uint8_t flow_flags, void *txv, const int list_id)
@ DETECT_BUFFER_MPM_TYPE_SIZE
#define SGH_PROTO(sgh, p)
#define DETECT_CONTENT_REPLACE
void DetectPktMpmRegisterByParentId(DetectEngineCtx *de_ctx, const int id, const int parent_id, DetectEngineTransforms *transforms)
copy a mpm engine from parent_id, add in transforms
#define DETECT_CONTENT_FAST_PATTERN
#define MPMCTX_FLAGS_CACHE_TO_DISK
void DetectFrameMpmRegister(const char *name, int direction, int priority, int(*PrefilterRegister)(DetectEngineCtx *de_ctx, SigGroupHead *sgh, MpmCtx *mpm_ctx, const DetectBufferMpmRegistry *mpm_reg, int list_id), AppProto alproto, uint8_t type)
register a MPM engine
struct DetectBufferInstance DetectBufferInstance
#define SCMemcmp(a, b, c)
int DetectMpmPrepareAppMpms(DetectEngineCtx *de_ctx)
initialize mpm contexts for applayer buffers that are in "single or "shared" mode.
SCFPSupportSMList * fp_support_smlist_list
#define DEBUG_VALIDATE_BUG_ON(exp)
void PatternMatchThreadDestroy(MpmThreadCtx *mpm_thread_ctx, uint16_t mpm_matcher)
enum MpmBuiltinBuffers buffer
void RetrieveFPForSig(const DetectEngineCtx *de_ctx, Signature *s)
uint32_t StringHashDjb2(const uint8_t *data, uint32_t datalen)
int PrefilterPktStreamRegister(DetectEngineCtx *de_ctx, SigGroupHead *sgh, MpmCtx *mpm_ctx)
#define DETECT_CONTENT_OFFSET_VAR
int DetectProtoContainsProto(const DetectProto *dp, int proto)
see if a DetectProto contains a certain proto
#define SIG_FLAG_REQUIRE_PACKET