From 2c51744ccc755cbba4efb90b0ecc525c0250860f Mon Sep 17 00:00:00 2001 From: Jason Ish Date: Wed, 4 Feb 2026 10:30:38 -0600 Subject: [PATCH] rust/ffi: stub out a rust ffi crate This crate is for Rust wrappers around the -sys crate which includes only raw bindings. This is the place to add nice wrappers around those bindings, however it should remain clear of dependencies on the main Suricata core crates. Ticket: #7666 --- .github/workflows/rust.yml | 3 +++ configure.ac | 1 + rust/Cargo.lock.in | 4 ++++ rust/Cargo.toml.in | 1 + rust/Makefile.am | 4 +++- rust/ffi/Cargo.toml.in | 6 ++++++ rust/ffi/Makefile.am | 3 +++ rust/ffi/src/lib.rs | 16 ++++++++++++++++ 8 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 rust/ffi/Cargo.toml.in create mode 100644 rust/ffi/Makefile.am create mode 100644 rust/ffi/src/lib.rs diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 06797f44d7..4ef23f99d3 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -112,3 +112,6 @@ jobs: # does not work in other subdirectories for now - run: cargo fmt --check working-directory: rust/htp + # The ffi crate is cargo fmt clean. + - run: cargo fmt --check + working-directory: rust/ffi diff --git a/configure.ac b/configure.ac index 0c8376358e..f3909ed610 100644 --- a/configure.ac +++ b/configure.ac @@ -2558,6 +2558,7 @@ AM_CONDITIONAL([BUILD_SHARED_LIBRARY], [test "x$enable_shared" = "xyes"] && [tes AC_CONFIG_FILES(Makefile src/Makefile rust/Makefile rust/Cargo.lock rust/Cargo.toml rust/derive/Cargo.toml rust/.cargo/config.toml) AC_CONFIG_FILES(rust/sys/Makefile rust/sys/Cargo.toml) +AC_CONFIG_FILES(rust/ffi/Makefile rust/ffi/Cargo.toml) AC_CONFIG_FILES(rust/suricatactl/Makefile rust/suricatactl/Cargo.toml) AC_CONFIG_FILES(rust/suricatasc/Makefile rust/suricatasc/Cargo.toml) AC_CONFIG_FILES(rust/htp/Makefile rust/htp/Cargo.toml) diff --git a/rust/Cargo.lock.in b/rust/Cargo.lock.in index d47cdd197b..283c1aaeae 100644 --- a/rust/Cargo.lock.in +++ b/rust/Cargo.lock.in @@ -1603,6 +1603,10 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "suricata-ffi" +version = "9.0.0-dev" + [[package]] name = "suricata-htp" version = "9.0.0-dev" diff --git a/rust/Cargo.toml.in b/rust/Cargo.toml.in index 22e1660621..94ddfaa939 100644 --- a/rust/Cargo.toml.in +++ b/rust/Cargo.toml.in @@ -13,6 +13,7 @@ members = [ "suricatactl", "suricatasc", "sys", + "ffi", "htp", ] diff --git a/rust/Makefile.am b/rust/Makefile.am index dce38d127e..9d70c6e0db 100644 --- a/rust/Makefile.am +++ b/rust/Makefile.am @@ -1,4 +1,5 @@ -SUBDIRS = htp \ +SUBDIRS = ffi \ + htp \ sys \ suricatasc \ suricatactl @@ -11,6 +12,7 @@ EXTRA_DIST = .cargo/config.toml.in \ derive/Cargo.toml \ dist/htp/htp_rs.h \ dist/rust-bindings.h \ + ffi \ htp \ src \ suricatactl \ diff --git a/rust/ffi/Cargo.toml.in b/rust/ffi/Cargo.toml.in new file mode 100644 index 0000000000..a9d66d3282 --- /dev/null +++ b/rust/ffi/Cargo.toml.in @@ -0,0 +1,6 @@ +[package] +name = "suricata-ffi" +version = "@PACKAGE_VERSION@" +edition = "2021" +license = "GPL-2.0-only" +description = "Nice wrappers around Suricata C interface" diff --git a/rust/ffi/Makefile.am b/rust/ffi/Makefile.am new file mode 100644 index 0000000000..acf00aeb68 --- /dev/null +++ b/rust/ffi/Makefile.am @@ -0,0 +1,3 @@ +EXTRA_DIST = Cargo.toml + +all-local: Cargo.toml diff --git a/rust/ffi/src/lib.rs b/rust/ffi/src/lib.rs new file mode 100644 index 0000000000..fb5ac17780 --- /dev/null +++ b/rust/ffi/src/lib.rs @@ -0,0 +1,16 @@ +/* Copyright (C) 2026 Open Information Security Foundation + * + * You can copy, redistribute or modify this Program under the terms of + * the GNU General Public License version 2 as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * version 2 along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */