diff --git a/rust/src/applayer.rs b/rust/src/applayer.rs index 9814143ba5ef..46fbbd55604f 100644 --- a/rust/src/applayer.rs +++ b/rust/src/applayer.rs @@ -502,8 +502,6 @@ pub const APP_LAYER_PARSER_NO_INSPECTION_PAYLOAD : u16 = BIT_U16!(3); pub const APP_LAYER_PARSER_BYPASS_READY : u16 = BIT_U16!(4); pub const APP_LAYER_PARSER_EOF_TS : u16 = BIT_U16!(5); pub const APP_LAYER_PARSER_EOF_TC : u16 = BIT_U16!(6); -pub const APP_LAYER_PARSER_TRUNC_TS : u16 = BIT_U16!(7); -pub const APP_LAYER_PARSER_TRUNC_TC : u16 = BIT_U16!(8); pub const APP_LAYER_PARSER_OPT_ACCEPT_GAPS: u32 = BIT_U32!(0); diff --git a/src/app-layer-parser.c b/src/app-layer-parser.c index 70e4d2af2086..b9d4c2c05d9d 100644 --- a/src/app-layer-parser.c +++ b/src/app-layer-parser.c @@ -201,9 +201,6 @@ FramesContainer *AppLayerFramesSetupContainer(Flow *f) return f->alparser->frames; } -static inline void AppLayerParserStreamTruncated(AppLayerParserState *pstate, const uint8_t ipproto, - const AppProto alproto, void *alstate, const uint8_t direction); - #ifdef UNITTESTS void UTHAppLayerParserStateGetIds(void *ptr, uint64_t *i1, uint64_t *i2, uint64_t *log, uint64_t *min) { @@ -947,11 +944,7 @@ void AppLayerParserTransactionsCleanup(Flow *f, const uint8_t pkt_dir) AppLayerTxData *txd = AppLayerParserGetTxData(ipproto, alproto, tx); if (txd != NULL && AppLayerParserHasFilesInDir(txd, pkt_dir)) { if (pkt_dir_trunc == -1) - pkt_dir_trunc = - AppLayerParserStateIssetFlag(f->alparser, - (pkt_dir == STREAM_TOSERVER) ? APP_LAYER_PARSER_TRUNC_TS - : APP_LAYER_PARSER_TRUNC_TC) != 0; - + pkt_dir_trunc = IS_DISRUPTED((pkt_dir == STREAM_TOSERVER) ? ts_disrupt_flags : tc_disrupt_flags); AppLayerParserFileTxHousekeeping(f, tx, pkt_dir, (bool)pkt_dir_trunc); } @@ -1308,7 +1301,7 @@ int AppLayerParserParse(ThreadVars *tv, AppLayerParserThreadCtx *alp_tctx, Flow if (!(p->option_flags & APP_LAYER_PARSER_OPT_ACCEPT_GAPS)) { SCLogDebug("app-layer parser does not accept gaps"); if (f->alstate != NULL && !FlowChangeProto(f)) { - AppLayerParserStreamTruncated(pstate, f->proto, alproto, f->alstate, flags); + AppLayerParserTriggerRawStreamReassembly(f, direction); } AppLayerIncGapErrorCounter(tv, f); goto error; @@ -1468,9 +1461,9 @@ int AppLayerParserParse(ThreadVars *tv, AppLayerParserThreadCtx *alp_tctx, Flow AppLayerIncTxCounter(tv, f, cur_tx_cnt - p_tx_cnt); } - /* stream truncated, inform app layer */ + /* stream truncated, trigger raw stream reassembly */ if (flags & STREAM_DEPTH) - AppLayerParserStreamTruncated(pstate, f->proto, alproto, f->alstate, flags); + AppLayerParserTriggerRawStreamReassembly(f, direction); end: /* update app progress */ @@ -1796,24 +1789,6 @@ uint16_t AppLayerParserStateIssetFlag(AppLayerParserState *pstate, uint16_t flag SCReturnUInt(pstate->flags & flag); } -static inline void AppLayerParserStreamTruncated(AppLayerParserState *pstate, const uint8_t ipproto, - const AppProto alproto, void *alstate, const uint8_t direction) -{ - SCEnter(); - - if (direction & STREAM_TOSERVER) { - AppLayerParserStateSetFlag(pstate, APP_LAYER_PARSER_TRUNC_TS); - } else { - AppLayerParserStateSetFlag(pstate, APP_LAYER_PARSER_TRUNC_TC); - } - - if (alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].Truncate != NULL) { - alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].Truncate(alstate, direction); - } - - SCReturn; -} - /***** Unittests *****/ #ifdef UNITTESTS diff --git a/src/app-layer-parser.h b/src/app-layer-parser.h index 9dbab6701d60..540d4a2b06ff 100644 --- a/src/app-layer-parser.h +++ b/src/app-layer-parser.h @@ -38,8 +38,7 @@ #define APP_LAYER_PARSER_BYPASS_READY BIT_U16(4) #define APP_LAYER_PARSER_EOF_TS BIT_U16(5) #define APP_LAYER_PARSER_EOF_TC BIT_U16(6) -#define APP_LAYER_PARSER_TRUNC_TS BIT_U16(7) -#define APP_LAYER_PARSER_TRUNC_TC BIT_U16(8) +/* 2x vacancy */ #define APP_LAYER_PARSER_SFRAME_TS BIT_U16(9) #define APP_LAYER_PARSER_SFRAME_TC BIT_U16(10) diff --git a/src/output-tx.c b/src/output-tx.c index 671829fb75bf..b73b444de5fc 100644 --- a/src/output-tx.c +++ b/src/output-tx.c @@ -378,10 +378,8 @@ static TmEcode OutputTxLog(ThreadVars *tv, Packet *p, void *thread_data) SCLogDebug("pcap_cnt %" PRIu64, p->pcap_cnt); const bool last_pseudo = (p->flowflags & FLOW_PKT_LAST_PSEUDO) != 0; - const bool ts_eof = AppLayerParserStateIssetFlag(f->alparser, - (APP_LAYER_PARSER_EOF_TS | APP_LAYER_PARSER_TRUNC_TS)) != 0; - const bool tc_eof = AppLayerParserStateIssetFlag(f->alparser, - (APP_LAYER_PARSER_EOF_TC | APP_LAYER_PARSER_TRUNC_TC)) != 0; + const bool ts_eof = AppLayerParserStateIssetFlag(f->alparser, APP_LAYER_PARSER_EOF_TS) != 0; + const bool tc_eof = AppLayerParserStateIssetFlag(f->alparser, APP_LAYER_PARSER_EOF_TC) != 0; const bool eof = last_pseudo || (ts_eof && tc_eof); SCLogDebug("eof %d last_pseudo %d ts_eof %d tc_eof %d", eof, last_pseudo, ts_eof, tc_eof);