]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
rust/core: add file tx API call
authorVictor Julien <victor@inliniac.net>
Mon, 22 May 2017 19:56:14 +0000 (21:56 +0200)
committerVictor Julien <victor@inliniac.net>
Tue, 6 Jun 2017 07:45:17 +0000 (09:45 +0200)
rust/src/core.rs
src/rust.h
src/suricata.c
src/util-file.c
src/util-file.h

index fb6edd26eb1b7c40d7d08e8e45c89f4f1b492dc0..d87cd976dcdec0780a49baf77aa49783283ab6a6 100644 (file)
@@ -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)]
index 0dcf54f7a073ba1b20e7a1edbdb79ed690b6f294..f69986008db9fe5f61f5d4ba609c23dde56decc8 100644 (file)
@@ -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;
 
index a5f76a40f80ce451f82e181c8906198764ef1d04..ee5499faa0e83a1bd8d3382a38ce4e9941105380 100644 (file)
@@ -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
index 3998262db35d0ac0407f80681860f0c542c7658b..0fb6da10df15e608903c93400d720613f49027ca 100644 (file)
@@ -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
  *
index 29bc967dd39643df645636b0e203a318667d793e..4c52adae1d2c958230d0e4b404205c4598a942de 100644 (file)
@@ -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