+ 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)
+ {
+ if (begin_frame)
+ {
+ // Set new Start sequence
+ this_fragmentation->start_index = begin_index;
+ this_fragmentation->start_seq = min;
+ frag_offset = 0;
+ }
+ }
+ else
+ {
+ // 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--;
+ }
+
+ // begin sequence found ?
+ if (this_fragmentation->fragment[begin_index].length)
+ {
+ // Set new Start sequence
+ this_fragmentation->start_index = begin_index;
+ this_fragmentation->start_seq = b_seq;
+ // recalculate the fragment offset from the new begin seq in the bundle
+ frag_offset = (int) (seq_num - b_seq);
+ }
+ }
+ }
+ }
+ else if ((this_fragmentation->fragment[start_index].length) &&
+ (!(this_fragmentation->fragment[start_index].flags & MP_BEGIN)))
+ {
+ uint32_t f_seq = this_fragmentation->start_seq;
+ end_index = start_index;
+ // Find the Begin sequence
+ while (this_fragmentation->fragment[end_index].length)
+ {
+ if (f_seq == this_fragmentation->fragment[end_index].seq)
+ {
+ if (this_fragmentation->fragment[end_index].flags & MP_BEGIN)
+ break;
+ }
+ else
+ {
+ // This fragment is lost, it was never completed the packet.
+ LOG(3, this_fragmentation->fragment[end_index].sid, this_fragmentation->fragment[end_index].tid,
+ "MPPP: (FIND2) seq_num:%d frag_index:%d flags:%d is LOST\n",
+ this_fragmentation->fragment[end_index].seq, end_index, this_fragmentation->fragment[end_index].flags);
+ // this frag is lost
+ this_fragmentation->fragment[end_index].length = 0;
+ this_fragmentation->fragment[end_index].flags = 0;
+ break;
+ }
+ end_index = (end_index +1) & MAXFRAGNUM_MASK;
+ f_seq++;
+ }
+
+ // Set new Start sequence
+ this_fragmentation->start_index = end_index;
+ this_fragmentation->start_seq = f_seq;
+ // recalculate the fragment offset from the new begin seq in the bundle
+ frag_offset = (int) (seq_num - f_seq);
+ }