applayer/template: support AppLayerTxData

pull/5168/head
Victor Julien 5 years ago
parent a484bbbe1b
commit 64e2a27512

@ -31,9 +31,9 @@ pub struct TemplateTransaction {
pub request: Option<String>, pub request: Option<String>,
pub response: Option<String>, pub response: Option<String>,
logged: LoggerFlags,
de_state: Option<*mut core::DetectEngineState>, de_state: Option<*mut core::DetectEngineState>,
events: *mut core::AppLayerDecoderEvents, events: *mut core::AppLayerDecoderEvents,
tx_data: AppLayerTxData,
} }
impl TemplateTransaction { impl TemplateTransaction {
@ -42,9 +42,9 @@ impl TemplateTransaction {
tx_id: 0, tx_id: 0,
request: None, request: None,
response: None, response: None,
logged: LoggerFlags::new(),
de_state: None, de_state: None,
events: std::ptr::null_mut(), events: std::ptr::null_mut(),
tx_data: AppLayerTxData::new(),
} }
} }
@ -387,25 +387,6 @@ pub extern "C" fn rs_template_tx_get_alstate_progress(
return 0; return 0;
} }
#[no_mangle]
pub extern "C" fn rs_template_tx_get_logged(
_state: *mut std::os::raw::c_void,
tx: *mut std::os::raw::c_void,
) -> u32 {
let tx = cast_pointer!(tx, TemplateTransaction);
return tx.logged.get();
}
#[no_mangle]
pub extern "C" fn rs_template_tx_set_logged(
_state: *mut std::os::raw::c_void,
tx: *mut std::os::raw::c_void,
logged: u32,
) {
let tx = cast_pointer!(tx, TemplateTransaction);
tx.logged.set(logged);
}
#[no_mangle] #[no_mangle]
pub extern "C" fn rs_template_state_get_events( pub extern "C" fn rs_template_state_get_events(
tx: *mut std::os::raw::c_void tx: *mut std::os::raw::c_void
@ -501,6 +482,8 @@ pub extern "C" fn rs_template_get_response_buffer(
return 0; return 0;
} }
export_tx_data_get!(rs_template_get_tx_data, TemplateTransaction);
// Parser name as a C style string. // Parser name as a C style string.
const PARSER_NAME: &'static [u8] = b"template-rust\0"; const PARSER_NAME: &'static [u8] = b"template-rust\0";
@ -524,8 +507,8 @@ pub unsafe extern "C" fn rs_template_register_parser() {
get_tx: rs_template_state_get_tx, get_tx: rs_template_state_get_tx,
tx_get_comp_st: rs_template_state_progress_completion_status, tx_get_comp_st: rs_template_state_progress_completion_status,
tx_get_progress: rs_template_tx_get_alstate_progress, tx_get_progress: rs_template_tx_get_alstate_progress,
get_tx_logged: Some(rs_template_tx_get_logged), get_tx_logged: None,
set_tx_logged: Some(rs_template_tx_set_logged), set_tx_logged: None,
get_de_state: rs_template_tx_get_detect_state, get_de_state: rs_template_tx_get_detect_state,
set_de_state: rs_template_tx_set_detect_state, set_de_state: rs_template_tx_set_detect_state,
get_events: Some(rs_template_state_get_events), get_events: Some(rs_template_state_get_events),
@ -537,7 +520,7 @@ pub unsafe extern "C" fn rs_template_register_parser() {
get_tx_iterator: Some(rs_template_state_get_tx_iterator), get_tx_iterator: Some(rs_template_state_get_tx_iterator),
get_tx_detect_flags: None, get_tx_detect_flags: None,
set_tx_detect_flags: None, set_tx_detect_flags: None,
get_tx_data: None, get_tx_data: Some(rs_template_get_tx_data),
apply_tx_config: None, apply_tx_config: None,
}; };

Loading…
Cancel
Save