]> git.ipfire.org Git - people/ms/suricata.git/commitdiff
ntp: add tx iterator
authorJason Ish <jason.ish@oisf.net>
Wed, 10 Nov 2021 19:31:54 +0000 (13:31 -0600)
committerVictor Julien <vjulien@oisf.net>
Mon, 22 Nov 2021 09:20:23 +0000 (10:20 +0100)
rust/src/ntp/ntp.rs

index df5fb470c8c4710b8e82e93bcf51bc2186d5b8bb..6a454bcd2bc82191972d48107102f3014508e890 100644 (file)
@@ -63,7 +63,11 @@ pub struct NTPTransaction {
     tx_data: applayer::AppLayerTxData,
 }
 
-
+impl Transaction for NTPTransaction {
+    fn id(&self) -> u64 {
+        self.id
+    }
+}
 
 impl NTPState {
     pub fn new() -> NTPState {
@@ -75,6 +79,12 @@ impl NTPState {
     }
 }
 
+impl State<NTPTransaction> for NTPState {
+    fn get_transactions(&self) -> &[NTPTransaction] {
+        &self.transactions
+    }
+}
+
 impl NTPState {
     /// Parse an NTP request message
     ///
@@ -338,7 +348,7 @@ pub unsafe extern "C" fn rs_register_ntp_parser() {
         localstorage_new   : None,
         localstorage_free  : None,
         get_files          : None,
-        get_tx_iterator    : None,
+        get_tx_iterator    : Some(applayer::state_get_tx_iterator::<NTPState, NTPTransaction>),
         get_tx_data        : rs_ntp_get_tx_data,
         apply_tx_config    : None,
         flags              : APP_LAYER_PARSER_OPT_UNIDIR_TXS,