Go to the documentation of this file.
50 static void DetectAckRegisterTests(
void);
54 static bool PrefilterTcpAckIsPrefilterable(
const Signature *s);
92 if (!(PacketIsTCP(p))) {
158 if (!PrefilterPacketHeaderExtraMatch(
ctx, p))
161 if (p->
proto == IPPROTO_TCP && PacketIsTCP(p) &&
164 PrefilterAddSids(&det_ctx->
pmq,
ctx->sigs_array,
ctx->sigs_cnt);
187 PrefilterPacketAckSet, PrefilterPacketAckCompare, PrefilterPacketAckMatch);
190 static bool PrefilterTcpAckIsPrefilterable(
const Signature *s)
208 static int DetectAckSigTest01(
void)
217 memset(&th_v, 0,
sizeof(th_v));
239 "alert tcp any any -> any any "
240 "(msg:\"Testing ack\";ack:foo;sid:1;)") != NULL)
242 printf(
"invalid ack accepted: ");
246 "alert tcp any any -> any any "
247 "(msg:\"Testing ack\";ack:9999999999;sid:1;)") != NULL)
249 printf(
"overflowing ack accepted: ");
253 "alert tcp any any -> any any "
254 "(msg:\"Testing ack\";ack:-100;sid:1;)") != NULL)
256 printf(
"negative ack accepted: ");
261 "alert tcp any any -> any any "
262 "(msg:\"Testing ack\";ack:41;sid:1;)");
268 "alert tcp any any -> any any "
269 "(msg:\"Testing ack\";ack:42;sid:2;)");
279 printf(
"sid 1 alerted, but should not have: ");
283 printf(
"sid 2 did not alert, but should have: ");
289 printf(
"sid 1 alerted, but should not have: ");
293 printf(
"sid 2 alerted, but should not have: ");
299 printf(
"sid 1 alerted, but should not have: ");
303 printf(
"sid 2 alerted, but should not have: ");
326 static void DetectAckRegisterTests(
void)
#define SIG_MASK_REQUIRE_REAL_PKT
struct SigMatch_ * smlists[DETECT_SM_LIST_MAX]
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.
int PacketAlertCheck(Packet *p, uint32_t sid)
Check if a certain sid alerted, this is used in the test functions.
main detection engine ctx
void DetectEngineCtxFree(DetectEngineCtx *)
Free a DetectEngineCtx::
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.
void SigMatchSignatures(ThreadVars *tv, DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, Packet *p)
wrapper for old tests
void SigCleanSignatures(DetectEngineCtx *de_ctx)
int(* Setup)(DetectEngineCtx *, Signature *, const char *)
int(* SetupPrefilter)(DetectEngineCtx *de_ctx, struct SigGroupHead_ *sgh)
Per thread variable structure.
TmEcode DetectEngineThreadCtxInit(ThreadVars *tv, void *initdata, void **data)
initialize thread specific detection engine context
int StringParseUint32(uint32_t *res, int base, size_t len, const char *str)
Signature * SigInit(DetectEngineCtx *de_ctx, const char *sigstr)
Parses a signature and adds it to the Detection Engine Context.
int SigGroupCleanup(DetectEngineCtx *de_ctx)
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...
void DetectAckRegister(void)
Registration function for ack: keyword.
TmEcode DetectEngineThreadCtxDeinit(ThreadVars *tv, void *data)
bool(* SupportsPrefilter)(const Signature *s)
a single match condition for a signature
union PacketL4::L4Hdrs hdrs
DetectEngineCtx * DetectEngineCtxInit(void)
SigMatch * SigMatchAppendSMToList(DetectEngineCtx *de_ctx, Signature *s, uint16_t type, SigMatchCtx *ctx, const int list)
Append a SigMatch to the list type.
#define TCP_GET_RAW_ACK(tcph)
#define DEBUG_VALIDATE_BUG_ON(exp)
void(* RegisterTests)(void)
#define SIG_FLAG_REQUIRE_PACKET