Go to the documentation of this file.
51 static void DetectL3protoRegisterTests(
void);
76 const char *
str = optstr;
84 if (strcasecmp(
str,
"ipv4") == 0 ||
85 strcasecmp(
str,
"ip4") == 0 ) {
92 }
else if (strcasecmp(
str,
"ipv6") == 0 ||
93 strcasecmp(
str,
"ip6") == 0 ) {
119 static int DetectL3protoTestSig1(
void)
129 memset(&th_v, 0,
sizeof(th_v));
133 p->
proto = IPPROTO_TCP;
142 de_ctx,
"alert ip any any -> any any (msg:\"l3proto ipv4\"; l3_proto:ipv4; sid:1;)");
146 de_ctx,
"alert ip any any -> any any (msg:\"l3proto ipv6\"; l3_proto:ipv6; sid:2;)");
150 de_ctx,
"alert ip any any -> any any (msg:\"l3proto ip4\"; l3_proto:ip4; sid:3;)");
154 de_ctx,
"alert ip any any -> any any (msg:\"l3proto ip6\"; l3_proto:ip6; sid:4;)");
180 static int DetectL3protoTestSig2(
void)
190 memset(&th_v, 0,
sizeof(th_v));
194 p->
proto = IPPROTO_TCP;
203 de_ctx,
"alert ip any any -> any any (msg:\"l3proto ipv4\"; l3_proto:ipv4; sid:1;)");
207 de_ctx,
"alert ip any any -> any any (msg:\"l3proto ipv6\"; l3_proto:ipv6; sid:2;)");
211 de_ctx,
"alert ip any any -> any any (msg:\"l3proto ip4\"; l3_proto:ip4; sid:3;)");
215 de_ctx,
"alert ip any any -> any any (msg:\"l3proto ip6\"; l3_proto:ip6; sid:4;)");
240 static int DetectL3protoTestSig3(
void)
250 memset(&th_v, 0,
sizeof(th_v));
254 p->
proto = IPPROTO_TCP;
263 "ip_proto udp\"; l3_proto:ipv4; ip_proto:17; sid:1;)");
267 "ip_proto udp\"; l3_proto:ipv6; ip_proto:17; sid:2;)");
271 "tcp\"; l3_proto:ipv4; ip_proto:6; sid:3;)");
275 "ip_proto tcp\"; l3_proto:ipv6; ip_proto:6; sid:4;)");
298 static void DetectL3protoRegisterTests(
void)
#define FAIL_IF_NULL(expr)
Fail a test if expression evaluates to NULL.
SigTableElmt * sigmatch_table
void(* Free)(DetectEngineCtx *, void *)
#define DETECT_PROTO_IPV6
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.
void UTHSetIPV4Hdr(Packet *p, IPV4Hdr *ip4h)
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
void UTHSetIPV6Hdr(Packet *p, IPV6Hdr *ip6h)
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.
#define PASS
Pass the test.
void DetectL3ProtoRegister(void)
Registration function for ip_proto keyword.
Per thread variable structure.
TmEcode DetectEngineThreadCtxInit(ThreadVars *tv, void *initdata, void **data)
initialize thread specific detection engine context
int(* Match)(DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *)
int SigGroupBuild(DetectEngineCtx *de_ctx)
Convert the signature list into the runtime match structure.
#define DETECT_PROTO_IPV4
#define FAIL_IF(expr)
Fail a test if expression evaluates to true.
TmEcode DetectEngineThreadCtxDeinit(ThreadVars *tv, void *data)
Packet * PacketGetFromAlloc(void)
Get a malloced packet.
#define SCLogError(...)
Macro used to log ERROR messages.
DetectEngineCtx * DetectEngineCtxInit(void)
void(* RegisterTests)(void)