diff --git a/rust/src/common.rs b/rust/src/common.rs index aa7741f5e1..814fdd2d38 100644 --- a/rust/src/common.rs +++ b/rust/src/common.rs @@ -81,7 +81,7 @@ pub fn rust_string_to_c(s: String) -> *mut c_char { /// /// s must be allocated by rust, using `CString::new` #[no_mangle] -pub unsafe extern "C" fn rs_cstring_free(s: *mut c_char) { +pub unsafe extern "C" fn SCRustCStringFree(s: *mut c_char) { if s.is_null() { return; } @@ -102,7 +102,7 @@ pub fn to_hex(input: &[u8]) -> String { } #[no_mangle] -pub unsafe extern "C" fn rs_to_hex( +pub unsafe extern "C" fn SCToHex( output: *mut u8, out_len: usize, input: *const u8, in_len: usize, ) { if out_len < 2 * in_len + 1 { @@ -119,7 +119,7 @@ pub unsafe extern "C" fn rs_to_hex( } #[no_mangle] -pub unsafe extern "C" fn rs_to_hex_sep( +pub unsafe extern "C" fn SCToHex_sep( output: *mut u8, out_len: usize, sep: u8, input: *const u8, in_len: usize, ) { if out_len < 3 * in_len { diff --git a/rust/src/core.rs b/rust/src/core.rs index 73a67d22a6..ee4960293e 100644 --- a/rust/src/core.rs +++ b/rust/src/core.rs @@ -205,7 +205,7 @@ pub fn init_ffi(context: &'static SuricataContext) } #[no_mangle] -pub extern "C" fn rs_init(context: &'static SuricataContext) +pub extern "C" fn SCRustInit(context: &'static SuricataContext) { init_ffi(context); } diff --git a/rust/src/ike/ike.rs b/rust/src/ike/ike.rs index 398fd6e83b..07e7358356 100644 --- a/rust/src/ike/ike.rs +++ b/rust/src/ike/ike.rs @@ -365,7 +365,7 @@ export_tx_data_get!(ike_get_tx_data, IKETransaction); export_state_data_get!(ike_get_state_data, IKEState); #[no_mangle] -pub unsafe extern "C" fn rs_ike_register_parser() { +pub unsafe extern "C" fn SCRegisterIkeParser() { let default_port = CString::new("500").unwrap(); let parser = RustParser { name: PARSER_NAME.as_ptr() as *const std::os::raw::c_char, diff --git a/rust/src/krb/krb5.rs b/rust/src/krb/krb5.rs index 79f160f29c..db0e472b30 100644 --- a/rust/src/krb/krb5.rs +++ b/rust/src/krb/krb5.rs @@ -467,7 +467,7 @@ unsafe extern "C" fn krb5_parse_request_tcp( // sanity check to avoid memory exhaustion if state.defrag_buf_ts.len() + buf.len() > 100000 { SCLogDebug!( - "rs_krb5_parse_request_tcp: TCP buffer exploded {} {}", + "krb5_parse_request_tcp: TCP buffer exploded {} {}", state.defrag_buf_ts.len(), buf.len() ); @@ -491,7 +491,7 @@ unsafe extern "C" fn krb5_parse_request_tcp( return AppLayerResult::ok(); } _ => { - SCLogDebug!("rs_krb5_parse_request_tcp: reading record mark failed!"); + SCLogDebug!("krb5_parse_request_tcp: reading record mark failed!"); return AppLayerResult::err(); } } @@ -525,7 +525,7 @@ unsafe extern "C" fn krb5_parse_response_tcp( // sanity check to avoid memory exhaustion if state.defrag_buf_tc.len() + buf.len() > 100000 { SCLogDebug!( - "rs_krb5_parse_response_tcp: TCP buffer exploded {} {}", + "krb5_parse_response_tcp: TCP buffer exploded {} {}", state.defrag_buf_tc.len(), buf.len() ); diff --git a/rust/src/ldap/logger.rs b/rust/src/ldap/logger.rs index 7ab372d877..57557f3a40 100644 --- a/rust/src/ldap/logger.rs +++ b/rust/src/ldap/logger.rs @@ -348,7 +348,7 @@ fn log_controls(controls: &Option>, js: &mut JsonBuilder) -> Result } #[no_mangle] -pub unsafe extern "C" fn rs_ldap_logger_log( +pub unsafe extern "C" fn SCLdapLoggerLog( tx: *mut std::os::raw::c_void, js: &mut JsonBuilder, ) -> bool { let tx = cast_pointer!(tx, LdapTransaction); diff --git a/rust/src/ntp/ntp.rs b/rust/src/ntp/ntp.rs index 468eb68e7d..d547a49625 100644 --- a/rust/src/ntp/ntp.rs +++ b/rust/src/ntp/ntp.rs @@ -254,7 +254,7 @@ export_state_data_get!(ntp_get_state_data, NTPState); const PARSER_NAME: &[u8] = b"ntp\0"; #[no_mangle] -pub unsafe extern "C" fn rs_register_ntp_parser() { +pub unsafe extern "C" fn SCRegisterNtpParser() { let default_port = CString::new("123").unwrap(); let parser = RustParser { name: PARSER_NAME.as_ptr() as *const std::os::raw::c_char, diff --git a/rust/src/ssh/ssh.rs b/rust/src/ssh/ssh.rs index e9ead58377..174644d85b 100644 --- a/rust/src/ssh/ssh.rs +++ b/rust/src/ssh/ssh.rs @@ -441,7 +441,7 @@ extern "C" fn ssh_state_tx_free(_state: *mut std::os::raw::c_void, _tx_id: u64) //do nothing } -unsafe extern "C" fn rs_ssh_parse_request( +unsafe extern "C" fn 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, ) -> AppLayerResult { @@ -535,7 +535,7 @@ pub unsafe extern "C" fn SCRegisterSshParser() { state_new: ssh_state_new, state_free: ssh_state_free, tx_free: ssh_state_tx_free, - parse_ts: rs_ssh_parse_request, + parse_ts: ssh_parse_request, parse_tc: ssh_parse_response, get_tx_count: ssh_state_get_tx_count, get_tx: SCSshStateGetTx, diff --git a/rust/src/util.rs b/rust/src/util.rs index d3f76e41eb..56b37ea853 100644 --- a/rust/src/util.rs +++ b/rust/src/util.rs @@ -28,7 +28,7 @@ use nom7::multi::many1_count; use nom7::IResult; #[no_mangle] -pub unsafe extern "C" fn rs_check_utf8(val: *const c_char) -> bool { +pub unsafe extern "C" fn SCCheckUtf8(val: *const c_char) -> bool { CStr::from_ptr(val).to_str().is_ok() } diff --git a/src/app-layer-ike.c b/src/app-layer-ike.c index fa8c33cc80..f11ecdd356 100644 --- a/src/app-layer-ike.c +++ b/src/app-layer-ike.c @@ -39,7 +39,7 @@ void RegisterIKEParsers(void) { - rs_ike_register_parser(); + SCRegisterIkeParser(); #ifdef UNITTESTS AppLayerParserRegisterProtocolUnittests(IPPROTO_UDP, ALPROTO_IKE, IKEParserRegisterTests); #endif diff --git a/src/app-layer-parser.c b/src/app-layer-parser.c index cbf97e2346..75845c4a51 100644 --- a/src/app-layer-parser.c +++ b/src/app-layer-parser.c @@ -1787,7 +1787,7 @@ void AppLayerParserRegisterProtocolParsers(void) RegisterDNP3Parsers(); RegisterNFSTCPParsers(); RegisterNFSUDPParsers(); - rs_register_ntp_parser(); + SCRegisterNtpParser(); RegisterTFTPParsers(); RegisterIKEParsers(); SCRegisterKrb5Parser(); diff --git a/src/app-layer-ssl.c b/src/app-layer-ssl.c index 10c9dce7ca..ff8a11e3fa 100644 --- a/src/app-layer-ssl.c +++ b/src/app-layer-ssl.c @@ -532,7 +532,7 @@ static inline int TlsDecodeHSCertificateFingerprint( uint8_t hash[SC_SHA1_LEN]; if (SCSha1HashBuffer(input, cert_len, hash, sizeof(hash)) == 1) { - rs_to_hex_sep( + SCToHex_sep( (uint8_t *)connp->cert0_fingerprint, SHA1_STRING_LENGTH, ':', hash, SC_SHA1_LEN); } return 0; @@ -2973,7 +2973,7 @@ static void SSLStateCertSANFree(SSLStateConnp *connp) { if (connp->cert0_sans) { for (uint16_t i = 0; i < connp->cert0_sans_len; i++) { - rs_cstring_free(connp->cert0_sans[i]); + SCRustCStringFree(connp->cert0_sans[i]); } SCFree(connp->cert0_sans); } @@ -2989,11 +2989,11 @@ static void SSLStateFree(void *p) SSLCertsChain *item; if (ssl_state->client_connp.cert0_subject) - rs_cstring_free(ssl_state->client_connp.cert0_subject); + SCRustCStringFree(ssl_state->client_connp.cert0_subject); if (ssl_state->client_connp.cert0_issuerdn) - rs_cstring_free(ssl_state->client_connp.cert0_issuerdn); + SCRustCStringFree(ssl_state->client_connp.cert0_issuerdn); if (ssl_state->client_connp.cert0_serial) - rs_cstring_free(ssl_state->client_connp.cert0_serial); + SCRustCStringFree(ssl_state->client_connp.cert0_serial); if (ssl_state->client_connp.cert0_fingerprint) SCFree(ssl_state->client_connp.cert0_fingerprint); if (ssl_state->client_connp.sni) @@ -3004,11 +3004,11 @@ static void SSLStateFree(void *p) SCFree(ssl_state->client_connp.hs_buffer); if (ssl_state->server_connp.cert0_subject) - rs_cstring_free(ssl_state->server_connp.cert0_subject); + SCRustCStringFree(ssl_state->server_connp.cert0_subject); if (ssl_state->server_connp.cert0_issuerdn) - rs_cstring_free(ssl_state->server_connp.cert0_issuerdn); + SCRustCStringFree(ssl_state->server_connp.cert0_issuerdn); if (ssl_state->server_connp.cert0_serial) - rs_cstring_free(ssl_state->server_connp.cert0_serial); + SCRustCStringFree(ssl_state->server_connp.cert0_serial); if (ssl_state->server_connp.cert0_fingerprint) SCFree(ssl_state->server_connp.cert0_fingerprint); if (ssl_state->server_connp.sni) diff --git a/src/detect-parse.c b/src/detect-parse.c index ad7696c731..01c5efd64a 100644 --- a/src/detect-parse.c +++ b/src/detect-parse.c @@ -1828,7 +1828,7 @@ static int SigParse(DetectEngineCtx *de_ctx, Signature *s, const char *sigstr, { SCEnter(); - if (!rs_check_utf8(sigstr)) { + if (!SCCheckUtf8(sigstr)) { SCLogError("rule is not valid UTF-8"); SCReturnInt(-1); } diff --git a/src/output.c b/src/output.c index c1fa74db50..d03cdcaa59 100644 --- a/src/output.c +++ b/src/output.c @@ -924,8 +924,7 @@ void OutputRegisterRootLoggers(void) ALPROTO_PGSQL, (EveJsonSimpleTxLogFunc)JsonPgsqlAddMetadata, NULL); RegisterSimpleJsonApplayerLogger( ALPROTO_WEBSOCKET, (EveJsonSimpleTxLogFunc)SCWebSocketLoggerLog, NULL); - RegisterSimpleJsonApplayerLogger( - ALPROTO_LDAP, (EveJsonSimpleTxLogFunc)rs_ldap_logger_log, NULL); + RegisterSimpleJsonApplayerLogger(ALPROTO_LDAP, (EveJsonSimpleTxLogFunc)SCLdapLoggerLog, NULL); RegisterSimpleJsonApplayerLogger(ALPROTO_DOH2, (EveJsonSimpleTxLogFunc)AlertJsonDoh2, NULL); RegisterSimpleJsonApplayerLogger( ALPROTO_TEMPLATE, (EveJsonSimpleTxLogFunc)SCTemplateLoggerLog, NULL); diff --git a/src/suricata.c b/src/suricata.c index 9b3099149e..6e9a0dacf4 100644 --- a/src/suricata.c +++ b/src/suricata.c @@ -2879,7 +2879,7 @@ void SuricataMainLoop(void) int InitGlobal(void) { - rs_init(&suricata_context); + SCRustInit(&suricata_context); SC_ATOMIC_INIT(engine_stage); diff --git a/src/util-print.c b/src/util-print.c index 77d88faa64..b7f33583d8 100644 --- a/src/util-print.c +++ b/src/util-print.c @@ -255,5 +255,5 @@ const char *PrintInet(int af, const void *src, char *dst, socklen_t size) void PrintHexString(char *str, size_t size, uint8_t *buf, size_t buf_len) { DEBUG_VALIDATE_BUG_ON(size < 2 * buf_len); - rs_to_hex((uint8_t *)str, size, buf, buf_len); + SCToHex((uint8_t *)str, size, buf, buf_len); }