suricata
detect-threshold.h
Go to the documentation of this file.
1 /* Copyright (C) 2007-2013 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 Breno Silva <breno.silva@gmail.com>
22  */
23 
24 #ifndef __DETECT_THRESHOLD_H__
25 #define __DETECT_THRESHOLD_H__
26 
27 #include "decode-events.h"
28 #include "decode-ipv4.h"
29 #include "decode-tcp.h"
30 
31 #define TYPE_LIMIT 1
32 #define TYPE_BOTH 2
33 #define TYPE_THRESHOLD 3
34 #define TYPE_DETECTION 4
35 #define TYPE_RATE 5
36 #define TYPE_SUPPRESS 6
37 
38 #define TRACK_DST 1
39 #define TRACK_SRC 2
40 #define TRACK_RULE 3
41 #define TRACK_EITHER 4 /**< either src or dst: only used by suppress */
42 #define TRACK_BOTH 5 /* used by rate_filter to match detections by both src and dst addresses */
43 
44 /* Get the new action to take */
45 #define TH_ACTION_ALERT 0x01
46 #define TH_ACTION_DROP 0x02
47 #define TH_ACTION_PASS 0x04
48 #define TH_ACTION_LOG 0x08
49 #define TH_ACTION_SDROP 0x10
50 #define TH_ACTION_REJECT 0x20
51 
52 /**
53  * \typedef DetectThresholdData
54  * A typedef for DetectThresholdData_
55  */
56 
57 typedef struct DetectThresholdData_ {
58  uint32_t count; /**< Event count */
59  uint32_t seconds; /**< Event seconds */
60  uint8_t type; /**< Threshold type : limit , threshold, both, detection_filter */
61  uint8_t track; /**< Track type: by_src, by_dst */
62  uint8_t new_action; /**< new_action alert|drop|pass|log|sdrop|reject */
63  uint32_t timeout; /**< timeout */
64  uint32_t flags; /**< flags used to set option */
67 
68 typedef struct DetectThresholdEntry_ {
69  uint32_t sid; /**< Signature id */
70  uint32_t gid; /**< Signature group id */
71 
72  uint32_t tv_timeout; /**< Timeout for new_action (for rate_filter)
73  its not "seconds", that define the time interval */
74  uint32_t seconds; /**< Event seconds */
75  uint32_t tv_sec1; /**< Var for time control */
76  uint32_t tv_usec1; /**< Var for time control */
77  uint32_t current_count; /**< Var for count control */
78  int track; /**< Track type: by_src, by_src */
79 
82 
83 
84 /**
85  * Registration function for threshold: keyword
86  */
87 
88 void DetectThresholdRegister(void);
89 
90 /**
91  * This function registers unit tests for Threshold
92  */
93 
94 void ThresholdRegisterTests(void);
95 
96 #endif /*__DETECT_THRESHOLD_H__ */
struct DetectThresholdEntry_ DetectThresholdEntry
void DetectThresholdRegister(void)
Registration function for threshold: keyword.
void ThresholdRegisterTests(void)
DetectAddressHead addrs
struct DetectThresholdEntry_ * next
struct DetectThresholdData_ DetectThresholdData