From 3e4f19663e28907e977f53d5d39740c44d6b515e Mon Sep 17 00:00:00 2001 From: Jason Ish Date: Wed, 23 Oct 2024 13:03:25 -0600 Subject: [PATCH] app-layer: export to SCAppLayerStateGetEventInfoByFn with bindgen Rust will now fail, as the discrepancy between i8 and i32 is picked up. --- rust/src/applayer.rs | 3 +-- src/app-layer-ext.h | 2 ++ src/app-layer-register.h | 3 +-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/rust/src/applayer.rs b/rust/src/applayer.rs index 3ed33b88acad..a7136cde0522 100644 --- a/rust/src/applayer.rs +++ b/rust/src/applayer.rs @@ -374,7 +374,7 @@ pub struct RustParser { /// Function to get an event id from a description pub get_eventinfo: crate::sys::SCAppLayerStateGetEventInfoFn, /// Function to get an event description from an event id - pub get_eventinfo_byid: Option, + pub get_eventinfo_byid: crate::sys::SCAppLayerStateGetEventInfoByIdFn, /// Function to allocate local storage pub localstorage_new: Option, @@ -443,7 +443,6 @@ pub type StateFreeFn = unsafe extern "C" fn (*mut c_void); pub type StateTxFreeFn = unsafe extern "C" fn (*mut c_void, u64); pub type StateGetTxFn = unsafe extern "C" fn (*mut c_void, u64) -> *mut c_void; pub type StateGetTxCntFn = unsafe extern "C" fn (*mut c_void) -> u64; -pub type GetEventInfoByIdFn = unsafe extern "C" fn (c_int, *mut *const c_char, *mut AppLayerEventType) -> i8; pub type LocalStorageNewFn = extern "C" fn () -> *mut c_void; pub type LocalStorageFreeFn = extern "C" fn (*mut c_void); pub type GetTxFilesFn = unsafe extern "C" fn (*mut c_void, u8) -> AppLayerGetFileState; diff --git a/src/app-layer-ext.h b/src/app-layer-ext.h index fa7715ed3ce3..36cdfa7d4bfd 100644 --- a/src/app-layer-ext.h +++ b/src/app-layer-ext.h @@ -11,5 +11,7 @@ typedef enum AppLayerEventType { typedef int (*SCAppLayerStateGetProgressFn)(void *alstate, uint8_t direction); typedef int (*SCAppLayerStateGetEventInfoFn)( const char *event_name, int *event_id, AppLayerEventType *event_type); +typedef int (*SCAppLayerStateGetEventInfoByIdFn)( + int event_id, const char **event_name, AppLayerEventType *event_type); #endif /* SURICATA_APP_LAYER_EXT_H */ diff --git a/src/app-layer-register.h b/src/app-layer-register.h index 6d74998c837a..b0a6685fc9f3 100644 --- a/src/app-layer-register.h +++ b/src/app-layer-register.h @@ -53,8 +53,7 @@ typedef struct AppLayerParser { SCAppLayerStateGetProgressFn StateGetProgress; SCAppLayerStateGetEventInfoFn StateGetEventInfo; - int (*StateGetEventInfoById)(int event_id, const char **event_name, - AppLayerEventType *event_type); + SCAppLayerStateGetEventInfoByIdFn StateGetEventInfoById; void *(*LocalStorageAlloc)(void); void (*LocalStorageFree)(void *);