From: Victor Julien Date: Fri, 17 Jul 2015 11:32:31 +0000 (+0200) Subject: detect: pass flags to inspect_id update logic X-Git-Tag: suricata-3.0RC1~233 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6946e0be55e89f546f842bca3b2f64b479cb4277;p=thirdparty%2Fsuricata.git detect: pass flags to inspect_id update logic --- diff --git a/src/app-layer-parser.c b/src/app-layer-parser.c index 0e2fdfb474..134f99095c 100644 --- a/src/app-layer-parser.c +++ b/src/app-layer-parser.c @@ -546,15 +546,15 @@ uint64_t AppLayerParserGetTransactionInspectId(AppLayerParserState *pstate, uint } void AppLayerParserSetTransactionInspectId(AppLayerParserState *pstate, - uint8_t ipproto, AppProto alproto, void *alstate, - uint8_t direction) + const uint8_t ipproto, const AppProto alproto, + void *alstate, const uint8_t flags) { SCEnter(); - uint8_t dir = (direction & STREAM_TOSERVER) ? 0 : 1; + int direction = (flags & STREAM_TOSERVER) ? 0 : 1; uint64_t total_txs = AppLayerParserGetTxCnt(ipproto, alproto, alstate); - uint64_t idx = AppLayerParserGetTransactionInspectId(pstate, direction); - int state_done_progress = AppLayerParserGetStateProgressCompletionStatus(ipproto, alproto, direction); + uint64_t idx = AppLayerParserGetTransactionInspectId(pstate, flags); + int state_done_progress = AppLayerParserGetStateProgressCompletionStatus(ipproto, alproto, flags); void *tx; int state_progress; @@ -562,13 +562,13 @@ void AppLayerParserSetTransactionInspectId(AppLayerParserState *pstate, tx = AppLayerParserGetTx(ipproto, alproto, alstate, idx); if (tx == NULL) continue; - state_progress = AppLayerParserGetStateProgress(ipproto, alproto, tx, direction); + state_progress = AppLayerParserGetStateProgress(ipproto, alproto, tx, flags); if (state_progress >= state_done_progress) continue; else break; } - pstate->inspect_id[dir] = idx; + pstate->inspect_id[direction] = idx; SCReturn; } diff --git a/src/app-layer-parser.h b/src/app-layer-parser.h index b81459b766..62cb8f6869 100644 --- a/src/app-layer-parser.h +++ b/src/app-layer-parser.h @@ -158,8 +158,8 @@ uint64_t AppLayerParserGetTransactionLogId(AppLayerParserState *pstate); void AppLayerParserSetTransactionLogId(AppLayerParserState *pstate); uint64_t AppLayerParserGetTransactionInspectId(AppLayerParserState *pstate, uint8_t direction); void AppLayerParserSetTransactionInspectId(AppLayerParserState *pstate, - uint8_t ipproto, AppProto alproto, void *alstate, - uint8_t direction); + const uint8_t ipproto, const AppProto alproto, void *alstate, + const uint8_t flags); AppLayerDecoderEvents *AppLayerParserGetDecoderEvents(AppLayerParserState *pstate); void AppLayerParserSetDecoderEvents(AppLayerParserState *pstate, AppLayerDecoderEvents *devents); AppLayerDecoderEvents *AppLayerParserGetEventsByTx(uint8_t ipproto, AppProto alproto, void *alstate, diff --git a/src/detect-engine-state.c b/src/detect-engine-state.c index 8d5baca8bd..05ca25d57f 100644 --- a/src/detect-engine-state.c +++ b/src/detect-engine-state.c @@ -1095,13 +1095,17 @@ end: return; } /** \brief update flow's inspection id's + * + * \param f unlocked flow + * \param flags direction and disruption flags * * \note it is possible that f->alstate, f->alparser are NULL */ -void DeStateUpdateInspectTransactionId(Flow *f, uint8_t direction) +void DeStateUpdateInspectTransactionId(Flow *f, const uint8_t flags) { FLOWLOCK_WRLOCK(f); if (f->alparser && f->alstate) { - AppLayerParserSetTransactionInspectId(f->alparser, f->proto, f->alproto, f->alstate, direction); + AppLayerParserSetTransactionInspectId(f->alparser, f->proto, + f->alproto, f->alstate, flags); } FLOWLOCK_UNLOCK(f); diff --git a/src/detect-engine-state.h b/src/detect-engine-state.h index 8efb9445a0..51f67448e7 100644 --- a/src/detect-engine-state.h +++ b/src/detect-engine-state.h @@ -219,10 +219,10 @@ void DeStateDetectContinueDetection(ThreadVars *tv, DetectEngineCtx *de_ctx, /** * \brief Update the inspect id. * - * \param f Flow(unlocked). - * \param direction 0 for to server, 1 for toclient. + * \param f unlocked flow + * \param flags direction and disruption flags */ -void DeStateUpdateInspectTransactionId(Flow *f, uint8_t direction); +void DeStateUpdateInspectTransactionId(Flow *f, const uint8_t flags); /** * \brief Reset a DetectEngineState state.