aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-diameter.c
diff options
context:
space:
mode:
authorAndersBroman <anders.broman@ericsson.com>2014-09-10 15:13:46 +0200
committerAnders Broman <a.broman58@gmail.com>2014-09-10 13:16:46 +0000
commit5ff7a2639ca8a35e544119ae742ec208a47f9e74 (patch)
tree1d4affa686d26133a7d74ad823e852f491181554 /epan/dissectors/packet-diameter.c
parentc6c8dc2b4268005c44a7a2691ab85b0ea435242e (diff)
Minor performance tweaks:
- Only calculate tvb length once. - Use tvb_reported_length() instead of tvb_reported_length_remaining() as this is a subtvb offset is always 0. Change-Id: I03bd7a95061488d4576fa93f26e6b31d55f88738 Reviewed-on: https://code.wireshark.org/review/4060 Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-diameter.c')
-rw-r--r--epan/dissectors/packet-diameter.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/epan/dissectors/packet-diameter.c b/epan/dissectors/packet-diameter.c
index c3ee92b65a..73a0f801a7 100644
--- a/epan/dissectors/packet-diameter.c
+++ b/epan/dissectors/packet-diameter.c
@@ -750,10 +750,11 @@ address_rfc_avp(diam_ctx_t *c, diam_avp_t *a, tvbuff_t *tvb, diam_sub_dis_t *dia
{
char *label = (char *)wmem_alloc(wmem_packet_scope(), ITEM_LABEL_LENGTH+1);
address_avp_t *t = (address_avp_t *)a->type_data;
- proto_item *pi = proto_tree_add_item(c->tree,a->hf_value,tvb,0,tvb_reported_length(tvb),ENC_BIG_ENDIAN);
+ gint len = tvb_reported_length(tvb);
+ proto_item *pi = proto_tree_add_item(c->tree, a->hf_value, tvb, 0, len, ENC_BIG_ENDIAN);
proto_tree *pt = proto_item_add_subtree(pi,t->ett);
guint32 addr_type = tvb_get_ntohs(tvb,0);
- gint len = tvb_reported_length_remaining(tvb,2);
+ len = len-2;
proto_tree_add_item(pt,t->hf_address_type,tvb,0,2,ENC_NA);
switch (addr_type ) {
@@ -879,9 +880,9 @@ integer32_avp(diam_ctx_t *c, diam_avp_t *a, tvbuff_t *tvb, diam_sub_dis_t *diam_
proto_item *pi;
/* Verify length before adding */
- gint length = tvb_reported_length_remaining(tvb,0);
+ gint length = tvb_reported_length(tvb);
if (length == 4) {
- pi= proto_tree_add_item(c->tree,a->hf_value,tvb,0,tvb_reported_length_remaining(tvb,0),ENC_BIG_ENDIAN);
+ pi= proto_tree_add_item(c->tree, a->hf_value, tvb, 0, length, ENC_BIG_ENDIAN);
label = (char *)wmem_alloc(wmem_packet_scope(), ITEM_LABEL_LENGTH+1);
proto_item_fill_label(PITEM_FINFO(pi), label);
label = strstr(label,": ")+2;
@@ -905,9 +906,9 @@ integer64_avp(diam_ctx_t *c, diam_avp_t *a, tvbuff_t *tvb, diam_sub_dis_t *diam_
proto_item *pi;
/* Verify length before adding */
- gint length = tvb_reported_length_remaining(tvb,0);
+ gint length = tvb_reported_length(tvb);
if (length == 8) {
- pi= proto_tree_add_item(c->tree,a->hf_value,tvb,0,tvb_reported_length_remaining(tvb,0),ENC_BIG_ENDIAN);
+ pi= proto_tree_add_item(c->tree, a->hf_value, tvb, 0, length, ENC_BIG_ENDIAN);
label = (char *)wmem_alloc(wmem_packet_scope(), ITEM_LABEL_LENGTH+1);
proto_item_fill_label(PITEM_FINFO(pi), label);
label = strstr(label,": ")+2;
@@ -931,9 +932,9 @@ unsigned32_avp(diam_ctx_t *c, diam_avp_t *a, tvbuff_t *tvb, diam_sub_dis_t *diam
proto_item *pi;
/* Verify length before adding */
- gint length = tvb_reported_length_remaining(tvb,0);
+ gint length = tvb_reported_length(tvb);
if (length == 4) {
- pi= proto_tree_add_item(c->tree,a->hf_value,tvb,0,tvb_reported_length_remaining(tvb,0),ENC_BIG_ENDIAN);
+ pi= proto_tree_add_item(c->tree, a->hf_value, tvb, 0, length, ENC_BIG_ENDIAN);
label = (char *)wmem_alloc(wmem_packet_scope(), ITEM_LABEL_LENGTH+1);
proto_item_fill_label(PITEM_FINFO(pi), label);
label = strstr(label,": ")+2;
@@ -957,9 +958,9 @@ unsigned64_avp(diam_ctx_t *c, diam_avp_t *a, tvbuff_t *tvb, diam_sub_dis_t *diam
proto_item *pi;
/* Verify length before adding */
- gint length = tvb_reported_length_remaining(tvb,0);
+ gint length = tvb_reported_length(tvb);
if (length == 8) {
- pi= proto_tree_add_item(c->tree,a->hf_value,tvb,0,tvb_reported_length_remaining(tvb,0),ENC_BIG_ENDIAN);
+ pi= proto_tree_add_item(c->tree, a->hf_value, tvb, 0, length, ENC_BIG_ENDIAN);
label = (char *)wmem_alloc(wmem_packet_scope(), ITEM_LABEL_LENGTH+1);
proto_item_fill_label(PITEM_FINFO(pi), label);
label = strstr(label,": ")+2;
@@ -983,9 +984,9 @@ float32_avp(diam_ctx_t *c, diam_avp_t *a, tvbuff_t *tvb, diam_sub_dis_t *diam_su
proto_item *pi;
/* Verify length before adding */
- gint length = tvb_reported_length_remaining(tvb,0);
+ gint length = tvb_reported_length(tvb);
if (length == 4) {
- pi= proto_tree_add_item(c->tree,a->hf_value,tvb,0,tvb_reported_length_remaining(tvb,0),ENC_BIG_ENDIAN);
+ pi= proto_tree_add_item(c->tree,a->hf_value, tvb, 0, length, ENC_BIG_ENDIAN);
label = (char *)wmem_alloc(wmem_packet_scope(), ITEM_LABEL_LENGTH+1);
proto_item_fill_label(PITEM_FINFO(pi), label);
label = strstr(label,": ")+2;
@@ -1009,9 +1010,9 @@ float64_avp(diam_ctx_t *c, diam_avp_t *a, tvbuff_t *tvb, diam_sub_dis_t *diam_su
proto_item *pi;
/* Verify length before adding */
- gint length = tvb_reported_length_remaining(tvb,0);
+ gint length = tvb_reported_length(tvb);
if (length == 8) {
- pi= proto_tree_add_item(c->tree,a->hf_value,tvb,0,tvb_reported_length_remaining(tvb,0),ENC_BIG_ENDIAN);
+ pi= proto_tree_add_item(c->tree, a->hf_value, tvb, 0, length, ENC_BIG_ENDIAN);
label = (char *)wmem_alloc(wmem_packet_scope(), ITEM_LABEL_LENGTH+1);
proto_item_fill_label(PITEM_FINFO(pi), label);
label = strstr(label,": ")+2;