]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
ssh: cleanup rust visibility and naming
authorJason Ish <jason.ish@oisf.net>
Mon, 20 Jan 2025 18:06:20 +0000 (12:06 -0600)
committerVictor Julien <victor@inliniac.net>
Tue, 21 Jan 2025 17:36:36 +0000 (18:36 +0100)
Remove pub and no_mangle from non-exported functions and rename to
Rust as-needed.

Ticket: 7498

13 files changed:
rust/src/ssh/detect.rs
rust/src/ssh/logger.rs
rust/src/ssh/ssh.rs
src/app-layer-ssh.c
src/detect-ssh-hassh-server-string.c
src/detect-ssh-hassh-server.c
src/detect-ssh-hassh-string.c
src/detect-ssh-hassh.c
src/detect-ssh-proto.c
src/detect-ssh-software.c
src/output.c
src/util-lua-hassh.c
src/util-lua-ssh.c

index a8ba19ffa8380ae0d36d67c17e89a02a549a2c72..31c02ba7ea906f522ce9b4fbb0b270c0b7d3c529 100644 (file)
@@ -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,
index bee6693c898ecc1612bed9caf7bde89d7e0b3e2e..3dc4fba68ef57e11bf6cd69ee0e4203fe1c6df4a 100644 (file)
@@ -64,7 +64,7 @@ fn log_ssh(tx: &SSHTransaction, js: &mut JsonBuilder) -> Result<bool, JsonError>
 }
 
 #[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;
index 9a99bb188ebcf44c8df4cdc4b99b54406b026973..2e91c7f7e8496bb14daf56c6976587c8ac6fe2bc 100644 (file)
@@ -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; 
index 71bc786ad6b494ee13e93c40c26fc50a24bdb631..276e0fbee385a51cbd73828561ac9ff2994c0c42 100644 (file)
@@ -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);
index 6aefc39682dd13c6cdaf9d9dfa90e6c43be46452..45e67edb3c8cc13230238478678e4319eb7f8c92 100644 (file)
@@ -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");
         }
index 487ea92f141a4094bca103aec43d1a4ec605d100..da51188538699663337fa84abaf59b896730777e 100644 (file)
@@ -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");
         }
index 9b268ee96c30e005cfe8149fde18de5c04c59b3b..346e94d74b9b9fe54aa3b4f54c0bdeaaa2fdbe0f 100644 (file)
@@ -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");
         }
index d8309c265cbec1fba81856a868ca0b8f623ce28a..ec78519b907f9fec9e1b6813384cfdf1db6d905c 100644 (file)
@@ -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");
         }
index 5d53881abc15f3e4370e3c594575137ff264d17d..5ed0cdfb54a868b7d86ecaf7ecc961d5291c4183 100644 (file)
@@ -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");
index c7b89b5ea18c08529562d8c33bb928ed794d3fd9..d7cb872523ca26cf76798b0da1a1ea47ac053086 100644 (file)
@@ -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");
index 6af423fb47442298cd5b6950d67cffa7c94f8029..b86e3d483c8bdbaabb3dfc5b59d743bb74184257 100644 (file)
@@ -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);
index f4c5216e5c3d756b54309bc78eaa09d5bff37470..752a178de7ae77b88a434db3b8b88021171cf0dc 100644 (file)
@@ -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");
index f8d6e30ccd21fd68662a1cf96948790b944b19db..a2d6d2edaf2a02433b883457503f011527f43814 100644 (file)
@@ -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");