suricata
util-mpm-ac.h
Go to the documentation of this file.
1 /* Copyright (C) 2007-2014 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 Anoop Saldanha <anoopsaldanha@gmail.com>
22  *
23  */
24 
25 #ifndef __UTIL_MPM_AC__H__
26 #define __UTIL_MPM_AC__H__
27 
28 #define SC_AC_STATE_TYPE_U16 uint16_t
29 #define SC_AC_STATE_TYPE_U32 uint32_t
30 
31 typedef struct SCACPatternList_ {
32  uint8_t *cs;
33  uint16_t patlen;
34 
35  uint16_t offset;
36  uint16_t depth;
37 
38  /* sid(s) for this pattern */
39  uint32_t sids_size;
42 
43 typedef struct SCACOutputTable_ {
44  /* list of pattern sids */
45  uint32_t *pids;
46  /* no of entries we have in pids */
47  uint32_t no_of_entries;
49 
50 typedef struct SCACCtx_ {
51  /* pattern arrays. We need this only during the goto table creation phase */
53 
54  /* no of states used by ac */
55  uint32_t state_count;
56 
58 
59  /* the all important memory hungry state_table */
60  SC_AC_STATE_TYPE_U16 (*state_table_u16)[256];
61  /* the all important memory hungry state_table */
62  SC_AC_STATE_TYPE_U32 (*state_table_u32)[256];
63 
64  /* goto_table, failure table and output table. Needed to create state_table.
65  * Will be freed, once we have created the state_table */
66  int32_t (*goto_table)[256];
67  int32_t *failure_table;
70 
71  /* the size of each state */
73 
75 
76 } SCACCtx;
77 
78 typedef struct SCACThreadCtx_ {
79  /* the total calls we make to the search function */
80  uint32_t total_calls;
81  /* the total patterns that we ended up matching against */
82  uint64_t total_matches;
84 
85 void MpmACRegister(void);
86 
87 #endif /* __UTIL_MPM_AC__H__ */
SCACOutputTable * output_table
Definition: util-mpm-ac.h:68
struct SCACThreadCtx_ SCACThreadCtx
uint32_t total_calls
Definition: util-mpm-ac.h:80
void MpmACRegister(void)
Register the aho-corasick mpm.
Definition: util-mpm-ac.c:1239
uint8_t * cs
Definition: util-mpm-ac.h:32
uint32_t pattern_id_bitarray_size
Definition: util-mpm-ac.h:57
uint16_t patlen
Definition: util-mpm-ac.h:33
struct SCACCtx_ SCACCtx
#define SC_AC_STATE_TYPE_U16
Definition: util-mpm-ac.h:28
uint32_t single_state_size
Definition: util-mpm-ac.h:72
uint32_t no_of_entries
Definition: util-mpm-ac.h:47
SigIntId * sids
Definition: util-mpm-ac.h:40
struct SCACOutputTable_ SCACOutputTable
uint16_t depth
Definition: util-mpm-ac.h:36
SCACPatternList * pid_pat_list
Definition: util-mpm-ac.h:69
#define SC_AC_STATE_TYPE_U32
Definition: util-mpm-ac.h:29
uint32_t * pids
Definition: util-mpm-ac.h:45
uint16_t offset
Definition: util-mpm-ac.h:35
uint32_t allocated_state_count
Definition: util-mpm-ac.h:74
MpmPattern ** parray
Definition: util-mpm-ac.h:52
uint32_t state_count
Definition: util-mpm-ac.h:55
uint64_t total_matches
Definition: util-mpm-ac.h:82
int32_t * failure_table
Definition: util-mpm-ac.h:67
struct SCACPatternList_ SCACPatternList
uint32_t sids_size
Definition: util-mpm-ac.h:39
#define SigIntId