This is our old Q&A Site. Please post any new questions and answers at ask.wireshark.org.

Hi My reassembly is not working . Iam using switch case for beginning of message continuation of message end of message

my code i not working . is it because of switch case ? please help.

    switch (msg_type){

            case 0x00: // Continuation of Message 
                                        msg_seqid=1;

                                        pdu_length+=1;

                                        rem_length = pdu_length;
            proto_tree_add_text(FT_BCnPDU_tree, next_tvb, offset_payload, rem_length , "PDU data : %d", rem_length);

                                        pdu_length-=rem_length;

                                        if (pf ==0x00){
                                        save_fragmented = pinfo->fragmented;    
                                        pinfo->fragmented = TRUE;

                                        frag_msg = fragment_add_seq_check(&mte_reassembly_table,
                                              next_tvb,
                                              offset_payload,
                                              pinfo,
                                              msg_seqid, /* ID for fragments belonging together */
                                              NULL,
                                              mte_seqid, /* fragment sequence number */
                                              rem_length,  /* fragment length - to the end */
                                              more_frags); /* More fragments? */

                                        save_fragmented = pinfo->fragmented;

                                        offset_payload+=rem_length;

                                        if (frag_msg != NULL){
                                        col_append_fstr(pinfo->cinfo, COL_INFO, " mte segment of a reassembled PDU");
                                                            }

                                        }

                        break;

            case 0x01: // Beginning of Message 
                                            msg_seqid=0;

                                            BCnPDU_bom_item = proto_tree_add_text(BCnPDU_stype_tree, next_tvb, offset_payload, 1, "MACSAPFLAGS");
                                            BCnPDU_bom_tree = proto_item_add_subtree(BCnPDU_bom_item, ett_BCnPDU_bom);

                                            pdu_len = (tvb_get_ntohl(next_tvb, offset_payload) & 0x07ff0000) >>16; // PDU Length - 11 Bits  pdu_len is guint32 32 bit variable

                                            proto_tree_add_text(BCnPDU_bom_tree, next_tvb, offset_payload, 2, "PDU Length : 0x%02x (%d)", pdu_len,pdu_len);

                                            offset_payload+=2;

                                            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 (else) : %d ", rem_length);

                                           save_fragmented = pinfo->fragmented;    
                                            pinfo->fragmented = TRUE;

                                            fragment_set_tot_len(&mte_reassembly_table, pinfo, msg_seqid, NULL, pdu_len);

                                          frag_msg = fragment_add_seq_check(&mte_reassembly_table,
                                              next_tvb,
                                              offset_payload,
                                              pinfo,
                                              msg_seqid, /* ID for fragments belonging together */
                                              NULL,
                                              mte_seqid, /* fragment sequence number */
                                              rem_length,  /* fragment length - to the end */
                                              more_frags); /* More fragments? */

                                              pinfo->fragmented = save_fragmented;

                                        offset_payload+=rem_length;

                                        if (frag_msg != NULL){                                      
                                                col_append_fstr(pinfo->cinfo, COL_INFO, " Fragmented ");

                                                    }else{

                                                        col_append_fstr(pinfo->cinfo, COL_INFO, " SOmthing wrong ");
                                                    }                       
                                            }

                            break;

        case 0x02: // End of Message

                                    msg_seqid=2;
                                        pdu_length+=2;
                                        more_frags=FALSE;

                                        rem_length =  pdu_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;
                                        save_fragmented = pinfo->fragmented;

                                        pinfo->fragmented = FALSE;

                                        frag_msg = fragment_add_seq_check(&mte_reassembly_table,
                                              next_tvb,
                                              offset_payload,
                                              pinfo,
                                              msg_seqid, /* ID for fragments belonging together */
                                              NULL,
                                              mte_seqid, /* fragment sequence number */
                                              rem_length,  /* fragment length - to the end */
                                              more_frags); /* More fragments? */

                                        save_fragmented = pinfo->fragmented;

                                         rass_tvb = process_reassembled_data(next_tvb,
                                               offset_payload,
                                               pinfo,
                                               "Reassembled Message",
                                               frag_msg,
                                               &mte_frag_items,
                                               NULL,
                                               FT_BCnPDU_tree);

                                if (frag_msg != NULL) { /* Reassembled */
                                    //rass_tvb=try_tvb;
                                    add_new_data_source(pinfo, rass_tvb, "Reassembled mte");
                                    show_fragment_tree(frag_msg, &mte_frag_items,FT_BCnPDU_tree, pinfo, rass_tvb, &frag_tree_item);
                                    col_append_str(pinfo->cinfo, COL_INFO,"(Message reassemble progress) ");

                                                    }else { /* Not last packet of reassembled message */
                                                            col_append_str(pinfo->cinfo, COL_INFO,"(Message fragment) ");
                                                                            }

                                    if (rass_tvb){
                                                offset_payload=0;
                                                col_append_str(pinfo->cinfo, COL_INFO,"(Message reassembled ) ");
                                                SIGPDU(rass_tvb, pinfo, FT_BCnPDU_tree);
                                                    }

                                                    reassembly_table_destroy(&mte_reassembly_table);

                                                    break;

asked 14 Dec '14, 06:15

umar's gravatar image

umar
26222427
accept rate: 0%

I have used fragmentation out of this switch case and tried

my frag_msg is always returning NULL Value . I believe something wrong with my reassembly table.

i have tried many

fragment_add_seq_check fragment_add_seq_next

i have 3 diff message 1. beginning 2 continuation 3 end of message

and my msg_seq id i set to 0,1,2

and mte seq number i get from pdu . (message belongs to mte_seq id 3 will assemble together) sometimes my data is not comes in order,

please help

(14 Dec '14, 06:50) umar
Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×78
×32
×16
×1

question asked: 14 Dec '14, 06:15

question was seen: 937 times

last updated: 14 Dec '14, 06:50

p​o​w​e​r​e​d by O​S​Q​A