"Fossies" - the Fresh Open Source Software Archive 
Member "snort3_extra-3.1.51.0/src/search_engines/lowmem/sfksearch.h" (20 Dec 2022, 2678 Bytes) of package /linux/misc/snort3_extra-3.1.51.0.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "sfksearch.h" see the
Fossies "Dox" file reference documentation.
1 //--------------------------------------------------------------------------
2 // Copyright (C) 2014-2022 Cisco and/or its affiliates. All rights reserved.
3 // Copyright (C) 2003-2013 Sourcefire, Inc.
4 // Copyright (C) 2001 Marc Norton
5 //
6 // This program is free software; you can redistribute it and/or modify it
7 // under the terms of the GNU General Public License Version 2 as published
8 // by the Free Software Foundation. You may not use, modify or distribute
9 // this program under any other version of the GNU General Public License.
10 //
11 // This program is distributed in the hope that it will be useful, but
12 // WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License along
17 // with this program; if not, write to the Free Software Foundation, Inc.,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 //--------------------------------------------------------------------------
20
21 #ifndef SFKSEARCH_H
22 #define SFKSEARCH_H
23
24 // ksearch.h - Trie based multi-pattern matcher
25
26 #include <cstdint>
27 #include "search_engines/search_common.h"
28
29 namespace snort
30 {
31 struct SnortConfig;
32 }
33
34 struct KTRIEPATTERN
35 {
36 KTRIEPATTERN* next; /* global list of all patterns*/
37 KTRIEPATTERN* mnext; /* matching list of duplicate keywords*/
38
39 uint8_t* P; /* no case*/
40 uint8_t* Pcase; /* case sensitive*/
41
42 void* user;
43 void* rule_option_tree;
44 void* neg_list;
45
46 int n;
47 int nocase;
48 int negative;
49 };
50
51 struct KTRIENODE
52 {
53 int edge; /* character*/
54
55 KTRIENODE* sibling;
56 KTRIENODE* child;
57
58 KTRIEPATTERN* pkeyword;
59 };
60
61 #define KTRIE_ROOT_NODES 256
62
63 struct KTRIE_STRUCT
64 {
65 KTRIEPATTERN* patrn; /* List of patterns, built as they are added*/
66 KTRIENODE* root[KTRIE_ROOT_NODES]; /* KTrie nodes*/
67
68 const struct MpseAgent* agent;
69
70 int memory;
71 int nchars;
72 int npats;
73 int duplicates;
74 int method;
75 int end_states; /* should equal npats - duplicates*/
76
77 int bcSize;
78 unsigned short bcShift[KTRIE_ROOT_NODES];
79 };
80
81 void KTrie_init_xlatcase();
82
83 KTRIE_STRUCT* KTrieNew(int method, const MpseAgent*);
84
85 int KTrieAddPattern(
86 KTRIE_STRUCT*, const uint8_t* P, unsigned n,
87 bool nocase, bool negative, void* id);
88
89 int KTrieCompile(snort::SnortConfig*, KTRIE_STRUCT*);
90
91 int KTrieSearch(KTRIE_STRUCT*, const uint8_t* T, int n, MpseMatch, void* context);
92
93 unsigned int KTrieMemUsed();
94 void KTrieInitMemUsed();
95
96 void KTrieDelete(KTRIE_STRUCT*);
97 int KTriePatternCount(KTRIE_STRUCT*);
98
99 void sfksearch_print_qinfo();
100
101 #endif
102