]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
rust: add comment tags to support documentation
authorJuliana Fajardini <jufajardini@gmail.com>
Wed, 9 Feb 2022 17:26:25 +0000 (17:26 +0000)
committerVictor Julien <vjulien@oisf.net>
Wed, 16 Feb 2022 13:24:38 +0000 (14:24 +0100)
With these, the portion of code within the tags should be included
in the related code-snippets (for frame support documentation) w/o
errors, even if the code within changes. The tags can also work as
a reminder that the existing code is being shown elsewhere, so folks
know documentation might need updates, in case of major changes.

rust/src/sip/sip.rs
rust/src/telnet/telnet.rs

index a321ca7dae3fea823a7f79c7fc135a16bb2b6bfd..c775e6536cc18357ef3314a5b9075c8ffd76893c 100755 (executable)
@@ -26,6 +26,7 @@ use nom7::Err;
 use std;
 use std::ffi::CString;
 
+// app-layer-frame-documentation tag start: FrameType enum
 #[derive(AppLayerFrameType)]
 pub enum SIPFrameType {
     Pdu,
@@ -36,6 +37,7 @@ pub enum SIPFrameType {
     RequestBody,
     ResponseBody,
 }
+// app-layer-frame-documentation tag end: FrameType enum
 
 #[derive(AppLayerEvent)]
 pub enum SIPEvent {
@@ -107,6 +109,7 @@ impl SIPState {
         }
     }
 
+    // app-layer-frame-documentation tag start: parse_request
     fn parse_request(&mut self, flow: *const core::Flow, stream_slice: StreamSlice) -> bool {
         let input = stream_slice.as_slice();
         let _pdu = Frame::new_ts(
@@ -129,6 +132,7 @@ impl SIPState {
                 self.transactions.push(tx);
                 return true;
             }
+            // app-layer-frame-documentation tag end: parse_request
             Err(Err::Incomplete(_)) => {
                 self.set_event(SIPEvent::IncompleteData);
                 return false;
@@ -181,7 +185,7 @@ impl SIPTransaction {
     }
 }
 
-
+// app-layer-frame-documentation tag start: function to add frames
 fn sip_frames_ts(flow: *const core::Flow, stream_slice: &StreamSlice, r: &Request) {
     let oi = stream_slice.as_slice();
     let _f = Frame::new_ts(
@@ -213,6 +217,7 @@ fn sip_frames_ts(flow: *const core::Flow, stream_slice: &StreamSlice, r: &Reques
         SCLogDebug!("ts: request_body {:?}", _f);
     }
 }
+// app-layer-frame-documentation tag end: function to add frames
 
 fn sip_frames_tc(flow: *const core::Flow, stream_slice: &StreamSlice, r: &Response) {
     let oi = stream_slice.as_slice();
index 494c6a12d739a9b809805fe0de605aabbec7a982..bada4a3b20ed35abea869b81229826d9f13e5612 100644 (file)
@@ -141,6 +141,7 @@ impl TelnetState {
         None
     }
 
+    // app-layer-frame-documentation tag start: parse_request
     fn parse_request(
         &mut self, flow: *const Flow, stream_slice: &StreamSlice, input: &[u8],
     ) -> AppLayerResult {
@@ -191,10 +192,12 @@ impl TelnetState {
                             -1 as i64,
                             TelnetFrameType::Data as u8,
                         )
+                    // app-layer-frame-documentation tag end: parse_request
                     };
                     self.request_specific_frame = f;
                 }
             }
+            // app-layer-frame-documentation tag start: update frame_len
             match parser::parse_message(start) {
                 Ok((rem, request)) => {
                     let consumed = start.len() - rem.len();
@@ -205,6 +208,7 @@ impl TelnetState {
 
                     if let Some(frame) = &self.request_frame {
                         frame.set_len(flow, 0, consumed as i64);
+                        // app-layer-frame-documentation tag end: update frame_len
                         self.request_frame = None;
                     }
                     if let Some(frame) = &self.request_specific_frame {