From: Jason Ish Date: Mon, 20 Jan 2025 18:06:20 +0000 (-0600) Subject: ssh: cleanup rust visibility and naming X-Git-Tag: suricata-8.0.0-beta1~536 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9c87ac1b9bec7c3cb6a330eb84ddbc8f067c45d1;p=thirdparty%2Fsuricata.git ssh: cleanup rust visibility and naming Remove pub and no_mangle from non-exported functions and rename to Rust as-needed. Ticket: 7498 --- diff --git a/rust/src/ssh/detect.rs b/rust/src/ssh/detect.rs index a8ba19ffa8..31c02ba7ea 100644 --- a/rust/src/ssh/detect.rs +++ b/rust/src/ssh/detect.rs @@ -20,7 +20,7 @@ use crate::direction::Direction; use std::ptr; #[no_mangle] -pub unsafe extern "C" fn rs_ssh_tx_get_protocol( +pub unsafe extern "C" fn SCSshTxGetProtocol( tx: *mut std::os::raw::c_void, buffer: *mut *const u8, buffer_len: *mut u32, direction: u8, ) -> u8 { let tx = cast_pointer!(tx, SSHTransaction); @@ -49,7 +49,7 @@ pub unsafe extern "C" fn rs_ssh_tx_get_protocol( } #[no_mangle] -pub unsafe extern "C" fn rs_ssh_tx_get_software( +pub unsafe extern "C" fn SCSshTxGetSoftware( tx: *mut std::os::raw::c_void, buffer: *mut *const u8, buffer_len: *mut u32, direction: u8, ) -> u8 { let tx = cast_pointer!(tx, SSHTransaction); @@ -78,7 +78,7 @@ pub unsafe extern "C" fn rs_ssh_tx_get_software( } #[no_mangle] -pub unsafe extern "C" fn rs_ssh_tx_get_hassh( +pub unsafe extern "C" fn SCSshTxGetHassh( tx: *mut std::os::raw::c_void, buffer: *mut *const u8, buffer_len: *mut u32, @@ -110,7 +110,7 @@ pub unsafe extern "C" fn rs_ssh_tx_get_hassh( } #[no_mangle] -pub unsafe extern "C" fn rs_ssh_tx_get_hassh_string( +pub unsafe extern "C" fn SCSshTxGetHasshString( tx: *mut std::os::raw::c_void, buffer: *mut *const u8, buffer_len: *mut u32, diff --git a/rust/src/ssh/logger.rs b/rust/src/ssh/logger.rs index bee6693c89..3dc4fba68e 100644 --- a/rust/src/ssh/logger.rs +++ b/rust/src/ssh/logger.rs @@ -64,7 +64,7 @@ fn log_ssh(tx: &SSHTransaction, js: &mut JsonBuilder) -> Result } #[no_mangle] -pub unsafe extern "C" fn rs_ssh_log_json(tx: *mut std::os::raw::c_void, js: &mut JsonBuilder) -> bool { +pub unsafe extern "C" fn SCSshLogJson(tx: *mut std::os::raw::c_void, js: &mut JsonBuilder) -> bool { let tx = cast_pointer!(tx, SSHTransaction); if let Ok(x) = log_ssh(tx, js) { return x; diff --git a/rust/src/ssh/ssh.rs b/rust/src/ssh/ssh.rs index 9a99bb188e..2e91c7f7e8 100644 --- a/rust/src/ssh/ssh.rs +++ b/rust/src/ssh/ssh.rs @@ -391,25 +391,21 @@ impl SSHState { export_tx_data_get!(ssh_get_tx_data, SSHTransaction); export_state_data_get!(ssh_get_state_data, SSHState); -#[no_mangle] -pub extern "C" fn rs_ssh_state_new(_orig_state: *mut std::os::raw::c_void, _orig_proto: AppProto) -> *mut std::os::raw::c_void { +extern "C" fn ssh_state_new(_orig_state: *mut std::os::raw::c_void, _orig_proto: AppProto) -> *mut std::os::raw::c_void { let state = SSHState::new(); let boxed = Box::new(state); return Box::into_raw(boxed) as *mut _; } -#[no_mangle] -pub unsafe extern "C" fn rs_ssh_state_free(state: *mut std::os::raw::c_void) { +unsafe extern "C" fn ssh_state_free(state: *mut std::os::raw::c_void) { std::mem::drop(Box::from_raw(state as *mut SSHState)); } -#[no_mangle] -pub extern "C" fn rs_ssh_state_tx_free(_state: *mut std::os::raw::c_void, _tx_id: u64) { +extern "C" fn ssh_state_tx_free(_state: *mut std::os::raw::c_void, _tx_id: u64) { //do nothing } -#[no_mangle] -pub unsafe extern "C" fn rs_ssh_parse_request( +unsafe extern "C" fn rs_ssh_parse_request( 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 @@ -425,8 +421,7 @@ pub unsafe extern "C" fn rs_ssh_parse_request( } } -#[no_mangle] -pub unsafe extern "C" fn rs_ssh_parse_response( +unsafe extern "C" fn ssh_parse_response( 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,20 +438,19 @@ pub unsafe extern "C" fn rs_ssh_parse_response( } #[no_mangle] -pub unsafe extern "C" fn rs_ssh_state_get_tx( +pub unsafe extern "C" fn SCSshStateGetTx( state: *mut std::os::raw::c_void, _tx_id: u64, ) -> *mut std::os::raw::c_void { let state = cast_pointer!(state, SSHState); return &state.transaction as *const _ as *mut _; } -#[no_mangle] -pub extern "C" fn rs_ssh_state_get_tx_count(_state: *mut std::os::raw::c_void) -> u64 { +extern "C" fn ssh_state_get_tx_count(_state: *mut std::os::raw::c_void) -> u64 { return 1; } #[no_mangle] -pub unsafe extern "C" fn rs_ssh_tx_get_flags( +pub unsafe extern "C" fn SCSshTxGetFlags( tx: *mut std::os::raw::c_void, direction: u8, ) -> SSHConnectionState { let tx = cast_pointer!(tx, SSHTransaction); @@ -468,7 +462,7 @@ pub unsafe extern "C" fn rs_ssh_tx_get_flags( } #[no_mangle] -pub unsafe extern "C" fn rs_ssh_tx_get_alstate_progress( +pub unsafe extern "C" fn SCSshTxGetAlStateProgress( tx: *mut std::os::raw::c_void, direction: u8, ) -> std::os::raw::c_int { let tx = cast_pointer!(tx, SSHTransaction); @@ -494,7 +488,7 @@ pub unsafe extern "C" fn rs_ssh_tx_get_alstate_progress( const PARSER_NAME: &[u8] = b"ssh\0"; #[no_mangle] -pub unsafe extern "C" fn rs_ssh_register_parser() { +pub unsafe extern "C" fn SCRegisterSshParser() { let parser = RustParser { name: PARSER_NAME.as_ptr() as *const std::os::raw::c_char, default_port: std::ptr::null(), @@ -504,16 +498,16 @@ pub unsafe extern "C" fn rs_ssh_register_parser() { probe_tc: None, min_depth: 0, max_depth: 0, - state_new: rs_ssh_state_new, - state_free: rs_ssh_state_free, - tx_free: rs_ssh_state_tx_free, + state_new: ssh_state_new, + state_free: ssh_state_free, + tx_free: ssh_state_tx_free, parse_ts: rs_ssh_parse_request, - parse_tc: rs_ssh_parse_response, - get_tx_count: rs_ssh_state_get_tx_count, - get_tx: rs_ssh_state_get_tx, + parse_tc: ssh_parse_response, + get_tx_count: ssh_state_get_tx_count, + get_tx: SCSshStateGetTx, tx_comp_st_ts: SSHConnectionState::SshStateFinished as i32, tx_comp_st_tc: SSHConnectionState::SshStateFinished as i32, - tx_get_progress: rs_ssh_tx_get_alstate_progress, + tx_get_progress: SCSshTxGetAlStateProgress, get_eventinfo: Some(SSHEvent::get_event_info), get_eventinfo_byid: Some(SSHEvent::get_event_info_by_id), localstorage_new: None, @@ -544,20 +538,20 @@ pub unsafe extern "C" fn rs_ssh_register_parser() { } #[no_mangle] -pub extern "C" fn rs_ssh_enable_hassh() { +pub extern "C" fn SCSshEnableHassh() { HASSH_ENABLED.store(true, Ordering::Relaxed) } #[no_mangle] -pub extern "C" fn rs_ssh_hassh_is_enabled() -> bool { +pub extern "C" fn SCSshHasshIsEnabled() -> bool { hassh_is_enabled() } #[no_mangle] -pub unsafe extern "C" fn rs_ssh_tx_get_log_condition( tx: *mut std::os::raw::c_void) -> bool { +pub unsafe extern "C" fn SCSshTxGetLogCondition( tx: *mut std::os::raw::c_void) -> bool { let tx = cast_pointer!(tx, SSHTransaction); - if rs_ssh_hassh_is_enabled() { + if SCSshHasshIsEnabled() { if tx.cli_hdr.flags == SSHConnectionState::SshStateFinished && tx.srv_hdr.flags == SSHConnectionState::SshStateFinished { return true; diff --git a/src/app-layer-ssh.c b/src/app-layer-ssh.c index 71bc786ad6..276e0fbee3 100644 --- a/src/app-layer-ssh.c +++ b/src/app-layer-ssh.c @@ -73,7 +73,7 @@ static int SSHRegisterPatternsForProtocolDetection(void) bool SSHTxLogCondition(ThreadVars *tv, const Packet *p, void *state, void *tx, uint64_t tx_id) { - return rs_ssh_tx_get_log_condition(tx); + return SCSshTxGetLogCondition(tx); } /** \brief Function to register the SSH protocol parsers and other functions @@ -101,13 +101,12 @@ void RegisterSSHParsers(void) } if (RunmodeIsUnittests() || enable_hassh) { - rs_ssh_enable_hassh(); + SCSshEnableHassh(); } } SCLogDebug("Registering Rust SSH parser."); - rs_ssh_register_parser(); - + SCRegisterSshParser(); #ifdef UNITTESTS AppLayerParserRegisterProtocolUnittests(IPPROTO_TCP, ALPROTO_SSH, SSHParserRegisterTests); @@ -126,7 +125,7 @@ static int SSHParserTestUtilCheck(const char *protoexp, const char *softexp, voi const uint8_t *software = NULL; uint32_t s_len = 0; - if (rs_ssh_tx_get_protocol(tx, &protocol, &p_len, flags) != 1) { + if (SCSshTxGetProtocol(tx, &protocol, &p_len, flags) != 1) { printf("Version string not parsed correctly return: "); return 1; } @@ -145,7 +144,7 @@ static int SSHParserTestUtilCheck(const char *protoexp, const char *softexp, voi } if (softexp != NULL) { - if (rs_ssh_tx_get_software(tx, &software, &s_len, flags) != 1) + if (SCSshTxGetSoftware(tx, &software, &s_len, flags) != 1) return 1; if (software == NULL) return 1; @@ -192,8 +191,8 @@ static int SSHParserTest01(void) goto end; } - void * tx = rs_ssh_state_get_tx(ssh_state, 0); - if ( rs_ssh_tx_get_alstate_progress(tx, STREAM_TOSERVER) != SshStateBannerDone ) { + void *tx = SCSshStateGetTx(ssh_state, 0); + if (SCSshTxGetAlStateProgress(tx, STREAM_TOSERVER) != SshStateBannerDone) { printf("Client version string not parsed: "); goto end; } @@ -242,9 +241,9 @@ static int SSHParserTest02(void) printf("no ssh state: "); goto end; } - void * tx = rs_ssh_state_get_tx(ssh_state, 0); + void *tx = SCSshStateGetTx(ssh_state, 0); - if ( rs_ssh_tx_get_alstate_progress(tx, STREAM_TOSERVER) != SshStateBannerDone ) { + if (SCSshTxGetAlStateProgress(tx, STREAM_TOSERVER) != SshStateBannerDone) { printf("Client version string not parsed: "); goto end; } @@ -292,17 +291,17 @@ static int SSHParserTest03(void) printf("no ssh state: "); goto end; } - void * tx = rs_ssh_state_get_tx(ssh_state, 0); + void *tx = SCSshStateGetTx(ssh_state, 0); - if ( rs_ssh_tx_get_alstate_progress(tx, STREAM_TOSERVER) == SshStateBannerDone ) { + if (SCSshTxGetAlStateProgress(tx, STREAM_TOSERVER) == SshStateBannerDone) { printf("Client version string parsed? It's not a valid string: "); goto end; } const uint8_t *dummy = NULL; uint32_t dummy_len = 0; - if (rs_ssh_tx_get_protocol(tx, &dummy, &dummy_len, STREAM_TOSERVER) != 0) + if (SCSshTxGetProtocol(tx, &dummy, &dummy_len, STREAM_TOSERVER) != 0) goto end; - if (rs_ssh_tx_get_software(tx, &dummy, &dummy_len, STREAM_TOSERVER) != 0) + if (SCSshTxGetSoftware(tx, &dummy, &dummy_len, STREAM_TOSERVER) != 0) goto end; result = 1; @@ -344,9 +343,9 @@ static int SSHParserTest04(void) printf("no ssh state: "); goto end; } - void * tx = rs_ssh_state_get_tx(ssh_state, 0); + void *tx = SCSshStateGetTx(ssh_state, 0); - if ( rs_ssh_tx_get_alstate_progress(tx, STREAM_TOCLIENT) != SshStateBannerDone ) { + if (SCSshTxGetAlStateProgress(tx, STREAM_TOCLIENT) != SshStateBannerDone) { printf("Client version string not parsed: "); goto end; } @@ -394,9 +393,9 @@ static int SSHParserTest05(void) printf("no ssh state: "); goto end; } - void * tx = rs_ssh_state_get_tx(ssh_state, 0); + void *tx = SCSshStateGetTx(ssh_state, 0); - if ( rs_ssh_tx_get_alstate_progress(tx, STREAM_TOCLIENT) != SshStateBannerDone ) { + if (SCSshTxGetAlStateProgress(tx, STREAM_TOCLIENT) != SshStateBannerDone) { printf("Client version string not parsed: "); goto end; } @@ -444,17 +443,17 @@ static int SSHParserTest06(void) printf("no ssh state: "); goto end; } - void * tx = rs_ssh_state_get_tx(ssh_state, 0); + void *tx = SCSshStateGetTx(ssh_state, 0); - if ( rs_ssh_tx_get_alstate_progress(tx, STREAM_TOCLIENT) == SshStateBannerDone ) { + if (SCSshTxGetAlStateProgress(tx, STREAM_TOCLIENT) == SshStateBannerDone) { printf("Client version string parsed? It's not a valid string: "); goto end; } const uint8_t *dummy = NULL; uint32_t dummy_len = 0; - if (rs_ssh_tx_get_protocol(tx, &dummy, &dummy_len, STREAM_TOCLIENT) != 0) + if (SCSshTxGetProtocol(tx, &dummy, &dummy_len, STREAM_TOCLIENT) != 0) goto end; - if (rs_ssh_tx_get_software(tx, &dummy, &dummy_len, STREAM_TOCLIENT) != 0) + if (SCSshTxGetSoftware(tx, &dummy, &dummy_len, STREAM_TOCLIENT) != 0) goto end; @@ -507,8 +506,8 @@ static int SSHParserTest07(void) void *ssh_state = f->alstate; FAIL_IF_NULL(ssh_state); - void * tx = rs_ssh_state_get_tx(ssh_state, 0); - FAIL_IF( rs_ssh_tx_get_alstate_progress(tx, STREAM_TOSERVER) != SshStateBannerDone ); + void *tx = SCSshStateGetTx(ssh_state, 0); + FAIL_IF(SCSshTxGetAlStateProgress(tx, STREAM_TOSERVER) != SshStateBannerDone); FAIL_IF(SSHParserTestUtilCheck("2.0", "MySSHClient-0.5.1", tx, STREAM_TOSERVER)); @@ -558,8 +557,8 @@ static int SSHParserTest08(void) void *ssh_state = f->alstate; FAIL_IF_NULL(ssh_state); - void * tx = rs_ssh_state_get_tx(ssh_state, 0); - FAIL_IF( rs_ssh_tx_get_alstate_progress(tx, STREAM_TOSERVER) != SshStateBannerDone ); + void *tx = SCSshStateGetTx(ssh_state, 0); + FAIL_IF(SCSshTxGetAlStateProgress(tx, STREAM_TOSERVER) != SshStateBannerDone); FAIL_IF(SSHParserTestUtilCheck("2.0", "MySSHClient-0.5.1", tx, STREAM_TOSERVER)); @@ -608,8 +607,8 @@ static int SSHParserTest09(void) void *ssh_state = f->alstate; FAIL_IF_NULL(ssh_state); - void * tx = rs_ssh_state_get_tx(ssh_state, 0); - FAIL_IF( rs_ssh_tx_get_alstate_progress(tx, STREAM_TOCLIENT) != SshStateBannerDone ); + void *tx = SCSshStateGetTx(ssh_state, 0); + FAIL_IF(SCSshTxGetAlStateProgress(tx, STREAM_TOCLIENT) != SshStateBannerDone); FAIL_IF(SSHParserTestUtilCheck("2.0", "MySSHClient-0.5.1", tx, STREAM_TOCLIENT)); @@ -659,8 +658,8 @@ static int SSHParserTest10(void) void *ssh_state = f->alstate; FAIL_IF_NULL(ssh_state); - void * tx = rs_ssh_state_get_tx(ssh_state, 0); - FAIL_IF( rs_ssh_tx_get_alstate_progress(tx, STREAM_TOCLIENT) != SshStateBannerDone ); + void *tx = SCSshStateGetTx(ssh_state, 0); + FAIL_IF(SCSshTxGetAlStateProgress(tx, STREAM_TOCLIENT) != SshStateBannerDone); FAIL_IF(SSHParserTestUtilCheck("2.0", "MySSHClient-0.5.1", tx, STREAM_TOCLIENT)); @@ -709,8 +708,8 @@ static int SSHParserTest11(void) printf("no ssh state: "); goto end; } - void * tx = rs_ssh_state_get_tx(ssh_state, 0); - if ( rs_ssh_tx_get_flags(tx, STREAM_TOSERVER) != SshStateFinished ) { + void *tx = SCSshStateGetTx(ssh_state, 0); + if (SCSshTxGetFlags(tx, STREAM_TOSERVER) != SshStateFinished) { printf("Didn't detect the msg code of new keys (ciphered data starts): "); goto end; } @@ -772,8 +771,8 @@ static int SSHParserTest12(void) printf("no ssh state: "); goto end; } - void * tx = rs_ssh_state_get_tx(ssh_state, 0); - if ( rs_ssh_tx_get_flags(tx, STREAM_TOSERVER) != SshStateFinished ) { + void *tx = SCSshStateGetTx(ssh_state, 0); + if (SCSshTxGetFlags(tx, STREAM_TOSERVER) != SshStateFinished) { printf("Didn't detect the msg code of new keys (ciphered data starts): "); goto end; } @@ -833,8 +832,8 @@ static int SSHParserTest13(void) void *ssh_state = f->alstate; FAIL_IF_NULL(ssh_state); - void * tx = rs_ssh_state_get_tx(ssh_state, 0); - FAIL_IF( rs_ssh_tx_get_flags(tx, STREAM_TOSERVER) != SshStateFinished ); + void *tx = SCSshStateGetTx(ssh_state, 0); + FAIL_IF(SCSshTxGetFlags(tx, STREAM_TOSERVER) != SshStateFinished); FAIL_IF(SSHParserTestUtilCheck("2.0", "MySSHClient-0.5.1", tx, STREAM_TOSERVER)); @@ -892,8 +891,8 @@ static int SSHParserTest14(void) void *ssh_state = f->alstate; FAIL_IF_NULL(ssh_state); - void * tx = rs_ssh_state_get_tx(ssh_state, 0); - FAIL_IF( rs_ssh_tx_get_flags(tx, STREAM_TOSERVER) != SshStateFinished ); + void *tx = SCSshStateGetTx(ssh_state, 0); + FAIL_IF(SCSshTxGetFlags(tx, STREAM_TOSERVER) != SshStateFinished); FAIL_IF(SSHParserTestUtilCheck("2.0", "MySSHClient-0.5.1", tx, STREAM_TOSERVER)); @@ -950,8 +949,8 @@ static int SSHParserTest15(void) void *ssh_state = f->alstate; FAIL_IF_NULL(ssh_state); - void * tx = rs_ssh_state_get_tx(ssh_state, 0); - FAIL_IF( rs_ssh_tx_get_flags(tx, STREAM_TOSERVER) != SshStateFinished ); + void *tx = SCSshStateGetTx(ssh_state, 0); + FAIL_IF(SCSshTxGetFlags(tx, STREAM_TOSERVER) != SshStateFinished); FAIL_IF(SSHParserTestUtilCheck("2.0", "MySSHClient-0.5.1", tx, STREAM_TOSERVER)); @@ -1006,8 +1005,8 @@ static int SSHParserTest16(void) void *ssh_state = f->alstate; FAIL_IF_NULL(ssh_state); - void * tx = rs_ssh_state_get_tx(ssh_state, 0); - FAIL_IF( rs_ssh_tx_get_flags(tx, STREAM_TOCLIENT) != SshStateFinished ); + void *tx = SCSshStateGetTx(ssh_state, 0); + FAIL_IF(SCSshTxGetFlags(tx, STREAM_TOCLIENT) != SshStateFinished); FAIL_IF(SSHParserTestUtilCheck("2.0", "MySSHClient-0.5.1", tx, STREAM_TOCLIENT)); @@ -1063,8 +1062,8 @@ static int SSHParserTest17(void) void *ssh_state = f->alstate; FAIL_IF_NULL(ssh_state); - void * tx = rs_ssh_state_get_tx(ssh_state, 0); - FAIL_IF( rs_ssh_tx_get_flags(tx, STREAM_TOCLIENT) != SshStateFinished ); + void *tx = SCSshStateGetTx(ssh_state, 0); + FAIL_IF(SCSshTxGetFlags(tx, STREAM_TOCLIENT) != SshStateFinished); FAIL_IF(SSHParserTestUtilCheck("2.0", "MySSHClient-0.5.1", tx, STREAM_TOCLIENT)); @@ -1130,8 +1129,8 @@ static int SSHParserTest18(void) void *ssh_state = f->alstate; FAIL_IF_NULL(ssh_state); - void * tx = rs_ssh_state_get_tx(ssh_state, 0); - FAIL_IF( rs_ssh_tx_get_flags(tx, STREAM_TOCLIENT) != SshStateFinished ); + void *tx = SCSshStateGetTx(ssh_state, 0); + FAIL_IF(SCSshTxGetFlags(tx, STREAM_TOCLIENT) != SshStateFinished); FAIL_IF(!(AppLayerParserStateIssetFlag(f->alparser, APP_LAYER_PARSER_NO_INSPECTION))); @@ -1196,8 +1195,8 @@ static int SSHParserTest19(void) void *ssh_state = f->alstate; FAIL_IF_NULL(ssh_state); - void * tx = rs_ssh_state_get_tx(ssh_state, 0); - FAIL_IF( rs_ssh_tx_get_flags(tx, STREAM_TOCLIENT) != SshStateFinished ); + void *tx = SCSshStateGetTx(ssh_state, 0); + FAIL_IF(SCSshTxGetFlags(tx, STREAM_TOCLIENT) != SshStateFinished); sshbuf3[sizeof(sshbuf3) - 2] = 0; FAIL_IF(SSHParserTestUtilCheck("2.0", (char *)sshbuf3, tx, STREAM_TOCLIENT)); @@ -1265,8 +1264,8 @@ static int SSHParserTest20(void) void *ssh_state = f->alstate; FAIL_IF_NULL(ssh_state); - void * tx = rs_ssh_state_get_tx(ssh_state, 0); - FAIL_IF( rs_ssh_tx_get_flags(tx, STREAM_TOCLIENT) != SshStateFinished ); + void *tx = SCSshStateGetTx(ssh_state, 0); + FAIL_IF(SCSshTxGetFlags(tx, STREAM_TOCLIENT) != SshStateFinished); FAIL_IF(SSHParserTestUtilCheck("2.0", NULL, tx, STREAM_TOCLIENT)); @@ -1332,8 +1331,8 @@ static int SSHParserTest21(void) void *ssh_state = f->alstate; FAIL_IF_NULL(ssh_state); - void * tx = rs_ssh_state_get_tx(ssh_state, 0); - FAIL_IF( rs_ssh_tx_get_flags(tx, STREAM_TOCLIENT) != SshStateFinished ); + void *tx = SCSshStateGetTx(ssh_state, 0); + FAIL_IF(SCSshTxGetFlags(tx, STREAM_TOCLIENT) != SshStateFinished); FAIL_IF(SSHParserTestUtilCheck("2.0", NULL, tx, STREAM_TOCLIENT)); @@ -1428,8 +1427,8 @@ static int SSHParserTest22(void) void *ssh_state = f->alstate; FAIL_IF_NULL(ssh_state); - void * tx = rs_ssh_state_get_tx(ssh_state, 0); - FAIL_IF( rs_ssh_tx_get_flags(tx, STREAM_TOCLIENT) != SshStateFinished ); + void *tx = SCSshStateGetTx(ssh_state, 0); + FAIL_IF(SCSshTxGetFlags(tx, STREAM_TOCLIENT) != SshStateFinished); FAIL_IF(SSHParserTestUtilCheck("2.0", "libssh", tx, STREAM_TOCLIENT)); @@ -1504,8 +1503,8 @@ static int SSHParserTest24(void) printf("no ssh state: "); goto end; } - void * tx = rs_ssh_state_get_tx(ssh_state, 0); - if ( rs_ssh_tx_get_flags(tx, STREAM_TOSERVER) != SshStateBannerDone ) { + void *tx = SCSshStateGetTx(ssh_state, 0); + if (SCSshTxGetFlags(tx, STREAM_TOSERVER) != SshStateBannerDone) { printf("Didn't detect the msg code of new keys (ciphered data starts): "); goto end; } @@ -1545,11 +1544,11 @@ static int SSHParserTest25(void) void *ssh_state = f.alstate; FAIL_IF_NULL(ssh_state); - void * tx = rs_ssh_state_get_tx(ssh_state, 0); - FAIL_IF( rs_ssh_tx_get_flags(tx, STREAM_TOSERVER) == SshStateBannerDone ); + void *tx = SCSshStateGetTx(ssh_state, 0); + FAIL_IF(SCSshTxGetFlags(tx, STREAM_TOSERVER) == SshStateBannerDone); const uint8_t *dummy = NULL; uint32_t dummy_len = 0; - FAIL_IF (rs_ssh_tx_get_software(tx, &dummy, &dummy_len, STREAM_TOCLIENT) != 0); + FAIL_IF(SCSshTxGetSoftware(tx, &dummy, &dummy_len, STREAM_TOCLIENT) != 0); AppLayerParserThreadCtxFree(alp_tctx); StreamTcpFreeConfig(true); diff --git a/src/detect-ssh-hassh-server-string.c b/src/detect-ssh-hassh-server-string.c index 6aefc39682..45e67edb3c 100644 --- a/src/detect-ssh-hassh-server-string.c +++ b/src/detect-ssh-hassh-server-string.c @@ -69,7 +69,7 @@ static InspectionBuffer *GetSshData(DetectEngineThreadCtx *det_ctx, const uint8_t *hassh = NULL; uint32_t b_len = 0; - if (rs_ssh_tx_get_hassh_string(txv, &hassh, &b_len, flow_flags) != 1) + if (SCSshTxGetHasshString(txv, &hassh, &b_len, flow_flags) != 1) return NULL; if (hassh == NULL || b_len == 0) { SCLogDebug("SSH hassh string is not set"); @@ -103,10 +103,10 @@ static int DetectSshHasshServerStringSetup(DetectEngineCtx *de_ctx, Signature *s return -1; /* try to enable Hassh */ - rs_ssh_enable_hassh(); + SCSshEnableHassh(); /* Check if Hassh is disabled */ - if (!RunmodeIsUnittests() && !rs_ssh_hassh_is_enabled()) { + if (!RunmodeIsUnittests() && !SCSshHasshIsEnabled()) { if (!SigMatchSilentErrorEnabled(de_ctx, DETECT_SSH_HASSH_SERVER_STRING)) { SCLogError("hassh support is not enabled"); } diff --git a/src/detect-ssh-hassh-server.c b/src/detect-ssh-hassh-server.c index 487ea92f14..da51188538 100644 --- a/src/detect-ssh-hassh-server.c +++ b/src/detect-ssh-hassh-server.c @@ -70,7 +70,7 @@ static InspectionBuffer *GetSshData(DetectEngineThreadCtx *det_ctx, const uint8_t *hasshServer = NULL; uint32_t b_len = 0; - if (rs_ssh_tx_get_hassh(txv, &hasshServer, &b_len, flow_flags) != 1) + if (SCSshTxGetHassh(txv, &hasshServer, &b_len, flow_flags) != 1) return NULL; if (hasshServer == NULL || b_len == 0) { SCLogDebug("SSH hassh not set"); @@ -104,10 +104,10 @@ static int DetectSshHasshServerSetup(DetectEngineCtx *de_ctx, Signature *s, cons return -1; /* try to enable Hassh */ - rs_ssh_enable_hassh(); + SCSshEnableHassh(); /* Check if Hassh is disabled */ - if (!RunmodeIsUnittests() && !rs_ssh_hassh_is_enabled()) { + if (!RunmodeIsUnittests() && !SCSshHasshIsEnabled()) { if (!SigMatchSilentErrorEnabled(de_ctx, DETECT_SSH_HASSH_SERVER)) { SCLogError("hassh support is not enabled"); } diff --git a/src/detect-ssh-hassh-string.c b/src/detect-ssh-hassh-string.c index 9b268ee96c..346e94d74b 100644 --- a/src/detect-ssh-hassh-string.c +++ b/src/detect-ssh-hassh-string.c @@ -69,7 +69,7 @@ static InspectionBuffer *GetSshData(DetectEngineThreadCtx *det_ctx, const uint8_t *hassh = NULL; uint32_t b_len = 0; - if (rs_ssh_tx_get_hassh_string(txv, &hassh, &b_len, flow_flags) != 1) + if (SCSshTxGetHasshString(txv, &hassh, &b_len, flow_flags) != 1) return NULL; if (hassh == NULL || b_len == 0) { SCLogDebug("SSH hassh string is not set"); @@ -103,10 +103,10 @@ static int DetectSshHasshStringSetup(DetectEngineCtx *de_ctx, Signature *s, cons return -1; /* try to enable Hassh */ - rs_ssh_enable_hassh(); + SCSshEnableHassh(); /* Check if Hassh is disabled */ - if (!RunmodeIsUnittests() && !rs_ssh_hassh_is_enabled()) { + if (!RunmodeIsUnittests() && !SCSshHasshIsEnabled()) { if (!SigMatchSilentErrorEnabled(de_ctx, DETECT_SSH_HASSH_STRING)) { SCLogError("hassh support is not enabled"); } diff --git a/src/detect-ssh-hassh.c b/src/detect-ssh-hassh.c index d8309c265c..ec78519b90 100644 --- a/src/detect-ssh-hassh.c +++ b/src/detect-ssh-hassh.c @@ -70,7 +70,7 @@ static InspectionBuffer *GetSshData(DetectEngineThreadCtx *det_ctx, const uint8_t *hassh = NULL; uint32_t b_len = 0; - if (rs_ssh_tx_get_hassh(txv, &hassh, &b_len, flow_flags) != 1) + if (SCSshTxGetHassh(txv, &hassh, &b_len, flow_flags) != 1) return NULL; if (hassh == NULL || b_len == 0) { SCLogDebug("SSH hassh not set"); @@ -104,10 +104,10 @@ static int DetectSshHasshSetup(DetectEngineCtx *de_ctx, Signature *s, const char return -1; /* try to enable Hassh */ - rs_ssh_enable_hassh(); + SCSshEnableHassh(); /* Check if Hassh is disabled */ - if (!RunmodeIsUnittests() && !rs_ssh_hassh_is_enabled()) { + if (!RunmodeIsUnittests() && !SCSshHasshIsEnabled()) { if (!SigMatchSilentErrorEnabled(de_ctx, DETECT_SSH_HASSH)) { SCLogError("hassh support is not enabled"); } diff --git a/src/detect-ssh-proto.c b/src/detect-ssh-proto.c index 5d53881abc..5ed0cdfb54 100644 --- a/src/detect-ssh-proto.c +++ b/src/detect-ssh-proto.c @@ -67,7 +67,7 @@ static InspectionBuffer *GetSshData(DetectEngineThreadCtx *det_ctx, const uint8_t *protocol = NULL; uint32_t b_len = 0; - if (rs_ssh_tx_get_protocol(txv, &protocol, &b_len, flow_flags) != 1) + if (SCSshTxGetProtocol(txv, &protocol, &b_len, flow_flags) != 1) return NULL; if (protocol == NULL || b_len == 0) { SCLogDebug("SSH protocol not set"); diff --git a/src/detect-ssh-software.c b/src/detect-ssh-software.c index c7b89b5ea1..d7cb872523 100644 --- a/src/detect-ssh-software.c +++ b/src/detect-ssh-software.c @@ -67,7 +67,7 @@ static InspectionBuffer *GetSshData(DetectEngineThreadCtx *det_ctx, const uint8_t *software = NULL; uint32_t b_len = 0; - if (rs_ssh_tx_get_software(txv, &software, &b_len, flow_flags) != 1) + if (SCSshTxGetSoftware(txv, &software, &b_len, flow_flags) != 1) return NULL; if (software == NULL || b_len == 0) { SCLogDebug("SSH software version not set"); diff --git a/src/output.c b/src/output.c index 6af423fb47..b86e3d483c 100644 --- a/src/output.c +++ b/src/output.c @@ -866,7 +866,7 @@ void OutputRegisterRootLoggers(void) // ALPROTO_SMTP special: uses state RegisterSimpleJsonApplayerLogger(ALPROTO_TLS, JsonTlsLogJSONExtended, NULL); // no cast here but done in rust for SSHTransaction - RegisterSimpleJsonApplayerLogger(ALPROTO_SSH, rs_ssh_log_json, NULL); + RegisterSimpleJsonApplayerLogger(ALPROTO_SSH, SCSshLogJson, NULL); // ALPROTO_SMB special: uses state // ALPROTO_DCERPC special: uses state RegisterSimpleJsonApplayerLogger(ALPROTO_DNS, AlertJsonDns, NULL); diff --git a/src/util-lua-hassh.c b/src/util-lua-hassh.c index f4c5216e5c..752a178de7 100644 --- a/src/util-lua-hassh.c +++ b/src/util-lua-hassh.c @@ -64,8 +64,8 @@ static int GetHasshServerString(lua_State *luastate, const Flow *f) const uint8_t *hassh_server_string = NULL; uint32_t b_len = 0; - void *tx = rs_ssh_state_get_tx(state, 0); - if (rs_ssh_tx_get_hassh_string(tx, &hassh_server_string, &b_len, STREAM_TOCLIENT) != 1) + void *tx = SCSshStateGetTx(state, 0); + if (SCSshTxGetHasshString(tx, &hassh_server_string, &b_len, STREAM_TOCLIENT) != 1) return LuaCallbackError(luastate, "error: no server hassh string"); if (hassh_server_string == NULL || b_len == 0) { return LuaCallbackError(luastate, "error: no server hassh string"); @@ -99,8 +99,8 @@ static int GetHasshServer(lua_State *luastate, const Flow *f) const uint8_t *hassh_server = NULL; uint32_t b_len = 0; - void *tx = rs_ssh_state_get_tx(state, 0); - if (rs_ssh_tx_get_hassh(tx, &hassh_server, &b_len, STREAM_TOCLIENT) != 1) + void *tx = SCSshStateGetTx(state, 0); + if (SCSshTxGetHassh(tx, &hassh_server, &b_len, STREAM_TOCLIENT) != 1) return LuaCallbackError(luastate, "error: no server hassh"); if (hassh_server == NULL || b_len == 0) { return LuaCallbackError(luastate, "error: no server hassh"); @@ -134,8 +134,8 @@ static int GetHasshString(lua_State *luastate, const Flow *f) const uint8_t *hassh_string = NULL; uint32_t b_len = 0; - void *tx = rs_ssh_state_get_tx(state, 0); - if (rs_ssh_tx_get_hassh_string(tx, &hassh_string, &b_len, STREAM_TOSERVER) != 1) + void *tx = SCSshStateGetTx(state, 0); + if (SCSshTxGetHasshString(tx, &hassh_string, &b_len, STREAM_TOSERVER) != 1) return LuaCallbackError(luastate, "error: no client hassh_string"); if (hassh_string == NULL || b_len == 0) { return LuaCallbackError(luastate, "error: no client hassh_string"); @@ -169,8 +169,8 @@ static int GetHassh(lua_State *luastate, const Flow *f) const uint8_t *hassh = NULL; uint32_t b_len = 0; - void *tx = rs_ssh_state_get_tx(state, 0); - if (rs_ssh_tx_get_hassh(tx, &hassh, &b_len, STREAM_TOSERVER) != 1) + void *tx = SCSshStateGetTx(state, 0); + if (SCSshTxGetHassh(tx, &hassh, &b_len, STREAM_TOSERVER) != 1) return LuaCallbackError(luastate, "error: no client hassh"); if (hassh == NULL || b_len == 0) { return LuaCallbackError(luastate, "error: no client hassh"); diff --git a/src/util-lua-ssh.c b/src/util-lua-ssh.c index f8d6e30ccd..a2d6d2edaf 100644 --- a/src/util-lua-ssh.c +++ b/src/util-lua-ssh.c @@ -64,8 +64,8 @@ static int GetServerProtoVersion(lua_State *luastate, const Flow *f) const uint8_t *protocol = NULL; uint32_t b_len = 0; - void *tx = rs_ssh_state_get_tx(state, 0); - if (rs_ssh_tx_get_protocol(tx, &protocol, &b_len, STREAM_TOCLIENT) != 1) + void *tx = SCSshStateGetTx(state, 0); + if (SCSshTxGetProtocol(tx, &protocol, &b_len, STREAM_TOCLIENT) != 1) return LuaCallbackError(luastate, "error: no server proto version"); if (protocol == NULL || b_len == 0) { return LuaCallbackError(luastate, "error: no server proto version"); @@ -99,8 +99,8 @@ static int GetServerSoftwareVersion(lua_State *luastate, const Flow *f) const uint8_t *software = NULL; uint32_t b_len = 0; - void *tx = rs_ssh_state_get_tx(state, 0); - if (rs_ssh_tx_get_software(tx, &software, &b_len, STREAM_TOCLIENT) != 1) + void *tx = SCSshStateGetTx(state, 0); + if (SCSshTxGetSoftware(tx, &software, &b_len, STREAM_TOCLIENT) != 1) return LuaCallbackError(luastate, "error: no server software version"); if (software == NULL || b_len == 0) { return LuaCallbackError(luastate, "error: no server software version"); @@ -134,8 +134,8 @@ static int GetClientProtoVersion(lua_State *luastate, const Flow *f) const uint8_t *protocol = NULL; uint32_t b_len = 0; - void *tx = rs_ssh_state_get_tx(state, 0); - if (rs_ssh_tx_get_protocol(tx, &protocol, &b_len, STREAM_TOSERVER) != 1) + void *tx = SCSshStateGetTx(state, 0); + if (SCSshTxGetProtocol(tx, &protocol, &b_len, STREAM_TOSERVER) != 1) return LuaCallbackError(luastate, "error: no client proto version"); if (protocol == NULL || b_len == 0) { return LuaCallbackError(luastate, "error: no client proto version"); @@ -169,8 +169,8 @@ static int GetClientSoftwareVersion(lua_State *luastate, const Flow *f) const uint8_t *software = NULL; uint32_t b_len = 0; - void *tx = rs_ssh_state_get_tx(state, 0); - if (rs_ssh_tx_get_software(tx, &software, &b_len, STREAM_TOSERVER) != 1) + void *tx = SCSshStateGetTx(state, 0); + if (SCSshTxGetSoftware(tx, &software, &b_len, STREAM_TOSERVER) != 1) return LuaCallbackError(luastate, "error: no client software version"); if (software == NULL || b_len == 0) { return LuaCallbackError(luastate, "error: no client software version");