31 static uint32_t PrefilterPacketHeaderHashFunc(
HashListTable *ht,
void *data, uint16_t datalen)
34 uint64_t hash =
ctx->v1.u64[0] +
ctx->v1.u64[1] +
ctx->type +
ctx->value;
39 static char PrefilterPacketHeaderCompareFunc(
void *data1, uint16_t len1,
40 void *data2, uint16_t len2)
50 static void PrefilterPacketHeaderFreeFunc(
void *ptr)
55 static void PrefilterPacketHeaderFree(
void *pectx)
62 static void PrefilterPacketU8HashCtxFree(
void *vctx)
66 for (i = 0; i < 256; i++) {
76 static void GetExtraMatch(
const Signature *s, uint16_t *
type, uint16_t *value)
103 uint32_t sig_offset = 0;
113 ctx->sigs_cnt = hctx->
cnt;
115 if (
ctx->sigs_array == NULL) {
129 GetExtraMatch(s, &
type, &value);
134 SCLogDebug(
"appending sid %u on %u", s->
id, sig_offset);
135 ctx->sigs_array[sig_offset] = s->
num;
142 SCLogDebug(
"%s: ctx %p extra type %u extra value %u, sig cnt %u",
163 uint8_t x = v.
u8[1] - 1;
187 }
while (++x < v.
u8[2]);
214 for (
int i = 0; i < 256; i++) {
220 ctx->array[i]->cnt = counts[i];
227 PrefilterPacketU8HashCtxFree(
ctx);
239 memset(&v, 0,
sizeof(v));
242 ApplyToU8Hash(
ctx, v, s);
251 PrefilterPacketU8HashCtxFree(
ctx);
267 SetupEngineForPacketHeader(
de_ctx, sgh, sm_type, mask,
ctx, Compare, Match);
279 uint32_t counts[256];
280 memset(&counts, 0,
sizeof(counts));
286 switch (
ctx->v1.u8[0]) {
288 counts[
ctx->v1.u8[1]] +=
ctx->cnt;
292 uint8_t v =
ctx->v1.u8[1];
295 counts[v] +=
ctx->cnt;
302 uint8_t v =
ctx->v1.u8[1];
303 while (v < UINT8_MAX) {
305 counts[v] +=
ctx->cnt;
312 if (
ctx->v1.u8[1] <
ctx->v1.u8[2]) {
314 uint8_t v =
ctx->v1.u8[1] + 1;
315 while (v < ctx->v1.u8[2]) {
316 counts[v] +=
ctx->cnt;
325 SetupEngineForPacketHeaderPrefilterPacketU8HashCtx(
326 de_ctx, sgh, sm_type, mask, counts, Set, Compare, Match);
343 PrefilterPacketHeaderHashFunc,
344 PrefilterPacketHeaderCompareFunc,
345 PrefilterPacketHeaderFreeFunc);
346 if (hash_table == NULL)
357 memset(&
ctx, 0,
sizeof(
ctx));
360 GetExtraMatch(s, &
ctx.type, &
ctx.value);
384 SetupSingle(
de_ctx, hash_table, sgh, sm_type, mask, Compare, Match);
386 SetupU8Hash(
de_ctx, hash_table, sgh, sm_type, mask, Set, Compare, Match);
401 return PrefilterSetupPacketHeaderCommon(
de_ctx, sgh, sm_type, mask, Set, Compare, Match,
true);
409 return PrefilterSetupPacketHeaderCommon(
de_ctx, sgh, sm_type, mask, Set, Compare, Match,
false);