Commit graph

95 commits

Author SHA1 Message Date
Jason Ish
3dc8b154f3 rust/ffi: add safe thread storage wrapper
Add a typed ThreadStorage<T> wrapper around the thread storage bindings.

Ticket: #8445
2026-06-01 15:56:57 +00:00
Jason Ish
5e0abf1572 rust/ffi: use ThreadVars wrapper in flow callbacks
Update the flow init, update and finish callback registrations to pass the
safe ThreadVars wrapper instead of a raw pointer.

Ticket: #8598
2026-06-01 15:56:57 +00:00
Jason Ish
1cac242948 rust/ffi: use ThreadVars wrapper in eve callback
Update the EVE callback registration to pass the safe ThreadVars wrapper
instead of a raw pointer.

Ticket: #8598
2026-06-01 15:56:57 +00:00
Jason Ish
45762aa644 rust/ffi: use ThreadVars wrapper in thread init callback
Update the thread init callback registration to pass the safe ThreadVars
wrapper instead of a raw pointer.

Ticket: #8598
2026-06-01 15:56:57 +00:00
Jason Ish
144f824f17 rust/ffi: add thread init callback wrapper
Ticket: #8605
2026-05-28 20:49:57 +00:00
Jason Ish
e1a2a36ee7 examples/plugins/rust: misc cleanups
- Remove registration helper
- Limit function visibility
2026-05-28 20:49:56 +00:00
Promise Charles
5c9602bcf2 suricata: add error about missing runmode
If a runmode is missing but other params are passed on the commandline,
issue an error.

Ticket: #5711

Signed-off-by: Promise Charles <descencybobby@gmail.com>
2026-05-23 18:01:37 +00:00
Philippe Antoine
5db471500c rust/ffi: remove altemplate plugin last dependency on suricata crate
Ticket: 7666
2026-05-20 17:57:52 +00:00
Jason Ish
5e2a33d080 examples: add flow callbacks to rust plugin example
Ticket: #8446
2026-05-09 04:17:38 +00:00
Philippe Antoine
5ed394b26b rust/ffi: move AppLayerEvent to ffi
Ticket: 7666
2026-05-06 18:58:47 +00:00
Philippe Antoine
9b12fd9f09 rust/ffi: move helper trait state_get_tx_iterator to ffi
Ticket: 7666
2026-04-30 05:38:06 +00:00
Philippe Antoine
07f37676b6 rust/ffi: move Flags for AppLayerParserState to ffi crate
Ticket: 7666
2026-04-30 05:38:06 +00:00
Philippe Antoine
fb20c69d8d rust/ffi: move APP_LAYER_PARSER_OPT_X const to ffi crate
Ticket: 7666
2026-04-30 05:38:06 +00:00
Philippe Antoine
9677851637 rust/ffi: move app-layer traits to ffi crate
Ticket: 7666

