Go to the documentation of this file.
53 #define MAX_ALPROTO_NAME 50
66 uint8_t
flags,
void *alstate,
void *tx, uint64_t tx_id);
67 static int g_applayer_events_list_id = 0;
76 "match on events generated by the App Layer Parsers and the protocol detection engine";
83 DetectEngineAptEventInspect, NULL);
85 DetectEngineAptEventInspect, NULL);
92 uint8_t
flags,
void *alstate,
void *tx, uint64_t tx_id)
98 if (decoder_events == NULL) {
106 if (AppLayerDecoderEventsIsEventSet(decoder_events, aled->
event_id)) {
148 uint8_t event_id = 0;
151 "supplied with packet based event - \"%s\" that isn't "
166 static bool OutdatedEvent(
const char *raw)
168 return strcmp(raw,
"tls.certificate_missing_element") == 0 ||
169 strcmp(raw,
"tls.certificate_unknown_element") == 0 ||
170 strcmp(raw,
"tls.certificate_invalid_string") == 0;
173 static AppProto AppLayerEventGetProtoByName(
char *alproto_name)
186 SCLogError(
"app-layer-event keyword supplied "
187 "with no arguments. This keyword needs an argument.");
191 while (*arg !=
'\0' && isspace((
unsigned char)*arg))
197 if (strchr(arg,
'.') == NULL) {
198 data = DetectAppLayerEventParsePkt(arg, &event_type);
204 bool needs_detctx =
false;
206 const char *p_idx = strchr(arg,
'.');
208 SCLogError(
"app-layer-event keyword is too long or malformed");
211 const char *event_name = p_idx + 1;
213 strlcpy(alproto_name, arg, p_idx - arg + 1);
215 const AppProto alproto = AppLayerEventGetProtoByName(alproto_name);
217 if (!strcmp(alproto_name,
"file")) {
221 "supplied with unknown protocol \"%s\"",
226 if (OutdatedEvent(arg)) {
228 SCLogError(
"app-layer-event keyword no longer supports event \"%s\"", arg);
231 SCLogWarning(
"app-layer-event keyword no longer supports event \"%s\"", arg);
237 if (s->
proto.
proto[IPPROTO_TCP / 8] & 1 << (IPPROTO_TCP % 8)) {
238 ipproto = IPPROTO_TCP;
239 }
else if (s->
proto.
proto[IPPROTO_UDP / 8] & 1 << (IPPROTO_UDP % 8)) {
240 ipproto = IPPROTO_UDP;
242 SCLogError(
"protocol %s is disabled", alproto_name);
247 uint8_t event_id = 0;
256 "protocol \"%s\" doesn't have event \"%s\" registered",
257 alproto_name, event_name);
261 "protocol \"%s\" doesn't have event \"%s\" registered",
262 alproto_name, event_name);
284 g_applayer_events_list_id) == NULL) {
294 DetectAppLayerEventFree(
de_ctx, data);
void DetectAppLayerEventRegister(void)
Registers the keyword handlers for the "app-layer-event" keyword.
SigTableElmt * sigmatch_table
void(* Free)(DetectEngineCtx *, void *)
AppProto AppLayerGetProtoByName(const char *alproto_name)
Given a protocol string, returns the corresponding internal protocol id.
AppLayerDecoderEvents * AppLayerParserGetEventsByTx(uint8_t ipproto, AppProto alproto, void *tx)
int AppLayerParserGetStateProgress(uint8_t ipproto, AppProto alproto, void *alstate, uint8_t flags)
get the progress value for a tx/protocol
struct DetectAppLayerEventData_ DetectAppLayerEventData
main detection engine ctx
int AppLayerParserGetStateProgressCompletionStatus(AppProto alproto, uint8_t direction)
int DetectEngineGetEventInfo(const char *event_name, uint8_t *event_id, AppLayerEventType *event_type)
int SCDetectSignatureSetAppProto(Signature *s, AppProto alproto)
#define SIG_FLAG_TOCLIENT
int(* Setup)(DetectEngineCtx *, Signature *, const char *)
#define KEYWORD_PROFILING_START
Data structure to store app layer decoder events.
AppLayerDecoderEvents * app_layer_events
#define SIG_FLAG_APPLAYER
int DetectBufferTypeGetByName(const char *name)
#define KEYWORD_PROFILING_END(ctx, type, m)
size_t strlcpy(char *dst, const char *src, size_t siz)
#define SIG_FLAG_TOSERVER
int AppLayerGetPktEventInfo(const char *event_name, uint8_t *event_id)
SigMatch * SCSigMatchAppendSMToList(DetectEngineCtx *de_ctx, Signature *s, uint16_t type, SigMatchCtx *ctx, const int list)
Append a SigMatch to the list type.
#define DETECT_ENGINE_INSPECT_SIG_MATCH
bool SigMatchStrictEnabled(const enum DetectKeywordId id)
#define SCLogWarning(...)
Macro used to log WARNING messages.
Data structures and function prototypes for keeping state for the detection engine.
int(* Match)(DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *)
#define DETECT_ENGINE_INSPECT_SIG_CANT_MATCH
Used to start a pointer to SigMatch context Should never be dereferenced without casting to something...
#define DETECT_ENGINE_INSPECT_SIG_NO_MATCH
#define SCLogError(...)
Macro used to log ERROR messages.
@ APP_LAYER_EVENT_TYPE_PACKET
void DetectAppLayerInspectEngineRegister(const char *name, AppProto alproto, uint32_t dir, int progress, InspectEngineFuncPtr Callback, InspectionBufferGetDataPtr GetData)
Registers an app inspection engine.
AppProto alproto
application level protocol
int AppLayerParserGetEventInfo(uint8_t ipproto, AppProto alproto, const char *event_name, uint8_t *event_id, AppLayerEventType *event_type)