suricata
detect-engine-uint.c
Go to the documentation of this file.
1/* Copyright (C) 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 Philippe Antoine <p.antoine@catenacyber.fr>
22 *
23 */
24
25#include "suricata-common.h"
26
27#include "util-byte.h"
28#include "detect-parse.h"
29#include "detect-engine-uint.h"
30
31int DetectU32Match(const uint32_t parg, const DetectUintData_u32 *du32)
32{
33 return SCDetectU32Match(parg, du32);
34}
35
36/**
37 * \brief This function is used to parse u32 options passed via some u32 keyword
38 *
39 * \param u32str Pointer to the user provided u32 options
40 *
41 * \retval DetectU32Data pointer to DetectU32Data on success
42 * \retval NULL on failure
43 */
44
45DetectUintData_u32 *DetectU32Parse(const char *u32str)
46{
47 return SCDetectU32Parse(u32str);
48}
49
50void
52{
53 const DetectUintData_u32 *a = smctx;
54 v->u8[0] = a->mode;
55 v->u32[1] = a->arg1;
56 v->u32[2] = a->arg2;
57}
58
59bool
61{
62 const DetectUintData_u32 *a = smctx;
63 if (v.u8[0] == a->mode &&
64 v.u32[1] == a->arg1 &&
65 v.u32[2] == a->arg2)
66 return true;
67 return false;
68}
69
70//same as u32 but with u8
71int DetectU8Match(const uint8_t parg, const DetectUintData_u8 *du8)
72{
73 return SCDetectU8Match(parg, du8);
74}
75
76/**
77 * \brief This function is used to parse u8 options passed via some u8 keyword
78 *
79 * \param u8str Pointer to the user provided u8 options
80 *
81 * \retval DetectU8Data pointer to DetectU8Data on success
82 * \retval NULL on failure
83 */
84
85DetectUintData_u8 *DetectU8Parse(const char *u8str)
86{
87 return SCDetectU8Parse(u8str);
88}
89
91{
92 const DetectUintData_u8 *a = smctx;
93 v->u8[0] = a->mode;
94 v->u8[1] = a->arg1;
95 v->u8[2] = a->arg2;
96}
97
99{
100 const DetectUintData_u8 *a = smctx;
101 if (v.u8[0] == a->mode && v.u8[1] == a->arg1 && v.u8[2] == a->arg2)
102 return true;
103 return false;
104}
105
106// same as u32 but with u16
107int DetectU16Match(const uint16_t parg, const DetectUintData_u16 *du16)
108{
109 return SCDetectU16Match(parg, du16);
110}
111
112/**
113 * \brief This function is used to parse u16 options passed via some u16 keyword
114 *
115 * \param u16str Pointer to the user provided u16 options
116 *
117 * \retval DetectU16Data pointer to DetectU16Data on success
118 * \retval NULL on failure
119 */
120
121DetectUintData_u16 *DetectU16Parse(const char *u16str)
122{
123 return SCDetectU16Parse(u16str);
124}
125
127{
128 const DetectUintData_u16 *a = smctx;
129 v->u8[0] = a->mode;
130 v->u16[1] = a->arg1;
131 v->u16[2] = a->arg2;
132}
133
135{
136 const DetectUintData_u16 *a = smctx;
137 if (v.u8[0] == a->mode && v.u16[1] == a->arg1 && v.u16[2] == a->arg2)
138 return true;
139 return false;
140}
141
142int DetectU64Match(const uint64_t parg, const DetectUintData_u64 *du64)
143{
144 return SCDetectU64Match(parg, du64);
145}
146
147DetectUintData_u64 *DetectU64Parse(const char *u64str)
148{
149 return SCDetectU64Parse(u64str);
150}
DetectUintData_u8 * DetectU8Parse(const char *u8str)
This function is used to parse u8 options passed via some u8 keyword.
int DetectU16Match(const uint16_t parg, const DetectUintData_u16 *du16)
void PrefilterPacketU16Set(PrefilterPacketHeaderValue *v, void *smctx)
DetectUintData_u64 * DetectU64Parse(const char *u64str)
DetectUintData_u32 * DetectU32Parse(const char *u32str)
This function is used to parse u32 options passed via some u32 keyword.
bool PrefilterPacketU16Compare(PrefilterPacketHeaderValue v, void *smctx)
int DetectU32Match(const uint32_t parg, const DetectUintData_u32 *du32)
void PrefilterPacketU8Set(PrefilterPacketHeaderValue *v, void *smctx)
int DetectU8Match(const uint8_t parg, const DetectUintData_u8 *du8)
int DetectU64Match(const uint64_t parg, const DetectUintData_u64 *du64)
bool PrefilterPacketU8Compare(PrefilterPacketHeaderValue v, void *smctx)
void PrefilterPacketU32Set(PrefilterPacketHeaderValue *v, void *smctx)
bool PrefilterPacketU32Compare(PrefilterPacketHeaderValue v, void *smctx)
DetectUintData_u16 * DetectU16Parse(const char *u16str)
This function is used to parse u16 options passed via some u16 keyword.