rust/tftp: replace rs_ naming with SC

pull/13152/head
Jason Ish 7 months ago committed by Victor Julien
parent aa24276999
commit 9b830c92dc

@ -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()
}

@ -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
{

@ -43,12 +43,12 @@
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.");

@ -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);

Loading…
Cancel
Save