From: Philippe Antoine Date: Mon, 9 Jun 2025 20:05:12 +0000 (+0200) Subject: src: clean includes for app-layer-parser.h X-Git-Tag: suricata-8.0.0-rc1~98 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=249131e9de27bb7ebc9b949a02320ae30acb9ef7;p=thirdparty%2Fsuricata.git src: clean includes for app-layer-parser.h To prepare bindgening --- diff --git a/src/app-layer-dnp3.c b/src/app-layer-dnp3.c index 63e5972319..4fe796d58a 100644 --- a/src/app-layer-dnp3.c +++ b/src/app-layer-dnp3.c @@ -32,6 +32,7 @@ #include "app-layer-protos.h" #include "app-layer-parser.h" #include "app-layer-detect-proto.h" +#include "app-layer-events.h" #include "app-layer-dnp3.h" #include "app-layer-dnp3-objects.h" diff --git a/src/app-layer-ftp.c b/src/app-layer-ftp.c index e84fbb7072..24245593d8 100644 --- a/src/app-layer-ftp.c +++ b/src/app-layer-ftp.c @@ -31,6 +31,7 @@ #include "app-layer-parser.h" #include "app-layer-expectation.h" #include "app-layer-detect-proto.h" +#include "app-layer-events.h" #include "rust.h" diff --git a/src/app-layer-htp.c b/src/app-layer-htp.c index 4cc879a586..8ad24fe970 100644 --- a/src/app-layer-htp.c +++ b/src/app-layer-htp.c @@ -55,6 +55,7 @@ #include "app-layer-htp-xff.h" #include "app-layer-htp-range.h" #include "app-layer-htp-mem.h" +#include "app-layer-events.h" #include "util-debug.h" #include "util-misc.h" diff --git a/src/app-layer-modbus.c b/src/app-layer-modbus.c index 5640953a53..e0bd7f253f 100644 --- a/src/app-layer-modbus.c +++ b/src/app-layer-modbus.c @@ -40,6 +40,7 @@ #include "app-layer-parser.h" #include "app-layer-modbus.h" +#include "rust.h" void ModbusParserRegisterTests(void); diff --git a/src/app-layer-parser.c b/src/app-layer-parser.c index ff4d13c4c2..bd0f536c35 100644 --- a/src/app-layer-parser.c +++ b/src/app-layer-parser.c @@ -31,10 +31,12 @@ #include "flow-util.h" #include "app-layer-frames.h" +#include "app-layer-events.h" #include "stream-tcp.h" #include "util-validate.h" +#include "util-config.h" #include "app-layer.h" #include "app-layer-detect-proto.h" diff --git a/src/app-layer-parser.h b/src/app-layer-parser.h index d269c177e1..f1ef436914 100644 --- a/src/app-layer-parser.h +++ b/src/app-layer-parser.h @@ -25,10 +25,23 @@ #ifndef SURICATA_APP_LAYER_PARSER_H #define SURICATA_APP_LAYER_PARSER_H -#include "app-layer-events.h" -#include "util-file.h" -#include "rust.h" -#include "util-config.h" +#include "app-layer-protos.h" +// Forward declarations for bindgen +enum ConfigAction; +typedef struct Flow_ Flow; +typedef struct AppLayerParserState_ AppLayerParserState; +typedef struct AppLayerDecoderEvents_ AppLayerDecoderEvents; +typedef struct ThreadVars_ ThreadVars; +typedef struct File_ File; +// Forward declarations from rust +typedef struct StreamSlice StreamSlice; +typedef struct AppLayerResult AppLayerResult; +typedef struct AppLayerGetTxIterTuple AppLayerGetTxIterTuple; +typedef struct AppLayerGetFileState AppLayerGetFileState; +typedef struct AppLayerTxData AppLayerTxData; +typedef enum AppLayerEventType AppLayerEventType; +typedef struct AppLayerStateData AppLayerStateData; +typedef struct AppLayerTxConfig AppLayerTxConfig; /* Flags for AppLayerParserState. */ // flag available BIT_U16(0) @@ -248,27 +261,9 @@ AppLayerStateData *AppLayerParserGetStateData(uint8_t ipproto, AppProto alproto, void AppLayerParserApplyTxConfig(uint8_t ipproto, AppProto alproto, void *state, void *tx, enum ConfigAction mode, AppLayerTxConfig); -static inline bool AppLayerParserIsFileTx(const AppLayerTxData *txd) -{ - if (txd->file_tx != 0) { - return true; - } - return false; -} - -static inline bool AppLayerParserIsFileTxInDir(const AppLayerTxData *txd, const uint8_t direction) -{ - if ((txd->file_tx & direction) != 0) { - return true; - } - return false; -} - /** \brief check if tx (possibly) has files in this tx for the direction */ -static inline bool AppLayerParserHasFilesInDir(const AppLayerTxData *txd, const uint8_t direction) -{ - return (txd->files_opened && AppLayerParserIsFileTxInDir(txd, direction)); -} +#define AppLayerParserHasFilesInDir(txd, direction) \ + ((txd)->files_opened && ((txd)->file_tx & (direction)) != 0) /***** General *****/ diff --git a/src/app-layer-register.c b/src/app-layer-register.c index d60110c5e0..00f0818682 100644 --- a/src/app-layer-register.c +++ b/src/app-layer-register.c @@ -27,6 +27,7 @@ #include "suricata.h" #include "stream.h" #include "conf.h" +#include "rust.h" #include "app-layer-detect-proto.h" #include "app-layer-parser.h" diff --git a/src/app-layer-smtp.c b/src/app-layer-smtp.c index 5dfa7737b7..12bf050ba9 100644 --- a/src/app-layer-smtp.c +++ b/src/app-layer-smtp.c @@ -32,6 +32,7 @@ #include "app-layer-protos.h" #include "app-layer-parser.h" #include "app-layer-frames.h" +#include "app-layer-events.h" #include "app-layer-smtp.h" #include "util-enum.h" diff --git a/src/app-layer-ssl.c b/src/app-layer-ssl.c index 8a64884525..2af5ac514b 100644 --- a/src/app-layer-ssl.c +++ b/src/app-layer-ssl.c @@ -32,6 +32,7 @@ #include "app-layer-protos.h" #include "app-layer-parser.h" #include "app-layer-frames.h" +#include "app-layer-events.h" #include "app-layer-ssl.h" #include "conf.h" diff --git a/src/app-layer.c b/src/app-layer.c index 0171db8cf5..13dcee2a58 100644 --- a/src/app-layer.c +++ b/src/app-layer.c @@ -34,6 +34,7 @@ #include "app-layer-htp-range.h" #include "app-layer-detect-proto.h" #include "app-layer-frames.h" +#include "app-layer-events.h" #include "stream-tcp-reassemble.h" #include "stream-tcp-private.h" #include "stream-tcp-inline.h" diff --git a/src/detect-app-layer-event.c b/src/detect-app-layer-event.c index 88db53fa50..e7886da5d7 100644 --- a/src/detect-app-layer-event.c +++ b/src/detect-app-layer-event.c @@ -28,6 +28,7 @@ #include "app-layer.h" #include "app-layer-protos.h" #include "app-layer-parser.h" +#include "app-layer-events.h" #include "app-layer-smtp.h" #include "detect.h" #include "detect-parse.h" diff --git a/src/detect-bytemath.c b/src/detect-bytemath.c index 053e07f28b..10902cf8cc 100644 --- a/src/detect-bytemath.c +++ b/src/detect-bytemath.c @@ -29,6 +29,7 @@ #include "threads.h" #include "decode.h" +#include "rust.h" #include "app-layer-parser.h" #include "app-layer-protos.h" @@ -40,8 +41,6 @@ #include "detect-engine-state.h" #include "detect-engine-build.h" -#include "rust-bindings.h" - #include "detect-content.h" #include "detect-pcre.h" #include "detect-byte.h" diff --git a/src/detect-engine.c b/src/detect-engine.c index 42b28f711a..ba3a54b93f 100644 --- a/src/detect-engine.c +++ b/src/detect-engine.c @@ -33,6 +33,7 @@ #include "datasets.h" #include "app-layer-parser.h" +#include "app-layer-events.h" #include "app-layer-htp.h" #include "detect-parse.h" diff --git a/src/detect-flowbits.c b/src/detect-flowbits.c index 2d810112c2..ba029ccd74 100644 --- a/src/detect-flowbits.c +++ b/src/detect-flowbits.c @@ -34,6 +34,7 @@ #include "flow-util.h" #include "detect-flowbits.h" #include "util-spm.h" +#include "rust.h" #include "app-layer-parser.h" diff --git a/src/detect-ike-vendor.c b/src/detect-ike-vendor.c index 220487f723..694ddfb954 100644 --- a/src/detect-ike-vendor.c +++ b/src/detect-ike-vendor.c @@ -30,10 +30,10 @@ #include "detect-engine-content-inspection.h" #include "detect-engine-mpm.h" #include "detect-ike-vendor.h" +#include "rust.h" #include "app-layer-parser.h" #include "util-byte.h" -#include "rust-bindings.h" #include "util-profiling.h" static int DetectIkeVendorSetup(DetectEngineCtx *, Signature *, const char *); diff --git a/src/detect-lua-extensions.c b/src/detect-lua-extensions.c index 339292d76c..30b9e5771e 100644 --- a/src/detect-lua-extensions.c +++ b/src/detect-lua-extensions.c @@ -34,6 +34,7 @@ #include "detect-lua.h" +#include "rust.h" #include "app-layer-parser.h" #include "util-lua.h" diff --git a/src/flow.c b/src/flow.c index 751515303b..ef10da305e 100644 --- a/src/flow.c +++ b/src/flow.c @@ -57,6 +57,7 @@ #include "util-debug.h" +#include "rust.h" #include "app-layer-parser.h" #include "app-layer-expectation.h" diff --git a/src/output-tx.c b/src/output-tx.c index 9bc08ad45c..996febf057 100644 --- a/src/output-tx.c +++ b/src/output-tx.c @@ -29,6 +29,7 @@ #include "stream.h" #include "app-layer.h" #include "app-layer-parser.h" +#include "util-config.h" #include "util-profiling.h" #include "util-validate.h" @@ -427,8 +428,8 @@ static TmEcode OutputTxLog(ThreadVars *tv, Packet *p, void *thread_data) op_thread_data->filedata); if (file_logging_active) { - if (AppLayerParserIsFileTx(txd)) { // need to process each tx that might be a file tx, - // even if there are not files (yet) + if (txd->file_tx != 0) { // need to process each tx that might be a file tx, + // even if there are not files (yet) const bool ts_ready = (tx_progress_ts == complete_ts); const bool tc_ready = (tx_progress_tc == complete_tc); SCLogDebug("ts_ready %d tc_ready %d", ts_ready, tc_ready); @@ -444,7 +445,7 @@ static TmEcode OutputTxLog(ThreadVars *tv, Packet *p, void *thread_data) /* call only for the correct direction, except when it looks anything like a end of * transaction or end of stream. Since OutputTxLogFiles has complicated logic around * that, we just leave it to that function to sort things out for now. */ - if (eval_files || AppLayerParserIsFileTxInDir(txd, pkt_dir)) { + if (eval_files || ((txd->file_tx & pkt_dir) != 0)) { OutputTxLogFiles(tv, op_thread_data->file, op_thread_data->filedata, p, f, tx, tx_id, txd, tx_complete, ts_ready, tc_ready, ts_eof, tc_eof, eof); } diff --git a/src/rust-context.c b/src/rust-context.c index 226ae5c044..2155121f30 100644 --- a/src/rust-context.c +++ b/src/rust-context.c @@ -18,6 +18,7 @@ #include "suricata-common.h" #include "rust-context.h" #include "app-layer-parser.h" +#include "app-layer-events.h" #include "app-layer-register.h" #include "app-layer-htp-range.h" #include "app-layer-htp-file.h" diff --git a/src/tests/fuzz/fuzz_applayerparserparse.c b/src/tests/fuzz/fuzz_applayerparserparse.c index 759dcd371f..4e4c7cfe48 100644 --- a/src/tests/fuzz/fuzz_applayerparserparse.c +++ b/src/tests/fuzz/fuzz_applayerparserparse.c @@ -13,6 +13,7 @@ #include "util-byte.h" #include "conf-yaml-loader.h" #include "util-conf.h" +#include "rust.h" #define HEADER_LEN 6