aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
Diffstat (limited to 'epan')
-rw-r--r--epan/dissectors/packet-dccp.c46
1 files changed, 28 insertions, 18 deletions
diff --git a/epan/dissectors/packet-dccp.c b/epan/dissectors/packet-dccp.c
index 1415042a10..be8988c3da 100644
--- a/epan/dissectors/packet-dccp.c
+++ b/epan/dissectors/packet-dccp.c
@@ -315,24 +315,35 @@ decode_dccp_ports(tvbuff_t *tvb, int offset, packet_info *pinfo,
* a concept by Arnaldo de Melo
*/
static guint64
-tvb_get_ntoh_var(tvbuff_t *tvb, gint offset, guint nbytes)
+dccp_ntoh_var(tvbuff_t *tvb, gint offset, guint nbytes)
{
- const guint8 *ptr;
guint64 value = 0;
- ptr = tvb_get_ptr(tvb, offset, nbytes);
- if (nbytes > 5)
- value += ((guint64) * ptr++) << 40;
- if (nbytes > 4)
- value += ((guint64) * ptr++) << 32;
- if (nbytes > 3)
- value += ((guint64) * ptr++) << 24;
- if (nbytes > 2)
- value += ((guint64) * ptr++) << 16;
- if (nbytes > 1)
- value += ((guint64) * ptr++) << 8;
- if (nbytes > 0)
- value += *ptr;
+ switch (nbytes)
+ {
+ case 5:
+ value = tvb_get_ntoh40(tvb, offset);
+ break;
+ case 4:
+ value = tvb_get_ntohl(tvb, offset);
+ break;
+ case 3:
+ value = tvb_get_ntoh24(tvb, offset);
+ break;
+ case 2:
+ value = tvb_get_ntohs(tvb, offset);
+ break;
+ case 1:
+ value = tvb_get_guint8(tvb, offset);
+ break;
+ case 0:
+ // do nothing
+ break;
+ case 6:
+ default:
+ value = tvb_get_ntoh48(tvb, offset);
+ break;
+ }
return value;
}
@@ -385,7 +396,7 @@ dissect_feature_options(proto_tree *dccp_options_tree, tvbuff_t *tvb,
if (option_len > 0) /* could be empty Confirm */
proto_item_append_text(dccp_item, " %" G_GINT64_MODIFIER "u",
- tvb_get_ntoh_var(tvb, offset, option_len));
+ dccp_ntoh_var(tvb, offset, option_len));
break;
/* Reserved, specific, or unknown features */
@@ -469,8 +480,7 @@ dissect_options(tvbuff_t *tvb, packet_info *pinfo,
expert_add_info_format(pinfo, option_item, &ei_dccp_option_len_bad,
"NDP Count too long (max 6 bytes)");
else
- proto_tree_add_uint64(option_tree, hf_dccp_ndp_count, tvb, offset, option_len,
- tvb_get_ntoh_var(tvb, offset, option_len));
+ proto_tree_add_item(option_tree, hf_dccp_ndp_count, tvb, offset, option_len, ENC_BIG_ENDIAN);
break;
case 38:
proto_tree_add_item(option_tree, hf_dccp_ack_vector_nonce_0, tvb, offset, option_len, ENC_NA);