]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
src: includes cleanup
authorVictor Julien <vjulien@oisf.net>
Fri, 16 Sep 2022 09:08:21 +0000 (11:08 +0200)
committerVictor Julien <vjulien@oisf.net>
Sat, 1 Oct 2022 18:27:38 +0000 (20:27 +0200)
Work towards making `suricata-common.h` only introduce system headers
and other things that are independent of complex internal Suricata
data structures.

Update files to compile after this.

Remove special DPDK handling for strlcpy and strlcat, as this caused
many compilation failures w/o including DPDK headers for all files.

Remove packet macros from decode.h and move them into their own file,
turn them into functions and rename them to match our function naming
policy.

189 files changed:
configure.ac
qa/coccinelle/pktnotset-packet.cocci
src/Makefile.am
src/app-layer-detect-proto.c
src/app-layer-detect-proto.h
src/app-layer-frames.c
src/app-layer-ftp.c
src/app-layer-htp-body.c
src/app-layer-htp-file.c
src/app-layer-htp-libhtp.c
src/app-layer-htp-mem.c
src/app-layer-htp.c
src/app-layer-htp.h
src/app-layer-modbus.c
src/app-layer-parser.c
src/app-layer.c
src/conf.c
src/counters.c
src/counters.h
src/datasets.c
src/decode-geneve.c
src/decode-icmpv6.c
src/decode-ipv4.c
src/decode-ipv6.c
src/decode-null.c
src/decode-raw.c
src/decode-tcp.c
src/decode-teredo.c
src/decode-vlan.c
src/decode-vntag.c
src/decode-vxlan.c
src/decode.c
src/decode.h
src/defrag-config.c
src/defrag-config.h
src/defrag-hash.h
src/defrag-queue.c
src/defrag-queue.h
src/defrag-timeout.c
src/defrag.c
src/defrag.h
src/detect-byte.h
src/detect-content.c
src/detect-csum.c
src/detect-datarep.c
src/detect-dataset.c
src/detect-dsize.c
src/detect-engine-analyzer.c
src/detect-engine-build.c
src/detect-engine-loader.c
src/detect-engine-port.c
src/detect-engine-prefilter.h
src/detect-engine-profile.c
src/detect-engine-profile.h
src/detect-engine.c
src/detect-filename.c
src/detect-flowbits.c
src/detect-fragbits.c
src/detect-fragoffset.c
src/detect-http-headers-stub.h
src/detect-parse.c
src/detect-parse.h
src/detect-replace.c
src/device-storage.h
src/feature.c
src/flow-bypass.h
src/flow-hash.h
src/flow-storage.h
src/flow-util.h
src/log-cf-common.c
src/log-pcap.c
src/log-tcp-data.c
src/log-tcp-data.h
src/log-tlsstore.c
src/output-file.c
src/output-file.h
src/output-filedata.c
src/output-filedata.h
src/output-filestore.c
src/output-flow.c
src/output-json-common.c
src/output-json-dcerpc.c
src/output-json-smb.c
src/output-lua.c
src/output-packet.c
src/output-packet.h
src/output-stats.c
src/output-streaming.c
src/output-tx.c
src/output-tx.h
src/output.h
src/packet-queue.h
src/packet.c [new file with mode: 0644]
src/packet.h [new file with mode: 0644]
src/reputation.c
src/reputation.h
src/runmode-af-packet.c
src/runmode-dpdk.c
src/runmode-netmap.c
src/runmode-pcap.c
src/runmode-pfring.c
src/runmode-unittests.c
src/rust-context.h
src/rust.h
src/source-dpdk.c
src/source-dpdk.h
src/source-napatech.c
src/stream-tcp-inline.c
src/stream-tcp-reassemble.h
src/stream.h
src/suricata-common.h
src/suricata.c
src/tests/detect-ttl.c
src/tests/detect.c
src/tests/fuzz/fuzz_applayerparserparse.c
src/tests/fuzz/fuzz_decodepcapfile.c
src/tests/fuzz/fuzz_predefpcap_aware.c
src/tests/fuzz/fuzz_sigpcap.c
src/tests/fuzz/fuzz_sigpcap_aware.c
src/threads-profile.h
src/threads.h
src/tm-threads.h
src/tmqh-packetpool.c
src/unix-manager.c
src/unix-manager.h
src/util-affinity.c
src/util-affinity.h
src/util-base64.c
src/util-bpf.c
src/util-checksum.c
src/util-checksum.h
src/util-cidr.c
src/util-conf.c
src/util-coredump-config.c
src/util-datalink.c
src/util-debug-filters.c
src/util-debug-filters.h
src/util-debug.c
src/util-decode-mime.c
src/util-decode-mime.h
src/util-device.c
src/util-dpdk-i40e.c
src/util-dpdk-ice.c
src/util-dpdk-ixgbe.c
src/util-dpdk.c
src/util-exception-policy.h
src/util-file.h
src/util-hash-string.h
src/util-hash.c
src/util-host-info.c
src/util-ioctl.c
src/util-ip.c
src/util-landlock.c
src/util-log-redis.c
src/util-logopenfile.c
src/util-logopenfile.h
src/util-lua-common.c
src/util-lua.h
src/util-magic.c
src/util-mem.c
src/util-memcmp.c
src/util-memcmp.h
src/util-mpm-ac.h
src/util-mpm.h
src/util-pages.c
src/util-pidfile.c
src/util-plugin.c
src/util-pool-thread.h
src/util-prefilter.c
src/util-prefilter.h
src/util-privs.h
src/util-profiling-keywords.c
src/util-profiling-locks.c
src/util-profiling-locks.h
src/util-profiling-prefilter.c
src/util-profiling-rulegroups.c
src/util-profiling-rules.c
src/util-profiling.c
src/util-profiling.h
src/util-proto-name.c
src/util-random.c
src/util-reference-config.h
src/util-rohash.c
src/util-spm-hs.c
src/util-spm.c
src/util-storage.c
src/util-streaming-buffer.c
src/util-thash.h
src/util-unittest-helper.h

index 6a28ea10b9ab1a6e0514cd10e0723a6707ffb440..1685f2de3056a1e9e14d5b1ab7a3a91d10586910 100644 (file)
         fi
 
         AC_DEFINE([HAVE_DPDK],[1],(DPDK support enabled))
-        PKG_CHECK_EXISTS(libdpdk >= 20.11, [pkgconfig_libdpdk_above20=yes], )
-        if test "$pkgconfig_libdpdk_above20" = "yes"; then
-            AC_DEFINE([HAVE_STRLCAT],[1],[STRLCAT is predefined by DPDK 20.11+])
-            AC_DEFINE([HAVE_STRLCPY],[1],[STRLCPY is predefined by DPDK 20.11+])
-        fi
-
         PKG_CHECK_EXISTS(libdpdk >= 19.11, , [with_pkgconfig_libdpdk=no])
         if test "$with_pkgconfig_libdpdk" = "no"; then
             echo
index ab6a98c1d06edcde0b2fe9d305d8bd51cbd7cb9f..87f7a605c0db6a870212a24c16da9aa9210531e9 100644 (file)
@@ -17,7 +17,7 @@ memset(p@p1, 0, ...);
 (
 p->pkt
 |
-PACKET_INITIALIZE(p)
+PacketInit(p)
 )
 
 @script:python depends on !isset@
index e5a855486b17970f3e6d56d02c4cf211e55af7ab..f348e89f2264cc9fc53a7aca85853e24a550c5bb 100755 (executable)
@@ -433,6 +433,7 @@ noinst_HEADERS = \
        output-stats.h \
        output-streaming.h \
        output-tx.h \
+       packet.h \
        packet-queue.h \
        pkt-var.h \
        queue.h \
@@ -1035,6 +1036,7 @@ libsuricata_c_a_SOURCES = \
        output-stats.c \
        output-streaming.c \
        output-tx.c \
+       packet.c \
        packet-queue.c \
        pkt-var.c \
        reputation.c \
index f94b379835b773182a9a3e7981d476bbd9b656f2..ceb0474a81bd668fe72c5636b841da0431fad379 100644 (file)
@@ -2266,6 +2266,7 @@ void AppLayerRegisterExpectationProto(uint8_t proto, AppProto alproto)
 #ifdef UNITTESTS
 
 #include "app-layer-htp.h"
+#include "detect-engine-alert.h"
 
 static AppLayerProtoDetectCtx alpd_ctx_ut;
 
index 7d1430d541af5971b9f71647d5c97eac1fb3f970..e97b35cc4e82d4041446ac6d766dcc01fccd0ab4 100644 (file)
@@ -25,6 +25,9 @@
 #ifndef __APP_LAYER_DETECT_PROTO__H__
 #define __APP_LAYER_DETECT_PROTO__H__
 
