From ee00a6f2ec9d91d343a15f7de487dd58a03edbd4 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Tue, 28 Feb 2017 23:13:00 +0100 Subject: [PATCH] stream: validate code --- src/stream-tcp-list.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/stream-tcp-list.c b/src/stream-tcp-list.c index fbd697d871..2546c5d3d2 100644 --- a/src/stream-tcp-list.c +++ b/src/stream-tcp-list.c @@ -913,6 +913,24 @@ void PrintList(TcpSegment *seg) } } +void ValidateList(const TcpStream *stream) +{ + TcpSegment *seg = stream->seg_list; + TcpSegment *prev_seg = NULL; + + BUG_ON(seg && seg->next == NULL && stream->seg_list != stream->seg_list_tail); + BUG_ON(stream->seg_list != stream->seg_list_tail && stream->seg_list_tail->prev == NULL); + + while (seg != NULL) { + prev_seg = seg; + seg = seg->next; + BUG_ON(seg && seg->prev != prev_seg); + + // equal is possible + BUG_ON(seg && SEQ_LT(seg->seq, prev_seg->seq)); + } +} + /* * unittests */