From: Jason Ish Date: Tue, 1 Apr 2025 15:16:11 +0000 (-0600) Subject: rust/rdp: namespace and visibility cleanups X-Git-Tag: suricata-8.0.0-beta1~120 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b67917489d7d8d663bd30990b393ee587f7eea57;p=thirdparty%2Fsuricata.git rust/rdp: namespace and visibility cleanups Ticket: #7498 --- diff --git a/rust/src/rdp/log.rs b/rust/src/rdp/log.rs index a3d7b6043d..61b06d380c 100644 --- a/rust/src/rdp/log.rs +++ b/rust/src/rdp/log.rs @@ -24,7 +24,7 @@ use crate::rdp::windows; use x509_parser::prelude::{FromDer, X509Certificate}; #[no_mangle] -pub extern "C" fn rs_rdp_to_json(tx: &RdpTransaction, js: &mut JsonBuilder) -> bool { +pub extern "C" fn SCRdpToJson(tx: &RdpTransaction, js: &mut JsonBuilder) -> bool { log(tx, js).is_ok() } diff --git a/rust/src/rdp/rdp.rs b/rust/src/rdp/rdp.rs index 45c924e49e..9f681e0235 100644 --- a/rust/src/rdp/rdp.rs +++ b/rust/src/rdp/rdp.rs @@ -73,8 +73,7 @@ impl RdpTransaction { } } -#[no_mangle] -pub unsafe extern "C" fn rs_rdp_state_get_tx( +unsafe extern "C" fn rdp_state_get_tx( state: *mut std::os::raw::c_void, tx_id: u64, ) -> *mut std::os::raw::c_void { let state = cast_pointer!(state, RdpState); @@ -88,14 +87,12 @@ pub unsafe extern "C" fn rs_rdp_state_get_tx( } } -#[no_mangle] -pub unsafe extern "C" fn rs_rdp_state_get_tx_count(state: *mut std::os::raw::c_void) -> u64 { +unsafe extern "C" fn rdp_state_get_tx_count(state: *mut std::os::raw::c_void) -> u64 { let state = cast_pointer!(state, RdpState); return state.next_id; } -#[no_mangle] -pub extern "C" fn rs_rdp_tx_get_progress( +extern "C" fn rdp_tx_get_progress( _tx: *mut std::os::raw::c_void, _direction: u8, ) -> std::os::raw::c_int { // tx complete when `rs_rdp_tx_get_progress(...) == rs_rdp_tx_get_progress_complete(...)` @@ -376,20 +373,17 @@ impl RdpState { } } -#[no_mangle] -pub extern "C" fn rs_rdp_state_new(_orig_state: *mut std::os::raw::c_void, _orig_proto: AppProto) -> *mut std::os::raw::c_void { +extern "C" fn rdp_state_new(_orig_state: *mut std::os::raw::c_void, _orig_proto: AppProto) -> *mut std::os::raw::c_void { let state = RdpState::new(); let boxed = Box::new(state); return Box::into_raw(boxed) as *mut _; } -#[no_mangle] -pub extern "C" fn rs_rdp_state_free(state: *mut std::os::raw::c_void) { +extern "C" fn rdp_state_free(state: *mut std::os::raw::c_void) { std::mem::drop(unsafe { Box::from_raw(state as *mut RdpState) }); } -#[no_mangle] -pub unsafe extern "C" fn rs_rdp_state_tx_free(state: *mut std::os::raw::c_void, tx_id: u64) { +unsafe extern "C" fn rdp_state_tx_free(state: *mut std::os::raw::c_void, tx_id: u64) { let state = cast_pointer!(state, RdpState); state.free_tx(tx_id); } @@ -404,8 +398,7 @@ fn probe_rdp(input: &[u8]) -> bool { } /// probe for T.123 message, whether to client or to server -#[no_mangle] -pub unsafe extern "C" fn rs_rdp_probe_ts_tc( +unsafe extern "C" fn rdp_probe_ts_tc( _flow: *const Flow, _direction: u8, input: *const u8, input_len: u32, _rdir: *mut u8, ) -> AppProto { if !input.is_null() { @@ -431,8 +424,7 @@ fn probe_tls_handshake(input: &[u8]) -> bool { // parse // -#[no_mangle] -pub unsafe extern "C" fn rs_rdp_parse_ts( +unsafe extern "C" fn rdp_parse_ts( _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 @@ -443,8 +435,7 @@ pub unsafe extern "C" fn rs_rdp_parse_ts( return state.parse_ts(buf); } -#[no_mangle] -pub unsafe extern "C" fn rs_rdp_parse_tc( +unsafe extern "C" fn rdp_parse_tc( _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 @@ -465,26 +456,26 @@ export_state_data_get!(rdp_get_state_data, RdpState); const PARSER_NAME: &[u8] = b"rdp\0"; #[no_mangle] -pub unsafe extern "C" fn rs_rdp_register_parser() { +pub unsafe extern "C" fn SCRegisterRdpParser() { let default_port = std::ffi::CString::new("[3389]").unwrap(); let parser = RustParser { name: PARSER_NAME.as_ptr() as *const std::os::raw::c_char, default_port: default_port.as_ptr(), ipproto: IPPROTO_TCP, - probe_ts: Some(rs_rdp_probe_ts_tc), - probe_tc: Some(rs_rdp_probe_ts_tc), + probe_ts: Some(rdp_probe_ts_tc), + probe_tc: Some(rdp_probe_ts_tc), min_depth: 0, max_depth: 16, - state_new: rs_rdp_state_new, - state_free: rs_rdp_state_free, - tx_free: rs_rdp_state_tx_free, - parse_ts: rs_rdp_parse_ts, - parse_tc: rs_rdp_parse_tc, - get_tx_count: rs_rdp_state_get_tx_count, - get_tx: rs_rdp_state_get_tx, + state_new: rdp_state_new, + state_free: rdp_state_free, + tx_free: rdp_state_tx_free, + parse_ts: rdp_parse_ts, + parse_tc: rdp_parse_tc, + get_tx_count: rdp_state_get_tx_count, + get_tx: rdp_state_get_tx, tx_comp_st_ts: 1, tx_comp_st_tc: 1, - tx_get_progress: rs_rdp_tx_get_progress, + tx_get_progress: rdp_tx_get_progress, get_eventinfo: None, get_eventinfo_byid: None, localstorage_new: None, diff --git a/src/app-layer-parser.c b/src/app-layer-parser.c index 917c5d0f70..7601da2592 100644 --- a/src/app-layer-parser.c +++ b/src/app-layer-parser.c @@ -1755,7 +1755,7 @@ void AppLayerParserRegisterProtocolParsers(void) SCRfbRegisterParser(); SCMqttRegisterParser(); SCRegisterPgsqlParser(); - rs_rdp_register_parser(); + SCRegisterRdpParser(); RegisterHTTP2Parsers(); rs_telnet_register_parser(); RegisterIMAPParsers(); diff --git a/src/output.c b/src/output.c index 8fbb9265f5..ffe939d16c 100644 --- a/src/output.c +++ b/src/output.c @@ -914,7 +914,7 @@ void OutputRegisterRootLoggers(void) RegisterSimpleJsonApplayerLogger(ALPROTO_DOH2, AlertJsonDoh2, NULL); RegisterSimpleJsonApplayerLogger( ALPROTO_TEMPLATE, (EveJsonSimpleTxLogFunc)rs_template_logger_log, NULL); - RegisterSimpleJsonApplayerLogger(ALPROTO_RDP, (EveJsonSimpleTxLogFunc)rs_rdp_to_json, NULL); + RegisterSimpleJsonApplayerLogger(ALPROTO_RDP, (EveJsonSimpleTxLogFunc)SCRdpToJson, NULL); // special case : http2 is logged in http object RegisterSimpleJsonApplayerLogger(ALPROTO_HTTP2, rs_http2_log_json, "http"); // underscore instead of dash for bittorrent_dht