rust: move AppLayerEventType definition to C

and bindgen it to rust.

Will make easier the bindgen of RustParser structure which uses
a callback which uses AppLayerEventType
pull/14639/head
Philippe Antoine 8 months ago committed by Victor Julien
parent c960b7d7c1
commit 4b541b39f2

@ -144,6 +144,7 @@ if HAVE_BINDGEN
--allowlist-function 'AppProto.*' \ --allowlist-function 'AppProto.*' \
--allowlist-function 'File.*' \ --allowlist-function 'File.*' \
--allowlist-type 'SC.*' \ --allowlist-type 'SC.*' \
--allowlist-type 'AppLayerEventType' \
--allowlist-function 'SC.*' \ --allowlist-function 'SC.*' \
--allowlist-var 'SC.*' \ --allowlist-var 'SC.*' \
--opaque-type 'SCConfNode' \ --opaque-type 'SCConfNode' \

@ -23,13 +23,7 @@ use suricata_sys::sys::SCAppLayerParserTriggerRawStreamInspection;
use crate::flow::Flow; use crate::flow::Flow;
#[repr(C)] pub use suricata_sys::sys::AppLayerEventType;
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
#[allow(non_camel_case_types)]
pub enum AppLayerEventType {
APP_LAYER_EVENT_TYPE_TRANSACTION = 1,
APP_LAYER_EVENT_TYPE_PACKET = 2,
}
pub const STREAM_START: u8 = 0x01; pub const STREAM_START: u8 = 0x01;
pub const STREAM_EOF: u8 = 0x02; pub const STREAM_EOF: u8 = 0x02;

