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_ENGINE_SIGGROUP_H__
25 #define __DETECT_ENGINE_SIGGROUP_H__
26 
27 int SigGroupHeadAppendSig(const DetectEngineCtx *, SigGroupHead **, const Signature *);
28 int SigGroupHeadClearSigs(SigGroupHead *);
29 int SigGroupHeadCopySigs(DetectEngineCtx *, SigGroupHead *, SigGroupHead **);
30 
31 void SigGroupHeadFree(const DetectEngineCtx *de_ctx, SigGroupHead *);
32 
33 void SigGroupHeadFreeMpmArrays(DetectEngineCtx *);
34 
35 SigGroupHead *SigGroupHeadHashLookup(DetectEngineCtx *, SigGroupHead *);
36 SigGroupHead *SigGroupHeadMpmHashLookup(DetectEngineCtx *, SigGroupHead *);
37 SigGroupHead *SigGroupHeadDPortHashLookup(DetectEngineCtx *, SigGroupHead *);
38 
39 int SigGroupHeadMpmHashAdd(DetectEngineCtx *, SigGroupHead *);
40 int SigGroupHeadHashAdd(DetectEngineCtx *, SigGroupHead *);
41 int SigGroupHeadDPortHashAdd(DetectEngineCtx *, SigGroupHead *);
42 
43 void SigGroupHeadHashFree(DetectEngineCtx *);
44 void SigGroupHeadMpmHashFree(DetectEngineCtx *);
45 void SigGroupHeadDPortHashFree(DetectEngineCtx *);
46 
47 int SigGroupHeadHashInit(DetectEngineCtx *);
48 int SigGroupHeadMpmHashInit(DetectEngineCtx *);
49 int SigGroupHeadDPortHashInit(DetectEngineCtx *);
50 
51 int SigGroupHeadHashRemove(DetectEngineCtx *, SigGroupHead *);
52 
53 void SigGroupHeadInitDataFree(SigGroupHeadInitData *sghid);
54 void SigGroupHeadSetSigCnt(SigGroupHead *sgh, uint32_t max_idx);
55 void SigGroupHeadSetProtoAndDirection(SigGroupHead *sgh,
56                                       uint8_t ipproto, int dir);
57 int SigGroupHeadBuildMatchArray (DetectEngineCtx *de_ctx, SigGroupHead *sgh,
58                                  uint32_t max_idx);
59 void SigGroupHeadFreeSigArrays(DetectEngineCtx *de_ctx);
60 
61 int SigGroupHeadContainsSigId (DetectEngineCtx *de_ctx, SigGroupHead *sgh,
62                                uint32_t sid);
63 
64 void SigGroupHeadRegisterTests(void);
65 void SigGroupHeadPrintSigs(DetectEngineCtx *de_ctx, SigGroupHead *sgh);
66 
67 void SigGroupHeadStore(DetectEngineCtx *, SigGroupHead *);
68 void SigGroupHeadSetFilemagicFlag(DetectEngineCtx *, SigGroupHead *);
69 void SigGroupHeadSetFilestoreCount(DetectEngineCtx *, SigGroupHead *);
70 void SigGroupHeadSetFileHashFlag(DetectEngineCtx *, SigGroupHead *);
71 void SigGroupHeadSetFilesizeFlag(DetectEngineCtx *, SigGroupHead *);
72 uint16_t SigGroupHeadGetMinMpmSize(DetectEngineCtx *de_ctx,
73                                    SigGroupHead *sgh, int list);
74 
75 int SigGroupHeadBuildNonPrefilterArray(DetectEngineCtx *de_ctx, SigGroupHead *sgh);
76 
77 #endif /* __DETECT_ENGINE_SIGGROUP_H__ */
78