src: includes cleanup

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.
pull/7957/head
Victor Julien 3 years ago
parent 3e2295a963
commit 39cf5b151a

@ -1321,12 +1321,6 @@
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

@ -17,7 +17,7 @@ memset(p@p1, 0, ...);
(
p->pkt
|
PACKET_INITIALIZE(p)
PacketInit(p)
)
@script:python depends on !isset@

@ -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 \

@ -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;

@ -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)(

@ -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"

@ -26,42 +26,18 @@
*/
#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)

@ -26,42 +26,12 @@
* 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 };

@ -24,43 +24,10 @@
* 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"

@ -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"
/**

@ -30,13 +30,11 @@
*/
#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);

@ -3233,6 +3233,8 @@ void RegisterHTPParsers(void)
}
#ifdef UNITTESTS
#include "detect-engine-alert.h"
static HTPCfgRec cfglist_backup;
void HtpConfigCreateBackup(void)

@ -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"

@ -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"

@ -24,34 +24,28 @@
*/
#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"
@ -61,28 +55,16 @@
#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;

@ -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"

@ -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

@ -25,24 +25,22 @@
*/
#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

@ -25,6 +25,8 @@
#ifndef __COUNTERS_H__
#define __COUNTERS_H__
#include "threads.h"
/* forward declaration of the ThreadVars structure */
struct ThreadVars_;

@ -28,11 +28,14 @@
#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;

@ -31,6 +31,7 @@
#include "decode-geneve.h"
#include "decode-events.h"
#include "detect.h"
#include "detect-engine-port.h"
#include "flow.h"

@ -33,21 +33,10 @@
#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;

@ -32,19 +32,11 @@
*/
#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;

@ -31,19 +31,11 @@
*/
#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;

@ -40,10 +40,6 @@
#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

@ -31,19 +31,14 @@
*/
#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;

@ -31,16 +31,13 @@
*/
#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;

@ -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

@ -35,16 +35,10 @@
#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;

@ -30,20 +30,14 @@
*/
#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;

@ -31,6 +31,7 @@
#include "decode-vxlan.h"
#include "decode-events.h"
#include "detect.h"
#include "detect-engine-port.h"
#include "flow.h"
@ -39,10 +40,6 @@
#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

@ -48,28 +48,24 @@
*/
#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;

@ -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 */

@ -23,12 +23,9 @@
*/
#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;

@ -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);

@ -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

@ -24,7 +24,6 @@
*/
#include "suricata-common.h"
#include "threads.h"
#include "defrag-queue.h"
#include "util-error.h"
#include "util-debug.h"

@ -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. */

@ -22,6 +22,7 @@
*/
#include "suricata-common.h"
#include "decode.h"
#include "defrag.h"
#include "defrag-hash.h"
#include "defrag-timeout.h"

@ -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);

@ -24,6 +24,7 @@
#ifndef __DEFRAG_H__
#define __DEFRAG_H__
#include "threads.h"
#include "util-pool.h"
/**

@ -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 *);

@ -1125,7 +1125,7 @@ end:
DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx);
DetectEngineCtxFree(de_ctx);
}
PACKET_RECYCLE(p);
PacketRecycle(p);
FlowShutdown();
SCFree(p);

@ -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;

@ -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;

@ -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 *);

@ -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);

@ -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;

@ -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)
{

@ -42,6 +42,7 @@
#include "util-detect.h"
#include "util-threshold-config.h"
#include "util-path.h"
#ifdef HAVE_GLOB_H
#include <glob.h>

@ -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;
}

@ -24,6 +24,7 @@
#ifndef __DETECT_ENGINE_PREFILTER_H__
#define __DETECT_ENGINE_PREFILTER_H__
#include "detect.h"
#include "detect-engine-state.h"
// TODO

@ -23,16 +23,12 @@
*/
#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,

@ -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);

@ -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"

@ -49,6 +49,7 @@
#include "util-profiling.h"
#include "app-layer.h"
#include "app-layer-htp.h"
#include "stream-tcp.h"

@ -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;

@ -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;

@ -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

@ -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"

@ -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);

@ -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 */

@ -321,7 +321,7 @@ end:
if (det_ctx != NULL)
DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx);
DetectEnginePruneFreeList();
PACKET_RECYCLE(p);
PacketRecycle(p);
FlowShutdown();
SCFree(p);

@ -27,6 +27,7 @@
#define __DEVICE_STORAGE_H__
#include "util-device.h"
#include "util-storage.h"
typedef struct LiveDevStorageId_ {
int id;

@ -24,10 +24,11 @@
*/
#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;

@ -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;

@ -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

@ -27,6 +27,7 @@
#define __FLOW_STORAGE_H__
#include "flow.h"
#include "util-storage.h"
typedef struct FlowStorageId {
int id;

@ -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)

@ -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

@ -25,14 +25,9 @@
*/
#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)
@ -41,31 +36,25 @@
#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"

@ -22,29 +22,14 @@
*/
#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"

@ -24,6 +24,9 @@
#ifndef __LOG_TCPDATALOG_H__
#define __LOG_TCPDATALOG_H__
#include "conf.h"
#include "output.h"
void LogTcpDataLogRegister(void);
OutputInitResult LogTcpDataLogInitCtx(ConfNode *);

@ -27,29 +27,18 @@
*/
#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"

@ -24,15 +24,17 @@
*/
#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;

@ -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. */

@ -24,16 +24,15 @@
*/
#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;

@ -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

@ -16,21 +16,19 @@
*/
#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"

@ -24,7 +24,6 @@
*/
#include "suricata-common.h"
#include "tm-modules.h"
#include "output.h"
#include "output-flow.h"
#include "util-profiling.h"

@ -22,23 +22,9 @@
*/
#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)
{

@ -16,26 +16,11 @@
*/
#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"

@ -24,26 +24,11 @@
*/
#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)

@ -23,18 +23,12 @@
*/
#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"
@ -46,15 +40,6 @@
#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"

@ -24,7 +24,6 @@
*/
#include "suricata-common.h"
#include "tm-modules.h"
#include "output.h"
#include "output-packet.h"
#include "util-profiling.h"

@ -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 *);

@ -24,15 +24,10 @@
*/
#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_ {

@ -24,7 +24,6 @@
*/
#include "suricata-common.h"
#include "tm-modules.h"
#include "output.h"
#include "output-streaming.h"
#include "app-layer.h"

@ -24,7 +24,6 @@
*/
#include "suricata-common.h"
#include "tm-modules.h"
#include "output.h"
#include "output-tx.h"
#include "stream.h"

@ -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);

@ -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"

@ -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

@ -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);
}

@ -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

@ -26,18 +26,17 @@
*/
#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

@ -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);

@ -44,6 +44,7 @@
#include "flow-bypass.h"
#include "util-conf.h"
#include "util-debug.h"
#include "util-time.h"
#include "util-cpu.h"

@ -33,10 +33,13 @@
#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"

@ -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;

@ -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
@ -16,20 +16,16 @@
*/
#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"

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save