From 08ca01b2a4affc5df6e9fef0aaafe35aa72b0978 Mon Sep 17 00:00:00 2001 From: Anders Broman Date: Fri, 9 Dec 2011 18:58:26 +0000 Subject: Dissect the whole IR packet in packet-rohc.c svn path=/trunk/; revision=40135 --- epan/dissectors/packet-pdcp-lte.c | 38 ++++++------ epan/dissectors/packet-rohc.c | 119 ++++++++++++++++++++++---------------- epan/dissectors/packet-rohc.h | 2 + 3 files changed, 88 insertions(+), 71 deletions(-) diff --git a/epan/dissectors/packet-pdcp-lte.c b/epan/dissectors/packet-pdcp-lte.c index 85113f3c24..2726f82920 100644 --- a/epan/dissectors/packet-pdcp-lte.c +++ b/epan/dissectors/packet-pdcp-lte.c @@ -885,7 +885,7 @@ static int dissect_pdcp_irdyn_packet(proto_tree *tree, return offset; } - +#if 0 static int dissect_pdcp_ir_packet(proto_tree *tree, proto_item *root_item, tvbuff_t *tvb, @@ -1010,34 +1010,17 @@ static int dissect_pdcp_ir_packet(proto_tree *tree, /* Dynamic chain */ if (dynamic_chain_present) { -#if 0 offset = dissect_pdcp_dynamic_chain(tree, root_item, tvb, offset, p_pdcp_info, pinfo); -#endif - /* RoHC settings */ - p_rohc_info = ep_new(rohc_info); - - p_rohc_info->rohc_compression = p_pdcp_info->rohc_compression; - p_rohc_info->rohc_ip_version = p_pdcp_info->rohc_ip_version; - p_rohc_info->cid_inclusion_info = p_pdcp_info->cid_inclusion_info; - p_rohc_info->large_cid_present = p_pdcp_info->large_cid_present; - p_rohc_info->mode = p_pdcp_info->mode; - p_rohc_info->rnd = p_pdcp_info->rnd; - p_rohc_info->udp_checkum_present = p_pdcp_info->udp_checkum_present; - p_rohc_info->profile = p_pdcp_info->profile; - p_rohc_info->last_created_item = root_item; - - offset = dissect_rohc_ir_rtp_profile_dynamic(tvb, tree, offset, p_rohc_info); - } return offset; } - +#endif static int dissect_pdcp_feedback_feedback1(proto_tree *tree, @@ -1946,6 +1929,7 @@ static void dissect_pdcp_lte(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree guint8 base_header_byte; gboolean udp_checksum_needed = TRUE; gboolean ip_id_needed = TRUE; + rohc_info *p_rohc_info = NULL; /* Append this protocol name rather than replace. */ col_set_str(pinfo->cinfo, COL_PROTOCOL, "PDCP-LTE"); @@ -2269,7 +2253,21 @@ static void dissect_pdcp_lte(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree /* IR (1111110) */ if ((base_header_byte & 0xfe) == 0xfc) { - offset = dissect_pdcp_ir_packet(rohc_tree, rohc_ti, tvb, offset, p_pdcp_info, pinfo); + /* RoHC settings */ + p_rohc_info = ep_new(rohc_info); + + p_rohc_info->rohc_compression = p_pdcp_info->rohc_compression; + p_rohc_info->rohc_ip_version = p_pdcp_info->rohc_ip_version; + p_rohc_info->cid_inclusion_info = p_pdcp_info->cid_inclusion_info; + p_rohc_info->large_cid_present = p_pdcp_info->large_cid_present; + p_rohc_info->mode = p_pdcp_info->mode; + p_rohc_info->rnd = p_pdcp_info->rnd; + p_rohc_info->udp_checkum_present = p_pdcp_info->udp_checkum_present; + p_rohc_info->profile = p_pdcp_info->profile; + p_rohc_info->last_created_item = NULL; + + /*offset = dissect_pdcp_ir_packet(rohc_tree, rohc_ti, tvb, offset, p_pdcp_info, pinfo);*/ + offset = dissect_rohc_ir_packet(tvb, rohc_tree, pinfo, offset, 0, TRUE/* fool the ROCH dissector */, p_rohc_info); udp_checksum_needed = FALSE; ip_id_needed = FALSE; } diff --git a/epan/dissectors/packet-rohc.c b/epan/dissectors/packet-rohc.c index df81651752..cf37a96b8f 100644 --- a/epan/dissectors/packet-rohc.c +++ b/epan/dissectors/packet-rohc.c @@ -379,7 +379,6 @@ dissect_rohc_ir_rtp_profile_dynamic(tvbuff_t *tvb, proto_tree *tree, int offset, 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 offset; } @@ -432,7 +431,6 @@ 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 offset; } proto_tree_add_item(sub_tree, hf_rohc_rtp_x, tvb, offset, 1, ENC_BIG_ENDIAN); @@ -464,7 +462,7 @@ dissect_rohc_ir_rtp_profile_dynamic(tvbuff_t *tvb, proto_tree *tree, int offset, return offset; } -static void +static int dissect_rohc_ir_rtp_udp_profile_static(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, int offset, gboolean d, rohc_info *p_rohc_info){ proto_item *item; @@ -504,11 +502,11 @@ dissect_rohc_ir_rtp_udp_profile_static(tvbuff_t *tvb, proto_tree *tree, packet_i /* 5.7.7.3. Initialization of IPv6 Header [IPv6]*/ proto_tree_add_text(tree, tvb, offset, -1, "Not dissected yet"); /* TODO: Short term, Calculate length and continue? */ - return; + return -1; break; default: proto_tree_add_text(sub_tree, tvb, offset, -1, "Error unknown version, only 4 or 6 allowed"); - return; + return -1; } if ((p_rohc_info->profile == ROHC_PROFILE_RTP) || (p_rohc_info->profile == ROHC_PROFILE_UDP)) { @@ -526,8 +524,7 @@ dissect_rohc_ir_rtp_udp_profile_static(tvbuff_t *tvb, proto_tree *tree, packet_i 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"); - return; + return offset; } /* 5.7.7.6. Initialization of RTP Header [RTP]. */ @@ -540,17 +537,73 @@ dissect_rohc_ir_rtp_udp_profile_static(tvbuff_t *tvb, proto_tree *tree, packet_i if(d==TRUE){ offset = dissect_rohc_ir_rtp_profile_dynamic(tvb, tree, offset, p_rohc_info); } - proto_tree_add_text(tree, tvb, offset, -1, "RTP data"); } + return offset; } +int +dissect_rohc_ir_packet(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, int offset, guint8 cid, gboolean is_add_cid, rohc_info *p_rohc_info) +{ + proto_item *ir_item, *item; + proto_tree *ir_tree; + int x_bit_offset; + gboolean d = FALSE; + guint8 oct, profile, val_len; + gint16 feedback_data_len = 0; + + oct = tvb_get_guint8(tvb,offset); + + if((p_rohc_info->large_cid_present == FALSE) && (is_add_cid == FALSE)){ + item = proto_tree_add_uint(tree, hf_rohc_small_cid, tvb, 0, 0, cid); + PROTO_ITEM_SET_GENERATED(item); + } + ir_item = proto_tree_add_item(tree, hf_rohc_ir_packet, tvb, offset, 1, ENC_BIG_ENDIAN); + ir_tree = proto_item_add_subtree(ir_item, ett_rohc_ir); + d = oct & 0x01; + x_bit_offset = offset; + offset++; + if(p_rohc_info->large_cid_present == TRUE){ + /* Handle Large CID:s here */ + get_self_describing_var_len_val(tvb, ir_tree, offset, hf_rohc_large_cid, &val_len); + offset = offset + val_len; + } + profile = tvb_get_guint8(tvb,offset); + if(profile==ROHC_PROFILE_RTP){ + proto_tree_add_item(ir_tree, hf_rohc_d_bit, tvb, x_bit_offset, 1, ENC_BIG_ENDIAN); + } + item = proto_tree_add_item(ir_tree, hf_rohc_profile, tvb, offset, 1, ENC_BIG_ENDIAN); + if(p_rohc_info->profile != profile){ + expert_add_info_format(pinfo, item, PI_PROTOCOL, PI_WARN, + "Configured profile %u, differs from actual profile %u, Dissection of other packets may be faulty", + p_rohc_info->profile, profile); + /* Oweride the configured profile */ + p_rohc_info->profile = profile; + } + offset++; + proto_tree_add_item(ir_tree, hf_rohc_rtp_crc, tvb, offset, 1, ENC_BIG_ENDIAN); + offset++; + switch(profile){ + case ROHC_PROFILE_RTP: + offset = dissect_rohc_ir_rtp_udp_profile_static(tvb, ir_tree, pinfo, offset, d, p_rohc_info); + break; + case ROHC_PROFILE_UDP: + offset = dissect_rohc_ir_rtp_udp_profile_static(tvb, ir_tree, pinfo, offset, d, p_rohc_info); + break; + default: + proto_tree_add_text(ir_tree, tvb, offset, feedback_data_len, "profile-specific information[Not dissected yet]"); + offset = -1; + break; + } + return offset; + +} static void dissect_rohc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { - proto_item *ti, *item, *ir_item; + proto_item *ti, *ir_item, *item; proto_tree *rohc_tree, *ir_tree, *sub_tree = NULL; - int offset = 0, length, x_bit_offset; + int offset = 0, length; guint8 oct, code, size , cid, profile, val_len; gint16 feedback_data_len = 0; gboolean is_add_cid = FALSE, d = FALSE; @@ -703,47 +756,11 @@ start_over: */ if((oct&0xfe) == 0xfc){ col_append_str(pinfo->cinfo, COL_INFO, "IR packet"); - if((p_rohc_info->large_cid_present == FALSE) && (is_add_cid == FALSE)){ - item = proto_tree_add_uint(rohc_tree, hf_rohc_small_cid, tvb, 0, 0, cid); - PROTO_ITEM_SET_GENERATED(item); - } - ir_item = proto_tree_add_item(rohc_tree, hf_rohc_ir_packet, tvb, offset, 1, ENC_BIG_ENDIAN); - ir_tree = proto_item_add_subtree(ir_item, ett_rohc_ir); - d = oct & 0x01; - x_bit_offset = offset; - offset++; - if(p_rohc_info->large_cid_present == TRUE){ - /* Handle Large CID:s here */ - get_self_describing_var_len_val(tvb, sub_tree, offset, hf_rohc_large_cid, &val_len); - offset = offset + val_len; - } - profile = tvb_get_guint8(tvb,offset); - if(profile==ROHC_PROFILE_RTP){ - proto_tree_add_item(ir_tree, hf_rohc_d_bit, tvb, x_bit_offset, 1, ENC_BIG_ENDIAN); - } - item = proto_tree_add_item(ir_tree, hf_rohc_profile, tvb, offset, 1, ENC_BIG_ENDIAN); - if(p_rohc_info->profile != profile){ - expert_add_info_format(pinfo, item, PI_PROTOCOL, PI_WARN, - "Configured profile %u, differs from actual profile %u, Dissection of other packets may be faulty", - p_rohc_info->profile, profile); - /* Oweride the configured profile */ - p_rohc_info->profile = profile; - } - offset++; - proto_tree_add_item(ir_tree, hf_rohc_rtp_crc, tvb, offset, 1, ENC_BIG_ENDIAN); - offset++; - switch(profile){ - case ROHC_PROFILE_RTP: - dissect_rohc_ir_rtp_udp_profile_static(tvb, ir_tree, pinfo, offset, d, p_rohc_info); - break; - case ROHC_PROFILE_UDP: - dissect_rohc_ir_rtp_udp_profile_static(tvb, ir_tree, pinfo, offset, d, p_rohc_info); - break; - default: - proto_tree_add_text(ir_tree, tvb, offset, feedback_data_len, "profile-specific information[Not dissected yet]"); - break; + offset = dissect_rohc_ir_packet(tvb, rohc_tree, pinfo, offset, cid, is_add_cid, p_rohc_info); + if(offset = -1){ + return; } - return; + proto_tree_add_text(rohc_tree, tvb, offset, -1, "Data"); } if((oct&0xff) == 0xf8){ col_append_str(pinfo->cinfo, COL_INFO, "IR-DYN packet"); @@ -755,7 +772,7 @@ start_over: ir_tree = proto_item_add_subtree(ir_item, ett_rohc_ir_dyn); if(p_rohc_info->large_cid_present == TRUE){ /* Handle Large CID:s here */ - get_self_describing_var_len_val(tvb, sub_tree, offset, hf_rohc_large_cid, &val_len); + get_self_describing_var_len_val(tvb, ir_tree, offset, hf_rohc_large_cid, &val_len); offset = offset + val_len; } profile = tvb_get_guint8(tvb,offset); diff --git a/epan/dissectors/packet-rohc.h b/epan/dissectors/packet-rohc.h index a9b803ba06..d9e509c4d5 100644 --- a/epan/dissectors/packet-rohc.h +++ b/epan/dissectors/packet-rohc.h @@ -53,4 +53,6 @@ typedef struct rohc_info } rohc_info; int dissect_rohc_ir_rtp_profile_dynamic(tvbuff_t *tvb, proto_tree *tree, int offset, rohc_info *p_rohc_info); +int dissect_rohc_ir_packet(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, int offset, guint8 cid, gboolean is_add_cid, rohc_info *p_rohc_info); + #endif /* PACKET_ROHC_H */ -- cgit v1.2.3