mirror of
https://github.com/OISF/suricata.git
synced 2026-10-11 22:09:53 +00:00
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
This commit is contained in:
committed by
Victor Julien
parent
c960b7d7c1
commit
4b541b39f2
@@ -144,6 +144,7 @@ if HAVE_BINDGEN
|
||||
--allowlist-function 'AppProto.*' \
|
||||
--allowlist-function 'File.*' \
|
||||
--allowlist-type 'SC.*' \
|
||||
--allowlist-type 'AppLayerEventType' \
|
||||
--allowlist-function 'SC.*' \
|
||||
--allowlist-var 'SC.*' \
|
||||
--opaque-type 'SCConfNode' \
|
||||
|
||||
+1
-7
@@ -23,13 +23,7 @@ use suricata_sys::sys::SCAppLayerParserTriggerRawStreamInspection;
|
||||
|
||||
use crate::flow::Flow;
|
||||
|
||||
#[repr(C)]
|
||||
#[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 use suricata_sys::sys::AppLayerEventType;
|
||||
|
||||
pub const STREAM_START: u8 = 0x01;
|
||||
pub const STREAM_EOF: u8 = 0x02;
|
||||
|
||||
+37
-31
@@ -925,14 +925,49 @@ extern "C" {
|
||||
extern "C" {
|
||||
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)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct AppLayerParserState_ {
|
||||
_unused: [u8; 0],
|
||||
}
|
||||
pub type AppLayerParserState = AppLayerParserState_;
|
||||
#[doc = " \\brief Data structure to store app layer decoder events."]
|
||||
pub type AppLayerDecoderEvents = AppLayerDecoderEvents_;
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
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,
|
||||
) -> ::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" {
|
||||
pub fn SCHTTP2MimicHttp1Request(
|
||||
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.
|
||||
*/
|
||||
struct AppLayerDecoderEvents_ {
|
||||
typedef struct AppLayerDecoderEvents_ {
|
||||
/* array of events */
|
||||
uint8_t *events;
|
||||
/* number of events in the above buffer */
|
||||
@@ -39,7 +39,7 @@ struct AppLayerDecoderEvents_ {
|
||||
uint8_t events_buffer_size;
|
||||
/* last logged */
|
||||
uint8_t event_last_logged;
|
||||
};
|
||||
} AppLayerDecoderEvents;
|
||||
|
||||
/* app layer pkt level events */
|
||||
enum {
|
||||
@@ -51,6 +51,11 @@ enum {
|
||||
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 AppLayerGetEventInfoById(
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#define SURICATA_APP_LAYER_PARSER_H
|
||||
|
||||
#include "app-layer-protos.h"
|
||||
#include "app-layer-events.h"
|
||||
// Forward declarations for bindgen
|
||||
enum ConfigAction;
|
||||
typedef struct Flow_ Flow;
|
||||
@@ -40,7 +41,6 @@ typedef struct AppLayerResult AppLayerResult;
|
||||
typedef struct AppLayerGetTxIterTuple AppLayerGetTxIterTuple;
|
||||
typedef struct AppLayerGetFileState AppLayerGetFileState;
|
||||
typedef struct AppLayerTxData AppLayerTxData;
|
||||
typedef enum AppLayerEventType AppLayerEventType;
|
||||
typedef struct AppLayerStateData AppLayerStateData;
|
||||
typedef struct AppLayerTxConfig AppLayerTxConfig;
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ typedef struct HttpRangeContainerBlock HttpRangeContainerBlock;
|
||||
typedef struct Dataset Dataset;
|
||||
|
||||
typedef struct DetectEngineState_ DetectEngineState;
|
||||
typedef enum AppLayerEventType AppLayerEventType;
|
||||
|
||||
// may be improved by smaller include
|
||||
#include "detect.h"
|
||||
|
||||
Reference in New Issue
Block a user