diff --git a/rust/src/sip/detect.rs b/rust/src/sip/detect.rs index d4f61f9479..7bedd9169b 100644 --- a/rust/src/sip/detect.rs +++ b/rust/src/sip/detect.rs @@ -41,7 +41,7 @@ static mut G_SIP_CONTENT_TYPE_HDR_BUFFER_ID: c_int = 0; static mut G_SIP_CONTENT_LENGTH_HDR_BUFFER_ID: c_int = 0; #[no_mangle] -pub unsafe extern "C" fn rs_sip_tx_get_method( +pub unsafe extern "C" fn SCSipTxGetMethod( tx: &SIPTransaction, buffer: *mut *const u8, buffer_len: *mut u32, ) -> u8 { if let Some(ref r) = tx.request { @@ -60,7 +60,7 @@ pub unsafe extern "C" fn rs_sip_tx_get_method( } #[no_mangle] -pub unsafe extern "C" fn rs_sip_tx_get_uri( +pub unsafe extern "C" fn SCSipTxGetUri( tx: &SIPTransaction, buffer: *mut *const u8, buffer_len: *mut u32, ) -> u8 { if let Some(ref r) = tx.request { diff --git a/rust/src/sip/log.rs b/rust/src/sip/log.rs index 49e30a00db..bcab30b0d4 100644 --- a/rust/src/sip/log.rs +++ b/rust/src/sip/log.rs @@ -57,6 +57,6 @@ fn log(tx: &SIPTransaction, js: &mut JsonBuilder) -> Result<(), JsonError> { } #[no_mangle] -pub extern "C" fn rs_sip_log_json(tx: &SIPTransaction, js: &mut JsonBuilder) -> bool { +pub extern "C" fn SCSipLogJson(tx: &SIPTransaction, js: &mut JsonBuilder) -> bool { log(tx, js).is_ok() } diff --git a/rust/src/sip/parser.rs b/rust/src/sip/parser.rs index bc66640da6..b833616fe5 100644 --- a/rust/src/sip/parser.rs +++ b/rust/src/sip/parser.rs @@ -113,7 +113,7 @@ fn expand_header_name(h: &str) -> &str { } } -pub fn sip_parse_request(oi: &[u8]) -> IResult<&[u8], Request> { +pub fn parse_request(oi: &[u8]) -> IResult<&[u8], Request> { let (i, method) = parse_method(oi)?; let (i, _) = char(' ')(i)?; let (i, path) = parse_request_uri(i)?; @@ -143,7 +143,7 @@ pub fn sip_parse_request(oi: &[u8]) -> IResult<&[u8], Request> { )) } -pub fn sip_parse_response(oi: &[u8]) -> IResult<&[u8], Response> { +pub fn parse_response(oi: &[u8]) -> IResult<&[u8], Response> { let (i, version) = parse_version(oi)?; let (i, _) = char(' ')(i)?; let (i, code) = parse_code(i)?; @@ -308,7 +308,7 @@ mod tests { \r\n" .as_bytes(); - let (_, req) = sip_parse_request(buf).unwrap(); + let (_, req) = parse_request(buf).unwrap(); assert_eq!(req.method, "REGISTER"); assert_eq!(req.path, "sip:sip.cybercity.dk"); assert_eq!(req.version, "SIP/2.0"); @@ -324,7 +324,7 @@ mod tests { \r\nABCD" .as_bytes(); - let (body, req) = sip_parse_request(buf).expect("parsing failed"); + let (body, req) = parse_request(buf).expect("parsing failed"); assert_eq!(req.method, "REGISTER"); assert_eq!(req.path, "sip:sip.cybercity.dk"); assert_eq!(req.version, "SIP/2.0"); @@ -338,7 +338,7 @@ mod tests { \r\n" .as_bytes(); - let (_, resp) = sip_parse_response(buf).unwrap(); + let (_, resp) = parse_response(buf).unwrap(); assert_eq!(resp.version, "SIP/2.0"); assert_eq!(resp.code, "401"); assert_eq!(resp.reason, "Unauthorized"); @@ -370,7 +370,7 @@ mod tests { \r\n" .as_bytes(); - let (_, req) = sip_parse_request(buf).unwrap(); + let (_, req) = parse_request(buf).unwrap(); assert_eq!(req.method, "REGISTER"); assert_eq!(req.path, "sip:sip.cybercity.dk"); assert_eq!(req.version, "SIP/2.0"); diff --git a/rust/src/sip/sip.rs b/rust/src/sip/sip.rs index e85bdd7ad8..b58940f346 100755 --- a/rust/src/sip/sip.rs +++ b/rust/src/sip/sip.rs @@ -128,7 +128,7 @@ impl SIPState { ); SCLogDebug!("ts: pdu {:?}", _pdu); - match sip_parse_request(input) { + match parse_request(input) { Ok((_, request)) => { let mut tx = self.new_tx(Direction::ToServer); sip_frames_ts(flow, &stream_slice, &request, tx.id); @@ -172,7 +172,7 @@ impl SIPState { ); SCLogDebug!("ts: pdu {:?}", self.request_frame); } - match sip_parse_request(start) { + match parse_request(start) { Ok((rem, request)) => { let mut tx = self.new_tx(Direction::ToServer); let tx_id = tx.id; @@ -224,7 +224,7 @@ impl SIPState { ); SCLogDebug!("tc: pdu {:?}", _pdu); - match sip_parse_response(input) { + match parse_response(input) { Ok((_, response)) => { let mut tx = self.new_tx(Direction::ToClient); sip_frames_tc(flow, &stream_slice, &response, tx.id); @@ -267,7 +267,7 @@ impl SIPState { ); SCLogDebug!("tc: pdu {:?}", self.request_frame); } - match sip_parse_response(start) { + match parse_response(start) { Ok((rem, response)) => { let mut tx = self.new_tx(Direction::ToClient); let tx_id = tx.id; @@ -393,8 +393,7 @@ fn sip_frames_tc(flow: *const Flow, stream_slice: &StreamSlice, r: &Response, tx } } -#[no_mangle] -pub extern "C" fn rs_sip_state_new( +extern "C" fn sip_state_new( _orig_state: *mut std::os::raw::c_void, _orig_proto: AppProto, ) -> *mut std::os::raw::c_void { let state = SIPState::new(); @@ -402,14 +401,12 @@ pub extern "C" fn rs_sip_state_new( return Box::into_raw(boxed) as *mut _; } -#[no_mangle] -pub extern "C" fn rs_sip_state_free(state: *mut std::os::raw::c_void) { +extern "C" fn sip_state_free(state: *mut std::os::raw::c_void) { let mut state = unsafe { Box::from_raw(state as *mut SIPState) }; state.free(); } -#[no_mangle] -pub unsafe extern "C" fn rs_sip_state_get_tx( +unsafe extern "C" fn sip_state_get_tx( state: *mut std::os::raw::c_void, tx_id: u64, ) -> *mut std::os::raw::c_void { let state = cast_pointer!(state, SIPState); @@ -419,20 +416,17 @@ pub unsafe extern "C" fn rs_sip_state_get_tx( } } -#[no_mangle] -pub unsafe extern "C" fn rs_sip_state_get_tx_count(state: *mut std::os::raw::c_void) -> u64 { +unsafe extern "C" fn sip_state_get_tx_count(state: *mut std::os::raw::c_void) -> u64 { let state = cast_pointer!(state, SIPState); state.tx_id } -#[no_mangle] -pub unsafe extern "C" fn rs_sip_state_tx_free(state: *mut std::os::raw::c_void, tx_id: u64) { +unsafe extern "C" fn sip_state_tx_free(state: *mut std::os::raw::c_void, tx_id: u64) { let state = cast_pointer!(state, SIPState); state.free_tx(tx_id); } -#[no_mangle] -pub extern "C" fn rs_sip_tx_get_alstate_progress( +extern "C" fn sip_tx_get_alstate_progress( _tx: *mut std::os::raw::c_void, _direction: u8, ) -> std::os::raw::c_int { 1 @@ -440,8 +434,7 @@ pub extern "C" fn rs_sip_tx_get_alstate_progress( pub static mut ALPROTO_SIP: AppProto = ALPROTO_UNKNOWN; -#[no_mangle] -pub unsafe extern "C" fn rs_sip_parse_request( +unsafe extern "C" fn sip_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 { @@ -449,8 +442,7 @@ pub unsafe extern "C" fn rs_sip_parse_request( state.parse_request(flow, stream_slice).into() } -#[no_mangle] -pub unsafe extern "C" fn rs_sip_parse_request_tcp( +unsafe extern "C" fn sip_parse_request_tcp( 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 { @@ -466,8 +458,7 @@ pub unsafe extern "C" fn rs_sip_parse_request_tcp( state.parse_request_tcp(flow, stream_slice) } -#[no_mangle] -pub unsafe extern "C" fn rs_sip_parse_response( +unsafe extern "C" fn sip_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, ) -> AppLayerResult { @@ -475,8 +466,7 @@ pub unsafe extern "C" fn rs_sip_parse_response( state.parse_response(flow, stream_slice).into() } -#[no_mangle] -pub unsafe extern "C" fn rs_sip_parse_response_tcp( +unsafe extern "C" fn sip_parse_response_tcp( 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 { @@ -553,7 +543,7 @@ export_state_data_get!(sip_get_state_data, SIPState); const PARSER_NAME: &[u8] = b"sip\0"; #[no_mangle] -pub unsafe extern "C" fn rs_sip_register_parser() { +pub unsafe extern "C" fn SCRegisterSipParser() { let mut parser = RustParser { name: PARSER_NAME.as_ptr() as *const std::os::raw::c_char, default_port: std::ptr::null(), @@ -562,16 +552,16 @@ pub unsafe extern "C" fn rs_sip_register_parser() { probe_tc: None, min_depth: 0, max_depth: 16, - state_new: rs_sip_state_new, - state_free: rs_sip_state_free, - tx_free: rs_sip_state_tx_free, - parse_ts: rs_sip_parse_request, - parse_tc: rs_sip_parse_response, - get_tx_count: rs_sip_state_get_tx_count, - get_tx: rs_sip_state_get_tx, + state_new: sip_state_new, + state_free: sip_state_free, + tx_free: sip_state_tx_free, + parse_ts: sip_parse_request, + parse_tc: sip_parse_response, + get_tx_count: sip_state_get_tx_count, + get_tx: sip_state_get_tx, tx_comp_st_ts: 1, tx_comp_st_tc: 1, - tx_get_progress: rs_sip_tx_get_alstate_progress, + tx_get_progress: sip_tx_get_alstate_progress, get_eventinfo: Some(SIPEvent::get_event_info), get_eventinfo_byid: Some(SIPEvent::get_event_info_by_id), localstorage_new: None, @@ -607,8 +597,8 @@ pub unsafe extern "C" fn rs_sip_register_parser() { parser.ipproto = core::IPPROTO_TCP; parser.probe_ts = None; parser.probe_tc = None; - parser.parse_ts = rs_sip_parse_request_tcp; - parser.parse_tc = rs_sip_parse_response_tcp; + parser.parse_ts = sip_parse_request_tcp; + parser.parse_tc = sip_parse_response_tcp; let ip_proto_str = CString::new("tcp").unwrap(); if AppLayerProtoDetectConfProtoDetectionEnabled(ip_proto_str.as_ptr(), parser.name) != 0 { diff --git a/src/app-layer-parser.c b/src/app-layer-parser.c index b95cb9433d..06b0015a30 100644 --- a/src/app-layer-parser.c +++ b/src/app-layer-parser.c @@ -1793,7 +1793,7 @@ void AppLayerParserRegisterProtocolParsers(void) SCRegisterKrb5Parser(); SCRegisterDhcpParser(); SCRegisterSnmpParser(); - rs_sip_register_parser(); + SCRegisterSipParser(); rs_quic_register_parser(); rs_websocket_register_parser(); SCRegisterLdapTcpParser(); diff --git a/src/detect-sip-method.c b/src/detect-sip-method.c index e9a5387b4e..a07e4cb40d 100644 --- a/src/detect-sip-method.c +++ b/src/detect-sip-method.c @@ -114,7 +114,7 @@ static InspectionBuffer *GetData(DetectEngineThreadCtx *det_ctx, const uint8_t *b = NULL; uint32_t b_len = 0; - if (rs_sip_tx_get_method(txv, &b, &b_len) != 1) + if (SCSipTxGetMethod(txv, &b, &b_len) != 1) return NULL; if (b == NULL || b_len == 0) return NULL; diff --git a/src/detect-sip-uri.c b/src/detect-sip-uri.c index 202b089372..1b1221a991 100644 --- a/src/detect-sip-uri.c +++ b/src/detect-sip-uri.c @@ -87,7 +87,7 @@ static InspectionBuffer *GetData(DetectEngineThreadCtx *det_ctx, const uint8_t *b = NULL; uint32_t b_len = 0; - if (rs_sip_tx_get_uri(txv, &b, &b_len) != 1) + if (SCSipTxGetUri(txv, &b, &b_len) != 1) return NULL; if (b == NULL || b_len == 0) return NULL; diff --git a/src/output.c b/src/output.c index d9858b8fe5..a82eaffcc2 100644 --- a/src/output.c +++ b/src/output.c @@ -916,7 +916,7 @@ void OutputRegisterRootLoggers(void) ALPROTO_KRB5, (EveJsonSimpleTxLogFunc)SCKrb5LogJsonResponse, NULL); RegisterSimpleJsonApplayerLogger(ALPROTO_QUIC, (EveJsonSimpleTxLogFunc)rs_quic_to_json, NULL); // ALPROTO_DHCP TODO missing - RegisterSimpleJsonApplayerLogger(ALPROTO_SIP, (EveJsonSimpleTxLogFunc)rs_sip_log_json, NULL); + RegisterSimpleJsonApplayerLogger(ALPROTO_SIP, (EveJsonSimpleTxLogFunc)SCSipLogJson, NULL); RegisterSimpleJsonApplayerLogger(ALPROTO_RFB, (EveJsonSimpleTxLogFunc)rs_rfb_logger_log, NULL); RegisterSimpleJsonApplayerLogger(ALPROTO_POP3, (EveJsonSimpleTxLogFunc)SCPop3LoggerLog, NULL); RegisterSimpleJsonApplayerLogger(