Traits around structures defined in C and bindgened to rust
2026-04-25 17:37:13 +00:00
Philippe Antoine
f803c25f24 rust/ffi: move export_X_data_get macros to ffi crate
Ticket: 7666
2026-04-25 17:37:13 +00:00
Jason Ish
f5bf76c0ee examples/plugins/rust: add a rust example plugin
Only demonstrates EVE callbacks for now, but I plan to turn this into a
show case of a variety of callbacks a Rust plugin can do as we add Rust
bindings to the ffi crate.
2026-04-16 05:58:15 +00:00
Philippe Antoine
58a71d94b0 rust/ffi: move conf_get helper to ffi crate
Ticket: 7666
2026-04-13 05:01:54 +00:00
Philippe Antoine
c53b9df5a2 rust/ffi: move detection helpers to ffi crate
Some checks failed
builds / Fedora (non-root, debug, clang, asan, wshadow, rust-strict, no-ja) (push) Has been cancelled
builds / AlmaLinux 9 (no jansson) (push) Has been cancelled
builds / AlmaLinux 9 (Minimal/Recommended Build) (push) Has been cancelled
builds / Ubuntu 24.04 (cocci) (push) Has been cancelled
builds / Ubuntu 24.04 (RUSTC+CARGO vars) (push) Has been cancelled
builds / Ubuntu 24.04 (unittests coverage) (push) Has been cancelled
builds / Ubuntu 24.04 (unix socket mode coverage) (push) Has been cancelled
builds / Ubuntu 24.04 (afpacket and dpdk coverage) (push) Has been cancelled
builds / Ubuntu 24.04 (pcap unix socket ASAN) (push) Has been cancelled
builds / Ubuntu 24.04 (afpacket IPS tests in namespaces) (push) Has been cancelled
builds / Ubuntu 24.04 (afpacket and dpdk live tests with ASAN) (push) Has been cancelled
builds / Ubuntu 24.04 (fuzz corpus coverage) (push) Has been cancelled
builds / Ubuntu 20.04 (-DNDEBUG) (push) Has been cancelled
builds / Ubuntu 20.04 (unsupported rust) (push) Has been cancelled
builds / Ubuntu 22.04 (Debug Validation) (push) Has been cancelled
builds / Ubuntu 22.04 (Fuzz) (push) Has been cancelled
builds / Ubuntu 22.04 (Netmap build) (push) Has been cancelled
builds / Ubuntu 22.04 (Minimal/Recommended Build) (push) Has been cancelled
builds / Ubuntu 22.04 (DPDK Build) (push) Has been cancelled
builds / Debian 12 (xdp) (push) Has been cancelled
builds / Debian 13 (xdp) (push) Has been cancelled
builds / Ubuntu 22.04 Dist Builder (push) Has been cancelled
builds / Debian 12 MSRV (push) Has been cancelled
builds / Debian 11 (push) Has been cancelled
builds / MacOS Latest (push) Has been cancelled
builds / Windows MSYS2 MINGW64 (NPcap) (push) Has been cancelled
builds / Windows MSYS2 MINGW64 (libpcap) (push) Has been cancelled
builds / Windows MSYS2 UCRT64 (libpcap) (push) Has been cancelled
builds / Windows MSYS2 MINGW64 (WinDivert) (push) Has been cancelled
builds / PF_RING (push) Has been cancelled
Ticket: 7666
2026-04-01 19:55:48 +00:00
Philippe Antoine
f61247e846 plugin: remove one small suricata crate dependency 2026-03-26 19:23:02 +00:00
Philippe Antoine
267c3baff7 rust/ffi: move STREAM_ constants to ffi crate
Ticket: 7666

reexport them in suricata crate
cbindgen them to C
2026-03-26 19:23:02 +00:00
Philippe Antoine
d77c43c79b rust/ffi: move build_slice macro to ffi crate
Ticket: 7666
2026-03-06 21:30:44 +00:00
Philippe Antoine
4a0143c8d4 rust/ffi: move cast_pointer macro to ffi crate
Ticket: 7666
2026-03-06 21:30:44 +00:00
Jason Ish
f711e57e8e examples/lib/live: a lib example with live capture
Simple libpcap example for live capture. Allows listening on multiple
interfaces to show how multiple threads (workers) can be used.

Ticket: #8096
2026-03-05 21:21:09 +00:00
Jason Ish
7dd23392cc examples/lib/cplusplus: simplfy, make more like the simple example
To prep for the removal of the lib runmode, simplify this C++ example
to match our simple example. We don't yet have the C++ compatible
headers to allow for a C++ app to register its own custom runmode.
2026-03-05 21:21:09 +00:00
Jason Ish
445de77c71 examples/lib/custom: use own custom run mode
Debug validation revealed that library ThreadVars were being
created *after* the threads were sealed. And the only way to create
your ThreadVars that fits within the current application life-cycle is
to create them in your own custom run mode.

This is likely a better model for users who are bringing their own
packets and threads anyways, as they are essentially providing their
own capture method, and all capture methods provide their own run
mode. They're also using their own threads, which means adapting to
their own threading model.

This is suitable for a backport to 8.0. But for 9.0 we can go further
and remove the built-in library run mode, which will be done in a
follow-up commit.

Ticket: #8259
2026-03-05 21:21:09 +00:00
Philippe Antoine
71b59f6dbe rust/ffi: move IPPROTO_TCP to ffi
and reexport in suricata

