app-layer: remove conditional logic around API calls

Remove logic that suggested some API calls could be conditional,
even though Suricata wouldn't even start up if they weren't
registered.
pull/6011/head
Victor Julien 4 years ago
parent 4d5d7b4bd3
commit 1098e3b7c6

@ -890,7 +890,7 @@ void AppLayerParserTransactionsCleanup(Flow *f)
if (unlikely(p->StateTransactionFree == NULL))
SCReturn;
const bool has_tx_detect_flags = (p->GetTxData != NULL && !g_detect_disabled);
const bool has_tx_detect_flags = !g_detect_disabled;
const uint8_t ipproto = f->proto;
const AppProto alproto = f->alproto;
void * const alstate = f->alstate;
@ -1150,13 +1150,6 @@ int AppLayerParserSupportsFiles(uint8_t ipproto, AppProto alproto)
return FALSE;
}
int AppLayerParserSupportsTxDetectState(uint8_t ipproto, AppProto alproto)
{
if (alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].GetTxDetectState != NULL)
return TRUE;
return FALSE;
}
DetectEngineState *AppLayerParserGetTxDetectState(uint8_t ipproto, AppProto alproto, void *tx)
{
SCEnter();
@ -1168,33 +1161,16 @@ DetectEngineState *AppLayerParserGetTxDetectState(uint8_t ipproto, AppProto alpr
int AppLayerParserSetTxDetectState(const Flow *f,
void *tx, DetectEngineState *s)
{
int r;
SCEnter();
if ((alp_ctx.ctxs[f->protomap][f->alproto].GetTxDetectState(tx) != NULL))
SCReturnInt(-EBUSY);
r = alp_ctx.ctxs[f->protomap][f->alproto].SetTxDetectState(tx, s);
int r = alp_ctx.ctxs[f->protomap][f->alproto].SetTxDetectState(tx, s);
SCReturnInt(r);
}
bool AppLayerParserSupportsTxDetectFlags(AppProto alproto)
{
SCEnter();
for (uint8_t p = 0; p < FLOW_PROTO_APPLAYER_MAX; p++) {
if (alp_ctx.ctxs[p][alproto].GetTxData != NULL) {
SCReturnBool(true);
}
}
SCReturnBool(false);
}
AppLayerTxData *AppLayerParserGetTxData(uint8_t ipproto, AppProto alproto, void *tx)
{
SCEnter();
if (alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].GetTxData) {
AppLayerTxData *d = alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].GetTxData(tx);
SCReturnPtr(d, "AppLayerTxData");
}
SCReturnPtr(NULL, "AppLayerTxData");
AppLayerTxData *d = alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].GetTxData(tx);
SCReturnPtr(d, "AppLayerTxData");
}
void AppLayerParserApplyTxConfig(uint8_t ipproto, AppProto alproto,
@ -1577,9 +1553,6 @@ static void ValidateParserProto(AppProto alproto, uint8_t ipproto)
if (!(BOTH_SET(ctx->GetTxDetectState, ctx->SetTxDetectState))) {
goto bad;
}
if (!(BOTH_SET_OR_BOTH_UNSET(ctx->GetTxDetectState, ctx->SetTxDetectState))) {
goto bad;
}
if (ctx->GetTxData == NULL) {
goto bad;
}

@ -229,13 +229,10 @@ uint64_t AppLayerParserGetTransactionActive(const Flow *f, AppLayerParserState *
uint8_t AppLayerParserGetFirstDataDir(uint8_t ipproto, AppProto alproto);
int AppLayerParserSupportsFiles(uint8_t ipproto, AppProto alproto);
int AppLayerParserSupportsTxDetectState(uint8_t ipproto, AppProto alproto);
int AppLayerParserHasTxDetectState(uint8_t ipproto, AppProto alproto, void *alstate);
DetectEngineState *AppLayerParserGetTxDetectState(uint8_t ipproto, AppProto alproto, void *tx);
int AppLayerParserSetTxDetectState(const Flow *f, void *tx, DetectEngineState *s);
bool AppLayerParserSupportsTxDetectFlags(AppProto alproto);
AppLayerTxData *AppLayerParserGetTxData(uint8_t ipproto, AppProto alproto, void *tx);
void AppLayerParserApplyTxConfig(uint8_t ipproto, AppProto alproto,
void *state, void *tx, enum ConfigAction mode, AppLayerTxConfig);

Loading…
Cancel
Save