suricata
detect-byte.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 Jeff Lucovsky <jeff@lucovsky.org>
22  */
23 
24 #include "suricata-common.h"
25 #include "rust.h"
26 #include "detect-byte.h"
27 #include "detect-byte-extract.h"
28 #include "detect-bytemath.h"
29 
30 /**
31  * \brief Used to retrieve args from BM.
32  *
33  * \param arg The name of the variable being sought
34  * \param s The signature to check for the variable
35  * \param sm_list The caller's matching buffer
36  * \param index When found, the value of the slot within the byte vars
37  *
38  * \retval true A match for the variable was found.
39  * \retval false
40  */
42  const char *arg, const Signature *s, int sm_list, DetectByteIndexType *index)
43 {
44  SigMatch *bed_sm = DetectByteExtractRetrieveSMVar(arg, sm_list, s);
45  if (bed_sm != NULL) {
46  *index = ((SCDetectByteExtractData *)bed_sm->ctx)->local_id;
47  return true;
48  }
49 
50  SigMatch *bmd_sm = DetectByteMathRetrieveSMVar(arg, sm_list, s);
51  if (bmd_sm != NULL) {
52  *index = ((DetectByteMathData *)bmd_sm->ctx)->local_id;
53  return true;
54  }
55  return false;
56 }
rust.h
DetectByteIndexType
uint8_t DetectByteIndexType
Definition: detect-byte.h:28
DetectByteMathRetrieveSMVar
SigMatch * DetectByteMathRetrieveSMVar(const char *arg, int sm_list, const Signature *s)
Lookup the SigMatch for a named byte_math variable.
Definition: detect-bytemath.c:443
DetectByteExtractRetrieveSMVar
SigMatch * DetectByteExtractRetrieveSMVar(const char *arg, int sm_list, const Signature *s)
Lookup the SigMatch for a named byte_extract variable.
Definition: detect-byte-extract.c:375
SigMatch_::ctx
SigMatchCtx * ctx
Definition: detect.h:359
detect-byte.h
suricata-common.h
detect-byte-extract.h
Signature_
Signature container.
Definition: detect.h:668
SigMatch_
a single match condition for a signature
Definition: detect.h:356
DetectByteRetrieveSMVar
bool DetectByteRetrieveSMVar(const char *arg, const Signature *s, int sm_list, DetectByteIndexType *index)
Used to retrieve args from BM.
Definition: detect-byte.c:41
detect-bytemath.h