suricata
app-layer-register.h
Go to the documentation of this file.
1 /* Copyright (C) 2017 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 Pierre Chifflier <chifflier@wzdftpd.net>
22  */
23 
24 #ifndef __APP_LAYER_REGISTER_H__
25 #define __APP_LAYER_REGISTER_H__
26 
27 typedef struct AppLayerParser {
28  const char *name;
29  const char *default_port;
30  uint8_t ip_proto;
31 
34 
35  uint16_t min_depth;
36  uint16_t max_depth;
37 
38  void *(*StateAlloc)(void *, AppProto);
39  void (*StateFree)(void *);
40 
43 
44  uint64_t (*StateGetTxCnt)(void *alstate);
45  void *(*StateGetTx)(void *alstate, uint64_t tx_id);
46  void (*StateTransactionFree)(void *, uint64_t);
47 
48  const int complete_ts;
49  const int complete_tc;
50  int (*StateGetProgress)(void *alstate, uint8_t direction);
51 
52  int (*StateGetEventInfo)(const char *event_name,
53  int *event_id, AppLayerEventType *event_type);
54  int (*StateGetEventInfoById)(int event_id, const char **event_name,
55  AppLayerEventType *event_type);
56 
57  void *(*LocalStorageAlloc)(void);
58  void (*LocalStorageFree)(void *);
59 
60  FileContainer *(*StateGetFiles)(void *, uint8_t);
61 
62  AppLayerGetTxIterTuple (*GetTxIterator)(const uint8_t ipproto,
63  const AppProto alproto, void *alstate, uint64_t min_tx_id,
64  uint64_t max_tx_id, AppLayerGetTxIterState *istate);
65 
66  AppLayerTxData *(*GetTxData)(void *tx);
67  bool (*ApplyTxConfig)(void *state, void *tx, int mode, AppLayerTxConfig);
68 
69  uint32_t flags;
70 
71  void (*Truncate)(void *state, uint8_t direction);
72 
75 
77 
78 /**
79  * \brief App layer protocol detection function.
80  *
81  * \param parser The parser declaration structure.
82  * \param enable_default A boolean to indicate if default port configuration should be used if none given
83  *
84  * \retval The AppProto constant if successful. On error, this function never returns.
85  */
86 AppProto AppLayerRegisterProtocolDetection(const struct AppLayerParser *parser, int enable_default);
87 
88 /**
89  * \brief App layer protocol registration function.
90  *
91  * \param parser The parser declaration structure.
92  * \param alproto The application layer protocol identifier.
93  *
94  * \retval 0 if successful. On error, this function never returns.
95  */
96 int AppLayerRegisterParser(const struct AppLayerParser *p, AppProto alproto);
97 
98 int AppLayerRegisterParserAlias(const char *proto_name, const char *proto_alias);
99 
100 #endif /* __APP_LAYER_REGISTER_H__ */
AppLayerParser::ip_proto
uint8_t ip_proto
Definition: app-layer-register.h:30
AppLayerParser::StateGetEventInfo
int(* StateGetEventInfo)(const char *event_name, int *event_id, AppLayerEventType *event_type)
Definition: app-layer-register.h:52
FileContainer_
Definition: util-file.h:110
AppLayerParser::default_port
const char * default_port
Definition: app-layer-register.h:29
AppLayerParser::max_depth
uint16_t max_depth
Definition: app-layer-register.h:36
AppLayerParser
struct AppLayerParser AppLayerParser
AppProto
uint16_t AppProto
Definition: app-layer-protos.h:80
AppLayerEventType
enum AppLayerEventType_ AppLayerEventType
AppLayerParser::ProbeTS
ProbingParserFPtr ProbeTS
Definition: app-layer-register.h:32
ProbingParserFPtr
AppProto(* ProbingParserFPtr)(Flow *f, uint8_t flags, const uint8_t *input, uint32_t input_len, uint8_t *rdir)
Definition: app-layer-detect-proto.h:30
AppLayerParser::Truncate
void(* Truncate)(void *state, uint8_t direction)
Definition: app-layer-register.h:71
AppLayerParser::ParseTS
AppLayerParserFPtr ParseTS
Definition: app-layer-register.h:41
AppLayerParser::StateFree
void(* StateFree)(void *)
Definition: app-layer-register.h:39
AppLayerParserFPtr
AppLayerResult(* AppLayerParserFPtr)(Flow *f, void *protocol_state, AppLayerParserState *pstate, StreamSlice stream_slice, void *local_storage)
Prototype for parsing functions.
Definition: app-layer-parser.h:140
AppLayerParser::StateGetProgress
int(* StateGetProgress)(void *alstate, uint8_t direction)
Definition: app-layer-register.h:50
AppLayerParser
Definition: app-layer-register.h:27
AppLayerParser::GetFrameNameById
AppLayerParserGetFrameNameByIdFn GetFrameNameById
Definition: app-layer-register.h:74
AppLayerParser::StateTransactionFree
void(* StateTransactionFree)(void *, uint64_t)
Definition: app-layer-register.h:46
AppLayerParser::min_depth
uint16_t min_depth
Definition: app-layer-register.h:35
AppLayerParser::ProbeTC
ProbingParserFPtr ProbeTC
Definition: app-layer-register.h:33
AppLayerParser::LocalStorageFree
void(* LocalStorageFree)(void *)
Definition: app-layer-register.h:58
AppLayerRegisterParserAlias
int AppLayerRegisterParserAlias(const char *proto_name, const char *proto_alias)
Definition: app-layer-register.c:190
AppLayerGetTxIterState
Definition: app-layer-parser.h:143
AppLayerParser::StateGetEventInfoById
int(* StateGetEventInfoById)(int event_id, const char **event_name, AppLayerEventType *event_type)
Definition: app-layer-register.h:54
AppLayerParserGetFrameNameByIdFn
const char *(* AppLayerParserGetFrameNameByIdFn)(const uint8_t id)
Definition: app-layer-parser.h:159
AppLayerRegisterParser
int AppLayerRegisterParser(const struct AppLayerParser *p, AppProto alproto)
App layer protocol registration function.
Definition: app-layer-register.c:94
AppLayerRegisterProtocolDetection
AppProto AppLayerRegisterProtocolDetection(const struct AppLayerParser *parser, int enable_default)
App layer protocol detection function.
Definition: app-layer-register.c:37
AppLayerParser::name
const char * name
Definition: app-layer-register.h:28
AppLayerParser::ParseTC
AppLayerParserFPtr ParseTC
Definition: app-layer-register.h:42
AppLayerParser::StateGetTxCnt
uint64_t(* StateGetTxCnt)(void *alstate)
Definition: app-layer-register.h:44
AppLayerParser::complete_tc
const int complete_tc
Definition: app-layer-register.h:49
AppLayerParser::GetTxIterator
AppLayerGetTxIterTuple(* GetTxIterator)(const uint8_t ipproto, const AppProto alproto, void *alstate, uint64_t min_tx_id, uint64_t max_tx_id, AppLayerGetTxIterState *istate)
Definition: app-layer-register.h:62
AppLayerParser::ApplyTxConfig
bool(* ApplyTxConfig)(void *state, void *tx, int mode, AppLayerTxConfig)
Definition: app-layer-register.h:67
AppLayerParser::flags
uint32_t flags
Definition: app-layer-register.h:69
AppLayerParser::complete_ts
const int complete_ts
Definition: app-layer-register.h:48
AppLayerParserGetFrameIdByNameFn
int(* AppLayerParserGetFrameIdByNameFn)(const char *frame_name)
Definition: app-layer-parser.h:158
AppLayerParser::GetFrameIdByName
AppLayerParserGetFrameIdByNameFn GetFrameIdByName
Definition: app-layer-register.h:73