suricata
app-layer-events.h
Go to the documentation of this file.
1 /* Copyright (C) 2014-2022 Open Information Security Foundation
2  *
3  * You can copy, redistribute or modify this Program under the terms of
4  * the GNU General Public License version 2 as published by the Free
5  * Software Foundation.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * version 2 along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15  * 02110-1301, USA.
16  */
17 
18 /**
19  * \file
20  *
21  * \author Victor Julien <victor@inliniac.net>
22  * \author Anoop Saldanha <anoopsaldanha@gmail.com>
23  */
24 
25 #ifndef __APP_LAYER_EVENTS_H__
26 #define __APP_LAYER_EVENTS_H__
27 
28 /* contains fwd declaration of AppLayerDecoderEvents_ */
29 #include "decode.h"
30 
31 /**
32  * \brief Data structure to store app layer decoder events.
33  */
35  /* array of events */
36  uint8_t *events;
37  /* number of events in the above buffer */
38  uint8_t cnt;
39  /* current event buffer size */
41  /* last logged */
43 };
44 
45 /* app layer pkt level events */
46 enum {
53 };
54 
55 /* the event types for app events */
56 typedef enum AppLayerEventType_ {
60 
61 int AppLayerGetPktEventInfo(const char *event_name, int *event_id);
62 
63 int AppLayerGetEventInfoById(int event_id, const char **event_name,
64  AppLayerEventType *event_type);
65 void AppLayerDecoderEventsSetEventRaw(AppLayerDecoderEvents **sevents, uint8_t event);
66 
67 static inline int AppLayerDecoderEventsIsEventSet(AppLayerDecoderEvents *devents,
68  uint8_t event)
69 {
70  if (devents == NULL)
71  return 0;
72 
73  int i;
74  int cnt = devents->cnt;
75  for (i = 0; i < cnt; i++) {
76  if (devents->events[i] == event)
77  return 1;
78  }
79 
80  return 0;
81 }
82 
85 
86 #endif /* __APP_LAYER_EVENTS_H__ */
87 
APPLAYER_MISMATCH_PROTOCOL_BOTH_DIRECTIONS
@ APPLAYER_MISMATCH_PROTOCOL_BOTH_DIRECTIONS
Definition: app-layer-events.h:47
AppLayerDecoderEventsFreeEvents
void AppLayerDecoderEventsFreeEvents(AppLayerDecoderEvents **events)
Definition: app-layer-events.c:134
APPLAYER_WRONG_DIRECTION_FIRST_DATA
@ APPLAYER_WRONG_DIRECTION_FIRST_DATA
Definition: app-layer-events.h:48
AppLayerEventType
enum AppLayerEventType_ AppLayerEventType
AppLayerDecoderEvents_::events_buffer_size
uint8_t events_buffer_size
Definition: app-layer-events.h:40
AppLayerDecoderEvents_::event_last_logged
uint8_t event_last_logged
Definition: app-layer-events.h:42
AppLayerDecoderEvents_
Data structure to store app layer decoder events.
Definition: app-layer-events.h:34
APP_LAYER_EVENT_TYPE_TRANSACTION
@ APP_LAYER_EVENT_TYPE_TRANSACTION
Definition: app-layer-events.h:57
AppLayerDecoderEventsResetEvents
void AppLayerDecoderEventsResetEvents(AppLayerDecoderEvents *events)
Definition: app-layer-events.c:125
APP_LAYER_EVENT_TYPE_PACKET
@ APP_LAYER_EVENT_TYPE_PACKET
Definition: app-layer-events.h:58
APPLAYER_DETECT_PROTOCOL_ONLY_ONE_DIRECTION
@ APPLAYER_DETECT_PROTOCOL_ONLY_ONE_DIRECTION
Definition: app-layer-events.h:49
decode.h
APPLAYER_PROTO_DETECTION_SKIPPED
@ APPLAYER_PROTO_DETECTION_SKIPPED
Definition: app-layer-events.h:50
AppLayerDecoderEventsSetEventRaw
void AppLayerDecoderEventsSetEventRaw(AppLayerDecoderEvents **sevents, uint8_t event)
Set an app layer decoder event.
Definition: app-layer-events.c:91
APPLAYER_NO_TLS_AFTER_STARTTLS
@ APPLAYER_NO_TLS_AFTER_STARTTLS
Definition: app-layer-events.h:51
AppLayerDecoderEvents_::cnt
uint8_t cnt
Definition: app-layer-events.h:38
AppLayerGetEventInfoById
int AppLayerGetEventInfoById(int event_id, const char **event_name, AppLayerEventType *event_type)
Definition: app-layer-events.c:51
AppLayerGetPktEventInfo
int AppLayerGetPktEventInfo(const char *event_name, int *event_id)
Definition: app-layer-events.c:68
AppLayerEventType_
AppLayerEventType_
Definition: app-layer-events.h:56
APPLAYER_UNEXPECTED_PROTOCOL
@ APPLAYER_UNEXPECTED_PROTOCOL
Definition: app-layer-events.h:52
AppLayerDecoderEvents_::events
uint8_t * events
Definition: app-layer-events.h:36