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 __DETECT_BYTETEST_H__
25 #define __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_U8(0) /**< "little" endian value */
44 #define DETECT_BYTETEST_BIG BIT_U8(1) /**< "bi" endian value */
45 #define DETECT_BYTETEST_STRING BIT_U8(2) /**< "string" value */
46 #define DETECT_BYTETEST_RELATIVE BIT_U8(3) /**< "relative" offset */
47 #define DETECT_BYTETEST_DCE BIT_U8(4) /**< dce enabled */
48 #define DETECT_BYTETEST_BITMASK BIT_U8(5) /**< bitmask supplied*/
49 #define DETECT_BYTETEST_VALUE_VAR BIT_U8(6) /**< byte extract value enabled */
50 #define DETECT_BYTETEST_OFFSET_VAR BIT_U8(7) /**< byte extract value enabled */
51 
52 typedef struct DetectBytetestData_ {
53  uint8_t nbytes; /**< Number of bytes to compare */
54  uint8_t op; /**< Operator used to compare */
55  uint8_t base; /**< String value base (oct|dec|hex) */
56  uint8_t bitmask_shift_count; /**< bitmask trailing 0 count */
57  uint8_t flags; /**< Flags (big|little|relative|string|bitmask) */
58  bool neg_op;
59  int32_t offset; /**< Offset in payload */
60  uint32_t bitmask; /**< bitmask value */
61  uint64_t value; /**< Value to compare against */
63 
64 /* prototypes */
65 
66 /**
67  * Registration function for byte_test.
68  *
69  * \todo add support for no_stream and stream_only
70  */
71 void DetectBytetestRegister (void);
72 
74  const SigMatchCtx *ctx, const uint8_t *, uint32_t,
75  uint8_t, int32_t, uint64_t);
76 
77 #endif /* __DETECT_BYTETEST_H__ */
DetectBytetestData_::bitmask_shift_count
uint8_t bitmask_shift_count
Definition: detect-bytetest.h:56
DetectBytetestData_::neg_op
bool neg_op
Definition: detect-bytetest.h:58
DetectBytetestData_::flags
uint8_t flags
Definition: detect-bytetest.h:57
DetectBytetestData_::bitmask
uint32_t bitmask
Definition: detect-bytetest.h:60
DetectBytetestData_::nbytes
uint8_t nbytes
Definition: detect-bytetest.h:53
DetectBytetestData_
Definition: detect-bytetest.h:52
DetectBytetestRegister
void DetectBytetestRegister(void)
Definition: detect-bytetest.c:79
DetectEngineThreadCtx_
Definition: detect.h:1010
DetectBytetestData_::op
uint8_t op
Definition: detect-bytetest.h:54
SigMatchCtx_
Used to start a pointer to SigMatch context Should never be dereferenced without casting to something...
Definition: detect.h:315
DetectBytetestData
struct DetectBytetestData_ DetectBytetestData
Signature_
Signature container.
Definition: detect.h:528
DetectBytetestData_::offset
int32_t offset
Definition: detect-bytetest.h:59
DetectBytetestDoMatch
int DetectBytetestDoMatch(DetectEngineThreadCtx *, const Signature *, const SigMatchCtx *ctx, const uint8_t *, uint32_t, uint8_t, int32_t, uint64_t)
Bytetest detection code.
Definition: detect-bytetest.c:105
DetectBytetestData_::base
uint8_t base
Definition: detect-bytetest.h:55
DetectBytetestData_::value
uint64_t value
Definition: detect-bytetest.h:61