+ // insert the frame in it's place
+ fragmentt *this_frag = &this_fragmentation->fragment[frag_index];
+ this_frag->length = l;
+ this_frag->sid = s;
+ this_frag->flags = flags;
+ this_frag->seq = seq_num;
+ memcpy(this_frag->data, p, l);
+
+ // try to assemble the frame that has the received fragment as a member
+ // get the beginning of this frame
+ begin_index = end_index = frag_index;
+ while (this_fragmentation->fragment[begin_index].length)
+ {
+ if (this_fragmentation->fragment[begin_index].flags & MP_BEGIN)
+ break;
+ begin_index = (begin_index ? (begin_index -1) : (MAXFRAGNUM -1));
+ }
+
+ // return if a lost fragment is found
+ if (!(this_fragmentation->fragment[begin_index].length))
+ return; // assembling frame failed
+ // get the end of his frame
+ while (this_fragmentation->fragment[end_index].length)
+ {
+ if (this_fragmentation->fragment[end_index].flags & MP_END)
+ break;
+ end_index = (end_index +1) & MAXFRAGNUM_MASK;
+ }
+
+ // return if a lost fragment is found
+ if (!(this_fragmentation->fragment[end_index].length))
+ return; // assembling frame failed
+
+ // assemble the packet
+ //assemble frame, process it, reset fragmentation
+ uint16_t cur_len = 4; // This is set to 4 to leave 4 bytes for function processipin
+ uint32_t i;
+
+ LOG(4, s, t, "MPPP: processing fragments from %d to %d\n", begin_index, end_index);