stream: add util function to get 'usable' data

pull/6805/head
Victor Julien 4 years ago
parent a6cb539054
commit eeee740e84

@ -331,6 +331,20 @@ static inline uint64_t GetAbsLastAck(const TcpStream *stream)
} }
} }
uint64_t StreamTcpGetAcked(const TcpStream *stream)
{
return GetAbsLastAck(stream);
}
uint64_t StreamTcpGetUsable(const TcpStream *stream, const bool eof)
{
uint64_t right_edge = STREAM_BASE_OFFSET(stream) + stream->sb.buf_offset;
if (!eof && StreamTcpInlineMode() == FALSE) {
right_edge = MIN(GetAbsLastAck(stream), right_edge);
}
return right_edge;
}
#ifdef UNITTESTS #ifdef UNITTESTS
/** \internal /** \internal
* \brief check if segments falls before stream 'offset' */ * \brief check if segments falls before stream 'offset' */

@ -198,5 +198,8 @@ int TcpSessionPacketSsnReuse(const Packet *p, const Flow *f, const void *tcp_ssn
void StreamTcpUpdateAppLayerProgress(TcpSession *ssn, char direction, void StreamTcpUpdateAppLayerProgress(TcpSession *ssn, char direction,
const uint32_t progress); const uint32_t progress);
uint64_t StreamTcpGetAcked(const TcpStream *stream);
uint64_t StreamTcpGetUsable(const TcpStream *stream, const bool eof);
#endif /* __STREAM_TCP_H__ */ #endif /* __STREAM_TCP_H__ */

Loading…
Cancel
Save