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 "detect-byte.h"
26 #include "detect-byte-extract.h"
27 #include "detect-bytemath.h"
28 
29 /**
30  * \brief Used to retrieve args from BM.
31  *
32  * \param arg The name of the variable being sought
33  * \param s The signature to check for the variable
34  * \param index When found, the value of the slot within the byte vars
35  *
36  * \retval true A match for the variable was found.
37  * \retval false
38  */
39 bool DetectByteRetrieveSMVar(const char *arg, const Signature *s, DetectByteIndexType *index)
40 {
41  SigMatch *bed_sm = DetectByteExtractRetrieveSMVar(arg, s);
42  if (bed_sm != NULL) {
43  *index = ((DetectByteExtractData *)bed_sm->ctx)->local_id;
44  return true;
45  }
46 
47  SigMatch *bmd_sm = DetectByteMathRetrieveSMVar(arg, s);
48  if (bmd_sm != NULL) {
49  *index = ((DetectByteMathData *)bmd_sm->ctx)->local_id;
50  return true;
51  }
52  return false;
53 }
DetectByteMathData_
Holds data related to byte_math keyword.
Definition: detect-bytemath.h:51
DetectByteExtractData_
Holds data related to byte_extract keyword.
Definition: detect-byte-extract.h:43
DetectByteIndexType
uint8_t DetectByteIndexType
Definition: detect-byte.h:26
DetectByteMathRetrieveSMVar
SigMatch * DetectByteMathRetrieveSMVar(const char *arg, const Signature *s)
Lookup the SigMatch for a named byte_math variable.
Definition: detect-bytemath.c:735
SigMatch_::ctx
SigMatchCtx * ctx
Definition: detect.h:323
detect-byte.h
DetectByteExtractRetrieveSMVar
SigMatch * DetectByteExtractRetrieveSMVar(const char *arg, const Signature *s)
Lookup the SigMatch for a named byte_extract variable.
Definition: detect-byte-extract.c:656
DetectByteRetrieveSMVar
bool DetectByteRetrieveSMVar(const char *arg, const Signature *s, DetectByteIndexType *index)
Used to retrieve args from BM.
Definition: detect-byte.c:39
suricata-common.h
detect-byte-extract.h
Signature_
Signature container.
Definition: detect.h:528
SigMatch_
a single match condition for a signature
Definition: detect.h:320
detect-bytemath.h