From 2d1fefdb103465c572f87a5bcea3d5281ae124b9 Mon Sep 17 00:00:00 2001 From: Benjamin Cama Date: Thu, 26 Jan 2012 23:44:14 +0100 Subject: [PATCH] MPPP: Fix discarding algorithm --- ppp.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/ppp.c b/ppp.c index 036292a..afbffd8 100644 --- a/ppp.c +++ b/ppp.c @@ -2012,7 +2012,7 @@ discard_lost_frames: uint16_t index = M_index; uint8_t end_or_hole_found = 0; - for (;;) + while (index != this_fragmentation->start_index) { fragmentt *this_frag; @@ -2022,17 +2022,23 @@ discard_lost_frames: // before a MP_BEGIN, there must be a MP_END if (front_frag->length && (front_frag->flags & MP_BEGIN)) + { end_or_hole_found = 1; + end_index = index; + } + } - index = (index + (MAXFRAGNUM-1)) & MAXFRAGNUM_MASK; - this_frag = &this_fragmentation->frag[index]; + index = (index + (MAXFRAGNUM-1)) & MAXFRAGNUM_MASK; + this_frag = &this_fragmentation->frag[index]; + if (!end_or_hole_found) + { // we are a hole or a MP_END if (!this_frag->length || (this_frag->flags & MP_END)) + { end_or_hole_found = 1; - - if (end_or_hole_found) end_index = index; + } } if (end_or_hole_found) @@ -2040,9 +2046,6 @@ discard_lost_frames: this_frag->flags = 0; this_frag->length = 0; } - - if (index == this_fragmentation->start_index) - break; } this_fragmentation->start_index = (end_index + 1) & MAXFRAGNUM_MASK; -- 2.20.1