+#include "flow.h"
+#include "app-layer-protos.h"
+
 typedef struct AppLayerProtoDetectThreadCtx_ AppLayerProtoDetectThreadCtx;
 
 typedef AppProto (*ProbingParserFPtr)(
index 52fb8c8cca1a870ee790f676cb09db4550eb9273..62e150eb347fff1f086049c73517c5f72c422ad5 100644 (file)
@@ -25,6 +25,7 @@
 #include "suricata-common.h"
 #include "util-print.h"
 
+#include "flow.h"
 #include "stream-tcp.h"
 #include "app-layer-frames.h"
 #include "app-layer-parser.h"
index 72be86cf41a0e38848b3c1f4326655134f6c1b88..8980b6ccc4b18941f90c6f568766bf3486003245 100644 (file)
  */
 
 #include "suricata-common.h"
-#include "decode.h"
-#include "threads.h"
-
-#include "util-print.h"
-#include "util-pool.h"
-
-#include "flow-util.h"
-#include "flow-storage.h"
-
-#include "detect-engine-state.h"
-
-#include "stream-tcp-private.h"
-#include "stream-tcp-reassemble.h"
-#include "stream-tcp.h"
-#include "stream.h"
-
+#include "app-layer-ftp.h"
 #include "app-layer.h"
-#include "app-layer-protos.h"
 #include "app-layer-parser.h"
-#include "app-layer-ftp.h"
 #include "app-layer-expectation.h"
 #include "app-layer-detect-proto.h"
 
-#include "util-spm.h"
-#include "util-mpm.h"
-#include "util-unittest.h"
-#include "util-debug.h"
-#include "util-memcmp.h"
-#include "util-memrchr.h"
-#include "util-mem.h"
+#include "rust.h"
+
 #include "util-misc.h"
+#include "util-mpm.h"
 #include "util-validate.h"
 
-#include "output-json.h"
-#include "rust.h"
-
 typedef struct FTPThreadCtx_ {
     MpmThreadCtx *ftp_mpm_thread_ctx;
     PrefilterRuleStore *pmq;
@@ -1539,6 +1515,7 @@ void FTPParserCleanup(void)
 
 /* UNITTESTS */
 #ifdef UNITTESTS
+#include "stream-tcp.h"
 
 /** \test Send a get request in one chunk. */
 static int FTPParserTest01(void)
index 828550e636ec8cee60a79490bebec4b03e4370c9..caed4ff9c26af6bdd8aaf014f50178e7d59d3175 100644 (file)
  * This file provides a HTTP protocol support for the engine using HTP library.
  */
 
-#include "suricata.h"
 #include "suricata-common.h"
-#include "decode.h"
-#include "threads.h"
-
-#include "util-print.h"
-#include "util-pool.h"
-#include "util-radix-tree.h"
-
-#include "stream-tcp-private.h"
-#include "stream-tcp-reassemble.h"
-#include "stream-tcp.h"
-#include "stream.h"
-
-#include "app-layer-protos.h"
-#include "app-layer-parser.h"
 #include "app-layer-htp.h"
-#include "app-layer-htp-body.h"
 #include "app-layer-htp-mem.h"
-
-#include "util-spm.h"
-#include "util-debug.h"
-#include "app-layer-htp-file.h"
-#include "util-time.h"
-
-#include "util-unittest.h"
-#include "util-unittest-helper.h"
-#include "flow-util.h"
-
-#include "detect-engine.h"
-#include "detect-engine-state.h"
-#include "detect-parse.h"
-
-#include "conf.h"
-
-#include "util-memcmp.h"
+#include "app-layer-htp-body.h"
+#include "util-streaming-buffer.h"
+#include "util-print.h"
 
 static StreamingBufferConfig default_cfg = { 0, 3072, HTPCalloc, HTPRealloc, HTPFree };
 
index 03fe1c378bdeb64a188b7e842eee59582be70b75..78e8799d718afa22c09c780a8ebcf15f7f4dc170 100644 (file)
  * using the HTP library.
  */
 
-#include "suricata.h"
 #include "suricata-common.h"
-#include "util-validate.h"
-#include "decode.h"
-#include "threads.h"
-
-#include "util-print.h"
-#include "util-pool.h"
-#include "util-radix-tree.h"
-
-#include "stream-tcp-private.h"
-#include "stream-tcp-reassemble.h"
-#include "stream-tcp.h"
-#include "stream.h"
-
-#include "app-layer.h"
-#include "app-layer-protos.h"
-#include "app-layer-parser.h"
-#include "app-layer-htp.h"
 #include "app-layer-htp-file.h"
 #include "app-layer-htp-range.h"
-
-#include "util-spm.h"
-#include "util-debug.h"
-#include "util-time.h"
-
-#include "util-unittest.h"
-#include "util-unittest-helper.h"
-#include "flow-util.h"
-
-#include "detect-engine.h"
-#include "detect-engine-state.h"
-#include "detect-parse.h"
-
-#include "conf.h"
-
-#include "util-memcmp.h"
+#include "util-validate.h"
 
 /**
  *  \brief Open the file with "filename" and pass the first chunk
@@ -374,6 +341,10 @@ end:
 }
 
 #ifdef UNITTESTS
+#include "stream-tcp.h"
+#include "app-layer-parser.h"
+#include "util-unittest-helper.h"
+
 static int HTPFileParserTest01(void)
 {
     uint8_t httpbuf1[] = "POST /upload.cgi HTTP/1.1\r\n"
index a4ef784b0ed7c54d66b756ea8f5e4eb1c6f72ef8..f7daf70c92ba1fd1071cb57c5002913f065cbea1 100644 (file)
@@ -39,8 +39,8 @@
  * Anoop Saldanha <anoopsaldanha@gmail.com>
  */
 
-#include "suricata.h"
 #include "suricata-common.h"
+#include <htp/htp.h>
 #include "app-layer-htp-libhtp.h"
 
 /**
index e1893f1e900807f7dfcce1eb0ccf1deadd985084..7d06db0b1f51a25077aa4ee78f0d6ae42a730156 100644 (file)
  */
 
 #include "suricata-common.h"
-#include "suricata.h"
+#include "app-layer-htp-mem.h"
 
 #include "conf.h"
-#include "util-mem.h"
 #include "util-misc.h"
-
-#include "app-layer-htp-mem.h"
+#include "util-debug.h"
 
 SC_ATOMIC_DECLARE(uint64_t, htp_config_memcap);
 SC_ATOMIC_DECLARE(uint64_t, htp_memuse);
index d7a8cd0a384ff2e5973ea369ad872a7cb7f7c815..c3dec401d76e03a20580c79ce99d9e7339a60018 100644 (file)
@@ -3233,6 +3233,8 @@ void RegisterHTPParsers(void)
 }
 
 #ifdef UNITTESTS
+#include "detect-engine-alert.h"
+
 static HTPCfgRec cfglist_backup;
 
 void HtpConfigCreateBackup(void)
index 51dae0b811a79aaeceb63594a14e3bd628c49be6..6c6c60e0ba41374d910d2c520d0e8d16e3da41c7 100644 (file)
@@ -33,8 +33,6 @@
 #ifndef __APP_LAYER_HTP_H__
 #define __APP_LAYER_HTP_H__
 
-#include "util-file.h"
-#include "util-streaming-buffer.h"
 #include "rust.h"
 #include "app-layer-frames.h"
 
index 0f608c9c093199314ae2a606991d6924e7e554e9..2534d72bf65722b7376f81177c18f68e783d2dd1 100644 (file)
@@ -40,7 +40,6 @@
 
 #include "app-layer-parser.h"
 #include "app-layer-modbus.h"
-#include "detect-engine-build.h"
 
 void ModbusParserRegisterTests(void);
 
@@ -62,6 +61,7 @@ void RegisterModbusParsers(void)
 #include "detect.h"
 #include "detect-engine.h"
 #include "detect-parse.h"
+#include "detect-engine-build.h"
 
 #include "flow-util.h"
 
index 3b33912bd134a3b11e6cd6c1455ebe6a9ece67fd..31c4c8ade5134292351042ad5db02d6dd9e34044 100644 (file)
  */
 
 #include "suricata-common.h"
-#include "util-unittest.h"
-#include "decode.h"
-#include "threads.h"
-
-#include "util-print.h"
-#include "util-pool.h"
+#include "app-layer-parser.h"
 
-#include "flow-util.h"
+#include "flow.h"
 #include "flow-private.h"
+#include "flow-util.h"
 
-#include "detect-engine-state.h"
-#include "detect-engine-port.h"
+#include "app-layer-frames.h"
 
 #include "stream-tcp.h"
-#include "stream-tcp-private.h"
-#include "stream.h"
-#include "stream-tcp-reassemble.h"
+
+#include "util-validate.h"
 
 #include "app-layer.h"
 #include "app-layer-detect-proto.h"
-#include "app-layer-protos.h"
-#include "app-layer-parser.h"
+
+#include "app-layer-ftp.h"
+#include "app-layer-smtp.h"
+
 #include "app-layer-smb.h"
 #include "app-layer-htp.h"
-#include "app-layer-ftp.h"
 #include "app-layer-ssl.h"
 #include "app-layer-ssh.h"
-#include "app-layer-smtp.h"
 #include "app-layer-modbus.h"
 #include "app-layer-enip.h"
 #include "app-layer-dnp3.h"
 #include "app-layer-tftp.h"
 #include "app-layer-ike.h"
 #include "app-layer-krb5.h"
-#include "app-layer-snmp.h"
 #include "app-layer-sip.h"
 #include "app-layer-rfb.h"
 #include "app-layer-mqtt.h"
+#include "app-layer-snmp.h"
 #include "app-layer-quic.h"
 #include "app-layer-template.h"
 #include "app-layer-template-rust.h"
 #include "app-layer-rdp.h"
 #include "app-layer-http2.h"
 
-#include "conf.h"
-#include "util-spm.h"
-
-#include "util-debug.h"
-#include "decode-events.h"
-#include "util-unittest-helper.h"
-#include "util-validate.h"
-
-#include "runmodes.h"
-
-#include "rust.h"
-
 struct AppLayerParserThreadCtx_ {
     void *alproto_local_storage[FLOW_PROTO_MAX][ALPROTO_MAX];
 };
@@ -1840,6 +1822,7 @@ void AppLayerParserStatePrintDetails(AppLayerParserState *pstate)
 /***** Unittests *****/
 
 #ifdef UNITTESTS
+#include "util-unittest-helper.h"
 
 static AppLayerParserCtx alp_ctx_backup_unittest;
 
index e7ac4d2eb3f48ed110f17c3864cc1eb5a7938e7c..fb0d407d22e21efce4b4ef95076c73925250d391 100644 (file)
@@ -25,7 +25,7 @@
  */
 
 #include "suricata-common.h"
-
+#include "suricata.h"
 #include "app-layer.h"
 #include "app-layer-parser.h"
 #include "app-layer-protos.h"
index 202a25da04da8bcf30d1ea6b9636f632d51caa8d..671da0f8086a36408366b5f155a903dacaeefeeb 100644 (file)
@@ -41,6 +41,7 @@
 #include "util-unittest.h"
 #include "util-debug.h"
 #include "util-path.h"
+#include "util-conf.h"
 
 /** Maximum size of a complete domain name. */
 #define NODE_NAME_MAX 1024
index 6960fe06e93663e49bc8c6c965b7212d36380202..d323bb2d5e511cfae48b620754dc8e6120b313ab 100644 (file)
  */
 
 #include "suricata-common.h"
-#include "suricata.h"
 #include "counters.h"
+
+#include "suricata.h"
 #include "threadvars.h"
-#include "tm-threads.h"
-#include "conf.h"
-#include "util-time.h"
-#include "util-unittest.h"
-#include "util-debug.h"
-#include "util-byte.h"
-#include "util-privs.h"
-#include "util-signal.h"
-#include "unix-manager.h"
-#include "runmodes.h"
 
 #include "output.h"
-#include "output-stats.h"
 #include "output-json-stats.h"
 
+#include "util-byte.h"
+#include "util-conf.h"
+#include "util-hash.h"
+#include "util-time.h"
+
+#include "tm-threads.h"
+#include "util-privs.h"
+
 /* Time interval for syncing the local counters with the global ones */
 #define STATS_WUT_TTS 3
 
index f6b6bc07a7c6a63ef2ae45576a8646f029f10510..74a505ffc91e62a054d41ce236c383e48cd47551 100644 (file)
@@ -25,6 +25,8 @@
 #ifndef __COUNTERS_H__
 #define __COUNTERS_H__
 
+#include "threads.h"
+
 /* forward declaration of the ThreadVars structure */
 struct ThreadVars_;
 
index 5ae1a9f1f314e2a57d2b0c87d2671d69a0a0e4aa..15a5f6f36c3b8e5034ff100e8e446ba33e8ba93e 100644 (file)
 #include "datasets-md5.h"
 #include "datasets-sha256.h"
 #include "datasets-reputation.h"
+#include "util-conf.h"
 #include "util-thash.h"
 #include "util-print.h"
 #include "util-base64.h"    // decode base64
 #include "util-byte.h"
 #include "util-misc.h"
+#include "util-path.h"
+#include "util-debug.h"
 
 SCMutex sets_lock = SCMUTEX_INITIALIZER;
 static Dataset *sets = NULL;
index 19c8baf98f163768c01f0cce2d238bd86d16d346..a41d33c46f7dad87ef47e2ab1c8784b534707a96 100644 (file)
@@ -31,6 +31,7 @@
 #include "decode-geneve.h"
 #include "decode-events.h"
 
+#include "detect.h"
 #include "detect-engine-port.h"
 
 #include "flow.h"
index 4325dadf53a958c23db2ee22ab45b609f1a1bf58..36666c9867f7d1d7eaa37c4c454ca84cd841db69 100644 (file)
 #include "suricata-common.h"
 #include "decode-icmpv6.h"
 #include "decode.h"
-#include "decode-tcp.h"
-#include "decode-sctp.h"
-#include "decode-udp.h"
-#include "decode-events.h"
-#include "util-unittest.h"
 #include "flow.h"
-#include "util-debug.h"
 #include "util-print.h"
 #include "util-validate.h"
 
-#include "pkt-var.h"
-#include "util-profiling.h"
-#include "host.h"
-
-
 /**
  * \brief Get variables and do some checks of the embedded IPV6 packet
  *
@@ -531,6 +520,7 @@ int DecodeICMPV6(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
 }
 
 #ifdef UNITTESTS
+#include "util-unittest-helper.h"
 
 static int ICMPV6CalculateValidChecksumtest01(void)
 {
@@ -640,7 +630,7 @@ static int ICMPV6ParamProbTest01(void)
             p->icmpv6vars.emb_ip6_dst[i] != ipv6dst[i]);
     }
 
-    PACKET_RECYCLE(p);
+    PacketRecycle(p);
     FlowShutdown();
     SCFree(p);
     PASS;
@@ -698,7 +688,7 @@ static int ICMPV6PktTooBigTest01(void)
 
     SCLogDebug("ICMPV6 IPV6 src and dst properly set");
 
-    PACKET_RECYCLE(p);
+    PacketRecycle(p);
     FlowShutdown();
     SCFree(p);
     PASS;
@@ -756,7 +746,7 @@ static int ICMPV6TimeExceedTest01(void)
 
     SCLogDebug("ICMPV6 IPV6 src and dst properly set");
 
-    PACKET_RECYCLE(p);
+    PacketRecycle(p);
     FlowShutdown();
     SCFree(p);
     PASS;
@@ -812,7 +802,7 @@ static int ICMPV6DestUnreachTest01(void)
             p->icmpv6vars.emb_ip6_dst[i] != ipv6dst[i]);
     }
 
-    PACKET_RECYCLE(p);
+    PacketRecycle(p);
     FlowShutdown();
     SCFree(p);
     PASS;
@@ -856,7 +846,7 @@ static int ICMPV6EchoReqTest01(void)
         FAIL;
     }
 
-    PACKET_RECYCLE(p);
+    PacketRecycle(p);
     FlowShutdown();
     SCFree(p);
     PASS;
@@ -902,7 +892,7 @@ static int ICMPV6EchoRepTest01(void)
         FAIL;
     }
 
-    PACKET_RECYCLE(p);
+    PacketRecycle(p);
     FlowShutdown();
     SCFree(p);
     PASS;
@@ -945,7 +935,7 @@ static int ICMPV6ParamProbTest02(void)
     FAIL_IF(ICMPV6_GET_TYPE(p) != 4 || ICMPV6_GET_CODE(p) != 0);
     FAIL_IF(!ENGINE_ISSET_EVENT(p, ICMPV6_IPV6_UNKNOWN_VER));
 
-    PACKET_RECYCLE(p);
+    PacketRecycle(p);
     FlowShutdown();
     SCFree(p);
     PASS;
@@ -986,7 +976,7 @@ static int ICMPV6PktTooBigTest02(void)
     FAIL_IF_NULL(p->icmpv6h);
     FAIL_IF(!ENGINE_ISSET_EVENT(p, ICMPV6_UNKNOWN_CODE));
 
-    PACKET_RECYCLE(p);
+    PacketRecycle(p);
     FlowShutdown();
     SCFree(p);
     PASS;
@@ -1023,7 +1013,7 @@ static int ICMPV6TimeExceedTest02(void)
 
     FAIL_IF(!ENGINE_ISSET_EVENT(p, ICMPV6_PKT_TOO_SMALL));
 
-    PACKET_RECYCLE(p);
+    PacketRecycle(p);
     FlowShutdown();
     SCFree(p);
     PASS;
@@ -1063,7 +1053,7 @@ static int ICMPV6DestUnreachTest02(void)
 
     FAIL_IF(!ENGINE_ISSET_EVENT(p, ICMPV6_IPV6_TRUNC_PKT));
 
-    PACKET_RECYCLE(p);
+    PacketRecycle(p);
     FlowShutdown();
     SCFree(p);
     PASS;
@@ -1099,7 +1089,7 @@ static int ICMPV6EchoReqTest02(void)
 
     FAIL_IF(!ENGINE_ISSET_EVENT(p, ICMPV6_UNKNOWN_CODE));
 
-    PACKET_RECYCLE(p);
+    PacketRecycle(p);
     FlowShutdown();
     SCFree(p);
     PASS;
@@ -1135,7 +1125,7 @@ static int ICMPV6EchoRepTest02(void)
 
     FAIL_IF(!ENGINE_ISSET_EVENT(p, ICMPV6_UNKNOWN_CODE));
 
-    PACKET_RECYCLE(p);
+    PacketRecycle(p);
     FlowShutdown();
     SCFree(p);
     PASS;
@@ -1175,7 +1165,7 @@ static int ICMPV6PayloadTest01(void)
     FAIL_IF_NULL(p->payload);
     FAIL_IF(p->payload_len != 37);
 
-    PACKET_RECYCLE(p);
+    PacketRecycle(p);
     FlowShutdown();
     SCFree(p);
     PASS;
@@ -1207,7 +1197,7 @@ static int ICMPV6RouterSolicitTestKnownCode(void)
 
     FAIL_IF(ENGINE_ISSET_EVENT(p, ICMPV6_UNKNOWN_CODE));
 
-    PACKET_RECYCLE(p);
+    PacketRecycle(p);
     FlowShutdown();
     SCFree(p);
     PASS;
@@ -1239,7 +1229,7 @@ static int ICMPV6RouterSolicitTestUnknownCode(void)
 
     FAIL_IF(!ENGINE_ISSET_EVENT(p, ICMPV6_UNKNOWN_CODE));
 
-    PACKET_RECYCLE(p);
+    PacketRecycle(p);
     FlowShutdown();
     SCFree(p);
     PASS;
@@ -1271,7 +1261,7 @@ static int ICMPV6RouterAdvertTestKnownCode(void)
 
     FAIL_IF(ENGINE_ISSET_EVENT(p, ICMPV6_UNKNOWN_CODE));
 
-    PACKET_RECYCLE(p);
+    PacketRecycle(p);
     FlowShutdown();
     SCFree(p);
     PASS;
@@ -1303,7 +1293,7 @@ static int ICMPV6RouterAdvertTestUnknownCode(void)
 
     FAIL_IF(!ENGINE_ISSET_EVENT(p, ICMPV6_UNKNOWN_CODE));
 
-    PACKET_RECYCLE(p);
+    PacketRecycle(p);
     FlowShutdown();
     SCFree(p);
     PASS;
@@ -1335,7 +1325,7 @@ static int ICMPV6NeighbourSolicitTestKnownCode(void)
 
     FAIL_IF(ENGINE_ISSET_EVENT(p, ICMPV6_UNKNOWN_CODE));
 
-    PACKET_RECYCLE(p);
+    PacketRecycle(p);
     FlowShutdown();
     SCFree(p);
     PASS;
@@ -1367,7 +1357,7 @@ static int ICMPV6NeighbourSolicitTestUnknownCode(void)
 
     FAIL_IF(!ENGINE_ISSET_EVENT(p, ICMPV6_UNKNOWN_CODE));
 
-    PACKET_RECYCLE(p);
+    PacketRecycle(p);
     FlowShutdown();
     SCFree(p);
     PASS;
@@ -1399,7 +1389,7 @@ static int ICMPV6NeighbourAdvertTestKnownCode(void)
 
     FAIL_IF(ENGINE_ISSET_EVENT(p, ICMPV6_UNKNOWN_CODE));
 
-    PACKET_RECYCLE(p);
+    PacketRecycle(p);
     FlowShutdown();
     SCFree(p);
     PASS;
@@ -1431,7 +1421,7 @@ static int ICMPV6NeighbourAdvertTestUnknownCode(void)
 
     FAIL_IF(!ENGINE_ISSET_EVENT(p, ICMPV6_UNKNOWN_CODE));
 
-    PACKET_RECYCLE(p);
+    PacketRecycle(p);
     FlowShutdown();
     SCFree(p);
     PASS;
@@ -1463,7 +1453,7 @@ static int ICMPV6RedirectTestKnownCode(void)
 
     FAIL_IF(ENGINE_ISSET_EVENT(p, ICMPV6_UNKNOWN_CODE));
 
-    PACKET_RECYCLE(p);
+    PacketRecycle(p);
     FlowShutdown();
     SCFree(p);
     PASS;
@@ -1495,7 +1485,7 @@ static int ICMPV6RedirectTestUnknownCode(void)
 
     FAIL_IF(!ENGINE_ISSET_EVENT(p, ICMPV6_UNKNOWN_CODE));
 
-    PACKET_RECYCLE(p);
+    PacketRecycle(p);
     FlowShutdown();
     SCFree(p);
     PASS;
@@ -1549,7 +1539,7 @@ static int ICMPV6CalculateValidChecksumWithFCS(void)
     FAIL_IF(ICMPV6CalculateChecksum(p->ip6h->s_ip6_addrs,
             (uint16_t *)p->icmpv6h, icmpv6_len) != csum);
 
-    PACKET_RECYCLE(p);
+    PacketRecycle(p);
     FlowShutdown();
     SCFree(p);
     PASS;
index 2c3d781de4d8dc2e6f9f34805e03e883f723f9b9..7b84964917f2650687e3e36d1cc655627abbbf15 100644 (file)
  */
 
 #include "suricata-common.h"
-#include "packet-queue.h"
-#include "decode.h"
 #include "decode-ipv4.h"
-#include "decode-events.h"
+#include "decode.h"
 #include "defrag.h"
-#include "pkt-var.h"
-#include "host.h"
-
-#include "util-unittest.h"
-#include "util-debug.h"
-#include "util-optimize.h"
+#include "flow.h"
 #include "util-print.h"
-#include "util-profiling.h"
 
 /* Generic validation
  *
@@ -624,6 +616,7 @@ int DecodeIPV4(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
 
 /* UNITTESTS */
 #ifdef UNITTESTS
+#include "packet.h"
 
 /** \test IPV4 with no options. */
 static int DecodeIPV4OptionsNONETest01(void)
@@ -1312,7 +1305,7 @@ static int DecodeIPV4DefragTest01(void)
         result = 0;
         goto end;
     }
-    PACKET_RECYCLE(p);
+    PacketRecycle(p);
 
     PacketCopyData(p, pkt2, sizeof(pkt2));
     DecodeIPV4(&tv, &dtv, p, GET_PKT_DATA(p) + ETHERNET_HEADER_LEN,
@@ -1322,7 +1315,7 @@ static int DecodeIPV4DefragTest01(void)
         result = 0;
         goto end;
     }
-    PACKET_RECYCLE(p);
+    PacketRecycle(p);
 
     PacketCopyData(p, pkt3, sizeof(pkt3));
     DecodeIPV4(&tv, &dtv, p, GET_PKT_DATA(p) + ETHERNET_HEADER_LEN,
@@ -1363,12 +1356,12 @@ static int DecodeIPV4DefragTest01(void)
             goto end;
     }
 
-    PACKET_RECYCLE(tp);
+    PacketRecycle(tp);
     SCFree(tp);
 
 end:
     DefragDestroy();
-    PACKET_RECYCLE(p);
+    PacketRecycle(p);
     FlowShutdown();
     SCFree(p);
     return result;
@@ -1446,7 +1439,7 @@ static int DecodeIPV4DefragTest02(void)
         printf("tcp header should be NULL for ip fragment, but it isn't\n");
         goto end;
     }
-    PACKET_RECYCLE(p);
+    PacketRecycle(p);
 
     PacketCopyData(p, pkt2, sizeof(pkt2));
     DecodeIPV4(&tv, &dtv, p, GET_PKT_DATA(p) + ETHERNET_HEADER_LEN,
@@ -1455,7 +1448,7 @@ static int DecodeIPV4DefragTest02(void)
         printf("tcp header should be NULL for ip fragment, but it isn't\n");
         goto end;
     }
-    PACKET_RECYCLE(p);
+    PacketRecycle(p);
 
     p->recursion_level = 3;
     PacketCopyData(p, pkt3, sizeof(pkt3));
@@ -1493,12 +1486,12 @@ static int DecodeIPV4DefragTest02(void)
     }
 
     result = 1;
-    PACKET_RECYCLE(tp);
+    PacketRecycle(tp);
     SCFree(tp);
 
 end:
     DefragDestroy();
-    PACKET_RECYCLE(p);
+    PacketRecycle(p);
     FlowShutdown();
     SCFree(p);
     return result;
@@ -1577,7 +1570,7 @@ static int DecodeIPV4DefragTest03(void)
         result = 0;
         goto end;
     }
-    PACKET_RECYCLE(p);
+    PacketRecycle(p);
 
     PacketCopyData(p, pkt1, sizeof(pkt1));
     DecodeIPV4(&tv, &dtv, p, GET_PKT_DATA(p) + ETHERNET_HEADER_LEN,
@@ -1587,7 +1580,7 @@ static int DecodeIPV4DefragTest03(void)
         result = 0;
         goto end;
     }
-    PACKET_RECYCLE(p);
+    PacketRecycle(p);
 
     PacketCopyData(p, pkt2, sizeof(pkt2));
     DecodeIPV4(&tv, &dtv, p, GET_PKT_DATA(p) + ETHERNET_HEADER_LEN,
@@ -1597,7 +1590,7 @@ static int DecodeIPV4DefragTest03(void)
         result = 0;
         goto end;
     }
-    PACKET_RECYCLE(p);
+    PacketRecycle(p);
 
     PacketCopyData(p, pkt3, sizeof(pkt3));
     DecodeIPV4(&tv, &dtv, p, GET_PKT_DATA(p) + ETHERNET_HEADER_LEN,
@@ -1648,12 +1641,12 @@ static int DecodeIPV4DefragTest03(void)
             goto end;
     }
 
-    PACKET_RECYCLE(tp);
+    PacketRecycle(tp);
     SCFree(tp);
 
 end:
     DefragDestroy();
-    PACKET_RECYCLE(p);
+    PacketRecycle(p);
     FlowShutdown();
     SCFree(p);
     return result;
index 5872e762e3b77ba140a6c8dfcf74b7b27e944068..65fedc22d3fef1b2bc1af8c613f236cfe7dfe96e 100644 (file)
  */
 
 #include "suricata-common.h"
-#include "packet-queue.h"
-#include "decode.h"
 #include "decode-ipv6.h"
-#include "decode-icmpv6.h"
-#include "decode-events.h"
+#include "decode.h"
 #include "defrag.h"
-#include "pkt-var.h"
-#include "util-debug.h"
 #include "util-print.h"
-#include "util-unittest.h"
-#include "util-profiling.h"
 #include "util-validate.h"
