]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
rust: compatibility with cbindgen 0.27 11626/head
authorPhilippe Antoine <pantoine@oisf.net>
Mon, 12 Aug 2024 12:55:22 +0000 (14:55 +0200)
committerJason Ish <jason.ish@oisf.net>
Tue, 13 Aug 2024 15:12:47 +0000 (09:12 -0600)
Ticket: 7206

Cbindgen 0.27 now handles extern blocks as extern "C" blocks.
The way to differentiate them is to use a special comment
before the block.

(cherry picked from commit 304271e63a9e388412f25f0f94a1a0da4bf619d9)

rust/src/applayer.rs
rust/src/conf.rs
rust/src/core.rs
rust/src/filecontainer.rs
rust/src/frames.rs
rust/src/lib.rs
rust/src/lua.rs

index 7c00af465c1749c356592c09a4a62785756dc5fd..ff19d87632343b33eb84a20d895a2bf474b8de24 100644 (file)
@@ -464,6 +464,7 @@ pub type GetFrameNameById = unsafe extern "C" fn(u8) -> *const c_char;
 
 
 // Defined in app-layer-register.h
+/// cbindgen:ignore
 extern {
     pub fn AppLayerRegisterProtocolDetection(parser: *const RustParser, enable_default: c_int) -> AppProto;
     pub fn AppLayerRegisterParserAlias(parser_name: *const c_char, alias_name: *const c_char);
@@ -475,6 +476,7 @@ pub unsafe fn AppLayerRegisterParser(parser: *const RustParser, alproto: AppProt
 }
 
 // Defined in app-layer-detect-proto.h
+/// cbindgen:ignore
 extern {
     pub fn AppLayerProtoDetectPPRegister(ipproto: u8, portstr: *const c_char, alproto: AppProto,
                                          min_depth: u16, max_depth: u16, dir: u8,
@@ -509,6 +511,7 @@ pub const APP_LAYER_PARSER_OPT_ACCEPT_GAPS: u32 = BIT_U32!(0);
 
 pub const APP_LAYER_TX_SKIP_INSPECT_FLAG: u64 = BIT_U64!(62);
 
+/// cbindgen:ignore
 extern {
     pub fn AppLayerParserStateSetFlag(state: *mut c_void, flag: u16);
     pub fn AppLayerParserStateIssetFlag(state: *mut c_void, flag: u16) -> u16;
index 0d28f4d8b494b1e0c13a888c60f8894cc3fa5c68..50cc07257009938dce64e13521ed1ef20b976150 100644 (file)
@@ -31,6 +31,7 @@ use nom7::{
     IResult,
 };
 
+/// cbindgen:ignore
 extern {
     fn ConfGet(key: *const c_char, res: *mut *const c_char) -> i8;
     fn ConfGetChildValue(conf: *const c_void, key: *const c_char,
index abb27ea578fe6c8abf9ce5b18cc46ed8a0dc2458..61d391e11bbb6cb05b5a15b368901290b3fe77e1 100644 (file)
@@ -128,6 +128,7 @@ macro_rules!BIT_U64 {
 pub const FLOW_DIR_REVERSED: u32 = BIT_U32!(26);
 
 // Defined in app-layer-protos.h
+/// cbindgen:ignore
 extern {
     pub fn StringToAppProto(proto_name: *const u8) -> AppProto;
 }
@@ -232,6 +233,7 @@ pub struct SuricataFileContext {
     pub files_sbcfg: &'static StreamingBufferConfig,
 }
 
+/// cbindgen:ignore
 extern {
     pub fn SCGetContext() -> &'static mut SuricataContext;
     pub fn SCLogGetLogLevel() -> i32;
@@ -298,6 +300,7 @@ pub fn sc_app_layer_decoder_events_free_events(
 pub enum Flow {}
 
 // Extern functions operating on Flow.
+/// cbindgen:ignore
 extern {
     pub fn FlowGetLastTimeAsParts(flow: &Flow, secs: *mut u64, usecs: *mut u64);
     pub fn FlowGetFlags(flow: &Flow) -> u32;
index 3a8bde5f7d5b4ab536d8fd9c9f14db27cd123b4d..28d10cf05cf200aab2ea1f2c435951dddffb7e1a 100644 (file)
@@ -23,6 +23,7 @@ use std::os::raw::{c_void};
 use crate::core::*;
 
 // Defined in util-file.h
+/// cbindgen:ignore
 extern {
     pub fn FileFlowFlagsToFlags(flow_file_flags: u16, flags: u8) -> u16;
 }
index 3a45d014b47214793e5799fe3e0fb95993d409bd..3496caa69428f434e31601eed84c5362adf9f4a9 100644 (file)
@@ -30,6 +30,7 @@ struct CFrame {
 }
 
 // Defined in app-layer-register.h
+/// cbindgen:ignore
 extern {
     #[cfg(not(test))]
     fn AppLayerFrameNewByRelativeOffset(
index 9e58d4d805e8a22f64e536c4c047880a95d25aca..7091e73e823f28967933a566cc7ac59ca0c11e05 100644 (file)
 // just due to FFI.
 #![allow(clippy::missing_safety_doc)]
 
+// Allow /// cbindgen:ignore comments on extern blocks
+// cf https://github.com/mozilla/cbindgen/issues/709
+#![allow(unused_doc_comments)]
+
 #[macro_use]
 extern crate bitflags;
 extern crate byteorder;
index 4fce2a824944fd3c99b6e29eb40e95d81f843b3d..a8cfc7417518cccc37001e85b4b44fea0866f59b 100644 (file)
@@ -30,6 +30,7 @@ type LuaInteger = i32;
 /// The Rust place holder for lua_State.
 pub enum CLuaState {}
 
+/// cbindgen:ignore
 extern {
     fn lua_createtable(lua: *mut CLuaState, narr: c_int, nrec: c_int);
     fn lua_settable(lua: *mut CLuaState, idx: c_long);