Go to the documentation of this file.
53 static void DetectIdRegisterTests(
void);
58 static bool PrefilterIdIsPrefilterable(
const Signature *s);
99 if (!PacketIsIPv4(p)) {
103 const IPV4Hdr *ip4h = PacketGetIPv4(p);
142 SCDetectU16Free(ptr);
154 if (!PacketIsIPv4(p)) {
158 if (!PrefilterPacketHeaderExtraMatch(
ctx, p))
161 const IPV4Hdr *ip4h = PacketGetIPv4(p);
163 du16.mode =
ctx->v1.u8[0];
164 du16.arg1 =
ctx->v1.u16[1];
165 du16.arg2 =
ctx->v1.u16[2];
168 PrefilterAddSids(&det_ctx->
pmq,
ctx->sigs_array,
ctx->sigs_cnt);
178 static bool PrefilterIdIsPrefilterable(
const Signature *s)
196 static int DetectIdTestParse01 (
void)
213 static int DetectIdTestParse02 (
void)
227 static int DetectIdTestParse03 (
void)
240 static int DetectIdTestParse04 (
void)
243 DetectU16Data *id_d = SCDetectU16UnquoteParse(
" \"35402\" ");
257 static int DetectIdTestMatch01(
void)
259 uint8_t *buf = (uint8_t *)
"Hi all!";
260 uint16_t buflen = strlen((
char *)buf);
280 sigs[0]=
"alert ip any any -> any any (msg:\"Testing id 1\"; id:1234; sid:1;)";
281 sigs[1]=
"alert ip any any -> any any (msg:\"Testing id 2\"; id:5678; sid:2;)";
282 sigs[2]=
"alert ip any any -> any any (msg:\"Testing id 3\"; id:5101; sid:3;)";
284 uint32_t sid[3] = {1, 2, 3};
286 uint32_t results[3][3] = {
304 void DetectIdRegisterTests(
void)
#define SIGMATCH_INFO_UINT16
#define IPV4_GET_RAW_IPID(ip4h)
#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 PrefilterPacketU16Set(PrefilterPacketHeaderValue *v, void *smctx)
SigTableElmt * sigmatch_table
void(* Free)(DetectEngineCtx *, void *)
#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.
main detection engine ctx
union PacketL3::Hdrs hdrs
Packet * UTHBuildPacket(uint8_t *payload, uint16_t payload_len, uint8_t ipproto)
UTHBuildPacket is a wrapper that build packets with default ip and port fields.
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)
#define FAIL_IF_NOT_NULL(expr)
Fail a test if expression evaluates to non-NULL.
#define PASS
Pass the test.
SigMatch * SCSigMatchAppendSMToList(DetectEngineCtx *de_ctx, Signature *s, uint16_t type, SigMatchCtx *ctx, const int list)
Append a SigMatch to the list type.
void DetectIdRegister(void)
Registration function for keyword: id.
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 *)
Used to start a pointer to SigMatch context Should never be dereferenced without casting to something...
int DetectU16Match(const uint16_t parg, const DetectUintData_u16 *du16)
bool PrefilterPacketU16Compare(PrefilterPacketHeaderValue v, void *smctx)
int UTHGenericTest(Packet **pkt, int numpkts, const char *sigs[], uint32_t sids[], uint32_t *results, int numsigs)
UTHGenericTest: function that perform a generic check taking care of as maximum common unittest eleme...
bool(* SupportsPrefilter)(const Signature *s)
a single match condition for a signature
void DetectIdFree(DetectEngineCtx *, void *)
this function will free memory associated with DetectIdData
DetectUintData_u16 DetectU16Data
#define DEBUG_VALIDATE_BUG_ON(exp)
void(* RegisterTests)(void)
#define SIG_FLAG_REQUIRE_PACKET
void UTHFreePackets(Packet **p, int numpkts)
UTHFreePackets: function to release the allocated data from UTHBuildPacket and the packet itself.