-#include "host.h"
 
 /**
  * \brief Function to decode IPv4 in IPv6 packets
@@ -657,6 +649,7 @@ int DecodeIPV6(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t *
 }
 
 #ifdef UNITTESTS
+#include "util-unittest-helper.h"
 
 /**
  * \test fragment decoding
@@ -809,13 +802,13 @@ static int DecodeIPV6FragTest01 (void)
 
     result = 1;
 end:
-    PACKET_RECYCLE(p1);
-    PACKET_RECYCLE(p2);
+    PacketRecycle(p1);
+    PacketRecycle(p2);
     SCFree(p1);
     SCFree(p2);
     pkt = PacketDequeueNoLock(&tv.decode_pq);
     while (pkt != NULL) {
-        PACKET_RECYCLE(pkt);
+        PacketRecycle(pkt);
         SCFree(pkt);
         pkt = PacketDequeueNoLock(&tv.decode_pq);
     }
@@ -857,7 +850,7 @@ static int DecodeIPV6RouteTest01 (void)
 
     FAIL_IF (!(IPV6_EXTHDR_ISSET_RH(p1)));
     FAIL_IF (p1->ip6eh.rh_type != 0);
-    PACKET_RECYCLE(p1);
+    PacketRecycle(p1);
     SCFree(p1);
     FlowShutdown();
     PASS;
@@ -892,7 +885,7 @@ static int DecodeIPV6HopTest01 (void)
 
     FAIL_IF (!(ENGINE_ISSET_EVENT(p1, IPV6_HOPOPTS_UNKNOWN_OPT)));
 
-    PACKET_RECYCLE(p1);
+    PacketRecycle(p1);
     SCFree(p1);
     FlowShutdown();
     PASS;
index dc7051edc3f6cba9c3849cefd40fd48c01db4aae..d926516fdc559769797d2ab3393781e9d84fd70c 100644 (file)
 #include "util-unittest.h"
 #include "util-debug.h"
 
-#include "pkt-var.h"
-#include "util-profiling.h"
-#include "host.h"
-
 #define HDR_SIZE 4
 
 #define AF_INET6_BSD     24
index 2eaa700f286d41dd669698abf508354cf674ef7b..bb34b4323670512538278ff8e45994b76b02e61d 100644 (file)
  */
 
 #include "suricata-common.h"
-#include "decode.h"
 #include "decode-raw.h"
+#include "decode.h"
 #include "decode-events.h"
 
 #include "util-validate.h"
 #include "util-unittest.h"
 #include "util-debug.h"
 
-#include "pkt-var.h"
-#include "util-profiling.h"
-#include "host.h"
-
-
 int DecodeRaw(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
         const uint8_t *pkt, uint32_t len)
 {
@@ -79,8 +74,7 @@ int DecodeRaw(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
 }
 
 #ifdef UNITTESTS
-#include "flow.h"
-#include "flow-util.h"
+#include "util-unittest-helper.h"
 
 /** DecodeRawtest01
  *  \brief Valid Raw packet
@@ -125,7 +119,7 @@ static int DecodeRawTest01 (void)
         return 0;
     }
 
-    PACKET_RECYCLE(p);
+    PacketRecycle(p);
     FlowShutdown();
     SCFree(p);
     return 1;
@@ -166,13 +160,13 @@ static int DecodeRawTest02 (void)
     DecodeRaw(&tv, &dtv, p, raw_ip, GET_PKT_LEN(p));
     if (p->ip4h == NULL) {
         printf("expected a valid ipv4 header but it was NULL: ");
-        PACKET_RECYCLE(p);
+        PacketRecycle(p);
         FlowShutdown();
         SCFree(p);
         return 0;
     }
 
-    PACKET_RECYCLE(p);
+    PacketRecycle(p);
     FlowShutdown();
     SCFree(p);
     return 1;
@@ -218,7 +212,7 @@ static int DecodeRawTest03 (void)
         SCFree(p);
         return 0;
     }
-    PACKET_RECYCLE(p);
+    PacketRecycle(p);
     FlowShutdown();
     SCFree(p);
     return 1;
index 8fa8fd99ac92f91d0dd4cde6b10d3210b1ba4839..1df718d2ede54d48a38e2f700ebd13119f2fd05f 100644 (file)
  */
 
 #include "suricata-common.h"
-#include "decode.h"
 #include "decode-tcp.h"
+#include "decode.h"
 #include "decode-events.h"
 #include "util-unittest.h"
 #include "util-debug.h"
 #include "util-optimize.h"
 #include "flow.h"
-#include "util-profiling.h"
-#include "pkt-var.h"
-#include "host.h"
 
 #define SET_OPTS(dst, src) \
     (dst).type = (src).type; \
@@ -273,6 +270,8 @@ int DecodeTCP(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
 }
 
 #ifdef UNITTESTS
+#include "util-unittest-helper.h"
+
 static int TCPCalculateValidChecksumtest01(void)
 {
     uint16_t csum = 0;
@@ -404,7 +403,7 @@ static int TCPGetWscaleTest01(void)
 
     retval = 1;
 end:
-    PACKET_RECYCLE(p);
+    PacketRecycle(p);
     FlowShutdown();
     SCFree(p);
     return retval;
@@ -450,7 +449,7 @@ static int TCPGetWscaleTest02(void)
 
     retval = 1;
 end:
-    PACKET_RECYCLE(p);
+    PacketRecycle(p);
     FlowShutdown();
     SCFree(p);
     return retval;
@@ -495,7 +494,7 @@ static int TCPGetWscaleTest03(void)
 
     retval = 1;
 end:
-    PACKET_RECYCLE(p);
+    PacketRecycle(p);
     FlowShutdown();
     SCFree(p);
     return retval;
@@ -560,7 +559,7 @@ static int TCPGetSackTest01(void)
 
     retval = 1;
 end:
-    PACKET_RECYCLE(p);
+    PacketRecycle(p);
     FlowShutdown();
     SCFree(p);
     return retval;
index 194d09a92efb5216fc6dd107f53b24cc1fad7b52..8364a2e1e2beb32d69903d35d2435c14b16f08b8 100644 (file)
@@ -40,6 +40,8 @@
 #include "util-validate.h"
 #include "util-debug.h"
 #include "conf.h"
+
+#include "detect.h"
 #include "detect-engine-port.h"
 
 #define TEREDO_ORIG_INDICATION_LENGTH   8
index 351fcf9e7cf20582b86f01e35f1b09ed32eb0d63..820b316d9845abbc130767e5eb43e51ee5d4beb3 100644 (file)
 #include "decode-vlan.h"
 #include "decode-events.h"
 
-#include "flow.h"
-
 #include "util-validate.h"
 #include "util-unittest.h"
 #include "util-debug.h"
 
-#include "pkt-var.h"
-#include "util-profiling.h"
-#include "host.h"
-
 /**
  * \internal
  * \brief this function is used to decode IEEE802.1q packets
@@ -140,6 +134,8 @@ int DecodeIEEE8021ah(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
 }
 
 #ifdef UNITTESTS
+#include "util-unittest-helper.h"
+
 /** \todo Must GRE+VLAN and Multi-Vlan packets to
  * create more tests
  */
@@ -252,13 +248,13 @@ static int DecodeVLANtest03 (void)
         goto error;
     }
 
-    PACKET_RECYCLE(p);
+    PacketRecycle(p);
     FlowShutdown();
     SCFree(p);
     return 1;
 
 error:
-    PACKET_RECYCLE(p);
+    PacketRecycle(p);
     FlowShutdown();
     SCFree(p);
     return 0;
index 56f536a804c6e85e7b12c2df7b4200db979fd994..0b0eb28f43f96e3b05be809ef8b5358892c08e02 100644 (file)
  */
 
 #include "suricata-common.h"
-#include "decode.h"
 #include "decode-vntag.h"
+#include "decode.h"
 #include "decode-events.h"
 
-#include "flow.h"
-
 #include "util-validate.h"
 #include "util-unittest.h"
 #include "util-debug.h"
 
-#include "pkt-var.h"
-#include "util-profiling.h"
-#include "host.h"
-
 /**
  * \internal
  * \brief this function is used to decode 802.1Qbh packets
@@ -89,6 +83,7 @@ int DecodeVNTag(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const uint8_t
 }
 
 #ifdef UNITTESTS
+#include "util-unittest-helper.h"
 
 /**
  * \test DecodeVNTagTest01 test if vntag header is too small.
@@ -166,7 +161,7 @@ static int DecodeVNTagtest03(void)
 
     FAIL_IF(TM_ECODE_OK != DecodeVNTag(&tv, &dtv, p, raw_vntag, sizeof(raw_vntag)));
 
-    PACKET_RECYCLE(p);
+    PacketRecycle(p);
     FlowShutdown();
     PacketFree(p);
     PASS;
index 6a7322993ee6390116b3e11785fcc4f438ca7997..e73bc5642b397c5f543eee56e7a10a3c62d66feb 100644 (file)
@@ -31,6 +31,7 @@
 #include "decode-vxlan.h"
 #include "decode-events.h"
 
+#include "detect.h"
 #include "detect-engine-port.h"
 
 #include "flow.h"
 #include "util-unittest.h"
 #include "util-debug.h"
 
-#include "pkt-var.h"
-#include "util-profiling.h"
-#include "host.h"
-
 #define VXLAN_HEADER_LEN sizeof(VXLANHeader)
 
 #define VXLAN_MAX_PORTS         4
index f7fb514123327c3610200d80c46d0ab7008e9e06..303349625bacf0d6a5fdac595413f199d9a07340 100644 (file)
  */
 
 #include "suricata-common.h"
-#include "suricata.h"
-#include "conf.h"
 #include "decode.h"
-#include "decode-teredo.h"
-#include "decode-erspan.h"
-#include "decode-geneve.h"
-#include "decode-vxlan.h"
-#include "util-debug.h"
-#include "util-mem.h"
-#include "app-layer-detect-proto.h"
+
+#include "packet.h"
+#include "flow.h"
+#include "flow-storage.h"
+#include "tmqh-packetpool.h"
 #include "app-layer.h"
-#include "tm-threads.h"
-#include "util-error.h"
+#include "output.h"
+
+#include "decode-vxlan.h"
+#include "decode-geneve.h"
+#include "decode-erspan.h"
+#include "decode-teredo.h"
+
+#include "util-hash.h"
+#include "util-hash-string.h"
 #include "util-print.h"
-#include "tmqh-packetpool.h"
 #include "util-profiling.h"
-#include "pkt-var.h"
-#include "util-mpm-ac.h"
-#include "util-hash-string.h"
-#include "output.h"
-#include "output-flow.h"
-#include "flow-storage.h"
 #include "util-validate.h"
 
 uint32_t default_packet_size = 0;
@@ -136,7 +132,7 @@ static int DecodeTunnel(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, const
  */
 void PacketFree(Packet *p)
 {
-    PACKET_DESTRUCTOR(p);
+    PacketDestructor(p);
     SCFree(p);
 }
 
@@ -181,7 +177,7 @@ Packet *PacketGetFromAlloc(void)
     }
 
     memset(p, 0, SIZE_OF_PACKET);
-    PACKET_INITIALIZE(p);
+    PacketInit(p);
     p->ReleasePacket = PacketFree;
     p->flags |= PKT_ALLOC;
 
index e205cb195b8a7339b74fd290fd05fd87cedb683c..f59570e14a7a10751ca942ded7a0b2452771471b 100644 (file)
@@ -223,6 +223,7 @@ typedef struct Address_ {
 #define GET_TCP_SRC_PORT(p)  ((p)->sp)
 #define GET_TCP_DST_PORT(p)  ((p)->dp)
 
+#define RESET_PKT_LEN(p)           ((p)->pktlen = 0)
 #define GET_PKT_LEN(p) ((p)->pktlen)
 #define GET_PKT_DATA(p) ((((p)->ext_pkt) == NULL ) ? (uint8_t *)((p) + 1) : (p)->ext_pkt)
 #define GET_PKT_DIRECT_DATA(p) (uint8_t *)((p) + 1)
@@ -777,123 +778,6 @@ void CaptureStatsSetup(ThreadVars *tv, CaptureStats *s);
         }                                           \
     } while(0)
 
-/**
- *  \brief Initialize a packet structure for use.
- */
-#define PACKET_INITIALIZE(p)                                                                       \
-    {                                                                                              \
-        SCMutexInit(&(p)->tunnel_mutex, NULL);                                                     \
-        (p)->alerts.alerts = PacketAlertCreate();                                                  \
-        PACKET_RESET_CHECKSUMS((p));                                                               \
-        (p)->livedev = NULL;                                                                       \
-    }
-
-#define PACKET_RELEASE_REFS(p) do {              \
-        FlowDeReference(&((p)->flow));          \
-        HostDeReference(&((p)->host_src));      \
-        HostDeReference(&((p)->host_dst));      \
-    } while (0)
-
-/**
- *  \brief Recycle a packet structure for reuse.
- */
-#define PACKET_REINIT(p)                                                                           \
-    do {                                                                                           \
-        CLEAR_ADDR(&(p)->src);                                                                     \
-        CLEAR_ADDR(&(p)->dst);                                                                     \
-        (p)->sp = 0;                                                                               \
-        (p)->dp = 0;                                                                               \
-        (p)->proto = 0;                                                                            \
-        (p)->recursion_level = 0;                                                                  \
-        PACKET_FREE_EXTDATA((p));                                                                  \
-        (p)->flags = (p)->flags & PKT_ALLOC;                                                       \
-        (p)->flowflags = 0;                                                                        \
-        (p)->pkt_src = 0;                                                                          \
-        (p)->vlan_id[0] = 0;                                                                       \
-        (p)->vlan_id[1] = 0;                                                                       \
-        (p)->vlan_idx = 0;                                                                         \
-        (p)->ts.tv_sec = 0;                                                                        \
-        (p)->ts.tv_usec = 0;                                                                       \
-        (p)->datalink = 0;                                                                         \
-        (p)->drop_reason = 0;                                                                      \
-        (p)->action = 0;                                                                           \
-        if ((p)->pktvar != NULL) {                                                                 \
-            PktVarFree((p)->pktvar);                                                               \
-            (p)->pktvar = NULL;                                                                    \
-        }                                                                                          \
-        (p)->ethh = NULL;                                                                          \
-        if ((p)->ip4h != NULL) {                                                                   \
-            CLEAR_IPV4_PACKET((p));                                                                \
-        }                                                                                          \
-        if ((p)->ip6h != NULL) {                                                                   \
-            CLEAR_IPV6_PACKET((p));                                                                \
-        }                                                                                          \
-        if ((p)->tcph != NULL) {                                                                   \
-            CLEAR_TCP_PACKET((p));                                                                 \
-        }                                                                                          \
-        if ((p)->udph != NULL) {                                                                   \
-            CLEAR_UDP_PACKET((p));                                                                 \
-        }                                                                                          \
-        if ((p)->sctph != NULL) {                                                                  \
-            CLEAR_SCTP_PACKET((p));                                                                \
-        }                                                                                          \
-        if ((p)->esph != NULL) {                                                                   \
-            CLEAR_ESP_PACKET((p));                                                                 \
-        }                                                                                          \
-        if ((p)->icmpv4h != NULL) {                                                                \
-            CLEAR_ICMPV4_PACKET((p));                                                              \
-        }                                                                                          \
-        if ((p)->icmpv6h != NULL) {                                                                \
-            CLEAR_ICMPV6_PACKET((p));                                                              \
-        }                                                                                          \
-        (p)->ppph = NULL;                                                                          \
-        (p)->pppoesh = NULL;                                                                       \
-        (p)->pppoedh = NULL;                                                                       \
-        (p)->greh = NULL;                                                                          \
-        (p)->payload = NULL;                                                                       \
-        (p)->payload_len = 0;                                                                      \
-        (p)->BypassPacketsFlow = NULL;                                                             \
-        (p)->pktlen = 0;                                                                           \
-        (p)->alerts.cnt = 0;                                                                       \
-        (p)->alerts.discarded = 0;                                                                 \
-        (p)->alerts.suppressed = 0;                                                                \
-        (p)->alerts.drop.action = 0;                                                               \
-        (p)->pcap_cnt = 0;                                                                         \
-        (p)->tunnel_rtv_cnt = 0;                                                                   \
-        (p)->tunnel_tpr_cnt = 0;                                                                   \
-        (p)->events.cnt = 0;                                                                       \
-        AppLayerDecoderEventsResetEvents((p)->app_layer_events);                                   \
-        (p)->next = NULL;                                                                          \
-        (p)->prev = NULL;                                                                          \
-        (p)->root = NULL;                                                                          \
-        (p)->livedev = NULL;                                                                       \
-        PACKET_RESET_CHECKSUMS((p));                                                               \
-        PACKET_PROFILING_RESET((p));                                                               \
-        p->tenant_id = 0;                                                                          \
-        p->nb_decoded_layers = 0;                                                                  \
-    } while (0)
-
-#define PACKET_RECYCLE(p) do { \
-        PACKET_RELEASE_REFS((p)); \
-        PACKET_REINIT((p)); \
-    } while (0)
-
-/**
- *  \brief Cleanup a packet so that we can free it. No memset needed..
- */
-#define PACKET_DESTRUCTOR(p)                                                                       \
-    do {                                                                                           \
-        PACKET_RELEASE_REFS((p));                                                                  \
-        if ((p)->pktvar != NULL) {                                                                 \
-            PktVarFree((p)->pktvar);                                                               \
-        }                                                                                          \
-        PacketAlertFree((p)->alerts.alerts);                                                       \
-        PACKET_FREE_EXTDATA((p));                                                                  \
-        SCMutexDestroy(&(p)->tunnel_mutex);                                                        \
-        AppLayerDecoderEventsFreeEvents(&(p)->app_layer_events);                                   \
-        PACKET_PROFILING_RESET((p));                                                               \
-    } while (0)
-
 /* macro's for setting the action
  * handle the case of a root packet
  * for tunnels */
index f5d0f89e0bd2311bc2dde2f8a9ad8a46de8bbcc4..beafe962f657f577f52627cffb7319d65bdf7620 100644 (file)
  */
 
 #include "suricata-common.h"
-#include "queue.h"
-#include "suricata.h"
-#include "conf.h"
-#include "util-debug.h"
-#include "util-misc.h"
 #include "defrag-config.h"
+#include "util-misc.h"
+#include "util-radix-tree.h"
 
 static SCRadixTree *defrag_tree = NULL;
 
index 08abd00b9c1652ecb99dd55da631350c0740537c..2a0fb4e96469478231560482c5259fb905ff1e8e 100644 (file)
@@ -25,6 +25,8 @@
 #ifndef DEFRAG_CONFIG_H_
 #define DEFRAG_CONFIG_H_
 
+#include "decode.h"
+
 void DefragSetDefaultTimeout(intmax_t timeout);
 void DefragPolicyLoadFromConfig(void);
 int DefragPolicyGetHostTimeout(Packet *p);
index 2307ef9710ed62efb659c042c021b75b2f1f4d97..ec4fbe6988581538616a127fd4dd530f7508dd8e 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "decode.h"
 #include "defrag.h"
+#include "util-exception-policy.h"
 
 /** Spinlocks or Mutex for the flow buckets. */
 //#define DRLOCK_SPIN
index 54dd84e7f213b63b3c698b5235f84088f7e7d207..b4e8ea237d32a7bb8ea093836173023a56c6ee96 100644 (file)
@@ -24,7 +24,6 @@
  */
 
 #include "suricata-common.h"
-#include "threads.h"
 #include "defrag-queue.h"
 #include "util-error.h"
 #include "util-debug.h"
index 63a58d0786450175aad8b103636d9234cb2978f5..4607770bdf45d9d5462e5dbc41e74da8485bf56b 100644 (file)
@@ -25,6 +25,7 @@
 #define __DEFRAG_QUEUE_H__
 
 #include "suricata-common.h"