Allows to reduce dependencies to full suricata crate

Ticket: 7666
2026-02-24 05:56:40 +00:00
Philippe Antoine
2a90cef318 plugin: reduce dependency on suricata crate
Ticket: 7666

The end goal is to remove all dependencies on suricata and just
use suricata_sys or suricata_ffi

For now, make usage of what is already available
2026-02-24 05:56:40 +00:00
Jason Ish
d230a760e6 examples/altemplate: update to use jsonbuilder from ffi crate
Some checks failed
builds / AlmaLinux 9 (no jansson) (push) Has been cancelled
builds / AlmaLinux 9 (Minimal/Recommended Build) (push) Has been cancelled
builds / Ubuntu 24.04 (cocci) (push) Has been cancelled
builds / Ubuntu 24.04 (RUSTC+CARGO vars) (push) Has been cancelled
builds / Ubuntu 24.04 (unittests coverage) (push) Has been cancelled
builds / Ubuntu 22.04 (unix socket mode coverage) (push) Has been cancelled
builds / Ubuntu 22.04 (afpacket and dpdk coverage) (push) Has been cancelled
builds / Ubuntu 24.04 (pcap unix socket ASAN) (push) Has been cancelled
builds / Ubuntu 24.04 (afpacket IPS tests in namespaces) (push) Has been cancelled
builds / Ubuntu 24.04 (afpacket and dpdk live tests with ASAN) (push) Has been cancelled
builds / Ubuntu 22.04 (fuzz corpus coverage) (push) Has been cancelled
builds / Ubuntu 20.04 (-DNDEBUG) (push) Has been cancelled
builds / Ubuntu 20.04 (unsupported rust) (push) Has been cancelled
builds / Ubuntu 22.04 (Debug Validation) (push) Has been cancelled
builds / Ubuntu 22.04 (Fuzz) (push) Has been cancelled
builds / Ubuntu 22.04 (Netmap build) (push) Has been cancelled
builds / Ubuntu 22.04 (Minimal/Recommended Build) (push) Has been cancelled
builds / Ubuntu 22.04 (DPDK Build) (push) Has been cancelled
builds / Debian 12 (xdp) (push) Has been cancelled
builds / Debian 13 (xdp) (push) Has been cancelled
builds / Ubuntu 22.04 Dist Builder (push) Has been cancelled
builds / Debian 12 MSRV (push) Has been cancelled
builds / Debian 11 (push) Has been cancelled
builds / MacOS Latest (push) Has been cancelled
builds / Windows MSYS2 MINGW64 (NPcap) (push) Has been cancelled
builds / Windows MSYS2 MINGW64 (libpcap) (push) Has been cancelled
builds / Windows MSYS2 UCRT64 (libpcap) (push) Has been cancelled
builds / Windows MSYS2 MINGW64 (WinDivert) (push) Has been cancelled
builds / PF_RING (push) Has been cancelled
docs / Ubuntu 22.04 Dist Builder (push) Has been cancelled
2026-02-13 13:34:27 +00:00
Jason Ish
f79158ae55 rust/sys: generate jsonbuilder bindings in sys
Bindgen the Rust bindings to the C JsonBuilder API along with the rest
of the Rust bindings to C. Breaking it out was probably the wrong
idea.

This should make it easier, and more correct to bindgen C functions
that use SCJsonBuilder types.
2026-02-13 13:34:27 +00:00
Jason Ish
8e3bd1ca55 examples/altemplate: use suricata-ffi for logging macros 2026-02-13 13:34:26 +00:00
Philippe Antoine
364d2c077d rust: bindgen SCAppLayerRegisterParser
Ticket: 7662
2026-02-05 21:11:16 +00:00
Philippe Antoine
c960b7d7c1 app-layer: AppLayerParserFPtr uses a mut pointer to local storage
So, fix the fn prototype in rust ParseFn
2026-01-16 21:07:38 +00:00
Philippe Antoine
455b7d1b3b rust: use snake case for applayer_register_protocol_detection 2025-12-11 04:30:43 +00:00
Victor Julien
46203de0e9 doc: adjust for master to main rename 2025-09-16 17:20:56 +02:00
Jason Ish
116d1763d9 lib: opt-in signal handlers
Instead of enabling signal handlers by default, require the user of
the library to opt-in. This is done with the call to
SCEnableDefaultSignalHandlers, which sets a flag to add the default
signal handlers.

