Skip to content

Commit

Permalink
dcerpc: use vecdeque tx iterator
Browse files Browse the repository at this point in the history
Ticket: OISF#5321
  • Loading branch information
catenacyber committed May 13, 2022
1 parent dfe76bb commit 5f98448
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions rust/src/dcerpc/dcerpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -186,6 +186,12 @@ pub struct DCERPCTransaction {
pub tx_data: AppLayerTxData,
}

impl Transaction for DCERPCTransaction {
fn id(&self) -> u64 {
self.id
}
}

impl DCERPCTransaction {
pub fn new() -> Self {
return Self {
Expand Down Expand Up @@ -316,6 +322,16 @@ pub struct DCERPCState {
pub flow: Option<*const core::Flow>,
}

impl State<DCERPCTransaction> 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 {
Expand Down Expand Up @@ -1349,7 +1365,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::<DCERPCState, DCERPCTransaction>),
get_tx_data: rs_dcerpc_get_tx_data,
apply_tx_config: None,
flags: APP_LAYER_PARSER_OPT_ACCEPT_GAPS,
Expand Down

0 comments on commit 5f98448

Please sign in to comment.