]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
rust/tftp: replace rs_ naming with SC
authorJason Ish <jason.ish@oisf.net>
Fri, 2 May 2025 17:38:26 +0000 (11:38 -0600)
committerVictor Julien <victor@inliniac.net>
Sat, 3 May 2025 06:19:41 +0000 (08:19 +0200)
rust/src/tftp/log.rs
rust/src/tftp/tftp.rs
src/app-layer-tftp.c
src/output.c

index da04521e7fa0f5cbf5f4b40be6f2ec4ac0e6c8b4..33c05de6c871eac419ce6c0483de72282d84aad5 100644 (file)
@@ -34,6 +34,6 @@ fn tftp_log_request(tx: &TFTPTransaction, jb: &mut JsonBuilder) -> Result<(), Js
 }
 
 #[no_mangle]
-pub extern "C" fn rs_tftp_log_json_request(tx: &TFTPTransaction, jb: &mut JsonBuilder) -> bool {
+pub extern "C" fn SCTftpLogJsonRequest(tx: &TFTPTransaction, jb: &mut JsonBuilder) -> bool {
     tftp_log_request(tx, jb).is_ok()
 }
index 8797e4ea1372faf52edb8ca6ca7c6f701bfdc1be..6d77d0c6a0740abdf3e4801fea8fb72433b8a602 100644 (file)
@@ -87,25 +87,25 @@ impl TFTPTransaction {
 }
 
 #[no_mangle]
-pub extern "C" fn rs_tftp_state_alloc() -> *mut std::os::raw::c_void {
+pub extern "C" fn SCTftpStateAlloc() -> *mut std::os::raw::c_void {
     let state = TFTPState { state_data: AppLayerStateData::new(), transactions : Vec::new(), tx_id: 0, };
     let boxed = Box::new(state);
     return Box::into_raw(boxed) as *mut _;
 }
 
 #[no_mangle]
-pub extern "C" fn rs_tftp_state_free(state: *mut std::os::raw::c_void) {
+pub extern "C" fn SCTftpStateFree(state: *mut std::os::raw::c_void) {
     std::mem::drop(unsafe { Box::from_raw(state as *mut TFTPState) });
 }
 
 #[no_mangle]
-pub extern "C" fn rs_tftp_state_tx_free(state: &mut TFTPState,
+pub extern "C" fn SCTftpStateTxFree(state: &mut TFTPState,
                                         tx_id: u64) {
     state.free_tx(tx_id);
 }
 
 #[no_mangle]
-pub extern "C" fn rs_tftp_get_tx(state: &mut TFTPState,
+pub extern "C" fn SCTftpGetTx(state: &mut TFTPState,
                                     tx_id: u64) -> *mut std::os::raw::c_void {
     match state.get_tx_by_id(tx_id) {
         Some(tx) => tx as *const _ as *mut _,
@@ -114,7 +114,7 @@ pub extern "C" fn rs_tftp_get_tx(state: &mut TFTPState,
 }
 
 #[no_mangle]
-pub extern "C" fn rs_tftp_get_tx_cnt(state: &mut TFTPState) -> u64 {
+pub extern "C" fn SCTftpGetTxCnt(state: &mut TFTPState) -> u64 {
     return state.tx_id;
 }
 
@@ -155,7 +155,7 @@ fn parse_tftp_request(input: &[u8]) -> Option<TFTPTransaction> {
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn rs_tftp_request(state: &mut TFTPState,
+pub unsafe extern "C" fn SCTftpParseRequest(state: &mut TFTPState,
                                   input: *const u8,
                                   len: u32) -> i64 {
     let buf = std::slice::from_raw_parts(input, len as usize);
@@ -173,7 +173,7 @@ pub unsafe extern "C" fn rs_tftp_request(state: &mut TFTPState,
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn rs_tftp_get_tx_data(
+pub unsafe extern "C" fn SCTftpGetTxData(
     tx: *mut std::os::raw::c_void)
     -> *mut AppLayerTxData
 {
@@ -182,7 +182,7 @@ pub unsafe extern "C" fn rs_tftp_get_tx_data(
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn rs_tftp_get_state_data(
+pub unsafe extern "C" fn SCTftpGetStateData(
     state: *mut std::os::raw::c_void)
     -> *mut AppLayerStateData
 {
index 4a9b41176af278f31c74faf87dbad060e34d3c3c..7a95fe8aadfc42da716dde99cdf6af4621274086 100644 (file)
 
 static void *TFTPStateAlloc(void *orig_state, AppProto proto_orig)
 {
-    return rs_tftp_state_alloc();
+    return SCTftpStateAlloc();
 }
 
 static void TFTPStateFree(void *state)
 {
-    rs_tftp_state_free(state);
+    SCTftpStateFree(state);
 }
 
 /**
@@ -59,7 +59,7 @@ static void TFTPStateFree(void *state)
  */
 static void TFTPStateTxFree(void *state, uint64_t tx_id)
 {
-    rs_tftp_state_tx_free(state, tx_id);
+    SCTftpStateTxFree(state, tx_id);
 }
 
 static int TFTPStateGetEventInfo(
@@ -108,7 +108,7 @@ static AppLayerResult TFTPParseRequest(Flow *f, void *state, AppLayerParserState
         SCReturnStruct(APP_LAYER_OK);
     }
 
-    int64_t res = rs_tftp_request(state, input, input_len);
+    int64_t res = SCTftpParseRequest(state, input, input_len);
     if (res < 0) {
         SCReturnStruct(APP_LAYER_ERROR);
     }
@@ -126,12 +126,12 @@ static AppLayerResult TFTPParseResponse(Flow *f, void *state, AppLayerParserStat
 
 static uint64_t TFTPGetTxCnt(void *state)
 {
-    return rs_tftp_get_tx_cnt(state);
+    return SCTftpGetTxCnt(state);
 }
 
 static void *TFTPGetTx(void *state, uint64_t tx_id)
 {
-    return rs_tftp_get_tx(state, tx_id);
+    return SCTftpGetTx(state, tx_id);
 }
 
 /**
@@ -228,9 +228,8 @@ void RegisterTFTPParsers(void)
         AppLayerParserRegisterGetEventInfo(IPPROTO_UDP, ALPROTO_TFTP,
                                            TFTPStateGetEventInfo);
 
-        AppLayerParserRegisterTxDataFunc(IPPROTO_UDP, ALPROTO_TFTP,
-                                         rs_tftp_get_tx_data);
-        AppLayerParserRegisterStateDataFunc(IPPROTO_UDP, ALPROTO_TFTP, rs_tftp_get_state_data);
+        AppLayerParserRegisterTxDataFunc(IPPROTO_UDP, ALPROTO_TFTP, SCTftpGetTxData);
+        AppLayerParserRegisterStateDataFunc(IPPROTO_UDP, ALPROTO_TFTP, SCTftpGetStateData);
     }
     else {
         SCLogDebug("TFTP protocol parsing disabled.");
index af591ee531794bb9ab429da9a3d4b3e52e52b08b..d9858b8fe593498a4652fc32ec35fb7234fd7e35 100644 (file)
@@ -910,7 +910,7 @@ void OutputRegisterRootLoggers(void)
     RegisterSimpleJsonApplayerLogger(
             ALPROTO_FTPDATA, (EveJsonSimpleTxLogFunc)EveFTPDataAddMetadata, "ftp_data");
     RegisterSimpleJsonApplayerLogger(
-            ALPROTO_TFTP, (EveJsonSimpleTxLogFunc)rs_tftp_log_json_request, NULL);
+            ALPROTO_TFTP, (EveJsonSimpleTxLogFunc)SCTftpLogJsonRequest, NULL);
     // ALPROTO_IKE special: uses state
     RegisterSimpleJsonApplayerLogger(
             ALPROTO_KRB5, (EveJsonSimpleTxLogFunc)SCKrb5LogJsonResponse, NULL);