app-layer-parser: split registration flags

pull/3448/head
Victor Julien 7 years ago
parent 397f5f5fdf
commit c8fb9bcba5

@ -130,7 +130,9 @@ typedef struct AppLayerParserProtoCtx_
uint8_t first_data_dir; uint8_t first_data_dir;
/* Option flags such as supporting gaps or not. */ /* Option flags such as supporting gaps or not. */
uint64_t flags; uint32_t option_flags;
uint32_t internal_flags;
#ifdef UNITTESTS #ifdef UNITTESTS
void (*RegisterUnittests)(void); void (*RegisterUnittests)(void);
@ -209,8 +211,8 @@ void AppLayerParserPostStreamSetup(void)
/* lets set a default value for stream_depth */ /* lets set a default value for stream_depth */
for (flow_proto = 0; flow_proto < FLOW_PROTO_DEFAULT; flow_proto++) { for (flow_proto = 0; flow_proto < FLOW_PROTO_DEFAULT; flow_proto++) {
for (alproto = 0; alproto < ALPROTO_MAX; alproto++) { for (alproto = 0; alproto < ALPROTO_MAX; alproto++) {
if (!(alp_ctx.ctxs[flow_proto][alproto].flags & if (!(alp_ctx.ctxs[flow_proto][alproto].internal_flags &
APP_LAYER_PARSER_OPT_STREAM_DEPTH_SET)) { APP_LAYER_PARSER_INT_STREAM_DEPTH_SET)) {
alp_ctx.ctxs[flow_proto][alproto].stream_depth = alp_ctx.ctxs[flow_proto][alproto].stream_depth =
stream_config.reassembly_depth; stream_config.reassembly_depth;
} }
@ -366,11 +368,11 @@ void AppLayerParserRegisterParserAcceptableDataDirection(uint8_t ipproto, AppPro
} }
void AppLayerParserRegisterOptionFlags(uint8_t ipproto, AppProto alproto, void AppLayerParserRegisterOptionFlags(uint8_t ipproto, AppProto alproto,
uint64_t flags) uint32_t flags)
{ {
SCEnter(); SCEnter();
alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].flags |= flags; alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].option_flags |= flags;
SCReturn; SCReturn;
} }
@ -1105,7 +1107,7 @@ int AppLayerParserParse(ThreadVars *tv, AppLayerParserThreadCtx *alp_tctx, Flow
goto end; goto end;
if (flags & STREAM_GAP) { 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"); SCLogDebug("app-layer parser does not accept gaps");
if (f->alstate != NULL) { if (f->alstate != NULL) {
AppLayerParserStreamTruncated(f->proto, alproto, f->alstate, AppLayerParserStreamTruncated(f->proto, alproto, f->alstate,
@ -1318,8 +1320,8 @@ void AppLayerParserSetStreamDepth(uint8_t ipproto, AppProto alproto, uint32_t st
SCEnter(); SCEnter();
alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].stream_depth = stream_depth; alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].stream_depth = stream_depth;
alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].flags |= alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].internal_flags |=
APP_LAYER_PARSER_OPT_STREAM_DEPTH_SET; APP_LAYER_PARSER_INT_STREAM_DEPTH_SET;
SCReturn; SCReturn;
} }
@ -1355,7 +1357,7 @@ static void ValidateParserProtoDump(AppProto alproto, uint8_t ipproto)
const AppLayerParserProtoCtx *ctx_def = &alp_ctx.ctxs[FLOW_PROTO_DEFAULT][alproto]; const AppLayerParserProtoCtx *ctx_def = &alp_ctx.ctxs[FLOW_PROTO_DEFAULT][alproto];
printf("ERROR: incomplete app-layer registration\n"); printf("ERROR: incomplete app-layer registration\n");
printf("AppLayer protocol %s ipproto %u\n", AppProtoToString(alproto), ipproto); 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("- first_data_dir %"PRIx8"\n", ctx->first_data_dir);
printf("Mandatory:\n"); printf("Mandatory:\n");
printf("- Parser[0] %p Parser[1] %p\n", ctx->Parser[0], ctx->Parser[1]); printf("- Parser[0] %p Parser[1] %p\n", ctx->Parser[0], ctx->Parser[1]);

@ -38,8 +38,9 @@
#define APP_LAYER_PARSER_BYPASS_READY BIT_U8(4) #define APP_LAYER_PARSER_BYPASS_READY BIT_U8(4)
/* Flags for AppLayerParserProtoCtx. */ /* Flags for AppLayerParserProtoCtx. */
#define APP_LAYER_PARSER_OPT_ACCEPT_GAPS BIT_U64(0) #define APP_LAYER_PARSER_OPT_ACCEPT_GAPS BIT_U32(0)
#define APP_LAYER_PARSER_OPT_STREAM_DEPTH_SET BIT_U64(1)
#define APP_LAYER_PARSER_INT_STREAM_DEPTH_SET BIT_U32(0)
/* applies to DetectFlags uint64_t field */ /* applies to DetectFlags uint64_t field */
@ -127,7 +128,7 @@ void AppLayerParserRegisterParserAcceptableDataDirection(uint8_t ipproto,
AppProto alproto, AppProto alproto,
uint8_t direction); uint8_t direction);
void AppLayerParserRegisterOptionFlags(uint8_t ipproto, AppProto alproto, void AppLayerParserRegisterOptionFlags(uint8_t ipproto, AppProto alproto,
uint64_t flags); uint32_t flags);
void AppLayerParserRegisterStateFuncs(uint8_t ipproto, AppProto alproto, void AppLayerParserRegisterStateFuncs(uint8_t ipproto, AppProto alproto,
void *(*StateAlloc)(void), void *(*StateAlloc)(void),
void (*StateFree)(void *)); void (*StateFree)(void *));

Loading…
Cancel
Save