suricata
detect-udphdr.c
Go to the documentation of this file.
1 /* Copyright (C) 2007-2018 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 #include "../suricata-common.h"
19 
20 #include "../detect.h"
21 #include "../detect-parse.h"
22 #include "../detect-engine-prefilter-common.h"
23 
24 #include "../detect-tcphdr.h"
25 
26 #include "../util-unittest.h"
27 
28 static int DetectUdphdrParseTest01 (void)
29 {
31  FAIL_IF_NULL(de_ctx);
32 
33  Signature *sig = DetectEngineAppendSig(de_ctx,
34  "alert udp any any -> any any (udp.hdr; content:\"A\"; sid:1; rev:1;)");
35  FAIL_IF_NULL(sig);
36 
37  DetectEngineCtxFree(de_ctx);
38  PASS;
39 }
40 
41 /**
42  * \brief this function registers unit tests for DetectUdphdr
43  */
45 {
46  UtRegisterTest("DetectUdphdrParseTest01", DetectUdphdrParseTest01);
47 }
Signature * DetectEngineAppendSig(DetectEngineCtx *de_ctx, const char *sigstr)
Parse and append a Signature into the Detection Engine Context signature list.
#define PASS
Pass the test.
Signature container.
Definition: detect.h:517
main detection engine ctx
Definition: detect.h:756
void UtRegisterTest(const char *name, int(*TestFn)(void))
Register unit test.
void DetectUdphdrRegisterTests(void)
this function registers unit tests for DetectUdphdr
Definition: detect-udphdr.c:44
#define FAIL_IF_NULL(expr)
Fail a test if expression evaluates to NULL.
Definition: util-unittest.h:89
void DetectEngineCtxFree(DetectEngineCtx *)
Free a DetectEngineCtx::
DetectEngineCtx * DetectEngineCtxInit(void)