Go to the documentation of this file.
54 {
"tcp", IPPROTO_TCP, 0, 0, },
57 {
"udp", IPPROTO_UDP, 0, 0, },
58 {
"icmpv4", IPPROTO_ICMP, 0, 0, },
59 {
"icmpv6", IPPROTO_ICMPV6, 0, 0, },
60 {
"icmp", IPPROTO_ICMP, IPPROTO_ICMPV6, 0, },
61 {
"igmp", IPPROTO_IGMP, 0, 0, },
142 static int DetectProtoIsOnlyTCPUDP(
const DetectProto *dp)
144 uint8_t protos[256 / 8];
145 memset(protos, 0x00,
sizeof(protos));
146 protos[IPPROTO_TCP / 8] |= (1 << (IPPROTO_TCP % 8));
147 protos[IPPROTO_UDP / 8] |= (1 << (IPPROTO_UDP % 8));
150 for (
size_t i = 0; i <
sizeof(protos); i++) {
151 if ((dp->
proto[i] & protos[i]) != 0)
173 SCLogDebug(
"sid %u has IPV4 or IPV6 flag set, so need full protocol", s->
id);
187 if (s->
proto == NULL)
210 static uint32_t test_sid = 1;
214 if (snprintf(fullstr, 1024,
215 "alert %s any any -> any any (msg:\"DetectProto"
217 str, test_sid++) >= 1024) {
246 static int ProtoTestParse01 (
void)
261 static int ProtoTestParse02 (
void)
277 static int ProtoTestParse03 (
void)
294 static int ProtoTestParse04 (
void)
311 static int ProtoTestParse05 (
void)
327 static int ProtoTestParse06 (
void)
344 static int ProtoTestParse07 (
void)
362 static int DetectProtoTestSetup01(
void)
369 memset(&dp, 0,
sizeof(dp));
376 for (i = 2; i < 256 / 8; i++) {
389 static int DetectProtoTestSetup02(
void)
397 memset(&dp, 0,
sizeof(dp));
399 FAIL_IF(DetectProtoInitTest(&
de_ctx, &sig_icmpv4, &dp,
"icmpv4") == 0);
400 FAIL_IF(DetectProtoInitTest(&
de_ctx, &sig_icmpv6, &dp,
"icmpv6") == 0);
401 FAIL_IF(DetectProtoInitTest(&
de_ctx, &sig_icmp, &dp,
"icmp") == 0);
419 static int DetectProtoTestSig01(
void)
427 de_ctx,
"alert tcp-pkt any any -> any any (msg:\"tcp-pkt\"; content:\"blah\"; sid:1;)");
431 "alert tcp-stream any any -> any any (msg:\"tcp-stream\"; content:\"blah\"; sid:2;)");
#define FAIL_IF_NULL(expr)
Fail a test if expression evaluates to NULL.
void DetectEngineProtoList(void)
#define DETECT_PROTO_IPV6
void UtRegisterTest(const char *name, int(*TestFn)(void))
Register unit test.
main detection engine ctx
#define DETECT_PROTO_ETHERNET
void DetectEngineCtxFree(DetectEngineCtx *)
Free a DetectEngineCtx::
Signature * DetectEngineAppendSig(DetectEngineCtx *, const char *)
Parse and append a Signature into the Detection Engine Context signature list.
#define FAIL_IF_NOT(expr)
Fail a test if expression evaluates to false.
#define PASS
Pass the test.
int DetectProtoParse(DetectProto *dp, const char *str)
Parses a protocol sent as a string.
SignatureInitData * init_data
Data structures and function prototypes for keeping state for the detection engine.
#define DETECT_PROTO_IPV4
#define FAIL_IF(expr)
Fail a test if expression evaluates to true.
#define SIG_FLAG_INIT_FRAME
#define DETECT_PROTO_ONLY_STREAM
bool DetectProtoHasExplicitProto(const DetectProto *dp, const uint8_t proto)
see if a DetectProto explicitly a certain proto Explicit means the protocol was explicitly set,...
#define DETECT_PROTO_ONLY_PKT
DetectEngineCtx * DetectEngineCtxInit(void)
#define DETECT_PROTO_L2_ANY
int DetectProtoContainsProto(const DetectProto *dp, int proto)
see if a DetectProto contains a certain proto
int DetectProtoFinalizeSignature(Signature *s)
void DetectProtoTests(void)
this function registers unit tests for DetectProto