suricata
detect-ike-vendor.c
Go to the documentation of this file.
1 /* Copyright (C) 2020-2022 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  *
20  * \author Frank Honza <frank.honza@dcso.de>
21  */
22 
23 #include "suricata-common.h"
24 #include "conf.h"
25 #include "detect.h"
26 #include "detect-parse.h"
27 #include "detect-engine.h"
28 #include "detect-engine-buffer.h"
31 #include "detect-engine-mpm.h"
32 #include "detect-ike-vendor.h"
33 #include "app-layer-parser.h"
34 #include "util-byte.h"
35 
36 #include "rust-bindings.h"
37 #include "util-profiling.h"
38 
39 static int DetectIkeVendorSetup(DetectEngineCtx *, Signature *, const char *);
40 
41 static int g_ike_vendor_buffer_id = 0;
42 
43 /**
44  * \brief Registration function for ike.vendor keyword.
45  */
47 {
48  sigmatch_table[DETECT_IKE_VENDOR].name = "ike.vendor";
49  sigmatch_table[DETECT_IKE_VENDOR].desc = "match IKE Vendor";
50  sigmatch_table[DETECT_IKE_VENDOR].url = "/rules/ike-keywords.html#ike-vendor";
51  sigmatch_table[DETECT_IKE_VENDOR].Setup = DetectIkeVendorSetup;
54 
56  "ike.vendor", ALPROTO_IKE, SIG_FLAG_TOSERVER, 1, SCIkeTxGetVendor, 1);
57 
58  g_ike_vendor_buffer_id = DetectBufferTypeGetByName("ike.vendor");
59 
61 }
62 
63 /**
64  * \brief setup the sticky buffer keyword used in the rule
65  *
66  * \param de_ctx Pointer to the Detection Engine Context
67  * \param s Pointer to the Signature to which the current keyword belongs
68  * \param str Should hold an empty string always
69  *
70  * \retval 0 On success
71  * \retval -1 On failure
72  */
73 
74 static int DetectIkeVendorSetup(DetectEngineCtx *de_ctx, Signature *s, const char *str)
75 {
76  if (SCDetectBufferSetActiveList(de_ctx, s, g_ike_vendor_buffer_id) < 0)
77  return -1;
79  return -1;
80  return 0;
81 }
util-byte.h
SigTableElmt_::url
const char * url
Definition: detect.h:1431
DetectSignatureSetAppProto
int DetectSignatureSetAppProto(Signature *s, AppProto alproto)
Definition: detect-parse.c:2313
detect-engine.h
SIGMATCH_INFO_STICKY_BUFFER
#define SIGMATCH_INFO_STICKY_BUFFER
Definition: detect.h:1645
ALPROTO_IKE
@ ALPROTO_IKE
Definition: app-layer-protos.h:55
SigTableElmt_::desc
const char * desc
Definition: detect.h:1430
sigmatch_table
SigTableElmt * sigmatch_table
Definition: detect-parse.c:155
SigTableElmt_::name
const char * name
Definition: detect.h:1428
SigTableElmt_::flags
uint16_t flags
Definition: detect.h:1422
DetectEngineCtx_
main detection engine ctx
Definition: detect.h:931
DetectBufferTypeSupportsMultiInstance
void DetectBufferTypeSupportsMultiInstance(const char *name)
Definition: detect-engine.c:1107
SCDetectBufferSetActiveList
int SCDetectBufferSetActiveList(DetectEngineCtx *de_ctx, Signature *s, const int list)
Definition: detect-engine-buffer.c:29
SigTableElmt_::Setup
int(* Setup)(DetectEngineCtx *, Signature *, const char *)
Definition: detect.h:1413
detect-engine-prefilter.h
DetectBufferTypeGetByName
int DetectBufferTypeGetByName(const char *name)
Definition: detect-engine.c:1157
SIG_FLAG_TOSERVER
#define SIG_FLAG_TOSERVER
Definition: detect.h:270
de_ctx
DetectEngineCtx * de_ctx
Definition: fuzz_siginit.c:18
detect-engine-mpm.h
detect.h
DetectIkeVendorRegister
void DetectIkeVendorRegister(void)
Registration function for ike.vendor keyword.
Definition: detect-ike-vendor.c:46
detect-ike-vendor.h
app-layer-parser.h
util-profiling.h
conf.h
detect-engine-content-inspection.h
suricata-common.h
detect-engine-buffer.h
DETECT_IKE_VENDOR
@ DETECT_IKE_VENDOR
Definition: detect-engine-register.h:322
str
#define str(s)
Definition: suricata-common.h:308
detect-parse.h
Signature_
Signature container.
Definition: detect.h:670
SIGMATCH_NOOPT
#define SIGMATCH_NOOPT
Definition: detect.h:1620
DetectAppLayerMultiRegister
void DetectAppLayerMultiRegister(const char *name, AppProto alproto, uint32_t dir, int progress, InspectionMultiBufferGetDataPtr GetData, int priority)
Definition: detect-engine.c:2153