summaryrefslogtreecommitdiff
path: root/epan
diff options
context:
space:
mode:
authorMartin Kaiser <wireshark@kaiser.cx>2015-06-22 10:23:36 -0700
committerMartin Kaiser <wireshark@kaiser.cx>2015-06-23 17:44:09 +0000
commit17ac3831d6b461e75cb0ddbaf485353891470185 (patch)
treeb278aed1fe068c20037250d67794f1b3530e1cb4 /epan
parented8ad06cccf1df33fe274fc8641d153a25204f38 (diff)
downloadwireshark-17ac3831d6b461e75cb0ddbaf485353891470185.tar.gz
[zvt] the TLV container starts with an overall length field
new function dissect_zvt_tlv_len(), use it for the total length and for each tlv entry's length field Change-Id: I2b7ba6939ddf0326b014c565ffbe5d16e3a88282 Reviewed-on: https://code.wireshark.org/review/9059 Reviewed-by: Martin Kaiser <wireshark@kaiser.cx>
Diffstat (limited to 'epan')
-rw-r--r--epan/dissectors/packet-zvt.c67
1 files changed, 47 insertions, 20 deletions
diff --git a/epan/dissectors/packet-zvt.c b/epan/dissectors/packet-zvt.c
index 74ca54f01a..cca399f137 100644
--- a/epan/dissectors/packet-zvt.c
+++ b/epan/dissectors/packet-zvt.c
@@ -153,6 +153,7 @@ static int hf_zvt_reg_cfg = -1;
static int hf_zvt_cc = -1;
static int hf_zvt_reg_svc_byte = -1;
static int hf_zvt_bitmap = -1;
+static int hf_zvt_tlv_total_len = -1;
static int hf_zvt_tlv_tag = -1;
static int hf_zvt_tlv_len = -1;
@@ -247,6 +248,37 @@ dissect_zvt_tlv_tag(tvbuff_t *tvb, gint offset,
static gint
+dissect_zvt_tlv_len(tvbuff_t *tvb, gint offset,
+ packet_info *pinfo _U_, proto_tree *tree, int hf, guint16 *len)
+{
+ guint16 _len;
+ gint len_bytes = 1;
+
+ _len = tvb_get_guint8(tvb, offset);
+ if (_len & 0x80) {
+ if ((_len & 0x03) == 1) {
+ len_bytes++;
+ _len = tvb_get_guint8(tvb, offset+1);
+ }
+ else if ((_len & 0x03) == 2) {
+ len_bytes += 2;
+ _len = tvb_get_ntohs(tvb, offset+1);
+ }
+ else {
+ /* XXX - expert info */
+ return -1;
+ }
+ }
+
+ proto_tree_add_uint(tree, hf, tvb, offset, len_bytes, _len);
+ if (len)
+ *len = _len;
+
+ return len_bytes;
+}
+
+
+static gint
dissect_zvt_tlv_container(tvbuff_t *tvb, gint offset,
packet_info *pinfo, proto_tree *tree)
{
@@ -255,11 +287,16 @@ dissect_zvt_tlv_container(tvbuff_t *tvb, gint offset,
proto_tree *dat_obj_tree;
gint tag_len;
guint32 tag;
- guint8 data_len_bytes = 1;
- guint16 data_len;
+ gint total_len_bytes, data_len_bytes;
+ guint16 data_len = 0;
offset_start = offset;
+ total_len_bytes = dissect_zvt_tlv_len(tvb, offset, pinfo,
+ tree, hf_zvt_tlv_total_len, NULL);
+ if (total_len_bytes > 0)
+ offset += total_len_bytes;
+
while (tvb_captured_length_remaining(tvb, offset) > 0) {
dat_obj_tree = proto_tree_add_subtree(tree,
tvb, offset, -1, ett_zvt_tlv_dat_obj, &dat_obj_it,
@@ -270,23 +307,10 @@ dissect_zvt_tlv_container(tvbuff_t *tvb, gint offset,
return offset - offset_start;
offset += tag_len;
- data_len = tvb_get_guint8(tvb, offset);
- if (data_len & 0x80) {
- if ((data_len & 0x03) == 1) {
- data_len_bytes++;
- data_len = tvb_get_guint8(tvb, offset+1);
- }
- else if ((data_len & 0x03) == 2) {
- data_len_bytes += 2;
- data_len = tvb_get_ntohs(tvb, offset+1);
- }
- else {
- /* XXX - expert info, exit */
- }
- }
- proto_tree_add_uint(dat_obj_tree, hf_zvt_tlv_len,
- tvb, offset, data_len_bytes, data_len);
- offset += data_len_bytes;
+ data_len_bytes = dissect_zvt_tlv_len(tvb, offset, pinfo,
+ dat_obj_tree,hf_zvt_tlv_len, &data_len);
+ if (data_len_bytes > 0)
+ offset += data_len_bytes;
/* XXX - dissect the data-element */
offset += data_len;
@@ -787,12 +811,15 @@ proto_register_zvt(void)
{ &hf_zvt_bitmap,
{ "Bitmap", "zvt.bitmap", FT_UINT8,
BASE_HEX|BASE_EXT_STRING, &bitmap_ext, 0, NULL, HFILL } },
+ { &hf_zvt_tlv_total_len,
+ { "Total length", "zvt.tlv.total_len",
+ FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_zvt_tlv_tag,
{ "Tag", "zvt.tlv.tag", FT_UINT32,
BASE_HEX|BASE_EXT_STRING, &tlv_tags_ext, 0, NULL, HFILL } },
{ &hf_zvt_tlv_len,
{ "Length", "zvt.tlv.len",
- FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL } }
+ FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } }
};
static ei_register_info ei[] = {