/***** General *****/
/** \retval int -1 in case of unrecoverable error. App-layer tracking stops for this flow.
- * \retval int 0 ok */
+ * \retval int 0 ok: we did not update app_progress
+ * \retval int 1 ok: we updated app_progress */
int AppLayerParserParse(ThreadVars *tv, AppLayerParserThreadCtx *alp_tctx, Flow *f, AppProto alproto,
uint8_t flags, const uint8_t *input, uint32_t input_len)
{
end:
/* update app progress */
- if (f->proto == IPPROTO_TCP && f->protoctx != NULL) {
+ if (consumed != input_len && f->proto == IPPROTO_TCP && f->protoctx != NULL) {
TcpSession *ssn = f->protoctx;
StreamTcpUpdateAppLayerProgress(ssn, direction, consumed);
+ SCReturnInt(1);
}
SCReturnInt(0);
{
AppProto *alproto;
AppProto *alproto_otherdir;
+ int direction = (flags & STREAM_TOSERVER) ? 0 : 1;
if (flags & STREAM_TOSERVER) {
alproto = &f->alproto_ts;
} else {
*stream = &ssn->client;
}
+ direction = 1 - direction;
}
/* account flow if we have both sides */
int r = AppLayerParserParse(tv, app_tctx->alp_tctx, f, f->alproto,
flags, data, data_len);
PACKET_PROFILING_APP_END(app_tctx, f->alproto);
- if (r < 0)
+ if (r < 0) {
goto failure;
+ } else if (r == 0) {
+ StreamTcpUpdateAppLayerProgress(ssn, direction, data_len);
+ }
} else {
/* if the ssn is midstream, we may end up with a case where the
* start of an HTTP request is missing. We won't detect HTTP based
f->alproto, flags,
data, data_len);
PACKET_PROFILING_APP_END(app_tctx, f->alproto);
+ if (r == 0) {
+ StreamTcpUpdateAppLayerProgress(ssn, direction, data_len);
+ }
AppLayerDecoderEventsSetEventRaw(&p->app_layer_events,
APPLAYER_DETECT_PROTOCOL_ONLY_ONE_DIRECTION);
goto end;
}
+ const int direction = (flags & STREAM_TOSERVER) ? 0 : 1;
+
if (flags & STREAM_TOSERVER) {
alproto = f->alproto_ts;
} else {
flags, data, data_len);
PACKET_PROFILING_APP_END(app_tctx, f->alproto);
/* ignore parser result for gap */
+ StreamTcpUpdateAppLayerProgress(ssn, direction, data_len);
goto end;
}
r = AppLayerParserParse(tv, app_tctx->alp_tctx, f, f->alproto,
flags, data, data_len);
PACKET_PROFILING_APP_END(app_tctx, f->alproto);
+ if (r == 0) {
+ StreamTcpUpdateAppLayerProgress(ssn, direction, data_len);
+ }
}
}