app-layer: remove checks

Now that app-layer parser registrations are validated at startup,
a number of runtime checks are no longer necessary. So remove them.
pull/2786/head
Victor Julien 9 years ago
parent e930513125
commit 1a2985ed76

@ -240,7 +240,6 @@ void DetectEngineStateFree(DetectEngineState *state)
static int HasStoredSigs(const Flow *f, const uint8_t flags) static int HasStoredSigs(const Flow *f, const uint8_t flags)
{ {
if (AppLayerParserProtocolSupportsTxs(f->proto, f->alproto)) {
AppProto alproto = f->alproto; AppProto alproto = f->alproto;
void *alstate = FlowGetAppState(f); void *alstate = FlowGetAppState(f);
if (!StateIsValid(f->alproto, alstate)) { if (!StateIsValid(f->alproto, alstate)) {
@ -271,7 +270,6 @@ static int HasStoredSigs(const Flow *f, const uint8_t flags)
} }
} }
} }
}
return 0; return 0;
} }
@ -311,7 +309,6 @@ static void StoreStateTxFileOnly(DetectEngineThreadCtx *det_ctx,
Flow *f, const uint8_t flags, const uint64_t tx_id, void *tx, Flow *f, const uint8_t flags, const uint64_t tx_id, void *tx,
const uint16_t file_no_match) const uint16_t file_no_match)
{ {
if (AppLayerParserSupportsTxDetectState(f->proto, f->alproto)) {
DetectEngineState *destate = AppLayerParserGetTxDetectState(f->proto, f->alproto, tx); DetectEngineState *destate = AppLayerParserGetTxDetectState(f->proto, f->alproto, tx);
if (destate == NULL) { if (destate == NULL) {
destate = DetectEngineStateAlloc(); destate = DetectEngineStateAlloc();
@ -324,7 +321,6 @@ static void StoreStateTxFileOnly(DetectEngineThreadCtx *det_ctx,
SCLogDebug("destate created for %"PRIu64, tx_id); SCLogDebug("destate created for %"PRIu64, tx_id);
} }
StoreStateTxHandleFiles(det_ctx, f, destate, flags, tx_id, file_no_match); StoreStateTxHandleFiles(det_ctx, f, destate, flags, tx_id, file_no_match);
}
} }
/** /**
@ -336,7 +332,6 @@ static void StoreStateTx(DetectEngineThreadCtx *det_ctx,
const Signature *s, const SigMatchData *smd, const Signature *s, const SigMatchData *smd,
const uint32_t inspect_flags, const uint16_t file_no_match, int check_before_add) const uint32_t inspect_flags, const uint16_t file_no_match, int check_before_add)
{ {
if (AppLayerParserSupportsTxDetectState(f->proto, f->alproto)) {
DetectEngineState *destate = AppLayerParserGetTxDetectState(f->proto, f->alproto, tx); DetectEngineState *destate = AppLayerParserGetTxDetectState(f->proto, f->alproto, tx);
if (destate == NULL) { if (destate == NULL) {
destate = DetectEngineStateAlloc(); destate = DetectEngineStateAlloc();
@ -355,7 +350,6 @@ static void StoreStateTx(DetectEngineThreadCtx *det_ctx,
DeStateSignatureAppend(destate, s, inspect_flags, flags); DeStateSignatureAppend(destate, s, inspect_flags, flags);
StoreStateTxHandleFiles(det_ctx, f, destate, flags, tx_id, file_no_match); StoreStateTxHandleFiles(det_ctx, f, destate, flags, tx_id, file_no_match);
}
SCLogDebug("Stored for TX %"PRIu64, tx_id); SCLogDebug("Stored for TX %"PRIu64, tx_id);
} }
@ -367,9 +361,6 @@ int DeStateDetectStartDetection(ThreadVars *tv, DetectEngineCtx *de_ctx,
SCLogDebug("rule %u/%u", s->id, s->num); SCLogDebug("rule %u/%u", s->id, s->num);
/* TX based matches (inspect engines) */ /* TX based matches (inspect engines) */
if (unlikely(!AppLayerParserProtocolSupportsTxs(f->proto, alproto))) {
return 0;
}
void *alstate = FlowGetAppState(f); void *alstate = FlowGetAppState(f);
if (unlikely(!StateIsValid(alproto, alstate))) { if (unlikely(!StateIsValid(alproto, alstate))) {
return 0; return 0;
@ -746,7 +737,6 @@ void DeStateDetectContinueDetection(ThreadVars *tv, DetectEngineCtx *de_ctx,
SCLogDebug("starting continue detection for packet %"PRIu64, p->pcap_cnt); SCLogDebug("starting continue detection for packet %"PRIu64, p->pcap_cnt);
if (AppLayerParserProtocolSupportsTxs(f->proto, alproto)) {
void *alstate = FlowGetAppState(f); void *alstate = FlowGetAppState(f);
if (!StateIsValid(alproto, alstate)) { if (!StateIsValid(alproto, alstate)) {
return; return;
@ -821,7 +811,6 @@ void DeStateDetectContinueDetection(ThreadVars *tv, DetectEngineCtx *de_ctx,
break; break;
} }
} }
}
end: end:
det_ctx->p = NULL; det_ctx->p = NULL;
@ -850,7 +839,6 @@ void DeStateUpdateInspectTransactionId(Flow *f, const uint8_t flags)
*/ */
void DetectEngineStateResetTxs(Flow *f) void DetectEngineStateResetTxs(Flow *f)
{ {
if (AppLayerParserProtocolSupportsTxs(f->proto, f->alproto)) {
void *alstate = FlowGetAppState(f); void *alstate = FlowGetAppState(f);
if (!StateIsValid(f->alproto, alstate)) { if (!StateIsValid(f->alproto, alstate)) {
return; return;
@ -880,7 +868,6 @@ void DetectEngineStateResetTxs(Flow *f)
tx_de_state->dir_state[1].flags = 0; tx_de_state->dir_state[1].flags = 0;
} }
} }
}
} }
/*********Unittests*********/ /*********Unittests*********/

Loading…
Cancel
Save