From 8f22e55678c621b93a92b51dd8023276c8064c46 Mon Sep 17 00:00:00 2001 From: Jason Ish Date: Thu, 23 Jan 2025 16:19:09 -0600 Subject: [PATCH] rust/sys: stub in suricata-sys crate for Rust bindings to C Follow Rust convention of using a "sys" crate for bindings to C functions. The bindings don't exist yet, but will be generated by bindgen and put into this crate. Ticket: #7341 --- configure.ac | 1 + rust/Cargo.lock.in | 5 +++++ rust/Cargo.toml.in | 3 ++- rust/Makefile.am | 6 +++++- rust/sys/Cargo.toml.in | 6 ++++++ rust/sys/Makefile.am | 3 +++ rust/sys/src/lib.rs | 16 ++++++++++++++++ 7 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 rust/sys/Cargo.toml.in create mode 100644 rust/sys/Makefile.am create mode 100644 rust/sys/src/lib.rs diff --git a/configure.ac b/configure.ac index 360c354ebc..9b4db2ba1f 100644 --- a/configure.ac +++ b/configure.ac @@ -2536,6 +2536,7 @@ AC_SUBST(enable_non_bundled_htp) AM_CONDITIONAL([BUILD_SHARED_LIBRARY], [test "x$enable_shared" = "xyes"] && [test "x$can_build_shared_library" = "xyes"]) 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(qa/Makefile qa/coccinelle/Makefile) AC_CONFIG_FILES(rules/Makefile doc/Makefile doc/userguide/Makefile) AC_CONFIG_FILES(contrib/Makefile contrib/file_processor/Makefile contrib/file_processor/Action/Makefile contrib/file_processor/Processor/Makefile) diff --git a/rust/Cargo.lock.in b/rust/Cargo.lock.in index 2f9dd776ac..f48fa14081 100644 --- a/rust/Cargo.lock.in +++ b/rust/Cargo.lock.in @@ -1010,6 +1010,7 @@ dependencies = [ "snmp-parser", "suricata-derive", "suricata-lua-sys", + "suricata-sys", "test-case", "time", "tls-parser", @@ -1037,6 +1038,10 @@ dependencies = [ "fs_extra", ] +[[package]] +name = "suricata-sys" +version = "8.0.0-dev" + [[package]] name = "syn" version = "1.0.109" diff --git a/rust/Cargo.toml.in b/rust/Cargo.toml.in index e3c469dc88..b01e4c570c 100644 --- a/rust/Cargo.toml.in +++ b/rust/Cargo.toml.in @@ -7,7 +7,7 @@ edition = "2021" rust-version = "1.67.1" [workspace] -members = [".", "./derive"] +members = [".", "./derive", "sys"] [lib] crate-type = ["staticlib", "rlib"] @@ -68,6 +68,7 @@ hex = "~0.4.3" time = "~0.3.36" suricata-derive = { path = "./derive", version = "@PACKAGE_VERSION@" } +suricata-sys = { path = "./sys", version = "@PACKAGE_VERSION@" } suricata-lua-sys = { version = "0.1.0-alpha.6" } diff --git a/rust/Makefile.am b/rust/Makefile.am index a47a1c1534..7abd37d220 100644 --- a/rust/Makefile.am +++ b/rust/Makefile.am @@ -1,10 +1,14 @@ +SUBDIRS = sys + EXTRA_DIST = src derive \ .cargo/config.toml.in \ cbindgen.toml \ dist/rust-bindings.h \ vendor \ Cargo.toml Cargo.lock \ - derive/Cargo.toml + derive/Cargo.toml \ + sys \ + sys/Cargo.toml if !DEBUG RELEASE = --release diff --git a/rust/sys/Cargo.toml.in b/rust/sys/Cargo.toml.in new file mode 100644 index 0000000000..518fe36db9 --- /dev/null +++ b/rust/sys/Cargo.toml.in @@ -0,0 +1,6 @@ +[package] +name = "suricata-sys" +version = "@PACKAGE_VERSION@" +edition = "2021" +license = "GPL-2.0-only" +description = "Bindings to Suricata C interface" diff --git a/rust/sys/Makefile.am b/rust/sys/Makefile.am new file mode 100644 index 0000000000..acf00aeb68 --- /dev/null +++ b/rust/sys/Makefile.am @@ -0,0 +1,3 @@ +EXTRA_DIST = Cargo.toml + +all-local: Cargo.toml diff --git a/rust/sys/src/lib.rs b/rust/sys/src/lib.rs new file mode 100644 index 0000000000..48917a9d99 --- /dev/null +++ b/rust/sys/src/lib.rs @@ -0,0 +1,16 @@ +/* Copyright (C) 2025 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. + */ -- 2.47.2