@ -925,14 +925,49 @@ extern "C" {
extern "C" { extern "C" {
pub fn AppProtoDetectListNames(); pub fn AppProtoDetectListNames();
} }
#[doc = " \\brief Data structure to store app layer decoder events."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct AppLayerDecoderEvents_ {
pub events: *mut u8,
pub cnt: u8,
pub events_buffer_size: u8,
pub event_last_logged: u8,
}
impl Default for AppLayerDecoderEvents_ {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[doc = " \\brief Data structure to store app layer decoder events."]
pub type AppLayerDecoderEvents = AppLayerDecoderEvents_;
#[repr(u32)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum AppLayerEventType {
APP_LAYER_EVENT_TYPE_TRANSACTION = 1,
APP_LAYER_EVENT_TYPE_PACKET = 2,
}
extern "C" {
pub fn SCAppLayerDecoderEventsSetEventRaw(sevents: *mut *mut AppLayerDecoderEvents, event: u8);
}
extern "C" {
pub fn SCAppLayerDecoderEventsFreeEvents(events: *mut *mut AppLayerDecoderEvents);
}
extern "C" {
pub fn SCAppLayerGetEventIdByName(
event_name: *const ::std::os::raw::c_char, table: *mut SCEnumCharMap, event_id: *mut u8,
) -> ::std::os::raw::c_int;
}
#[repr(C)] #[repr(C)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone)]
pub struct AppLayerParserState_ { pub struct AppLayerParserState_ {
_unused: [u8; 0], _unused: [u8; 0],
} }
pub type AppLayerParserState = AppLayerParserState_; pub type AppLayerParserState = AppLayerParserState_;
#[doc = " \\brief Data structure to store app layer decoder events."]
pub type AppLayerDecoderEvents = AppLayerDecoderEvents_;
#[repr(C)] #[repr(C)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone)]
pub struct File_ { pub struct File_ {
@ -1015,35 +1050,6 @@ extern "C" {
proto_name: *const ::std::os::raw::c_char, proto_alias: *const ::std::os::raw::c_char, proto_name: *const ::std::os::raw::c_char, proto_alias: *const ::std::os::raw::c_char,
) -> ::std::os::raw::c_int; ) -> ::std::os::raw::c_int;
} }
#[doc = " \\brief Data structure to store app layer decoder events."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct AppLayerDecoderEvents_ {
pub events: *mut u8,
pub cnt: u8,
pub events_buffer_size: u8,
pub event_last_logged: u8,
}
impl Default for AppLayerDecoderEvents_ {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
extern "C" {
pub fn SCAppLayerDecoderEventsSetEventRaw(sevents: *mut *mut AppLayerDecoderEvents, event: u8);
}
extern "C" {
pub fn SCAppLayerDecoderEventsFreeEvents(events: *mut *mut AppLayerDecoderEvents);
}
extern "C" {
pub fn SCAppLayerGetEventIdByName(
event_name: *const ::std::os::raw::c_char, table: *mut SCEnumCharMap, event_id: *mut u8,
) -> ::std::os::raw::c_int;
}
extern "C" { extern "C" {
pub fn SCHTTP2MimicHttp1Request( pub fn SCHTTP2MimicHttp1Request(
arg1: *mut ::std::os::raw::c_void, arg2: *mut ::std::os::raw::c_void, arg1: *mut ::std::os::raw::c_void, arg2: *mut ::std::os::raw::c_void,

@ -30,7 +30,7 @@
/** /**
* \brief Data structure to store app layer decoder events. * \brief Data structure to store app layer decoder events.
*/ */
struct AppLayerDecoderEvents_ { typedef struct AppLayerDecoderEvents_ {
/* array of events */ /* array of events */
uint8_t *events; uint8_t *events;
/* number of events in the above buffer */ /* number of events in the above buffer */
@ -39,7 +39,7 @@ struct AppLayerDecoderEvents_ {
uint8_t events_buffer_size; uint8_t events_buffer_size;
/* last logged */ /* last logged */
uint8_t event_last_logged; uint8_t event_last_logged;
}; } AppLayerDecoderEvents;
/* app layer pkt level events */ /* app layer pkt level events */
enum { enum {
@ -51,6 +51,11 @@ enum {
APPLAYER_UNEXPECTED_PROTOCOL, APPLAYER_UNEXPECTED_PROTOCOL,
}; };
typedef enum AppLayerEventType {
APP_LAYER_EVENT_TYPE_TRANSACTION = 1,
APP_LAYER_EVENT_TYPE_PACKET = 2,
} AppLayerEventType;
int AppLayerGetPktEventInfo(const char *event_name, uint8_t *event_id); int AppLayerGetPktEventInfo(const char *event_name, uint8_t *event_id);
int AppLayerGetEventInfoById( int AppLayerGetEventInfoById(

@ -26,6 +26,7 @@
#define SURICATA_APP_LAYER_PARSER_H #define SURICATA_APP_LAYER_PARSER_H
#include "app-layer-protos.h" #include "app-layer-protos.h"
#include "app-layer-events.h"
// Forward declarations for bindgen // Forward declarations for bindgen
enum ConfigAction; enum ConfigAction;
typedef struct Flow_ Flow; typedef struct Flow_ Flow;
@ -40,7 +41,6 @@ typedef struct AppLayerResult AppLayerResult;
typedef struct AppLayerGetTxIterTuple AppLayerGetTxIterTuple; typedef struct AppLayerGetTxIterTuple AppLayerGetTxIterTuple;
typedef struct AppLayerGetFileState AppLayerGetFileState; typedef struct AppLayerGetFileState AppLayerGetFileState;
typedef struct AppLayerTxData AppLayerTxData; typedef struct AppLayerTxData AppLayerTxData;
typedef enum AppLayerEventType AppLayerEventType;
typedef struct AppLayerStateData AppLayerStateData; typedef struct AppLayerStateData AppLayerStateData;
typedef struct AppLayerTxConfig AppLayerTxConfig; typedef struct AppLayerTxConfig AppLayerTxConfig;

@ -23,6 +23,7 @@ typedef struct HttpRangeContainerBlock HttpRangeContainerBlock;
typedef struct Dataset Dataset; typedef struct Dataset Dataset;
typedef struct DetectEngineState_ DetectEngineState; typedef struct DetectEngineState_ DetectEngineState;
typedef enum AppLayerEventType AppLayerEventType;
// may be improved by smaller include // may be improved by smaller include
#include "detect.h" #include "detect.h"

Loading…
Cancel
Save