]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
rust: add bindings to SCPlugin.* to sys crate 12357/head 12590/head
authorJason Ish <jason.ish@oisf.net>
Fri, 24 Jan 2025 15:56:58 +0000 (09:56 -0600)
committerVictor Julien <victor@inliniac.net>
Mon, 17 Feb 2025 06:31:29 +0000 (07:31 +0100)
Also disable bindgen's generated layout tests.  They are valid for the
platform generating the tests, but may not be valid for other
platforms. For example, if the tests are generated on a 64 bit
platform the tests will not be valid when run on a 32 bit platform as
pointers are a different size.

However, the generating bindings are valid for both platform.

Ticket: #7341

rust/Makefile.am
rust/sys/src/sys.rs
src/bindgen.h

index b1791b001d99d71c83a6c08e9ff0285b9fe94c4c..a751bb85a3aac8fb00466286bc070fdfdddfcc21 100644 (file)
@@ -110,10 +110,13 @@ if HAVE_BINDGEN
        $(BINDGEN) \
                -o sys/src/sys.rs \
                --rust-target 1.68 \
+               --no-layout-tests \
                --disable-header-comment \
                --default-enum-style rust \
                --allowlist-type 'AppProto.*' \
                --allowlist-function 'AppProto.*' \
+               --allowlist-type 'SC.*' \
+               --allowlist-function 'SC.*' \
                $(abs_top_srcdir)/src/bindgen.h \
                -- \
                -DHAVE_CONFIG_H -I../src -I../rust/gen $(CPPFLAGS)
index 1c358f7b5a15c1dc05c36abd0e05bcb85bd038d8..cf6f060a3e5d1e5402a6adcd6b8b3cc16a995f71 100644 (file)
@@ -54,3 +54,74 @@ extern "C" {
         alproto: AppProto, proto_name: *const ::std::os::raw::c_char,
     );
 }
+#[doc = " Structure to define a Suricata plugin."]
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct SCPlugin_ {
+    pub name: *const ::std::os::raw::c_char,
+    pub license: *const ::std::os::raw::c_char,
+    pub author: *const ::std::os::raw::c_char,
+    pub Init: ::std::option::Option<unsafe extern "C" fn()>,
+}
+#[doc = " Structure to define a Suricata plugin."]
+pub type SCPlugin = SCPlugin_;
+pub type SCPluginRegisterFunc = ::std::option::Option<unsafe extern "C" fn() -> *mut SCPlugin>;
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct SCCapturePlugin_ {
+    pub name: *mut ::std::os::raw::c_char,
+    pub Init: ::std::option::Option<
+        unsafe extern "C" fn(
+            args: *const ::std::os::raw::c_char,
+            plugin_slot: ::std::os::raw::c_int,
+            receive_slot: ::std::os::raw::c_int,
+            decode_slot: ::std::os::raw::c_int,
+        ),
+    >,
+    pub ThreadInit: ::std::option::Option<
+        unsafe extern "C" fn(
+            ctx: *mut ::std::os::raw::c_void,
+            thread_id: ::std::os::raw::c_int,
+            thread_ctx: *mut *mut ::std::os::raw::c_void,
+        ) -> ::std::os::raw::c_int,
+    >,
+    pub ThreadDeinit: ::std::option::Option<
+        unsafe extern "C" fn(
+            ctx: *mut ::std::os::raw::c_void,
+            thread_ctx: *mut ::std::os::raw::c_void,
+        ) -> ::std::os::raw::c_int,
+    >,
+    pub GetDefaultMode:
+        ::std::option::Option<unsafe extern "C" fn() -> *const ::std::os::raw::c_char>,
+    pub entries: SCCapturePlugin___bindgen_ty_1,
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct SCCapturePlugin___bindgen_ty_1 {
+    pub tqe_next: *mut SCCapturePlugin_,
+    pub tqe_prev: *mut *mut SCCapturePlugin_,
+}
+pub type SCCapturePlugin = SCCapturePlugin_;
+extern "C" {
+    pub fn SCPluginRegisterCapture(arg1: *mut SCCapturePlugin) -> ::std::os::raw::c_int;
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct SCAppLayerPlugin_ {
+    pub version: u64,
+    pub name: *mut ::std::os::raw::c_char,
+    pub Register: ::std::option::Option<unsafe extern "C" fn()>,
+    pub KeywordsRegister: ::std::option::Option<unsafe extern "C" fn()>,
+    pub logname: *mut ::std::os::raw::c_char,
+    pub confname: *mut ::std::os::raw::c_char,
+    pub Logger: ::std::option::Option<
+        unsafe extern "C" fn(
+            tx: *mut ::std::os::raw::c_void,
+            jb: *mut ::std::os::raw::c_void,
+        ) -> bool,
+    >,
+}
+pub type SCAppLayerPlugin = SCAppLayerPlugin_;
+extern "C" {
+    pub fn SCPluginRegisterAppLayer(arg1: *mut SCAppLayerPlugin) -> ::std::os::raw::c_int;
+}
index 9db5d0f6091dd399d34c3c7f9aafa12715c0a1f0..6f491b2a2a96f9ae98fc8c54081fa1de68eb5cb9 100644 (file)
@@ -30,5 +30,6 @@
 #include "stdbool.h"
 
 #include "app-layer-protos.h"
+#include "suricata-plugin.h"
 
 #endif