]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
ntp: add TX orientation
authorEric Leblond <el@stamus-networks.com>
Mon, 23 Jan 2023 19:05:08 +0000 (20:05 +0100)
committerVictor Julien <vjulien@oisf.net>
Fri, 31 Mar 2023 17:30:07 +0000 (19:30 +0200)
Set no inspection in the opposite side of the transaction.

Ticket: #5799

rust/src/ntp/ntp.rs

index 6e6f775903b7dacd5a367ef0c6a417d09f7c0c4b..db8c9897988e892039a67c3fe7e25b4387d12379 100644 (file)
@@ -20,7 +20,7 @@
 extern crate ntp_parser;
 use self::ntp_parser::*;
 use crate::core;
-use crate::core::{AppProto,Flow,ALPROTO_UNKNOWN,ALPROTO_FAILED};
+use crate::core::{AppProto,Flow,ALPROTO_UNKNOWN,ALPROTO_FAILED,Direction};
 use crate::applayer::{self, *};
 use std;
 use std::ffi::CString;
@@ -95,7 +95,7 @@ impl NTPState {
                     NtpPacket::V4(pkt) => (pkt.mode, pkt.ref_id),
                 };
                 if mode == NtpMode::SymmetricActive || mode == NtpMode::Client {
-                    let mut tx = self.new_tx();
+                    let mut tx = self.new_tx(_direction);
                     // use the reference id as identifier
                     tx.xid = ref_id;
                     self.transactions.push(tx);
@@ -121,9 +121,15 @@ impl NTPState {
         self.transactions.clear();
     }
 
-    fn new_tx(&mut self) -> NTPTransaction {
+    fn new_tx(&mut self, _direction: u8) -> NTPTransaction {
         self.tx_id += 1;
-        NTPTransaction::new(self.tx_id)
+        let mut tx = NTPTransaction::new(self.tx_id);
+        if _direction == 0 {
+            tx.tx_data.set_inspect_direction(Direction::ToServer);
+        } else {
+            tx.tx_data.set_inspect_direction(Direction::ToClient);
+        }
+        tx
     }
 
     pub fn get_tx_by_id(&mut self, tx_id: u64) -> Option<&NTPTransaction> {