+#include "decode.h"
 #include "defrag.h"
 
 /** Spinlocks or Mutex for the defrag tracker queues. */
index f9428e0fe913fe628ff4a2d1483199ff8dae7b35..25d1b6315cda681c0e16fab4f67d79fd877bc64e 100644 (file)
@@ -22,6 +22,7 @@
  */
 
 #include "suricata-common.h"
+#include "decode.h"
 #include "defrag.h"
 #include "defrag-hash.h"
 #include "defrag-timeout.h"
index a096ea58d8812b9920c9994617a2f8906df395f5..9920ed374067c74ef0898ec8ed663b1a6b5a52d4 100644 (file)
@@ -1081,6 +1081,7 @@ void DefragDestroy(void)
 }
 
 #ifdef UNITTESTS
+#include "util-unittest-helper.h"
 #define IP_MF 0x2000
 
 /**
@@ -1100,7 +1101,7 @@ static Packet *BuildTestPacket(uint8_t proto, uint16_t id, uint16_t off, int mf,
     if (unlikely(p == NULL))
         return NULL;
 
-    PACKET_INITIALIZE(p);
+    PacketInit(p);
 
     gettimeofday(&p->ts, NULL);
     //p->ip4h = (IPV4Hdr *)GET_PKT_DATA(p);
@@ -1170,7 +1171,7 @@ static Packet *IPV6BuildTestPacket(uint8_t proto, uint32_t id, uint16_t off,
     if (unlikely(p == NULL))
         return NULL;
 
-    PACKET_INITIALIZE(p);
+    PacketInit(p);
 
     gettimeofday(&p->ts, NULL);
 
index fe452dec32e93dc26bf70ddcfb77c0efe37a20ef..ac964823b84a91483b23aa2e07ef2e5aeef75508 100644 (file)
@@ -24,6 +24,7 @@
 #ifndef __DEFRAG_H__
 #define __DEFRAG_H__
 
+#include "threads.h"
 #include "util-pool.h"
 
 /**
index a43ccf0b8b6a39a3dfb9d28d2c35315b7a48db30..373a57d7e54e53a1dad94a781a3cf5350739c9af 100644 (file)
@@ -23,6 +23,8 @@
 
 #ifndef __DETECT_BYTE_H__
 #define __DETECT_BYTE_H__
+#include "detect.h"
+
 typedef uint8_t DetectByteIndexType;
 
 bool DetectByteRetrieveSMVar(const char *, const Signature *, DetectByteIndexType *);
index d3c7935e116b8a4dde8d3a02928d04cd87d09b13..f5229ab7bc2683859db35e1d8a0a22d58e05c27c 100644 (file)
@@ -1125,7 +1125,7 @@ end:
             DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx);
         DetectEngineCtxFree(de_ctx);
     }
-    PACKET_RECYCLE(p);
+    PacketRecycle(p);
     FlowShutdown();
 
     SCFree(p);
index 34b2764b8951e7c4ec248bcca52833d0000a0bee..d0071cd2b554b459f58bb24484638e9373224980 100644 (file)
@@ -898,7 +898,7 @@ static void DetectICMPV6CsumFree(DetectEngineCtx *de_ctx, void *ptr)
 /* ---------------------------------- Unit Tests --------------------------- */
 
 #ifdef UNITTESTS
-#include "detect-engine.h"
+#include "util-unittest-helper.h"
 
 #define mystr(s) #s
 #define TEST1(kwstr) {\
@@ -1055,7 +1055,7 @@ static int DetectCsumICMPV6Test01(void)
     DetectEngineCtxFree(de_ctx);
 
     StreamTcpFreeConfig(true);
-    PACKET_RECYCLE(p);
+    PacketRecycle(p);
     FlowShutdown();
     SCFree(p);
     PASS;
index 171566eded81d653a0e0b1df0ea35203e9e0325f..746f245c561225f6c6f43154dd4996565b913a31 100644 (file)
@@ -39,6 +39,7 @@
 #include "util-debug.h"
 #include "util-print.h"
 #include "util-misc.h"
+#include "util-path.h"
 
 #define PARSE_REGEX         "([a-z]+)(?:,\\s*([\\-_A-z0-9\\s\\.]+)){1,4}"
 static DetectParseRegex parse_regex;
index 45efc062b2aed07e64320b1820116a5fc7ca3854..aa0470c3db0e544a08e4ea34e61bac505307f486 100644 (file)
@@ -38,6 +38,8 @@
 #include "util-debug.h"
 #include "util-print.h"
 #include "util-misc.h"
+#include "util-path.h"
+#include "util-conf.h"
 
 int DetectDatasetMatch (ThreadVars *, DetectEngineThreadCtx *, Packet *,
         const Signature *, const SigMatchCtx *);
index 8702f99493142650196a2f9b032f85f613f2894b..b86140e5c489ade92c3343525a55d3f3f1479de2 100644 (file)
@@ -332,7 +332,7 @@ void SigParseApplyDsizeToContent(Signature *s)
  */
 
 #ifdef UNITTESTS
-#include "detect-engine.h"
+#include "util-unittest-helper.h"
 
 /**
  * \test this is a test for a valid dsize value 1
@@ -597,7 +597,7 @@ static int DetectDsizeIcmpv6Test01(void)
     DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx);
     DetectEngineCtxFree(de_ctx);
 
-    PACKET_RECYCLE(p);
+    PacketRecycle(p);
     FlowShutdown();
     SCFree(p);
 
index 8376286612a55589d5f7829b67931e3098b967a7..56a7a72f9d935fe61e1398dc4229ce46d47e9b0c 100644 (file)
@@ -40,6 +40,7 @@
 #include "util-print.h"
 #include "util-time.h"
 #include "util-validate.h"
+#include "util-conf.h"
 
 static int rule_warnings_only = 0;
 static FILE *rule_engine_analysis_FD = NULL;
index 4d92565577c9ef3949df0613d5c7f2b698bb1444..f9b95eb6cff9bf9bb25d4bec24b56c48ab56173e 100644 (file)
@@ -41,6 +41,7 @@
 #include "util-profiling.h"
 #include "util-validate.h"
 #include "util-var-name.h"
+#include "util-conf.h"
 
 void SigCleanSignatures(DetectEngineCtx *de_ctx)
 {
index f7db03ad4882b309d5dd17e54130d834f29460e4..9e1d39bd4df52323cca304adb33b4d41041610ec 100644 (file)
@@ -42,6 +42,7 @@
 
 #include "util-detect.h"
 #include "util-threshold-config.h"
+#include "util-path.h"
 
 #ifdef HAVE_GLOB_H
 #include <glob.h>
index 29d649b8f15790b072b6e4fe0cca11d4ff1a2646..8fc084539c11ac22bb06fca7224d2ef2ff3bbc01 100644 (file)
@@ -2186,7 +2186,7 @@ static int PortTestMatchReal(uint8_t *raw_eth_pkt, uint16_t pktsize, const char
     FlowInitConfig(FLOW_QUIET);
     Packet *p = UTHBuildPacketFromEth(raw_eth_pkt, pktsize);
     result = UTHPacketMatchSig(p, sig);
-    PACKET_RECYCLE(p);
+    PacketRecycle(p);
     FlowShutdown();
     return result;
 }
index 44344468aec1c14ea565e7babd06480fc085bdf9..2f38c8bdd15fd9e077dcf4d7495639b889d78f0c 100644 (file)
@@ -24,6 +24,7 @@
 #ifndef __DETECT_ENGINE_PREFILTER_H__
 #define __DETECT_ENGINE_PREFILTER_H__
 
+#include "detect.h"
 #include "detect-engine-state.h"
 
 // TODO
index 3fcc2a6b32f6b20e4b52c7766928b1cdefc89884..36cf6e106b0568fedec1e3e12e2d98c2da1d24ee 100644 (file)
  */
 
 #include "suricata-common.h"
-#include "suricata.h"
-#include "detect.h"
-#include "detect-parse.h"
-#include "detect-content.h"
-#include "output-json.h"
-#include "util-buffer.h"
-#include "util-print.h"
 #include "detect-engine-profile.h"
 
 #ifdef PROFILING
+#include "output-json.h"
+#include "util-conf.h"
+
 SCMutex g_rule_dump_write_m = SCMUTEX_INITIALIZER;
 
 void RulesDumpTxMatchArray(const DetectEngineThreadCtx *det_ctx, const SigGroupHead *sgh,
index cd5ec046175d29a32f4a98d7f4ab35f52e031620..2699a2435769cd4b5ea771c5fee2e417904424d6 100644 (file)
@@ -24,6 +24,8 @@
 #ifndef _DETECT_ENGINE_PROFILE_H
 #define        _DETECT_ENGINE_PROFILE_H
 
+#include "detect.h"
+
 void RulesDumpTxMatchArray(const DetectEngineThreadCtx *det_ctx, const SigGroupHead *sgh,
         const Packet *p, const uint64_t tx_id, const uint32_t rule_cnt,
         const uint32_t pkt_prefilter_cnt);
index cbb35ba684a09ce5ce7506141a9f48ed636aa8db..f2f6273d2c45a3dd37b42cbc2519c11838979513 100644 (file)
@@ -81,6 +81,7 @@
 #include "util-validate.h"
 #include "util-hash-string.h"
 #include "util-enum.h"
+#include "util-conf.h"
 
 #include "tm-threads.h"
 #include "runmodes.h"
index 11c8b692311b18ce2ecac962fbdb216efc6b0466..e953b03dbe8c8d52367f4f070ed46b6b850f427c 100644 (file)
@@ -49,6 +49,7 @@
 #include "util-profiling.h"
 
 #include "app-layer.h"
+#include "app-layer-htp.h"
 
 #include "stream-tcp.h"
 
index c7516f765261750cadd3a4dd38d5ac4ce238550d..1d0bea34cfdd7e6b104e047ce1b369104c902f31 100644 (file)
@@ -45,6 +45,7 @@
 #include "util-var-name.h"
 #include "util-unittest.h"
 #include "util-debug.h"
+#include "util-conf.h"
 
 #define PARSE_REGEX         "^([a-z]+)(?:,\\s*(.*))?"
 static DetectParseRegex parse_regex;
index 302f94e631943cb0e98739c065f788a7e081eb4d..623df8ceba03281e4936a2df96f4aa8f548f96ba 100644 (file)
@@ -385,6 +385,8 @@ static bool PrefilterFragBitsIsPrefilterable(const Signature *s)
  */
 
 #ifdef UNITTESTS
+#include "util-unittest-helper.h"
+
 /**
  * \test FragBitsTestParse01 is a test for a  valid fragbits value
  *
@@ -590,7 +592,7 @@ static int FragBitsTestParse04 (void)
     FAIL_IF(ret);
     SCFree(de);
     SCFree(sm);
-    PACKET_RECYCLE(p);
+    PacketRecycle(p);
     FlowShutdown();
     SCFree(p);
     PASS;
index ed7d42caae30c37c4346c6dcd168ebc9ac1793da..794de4099c591a4ca3e792204c62517739e33040 100644 (file)
@@ -327,8 +327,7 @@ static bool PrefilterFragOffsetIsPrefilterable(const Signature *s)
 }
 
 #ifdef UNITTESTS
-#include "detect-engine.h"
-#include "detect-engine-mpm.h"
+#include "util-unittest-helper.h"
 
 /**
  * \test DetectFragOffsetParseTest01 is a test for setting a valid fragoffset value
index d1f472718acf21abd5bf592a96727d976d175c52..f158a2c0e0f7a7d8de594af5f5017fe1f26583ac 100644 (file)
@@ -29,6 +29,8 @@
 #include "suricata-common.h"
 #include "flow.h"
 
+#include "app-layer-htp.h"
+
 #include "detect.h"
 #include "detect-parse.h"
 #include "detect-engine.h"
index bc208b0c84c1ca5d7be84013d8bc2eeed9304090..f25a9f1efaceeb2fe21cfdde32c29d8c1ffcaac5 100644 (file)
@@ -3603,7 +3603,7 @@ static int SigTestBidirec03 (void)
 
 end:
     if (p != NULL) {
-        PACKET_RECYCLE(p);
+        PacketRecycle(p);
         SCFree(p);
     }
     FlowShutdown();
@@ -3741,7 +3741,7 @@ static int SigTestBidirec04 (void)
     }
 
     if (p != NULL) {
-        PACKET_RECYCLE(p);
+        PacketRecycle(p);
     }
     FlowShutdown();
     DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx);
index 021dcbf4b8f968c35910c2d749b38bcc14a6329d..95b4514bbc75c6162ae2d4748e4bcb53b0c05b02 100644 (file)
@@ -24,6 +24,8 @@
 #ifndef __DETECT_PARSE_H__
 #define __DETECT_PARSE_H__
 
+#include "detect.h"
+
 /** Flags to indicate if the Signature parsing must be done
 *   switching the source and dest (for ip addresses and ports)
 *   or otherwise as normal */
index 4164a651a93fa2ad17d5053052604e02fa8dd894..06117058b34d37297482185ea17912c129c8c93a 100644 (file)
@@ -321,7 +321,7 @@ end:
     if (det_ctx != NULL)
         DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx);
     DetectEnginePruneFreeList();
-    PACKET_RECYCLE(p);
+    PacketRecycle(p);
     FlowShutdown();
     SCFree(p);
 
index 49fb59761df4e269ab3dfc835716928d07292abe..87ef61ff4401e8d5ff28e5c7c49faba0fd0575ef 100644 (file)
@@ -27,6 +27,7 @@
 #define __DEVICE_STORAGE_H__
 
 #include "util-device.h"
