From: Victor Julien Date: Wed, 6 Jul 2016 14:21:33 +0000 (+0200) Subject: app-layer: add AppLayerParserIsTxAware X-Git-Tag: suricata-3.1.1~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=01913f6a566f2b60d47f6cee59fa3b323f604a8a;p=thirdparty%2Fsuricata.git 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. --- 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);