]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
app-layer: document return macros
authorVictor Julien <victor@inliniac.net>
Fri, 13 Mar 2020 13:43:00 +0000 (14:43 +0100)
committerVictor Julien <victor@inliniac.net>
Tue, 17 Mar 2020 21:03:23 +0000 (22:03 +0100)
rust/src/parser.rs
src/app-layer-parser.h

index 61a3098302526cd25cd3449d9ac73b7f9cca83b3..0970532475344070598d6a0fb163430894b915c2 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2017 Open Information Security Foundation
+/* Copyright (C) 2017-2020 Open Information Security Foundation
  *
  * You can copy, redistribute or modify this Program under the terms of
  * the GNU General Public License version 2 as published by the Free
@@ -34,6 +34,7 @@ pub struct AppLayerResult {
 }
 
 impl AppLayerResult {
+    /// parser has successfully processed in the input, and has consumed all of it
     pub fn ok() -> AppLayerResult {
         return AppLayerResult {
             status: 0,
@@ -41,6 +42,8 @@ impl AppLayerResult {
             needed: 0,
         };
     }
+    /// parser has hit an unrecoverable error. Returning this to the API
+    /// leads to no further calls to the parser.
     pub fn err() -> AppLayerResult {
         return AppLayerResult {
             status: -1,
@@ -48,6 +51,11 @@ impl AppLayerResult {
             needed: 0,
         };
     }
+    /// parser needs more data. Through 'consumed' it will indicate how many
+    /// of the input bytes it has consumed. Through 'needed' it will indicate
+    /// how many more bytes it needs before getting called again.
+    /// Note: consumed should never be more than the input len
+    ///       needed + consumed should be more than the input len
     pub fn incomplete(consumed: u32, needed: u32) -> AppLayerResult {
         return AppLayerResult {
             status: 1,
index a4aa93166f24693c138a29c0d10c63c28f465a2a..44248cceb30420c64386e851f5510740e152e5f1 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2007-2013 Open Information Security Foundation
+/* Copyright (C) 2007-2020 Open Information Security Foundation
  *
  * You can copy, redistribute or modify this Program under the terms of
  * the GNU General Public License version 2 as published by the Free
  *  completely inspected */
 #define APP_LAYER_TX_PREFILTER_MASK             ~APP_LAYER_TX_INSPECTED_FLAG
 
+/** parser has successfully processed in the input, and has consumed
+ *  all of it. */
 #define APP_LAYER_OK (AppLayerResult) { 0, 0, 0 }
+
+/** parser has hit an unrecoverable error. Returning this to the API
+ *  leads to no further calls to the parser. */
 #define APP_LAYER_ERROR (AppLayerResult) { -1, 0, 0 }
+
+/** parser needs more data. Through 'c' it will indicate how many
+ *  of the input bytes it has consumed. Through 'n' it will indicate
+ *  how many more bytes it needs before getting called again.
+ *  \note consumed (c) should never be more than the input len
+ *        needed (n) + consumed (c) should be more than the input len
+ */
 #define APP_LAYER_INCOMPLETE(c,n) (AppLayerResult) { 1, (c), (n) }
 
 int AppLayerParserProtoIsRegistered(uint8_t ipproto, AppProto alproto);