|
|
@ -623,8 +623,7 @@ fn pgsql_tx_get_res_state(tx: *mut std::os::raw::c_void) -> PgsqlTxProgress {
|
|
|
|
// C exports.
|
|
|
|
// C exports.
|
|
|
|
|
|
|
|
|
|
|
|
/// C entry point for a probing parser.
|
|
|
|
/// C entry point for a probing parser.
|
|
|
|
#[no_mangle]
|
|
|
|
unsafe extern "C" fn probing_parser_ts(
|
|
|
|
pub unsafe extern "C" fn SCPgsqlProbingParserTS(
|
|
|
|
|
|
|
|
_flow: *const Flow, _direction: u8, input: *const u8, input_len: u32, _rdir: *mut u8,
|
|
|
|
_flow: *const Flow, _direction: u8, input: *const u8, input_len: u32, _rdir: *mut u8,
|
|
|
|
) -> AppProto {
|
|
|
|
) -> AppProto {
|
|
|
|
if input_len >= 1 && !input.is_null() {
|
|
|
|
if input_len >= 1 && !input.is_null() {
|
|
|
@ -649,8 +648,7 @@ pub unsafe extern "C" fn SCPgsqlProbingParserTS(
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// C entry point for a probing parser.
|
|
|
|
/// C entry point for a probing parser.
|
|
|
|
#[no_mangle]
|
|
|
|
unsafe extern "C" fn probing_parser_tc(
|
|
|
|
pub unsafe extern "C" fn SCPgsqlProbingParserTC(
|
|
|
|
|
|
|
|
_flow: *const Flow, _direction: u8, input: *const u8, input_len: u32, _rdir: *mut u8,
|
|
|
|
_flow: *const Flow, _direction: u8, input: *const u8, input_len: u32, _rdir: *mut u8,
|
|
|
|
) -> AppProto {
|
|
|
|
) -> AppProto {
|
|
|
|
if input_len >= 1 && !input.is_null() {
|
|
|
|
if input_len >= 1 && !input.is_null() {
|
|
|
@ -678,8 +676,7 @@ pub unsafe extern "C" fn SCPgsqlProbingParserTC(
|
|
|
|
return ALPROTO_UNKNOWN;
|
|
|
|
return ALPROTO_UNKNOWN;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[no_mangle]
|
|
|
|
extern "C" fn state_new(
|
|
|
|
pub extern "C" fn SCPgsqlStateNew(
|
|
|
|
|
|
|
|
_orig_state: *mut std::os::raw::c_void, _orig_proto: AppProto,
|
|
|
|
_orig_state: *mut std::os::raw::c_void, _orig_proto: AppProto,
|
|
|
|
) -> *mut std::os::raw::c_void {
|
|
|
|
) -> *mut std::os::raw::c_void {
|
|
|
|
let state = PgsqlState::new();
|
|
|
|
let state = PgsqlState::new();
|
|
|
@ -687,23 +684,17 @@ pub extern "C" fn SCPgsqlStateNew(
|
|
|
|
return Box::into_raw(boxed) as *mut _;
|
|
|
|
return Box::into_raw(boxed) as *mut _;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[no_mangle]
|
|
|
|
extern "C" fn state_free(state: *mut std::os::raw::c_void) {
|
|
|
|
pub extern "C" fn SCPgsqlStateFree(state: *mut std::os::raw::c_void) {
|
|
|
|
|
|
|
|
// Just unbox...
|
|
|
|
// Just unbox...
|
|
|
|
std::mem::drop(unsafe { Box::from_raw(state as *mut PgsqlState) });
|
|
|
|
std::mem::drop(unsafe { Box::from_raw(state as *mut PgsqlState) });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[no_mangle]
|
|
|
|
unsafe extern "C" fn state_tx_free(state: *mut std::os::raw::c_void, tx_id: u64) {
|
|
|
|
pub extern "C" fn SCPgsqlStateTxFree(state: *mut std::os::raw::c_void, tx_id: u64) {
|
|
|
|
let state_safe: &mut PgsqlState = cast_pointer!(state, PgsqlState);
|
|
|
|
let state_safe: &mut PgsqlState;
|
|
|
|
|
|
|
|
unsafe {
|
|
|
|
|
|
|
|
state_safe = cast_pointer!(state, PgsqlState);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
state_safe.free_tx(tx_id);
|
|
|
|
state_safe.free_tx(tx_id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[no_mangle]
|
|
|
|
unsafe extern "C" fn parse_request(
|
|
|
|
pub unsafe extern "C" fn SCPgsqlParseRequest(
|
|
|
|
|
|
|
|
flow: *const Flow, state: *mut std::os::raw::c_void, pstate: *mut std::os::raw::c_void,
|
|
|
|
flow: *const Flow, state: *mut std::os::raw::c_void, pstate: *mut std::os::raw::c_void,
|
|
|
|
stream_slice: StreamSlice, _data: *const std::os::raw::c_void,
|
|
|
|
stream_slice: StreamSlice, _data: *const std::os::raw::c_void,
|
|
|
|
) -> AppLayerResult {
|
|
|
|
) -> AppLayerResult {
|
|
|
@ -726,8 +717,7 @@ pub unsafe extern "C" fn SCPgsqlParseRequest(
|
|
|
|
AppLayerResult::ok()
|
|
|
|
AppLayerResult::ok()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[no_mangle]
|
|
|
|
unsafe extern "C" fn parse_response(
|
|
|
|
pub unsafe extern "C" fn SCPgsqlParseResponse(
|
|
|
|
|
|
|
|
flow: *const Flow, state: *mut std::os::raw::c_void, pstate: *mut std::os::raw::c_void,
|
|
|
|
flow: *const Flow, state: *mut std::os::raw::c_void, pstate: *mut std::os::raw::c_void,
|
|
|
|
stream_slice: StreamSlice, _data: *const std::os::raw::c_void,
|
|
|
|
stream_slice: StreamSlice, _data: *const std::os::raw::c_void,
|
|
|
|
) -> AppLayerResult {
|
|
|
|
) -> AppLayerResult {
|
|
|
@ -749,8 +739,7 @@ pub unsafe extern "C" fn SCPgsqlParseResponse(
|
|
|
|
AppLayerResult::ok()
|
|
|
|
AppLayerResult::ok()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[no_mangle]
|
|
|
|
unsafe extern "C" fn state_get_tx(
|
|
|
|
pub unsafe extern "C" fn SCPgsqlStateGetTx(
|
|
|
|
|
|
|
|
state: *mut std::os::raw::c_void, tx_id: u64,
|
|
|
|
state: *mut std::os::raw::c_void, tx_id: u64,
|
|
|
|
) -> *mut std::os::raw::c_void {
|
|
|
|
) -> *mut std::os::raw::c_void {
|
|
|
|
let state_safe: &mut PgsqlState = cast_pointer!(state, PgsqlState);
|
|
|
|
let state_safe: &mut PgsqlState = cast_pointer!(state, PgsqlState);
|
|
|
@ -764,17 +753,12 @@ pub unsafe extern "C" fn SCPgsqlStateGetTx(
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[no_mangle]
|
|
|
|
unsafe extern "C" fn state_get_tx_count(state: *mut std::os::raw::c_void) -> u64 {
|
|
|
|
pub extern "C" fn SCPgsqlStateGetTxCount(state: *mut std::os::raw::c_void) -> u64 {
|
|
|
|
let state_safe: &mut PgsqlState = cast_pointer!(state, PgsqlState);
|
|
|
|
let state_safe: &mut PgsqlState;
|
|
|
|
|
|
|
|
unsafe {
|
|
|
|
|
|
|
|
state_safe = cast_pointer!(state, PgsqlState);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return state_safe.tx_id;
|
|
|
|
return state_safe.tx_id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[no_mangle]
|
|
|
|
unsafe extern "C" fn tx_get_al_state_progress(
|
|
|
|
pub unsafe extern "C" fn SCPgsqlTxGetALStateProgress(
|
|
|
|
|
|
|
|
tx: *mut std::os::raw::c_void, direction: u8,
|
|
|
|
tx: *mut std::os::raw::c_void, direction: u8,
|
|
|
|
) -> std::os::raw::c_int {
|
|
|
|
) -> std::os::raw::c_int {
|
|
|
|
if direction == Direction::ToServer as u8 {
|
|
|
|
if direction == Direction::ToServer as u8 {
|
|
|
@ -799,20 +783,20 @@ pub unsafe extern "C" fn SCRegisterPgsqlParser() {
|
|
|
|
name: PARSER_NAME.as_ptr() as *const std::os::raw::c_char,
|
|
|
|
name: PARSER_NAME.as_ptr() as *const std::os::raw::c_char,
|
|
|
|
default_port: default_port.as_ptr(),
|
|
|
|
default_port: default_port.as_ptr(),
|
|
|
|
ipproto: IPPROTO_TCP,
|
|
|
|
ipproto: IPPROTO_TCP,
|
|
|
|
probe_ts: Some(SCPgsqlProbingParserTS),
|
|
|
|
probe_ts: Some(probing_parser_ts),
|
|
|
|
probe_tc: Some(SCPgsqlProbingParserTC),
|
|
|
|
probe_tc: Some(probing_parser_tc),
|
|
|
|
min_depth: 0,
|
|
|
|
min_depth: 0,
|
|
|
|
max_depth: 16,
|
|
|
|
max_depth: 16,
|
|
|
|
state_new: SCPgsqlStateNew,
|
|
|
|
state_new,
|
|
|
|
state_free: SCPgsqlStateFree,
|
|
|
|
state_free,
|
|
|
|
tx_free: SCPgsqlStateTxFree,
|
|
|
|
tx_free: state_tx_free,
|
|
|
|
parse_ts: SCPgsqlParseRequest,
|
|
|
|
parse_ts: parse_request,
|
|
|
|
parse_tc: SCPgsqlParseResponse,
|
|
|
|
parse_tc: parse_response,
|
|
|
|
get_tx_count: SCPgsqlStateGetTxCount,
|
|
|
|
get_tx_count: state_get_tx_count,
|
|
|
|
get_tx: SCPgsqlStateGetTx,
|
|
|
|
get_tx: state_get_tx,
|
|
|
|
tx_comp_st_ts: PgsqlTxProgress::TxDone as i32,
|
|
|
|
tx_comp_st_ts: PgsqlTxProgress::TxDone as i32,
|
|
|
|
tx_comp_st_tc: PgsqlTxProgress::TxDone as i32,
|
|
|
|
tx_comp_st_tc: PgsqlTxProgress::TxDone as i32,
|
|
|
|
tx_get_progress: SCPgsqlTxGetALStateProgress,
|
|
|
|
tx_get_progress: tx_get_al_state_progress,
|
|
|
|
get_eventinfo: None,
|
|
|
|
get_eventinfo: None,
|
|
|
|
get_eventinfo_byid: None,
|
|
|
|
get_eventinfo_byid: None,
|
|
|
|
localstorage_new: None,
|
|
|
|
localstorage_new: None,
|
|
|
|