]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
app-layer-parser: split registration flags
authorVictor Julien <victor@inliniac.net>
Tue, 7 Aug 2018 08:19:02 +0000 (10:19 +0200)
committerVictor Julien <victor@inliniac.net>
Tue, 7 Aug 2018 11:49:34 +0000 (13:49 +0200)
src/app-layer-parser.c
src/app-layer-parser.h

index cd42cfc0572bcd0000143017e2e311adbdd4d125..1203a8d3f54994d7e2aad17049909544fe8ef12f 100644 (file)
@@ -130,7 +130,9 @@ typedef struct AppLayerParserProtoCtx_
     uint8_t first_data_dir;
 
     /* Option flags such as supporting gaps or not. */
-    uint64_t flags;
+    uint32_t option_flags;
+
+    uint32_t internal_flags;
 
 #ifdef UNITTESTS
     void (*RegisterUnittests)(void);
@@ -209,8 +211,8 @@ void AppLayerParserPostStreamSetup(void)
     /* lets set a default value for stream_depth */
     for (flow_proto = 0; flow_proto < FLOW_PROTO_DEFAULT; flow_proto++) {
         for (alproto = 0; alproto < ALPROTO_MAX; alproto++) {
-            if (!(alp_ctx.ctxs[flow_proto][alproto].flags &
-                APP_LAYER_PARSER_OPT_STREAM_DEPTH_SET)) {
+            if (!(alp_ctx.ctxs[flow_proto][alproto].internal_flags &
+                        APP_LAYER_PARSER_INT_STREAM_DEPTH_SET)) {
                 alp_ctx.ctxs[flow_proto][alproto].stream_depth =
                     stream_config.reassembly_depth;
             }
@@ -366,11 +368,11 @@ void AppLayerParserRegisterParserAcceptableDataDirection(uint8_t ipproto, AppPro
 }
 
 void AppLayerParserRegisterOptionFlags(uint8_t ipproto, AppProto alproto,
-        uint64_t flags)
+        uint32_t flags)
 {
     SCEnter();
 
-    alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].flags |= flags;
+    alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].option_flags |= flags;
 
     SCReturn;
 }
@@ -1105,7 +1107,7 @@ int AppLayerParserParse(ThreadVars *tv, AppLayerParserThreadCtx *alp_tctx, Flow
         goto end;
 
     if (flags & STREAM_GAP) {
-        if (!(p->flags & APP_LAYER_PARSER_OPT_ACCEPT_GAPS)) {
+        if (!(p->option_flags & APP_LAYER_PARSER_OPT_ACCEPT_GAPS)) {
             SCLogDebug("app-layer parser does not accept gaps");
             if (f->alstate != NULL) {
                 AppLayerParserStreamTruncated(f->proto, alproto, f->alstate,
@@ -1318,8 +1320,8 @@ void AppLayerParserSetStreamDepth(uint8_t ipproto, AppProto alproto, uint32_t st
     SCEnter();
 
     alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].stream_depth = stream_depth;
-    alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].flags |=
-        APP_LAYER_PARSER_OPT_STREAM_DEPTH_SET;
+    alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].internal_flags |=
+        APP_LAYER_PARSER_INT_STREAM_DEPTH_SET;
 
     SCReturn;
 }
@@ -1355,7 +1357,7 @@ static void ValidateParserProtoDump(AppProto alproto, uint8_t ipproto)
     const AppLayerParserProtoCtx *ctx_def = &alp_ctx.ctxs[FLOW_PROTO_DEFAULT][alproto];
     printf("ERROR: incomplete app-layer registration\n");
     printf("AppLayer protocol %s ipproto %u\n", AppProtoToString(alproto), ipproto);
-    printf("- flags %"PRIx64"\n", ctx->flags);
+    printf("- option flags %"PRIx32"\n", ctx->option_flags);
     printf("- first_data_dir %"PRIx8"\n", ctx->first_data_dir);
     printf("Mandatory:\n");
     printf("- Parser[0] %p Parser[1] %p\n", ctx->Parser[0], ctx->Parser[1]);
index cec6bf1ac1da223688012d4236fe64ba02ec03bd..01f0956238985202d238cb190e1e840766434b69 100644 (file)
@@ -38,8 +38,9 @@
 #define APP_LAYER_PARSER_BYPASS_READY           BIT_U8(4)
 
 /* Flags for AppLayerParserProtoCtx. */
-#define APP_LAYER_PARSER_OPT_ACCEPT_GAPS        BIT_U64(0)
-#define APP_LAYER_PARSER_OPT_STREAM_DEPTH_SET   BIT_U64(1)
+#define APP_LAYER_PARSER_OPT_ACCEPT_GAPS        BIT_U32(0)
+
+#define APP_LAYER_PARSER_INT_STREAM_DEPTH_SET   BIT_U32(0)
 
 /* applies to DetectFlags uint64_t field */
 
@@ -127,7 +128,7 @@ void AppLayerParserRegisterParserAcceptableDataDirection(uint8_t ipproto,
                                               AppProto alproto,
                                               uint8_t direction);
 void AppLayerParserRegisterOptionFlags(uint8_t ipproto, AppProto alproto,
-        uint64_t flags);
+        uint32_t flags);
 void AppLayerParserRegisterStateFuncs(uint8_t ipproto, AppProto alproto,
                            void *(*StateAlloc)(void),
                            void (*StateFree)(void *));