Use correct offset.
[obnox/wireshark/wip.git] / epan / dissectors / packet-rohc.c
index 57fc8449d26ddcc17896f54099725958487e07ab..df81651752bda00191380f7aba775eeb11e02606 100644 (file)
@@ -40,6 +40,7 @@
 #include <epan/rtp_pt.h>
 #include <epan/expert.h>
 
+#include "packet-rohc.h"
 /* Initialize the protocol and registered fields */
 static int proto_rohc                  = -1;
 
@@ -107,28 +108,6 @@ static int ett_rohc_rtp_dynamic = -1;
 static guint8 g_profile = 1;
 static guint8 g_version = 4;
 
-enum rohc_mode
-{
-  UNIDIRECTIONAL = 1,
-  OPTIMISTIC_BIDIRECTIONAL = 2,
-  RELIABLE_BIDIRECTIONAL = 3
-};
-
-typedef struct rohc_info
-{
-
-    /* RoHC settings */
-    gboolean           rohc_compression;
-    unsigned short     rohc_ip_version;
-    gboolean           cid_inclusion_info;
-    gboolean           large_cid_present;
-    enum rohc_mode     mode;
-    gboolean           rnd;
-    gboolean           udp_checkum_present;
-    unsigned short     profile;
-       proto_item         *last_created_item;
-} rohc_info;
-
 /* ROHC Profiles */
 #define ROHC_PROFILE_RTP       1
 #define ROHC_PROFILE_UDP       2
@@ -347,7 +326,7 @@ dissect_rohc_feedback_data(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo,
                        break;
        }
 }
-static void
+int
 dissect_rohc_ir_rtp_profile_dynamic(tvbuff_t *tvb, proto_tree *tree, int offset, rohc_info *p_rohc_info){
 
        proto_item *item;
@@ -384,7 +363,7 @@ dissect_rohc_ir_rtp_profile_dynamic(tvbuff_t *tvb, proto_tree *tree, int offset,
                        break;
                case 6:
                        proto_tree_add_text(sub_tree, tvb, offset, -1, "Not dissected yet");
-                       return;
+                       return offset;
                        break;
                default:
                        break;
@@ -397,11 +376,11 @@ dissect_rohc_ir_rtp_profile_dynamic(tvbuff_t *tvb, proto_tree *tree, int offset,
        proto_tree_add_item(sub_tree, hf_rohc_rtp_checksum, tvb, offset, 2, ENC_BIG_ENDIAN);
        offset+=2;
        if (p_rohc_info->profile == 2) {
-               proto_tree_add_item(sub_tree, hf_rohc_dynamic_udp_seqnum, tvb, offset, 2, FALSE);
+               proto_tree_add_item(sub_tree, hf_rohc_dynamic_udp_seqnum, tvb, offset, 2, ENC_BIG_ENDIAN);
                offset +=2;
                proto_item_set_len(item, offset - start_offset);
                proto_tree_add_text(tree, tvb, offset, -1, "RTP data");
-               return;
+               return offset;
        }
 
        /* 5.7.7.6.  Initialization of RTP Header
@@ -454,7 +433,7 @@ dissect_rohc_ir_rtp_profile_dynamic(tvbuff_t *tvb, proto_tree *tree, int offset,
        /* : Reserved  | X |  Mode |TIS|TSS:  if RX = 1 */
        if(rx==0){
                proto_tree_add_text(tree, tvb, offset, -1, "RTP data");
-               return;
+               return offset;
        }
        proto_tree_add_item(sub_tree, hf_rohc_rtp_x, tvb, offset, 1, ENC_BIG_ENDIAN);
        proto_tree_add_item(sub_tree, hf_rohc_rtp_mode, tvb, offset, 1, ENC_BIG_ENDIAN);
@@ -481,7 +460,8 @@ dissect_rohc_ir_rtp_profile_dynamic(tvbuff_t *tvb, proto_tree *tree, int offset,
        }
 
        proto_item_set_len(item, offset - start_offset);
-       proto_tree_add_text(tree, tvb, offset, -1, "RTP data");
+       
+       return offset;
 
 }
 static void
@@ -543,7 +523,7 @@ dissect_rohc_ir_rtp_udp_profile_static(tvbuff_t *tvb, proto_tree *tree, packet_i
                offset+=2;
                if(p_rohc_info->profile == ROHC_PROFILE_UDP){
                        if(d==TRUE){
-                               dissect_rohc_ir_rtp_profile_dynamic(tvb, tree, offset, p_rohc_info);
+                               offset = dissect_rohc_ir_rtp_profile_dynamic(tvb, tree, offset, p_rohc_info);
                        }
                        proto_item_set_len(item, offset - start_offset);
                        proto_tree_add_text(tree, tvb, offset, -1, "UDP data");
@@ -558,10 +538,9 @@ dissect_rohc_ir_rtp_udp_profile_static(tvbuff_t *tvb, proto_tree *tree, packet_i
 
                /* D:   D = 1 indicates that the dynamic chain is present. */
                if(d==TRUE){
-                       dissect_rohc_ir_rtp_profile_dynamic(tvb, tree, offset, p_rohc_info);
-               }else{
-                       proto_tree_add_text(tree, tvb, offset, -1, "RTP data");
+                       offset = dissect_rohc_ir_rtp_profile_dynamic(tvb, tree, offset, p_rohc_info);
                }
+               proto_tree_add_text(tree, tvb, offset, -1, "RTP data");
        }
 }
 
@@ -609,7 +588,7 @@ dissect_rohc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                col_append_str(pinfo->cinfo, COL_INFO, " ");
        }
        /*if (tree) {*/
-               ti = proto_tree_add_item(tree, proto_rohc, tvb, 0, -1, ENC_BIG_ENDIAN);
+               ti = proto_tree_add_item(tree, proto_rohc, tvb, 0, -1, ENC_NA);
                rohc_tree = proto_item_add_subtree(ti, ett_rohc);
                /*    1) If the first octet is a Padding Octet (11100000),
                 *       strip away all initial Padding Octets and goto next step.