Go to the documentation of this file.
66 char buffer_name[512] =
"";
70 if (!(is_tcp || is_udp)) {
71 SCLogError(
"'frame' keyword only supported for TCP and UDP");
75 char *dot = strchr(value,
'.');
78 const char *val = dot ? dot : value;
79 const char *
proto = dot ? value : NULL;
81 bool is_short =
false;
87 if (!AppProtoIsValid(keyword_alproto)) {
89 keyword_alproto = rule_alproto;
93 keyword_alproto = rule_alproto;
97 SCLogError(
"rule protocol unknown, can't use shorthand notation for frame '%s'",
str);
102 }
else if (!AppProtoEquals(rule_alproto, keyword_alproto)) {
103 SCLogError(
"frame '%s' protocol '%s' mismatch with rule protocol '%s'",
str,
108 const char *frame_str = is_short ?
str : val;
109 int raw_frame_type = -1;
111 if (strcmp(frame_str,
"stream") == 0) {
118 if (is_udp && raw_frame_type < 0)
120 if (raw_frame_type < 0) {
124 BUG_ON(raw_frame_type > UINT8_MAX);
130 strlcpy(buffer_name,
str,
sizeof(buffer_name));
134 uint8_t frame_type = (uint8_t)raw_frame_type;
150 static int DetectFrameTestBadRules(
void)
155 const char *sigs[] = {
156 "alert tcp-pkt any any -> any any (frame:tls.pdu; content:\"a\"; sid:1;)",
157 "alert udp any any -> any any (frame:tls.pdu; content:\"a\"; sid:2;)",
158 "alert smb any any -> any any (frame:tls.pdu; content:\"a\"; sid:3;)",
159 "alert tcp any any -> any any (frame:tls; content:\"a\"; sid:4;)",
160 "alert tls any any -> any any (content:\"abc\"; frame:tls.pdu; content:\"a\"; sid:5;)",
161 "alert tls any any -> any any (tls.version:1.0; frame:tls.pdu; content:\"a\"; sid:6;)",
162 "alert tls any any -> any any (frame:smb1.pdu; content:\"a\"; sid:7;)",
166 const char **sig = sigs;
178 static void DetectFrameRegisterTests(
void)
180 UtRegisterTest(
"DetectFrameTestBadRules", DetectFrameTestBadRules);
int DetectSignatureSetAppProto(Signature *s, AppProto alproto)
#define FAIL_IF_NULL(expr)
Fail a test if expression evaluates to NULL.
#define SIGMATCH_INFO_STICKY_BUFFER
SigTableElmt * sigmatch_table
void UtRegisterTest(const char *name, int(*TestFn)(void))
Register unit test.
int DetectBufferSetActiveList(DetectEngineCtx *de_ctx, Signature *s, const int list)
const char * AppProtoToString(AppProto alproto)
Maps the ALPROTO_*, to its string equivalent.
main detection engine ctx
void DetectEngineCtxFree(DetectEngineCtx *)
Free a DetectEngineCtx::
Signature * DetectEngineAppendSig(DetectEngineCtx *, const char *)
Parse and append a Signature into the Detection Engine Context signature list.
#define SIG_FLAG_TOCLIENT
int(* Setup)(DetectEngineCtx *, Signature *, const char *)
size_t strlcpy(char *dst, const char *src, size_t siz)
#define SIG_FLAG_TOSERVER
#define FAIL_IF_NOT_NULL(expr)
Fail a test if expression evaluates to non-NULL.
#define PASS
Pass the test.
AppProto StringToAppProto(const char *proto_name)
Maps a string to its ALPROTO_* equivalent.
int DetectEngineBufferTypeRegisterWithFrameEngines(DetectEngineCtx *de_ctx, const char *name, const int direction, const AppProto alproto, const uint8_t frame_type)
int AppLayerParserGetFrameIdByName(uint8_t ipproto, AppProto alproto, const char *name)
#define FRAME_STREAM_TYPE
#define SCLogError(...)
Macro used to log ERROR messages.
void FrameConfigEnable(const AppProto p, const uint8_t type)
DetectEngineCtx * DetectEngineCtxInit(void)
void(* RegisterTests)(void)
int DetectProtoContainsProto(const DetectProto *dp, int proto)
see if a DetectProto contains a certain proto
void DetectFrameRegister(void)
Registration function for keyword: ja3_hash.