+ if (min >= (this_fragmentation->start_seq + this_bundle->num_of_links))
+ {
+ // Find the new start sequence, the previous frag are lost
+ // calculate M offset of the M seq in the bundle
+ int M_offset = (int) (min - this_fragmentation->start_seq);
+ begin_index = (M_offset + this_fragmentation->start_index) & MAXFRAGNUM_MASK;
+
+ if (M_offset >= MAXFRAGNUM)
+ {
+ // There have a long break of the link !!!!!!!!
+ // M_offset is bigger that the fragmentation buffer size
+ LOG(3, s, t, "MPPP: M_offset out of range, min:%d, begin_seq:%d, size frag:%d\n", min, this_fragmentation->start_seq, l);
+
+ // Set new Start sequence
+ this_fragmentation->start_index = begin_index;
+ this_fragmentation->start_seq = min;
+ M_offset = 0;
+ // recalculate the fragment offset from the new begin seq in the bundle
+ frag_offset = (int) (seq_num - min);
+ }
+ else if (M_offset > 0)
+ {
+ uint32_t b_seq = min;
+ if ((min == seq_num) && begin_frame)
+ {
+ // Set new Start sequence
+ this_fragmentation->start_index = begin_index;
+ this_fragmentation->start_seq = min;
+ frag_offset = 0;
+ }
+ else
+ {
+ if (min == seq_num)
+ {
+ M_offset--;
+ begin_index = (begin_index ? (begin_index -1) : (MAXFRAGNUM -1));
+ b_seq--;
+ }
+
+ // Find the Begin sequence
+ while (this_fragmentation->fragment[begin_index].length)
+ {
+ if (b_seq == this_fragmentation->fragment[begin_index].seq)
+ {
+ if (this_fragmentation->fragment[begin_index].flags & MP_BEGIN)
+ break;
+ }
+ else
+ {
+ // This fragment is lost, it was never completed the packet.
+ LOG(3, this_fragmentation->fragment[begin_index].sid, this_fragmentation->fragment[begin_index].tid,
+ "MPPP: (FIND) seq_num:%d frag_index:%d flags:%d is LOST\n",
+ this_fragmentation->fragment[begin_index].seq, begin_index, this_fragmentation->fragment[begin_index].flags);
+ // this frag is lost
+ this_fragmentation->fragment[begin_index].length = 0;
+ this_fragmentation->fragment[begin_index].flags = 0;
+ break;
+ }
+ begin_index = (begin_index ? (begin_index -1) : (MAXFRAGNUM -1));
+ b_seq--;
+ }