Go to the documentation of this file.
18 #include "../suricata-common.h"
20 #include "../detect.h"
21 #include "../detect-engine.h"
22 #include "../detect-engine-alert.h"
23 #include "../detect-parse.h"
25 #include "../util-unittest.h"
26 #include "../util-unittest-helper.h"
31 static int TestDetectAlertPacketApplySignatureActions01(
void)
34 uint8_t payload[] =
"Hi all!";
35 uint16_t length =
sizeof(payload) - 1;
37 (uint8_t *)payload, length, IPPROTO_TCP,
"192.168.1.5",
"192.168.1.1", 41424, 80);
40 const char sig[] =
"reject tcp any any -> any 80 (content:\"Hi all\"; sid:1; rev:1;)";
52 static int TestDetectAlertPacketApplySignatureActions02(
void)
54 uint8_t payload[] =
"Hi all!";
55 uint16_t length =
sizeof(payload) - 1;
57 (uint8_t *)payload, length, IPPROTO_TCP,
"192.168.1.5",
"192.168.1.1", 41424, 80);
60 const char sig[] =
"drop tcp any any -> any any (msg:\"sig 1\"; content:\"Hi all\"; sid:1;)";
74 TestDetectAlertPacketApplySignatureActions01);
76 TestDetectAlertPacketApplySignatureActions02);
#define FAIL_IF_NULL(expr)
Fail a test if expression evaluates to NULL.
void UtRegisterTest(const char *name, int(*TestFn)(void))
Register unit test.
#define ACTION_REJECT_ANY
int UTHPacketMatchSig(Packet *p, const char *sig)
Packet * UTHBuildPacketReal(uint8_t *payload, uint16_t payload_len, uint8_t ipproto, const char *src, const char *dst, uint16_t sport, uint16_t dport)
UTHBuildPacketReal is a function that create tcp/udp packets for unittests specifying ip and port sou...
#define FAIL_IF_NOT(expr)
Fail a test if expression evaluates to false.
#define PASS
Pass the test.
#define FAIL_IF(expr)
Fail a test if expression evaluates to true.
void DetectEngineAlertRegisterTests(void)
Registers Detect Engine Alert unit tests.
void UTHFreePackets(Packet **p, int numpkts)
UTHFreePackets: function to release the allocated data from UTHBuildPacket and the packet itself.