From: Victor Julien Date: Mon, 22 May 2017 19:56:14 +0000 (+0200) Subject: rust/core: add file tx API call X-Git-Tag: suricata-4.0.0-beta1~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=71ddc43d49f4419f3df43ddbbda0008ee8e3f1d1;p=thirdparty%2Fsuricata.git rust/core: add file tx API call --- diff --git a/rust/src/core.rs b/rust/src/core.rs index fb6edd26eb..d87cd976dc 100644 --- a/rust/src/core.rs +++ b/rust/src/core.rs @@ -87,6 +87,9 @@ pub type SCFilePrune = extern "C" fn ( pub type SCFileContainerRecycle = extern "C" fn ( file_container: &FileContainer); +pub type SCFileSetTx = extern "C" fn ( + file: &FileContainer, + tx_id: u64); // A Suricata context that is passed in from C. This is alternative to // using functions from Suricata directly, so they can be wrapped so @@ -108,6 +111,7 @@ pub struct SuricataContext { pub FileAppendData: SCFileAppendDataById, pub FileContainerRecycle: SCFileContainerRecycle, pub FilePrune: SCFilePrune, + pub FileSetTx: SCFileSetTx, } #[allow(non_snake_case)] diff --git a/src/rust.h b/src/rust.h index 0dcf54f7a0..f69986008d 100644 --- a/src/rust.h +++ b/src/rust.h @@ -35,6 +35,7 @@ typedef struct SuricataContext_ { const uint8_t *data, uint32_t data_len); void (*FileContainerRecycle)(FileContainer *ffc); void (*FilePrune)(FileContainer *ffc); + void (*FileSetTx)(FileContainer *, uint64_t); } SuricataContext; diff --git a/src/suricata.c b/src/suricata.c index a5f76a40f8..ee5499faa0 100644 --- a/src/suricata.c +++ b/src/suricata.c @@ -2792,6 +2792,7 @@ int main(int argc, char **argv) context.FileAppendDataById = FileAppendDataById; context.FileContainerRecycle = FileContainerRecycle; context.FilePrune = FilePrune; + context.FileSetTx = FileContainerSetTx; rs_init(&context); #endif diff --git a/src/util-file.c b/src/util-file.c index 3998262db3..0fb6da10df 100644 --- a/src/util-file.c +++ b/src/util-file.c @@ -517,6 +517,13 @@ int FileSetTx(File *ff, uint64_t txid) SCReturnInt(0); } +void FileContainerSetTx(FileContainer *ffc, uint64_t tx_id) +{ + if (ffc && ffc->tail) { + (void)FileSetTx(ffc->tail, tx_id); + } +} + /** * \brief check if we have stored enough * diff --git a/src/util-file.h b/src/util-file.h index 29bc967dd3..4c52adae1d 100644 --- a/src/util-file.h +++ b/src/util-file.h @@ -172,6 +172,7 @@ int FileStore(File *); * \param txid the tx id */ int FileSetTx(File *, uint64_t txid); +void FileContainerSetTx(FileContainer *ffc, uint64_t tx_id); /** * \brief disable file storage for a flow