+#include "util-storage.h"
 
 typedef struct LiveDevStorageId_ {
     int id;
index 0cc27861261e7f0e307048b22808ebd9c6c3418f..8505d9c0f6adcfb50ddbede2db7fe434bb763b78 100644 (file)
  */
 
 #include "suricata-common.h"
-#include "suricata.h"
 #include "feature.h"
+#include "threads.h"
 
-#include "util-hash.h"
+#include "util-debug.h"
+#include "util-hashlist.h"
 
 typedef struct FeatureEntryType {
        const char *feature;
index 50acc0ddceca47c9a76e952b26bab68938a11018..4e2721583f24ebeafc3a670bcd8c7411332a1d17 100644 (file)
@@ -24,6 +24,9 @@
 #ifndef __FLOW_BYPASS_H__
 #define __FLOW_BYPASS_H__
 
+#include "threadvars.h"
+#include "flow.h"
+
 struct flows_stats {
     uint64_t count;
     uint64_t packets;
index cad46652b1b88818dcca9976a6a28a3c67b65996..20bd2d9013ebbca94f3d009c3a984a378663d9be 100644 (file)
@@ -24,6 +24,8 @@
 #ifndef __FLOW_HASH_H__
 #define __FLOW_HASH_H__
 
+#include "flow.h"
+
 /** Spinlocks or Mutex for the flow buckets. */
 //#define FBLOCK_SPIN
 #define FBLOCK_MUTEX
index f6111ab9bc2478eeb5f4088b93f17bba71c42595..f896f2311db9c5a21553111e4ea7000665aefc18 100644 (file)
@@ -27,6 +27,7 @@
 #define __FLOW_STORAGE_H__
 
 #include "flow.h"
+#include "util-storage.h"
 
 typedef struct FlowStorageId {
     int id;
index 919ab95ef326b1564c064333575f3c03dbd5250c..c2f858709f983d275ce9128295864576aa18d6bd 100644 (file)
@@ -24,6 +24,7 @@
 #ifndef __FLOW_UTIL_H__
 #define __FLOW_UTIL_H__
 
+#include "flow.h"
 #include "stream-tcp-private.h"
 
 #define COPY_TIMESTAMP(src,dst) ((dst)->tv_sec = (src)->tv_sec, (dst)->tv_usec = (src)->tv_usec)
index 236926613a5c35da13bf224bd9304a088c44f7ea..891dfdc00ee6b654ed43fcc73bdb2ad446b9873e 100644 (file)
@@ -29,6 +29,7 @@
 #include "util-print.h"
 #include "util-unittest.h"
 #include "util-time.h"
+#include "util-debug.h"
 
 /**
  *  \brief Creates a custom format node
index ebf43357820f8c2a731695c302fc20b534eb4ed2..e1d8d65c4c9216b603b1b2cd13cdbe9bfde117f7 100644 (file)
  */
 
 #include "suricata-common.h"
-#include "util-buffer.h"
-#include "util-fmemopen.h"
-#include "util-datalink.h"
-#include "stream-tcp-util.h"
-#include "stream.h"
-
 #ifdef HAVE_LIBLZ4
 #include <lz4frame.h>
+#include "util-fmemopen.h"
 #endif /* HAVE_LIBLZ4 */
 
 #if defined(HAVE_DIRENT_H) && defined(HAVE_FNMATCH_H)
 #include <fnmatch.h>
 #endif
 
-#include "detect.h"
-#include "flow.h"
-#include "conf.h"
+#include "log-pcap.h"
 
 #include "threads.h"
 #include "threadvars.h"
-#include "tm-threads.h"
+#include "decode.h"
+#include "stream.h"
+#include "stream-tcp-reassemble.h"
 
-#include "util-unittest.h"
-#include "log-pcap.h"
-#include "decode-ipv4.h"
+#include "output.h"
 
-#include "util-error.h"
-#include "util-debug.h"
-#include "util-time.h"
+#include "util-buffer.h"
 #include "util-byte.h"
-#include "util-misc.h"
+#include "util-conf.h"
 #include "util-cpu.h"
-#include "util-atomic.h"
-
-#include "source-pcap.h"
-
-#include "output.h"
-
-#include "queue.h"
+#include "util-datalink.h"
+#include "util-misc.h"
+#include "util-path.h"
+#include "util-profiling.h"
+#include "util-time.h"
 
 #define DEFAULT_LOG_FILENAME            "pcaplog"
 #define MODULE_NAME                     "PcapLog"
index 0901ee79c4bfaf34f4ed86c5123749b3adc657a6..56195a26d108cba48c7be9e1db94f2421e5c48a2 100644 (file)
  */
 
 #include "suricata-common.h"
-#include "detect.h"
-#include "pkt-var.h"
-#include "conf.h"
+#include "log-tcp-data.h"
 
-#include "threads.h"
 #include "threadvars.h"
-#include "tm-threads.h"
-
-#include "util-print.h"
-#include "util-unittest.h"
-
-#include "util-debug.h"
-
-#include "output.h"
-#include "log-tcp-data.h"
-#include "app-layer-htp.h"
-#include "app-layer.h"
-#include "app-layer-parser.h"
-#include "util-privs.h"
-#include "util-buffer.h"
 
+#include "util-conf.h"
 #include "util-logopenfile.h"
-#include "util-time.h"
+#include "util-path.h"
+#include "util-print.h"
 
 #define DEFAULT_LOG_FILENAME "tcp-data.log"
 
index d23f8e7d7bb2a93c65a7f74032f510b44fcc2ef8..608dbef3090a0faf428aa084c99037c0fa3c4022 100644 (file)
@@ -24,6 +24,9 @@
 #ifndef __LOG_TCPDATALOG_H__
 #define __LOG_TCPDATALOG_H__
 
+#include "conf.h"
+#include "output.h"
+
 void LogTcpDataLogRegister(void);
 OutputInitResult LogTcpDataLogInitCtx(ConfNode *);
 
index c9366471a47a54ac3f795d70a7837fba943c00d1..e743828e8a5042d45e60945bbf76fb16677a132c 100644 (file)
  */
 
 #include "suricata-common.h"
-#include "detect.h"
-#include "pkt-var.h"
-#include "conf.h"
-
-#include "threads.h"
-#include "threadvars.h"
-#include "tm-threads.h"
+#include "log-tlsstore.h"
 
-#include "util-print.h"
-#include "util-unittest.h"
+#include "decode.h"
 
-#include "util-debug.h"
+#include "app-layer-parser.h"
+#include "app-layer-ssl.h"
 
 #include "output.h"
 #include "log-tlslog.h"
-#include "log-tlsstore.h"
-#include "app-layer-ssl.h"
-#include "app-layer.h"
-#include "app-layer-parser.h"
-#include "util-privs.h"
-#include "util-buffer.h"
 
-#include "util-logopenfile.h"
+#include "util-conf.h"
+#include "util-path.h"
 #include "util-time.h"
 
 #define MODULE_NAME "LogTlsStoreLog"
index c6d176dfb899b99f75c15c9b75c372306981547f..317e1139a56ae7c0e11cf2cd3ace593b4ee8d2d4 100644 (file)
  */
 
 #include "suricata-common.h"
-#include "tm-modules.h"
 #include "output.h"
 #include "output-file.h"
+#if 0
 #include "app-layer.h"
-#include "app-layer-parser.h"
+#endif
+#include "app-layer-parser.h" // FileApplyTxFlags
 #include "detect-filemagic.h"
+#include "util-file.h"
+#include "util-magic.h"
 #include "util-profiling.h"
 #include "util-validate.h"
-#include "util-magic.h"
 
 bool g_file_logger_enabled = false;
 
index c9e428a0201f6e55e1308bd2b636f8665f669139..13735b282de0f6572d80b4c66806401147e87d15 100644 (file)
@@ -26,9 +26,7 @@
 #ifndef __OUTPUT_FILE_H__
 #define __OUTPUT_FILE_H__
 
-#include "decode.h"
 #include "rust.h"
-#include "util-file.h"
 
 /** per thread data for this module, contains a list of per thread
  *  data for the packet loggers. */
index 5adba43bc5849aeaa15de46549e494b864c2e8f4..cec89ec83dbb2529d112ba13bc7f769d60a4b549 100644 (file)
  */
 
 #include "suricata-common.h"
-#include "tm-modules.h"
 #include "output.h"
 #include "output-filedata.h"
-#include "app-layer.h"
 #include "app-layer-parser.h"
 #include "detect-filemagic.h"
 #include "conf.h"
 #include "util-profiling.h"
 #include "util-validate.h"
 #include "util-magic.h"
+#include "util-path.h"
 
 bool g_filedata_logger_enabled = false;
 
index 9359e0eb71c59778abfb3f3b027ad35753d9534b..6d2d5446645d5e309d9c9c47451a85481787d516 100644 (file)
@@ -26,9 +26,6 @@
 #ifndef __OUTPUT_FILEDATA_H__
 #define __OUTPUT_FILEDATA_H__
 
-#include "decode.h"
-#include "util-file.h"
-
 #define OUTPUT_FILEDATA_FLAG_OPEN  0x01
 #define OUTPUT_FILEDATA_FLAG_CLOSE 0x02
 
index 47ff0d7357560a23205563507aa53c1ec161be99..5a10344b78204314e98af45855ce67c9ff08bf6d 100644 (file)
  */
 
 #include "suricata-common.h"
+#include "output-filestore.h"
 
 #include "stream-tcp.h"
-#include "app-layer-parser.h"
-#include "app-layer-htp.h"
-#include "app-layer-htp-xff.h"
-#include "app-layer-smtp.h"
 
 #include "feature.h"
 
 #include "output.h"
-#include "output-filestore.h"
 #include "output-json-file.h"
 
-#include "util-print.h"
+#include "util-conf.h"
 #include "util-misc.h"
+#include "util-path.h"
+#include "util-print.h"
 
 #define MODULE_NAME "OutputFilestore"
 
index ebef951ad5bd872b737f56d7a9ce8b9b8ce1cf38..fa60f3c579b81757ce44d24c2d3b4eee8f9bd038 100644 (file)
@@ -24,7 +24,6 @@
  */
 
 #include "suricata-common.h"
-#include "tm-modules.h"
 #include "output.h"
 #include "output-flow.h"
 #include "util-profiling.h"
index ece4452c1ba8c06eee46c2ff7a1055fdb9e3b0ad..60295ea2be029a823b5f9c6c05832436bd0ce2cb 100644 (file)
  */
 
 #include "suricata-common.h"
-#include "pkt-var.h"
-#include "conf.h"
-
-#include "threads.h"
-#include "threadvars.h"
-#include "tm-threads.h"
-
-#include "util-unittest.h"
-#include "util-buffer.h"
-#include "util-debug.h"
-#include "util-byte.h"
-
 #include "output.h"
 #include "output-json.h"
-
-#include "app-layer.h"
-#include "app-layer-parser.h"
+#include "util-buffer.h"
 
 OutputJsonThreadCtx *CreateEveThreadCtx(ThreadVars *t, OutputJsonCtx *ctx)
 {
index 1265d6a0532648476f2006b918c07ae7bef97b1e..6ad9fe78d182c06f39634ad3f1cf8361914daee8 100644 (file)
  */
 
 #include "suricata-common.h"
-#include "pkt-var.h"
-#include "conf.h"
-
-#include "threads.h"
-#include "threadvars.h"
-#include "tm-threads.h"
-
-#include "util-unittest.h"
 #include "util-buffer.h"
-#include "util-debug.h"
-#include "util-byte.h"
-
 #include "output.h"
 #include "output-json.h"
-
-#include "app-layer.h"
 #include "app-layer-parser.h"
-#include "app-layer-dcerpc-common.h"
 #include "output-json-dcerpc.h"
-
 #include "rust.h"
 
 
index 0f8b60e4237a375861ec563d8ae2e52e88b657df..1ab6f5c7ee40e6578268fe06ae4dbfd9fea3510b 100644 (file)
  */
 
 #include "suricata-common.h"
-#include "pkt-var.h"
-#include "conf.h"
-
-#include "threads.h"
-#include "threadvars.h"
-#include "tm-threads.h"
-
-#include "util-unittest.h"
 #include "util-buffer.h"
-#include "util-debug.h"
-#include "util-byte.h"
-
 #include "output.h"
 #include "output-json.h"
-
-#include "app-layer.h"
 #include "app-layer-parser.h"
-
 #include "output-json-smb.h"
-
 #include "rust.h"
 
 bool EveSMBAddMetadata(const Flow *f, uint64_t tx_id, JsonBuilder *jb)
index 1f752d73cd6aa11525f8cc016e1b49258c5522b9..c6b09e53a09eff1f8fcea3eb137f64e113f75cf2 100644 (file)
  */
 
 #include "suricata-common.h"
-#include "pkt-var.h"
-#include "conf.h"
-
-#include "threads.h"
-#include "threadvars.h"
-#include "tm-threads.h"
+#include "output-lua.h"
 
+#ifdef HAVE_LUA
 #include "util-print.h"
 #include "util-unittest.h"
-
 #include "util-debug.h"
-
 #include "output.h"
 #include "app-layer-htp.h"
 #include "app-layer.h"
 #include "util-proto-name.h"
 #include "util-logopenfile.h"
 #include "util-time.h"
-
-#include "output-lua.h"
-
-#ifdef HAVE_LUA
-
-#include <lua.h>
-#include <lualib.h>
-#include <lauxlib.h>
-
 #include "util-lua.h"
 #include "util-lua-common.h"
 #include "util-lua-http.h"
index c7b509520d152002f7851954323ce7c0458ba291..232be2697e5a3a32b177bcddbe8800aa9fb02361 100644 (file)
@@ -24,7 +24,6 @@
  */
 
 #include "suricata-common.h"
-#include "tm-modules.h"
 #include "output.h"
 #include "output-packet.h"
 #include "util-profiling.h"
index 3953b9d939adfb955a560ef7a70740b0453ab161..adba556891225d3d305bd685bec61ab578df1017 100644 (file)
@@ -26,9 +26,6 @@
 #ifndef __OUTPUT_PACKET_H__
 #define __OUTPUT_PACKET_H__
 
-#include "decode.h"
-#include "tm-modules.h"
-
 /** packet logger function pointer type */
 typedef int (*PacketLogger)(ThreadVars *, void *thread_data, const Packet *);
 
index 7079c785ad71fb3394460216824b7dd89c322db5..839606f2bde92622c428ad63fbc1ffec5e4a3bfd 100644 (file)
  */
 
 #include "suricata-common.h"
-#include "tm-modules.h"
+#include "output.h"
 #include "output-stats.h"
 #include "util-validate.h"
 
-typedef struct OutputLoggerThreadStore_ {
-    void *thread_data;
-    struct OutputLoggerThreadStore_ *next;
-} OutputLoggerThreadStore;
-
 /** per thread data for this module, contains a list of per thread
  *  data for the packet loggers. */
 typedef struct OutputStatsLoggerThreadData_ {
index 60efef57910bd1f573ddee4ce1ed77a1856c2fd5..4aca9546d4a77885de1d3da0f00e5a5fc172454f 100644 (file)
@@ -24,7 +24,6 @@
  */
 
 #include "suricata-common.h"
-#include "tm-modules.h"
 #include "output.h"
 #include "output-streaming.h"
 #include "app-layer.h"
index 2e2d3a578d3349c91a1b46ec093d0d436b7d41af..00eb6d8b019492ab11c16cbbb82a9469d9fc4a88 100644 (file)
@@ -24,7 +24,6 @@
  */
 
 #include "suricata-common.h"
-#include "tm-modules.h"
 #include "output.h"
 #include "output-tx.h"
 #include "stream.h"
index ae2c6d90633e23a34ca1a131f2fff8e51b5585f4..8d58156bef8d0745245cd02422b7e80fb0cd3ca5 100644 (file)
@@ -27,6 +27,7 @@
 #define __OUTPUT_TX_H__
 
 #include "decode.h"
+#include "flow.h"
 
 /** tx logger function pointer type */
 typedef int (*TxLogger)(ThreadVars *, void *thread_data, const Packet *, Flow *f, void *state, void *tx, uint64_t tx_id);
index e7234ddfbcca803e3708b3e0792eac3094976667..5c2d7bc90e62905bc0fa02ca004efc337587bee0 100644 (file)
@@ -24,6 +24,9 @@
 #ifndef __OUTPUT_H__
 #define __OUTPUT_H__
 
+#include "decode.h"
+#include "tm-modules.h"
+
 #define DEFAULT_LOG_MODE_APPEND     "yes"
 #define DEFAULT_LOG_FILETYPE        "regular"
 
index c7070d3e51f7b1a8a070cc926e9f5b9b6938cc36..408987064380b7ba199410340ee17853933c6a31 100644 (file)
@@ -24,6 +24,8 @@
 #ifndef __PACKET_QUEUE_H__
 #define __PACKET_QUEUE_H__
 
+#include "threads.h"
+
 /** \brief simple fifo queue for packets
  *
  *  \note PacketQueueNoLock and PacketQueue need to keep identical
diff --git a/src/packet.c b/src/packet.c
new file mode 100644 (file)
index 0000000..b419b5d
--- /dev/null
@@ -0,0 +1,141 @@
+/* Copyright (C) 2007-2022 Open Information Security Foundation
+ *
+ * You can copy, redistribute or modify this Program under the terms of
+ * the GNU General Public License version 2 as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * version 2 along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#include "packet.h"
+#include "pkt-var.h"
+#include "flow.h"
+#include "host.h"
+#include "util-profiling.h"
+
+/**
+ *  \brief Initialize a packet structure for use.
+ */
+void PacketInit(Packet *p)
+{
+    SCMutexInit(&p->tunnel_mutex, NULL);
+    p->alerts.alerts = PacketAlertCreate();
+    PACKET_RESET_CHECKSUMS(p);
+    p->livedev = NULL;
+}
+
+void PacketReleaseRefs(Packet *p)
+{
+    FlowDeReference(&p->flow);
+    HostDeReference(&p->host_src);
+    HostDeReference(&p->host_dst);
+}
+
+/**
+ *  \brief Recycle a packet structure for reuse.
+ */
+void PacketReinit(Packet *p)
+{
+    CLEAR_ADDR(&p->src);
+    CLEAR_ADDR(&p->dst);
+    p->sp = 0;
+    p->dp = 0;
+    p->proto = 0;
+    p->recursion_level = 0;
+    PACKET_FREE_EXTDATA(p);
+    p->flags = p->flags & PKT_ALLOC;
+    p->flowflags = 0;
+    p->pkt_src = 0;
+    p->vlan_id[0] = 0;
+    p->vlan_id[1] = 0;
+    p->vlan_idx = 0;
+    p->ts.tv_sec = 0;
+    p->ts.tv_usec = 0;
+    p->datalink = 0;
+    p->drop_reason = 0;
+    PACKET_SET_ACTION(p, 0);
+    if (p->pktvar != NULL) {
+        PktVarFree(p->pktvar);
+        p->pktvar = NULL;
+    }
+    p->ethh = NULL;
+    if (p->ip4h != NULL) {
+        CLEAR_IPV4_PACKET(p);
+    }
+    if (p->ip6h != NULL) {
+        CLEAR_IPV6_PACKET(p);
+    }
+    if (p->tcph != NULL) {
+        CLEAR_TCP_PACKET(p);
+    }
+    if (p->udph != NULL) {
+        CLEAR_UDP_PACKET(p);
+    }
+    if (p->sctph != NULL) {
+        CLEAR_SCTP_PACKET(p);
+    }
+    if (p->esph != NULL) {
+        CLEAR_ESP_PACKET(p);
+    }
+    if (p->icmpv4h != NULL) {
+        CLEAR_ICMPV4_PACKET(p);
+    }
+    if (p->icmpv6h != NULL) {
+        CLEAR_ICMPV6_PACKET(p);
+    }
+    p->ppph = NULL;
+    p->pppoesh = NULL;
+    p->pppoedh = NULL;
+    p->greh = NULL;
+    p->payload = NULL;
+    p->payload_len = 0;
+    p->BypassPacketsFlow = NULL;
+    RESET_PKT_LEN(p);
+    p->alerts.cnt = 0;
+    p->alerts.discarded = 0;
+    p->alerts.suppressed = 0;
+    p->alerts.drop.action = 0;
+    p->pcap_cnt = 0;
+    p->tunnel_rtv_cnt = 0;
+    p->tunnel_tpr_cnt = 0;
+    p->events.cnt = 0;
+    AppLayerDecoderEventsResetEvents(p->app_layer_events);
+    p->next = NULL;
+    p->prev = NULL;
+    p->root = NULL;
+    p->livedev = NULL;
+    PACKET_RESET_CHECKSUMS(p);
+    PACKET_PROFILING_RESET(p);
+    p->tenant_id = 0;
+    p->nb_decoded_layers = 0;
+}
+
+void PacketRecycle(Packet *p)
+{
+    PacketReleaseRefs(p);
+    PacketReinit(p);
+}
+
+/**
+ *  \brief Cleanup a packet so that we can free it. No memset needed..
+ */
+void PacketDestructor(Packet *p)
+{
+    PacketReleaseRefs(p);
+    if (p->pktvar != NULL) {
+        PktVarFree(p->pktvar);
+    }
+    PacketAlertFree(p->alerts.alerts);
+    PACKET_FREE_EXTDATA(p);
+    SCMutexDestroy(&p->tunnel_mutex);
+    AppLayerDecoderEventsFreeEvents(&p->app_layer_events);
+    PACKET_PROFILING_RESET(p);
+}
diff --git a/src/packet.h b/src/packet.h
new file mode 100644 (file)
index 0000000..fa7e8ce
--- /dev/null
@@ -0,0 +1,29 @@
+/* Copyright (C) 2007-2022 Open Information Security Foundation
+ *
+ * You can copy, redistribute or modify this Program under the terms of
+ * the GNU General Public License version 2 as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * version 2 along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#ifndef __PACKET_H__
+#define __PACKET_H__
+
+#include "decode.h"
+
+void PacketInit(Packet *p);
+void PacketReleaseRefs(Packet *p);
+void PacketReinit(Packet *p);
+void PacketRecycle(Packet *p);
+void PacketDestructor(Packet *p);
+
+#endif
index 101f580ae760a45bb20979f481aacdb0b0a3ea9c..18c5c157417242f33d4efdeaee108a7ccf4cb163 100644 (file)
  */
 
 #include "suricata-common.h"
-#include "util-error.h"
-#include "util-debug.h"
+#include "reputation.h"
+#include "threads.h"
+#include "conf.h"
+
 #include "util-byte.h"
+#include "util-debug.h"
+#include "util-error.h"
 #include "util-ip.h"
-#include "util-radix-tree.h"
-#include "util-unittest.h"
-#include "threads.h"
+#include "util-path.h"
 #include "util-print.h"
-#include "host.h"
-#include "conf.h"
-#include "detect.h"
-#include "reputation.h"
+#include "util-unittest.h"
 #include "util-validate.h"
 
 /** effective reputation version, atomic as the host
index 52c0756e80f769df227632e1d453d45c5fc09549..8c8369dd7477dcd6cdff510e5924f547eb80710e 100644 (file)
@@ -27,6 +27,7 @@
 #define __REPUTATION_H__
 
 #include "host.h"
+#include "util-radix-tree.h"
 
 #define SREP_MAX_CATS 60
 #define SREP_MAX_VAL 127
@@ -41,6 +42,8 @@ typedef struct SReputation_ {
     uint8_t rep[SREP_MAX_CATS];
 } SReputation;
 
+#include "detect.h"
+
 void SRepFreeHostData(Host *h);
 uint8_t SRepCatGetByShortname(char *shortname);
 int SRepInit(struct DetectEngineCtx_ *de_ctx);
index ac0b570a9b6b0dc48b04a8fb01a9e66ea7516ac9..f2500d3d3b0cb0934fc8245c340ee714fdc5249b 100644 (file)
@@ -44,6 +44,7 @@
 
 #include "flow-bypass.h"
 
+#include "util-conf.h"
 #include "util-debug.h"
 #include "util-time.h"
 #include "util-cpu.h"
index 170679ae32294a708768aec785d381b2412c200a..7b8d2341d54ebe91a01c363f0a260b88eb41e18d 100644 (file)
 #include "suricata-common.h"
 #include "runmodes.h"
 #include "runmode-dpdk.h"
+#include "decode.h"
 #include "source-dpdk.h"
 #include "util-runmodes.h"
 #include "util-byte.h"
 #include "util-cpu.h"
+#include "util-debug.h"
+#include "util-device.h"
 #include "util-dpdk.h"
 #include "util-dpdk-i40e.h"
 #include "util-dpdk-ice.h"
index 709ac0ffd90cff8cd6963b5fbc067f76377fe956..f5f66fe998d89240d43e61ed9dfc8932ef8c12d8 100644 (file)
@@ -32,6 +32,7 @@
  */
 
 #include "suricata-common.h"
+#include "decode.h"
 #include "runmodes.h"
 #include "runmode-netmap.h"
 #include "util-runmodes.h"
@@ -45,6 +46,7 @@
 #endif /* HAVE_NETMAP */
 
 #include "source-netmap.h"
+#include "util-conf.h"
 
 extern int max_pending_packets;
 
index de451a78fa74dc91849efd015ebb7408bb2c7e2a..942277e36ed6e5667e1b893c0c92cc274c3d7784 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2007-2012 Open Information Security Foundation
+/* Copyright (C) 2007-2022 Open Information Security Foundation
  *
  * You can copy, redistribute or modify this Program under the terms of
  * the GNU General Public License version 2 as published by the Free
  */
 
 #include "suricata-common.h"
-#include "tm-threads.h"
-#include "conf.h"
-#include "runmodes.h"
 #include "runmode-pcap.h"
+#include "runmodes.h"
 #include "output.h"
-#include "log-httplog.h"
 
+#include "util-conf.h"
 #include "util-debug.h"
 #include "util-time.h"
 #include "util-cpu.h"
-#include "util-affinity.h"
 #include "util-device.h"
 #include "util-runmodes.h"
-#include "util-atomic.h"
 #include "util-misc.h"
 #include "util-byte.h"
 
index 528d850760f0d988a5f662189299bc65ce7ec37d..95a837783a521d3b578323ea9d2f5254a4aacbf9 100644 (file)
  */
 
 #include "suricata-common.h"
+#include "runmode-pfring.h"
 #include "tm-threads.h"
 #include "conf.h"
 #include "runmodes.h"
-#include "runmode-pfring.h"
 #include "source-pfring.h"
-#include "output.h"
 
 #include "util-debug.h"
 #include "util-time.h"
 #include "util-cpu.h"
-#include "util-affinity.h"
 #include "util-runmodes.h"
 #include "util-device.h"
 #include "util-ioctl.h"
 #include "util-byte.h"
+#include "util-conf.h"
 
 #ifdef HAVE_PFRING
 #include <pfring.h>
index 42058329e78b57ee9dffb0180e6d796be9d21093..5d4655bfec0b73985dad1bb6eff9c5540a7793bc 100644 (file)
  */
 
 #include "suricata-common.h"
-#include "util-unittest.h"
 #include "runmode-unittests.h"
+#include "util-unittest.h"
 
+#include "util-debug.h"
 #ifdef UNITTESTS
-
 #include "detect-parse.h"
 #include "detect-engine.h"
 #include "detect-engine-address.h"
index 785175e632c015fec5f824ab26df6cb0235b408d..750d69ce0c7586b13149f48a43979d012badf507 100644 (file)
 #ifndef __RUST_CONTEXT_H__
 #define __RUST_CONTEXT_H__
 
+#include "flow.h"
+#include "detect.h"
 #include "detect-engine-state.h" //DetectEngineState
+
 #include "app-layer-krb5.h" //KRB5State, KRB5Transaction
 #include "app-layer-ike.h"  //IKEState, IKETransaction
 #include "app-layer-ntp.h" //NTPState, NTPTransaction
 #include "app-layer-snmp.h" //SNMPState, SNMPTransaction
 #include "app-layer-tftp.h" //TFTPState, TFTPTransaction
 
+#include "util-debug.h"
+#include "util-file.h"
+
 // hack for include orders cf SCSha256
 typedef struct HttpRangeContainerBlock HttpRangeContainerBlock;
 
index a01e6e602b518c71b6f196e98bdf229ef819b48e..39f94c4321fa449a25533469b8dc829e498378e3 100644 (file)
@@ -18,7 +18,9 @@
 #ifndef __RUST_H__
 #define __RUST_H__
 
-#include "util-lua.h"
+#include "app-layer-events.h"
+#include "util-file.h"
+
 // hack for include orders cf SCSha256
 typedef struct HttpRangeContainerBlock HttpRangeContainerBlock;
 #include "rust-context.h"
index c22c68b3fc60ee13c836e4f9ce87e5e5fe3c9b91..97b938d7e06b11438058619bc3c134f4167f10e4 100644 (file)
@@ -32,6 +32,7 @@
 
 #include "suricata-common.h"
 #include "runmodes.h"
+#include "decode.h"
 #include "source-dpdk.h"
 #include "suricata.h"
 #include "threads.h"
index b20b7fc6097e8648ac8cecc1a64a5a62c58f61f9..a17111ce4ddd93f8c5dffb106fad5b98d34a237f 100644 (file)
@@ -24,6 +24,8 @@
 #ifndef __SOURCE_DPDK_H__
 #define __SOURCE_DPDK_H__
 
+#include "suricata-common.h"
+
 #ifdef HAVE_DPDK
 #include <rte_ethdev.h>
 #endif
index 39863aa2512990e3c88d0996ee2e3633ba6b9738..6ac232b6dde9dcfe577b58f29e0787141cf5ccef 100644 (file)
@@ -26,6 +26,7 @@
  *
  */
 #include "suricata-common.h"
+#include "decode.h"
 #include "suricata.h"
 #include "threadvars.h"
 #include "util-datalink.h"
index 36374c5566a6072bd83ca2c9fa32cb65b089c712..9bdb90f34e892a94374a4f8c7e5f81221678eace 100644 (file)
@@ -24,6 +24,7 @@
  */
 
 #include "suricata-common.h"
+#include "decode.h"
 #include "stream-tcp-private.h"
 #include "stream-tcp-inline.h"
 
index ce7cf16bcb05474be06801ca41e4e53959033ed4..11bdd63851f59e5557655649a9ee9a4742001384 100644 (file)
 #ifndef __STREAM_TCP_REASSEMBLE_H__
 #define __STREAM_TCP_REASSEMBLE_H__
 
-#include "stream-tcp-private.h"
-#include "stream-tcp-private.h"
-
-#ifdef UNITTESTS
 #include "suricata.h"
-#endif
+#include "flow.h"
+#include "stream-tcp-private.h"
 
 /** Supported OS list and default OS policy is BSD */
 enum
index 53f1f6e0cc2414b015f56d48d441cb8572cfdd9e..51ae39daf283def2ec307b3ca176da0cd43275a0 100644 (file)
@@ -24,6 +24,7 @@
 #ifndef __STREAM_H__
 #define __STREAM_H__
 
+#include "decode.h"
 #include "stream-tcp-private.h"
 
 #define STREAM_FLAGS_FOR_PACKET(p) PKT_IS_TOSERVER((p)) ? STREAM_TOSERVER : STREAM_TOCLIENT
index 1e0b8698d0320785d8118ae02d46a46a2a8fb428..ded159adc58d0832f6ca468a3d43306e90ab9b9a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2007-2010 Open Information Security Foundation
+/* Copyright (C) 2007-2022 Open Information Security Foundation
  *
  * You can copy, redistribute or modify this Program under the terms of
  * the GNU General Public License version 2 as published by the Free
@@ -499,20 +499,30 @@ typedef enum {
     LOGGER_SIZE,
 } LoggerId;
 
-#include "util-optimize.h"
-#ifndef SURICATA_PLUGIN
-#include <htp/htp.h>
+#ifndef HAVE_LUA
+
+/* If we don't have Lua, create a typedef for lua_State so the
+ * exported Lua functions don't fail the build. */
+typedef void lua_State;
+
+#else
+
+#include <lua.h>
+#include <lualib.h>
+#include <lauxlib.h>
+
 #endif
-#include "threads.h"
+
 #include "tm-threads-common.h"
-#include "util-debug.h"
-#include "util-error.h"
+#include "util-optimize.h"
 #include "util-mem.h"
-#ifndef SURICATA_PLUGIN
-#include "detect-engine-alert.h"
-#endif
-#include "util-path.h"
-#include "util-conf.h"
+#include "util-memcmp.h"
+#include "util-atomic.h"
+#include "util-unittest.h"
+
+// pseudo system headers
+#include "queue.h"
+#include "tree.h"
 
 #ifndef HAVE_STRLCAT
 size_t strlcat(char *, const char *src, size_t siz);
@@ -542,4 +552,3 @@ extern int g_ut_covered;
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
 
 #endif /* __SURICATA_COMMON_H__ */
-
index 63dfd572da978dbf5ded31fd01cb4dc801d791de..81c2e6802d7e3bfea8c7e3ac83c8d0531fd19ae9 100644 (file)
 #endif
 
 #include "suricata.h"
-#include "decode.h"
-#include "feature.h"
-#include "detect.h"
-#include "packet-queue.h"
-#include "threads.h"
-#include "threadvars.h"
-#include "flow-worker.h"
 
-#include "util-atomic.h"
-#include "util-spm.h"
-#include "util-cpu.h"
-#include "util-action.h"
-#include "util-pidfile.h"
-#include "util-ioctl.h"
-#include "util-device.h"
-#include "util-misc.h"
-#include "util-macset.h"
-#include "util-running-modes.h"
+#include "conf.h"
+#include "conf-yaml-loader.h"
 
-#include "detect-engine.h"
+#include "decode.h"
+#include "defrag.h"
+#include "flow.h"
+#include "stream-tcp.h"
+#include "ippair.h"
+
+#include "detect.h"
 #include "detect-parse.h"
-#include "detect-fast-pattern.h"
-#include "detect-engine-tag.h"
-#include "detect-engine-threshold.h"
+#include "detect-engine.h"
 #include "detect-engine-address.h"
+#include "detect-engine-alert.h"
 #include "detect-engine-port.h"
-#include "detect-engine-mpm.h"
+#include "detect-engine-tag.h"
+#include "detect-engine-threshold.h"
+#include "detect-fast-pattern.h"
 
-#include "tm-queuehandlers.h"
-#include "tm-queues.h"
-#include "tm-threads.h"
+#include "datasets.h"
 
-#include "tmqh-flow.h"
+#include "feature.h"
 
-#include "conf.h"
-#include "conf-yaml-loader.h"
+#include "flow-bypass.h"
+#include "flow-manager.h"
+#include "flow-timeout.h"
+#include "flow-worker.h"
+
+#include "flow-bit.h"
+#include "host-bit.h"
+#include "ippair-bit.h"
 
+#include "app-layer.h"
+#include "app-layer-parser.h"
+#include "app-layer-htp.h"
 #include "app-layer-htp-range.h"
-#include "datasets.h"
 
-#include "stream-tcp.h"
+#include "output.h"
+#include "output-filestore.h"
+
+#include "respond-reject.h"
+
+#include "runmode-af-packet.h"
+#include "runmode-netmap.h"
+#include "runmode-unittests.h"
 
 #include "source-nfq.h"
 #include "source-nfq-prototypes.h"
-
 #include "source-nflog.h"
-
 #include "source-ipfw.h"
-
 #include "source-pcap.h"
 #include "source-pcap-file.h"
 #include "source-pcap-file-helper.h"
-
 #include "source-pfring.h"
-
 #include "source-erf-file.h"
 #include "source-erf-dag.h"
 #include "source-napatech.h"
-
 #include "source-af-packet.h"
 #include "source-netmap.h"
-
 #include "source-dpdk.h"
-
 #include "source-windivert.h"
 #include "source-windivert-prototypes.h"
 
-#include "respond-reject.h"
-
-#include "flow.h"
-#include "flow-timeout.h"
-#include "flow-manager.h"
-#include "flow-bypass.h"
-#include "flow-var.h"
-#include "flow-bit.h"
-#include "pkt-var.h"
-#include "host-bit.h"
-
-#include "ippair.h"
-#include "ippair-bit.h"
-
-#include "host.h"
 #include "unix-manager.h"
 
-#include "app-layer.h"
-#include "app-layer-parser.h"
-#include "app-layer-register.h"
-#include "app-layer-htp.h"
-#include "app-layer-ssl.h"
-#include "app-layer-ssh.h"
-#include "app-layer-ftp.h"
-#include "app-layer-smtp.h"
-#include "app-layer-enip.h"
-#include "app-layer-dnp3.h"
-#include "app-layer-smb.h"
-#include "app-layer-htp-file.h"
-
-#include "output-filestore.h"
-
-#include "util-ebpf.h"
-#include "util-radix-tree.h"
-#include "util-host-os-info.h"
-#include "util-cidr.h"
-#include "util-unittest.h"
-#include "util-unittest-helper.h"
-#include "util-time.h"
-#include "util-rule-vars.h"
 #include "util-classification-config.h"
 #include "util-threshold-config.h"
 #include "util-reference-config.h"
-#include "util-profiling.h"
-#include "util-magic.h"
-#include "util-signal.h"
-
-#include "util-coredump-config.h"
-
-#include "util-decode-mime.h"
-
-#include "defrag.h"
 
-#include "runmodes.h"
-#include "runmode-unittests.h"
-#include "runmode-af-packet.h"
-#include "runmode-netmap.h"
+#include "tmqh-packetpool.h"
+#include "tm-queuehandlers.h"
 
-#include "util-debug.h"
-#include "util-error.h"
-#include "util-daemon.h"
 #include "util-byte.h"
-#include "util-luajit.h"
+#include "util-conf.h"
+#include "util-coredump-config.h"
+#include "util-cpu.h"
+#include "util-daemon.h"
+#include "util-device.h"
+#include "util-dpdk.h"
+#include "util-ebpf.h"
+#include "util-host-os-info.h"
+#include "util-ioctl.h"
 #include "util-landlock.h"
-
-#include "reputation.h"
-
-#include "output.h"
-
-#include "util-privs.h"
-
-#include "tmqh-packetpool.h"
-
-#include "util-proto-name.h"
+#include "util-luajit.h"
+#include "util-macset.h"
+#include "util-misc.h"
 #include "util-mpm-hs.h"
-#include "util-storage.h"
-#include "host-storage.h"
-
-#include "util-lua.h"
-
+#include "util-pidfile.h"
 #include "util-plugin.h"
-
-#include "util-dpdk.h"
-#include "util-exception-policy.h"
-
-#include "rust.h"
+#include "util-privs.h"
+#include "util-profiling.h"
+#include "util-proto-name.h"
+#include "util-running-modes.h"
+#include "util-signal.h"
+#include "util-time.h"
 
 /*
  * we put this here, because we only use it here in main.
index d8052ecd7a0b1c80160260d543e51598eba3dafd..fc9e5a553039bd5269c752e2138bdc33f1e32b5b 100644 (file)
@@ -16,9 +16,8 @@
  * 02110-1301, USA.
  */
 
-#include "../detect-engine.h"
 #include "../util-unittest.h"
-#include "../detect-engine-build.h"
+#include "../util-unittest-helper.h"
 
 /**
  * \test DetectTtlParseTest01 is a test for setting up an valid ttl value.
index 30d653fa9e77903f0258bc107ac72e589843efb0..16bf078c4cb3a30394c62ef44b32bdd1b3d121d1 100644 (file)
@@ -3396,7 +3396,7 @@ static int SigTest36ContentAndIsdataatKeywords01 (void)
 
     DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx);
     DetectEngineCtxFree(de_ctx);
-    PACKET_RECYCLE(p);
+    PacketRecycle(p);
     FlowShutdown();
 
     SCFree(p);
@@ -3418,7 +3418,7 @@ end:
              DetectEngineCtxFree(de_ctx);
 
     if (p != NULL)
-        PACKET_RECYCLE(p);
+        PacketRecycle(p);
 
     FlowShutdown();
 
@@ -3521,7 +3521,7 @@ static int SigTest37ContentAndIsdataatKeywords02 (void)
     DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx);
     DetectEngineCtxFree(de_ctx);
 
-    PACKET_RECYCLE(p);
+    PacketRecycle(p);
     FlowShutdown();
 
     SCFree(p);
@@ -3541,7 +3541,7 @@ end:
         DetectEngineCtxFree(de_ctx);
 
     if (p != NULL)
-        PACKET_RECYCLE(p);
+        PacketRecycle(p);
 
     FlowShutdown();
 
@@ -4289,19 +4289,19 @@ end:
         DetectEngineCtxFree(de_ctx);
 
     if (p1 != NULL) {
-        PACKET_RECYCLE(p1);
+        PacketRecycle(p1);
         SCFree(p1);
     }
     if (p2 != NULL) {
-        PACKET_RECYCLE(p2);
+        PacketRecycle(p2);
         SCFree(p2);
     }
     if (p3 != NULL) {
-        PACKET_RECYCLE(p3);
+        PacketRecycle(p3);
         SCFree(p3);
     }
     if (p4 != NULL) {
-        PACKET_RECYCLE(p4);
+        PacketRecycle(p4);
         SCFree(p4);
     }
     FlowShutdown();
index 6da5b78b1c4314ec713c89fc8e109df16075d511..3952c953a5682d842ea00821b7b39af77087a7ed 100644 (file)
@@ -12,6 +12,7 @@
 #include "util-unittest-helper.h"
 #include "util-byte.h"
 #include "conf-yaml-loader.h"
+#include "util-conf.h"
 
 #define HEADER_LEN 6
 
index 3bf60af573bf43ebecff3c93ea7d1d80d0aed39d..9685ea51060c7663db3f7bb76b44b7437b1eb8f9 100644 (file)
@@ -14,6 +14,7 @@
 #include "util-unittest-helper.h"
 #include "conf-yaml-loader.h"
 #include "util-time.h"
+#include "util-conf.h"
 
 int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
 
index 80dc3bb7e1e07d3eea24d3219bbe0482c7bbc1e9..58ce96cc5cdf6129c820103428dd011a55c10ee2 100644 (file)
@@ -26,6 +26,7 @@
 #include "flow-util.h"
 #include "tm-modules.h"
 #include "tmqh-packetpool.h"
+#include "util-conf.h"
 
 #include <fuzz_pcap.h>
 
@@ -138,7 +139,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
             }
         }
         r = FPC_next(&pkts, &header, &pkt);
-        PACKET_RECYCLE(p);
+        PacketRecycle(p);
         p->ts.tv_sec = header.ts.tv_sec;
         p->ts.tv_usec = header.ts.tv_usec % 1000000;
         p->datalink = pkts.datalink;
index 04f2be6a1f51563d88c68eca42107125214bee8f..2509849aad83dd304e188decdfb44adf634b0745 100644 (file)
@@ -27,6 +27,8 @@
 #include "flow-worker.h"
 #include "tm-modules.h"
 #include "tmqh-packetpool.h"
+#include "util-file.h"
+#include "util-conf.h"
 
 int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
 
@@ -180,7 +182,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
             }
         }
         r = pcap_next_ex(pkts, &header, &pkt);
-        PACKET_RECYCLE(p);
+        PacketRecycle(p);
         p->ts.tv_sec = header->ts.tv_sec;
         p->ts.tv_usec = header->ts.tv_usec % 1000000;
         p->datalink = pcap_datalink(pkts);
index 611dba1e2933154b5d995a48b9f88bea04583572..2f58060f18bf410439dad6ecec5cc441cc34fcd9 100644 (file)
@@ -27,6 +27,7 @@
 #include "flow-worker.h"
 #include "tm-modules.h"
 #include "tmqh-packetpool.h"
+#include "util-conf.h"
 
 #include <fuzz_pcap.h>
 
@@ -179,7 +180,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
             }
         }
         r = FPC_next(&pkts, &header, &pkt);
-        PACKET_RECYCLE(p);
+        PacketRecycle(p);
         p->pkt_src = PKT_SRC_WIRE;
         p->ts.tv_sec = header.ts.tv_sec;
         p->ts.tv_usec = header.ts.tv_usec % 1000000;
index 1d66997f7d3a6fac7606bb9d85512250d9abee37..6df3b4be67aa39d2fac42e2902f10b21c2fafac4 100644 (file)
 #ifndef __THREADS_PROFILE_H__
 #define __THREADS_PROFILE_H__
 
+#include "util-cpu.h"
+
+#define PROFILING_MAX_LOCKS 64
+
 /* profiling */
 
+enum {
+    LOCK_MUTEX,
+    LOCK_SPIN,
+    LOCK_RWW, /**< rwlock, writer */
+    LOCK_RWR, /**< rwlock, reader */
+};
+
 typedef struct ProfilingLock_ {
     char *file;
     char *func;
index c11c054bc8dba285746c9bc562941475a385f8f8..3f8f109aab45cabc77951f222720a2b18f30c85e 100644 (file)
 #include <unistd.h>
 #endif
 
-#ifdef PROFILING
-#include "util-cpu.h"
-#ifdef PROFILE_LOCKING
-#include "util-profiling-locks.h"
-#endif /* PROFILE_LOCKING */
-#endif /* PROFILING */
-
 #if defined OS_FREEBSD || __OpenBSD__
 
 #if ! defined __OpenBSD__
index f7a0a57d8470a8f2b2a09439704b971d1c189240..624930561177ff6cab26eb587162d759d4466392 100644 (file)
@@ -28,6 +28,7 @@
 #include "tmqh-packetpool.h"
 #include "tm-threads-common.h"
 #include "tm-modules.h"
+#include "flow.h" // for the FlowQueue
 
 #ifdef OS_WIN32
 static inline void SleepUsec(uint64_t usec)
index e512aa114ab89e6a16a8d2c0b3e4304ac03cf84b..5c78968e61f9d8cb0b10fb17a9b394c545d859df 100644 (file)
  * Packetpool queue handlers. Packet pool is implemented as a stack.
  */
 
-#include "suricata.h"
-#include "packet-queue.h"
-#include "decode.h"
-#include "detect.h"
-#include "detect-uricontent.h"
-#include "threads.h"
-#include "threadvars.h"
-#include "flow.h"
-#include "flow-util.h"
-#include "host.h"
-
-#include "stream.h"
-#include "stream-tcp-reassemble.h"
-
+#include "suricata-common.h"
+#include "tmqh-packetpool.h"
 #include "tm-queuehandlers.h"
 #include "tm-threads.h"
+#include "threads.h"
+#include "decode.h"
 #include "tm-modules.h"
-
-#include "pkt-var.h"
-
-#include "tmqh-packetpool.h"
-
-#include "util-debug.h"
-#include "util-error.h"
+#include "packet.h"
 #include "util-profiling.h"
-#include "util-device.h"
 #include "util-validate.h"
 
 /* Number of freed packet to save for one pool before freeing them. */
@@ -195,7 +178,7 @@ Packet *PacketPoolGetPacket(void)
         Packet *p = pool->head;
         pool->head = p->next;
         p->pool = pool;
-        PACKET_REINIT(p);
+        PacketReinit(p);
         return p;
     }
 
@@ -211,7 +194,7 @@ Packet *PacketPoolGetPacket(void)
         Packet *p = pool->head;
         pool->head = p->next;
         p->pool = pool;
-        PACKET_REINIT(p);
+        PacketReinit(p);
         return p;
     }
 
@@ -232,7 +215,7 @@ void PacketPoolReturnPacket(Packet *p)
         return;
     }
 
-    PACKET_RELEASE_REFS(p);
+    PacketReleaseRefs(p);
 
 #ifdef DEBUG_VALIDATION
     BUG_ON(pool->initialized == 0);
@@ -463,14 +446,14 @@ void TmqhOutputPacketpool(ThreadVars *t, Packet *p)
     if (proot == true) {
         SCLogDebug("getting rid of root pkt... alloc'd %s", p->root->flags & PKT_ALLOC ? "true" : "false");
 
-        PACKET_RELEASE_REFS(p->root);
+        PacketReleaseRefs(p->root);
         p->root->ReleasePacket(p->root);
         p->root = NULL;
     }
 
     PACKET_PROFILING_END(p);
 
-    PACKET_RELEASE_REFS(p);
+    PacketReleaseRefs(p);
     p->ReleasePacket(p);
 
     SCReturn;
index 0f0c846c88a50d87bbc714ba47c6da6cb5f3bc41..a377f5aa913b6259e5816b77b83ec6b6ce8afcd9 100644 (file)
@@ -22,8 +22,8 @@
  */
 
 #include "suricata-common.h"
-#include "suricata.h"
 #include "unix-manager.h"
+#include "threads.h"
 #include "detect-engine.h"
 #include "tm-threads.h"
 #include "runmodes.h"
 
 #include "output-json-stats.h"
 
+#include "util-conf.h"
 #include "util-privs.h"
 #include "util-debug.h"
 #include "util-device.h"
 #include "util-ebpf.h"
 #include "util-signal.h"
 #include "util-buffer.h"
+#include "util-path.h"
 
 #if (defined BUILD_UNIX_SOCKET) && (defined HAVE_SYS_UN_H) && (defined HAVE_SYS_STAT_H) && (defined HAVE_SYS_TYPES_H)
 #include <sys/un.h>
index 22f21923be1f216431ed1f33cde9010093cd8dcc..65857a65fd15896df9652fa5966be6a397744f4b 100644 (file)
@@ -24,6 +24,8 @@
 #ifndef UNIX_MANAGER_H
 #define UNIX_MANAGER_H
 
+#include "threads.h"
+
 #define UNIX_CMD_TAKE_ARGS 1
 
 extern SCCtrlCondT unix_manager_ctrl_cond;
index 2ad03e6a735271f983e5a088a0c5ca5446af533b..302ab2d9c5918b9d302aa1d1dd8a9862370f42e8 100644 (file)
 #include "suricata-common.h"
 #define _THREAD_AFFINITY
 #include "util-affinity.h"
-#include "util-cpu.h"
-#include "util-byte.h"
 #include "conf.h"
-#include "threads.h"
-#include "queue.h"
 #include "runmodes.h"
+#include "util-cpu.h"
+#include "util-byte.h"
+#include "util-debug.h"
 
 ThreadsAffinityType thread_affinity[MAX_CPU_SET] = {
     {
index de0ccb1586f305833136accb6ffc65f0c4e0354c..cce7cebe026babd33211bf0e61df2f3be63e5175 100644 (file)
@@ -25,6 +25,7 @@
 #define __UTIL_AFFINITY_H__
 #include "suricata-common.h"
 #include "conf.h"
+#include "threads.h"
 
 #if defined OS_FREEBSD
 #include <sched.h>
index 4ccbc1eb5a3df186ef871a99c167781616490da7..dc3de2a1ea78a1d03d2fb873902fee46dc70b84a 100644 (file)
@@ -23,6 +23,7 @@
  */
 
 #include "util-base64.h"
+#include "util-debug.h"
 #include "util-unittest.h"
 /* Constants */
 #define BASE64_TABLE_MAX  122
index 934aca9ad2d6e1eabc9eb260186140b758d54a7a..b57dd0f512c2d5a96361e5a38ea07c1ab5a165a3 100644 (file)
  * \author Eric Leblond <eric@regit.org>
  */
 
-
 #include "suricata-common.h"
-#include "suricata.h"
 #include "util-bpf.h"
+#include "threads.h"
 
 #if !defined __OpenBSD__
 
index 3580e85def340455d05ea06eae08744d87c9b352..5bbb5d48374848b702cc765c0cad55d64aa70698 100644 (file)
@@ -24,7 +24,6 @@
  */
 
 #include "suricata-common.h"
-
 #include "util-checksum.h"
 
 int ReCalculateChecksum(Packet *p)
index eb2767e9b4a9f79e568457088161777e89f64dd0..c7b056bdd88cfc5e14770cf689248ed32daa3bd4 100644 (file)
@@ -24,6 +24,8 @@
 #ifndef __UTIL_CHECKSUM_H__
 #define __UTIL_CHECKSUM_H__
 
+#include "decode.h"
+
 int ReCalculateChecksum(Packet *p);
 int ChecksumAutoModeCheck(uint64_t thread_count,
         uint64_t iface_count, uint64_t iface_fail);
index 92f1d708767ab8219276032805c02a6d4b5c26b7..de93a535e20646bff0ebe97d01f0b7c4e1a4d215 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "suricata-common.h"
 #include "util-cidr.h"
+#include "util-debug.h"
 #include "util-unittest.h"
 
 /** \brief turn 32 bit mask into CIDR
index 4abdeca7c840cc1ba6b7a03434f3274119a1bb62..9807db0cae4d0f444999901909d0786570961322 100644 (file)
@@ -27,6 +27,7 @@
 #include "conf.h"
 #include "runmodes.h"
 #include "util-conf.h"
+#include "util-debug.h"
 
 TmEcode ConfigSetLogDirectory(const char *name)
 {
index e5b14a75688a321f19143695c30b7b9877e13bda..ba00a9fca5f96e1fab570ef09d3e07c7242edac0 100644 (file)
  * Coredump configuration
  */
 
+#include "suricata-common.h"
 #define _FILE_OFFSET_BITS 64
 #include "util-coredump-config.h"
 #include "conf.h"
 #ifdef HAVE_SYS_RESOURCE_H
 #include <sys/resource.h>
 #endif
+#ifdef HAVE_SYS_PRCTL_H
+#include <sys/prctl.h>
+#endif
+#include "util-debug.h"
 
 #ifdef OS_WIN32
 
index f645ffb88f7056024003cca4fd4fe424b724ec20..ad34a2b3a759e5efc7f4154d09b7c4063f7b8c4e 100644 (file)
@@ -16,8 +16,8 @@
  */
 
 #include "suricata-common.h"
-#include "conf.h"
 #include "util-datalink.h"
+#include "decode.h"
 
 int g_datalink_value = LINKTYPE_NULL;
 int g_datalink_is_multiple = 0;
index cbf8d5426211f3d5805d31fe2d3a37a1e677168b..ee3d566d8d07cbea783aa6b145085b3e8d8e555a 100644 (file)
@@ -25,6 +25,8 @@
 
 #include "suricata-common.h"
 #include "util-debug-filters.h"
+#include "threads.h"
+#include "util-debug.h"
 
 /* both of these are defined in util-debug.c */
 extern int sc_log_module_initialized;
index 5c6764c7120743d787696ecb9915797a4c3d564b..a7994dccd0db032bb4a3e39b620e55afceefebda 100644 (file)
@@ -24,7 +24,7 @@
 #ifndef __DEBUG_FILTERS_H__
 #define __DEBUG_FILTERS_H__
 
-#include <pthread.h>
+#include "threads.h"
 
 /**
  * \brief Enum that holds the different kinds of filters available
index f2beabd6cbdddedd4a835e3e2ee10e907d51c953..eb533badb2075fdaf62fb695a4a620050362f10a 100644 (file)
  */
 
 #include "suricata-common.h"
-#include "threads.h"
 #include "util-debug.h"
-#include "util-error.h"
-#include "util-enum.h"
-#include "util-debug-filters.h"
-#include "suricata.h"
 
-#include "decode.h"
-#include "detect.h"
-#include "packet-queue.h"
-#include "threadvars.h"
 #include "output.h"
 
-#include "tm-queuehandlers.h"
-#include "tm-queues.h"
-#include "tm-threads.h"
+#include "suricata.h"
 
-#include "util-unittest.h"
+#include "util-conf.h"
+#include "util-enum.h"
+#include "util-path.h"
 #include "util-syslog.h"
 #include "util-time.h"
-#include "rust.h"
-
-
-#include "conf.h"
 
 /* holds the string-enum mapping for the enums held in the table SCLogLevel */
 SCEnumCharMap sc_log_level_map[ ] = {
index 1dd2ee4c144b7e25ff794b7bd4cd14e112d30134..c9eb26570ccf77af54f901efee7cb4960a0304a4 100644 (file)
@@ -24,7 +24,7 @@
  */
 
 #include "suricata-common.h"
-
+#include "suricata.h"
 #include "util-decode-mime.h"
 #include "util-ip.h"
 #include "util-spm-bs.h"
index 657a90b9d61b3b543f53d1ee6542228c6db9c5e2..0dde13ca049639d1c9cd968bf6aeba1956c8b39f 100644 (file)
 #ifndef MIME_DECODE_H_
 #define MIME_DECODE_H_
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h>
-
+#include "conf.h"
 #include "util-base64.h"
+#include "util-file.h"
 
 /* Content Flags */
 #define CTNT_IS_MSG           1
index 48920197d3a0375633cc64d9cc6e54efd5a68790..89988c748aed5846791733b35ae5cc9b5f3b25b2 100644 (file)
@@ -23,6 +23,7 @@
 #include "util-dpdk.h"
 
 #include "device-storage.h"
+#include "util-debug.h"
 
 #define MAX_DEVNAME 10
 
index 77baf0b93cb2b17bfe06c1a75a4d1734306381ec..ac5dd03a207bd0bda22a1749e76204fb8004c7a2 100644 (file)
@@ -31,6 +31,8 @@
  */
 
 #include "util-dpdk-i40e.h"
+#include "util-dpdk.h"
+#include "util-debug.h"
 
 #ifdef HAVE_DPDK
 
index 736361bd6cb1af3aba33cc82a5e707cd35d8c845..060f1635d4a92f843b22109e4b4016fde2837621 100644 (file)
@@ -31,6 +31,7 @@
  */
 
 #include "util-dpdk-ice.h"
+#include "util-dpdk.h"
 
 #ifdef HAVE_DPDK
 
index 539f657a07fa012fa6c8e6cf059108d257b222ca..e7fcdd08059a531a12ea7d650be7479abf2f122c 100644 (file)
@@ -31,6 +31,7 @@
  */
 
 #include "util-dpdk-ixgbe.h"
+#include "util-dpdk.h"
 
 #ifdef HAVE_DPDK
 
index ac9e3d8653746b750eb9e1291e7a2adf5e215283..29479c1a2b01f5f8f5f24f02128df5d09a5f934c 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "suricata.h"
 #include "util-dpdk.h"
+#include "util-debug.h"
 
 void DPDKCleanupEAL(void)
 {
index 0a3b78d9f7e63cfdfa3d3936c51f6c648df70b38..b10610ca0757ec65bc59e8af0bf5a095b049df78 100644 (file)
@@ -22,6 +22,8 @@
 #ifndef __UTIL_EXCEPTION_POLICY_H__
 #define __UTIL_EXCEPTION_POLICY_H__
 
+#include "decode.h"
+
 enum ExceptionPolicy {
     EXCEPTION_POLICY_IGNORE = 0,
     EXCEPTION_POLICY_PASS_PACKET,
index d5dfa93feee66e1631f233e0ccb5630b663304a0..5bd1a186064d3ac2206ec6daa80818e3ccd58443 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "conf.h"
 #include "util-streaming-buffer.h"
+#include "flow.h"
 
 /* Hack: Pulling rust.h to get the SCSha256 causes all sorts of problems with
  *   header include orders, which is something we'll have to resolve as we provide
index 17fec82e1f5c09221635adad68c929aeb78c571e..7153af800d3b383971b22918169f90a19611207d 100644 (file)
@@ -18,6 +18,8 @@
 #ifndef __UTIL_HASH_STRING_H__
 #define __UTIL_HASH_STRING_H__
 
+#include "util-hash.h"
+
 uint32_t StringHashDjb2(const uint8_t *data, uint32_t datalen);
 uint32_t StringHashFunc(HashTable *ht, void *data, uint16_t datalen);
 char StringHashCompareFunc(void *data1, uint16_t datalen1,
index 98765f5c3dd92fe4f63aac1c97526d952f80fc99..a2b72209ecf404a661db9f5b088e61db2ab89608 100644 (file)
@@ -30,6 +30,7 @@
 #include "util-hash.h"
 #include "util-unittest.h"
 #include "util-memcmp.h"
+#include "util-debug.h"
 
 HashTable* HashTableInit(uint32_t size, uint32_t (*Hash)(struct HashTable_ *, void *, uint16_t), char (*Compare)(void *, uint16_t, void *, uint16_t), void (*Free)(void *)) {
 
index 568e5e0640538bda48d2b69acb522ca95db514a1..eac28fe2123cc2500dc7e4123bfb6359591e93e8 100644 (file)
@@ -27,6 +27,7 @@
 #include "suricata-common.h"
 #include "util-host-info.h"
 #include "util-byte.h"
+#include "util-debug.h"
 
 #ifndef OS_WIN32
 #include <sys/utsname.h>
index e0f7009e329796a31c8255a278ae2c9e87a4907b..b415e255f4460b4442474ee41b415d38c0520721 100644 (file)
@@ -23,8 +23,9 @@
  */
 
 #include "suricata-common.h"
+#include "util-ioctl.h"
 #include "conf.h"
-#include "util-device.h"
+#include "decode.h"
 #include "decode-sll.h"
 
 #ifdef HAVE_SYS_IOCTL_H
@@ -49,8 +50,6 @@
 #include "win32-syscall.h"
 #endif
 
-#include "util-ioctl.h"
-
 /**
  * \brief output a majorant of hardware header length
  *
index aad49df0e18f29b71796f3476df627f2e6737003..36df15027decae3f10c6d38303bfca3f513b2858 100644 (file)
@@ -27,6 +27,7 @@
 #include "suricata-common.h"
 #include "util-ip.h"
 #include "util-byte.h"
+#include "util-debug.h"
 
 /** \brief determine if a string is a valid ipv4 address
  *  \retval bool is addr valid?
index b0fa2f087df9c1adaf01154f05cead782031d6c0..fa15a08e049e89863ac2a5f6a0c36f23d5ec80ba 100644 (file)
  */
 
 #include "suricata.h"
+#include "feature.h"
 #include "util-conf.h"
 #include "util-file.h"
 #include "util-landlock.h"
 #include "util-mem.h"
-#include "feature.h"
+#include "util-path.h"
 
 #ifndef HAVE_LINUX_LANDLOCK_H
 
index 6814b142ab8802924af7f19db6fa026719fe7d80..bfaf29a5a91701840bb634c4b470f2b9eddc4b11 100644 (file)
@@ -27,6 +27,7 @@
 #include "util-log-redis.h"
 #include "util-logopenfile.h"
 #include "util-byte.h"
+#include "util-debug.h"
 
 #ifdef HAVE_LIBHIREDIS
 
index d4616845865622a87688aa52a9b082ba75c56422..81da79b828330930c5c91ff68abb472814b41566 100644 (file)
@@ -30,6 +30,8 @@
 #include "conf.h"            /* ConfNode, etc. */
 #include "output.h"          /* DEFAULT_LOG_* */
 #include "util-byte.h"
+#include "util-conf.h"
+#include "util-path.h"
 #include "util-time.h"
 
 #if defined(HAVE_SYS_UN_H) && defined(HAVE_SYS_SOCKET_H) && defined(HAVE_SYS_TYPES_H)
index b3b89c69e1b8304ac0110f067d59e1ba485fc301..7f0d65ff0366264fad5301110351d5916385dfc2 100644 (file)
@@ -24,6 +24,7 @@
 #ifndef __UTIL_LOGOPENFILE_H__
 #define __UTIL_LOGOPENFILE_H__
 
+#include "threads.h"
 #include "conf.h"            /* ConfNode   */
 #include "util-buffer.h"
 
index 228aeffcdd4a6e578de567346a3481ce626c54e5..a014ae7bba4f62fd5a9f7c2d46099d9a6f0cca72 100644 (file)
@@ -46,6 +46,7 @@
 #include "util-proto-name.h"
 #include "util-logopenfile.h"
 #include "util-time.h"
+#include "util-conf.h"
 
 #ifdef HAVE_LUA
 
index 019f254ae91ee55c36c24df54e83fb2d77c1e186..4de94005446fca9f4b35275c8fcaa41e9bca8c80 100644 (file)
 typedef void lua_State;
 
 #else
-
-#include <lua.h>
-#include <lualib.h>
-#include <lauxlib.h>
-
+#include "threadvars.h"
+#include "detect.h"
 
 typedef struct LuaStreamingBuffer_ {
     const uint8_t *data;
index 20ba08bb8807746488d95d4a2c8d3d646e8762aa..941c98f56c6a802402e8a498df87062aaec0c498 100644 (file)
  */
 
 #include "suricata-common.h"
-
 #include "conf.h"
-
 #include "util-unittest.h"
 #include "util-magic.h"
+#include "util-debug.h"
 
 #ifdef HAVE_MAGIC
 
index 2cf008e7095232cb16f7409d69fa7ec2c80906be..551d05b78ef43a6f84de577e857407f00642a507 100644 (file)
@@ -18,6 +18,7 @@
 #include "suricata-common.h"
 #include "suricata.h"
 #include "util-atomic.h"
+#include "util-debug.h"
 
 #if defined(_WIN32) || defined(__WIN32)
 #include <mm_malloc.h>
index 4342ac1f6cf04b98ea7a11d66eb0f5a8b0c14dd0..bf3d8e56b341d998cf37d4bea5b04bd84c9d417d 100644 (file)
@@ -24,7 +24,6 @@
  */
 
 #include "suricata-common.h"
-
 #include "util-memcmp.h"
 #include "util-unittest.h"
 
@@ -32,6 +31,7 @@
 
 /* UNITTESTS */
 #ifdef UNITTESTS
+#include "util-debug.h"
 
 static int MemcmpTest01 (void)
 {
@@ -372,7 +372,6 @@ static int MemcmpTest18 (void)
 
         if (SCMemcmpLowercase(t->a, t->b, strlen(t->a)-1) != t->result)
             return 0;
-        SCLogInfo("ok");
         t++;
     }
 
index 1ab636abae2e22f11003118fd06e96c0053a9b15..bb6df864966b7ad960ce2084dcea9746ea0c9237 100644 (file)
@@ -30,7 +30,6 @@
 #define __UTIL_MEMCMP_H__
 
 #include "util-optimize.h"
-#include "suricata.h"
 
 /** \brief compare two patterns, converting the 2nd to lowercase
  *  \warning *ONLY* the 2nd pattern is converted to lowercase
index a9dbd6a090c905f76689dff149d7a235c462a555..46d0238fed43aaed30352c26bcf06b55abf7c340 100644 (file)
@@ -25,6 +25,8 @@
 #ifndef __UTIL_MPM_AC__H__
 #define __UTIL_MPM_AC__H__
 
+#include "util-mpm.h"
+
 #define SC_AC_STATE_TYPE_U16 uint16_t
 #define SC_AC_STATE_TYPE_U32 uint32_t
 
index f7a0c682cf5e27b5b34861b9454c77ce62d22007..1c6b17f3e1bcf04152d278d341621c2253838bfd 100644 (file)
@@ -180,11 +180,6 @@ MpmCtx *MpmFactoryGetMpmCtxForProfile(const struct DetectEngineCtx_ *, int32_t,
 void MpmFactoryDeRegisterAllMpmCtxProfiles(struct DetectEngineCtx_ *);
 int32_t MpmFactoryIsMpmCtxAvailable(const struct DetectEngineCtx_ *, const MpmCtx *);
 
-int PmqSetup(PrefilterRuleStore *);
-void PmqReset(PrefilterRuleStore *);
-void PmqCleanup(PrefilterRuleStore *);
-void PmqFree(PrefilterRuleStore *);
-
 void MpmTableSetup(void);
 void MpmRegisterTests(void);
 
index afd9cb04956b7a8674538832c7952f583a21f871..170170b1933da4d9dbcc7719d976de9f348b064f 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "suricata-common.h"
 #include "util-pages.h"
+#include "util-debug.h"
 
 #ifndef HAVE_PAGESUPPORTSRWX_AS_MACRO
 
index cbc57d6cb40d3fa42129b7021e849689699d8d35..9642fe8cf779ecce42a33c61c0cfb74541c357d9 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "suricata-common.h"
 #include "util-pidfile.h"
+#include "util-debug.h"
 
 /**
  * \brief Write a pid file (used at the startup)
index 6a59f257c3675e92fb24c46facd91349b2c80078..b0e9d6286631b12e5b92c31c00bf3d9b30a83b5d 100644 (file)
@@ -21,6 +21,7 @@
 #include "runmodes.h"
 #include "output-eve-syslog.h"
 #include "util-plugin.h"
+#include "util-debug.h"
 
 #ifdef HAVE_PLUGINS
 
index a67fdf5d64c2d660e96d32c822cc580ed7763aa7..47e343b2c4e4863e4901cc67792ba836b786a862 100644 (file)
@@ -39,6 +39,7 @@
 #ifndef __UTIL_POOL_THREAD_H__
 #define __UTIL_POOL_THREAD_H__
 
+#include "threads.h"
 #include "util-pool.h"
 
 struct PoolThreadElement_ {
index 42f323a6e89d0ae15a183e537b6bc4db636c481d..ca59a1b48e4a943af0da6e7bc1f91095d8efd9e9 100644 (file)
@@ -24,6 +24,7 @@
  */
 
 #include "suricata-common.h"
+#include "util-prefilter.h"
 
 /**
  *  \brief Setup a pmq
index 379fd842b3610f0e2caf40abf95c5800d846f039..b956143114abe8dd97caf3b0be9419ca5de71d27 100644 (file)
@@ -24,6 +24,8 @@
 #ifndef __UTIL_PREFILTER_H__
 #define __UTIL_PREFILTER_H__
 
+#include "util-debug.h"
+
 /** \brief structure for storing potential rule matches
  *
  *  Helper structure for the prefilter engine. The Pattern Matchers
@@ -79,4 +81,10 @@ PrefilterAddSids(PrefilterRuleStore *pmq, SigIntId *sids, uint32_t sids_size)
     } while (ptr != end);
     pmq->rule_id_array_cnt += sids_size;
 }
+
+int PmqSetup(PrefilterRuleStore *);
+void PmqReset(PrefilterRuleStore *);
+void PmqCleanup(PrefilterRuleStore *);
+void PmqFree(PrefilterRuleStore *);
+
 #endif /* __UTIL_PREFILTER_H__ */
index 6d1f0c60f98814a52e3cc399ad39889eae039799..05592f63f9acd37496aae7470e5ba145f1c86ec4 100644 (file)
@@ -24,6 +24,8 @@
 #ifndef _UTIL_PRIVS_H
 #define        _UTIL_PRIVS_H
 
+#include "threadvars.h"
+
 #define SC_CAP_NONE             0x01
 #define SC_CAP_SYS_ADMIN        0x02
 #define SC_CAP_SYS_RAW_IO       0x04
index 1e55980df7b8c894dba3c899eb53c49702dee8d1..03f4d0243dc901a3b993a3b2a6d4c1246170c60a 100644 (file)
  */
 
 #include "suricata-common.h"
-#include "decode.h"
-#include "detect.h"
-#include "detect-engine.h"
-#include "conf.h"
-
-#include "tm-threads.h"
-
-#include "util-unittest.h"
-#include "util-byte.h"
 #include "util-profiling.h"
 #include "util-profiling-locks.h"
-#include "util-time.h"
 
 #ifdef PROFILING
-
-#ifndef MIN
-#define MIN(a, b) (((a) < (b)) ? (a) : (b))
-#endif
+#include "detect-engine.h"
+#include "tm-threads.h"
+#include "util-conf.h"
+#include "util-time.h"
 
 /**
  * Extra data for rule profiling.
index 0840750596047d2531c5176c848abd489d854005..a50570f74662f4a836de1c59d3f240be40f79fa2 100644 (file)
 
 #include "suricata-common.h"
 #include "util-profiling-locks.h"
-#include "util-hashlist.h"
 
 #ifdef PROFILING
 #ifdef PROFILE_LOCKING
+#include "threads.h"
+#include "util-hashlist.h"
+#include "util-debug.h"
 
 thread_local ProfilingLock locks[PROFILING_MAX_LOCKS];
 thread_local int locks_idx = 0;
index 0631681c627e6de4f5b3ae306559ff685e5c4655..08d745a7218232d8f0e11e5e9f94e947ff94a69b 100644 (file)
 
 #ifdef PROFILING
 
-#define PROFILING_MAX_LOCKS 64
-
-enum {
-    LOCK_MUTEX,
-    LOCK_SPIN,
-    LOCK_RWW,   /**< rwlock, writer */
-    LOCK_RWR,   /**< rwlock, reader */
-};
-
 void SCProfilingAddPacketLocks(void *);
 
 int LockRecordInitHash(void);
index c5e0cfd104632430cd24e5d30859023a7426fc87..526cc2c873693b0c18d23295f0d77c3e3959e5fa 100644 (file)
  */
 
 #include "suricata-common.h"
-#include "decode.h"
-#include "detect.h"
-#include "detect-engine.h"
-#include "detect-engine-prefilter.h"
-#include "conf.h"
-
-#include "tm-threads.h"
-
-#include "util-unittest.h"
-#include "util-byte.h"
 #include "util-profiling.h"
-#include "util-profiling-locks.h"
-#include "util-time.h"
 
 #ifdef PROFILING
+#include "detect-engine-prefilter.h"
+#include "util-conf.h"
+#include "util-time.h"
 
 typedef struct SCProfilePrefilterData_ {
     uint64_t called;
index 1a89908cd46273c5d8b1ad3c58dda107eb2b3afa..d1d03962c97fa323412df2f443fcf83aaa274722 100644 (file)
  */
 
 #include "suricata-common.h"
-#include "decode.h"
-#include "detect.h"
-#include "detect-engine.h"
-#include "conf.h"
-
-#include "tm-threads.h"
-
-#include "util-unittest.h"
-#include "util-byte.h"
 #include "util-profiling.h"
-#include "util-profiling-locks.h"
-#include "util-time.h"
 
 #ifdef PROFILING
+#include "util-conf.h"
+#include "util-time.h"
 
 /**
  * Extra data for rule profiling.
index 6c3f31d967a2d25ae159583fb21b48953d92c44c..2303a513265ba7fda3fac05e985a6c3b3fc783ea 100644 (file)
  */
 
 #include "suricata-common.h"
-#include "decode.h"
-#include "detect.h"
-#include "conf.h"
-
-#include "tm-threads.h"
-
-#include "util-unittest.h"
-#include "util-byte.h"
 #include "util-profiling.h"
-#include "util-profiling-locks.h"
-#include "util-time.h"
 
 #ifdef PROFILING
+#include "util-byte.h"
+#include "util-conf.h"
+#include "util-time.h"
 
 /**
  * Extra data for rule profiling.
index 615b40b9364771ca3598f09fd10197f8ab63194c..89bec12589b33a0252743ad9941b78d27a550a67 100644 (file)
  */
 
 #include "suricata-common.h"
-#include "decode.h"
-#include "detect.h"
-#include "detect-engine-prefilter.h"
-#include "conf.h"
-#include "flow-worker.h"
+#include "util-profiling.h"
 
+#ifdef PROFILING
 #include "tm-threads.h"
-
+#include "conf.h"
 #include "util-unittest.h"
 #include "util-byte.h"
-#include "util-profiling.h"
 #include "util-profiling-locks.h"
-
-#ifdef PROFILING
+#include "util-conf.h"
 
 #ifndef MIN
 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
index ad7c710169a220c89b009a5318d5b55a795da019..b54f764d3a857cd938cdc0c9b2f3596bd31bebf2 100644 (file)
@@ -27,6 +27,9 @@
 
 #ifdef PROFILING
 
+#include "detect.h"
+#include "util-cpu.h"
+#include "util-profiling-locks.h"
 
 extern int profiling_rules_enabled;
 extern int profiling_packets_enabled;
@@ -305,6 +308,7 @@ extern thread_local int profiling_prefilter_entered;
     (det_ctx)->prefilter_bytes += (bytes);                                                         \
     (det_ctx)->prefilter_bytes_called++
 
+struct SCProfileDetectCtx_;
 void SCProfilingRulesGlobalInit(void);
 void SCProfilingRuleDestroyCtx(struct SCProfileDetectCtx_ *);
 void SCProfilingRuleInitCounters(DetectEngineCtx *);
index e63d964d5b2b95a57d174969ea988384d4d4d254..e74b01daf6289d80969ecd722097ab31a03b877d 100644 (file)
@@ -27,6 +27,7 @@
 #include "suricata-common.h"
 #include "util-hash-string.h"
 #include "util-proto-name.h"
+#include "util-debug.h"
 
 #ifdef UNITTESTS
 #include "util-unittest.h"
index cac3f2864d26d7c5f8bca7c2f6d9c59152828040..0beee32878802757b9a1de93d56f54a1c7a9cf04 100644 (file)
@@ -27,7 +27,7 @@
 #include "suricata-common.h"
 #include "suricata.h"
 #include "util-random.h"
-
+#include "util-debug.h"
 
 #if !(defined(HAVE_WINCRYPT_H) &&  defined(OS_WIN32))
 #if defined(HAVE_CLOCK_GETTIME)
index 0bbab62af3cb4a32e9139d6a23ae7cd327324e9a..516e8cf9b59ce754a50a7d8a7ad3da4869ee0f3a 100644 (file)
@@ -24,6 +24,8 @@
 #ifndef __UTIL_REFERENCE_CONFIG_H__
 #define __UTIL_REFERENCE_CONFIG_H__
 
+#include "detect.h"
+
 #define REFERENCE_SYSTEM_NAME_MAX   64
 #define REFERENCE_CONTENT_NAME_MAX  1024
 
index 3b35201065e4c8731ebbf2d38477440091e0651e..a48bb12e72c6e3ff6128f2a4daf843fd1a61c09e 100644 (file)
@@ -39,8 +39,8 @@
 #include "util-unittest.h"
 #include "util-memcmp.h"
 #include "util-hash-lookup3.h"
-#include "queue.h"
 #include "util-rohash.h"
+#include "util-debug.h"
 
 /** item_size data beyond this header */
 typedef struct ROHashTableItem_ {
index 747a5d423e1409dcaba34118a4a08db459cece67..d637437f7c8661b32d2fd344b817fc29ac2ab93d 100644 (file)
  */
 
 #include "suricata-common.h"
-#include "suricata.h"
-
 #include "util-hyperscan.h"
+#include "util-spm.h"
 #include "util-spm-hs.h"
+#include "util-debug.h"
 
 #ifdef BUILD_HYPERSCAN
 
index b3b14d7f71385c961bc6c7c33b5727d276de68f6..d3251a8e39585dd41c4f0c8411cff7a63cb664c4 100644 (file)
@@ -44,7 +44,6 @@
  */
 
 #include "suricata-common.h"
-#include "suricata.h"
 #include "util-unittest.h"
 
 #include "conf.h"
@@ -58,6 +57,7 @@
 #ifdef BUILD_HYPERSCAN
 #include "hs.h"
 #endif
+#include "util-debug.h"
 
 SpmTableElmt spm_table[SPM_TABLE_SIZE];
 
index 7080009d7f7b8d60016896d55613ad3e43f20f31..4efc2333ae3369c50d56a98731de45d9dc216b01 100644 (file)
@@ -26,6 +26,7 @@
 #include "suricata-common.h"
 #include "util-unittest.h"
 #include "util-storage.h"
+#include "util-debug.h"
 
 typedef struct StorageMapping_ {
     const char *name;
index d4c36320379866752d65cf5dbf1f3ddf879a78d1..5bd0dd6f819aa34adb5d8f60164772c9163f95d0 100644 (file)
@@ -20,6 +20,7 @@
 #include "util-unittest.h"
 #include "util-print.h"
 #include "util-validate.h"
+#include "util-debug.h"
 
 /**
  * \file
index 644d7ac2018ec5ee50ab039f80752f0d474c44fa..166801134892fd077831c683701548ff62cc5f71 100644 (file)
@@ -26,6 +26,7 @@
 #ifndef __THASH_H__
 #define __THASH_H__
 
+#include "threads.h"
 
 /** Spinlocks or Mutex for the buckets. */
 //#define HRLOCK_SPIN
index fcecec3056dbc3d596894d8845a2860491e91f24..56f4501c96e66ce3b15b820939ba5601b48cd030 100644 (file)
 #ifndef __UTIL_UNITTEST_HELPER__
 #define __UTIL_UNITTEST_HELPER__
 
+#if defined(UNITTESTS)
+#include "packet.h"
+#include "flow.h"
+#include "stream-tcp.h"
+#include "detect.h"
+#include "detect-engine.h"
+#include "detect-engine-alert.h"
+#include "detect-engine-build.h"
+#elif defined(FUZZ)
+#include "packet.h"
+#include "flow.h"
+#endif
+
 #if defined(UNITTESTS) || defined(FUZZ)
 Flow *TestHelperBuildFlow(int family, const char *src, const char *dst, Port sp, Port dp);
 int TestHelperBufferToFile(const char *name, const uint8_t *data, size_t size);