suricata
detect-parse.h
Go to the documentation of this file.
1 /* Copyright (C) 2007-2010 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  */
23 
24 #ifndef __DETECT_PARSE_H__
25 #define __DETECT_PARSE_H__
26 
27 /** Flags to indicate if the Signature parsing must be done
28 * switching the source and dest (for ip addresses and ports)
29 * or otherwise as normal */
30 enum {
33 };
34 
35 /** Flags to indicate if are referencing the source of the Signature
36 * or the destination (for ip addresses and ports)*/
37 enum {
40 };
41 
42 /* prototypes */
43 Signature *SigAlloc(void);
44 void SigFree(Signature *s);
45 Signature *SigInit(DetectEngineCtx *, const char *sigstr);
46 Signature *SigInitReal(DetectEngineCtx *, const char *);
48 void SigParseRegisterTests(void);
50 
53 int SigMatchListSMBelongsTo(const Signature *, const SigMatch *);
54 
57 
59  Signature *s, const char *arg, int sm_type, int sm_list,
60  AppProto alproto);
61 
63  const enum DetectKeywordId id);
64 bool SigMatchStrictEnabled(const enum DetectKeywordId id);
65 
66 const char *DetectListToHumanString(int list);
67 const char *DetectListToString(int list);
68 
70 
74 SigMatch *DetectGetLastSMByListPtr(const Signature *s, SigMatch *sm_list, ...);
75 SigMatch *DetectGetLastSMByListId(const Signature *s, int list_id, ...);
76 
77 int DetectSignatureAddTransform(Signature *s, int transform);
79 
80 /* parse regex setup and free util funcs */
81 
82 void DetectSetupParseRegexes(const char *parse_str,
83  pcre **parse_regex,
84  pcre_extra **parse_regex_study);
85 void DetectParseRegexAddToFreeList(pcre *regex, pcre_extra *study);
86 void DetectParseFreeRegexes(void);
87 
88 #ifdef AFLFUZZ_RULES
89 int RuleParseDataFromFile(char *filename);
90 #endif
91 
92 #endif /* __DETECT_PARSE_H__ */
93 
void DetectParseFreeRegexes(void)
SigMatch * DetectGetLastSMByListId(const Signature *s, int list_id,...)
Returns the sm with the largest index (added last) from the list passed to us as an id...
Definition: detect-parse.c:537
int WARN_UNUSED DetectSignatureSetAppProto(Signature *s, AppProto alproto)
const char * DetectListToHumanString(int list)
Definition: detect-parse.c:111
void SigParseRegisterTests(void)
pcre_extra * study
Signature * SigInit(DetectEngineCtx *, const char *sigstr)
Parses a signature and adds it to the Detection Engine Context.
Data needed for Match()
Definition: detect.h:327
void DetectParseDupSigHashFree(DetectEngineCtx *)
Frees the hash table that is used to cull duplicate sigs.
void DetectParseRegexAddToFreeList(pcre *regex, pcre_extra *study)
add regex and/or study to at exit free list
Signature * DetectEngineAppendSig(DetectEngineCtx *, const char *)
Parse and append a Signature into the Detection Engine Context signature list.
SigMatch * DetectGetLastSMFromLists(const Signature *s,...)
Returns the sm with the largest index (added latest) from the lists passed to us. ...
Definition: detect-parse.c:465
uint16_t AppProto
void SigMatchRemoveSMFromList(Signature *, SigMatch *, int)
Definition: detect-parse.c:384
Flow * head
Definition: flow-hash.h:102
Signature container.
Definition: detect.h:522
main detection engine ctx
Definition: detect.h:761
#define str(s)
SigMatch * DetectGetLastSM(const Signature *)
Returns the sm with the largest index (added latest) from this sig.
Definition: detect-parse.c:569
int DetectSignatureAddTransform(Signature *s, int transform)
SigMatch * DetectGetLastSMFromMpmLists(const DetectEngineCtx *de_ctx, const Signature *s)
get the last SigMatch from lists that support MPM.
Definition: detect-parse.c:426
Signature * SigAlloc(void)
bool SigMatchSilentErrorEnabled(const DetectEngineCtx *de_ctx, const enum DetectKeywordId id)
Definition: detect-parse.c:289
int SigMatchListSMBelongsTo(const Signature *, const SigMatch *)
Definition: detect-parse.c:619
int DetectParseDupSigHashInit(DetectEngineCtx *)
Initializes the hash table that is used to cull duplicate sigs.
void SigTableApplyStrictCommandlineOption(const char *str)
Definition: detect-parse.c:303
bool SigMatchStrictEnabled(const enum DetectKeywordId id)
Definition: detect-parse.c:295
void SigMatchAppendSMToList(Signature *, SigMatch *, int)
Append a SigMatch to the list type.
Definition: detect-parse.c:346
int DetectEngineContentModifierBufferSetup(DetectEngineCtx *de_ctx, Signature *s, const char *arg, int sm_type, int sm_list, AppProto alproto)
Definition: detect-parse.c:143
const char * DetectListToString(int list)
Definition: detect-parse.c:128
#define WARN_UNUSED
SigMatch * DetectGetLastSMByListPtr(const Signature *s, SigMatch *sm_list,...)
Returns the sm with the largest index (added last) from the list passed to us as a pointer...
Definition: detect-parse.c:505
Signature * SigInitReal(DetectEngineCtx *, const char *)
SigMatchData * SigMatchList2DataArray(SigMatch *head)
convert SigMatch list to SigMatchData array
void DetectSetupParseRegexes(const char *parse_str, pcre **parse_regex, pcre_extra **parse_regex_study)
void SigFree(Signature *s)
a single match condition for a signature
Definition: detect.h:318