1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
/* Copyright (C) 2020 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
* Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* version 2 along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
/**
* \file
*
* \author Philippe Antoine <p.antoine@catenacyber.fr>
*
*/
#include "suricata-common.h"
#include "util-byte.h"
#include "detect-parse.h"
#include "detect-engine-uint.h"
int DetectU32Match(const uint32_t parg, const DetectUintData_u32 *du32)
{
return rs_detect_u32_match(parg, du32);
}
/**
* \brief This function is used to parse u32 options passed via some u32 keyword
*
* \param u32str Pointer to the user provided u32 options
*
* \retval DetectU32Data pointer to DetectU32Data on success
* \retval NULL on failure
*/
DetectUintData_u32 *DetectU32Parse(const char *u32str)
{
return rs_detect_u32_parse(u32str);
}
void
PrefilterPacketU32Set(PrefilterPacketHeaderValue *v, void *smctx)
{
const DetectUintData_u32 *a = smctx;
v->u8[0] = a->mode;
v->u32[1] = a->arg1;
v->u32[2] = a->arg2;
}
bool
PrefilterPacketU32Compare(PrefilterPacketHeaderValue v, void *smctx)
{
const DetectUintData_u32 *a = smctx;
if (v.u8[0] == a->mode &&
v.u32[1] == a->arg1 &&
v.u32[2] == a->arg2)
return true;
return false;
}
//same as u32 but with u8
int DetectU8Match(const uint8_t parg, const DetectUintData_u8 *du8)
{
return rs_detect_u8_match(parg, du8);
}
/**
* \brief This function is used to parse u8 options passed via some u8 keyword
*
* \param u8str Pointer to the user provided u8 options
*
* \retval DetectU8Data pointer to DetectU8Data on success
* \retval NULL on failure
*/
DetectUintData_u8 *DetectU8Parse(const char *u8str)
{
return rs_detect_u8_parse(u8str);
}
void PrefilterPacketU8Set(PrefilterPacketHeaderValue *v, void *smctx)
{
const DetectUintData_u8 *a = smctx;
v->u8[0] = a->mode;
v->u8[1] = a->arg1;
v->u8[2] = a->arg2;
}
bool PrefilterPacketU8Compare(PrefilterPacketHeaderValue v, void *smctx)
{
const DetectUintData_u8 *a = smctx;
if (v.u8[0] == a->mode && v.u8[1] == a->arg1 && v.u8[2] == a->arg2)
return true;
return false;
}
// same as u32 but with u16
int DetectU16Match(const uint16_t parg, const DetectUintData_u16 *du16)
{
return rs_detect_u16_match(parg, du16);
}
/**
* \brief This function is used to parse u16 options passed via some u16 keyword
*
* \param u16str Pointer to the user provided u16 options
*
* \retval DetectU16Data pointer to DetectU16Data on success
* \retval NULL on failure
*/
DetectUintData_u16 *DetectU16Parse(const char *u16str)
{
return rs_detect_u16_parse(u16str);
}
void PrefilterPacketU16Set(PrefilterPacketHeaderValue *v, void *smctx)
{
const DetectUintData_u16 *a = smctx;
v->u8[0] = a->mode;
v->u16[1] = a->arg1;
v->u16[2] = a->arg2;
}
bool PrefilterPacketU16Compare(PrefilterPacketHeaderValue v, void *smctx)
{
const DetectUintData_u16 *a = smctx;
if (v.u8[0] == a->mode && v.u16[1] == a->arg1 && v.u16[2] == a->arg2)
return true;
return false;
}
int DetectU64Match(const uint64_t parg, const DetectUintData_u64 *du64)
{
return rs_detect_u64_match(parg, du64);
}
DetectUintData_u64 *DetectU64Parse(const char *u64str)
{
return rs_detect_u64_parse(u64str);
}
|