From 10ede915369b87d0bab830bd290265e4786038a7 Mon Sep 17 00:00:00 2001 From: Jason Ish Date: Fri, 24 Jan 2025 09:56:58 -0600 Subject: [PATCH] rust: add bindings to SCPlugin.* to sys crate 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 | 3 ++ rust/sys/src/sys.rs | 71 +++++++++++++++++++++++++++++++++++++++++++++ src/bindgen.h | 1 + 3 files changed, 75 insertions(+) diff --git a/rust/Makefile.am b/rust/Makefile.am index b1791b001d..a751bb85a3 100644 --- a/rust/Makefile.am +++ b/rust/Makefile.am @@ -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) diff --git a/rust/sys/src/sys.rs b/rust/sys/src/sys.rs index 1c358f7b5a..cf6f060a3e 100644 --- a/rust/sys/src/sys.rs +++ b/rust/sys/src/sys.rs @@ -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, +} +#[doc = " Structure to define a Suricata plugin."] +pub type SCPlugin = SCPlugin_; +pub type SCPluginRegisterFunc = ::std::option::Option *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 *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, + pub KeywordsRegister: ::std::option::Option, + 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; +} diff --git a/src/bindgen.h b/src/bindgen.h index 9db5d0f609..6f491b2a2a 100644 --- a/src/bindgen.h +++ b/src/bindgen.h @@ -30,5 +30,6 @@ #include "stdbool.h" #include "app-layer-protos.h" +#include "suricata-plugin.h" #endif -- 2.47.2