suricata
flow-var.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 Victor Julien <victor@inliniac.net>
22 * \author Pablo Rincon <pablo.rincon.crespo@gmail.com>
23 */
24
25#ifndef SURICATA_FLOW_VAR_H
26#define SURICATA_FLOW_VAR_H
27
28#include "flow.h"
29#include "util-var.h"
30
31/** Available data types for Flowvars */
32
33#define FLOWVAR_TYPE_STR 1
34#define FLOWVAR_TYPE_INT 2
35#define FLOWVAR_TYPE_FLOAT 3
36
37typedef uint8_t FlowVarKeyLenType;
38/** Struct used to hold the string data type for flowvars */
39typedef struct FlowVarTypeStr {
40 uint8_t *value;
41 uint16_t value_len;
43
44/** Struct used to hold the integer data type for flowvars */
45typedef struct FlowVarTypeInt_ {
46 uint32_t value;
48
49/** Struct used to hold the integer data type for flowvars */
53
54/** Generic Flowvar Structure */
55typedef struct FlowVar_ {
56 uint16_t type; /* type, DETECT_FLOWVAR in this case */
57 uint8_t datatype;
59 uint32_t idx; /* name idx */
60 GenericVar *next; /* right now just implement this as a list,
61 * in the long run we have think of something
62 * faster. */
63 union {
68 uint8_t *key;
70
71/** Flowvar Interface API */
72
73void FlowVarAddIdValue(Flow *, uint32_t id, uint8_t *value, uint16_t size);
75 Flow *f, uint8_t *key, FlowVarKeyLenType keylen, uint8_t *value, uint16_t size);
76
77void FlowVarAddIntNoLock(Flow *, uint32_t, uint32_t);
78void FlowVarAddInt(Flow *, uint32_t, uint32_t);
79void FlowVarAddFloat(Flow *, uint32_t, double);
80FlowVar *FlowVarGet(Flow *, uint32_t);
81FlowVar *FlowVarGetByKey(Flow *f, const uint8_t *key, FlowVarKeyLenType keylen);
82void FlowVarFree(FlowVar *);
84
85#endif /* SURICATA_FLOW_VAR_H */
void FlowVarAddInt(Flow *, uint32_t, uint32_t)
Definition flow-var.c:183
void FlowVarPrint(GenericVar *)
Definition flow-var.c:201
struct FlowVar_ FlowVar
struct FlowVarTypeInt_ FlowVarTypeInt
void FlowVarAddFloat(Flow *, uint32_t, double)
Definition flow-var.c:142
void FlowVarFree(FlowVar *)
Definition flow-var.c:188
uint8_t FlowVarKeyLenType
Definition flow-var.h:37
FlowVar * FlowVarGetByKey(Flow *f, const uint8_t *key, FlowVarKeyLenType keylen)
get the flowvar with index 'idx' from the flow
Definition flow-var.c:60
void FlowVarAddKeyValue(Flow *f, uint8_t *key, FlowVarKeyLenType keylen, uint8_t *value, uint16_t size)
Definition flow-var.c:100
void FlowVarAddIdValue(Flow *, uint32_t id, uint8_t *value, uint16_t size)
Definition flow-var.c:120
void FlowVarAddIntNoLock(Flow *, uint32_t, uint32_t)
Definition flow-var.c:162
FlowVar * FlowVarGet(Flow *, uint32_t)
get the flowvar with index 'idx' from the flow
Definition flow-var.c:84
struct FlowVarTypeFloat_ FlowVarTypeFloat
uint32_t value
Definition flow-var.h:46
uint16_t value_len
Definition flow-var.h:41
uint8_t * value
Definition flow-var.h:40
uint8_t datatype
Definition flow-var.h:57
uint32_t idx
Definition flow-var.h:59
FlowVarTypeInt fv_int
Definition flow-var.h:65
FlowVarKeyLenType keylen
Definition flow-var.h:58
uint8_t * key
Definition flow-var.h:68
FlowVarTypeStr fv_str
Definition flow-var.h:64
uint16_t type
Definition flow-var.h:56
GenericVar * next
Definition flow-var.h:60
FlowVarTypeFloat fv_float
Definition flow-var.h:66
union FlowVar_::@124 data
Flow data structure.
Definition flow.h:356