Go to the documentation of this file.
52 static bool PrefilterFragOffsetIsPrefilterable(
const Signature *s);
93 if (PacketIsIPv4(p)) {
94 const IPV4Hdr *ip4h = PacketGetIPv4(p);
96 }
else if (PacketIsIPv6(p)) {
147 SCDetectU16Free(ptr);
157 if (PacketIsIPv4(p)) {
158 const IPV4Hdr *ip4h = PacketGetIPv4(p);
160 }
else if (PacketIsIPv6(p)) {
173 du16.mode =
ctx->v1.u8[0];
174 du16.arg1 =
ctx->v1.u16[1];
175 du16.arg2 =
ctx->v1.u16[2];
178 PrefilterAddSids(&det_ctx->
pmq,
ctx->sigs_array,
ctx->sigs_cnt);
188 static bool PrefilterFragOffsetIsPrefilterable(
const Signature *s)
208 static int DetectFragOffsetParseTest01 (
void)
224 static int DetectFragOffsetParseTest02 (
void)
240 static int DetectFragOffsetParseTest03 (
void)
254 static int DetectFragOffsetMatchTest01 (
void)
265 memset(&ip4h, 0,
sizeof(
IPV4Hdr));
273 p->
src.addr_data32[0] = 0x01020304;
274 p->
dst.addr_data32[0] = 0x04030201;
276 ip4h.s_ip_src.s_addr = p->
src.addr_data32[0];
277 ip4h.s_ip_dst.s_addr = p->
dst.addr_data32[0];
310 UtRegisterTest(
"DetectFragOffsetParseTest01", DetectFragOffsetParseTest01);
311 UtRegisterTest(
"DetectFragOffsetParseTest02", DetectFragOffsetParseTest02);
312 UtRegisterTest(
"DetectFragOffsetParseTest03", DetectFragOffsetParseTest03);
313 UtRegisterTest(
"DetectFragOffsetMatchTest01", DetectFragOffsetMatchTest01);
#define SIGMATCH_INFO_UINT16
#define FAIL_IF_NULL(expr)
Fail a test if expression evaluates to NULL.
#define SIG_MASK_REQUIRE_REAL_PKT
struct SigMatch_ * smlists[DETECT_SM_LIST_MAX]
void DetectFragOffsetRegisterTests(void)
void PrefilterPacketU16Set(PrefilterPacketHeaderValue *v, void *smctx)
SigTableElmt * sigmatch_table
void(* Free)(DetectEngineCtx *, void *)
#define IPV6_EXTHDR_GET_FH_OFFSET(p)
#define PKT_IS_PSEUDOPKT(p)
return 1 if the packet is a pseudo packet
Container for matching data for a signature group.
void UtRegisterTest(const char *name, int(*TestFn)(void))
Register unit test.
#define IPV6_EXTHDR_ISSET_FH(p)
int PacketAlertCheck(Packet *p, uint32_t sid)
Check if a certain sid alerted, this is used in the test functions.
void UTHSetIPV4Hdr(Packet *p, IPV4Hdr *ip4h)
void DetectFragOffsetRegister(void)
Registration function for fragoffset.
main detection engine ctx
void DetectEngineCtxFree(DetectEngineCtx *)
Free a DetectEngineCtx::
void SigMatchSignatures(ThreadVars *tv, DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, Packet *p)
wrapper for old tests
Signature * DetectEngineAppendSig(DetectEngineCtx *, const char *)
Parse and append a Signature into the Detection Engine Context signature list.
int(* Setup)(DetectEngineCtx *, Signature *, const char *)
#define FAIL_IF_NOT(expr)
Fail a test if expression evaluates to false.
int(* SetupPrefilter)(DetectEngineCtx *de_ctx, struct SigGroupHead_ *sgh)
void FlowInitConfig(bool quiet)
initialize the configuration
void DetectFragOffsetFree(DetectEngineCtx *, void *)
this function will free memory associated with DetectFragOffsetData
#define FAIL_IF_NOT_NULL(expr)
Fail a test if expression evaluates to non-NULL.
#define PASS
Pass the test.
#define IPV4_GET_RAW_FRAGOFFSET(ip4h)
SigMatch * SCSigMatchAppendSMToList(DetectEngineCtx *de_ctx, Signature *s, uint16_t type, SigMatchCtx *ctx, const int list)
Append a SigMatch to the list type.
Per thread variable structure.
TmEcode DetectEngineThreadCtxInit(ThreadVars *tv, void *initdata, void **data)
initialize thread specific detection engine context
void PacketFree(Packet *p)
Return a malloced packet.
SignatureInitData * init_data
int PrefilterSetupPacketHeader(DetectEngineCtx *de_ctx, SigGroupHead *sgh, int sm_type, SignatureMask mask, void(*Set)(PrefilterPacketHeaderValue *v, void *), bool(*Compare)(PrefilterPacketHeaderValue v, void *), void(*Match)(DetectEngineThreadCtx *det_ctx, Packet *p, const void *pectx))
int(* Match)(DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *)
int SigGroupBuild(DetectEngineCtx *de_ctx)
Convert the signature list into the runtime match structure.
Used to start a pointer to SigMatch context Should never be dereferenced without casting to something...
#define FAIL_IF(expr)
Fail a test if expression evaluates to true.
int DetectU16Match(const uint16_t parg, const DetectUintData_u16 *du16)
bool PrefilterPacketU16Compare(PrefilterPacketHeaderValue v, void *smctx)
void FlowShutdown(void)
shutdown the flow engine
TmEcode DetectEngineThreadCtxDeinit(ThreadVars *tv, void *data)
Packet * PacketGetFromAlloc(void)
Get a malloced packet.
Structure to hold thread specific data for all decode modules.
bool(* SupportsPrefilter)(const Signature *s)
a single match condition for a signature
DetectEngineCtx * DetectEngineCtxInit(void)
DetectUintData_u16 DetectU16Data
void StatsThreadCleanup(ThreadVars *tv)
#define DEBUG_VALIDATE_BUG_ON(exp)
void(* RegisterTests)(void)
#define SIG_FLAG_REQUIRE_PACKET