suricata
detect-tag.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 Pablo Rincon <pablo.rincon.crespo@gmail.com>
22 * \author Victor Julien <victor@inliniac.net>
23 */
24
25#ifndef SURICATA_DETECT_TAG_H
26#define SURICATA_DETECT_TAG_H
27
28#include "suricata-common.h"
29
30/* Limit the number of times a session can be tagged by the
31 * same rule without finishing older tags */
32#define DETECT_TAG_MATCH_LIMIT 10
33
34/* Limit the number of tags that a session can have */
35#define DETECT_TAG_MAX_TAGS 50
36
37/* Limit the number of pkts to capture. Change this to
38 * zero to make it unlimited
39 * TODO: load it from config (var tagged_packet_limit) */
40#define DETECT_TAG_MAX_PKTS 256
41
42/* Type of tag: session or host */
43enum {
47};
48
49enum {
52};
53
54enum {
58};
59
60/** This will be the rule options/parameters */
61typedef struct DetectTagData_ {
62 uint8_t type; /**< tag type */
63 uint8_t direction; /**< host direction */
64 uint32_t count; /**< count */
65 uint8_t metric; /**< metric */
67
68/** This is the installed data at the session/global or host table */
69typedef struct DetectTagDataEntry_ {
70 uint8_t flags:3;
71 uint8_t metric:5;
72 uint8_t pad0;
73 uint16_t cnt_match; /**< number of times this tag was reset/updated */
74
75 uint32_t count; /**< count setting from rule */
76 uint32_t sid; /**< sid originating the tag */
77 uint32_t gid; /**< gid originating the tag */
78 union {
79 uint32_t packets; /**< number of packets (metric packets) */
80 uint32_t bytes; /**< number of bytes (metric bytes) */
81 };
82 SCTime_t first_ts; /**< First time seen (for metric = seconds) */
83 SCTime_t last_ts; /**< Last time seen (to prune old sessions) */
84 struct DetectTagDataEntry_ *next; /**< Pointer to the next tag of this
85 * session/src_host/dst_host (if any from other rule) */
87
88#define TAG_ENTRY_FLAG_DIR_SRC 0x01
89#define TAG_ENTRY_FLAG_DIR_DST 0x02
90#define TAG_ENTRY_FLAG_SKIPPED_FIRST 0x04
91
92/* prototypes */
93struct DetectEngineCtx_ ;
94void DetectTagRegister(void);
95void DetectTagDataFree(struct DetectEngineCtx_ *, void *ptr);
96void DetectTagDataListFree(void *ptr);
97
98#endif /* SURICATA_DETECT_TAG_H */
struct DetectTagData_ DetectTagData
struct DetectTagDataEntry_ DetectTagDataEntry
@ DETECT_TAG_METRIC_PACKET
Definition detect-tag.h:55
@ DETECT_TAG_METRIC_BYTES
Definition detect-tag.h:57
@ DETECT_TAG_METRIC_SECONDS
Definition detect-tag.h:56
@ DETECT_TAG_TYPE_HOST
Definition detect-tag.h:45
@ DETECT_TAG_TYPE_MAX
Definition detect-tag.h:46
@ DETECT_TAG_TYPE_SESSION
Definition detect-tag.h:44
void DetectTagDataFree(struct DetectEngineCtx_ *, void *ptr)
this function will free memory associated with DetectTagData
Definition detect-tag.c:355
@ DETECT_TAG_DIR_SRC
Definition detect-tag.h:50
@ DETECT_TAG_DIR_DST
Definition detect-tag.h:51
void DetectTagDataListFree(void *ptr)
this function will free all the entries of a list DetectTagDataEntry
Definition detect-tag.c:336
void DetectTagRegister(void)
Registration function for keyword tag.
Definition detect-tag.c:69
main detection engine ctx
Definition detect.h:932
struct DetectTagDataEntry_ * next
Definition detect-tag.h:84
uint8_t direction
Definition detect-tag.h:63
uint32_t count
Definition detect-tag.h:64
uint8_t metric
Definition detect-tag.h:65