rust: add comment tags to support documentation

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.
pull/7013/head
Juliana Fajardini 4 years ago committed by Victor Julien
parent e0dd1820c2
commit 5a7645fac1

@ -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();

@ -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 {

Loading…
Cancel
Save