This seems like the least invasive way to do this at this time, but it
will require some re-thinking for 9.0, especially if migrate globals
to engine instances, signal handling will need to be re-thought.

Ticket: #6814
2025-07-02 21:38:42 +02:00
Philippe Antoine
6dbc421825 rust: bindgen AppLayerParserConfParserEnabled
Ticket: 7667
2025-06-10 22:13:53 +02:00
Philippe Antoine
49b2a2be5d rust: bindgen SCAppLayerParserRegisterLogger
Ticket: 7667
2025-06-10 22:13:53 +02:00
Philippe Antoine
b29d46d81f rust: bindgen SCAppLayerParserStateIssetFlag
Ticket: 7667
2025-06-10 22:13:53 +02:00
Jason Ish
25e32f4f7a output: delayed initialization for custom loggers
When a plugin is first initialized, it is too early to register
transaction loggers. Instead, a plugin can register a callback to be
called when Suricata is ready for outputs like transaction loggers to
be registered.

Likewise for library users, there is a window in SuricataInit where
transaction loggers can be registered that library users don't have
access to. So a lifecycle callback useful here as well.

Ticket #7236
2025-06-07 10:36:46 +02:00
Philippe Antoine
7bb0c94ae9 rust: bindgen app-layer-detect-proto.h
Ticket: 7667
2025-06-05 19:14:33 +02:00
Philippe Antoine
f2e7309bbb rust: use bindgened Flow definition
Ticket: 7667
2025-05-27 21:43:50 +02:00
Philippe Antoine
78034b218d rust: bindgen SCDetectSignatureSetAppProto
Ticket: 7667
2025-05-21 09:37:22 +02:00
Philippe Antoine
dc20129195 rust: bindgen SCDetectHelperBufferMpmRegister
Ticket: 7667
2025-05-16 21:33:55 +02:00
Philippe Antoine
e2603fa820 detect/single-buf: new simple wrapper
Introduce DetectGetSingleData which does the generic wrapping,
including the transforms, using a new callback prototype
DetectTxGetBufferPtr

The goal is to replace most InspectionBufferGetDataPtr.
For this commit, we do not change every callback to keep the
change relatively small.

Focus here is to remove DetectHelperGetData as its functionality is
provided more directly by the new DetectTxGetBufferPtr.
2025-05-16 21:33:55 +02:00
Jason Ish
14864d49ac examples/altemplate: remove rs_ naming 2025-05-05 21:41:03 +02:00
Jason Ish
60c429e04d detect: add callback for when rate filter changes action
This callback will be called when alert action has been changed due to a
rate filter. The user can then reset or customize the action in their
callback per their own logic.

As the callback is added to the current detection engine, make sure its
copied to the new detection engine on reload.

Ticket: #7673
2025-05-02 20:10:09 +02:00
Jason Ish
8540627b4e examples: add simple c++ example
For now just used to make sure a C++ variation of our custom example
can build.
2025-04-30 22:22:25 +02:00
Jason Ish
9d5158594f util-device: break into public and private definitions
util-device.h exposes some details that are particularly problematic
for C++, even when wrapped in 'extern "C"'. To address this, break the
header into public and private parts. The public part exposes
LiveDevice as an opaque data structure, while the private header has
the actual definition.

The idea is that only Suricata C source files should include the
private header, it should not be re-included in any other header
file. And this is the header library users should use, however we
don't enforce it with tecnical means, a library user could still
include the private header, but the clue there is in the name.
2025-04-30 22:22:25 +02:00
Victor Julien
ff0d609a9f threads: rename function to make scope more clear
SCTmThreadsSlotPktAcqLoopFinish ss now used outside of
just pktacq as well.
2025-04-30 22:22:23 +02:00
Philippe Antoine
033e0480cf detect/single-buf: helper with more explicit direction 2025-04-28 20:06:09 +02:00