From d745d28d4a400d08609985f453c675f2a1a1bcc6 Mon Sep 17 00:00:00 2001 From: Philippe Antoine Date: Fri, 13 May 2022 09:43:11 +0200 Subject: [PATCH] dcerpc: use vecdeque tx iterator Ticket: #5321 --- rust/src/dcerpc/dcerpc.rs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/rust/src/dcerpc/dcerpc.rs b/rust/src/dcerpc/dcerpc.rs index 7aae120ffc..a70bcb64f8 100644 --- a/rust/src/dcerpc/dcerpc.rs +++ b/rust/src/dcerpc/dcerpc.rs @@ -15,7 +15,7 @@ * 02110-1301, USA. */ -use crate::applayer::*; +use crate::applayer::{self, *}; use crate::core::{self, *}; use crate::dcerpc::parser; use nom7::error::{Error, ErrorKind}; @@ -186,6 +186,13 @@ pub struct DCERPCTransaction { pub tx_data: AppLayerTxData, } +impl Transaction for DCERPCTransaction { + fn id(&self) -> u64 { + // need +1 to match state.tx_id + self.id + 1 + } +} + impl DCERPCTransaction { pub fn new() -> Self { return Self { @@ -316,6 +323,16 @@ pub struct DCERPCState { pub flow: Option<*const core::Flow>, } +impl State for DCERPCState { + fn get_transaction_count(&self) -> usize { + self.transactions.len() + } + + fn get_transaction_by_index(&self, index: usize) -> Option<&DCERPCTransaction> { + self.transactions.get(index) + } +} + impl DCERPCState { pub fn new() -> Self { return Self { @@ -1349,7 +1366,7 @@ pub unsafe extern "C" fn rs_dcerpc_register_parser() { localstorage_new: None, localstorage_free: None, get_files: None, - get_tx_iterator: None, + get_tx_iterator: Some(applayer::state_get_tx_iterator::), get_tx_data: rs_dcerpc_get_tx_data, apply_tx_config: None, flags: APP_LAYER_PARSER_OPT_ACCEPT_GAPS, -- 2.47.2