]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
rust: compatibility with cbindgen 0.27 11622/head
authorPhilippe Antoine <pantoine@oisf.net>
Mon, 12 Aug 2024 12:55:22 +0000 (14:55 +0200)
committerPhilippe Antoine <pantoine@oisf.net>
Mon, 12 Aug 2024 12:55:22 +0000 (14:55 +0200)
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.

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

index 5a29be257b94fbd02a22f602a79b1c734a902483..92bab1d82fb0e97debacc1567ace8ff7cda1f3c3 100644 (file)
@@ -459,6 +459,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);
@@ -470,6 +471,7 @@ pub unsafe fn AppLayerRegisterParser(parser: *const RustParser, alproto: AppProt
 }
 
 // Defined in app-layer-detect-proto.h
+/// cbindgen:ignore
 extern {
     pub fn AppLayerForceProtocolChange(f: *const Flow, new_proto: AppProto);
     pub fn AppLayerProtoDetectPPRegister(ipproto: u8, portstr: *const c_char, alproto: AppProto,
@@ -506,6 +508,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 bca228131124ef07194f29d307fd671e6fe0b14d..a628b300384a4a16c0302382088da83343d61cb0 100644 (file)
@@ -135,6 +135,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;
 }
@@ -239,6 +240,7 @@ pub struct SuricataFileContext {
     pub files_sbcfg: &'static StreamingBufferConfig,
 }
 
+/// cbindgen:ignore
 extern {
     pub fn SCGetContext() -> &'static mut SuricataContext;
     pub fn SCLogGetLogLevel() -> i32;
@@ -305,6 +307,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 15f7a40918f5e7d24523a7205cae0146f0fbb400..b09af4fb98ed468e2b9b4a1be263f62b940537e0 100644 (file)
@@ -77,6 +77,7 @@ pub struct SCSigTableElmt {
 pub(crate) const SIGMATCH_NOOPT: u16 = 1; // BIT_U16(0) in detect.h
 pub(crate) const SIGMATCH_INFO_STICKY_BUFFER: u16 = 0x200; // BIT_U16(9)
 
+/// cbindgen:ignore
 extern {
     pub fn DetectBufferSetActiveList(de: *mut c_void, s: *mut c_void, bufid: c_int) -> c_int;
     pub fn DetectHelperGetData(
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 1d8ce40ef16d32b158c2ea27de2180a90569601f..2380a51594da27513ab0122037ab72c1835fa21b 100644 (file)
@@ -30,6 +30,7 @@ struct CFrame {
 }
 
 // Defined in app-layer-register.h
+/// cbindgen:ignore
 extern {
     #[cfg(not(test))]
     fn AppLayerFrameNewByRelativeOffset(
index 0f8f34aa7dc5dc5d3e376c3f15201a1ca6c0501f..389b79062aaf6e7606b7cb6c14d8d3f6ff6b2781 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 33dfe375f4bdaa50e0eeb8c65abf190ce55df71a..e68ba18be564f36451bce5013b16991ae484e4a3 100644 (file)
@@ -24,6 +24,7 @@ use std::os::raw::c_long;
 /// 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);