Wireshark-dev: [Wireshark-dev] Reassembly Fragment fail
From: Raj sekar <[email protected]>
Date: Tue, 17 Feb 2015 15:59:06 +0800
Hi,
 

Hi ,

Iam developing a custom dissector on top of UDP which uses PDCP layer PDU RFC 2507 Selective Repeat ARQ Mechanism for segmentation and Reassembly.

My message contains

          Beginning of Message

          continuation of message and

          end of message

Messages are not coming in sequence and based on sequence number and message id i need to reassemble.

I dont know whether i should use

          conversation or

          add_fragment_seq_next or

          add_fragment_seq_check

Please suggest. I got stuck with this for long time.

Why is my code below not working? The fragmentation itself not successful and thus reassembly not working. Please suggest!
switch (stype) {
case 0x00: // Continuation of Message
    msg_seqid = 2;
    rem_length = bctsdu_length;
    proto_tree_add_text(FT_BCnPDU_tree, next_tvb, offset_payload, rem_length, "PDU data : %d", rem_length);
    break;
case 0x01: // Beginning of Message
    msg_seqid = 1;
    proto_tree_add_text(BCnPDU_bom_tree, next_tvb, offset_payload, 2, "PDU Length : 0x%02x (%d)", pdu_len, pdu_len);
    rem_length = tvb_length_remaining(next_tvb, offset_payload);
    rem_length -= 2;
    proto_tree_add_text(BCnPDU_bom_tree, next_tvb, offset_payload, rem_length, "PDU data  : %d ", rem_length);

    break;
case 0x02: // End of Message
    msg_seqid = 3;
    bctsdu_length += 2;
    more_frags = FALSE;
    rem_length = bctsdu_length;
    rem_length -= 2;
    proto_tree_add_text(FT_BCnPDU_tree, next_tvb, offset_payload, rem_length, "PDU data : %d", rem_length);
    disable_CRC = 1;
    break;
case 0x04: // Single Segment Message
    ---- // doesn't need fragment/reassembly
      break;
}

if (msg_seqid == 1 || msg_seqid == 2 || msg_seqid == 3) {
    save_fragmented = pinfo->fragmented;
    pinfo->fragmented = TRUE;
    frag_msg = fragment_add_seq_check(&mns_reassembly_table,
                                      next_tvb,
                                      offset_payload,
                                      pinfo,
                                      mns_seqnum,
                                      NULL,
                                      mns_seqid,
                                      rem_length,
                                      more_frags);
    if (frag_msg) {
        col_append_fstr(pinfo->cinfo, COL_INFO, " mns segment of a FRAGMENT PDU");
    } else {
        col_append_fstr(pinfo->cinfo, COL_INFO, " FRAGMENT NOT DONE ");
    }
}
if (more_frags == FALSE) {
    save_fragmented = pinfo->fragmented;
    pinfo->fragmented = FALSE;

    rass_tvb = process_reassembled_data(next_tvb,
                                        offset_payload,
                                        pinfo,
                                        "Reassembled Message",
                                        frag_msg,
                                        &mns_frag_items,
                                        NULL,
                                        FT_BCnPDU_tree);
    if (rass_tvb) {
        col_append_str(pinfo->cinfo, COL_INFO, "(Message reassembled ) ");
        ALSIGPDU(rass_tvb, pinfo, FT_BCnPDU_tree);
    }
}

I am always getting the FRAGMENT NOT DONE error.

 

Thanks

 

Raj