]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
app-layer: add AppLayerParserIsTxAware
authorVictor Julien <victor@inliniac.net>
Wed, 6 Jul 2016 14:21:33 +0000 (16:21 +0200)
committerVictor Julien <victor@inliniac.net>
Wed, 6 Jul 2016 14:21:33 +0000 (16:21 +0200)
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
src/app-layer-parser.h

index 14942d16793999562cf5dcd83489e03b83fc03c5..4c0e9b8ee79bdfa4941ffc8982da4a73b609e407 100644 (file)
@@ -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();
index 7a319510c688a0a20c0f6a474c0813c3eb01f59b..cad9ec31821e55568eaa1b9922edd31dc18cd758 100644 (file)
@@ -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);