Go to the documentation of this file.
18 #include "../util-unittest.h"
19 #include "../util-unittest-helper.h"
20 #include "../app-layer-parser.h"
21 #include "../detect-engine.h"
22 #include "../detect-parse.h"
23 #include "../flow-util.h"
24 #include "../stream-tcp.h"
25 #include "../detect-engine-build.h"
27 static int DetectTemplateBufferTest(
void)
38 uint8_t request[] =
"Hello World!";
41 memset(&f, 0,
sizeof(
Flow));
48 f.
proto = IPPROTO_TCP;
60 "alert tcp any any -> any any ("
61 "msg:\"TEMPLATE Test Rule\"; "
62 "template_buffer; content:\"World!\"; "
68 "alert tcp any any -> any any ("
69 "msg:\"TEMPLATE Test Rule\"; "
70 "template_buffer; content:\"W0rld!\"; "
81 STREAM_TOSERVER, request,
sizeof(request));
101 static void DetectTemplateBufferRegisterTests(
void)
103 UtRegisterTest(
"DetectTemplateBufferTest", DetectTemplateBufferTest);
#define FAIL_IF_NULL(expr)
Fail a test if expression evaluates to NULL.
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::
void AppLayerParserThreadCtxFree(AppLayerParserThreadCtx *tctx)
Destroys the app layer parser thread context obtained using AppLayerParserThreadCtxAlloc().
#define FLOW_PKT_TOSERVER
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
Signature * DetectEngineAppendSig(DetectEngineCtx *, const char *)
Parse and append a Signature into the Detection Engine Context signature list.
void StreamTcpInitConfig(bool)
To initialize the stream global configuration data.
#define FLOW_INITIALIZE(f)
#define PASS
Pass the test.
AppLayerParserThreadCtx * alp_tctx
Per thread variable structure.
int SigGroupBuild(DetectEngineCtx *de_ctx)
Convert the signature list into the runtime match structure.
AppLayerParserThreadCtx * AppLayerParserThreadCtxAlloc(void)
Gets a new app layer protocol's parser thread context.
TmEcode DetectEngineThreadCtxInit(ThreadVars *, void *, void **)
initialize thread specific detection engine context
#define FAIL_IF(expr)
Fail a test if expression evaluates to true.
void StreamTcpFreeConfig(bool quiet)
int AppLayerParserParse(ThreadVars *tv, AppLayerParserThreadCtx *alp_tctx, Flow *f, AppProto alproto, uint8_t flags, const uint8_t *input, uint32_t input_len)
TmEcode DetectEngineThreadCtxDeinit(ThreadVars *, void *)
void UTHFreePacket(Packet *p)
UTHFreePacket: function to release the allocated data from UTHBuildPacket and the packet itself.
#define FLOW_PKT_ESTABLISHED
DetectEngineCtx * DetectEngineCtxInit(void)
AppProto alproto
application level protocol