suricata
detect-bytetest.h
Go to the documentation of this file.
1 /* Copyright (C) 2007-2020 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 Brian Rectanus <brectanu@gmail.com>
22  */
23 
24 #ifndef SURICATA_DETECT_BYTETEST_H
25 #define SURICATA_DETECT_BYTETEST_H
26 
27 /** Bytetest Operators */
28 #define DETECT_BYTETEST_OP_LT 1 /**< "less than" operator */
29 #define DETECT_BYTETEST_OP_GT 2 /**< "greater than" operator */
30 #define DETECT_BYTETEST_OP_EQ 3 /**< "equals" operator */
31 #define DETECT_BYTETEST_OP_AND 4 /**< "bitwise and" operator */
32 #define DETECT_BYTETEST_OP_OR 5 /**< "bitwise or" operator */
33 #define DETECT_BYTETEST_OP_GE 6 /**< greater than equal operator */
34 #define DETECT_BYTETEST_OP_LE 7 /**< less than equal operator */
35 
36 /** Bytetest Base */
37 #define DETECT_BYTETEST_BASE_UNSET 0 /**< Unset type value string (automatic)*/
38 #define DETECT_BYTETEST_BASE_OCT 8 /**< "oct" type value string */
39 #define DETECT_BYTETEST_BASE_DEC 10 /**< "dec" type value string */
40 #define DETECT_BYTETEST_BASE_HEX 16 /**< "hex" type value string */
41 
42 /** Bytetest Flags */
43 #define DETECT_BYTETEST_LITTLE BIT_U16(0) /**< "little" endian value */
44 #define DETECT_BYTETEST_BIG BIT_U16(1) /**< "bi" endian value */
45 #define DETECT_BYTETEST_STRING BIT_U16(2) /**< "string" value */
46 #define DETECT_BYTETEST_RELATIVE BIT_U16(3) /**< "relative" offset */
47 #define DETECT_BYTETEST_DCE BIT_U16(4) /**< dce enabled */
48 #define DETECT_BYTETEST_BITMASK BIT_U16(5) /**< bitmask supplied*/
49 #define DETECT_BYTETEST_VALUE_VAR BIT_U16(6) /**< byte extract value enabled */
50 #define DETECT_BYTETEST_OFFSET_VAR BIT_U16(7) /**< byte extract value enabled */
51 #define DETECT_BYTETEST_NBYTES_VAR BIT_U16(8) /**< byte extract value enabled */
52 
53 typedef struct DetectBytetestData_ {
54  uint8_t nbytes; /**< Number of bytes to compare */
55  uint8_t op; /**< Operator used to compare */
56  uint8_t base; /**< String value base (oct|dec|hex) */
57  uint8_t bitmask_shift_count; /**< bitmask trailing 0 count */
58  uint16_t flags; /**< Flags (big|little|relative|string|bitmask) */
59  bool neg_op;
60  int32_t offset; /**< Offset in payload */
61  uint32_t bitmask; /**< bitmask value */
62  uint64_t value; /**< Value to compare against */
64 
65 /* prototypes */
66 
67 /**
68  * Registration function for byte_test.
69  *
70  * \todo add support for no_stream and stream_only
71  */
72 void DetectBytetestRegister (void);
73 
75  const uint8_t *, uint32_t, uint16_t, int32_t, int32_t, uint64_t);
76 
77 #endif /* SURICATA_DETECT_BYTETEST_H */
DetectBytetestData_::flags
uint16_t flags
Definition: detect-bytetest.h:58
DetectBytetestData_::bitmask_shift_count
uint8_t bitmask_shift_count
Definition: detect-bytetest.h:57
DetectBytetestData_::neg_op
bool neg_op
Definition: detect-bytetest.h:59
ctx
struct Thresholds ctx
DetectBytetestData_::bitmask
uint32_t bitmask
Definition: detect-bytetest.h:61
DetectBytetestData_::nbytes
uint8_t nbytes
Definition: detect-bytetest.h:54
DetectBytetestData_
Definition: detect-bytetest.h:53
DetectBytetestRegister
void DetectBytetestRegister(void)
Definition: detect-bytetest.c:77
DetectEngineThreadCtx_
Definition: detect.h:1098
DetectBytetestData_::op
uint8_t op
Definition: detect-bytetest.h:55
SigMatchCtx_
Used to start a pointer to SigMatch context Should never be dereferenced without casting to something...
Definition: detect.h:344
DetectBytetestData
struct DetectBytetestData_ DetectBytetestData
DetectBytetestDoMatch
int DetectBytetestDoMatch(DetectEngineThreadCtx *, const Signature *, const SigMatchCtx *ctx, const uint8_t *, uint32_t, uint16_t, int32_t, int32_t, uint64_t)
Bytetest detection code.
Definition: detect-bytetest.c:154
Signature_
Signature container.
Definition: detect.h:603
DetectBytetestData_::offset
int32_t offset
Definition: detect-bytetest.h:60
DetectBytetestData_::base
uint8_t base
Definition: detect-bytetest.h:56
DetectBytetestData_::value
uint64_t value
Definition: detect-bytetest.h:62