From 01913f6a566f2b60d47f6cee59fa3b323f604a8a Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Wed, 6 Jul 2016 16:21:33 +0200 Subject: [PATCH] app-layer: add AppLayerParserIsTxAware This function globally checks if the protocol is registered and enabled by testing for the per alproto callback: StateGetProgressCompletionStatus This check is to be used before enabling Tx-aware code, like loggers. --- src/app-layer-parser.c | 9 +++++++++ src/app-layer-parser.h | 1 + 2 files changed, 10 insertions(+) diff --git a/src/app-layer-parser.c b/src/app-layer-parser.c index 14942d1679..4c0e9b8ee7 100644 --- a/src/app-layer-parser.c +++ b/src/app-layer-parser.c @@ -1076,6 +1076,15 @@ int AppLayerParserHasDecoderEvents(uint8_t ipproto, AppProto alproto, SCReturnInt(1); } +/** \brief simpler way to globally test if a alproto is registered + * and fully enabled in the configuration. + */ +int AppLayerParserIsTxAware(AppProto alproto) +{ + return (alp_ctx.ctxs[FLOW_PROTO_DEFAULT][alproto] + .StateGetProgressCompletionStatus != NULL); +} + int AppLayerParserProtocolIsTxAware(uint8_t ipproto, AppProto alproto) { SCEnter(); diff --git a/src/app-layer-parser.h b/src/app-layer-parser.h index 7a319510c6..cad9ec3182 100644 --- a/src/app-layer-parser.h +++ b/src/app-layer-parser.h @@ -197,6 +197,7 @@ int AppLayerParserParse(AppLayerParserThreadCtx *tctx, Flow *f, AppProto alproto void AppLayerParserSetEOF(AppLayerParserState *pstate); int AppLayerParserHasDecoderEvents(uint8_t ipproto, AppProto alproto, void *alstate, AppLayerParserState *pstate, uint8_t flags); +int AppLayerParserIsTxAware(AppProto alproto); int AppLayerParserProtocolIsTxAware(uint8_t ipproto, AppProto alproto); int AppLayerParserProtocolIsTxEventAware(uint8_t ipproto, AppProto alproto); int AppLayerParserProtocolSupportsTxs(uint8_t ipproto, AppProto alproto); -- 2.47.2