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 index When found, the value of the slot within the byte vars
36  *
37  * \retval true A match for the variable was found.
38  * \retval false
39  */
40 bool DetectByteRetrieveSMVar(const char *arg, const Signature *s, DetectByteIndexType *index)
41 {
42  SigMatch *bed_sm = DetectByteExtractRetrieveSMVar(arg, s);
43  if (bed_sm != NULL) {
44  *index = ((SCDetectByteExtractData *)bed_sm->ctx)->local_id;
45  return true;
46  }
47 
48  SigMatch *bmd_sm = DetectByteMathRetrieveSMVar(arg, s);
49  if (bmd_sm != NULL) {
50  *index = ((DetectByteMathData *)bmd_sm->ctx)->local_id;
51  return true;
52  }
53  return false;
54 }
rust.h
DetectByteIndexType
uint8_t DetectByteIndexType
Definition: detect-byte.h:28
DetectByteMathRetrieveSMVar
SigMatch * DetectByteMathRetrieveSMVar(const char *arg, const Signature *s)
Lookup the SigMatch for a named byte_math variable.
Definition: detect-bytemath.c:442
SigMatch_::ctx
SigMatchCtx * ctx
Definition: detect.h:352
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:375
DetectByteRetrieveSMVar
bool DetectByteRetrieveSMVar(const char *arg, const Signature *s, DetectByteIndexType *index)
Used to retrieve args from BM.
Definition: detect-byte.c:40
suricata-common.h
detect-byte-extract.h
Signature_
Signature container.
Definition: detect.h:601
SigMatch_
a single match condition for a signature
Definition: detect.h:349
detect-bytemath.h