diff options
Diffstat (limited to 'epan/dissectors')
-rw-r--r-- | epan/dissectors/packet-zbee-zdp-binding.c | 227 | ||||
-rw-r--r-- | epan/dissectors/packet-zbee-zdp-discovery.c | 346 | ||||
-rw-r--r-- | epan/dissectors/packet-zbee-zdp-management.c | 186 | ||||
-rw-r--r-- | epan/dissectors/packet-zbee-zdp.c | 103 | ||||
-rw-r--r-- | epan/dissectors/packet-zbee-zdp.h | 1 |
5 files changed, 442 insertions, 421 deletions
diff --git a/epan/dissectors/packet-zbee-zdp-binding.c b/epan/dissectors/packet-zbee-zdp-binding.c index 9ddc4ffa22..91c028c6ce 100644 --- a/epan/dissectors/packet-zbee-zdp-binding.c +++ b/epan/dissectors/packet-zbee-zdp-binding.c @@ -116,35 +116,40 @@ dissect_zbee_zdp_req_end_device_bind(tvbuff_t *tvb, packet_info *pinfo, proto_tr proto_tree *field_tree = NULL; guint offset = 0; - guint16 target; + guint32 target, in_count, out_count; guint64 ext_addr = 0; - /*guint8 src_ep;*/ - /*guint16 profile;*/ - guint8 in_count; - guint8 out_count; - target = zbee_parse_uint(tree, hf_zbee_zdp_target, tvb, &offset, (guint)sizeof(guint16), NULL); + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_target, tvb, offset, 2, ENC_LITTLE_ENDIAN, &target); + offset += 2; if (version >= ZBEE_VERSION_2007) { /* Extended address present on ZigBee 2006 & later. */ ext_addr = zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, (guint)sizeof(guint64), NULL); } - /*src_ep =*/ zbee_parse_uint(tree, hf_zbee_zdp_endpoint, tvb, &offset, (guint)sizeof(guint8), NULL); - /*profile =*/ zbee_parse_uint(tree, hf_zbee_zdp_profile, tvb, &offset, (guint)sizeof(guint16), NULL); - - in_count = zbee_parse_uint(tree, hf_zbee_zdp_in_count, tvb, &offset, (guint)sizeof(guint8), NULL); - if ((tree) && (in_count)){ + proto_tree_add_item(tree, hf_zbee_zdp_endpoint, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; + proto_tree_add_item(tree, hf_zbee_zdp_profile, tvb, offset, 2, ENC_LITTLE_ENDIAN); + offset += 2; + + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_in_count, tvb, offset, 2, ENC_LITTLE_ENDIAN, &in_count); + offset += 1; + if ((tree) && (in_count)) { field_tree = proto_tree_add_subtree(tree, tvb, offset, (int)(in_count*sizeof_cluster), ett_zbee_zdp_bind_end_in, NULL, "Input Cluster List"); } - for (i=0; i<in_count; i++) zbee_parse_uint(field_tree, hf_zbee_zdp_in_cluster, tvb, &offset, (guint)sizeof_cluster, NULL); - - out_count = zbee_parse_uint(tree, hf_zbee_zdp_out_count, tvb, &offset, (guint)sizeof(guint8), NULL); + for (i=0; i<in_count; i++) { + proto_tree_add_item(field_tree, hf_zbee_zdp_in_cluster, tvb, offset, sizeof_cluster, ENC_LITTLE_ENDIAN); + offset += sizeof_cluster; + } + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_out_count, tvb, offset, 2, ENC_LITTLE_ENDIAN, &out_count); + offset += 1; if ((tree) && (out_count)) { field_tree = proto_tree_add_subtree(tree, tvb, offset, (int)(out_count*sizeof_cluster), ett_zbee_zdp_bind_end_out, NULL, "Output Cluster List"); } - for (i=0; i<out_count; i++) zbee_parse_uint(field_tree, hf_zbee_zdp_out_cluster, tvb, &offset, sizeof_cluster, NULL); - + for (i=0; i<out_count; i++) { + proto_tree_add_item(field_tree, hf_zbee_zdp_out_cluster, tvb, offset, sizeof_cluster, ENC_LITTLE_ENDIAN); + offset += sizeof_cluster; + } if (version >= ZBEE_VERSION_2007) { zbee_append_info(tree, pinfo, " Src: %s", eui64_to_display(wmem_packet_scope(), ext_addr)); } @@ -165,28 +170,23 @@ void dissect_zbee_zdp_req_bind(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint8 version) { proto_item *ti; - + guint sizeof_cluster = ZBEE_HAS_2006(version)?(int)sizeof(guint16):(int)sizeof(guint8); guint offset = 0; guint64 src64; - /*guint8 src_ep;*/ - guint16 cluster; - guint8 dst_mode; - guint16 dst = 0; + guint32 cluster, dst_mode, dst; guint64 dst64 = 0; /*guint8 dst_ep;*/ src64 = zbee_parse_eui64(tree, hf_zbee_zdp_bind_src64, tvb, &offset, (int)sizeof(guint64), NULL); - /*src_ep =*/ zbee_parse_uint(tree, hf_zbee_zdp_bind_src_ep, tvb, &offset, (int)sizeof(guint8), NULL); - cluster = zbee_parse_uint(tree, hf_zbee_zdp_cluster, tvb, &offset, ZBEE_HAS_2006(version)?(int)sizeof(guint16):(int)sizeof(guint8), &ti); + proto_tree_add_item(tree, hf_zbee_zdp_bind_src_ep, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; + ti = proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_cluster, tvb, offset, sizeof_cluster, ENC_LITTLE_ENDIAN, &cluster); + offset += sizeof_cluster; proto_item_append_text(ti, " (%s)", val_to_str(cluster, zbee_aps_cid_names, "Unknown Cluster")); if (version >= ZBEE_VERSION_2007) { - dst_mode = zbee_parse_uint(tree, hf_zbee_zdp_addr_mode, tvb, &offset, (int)sizeof(guint8), &ti); - if (tree) { - if (dst_mode == ZBEE_ZDP_ADDR_MODE_GROUP) proto_item_append_text(ti, " (Group)"); - else if (dst_mode == ZBEE_ZDP_ADDR_MODE_UNICAST) proto_item_append_text(ti, " (Unicast)"); - else proto_item_append_text(ti, " (Reserved)"); - } + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_addr_mode, tvb, offset, 1, ENC_LITTLE_ENDIAN, &dst_mode); + offset += 1; } else { /* ZigBee 2003 & earlier does not have a address mode, and is unicast only. */ @@ -194,11 +194,13 @@ dissect_zbee_zdp_req_bind(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, g } if (dst_mode == ZBEE_ZDP_ADDR_MODE_GROUP) { - dst = zbee_parse_uint(tree, hf_zbee_zdp_bind_dst, tvb, &offset, (int)sizeof(guint16), NULL); + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_bind_dst, tvb, offset, 2, ENC_LITTLE_ENDIAN, &dst); + offset += 2; } else if (dst_mode == ZBEE_ZDP_ADDR_MODE_UNICAST) { dst64 = zbee_parse_eui64(tree, hf_zbee_zdp_bind_dst64, tvb, &offset, (int)sizeof(guint64), NULL); - /*dst_ep =*/ zbee_parse_uint(tree, hf_zbee_zdp_bind_dst_ep, tvb, &offset, (int)sizeof(guint8), NULL); + proto_tree_add_item(tree, hf_zbee_zdp_bind_dst_ep, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; } if (version >= ZBEE_VERSION_2007) { @@ -228,28 +230,24 @@ void dissect_zbee_zdp_req_unbind(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint8 version) { proto_item *ti; - + guint sizeof_cluster = (version >= ZBEE_VERSION_2007)?(int)sizeof(guint16):(int)sizeof(guint8); guint offset = 0; guint64 src64; /*guint8 src_ep;*/ - guint16 cluster; - guint8 dst_mode; - guint16 dst = 0; + guint32 cluster, dst_mode, dst = 0; guint64 dst64 = 0; /*guint8 dst_ep;*/ src64 = zbee_parse_eui64(tree, hf_zbee_zdp_bind_src64, tvb, &offset, (int)sizeof(guint64), NULL); - /*src_ep =*/ zbee_parse_uint(tree, hf_zbee_zdp_bind_src_ep, tvb, &offset, (int)sizeof(guint8), NULL); - cluster = zbee_parse_uint(tree, hf_zbee_zdp_cluster, tvb, &offset, (version >= ZBEE_VERSION_2007)?(int)sizeof(guint16):(int)sizeof(guint8), &ti); + proto_tree_add_item(tree, hf_zbee_zdp_bind_src_ep, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; + ti = proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_cluster, tvb, offset, sizeof_cluster, ENC_LITTLE_ENDIAN, &cluster); + offset += sizeof_cluster; proto_item_append_text(ti, " (%s)", val_to_str(cluster, zbee_aps_cid_names, "Unknown Cluster")); if (version >= ZBEE_VERSION_2007) { - dst_mode = zbee_parse_uint(tree, hf_zbee_zdp_addr_mode, tvb, &offset, (int)sizeof(guint8), &ti); - if (tree) { - if (dst_mode == ZBEE_ZDP_ADDR_MODE_GROUP) proto_item_append_text(ti, " (Group)"); - else if (dst_mode == ZBEE_ZDP_ADDR_MODE_UNICAST) proto_item_append_text(ti, " (Unicast)"); - else proto_item_append_text(ti, " (Reserved)"); - } + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_addr_mode, tvb, offset, 1, ENC_LITTLE_ENDIAN, &dst_mode); + offset += 1; } else { /* ZigBee 2003 & earlier does not have a address mode, and is unicast only. */ @@ -257,11 +255,13 @@ dissect_zbee_zdp_req_unbind(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, } if (dst_mode == ZBEE_ZDP_ADDR_MODE_GROUP) { - dst = zbee_parse_uint(tree, hf_zbee_zdp_bind_dst, tvb, &offset, (int)sizeof(guint16), NULL); + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_bind_dst, tvb, offset, 2, ENC_LITTLE_ENDIAN, &dst); + offset += 2; } else if (dst_mode == ZBEE_ZDP_ADDR_MODE_UNICAST) { dst64 = zbee_parse_eui64(tree, hf_zbee_zdp_bind_dst64, tvb, &offset, (int)sizeof(guint64), NULL); - /*dst_ep =*/ zbee_parse_uint(tree, hf_zbee_zdp_bind_dst_ep, tvb, &offset, (int)sizeof(guint8), NULL); + proto_tree_add_item(tree, hf_zbee_zdp_bind_dst_ep, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; } if (version >= ZBEE_VERSION_2007) { @@ -313,14 +313,14 @@ dissect_zbee_zdp_req_replace_device(tvbuff_t *tvb, packet_info *pinfo, proto_tre { guint offset = 0; guint64 ext_addr; - /*guint8 endpoint;*/ guint64 new_addr; - /*guint8 new_ep;*/ ext_addr = zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, (int)sizeof(guint64), NULL); - /*endpoint =*/ zbee_parse_uint(tree, hf_zbee_zdp_endpoint, tvb, &offset, (int)sizeof(guint8), NULL); + proto_tree_add_item(tree, hf_zbee_zdp_endpoint, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; new_addr = zbee_parse_eui64(tree, hf_zbee_zdp_replacement, tvb, &offset, (int)sizeof(guint64), NULL); - /*new_ep =*/ zbee_parse_uint(tree, hf_zbee_zdp_replacement_ep, tvb, &offset, (int)sizeof(guint8), NULL); + proto_tree_add_item(tree, hf_zbee_zdp_replacement_ep, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; zbee_append_info(tree, pinfo, ", Device: %s", eui64_to_display(wmem_packet_scope(), ext_addr)); zbee_append_info(tree, pinfo, ", Replacement: %s", eui64_to_display(wmem_packet_scope(), new_addr)); @@ -341,31 +341,31 @@ dissect_zbee_zdp_req_store_bak_bind_entry(tvbuff_t *tvb, packet_info *pinfo, pro { proto_item *ti; + guint sizeof_cluster = (version >= ZBEE_VERSION_2007)?(int)sizeof(guint16):(int)sizeof(guint8); guint offset = 0; guint64 src64; - guint8 src_ep; - guint16 cluster; - guint8 dst_mode; + guint32 src_ep, cluster, dst_mode; src64 = zbee_parse_eui64(tree, hf_zbee_zdp_bind_src64, tvb, &offset, (int)sizeof(guint64), NULL); - src_ep = zbee_parse_uint(tree, hf_zbee_zdp_bind_src_ep, tvb, &offset, (int)sizeof(guint8), NULL); - cluster = zbee_parse_uint(tree, hf_zbee_zdp_cluster, tvb, &offset, (version >= ZBEE_VERSION_2007)?(int)sizeof(guint16):(int)sizeof(guint8), &ti); + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_bind_src_ep, tvb, offset, 1, ENC_LITTLE_ENDIAN, &src_ep); + offset += 1; + ti = proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_cluster, tvb, offset, sizeof_cluster, ENC_LITTLE_ENDIAN, &cluster); + offset += sizeof_cluster; proto_item_append_text(ti, " (%s)", val_to_str(cluster, zbee_aps_cid_names, "Unknown Cluster")); - dst_mode = zbee_parse_uint(tree, hf_zbee_zdp_addr_mode, tvb, &offset, (int)sizeof(guint8), &ti); + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_addr_mode, tvb, offset, 1, ENC_LITTLE_ENDIAN, &dst_mode); + offset += 1; if (dst_mode == ZBEE_ZDP_ADDR_MODE_GROUP) { - /*guint16 dst;*/ - if (tree) proto_item_append_text(ti, " (Group)"); - /*dst =*/ zbee_parse_uint(tree, hf_zbee_zdp_bind_dst, tvb, &offset, (int)sizeof(guint16), NULL); + proto_tree_add_item(tree, hf_zbee_zdp_bind_dst, tvb, offset, 2, ENC_LITTLE_ENDIAN); + offset += 2; } else if (dst_mode == ZBEE_ZDP_ADDR_MODE_UNICAST) { /*guint64 dst64;*/ /*guint8 dst_ep;*/ - if (tree) proto_item_append_text(ti, " (Unicast)"); /*dst64 =*/ zbee_parse_eui64(tree, hf_zbee_zdp_bind_dst64, tvb, &offset, (int)sizeof(guint64), NULL); - /*dst_ep =*/ zbee_parse_uint(tree, hf_zbee_zdp_bind_dst_ep, tvb, &offset, (int)sizeof(guint8), NULL); + proto_tree_add_item(tree, hf_zbee_zdp_bind_dst_ep, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; } - else if (tree) proto_item_append_text(ti, " (Reserved)"); zbee_append_info(tree, pinfo, ", Src: %s", eui64_to_display(wmem_packet_scope(), src64)); zbee_append_info(tree, pinfo, ", Src Endpoint: %d", src_ep); @@ -387,31 +387,31 @@ dissect_zbee_zdp_req_remove_bak_bind_entry(tvbuff_t *tvb, packet_info *pinfo, pr { proto_item *ti; + guint sizeof_cluster = (version >= ZBEE_VERSION_2007)?(int)sizeof(guint16):(int)sizeof(guint8); guint offset = 0; guint64 src64; - guint8 src_ep; - guint16 cluster; - guint8 dst_mode; + guint32 src_ep, cluster, dst_mode; src64 = zbee_parse_eui64(tree, hf_zbee_zdp_bind_src64, tvb, &offset, (int)sizeof(guint64), NULL); - src_ep = zbee_parse_uint(tree, hf_zbee_zdp_bind_src_ep, tvb, &offset, (int)sizeof(guint8), NULL); - cluster = zbee_parse_uint(tree, hf_zbee_zdp_cluster, tvb, &offset, (version >= ZBEE_VERSION_2007)?(int)sizeof(guint16):(int)sizeof(guint8), &ti); + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_bind_src_ep, tvb, offset, 1, ENC_LITTLE_ENDIAN, &src_ep); + offset += 1; + ti = proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_cluster, tvb, offset, sizeof_cluster, ENC_LITTLE_ENDIAN, &cluster); + offset += sizeof_cluster; proto_item_append_text(ti, " (%s)", val_to_str(cluster, zbee_zdp_cluster_names, "Unknown Device Profile Cluster")); - dst_mode = zbee_parse_uint(tree, hf_zbee_zdp_addr_mode, tvb, &offset, (int)sizeof(guint8), &ti); + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_addr_mode, tvb, offset, 1, ENC_LITTLE_ENDIAN, &dst_mode); + offset += 1; if (dst_mode == ZBEE_ZDP_ADDR_MODE_GROUP) { - /*guint16 dst;*/ - if (tree) proto_item_append_text(ti, " (Group)"); - /*dst =*/ zbee_parse_uint(tree, hf_zbee_zdp_bind_dst, tvb, &offset, (int)sizeof(guint16), NULL); + proto_tree_add_item(tree, hf_zbee_zdp_bind_dst, tvb, offset, 2, ENC_LITTLE_ENDIAN); + offset += 2; } else if (dst_mode == ZBEE_ZDP_ADDR_MODE_UNICAST) { /*guint64 dst64;*/ /*guint8 dst_ep;*/ - if (tree) proto_item_append_text(ti, " (Unicast)"); /*dst64 =*/ zbee_parse_eui64(tree, hf_zbee_zdp_bind_dst64, tvb, &offset, (int)sizeof(guint64), NULL); - /*dst_ep =*/ zbee_parse_uint(tree, hf_zbee_zdp_bind_dst_ep, tvb, &offset, (int)sizeof(guint8), NULL); + proto_tree_add_item(tree, hf_zbee_zdp_bind_dst_ep, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; } - else if (tree) proto_item_append_text(ti, " (Reserved)"); zbee_append_info(tree, pinfo, ", Src: %s", eui64_to_display(wmem_packet_scope(), src64)); zbee_append_info(tree, pinfo, ", Src Endpoint: %d", src_ep); @@ -432,16 +432,16 @@ void dissect_zbee_zdp_req_backup_bind_table(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint8 version) { proto_tree *field_tree; - guint i; guint offset = 0; - /*guint16 table_size;*/ - /*guint16 idx;*/ - guint16 table_count; + guint32 i, table_count; - /*table_size =*/ zbee_parse_uint(tree, hf_zbee_zdp_table_size, tvb, &offset, (int)sizeof(guint16), NULL); - /*idx =*/ zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, (int)sizeof(guint16), NULL); - table_count = zbee_parse_uint(tree, hf_zbee_zdp_table_count, tvb, &offset, (int)sizeof(guint16), NULL); + proto_tree_add_item(tree, hf_zbee_zdp_table_size, tvb, offset, 2, ENC_LITTLE_ENDIAN); + offset += 2; + proto_tree_add_item(tree, hf_zbee_zdp_index, tvb, offset, 2, ENC_LITTLE_ENDIAN); + offset += 2; + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_table_count, tvb, offset, 2, ENC_LITTLE_ENDIAN, &table_count); + offset += 2; field_tree = proto_tree_add_subtree(tree, tvb, offset, -1, ett_zbee_zdp_bind, NULL, "Binding Table"); @@ -464,9 +464,9 @@ void dissect_zbee_zdp_req_recover_bind_table(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { guint offset = 0; - /*guint16 idx;*/ - /*idx =*/ zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, (int)sizeof(guint16), NULL); + proto_tree_add_item(tree, hf_zbee_zdp_index, tvb, offset, 2, ENC_LITTLE_ENDIAN); + offset += 2; /* Dump any leftover bytes. */ zdp_dump_excess(tvb, offset, pinfo, tree); @@ -483,21 +483,21 @@ void dissect_zbee_zdp_req_backup_source_bind(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { proto_tree *field_tree; - guint i; guint offset = 0; - /*guint16 entries;*/ - /*guint16 idx;*/ - guint16 count; + guint32 i, table_count; - /*entries =*/ zbee_parse_uint(tree, hf_zbee_zdp_table_size, tvb, &offset, (int)sizeof(guint16), NULL); - /*idx =*/ zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, (int)sizeof(guint16), NULL); - count = zbee_parse_uint(tree, hf_zbee_zdp_table_count, tvb, &offset, (int)sizeof(guint16), NULL); + proto_tree_add_item(tree, hf_zbee_zdp_table_size, tvb, offset, 2, ENC_LITTLE_ENDIAN); + offset += 2; + proto_tree_add_item(tree, hf_zbee_zdp_index, tvb, offset, 2, ENC_LITTLE_ENDIAN); + offset += 2; + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_table_count, tvb, offset, 2, ENC_LITTLE_ENDIAN, &table_count); + offset += 2; - field_tree = proto_tree_add_subtree(tree, tvb, offset, count*(int)sizeof(guint64), + field_tree = proto_tree_add_subtree(tree, tvb, offset, table_count*(int)sizeof(guint64), ett_zbee_zdp_bind_source, NULL, "Source Table"); - for (i=0; i<count; i++) zbee_parse_eui64(field_tree, hf_zbee_zdp_bind_src64, tvb, &offset, (int)sizeof(guint64), NULL); + for (i=0; i<table_count; i++) zbee_parse_eui64(field_tree, hf_zbee_zdp_bind_src64, tvb, &offset, (int)sizeof(guint64), NULL); /* Dump any leftover bytes. */ zdp_dump_excess(tvb, offset, pinfo, tree); @@ -514,9 +514,9 @@ void dissect_zbee_zdp_req_recover_source_bind(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { guint offset = 0; - /*guint16 idx;*/ - /*idx =*/ zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, (int)sizeof(guint16), NULL); + proto_tree_add_item(tree, hf_zbee_zdp_index, tvb, offset, 2, ENC_LITTLE_ENDIAN); + offset += 2; /* Dump any leftover bytes. */ zdp_dump_excess(tvb, offset, pinfo, tree); @@ -601,15 +601,16 @@ dissect_zbee_zdp_rsp_bind_register(tvbuff_t *tvb, packet_info *pinfo, proto_tree { proto_tree *field_tree = NULL; guint offset = 0; - guint i; guint8 status; /*guint16 table_size;*/ - guint16 table_count; + guint32 i, table_count; status = zdp_parse_status(tree, tvb, &offset); - /*table_size =*/ zbee_parse_uint(tree, hf_zbee_zdp_table_size, tvb, &offset, (int)sizeof(guint16), NULL); - table_count = zbee_parse_uint(tree, hf_zbee_zdp_table_count, tvb, &offset, (int)sizeof(guint16), NULL); + proto_tree_add_item(tree, hf_zbee_zdp_table_size, tvb, offset, 2, ENC_LITTLE_ENDIAN); + offset += 2; + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_table_count, tvb, offset, 2, ENC_LITTLE_ENDIAN, &table_count); + offset += 2; if (tree && table_count) { field_tree = proto_tree_add_subtree(tree, tvb, offset, -1, ett_zbee_zdp_bind, NULL, "Binding List"); @@ -699,10 +700,10 @@ dissect_zbee_zdp_rsp_backup_bind_table(tvbuff_t *tvb, packet_info *pinfo, proto_ { guint offset = 0; guint8 status; - /*guint16 count;*/ status = zdp_parse_status(tree, tvb, &offset); - /*count =*/ zbee_parse_uint(tree, hf_zbee_zdp_table_size, tvb, &offset, (int)sizeof(guint16), NULL); + proto_tree_add_item(tree, hf_zbee_zdp_table_size, tvb, offset, 2, ENC_LITTLE_ENDIAN); + offset += 2; zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status)); @@ -722,17 +723,17 @@ dissect_zbee_zdp_rsp_recover_bind_table(tvbuff_t *tvb, packet_info *pinfo, proto { proto_tree *field_tree = NULL; guint offset = 0; - guint i; guint8 status; - /*guint16 table_size;*/ - /*guint16 idx;*/ - guint16 table_count; + guint32 i, table_count; status = zdp_parse_status(tree, tvb, &offset); - /*table_size =*/ zbee_parse_uint(tree, hf_zbee_zdp_table_size, tvb, &offset, (int)sizeof(guint16), NULL); - /*idx =*/ zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, (int)sizeof(guint16), NULL); - table_count = zbee_parse_uint(tree, hf_zbee_zdp_table_count, tvb, &offset, (int)sizeof(guint16), NULL); + proto_tree_add_item(tree, hf_zbee_zdp_table_size, tvb, offset, 2, ENC_LITTLE_ENDIAN); + offset += 2; + proto_tree_add_item(tree, hf_zbee_zdp_index, tvb, offset, 2, ENC_LITTLE_ENDIAN); + offset += 2; + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_table_count, tvb, offset, 2, ENC_LITTLE_ENDIAN, &table_count); + offset += 2; if (tree && table_count) { field_tree = proto_tree_add_subtree(tree, tvb, offset, -1, ett_zbee_zdp_bind, NULL, "Binding Table"); @@ -780,17 +781,17 @@ dissect_zbee_zdp_rsp_recover_source_bind(tvbuff_t *tvb, packet_info *pinfo, prot { proto_tree *field_tree = NULL; guint offset = 0; - guint i; guint8 status; - /*guint16 table_size;*/ - /*guint16 idx;*/ - guint16 table_count; + guint32 i, table_count; status = zdp_parse_status(tree, tvb, &offset); - /*table_size = */ zbee_parse_uint(tree, hf_zbee_zdp_table_size, tvb, &offset, (int)sizeof(guint16), NULL); - /*idx = */ zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, (int)sizeof(guint16), NULL); - table_count = zbee_parse_uint(tree, hf_zbee_zdp_table_count, tvb, &offset, (int)sizeof(guint16), NULL); + proto_tree_add_item(tree, hf_zbee_zdp_table_size, tvb, offset, 2, ENC_LITTLE_ENDIAN); + offset += 2; + proto_tree_add_item(tree, hf_zbee_zdp_index, tvb, offset, 2, ENC_LITTLE_ENDIAN); + offset += 2; + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_table_count, tvb, offset, 2, ENC_LITTLE_ENDIAN, &table_count); + offset += 2; if (tree && table_count) { field_tree = proto_tree_add_subtree(tree, tvb, offset, table_count * (int)sizeof(guint64), diff --git a/epan/dissectors/packet-zbee-zdp-discovery.c b/epan/dissectors/packet-zbee-zdp-discovery.c index fa606069e4..0a1dc81844 100644 --- a/epan/dissectors/packet-zbee-zdp-discovery.c +++ b/epan/dissectors/packet-zbee-zdp-discovery.c @@ -48,12 +48,12 @@ dissect_zbee_zdp_req_nwk_addr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre guint offset = 0; guint64 ext_addr; - /*guint8 req_type;*/ - /*guint8 idx;*/ ext_addr = zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, sizeof(guint64), NULL); - /*req_type =*/ zbee_parse_uint(tree, hf_zbee_zdp_req_type, tvb, &offset, sizeof(guint8), NULL); - /*idx =*/ zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, sizeof(guint8), NULL); + proto_tree_add_item(tree, hf_zbee_zdp_req_type, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; + proto_tree_add_item(tree, hf_zbee_zdp_index, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; zbee_append_info(tree, pinfo, ", Address: %s", eui64_to_display(wmem_packet_scope(), ext_addr)); @@ -73,13 +73,14 @@ dissect_zbee_zdp_req_ext_addr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre { guint offset = 0; - guint16 device; - /*guint8 req_type;*/ - /*guint8 idx;*/ + guint32 device; - device = zbee_parse_uint(tree, hf_zbee_zdp_nwk_addr, tvb, &offset, sizeof(guint16), NULL); - /*req_type =*/ zbee_parse_uint(tree, hf_zbee_zdp_req_type, tvb, &offset, sizeof(guint8), NULL); - /*idx =*/ zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, sizeof(guint8), NULL); + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN, &device); + offset += 2; + proto_tree_add_item(tree, hf_zbee_zdp_req_type, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; + proto_tree_add_item(tree, hf_zbee_zdp_index, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; zbee_append_info(tree, pinfo, ", Nwk Addr: 0x%04x", device); @@ -98,9 +99,10 @@ void dissect_zbee_zdp_req_node_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { guint offset = 0; - guint16 device; + guint32 device; - device = zbee_parse_uint(tree, hf_zbee_zdp_nwk_addr, tvb, &offset, sizeof(guint16), NULL); + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN, &device); + offset += 2; zbee_append_info(tree, pinfo, ", Nwk Addr: 0x%04x", device); @@ -119,9 +121,10 @@ void dissect_zbee_zdp_req_power_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { guint offset = 0; - guint16 device; + guint32 device; - device = zbee_parse_uint(tree, hf_zbee_zdp_nwk_addr, tvb, &offset, sizeof(guint16), NULL); + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN, &device); + offset += 2; zbee_append_info(tree, pinfo, ", Nwk Addr: 0x%04x", device); @@ -140,11 +143,12 @@ void dissect_zbee_zdp_req_simple_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { guint offset = 0; - guint16 device; - guint8 endpt; + guint32 device, endpt; - device = zbee_parse_uint(tree, hf_zbee_zdp_nwk_addr, tvb, &offset, sizeof(guint16), NULL); - endpt = zbee_parse_uint(tree, hf_zbee_zdp_endpoint, tvb, &offset, sizeof(guint8), NULL); + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN, &device); + offset += 2; + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_endpoint, tvb, offset, 1, ENC_LITTLE_ENDIAN, &endpt); + offset += 1; zbee_append_info(tree, pinfo, ", Nwk Addr: 0x%04x, Endpoint: %d", device, endpt); @@ -163,9 +167,10 @@ void dissect_zbee_zdp_req_active_ep(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { guint offset = 0; - guint16 device; + guint32 device; - device = zbee_parse_uint(tree, hf_zbee_zdp_nwk_addr, tvb, &offset, sizeof(guint16), NULL); + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN, &device); + offset += 2; zbee_append_info(tree, pinfo, ", Nwk Addr: 0x%04x", device); @@ -188,33 +193,35 @@ dissect_zbee_zdp_req_match_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *t guint offset = 0, i; guint sizeof_cluster = (version >= ZBEE_VERSION_2007)?(int)sizeof(guint16):(int)sizeof(guint8); - guint16 device; - guint16 profile; - guint16 cluster; - guint8 in_count; - guint8 out_count; + guint32 device, profile, cluster, in_count, out_count; - device = zbee_parse_uint(tree, hf_zbee_zdp_nwk_addr, tvb, &offset, (int)sizeof(guint16), NULL); - profile = zbee_parse_uint(tree, hf_zbee_zdp_profile, tvb, &offset, (int)sizeof(guint16), NULL); + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN, &device); + offset += 2; + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_profile, tvb, offset, 2, ENC_LITTLE_ENDIAN, &profile); + offset += 2; /* Add the input cluster list. */ - in_count = zbee_parse_uint(tree, hf_zbee_zdp_in_count, tvb, &offset, (int)sizeof(guint8), NULL); + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_in_count, tvb, offset, 1, ENC_LITTLE_ENDIAN, &in_count); + offset += 1; if (tree && in_count) { field_tree = proto_tree_add_subtree(tree, tvb, offset, in_count*sizeof_cluster, ett_zbee_zdp_match_in, NULL, "Input Cluster List"); } for (i=0; i<in_count; i++) { - cluster = zbee_parse_uint(field_tree, hf_zbee_zdp_in_cluster, tvb, &offset, sizeof_cluster, &ti); + ti = proto_tree_add_item_ret_uint(field_tree, hf_zbee_zdp_in_cluster, tvb, offset, sizeof_cluster, ENC_LITTLE_ENDIAN, &cluster); + offset += sizeof_cluster; proto_item_append_text(ti, " (%s)", val_to_str(cluster, zbee_aps_cid_names, "Unknown Cluster")); } /* Add the output cluster list. */ - out_count = zbee_parse_uint(tree, hf_zbee_zdp_out_count, tvb, &offset, (int)sizeof(guint8), NULL); + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_out_count, tvb, offset, 1, ENC_LITTLE_ENDIAN, &out_count); + offset += 1; if (tree && out_count) { field_tree = proto_tree_add_subtree(tree, tvb, offset, out_count*sizeof_cluster, ett_zbee_zdp_match_out, NULL, "Output Cluster List"); } for (i=0; i<out_count; i++) { - cluster = zbee_parse_uint(field_tree, hf_zbee_zdp_out_cluster, tvb, &offset, sizeof_cluster, &ti); + ti = proto_tree_add_item_ret_uint(field_tree, hf_zbee_zdp_out_cluster, tvb, offset, sizeof_cluster, ENC_LITTLE_ENDIAN, &cluster); + offset += sizeof_cluster; proto_item_append_text(ti, " (%s)", val_to_str(cluster, zbee_aps_cid_names, "Unknown Cluster")); } @@ -235,9 +242,10 @@ void dissect_zbee_zdp_req_complex_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { guint offset = 0; - guint16 device; + guint32 device; - device = zbee_parse_uint(tree, hf_zbee_zdp_nwk_addr, tvb, &offset, (int)sizeof(guint16), NULL); + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN, &device); + offset += 2; zbee_append_info(tree, pinfo, ", Nwk Addr: 0x%04x", device); @@ -256,9 +264,10 @@ void dissect_zbee_zdp_req_user_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { guint offset = 0; - guint16 device; + guint32 device; - device = zbee_parse_uint(tree, hf_zbee_zdp_nwk_addr, tvb, &offset, (int)sizeof(guint16), NULL); + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN, &device); + offset += 2; zbee_append_info(tree, pinfo, ", Nwk Addr: 0x%04x", device); @@ -277,10 +286,10 @@ void dissect_zbee_zdp_req_discovery_cache(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { guint offset = 0; - /*guint16 device;*/ guint64 ext_addr; - /*device =*/ zbee_parse_uint(tree, hf_zbee_zdp_nwk_addr, tvb, &offset, (int)sizeof(guint16), NULL); + proto_tree_add_item(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN); + offset += 2; ext_addr = zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, (int)sizeof(guint64), NULL); zbee_append_info(tree, pinfo, ", Nwk Addr: %s", eui64_to_display(wmem_packet_scope(), ext_addr)); @@ -300,11 +309,11 @@ void dissect_zbee_zdp_device_annce(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { guint offset = 0; - /*guint16 device;*/ guint64 ext_addr; /*guint8 capability;*/ - /*device =*/ zbee_parse_uint(tree, hf_zbee_zdp_nwk_addr, tvb, &offset, (int)sizeof(guint16), NULL); + proto_tree_add_item(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN); + offset += 2; ext_addr = zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, (int)sizeof(guint64), NULL); /*capability =*/ zdp_parse_cinfo(tree, ett_zbee_zdp_cinfo, tvb, &offset); @@ -329,7 +338,9 @@ dissect_zbee_zdp_parent_annce(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre guint i; guint64 ext_addr; - n_children = zbee_parse_uint(tree, hf_zbee_zdp_number_of_children, tvb, &offset, (int)1, NULL); + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_number_of_children, tvb, offset, 1, ENC_LITTLE_ENDIAN, &n_children); + offset += 1; + zbee_append_info(tree, pinfo, ", # children %d :", n_children); for (i = 0 ; i < n_children ; ++i) { @@ -362,7 +373,8 @@ dissect_zbee_zdp_rsp_parent_annce(tvbuff_t *tvb, packet_info *pinfo, proto_tree guint8 status; status = zdp_parse_status(tree, tvb, &offset); - n_children = zbee_parse_uint(tree, hf_zbee_zdp_number_of_children, tvb, &offset, (int)1, NULL); + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_number_of_children, tvb, offset, 1, ENC_LITTLE_ENDIAN, &n_children); + offset += 1; zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status)); zbee_append_info(tree, pinfo, ", # children %d :", n_children); for (i = 0 ; i < n_children ; ++i) @@ -389,24 +401,20 @@ void dissect_zbee_zdp_req_set_user_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint8 version) { guint offset = 0; - guint16 device; - guint8 user_length; - gchar *user; + guint32 device, user_length; + const guint8 *user; - device = zbee_parse_uint(tree, hf_zbee_zdp_nwk_addr, tvb, &offset, (int)sizeof(guint16), NULL); + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN, &device); + offset += 2; if (version >= ZBEE_VERSION_2007) { - user_length = zbee_parse_uint(tree, hf_zbee_zdp_user_length, tvb, &offset, (int)sizeof(guint8), NULL); + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_user_length, tvb, offset, 1, ENC_LITTLE_ENDIAN, &user_length); + offset += 1; } else { /* No Length field in ZigBee 2003 & earlier, uses a fixed length of 16. */ user_length = 16; } - user = (gchar *)wmem_alloc(wmem_packet_scope(), user_length+1); - user = (gchar *)tvb_memcpy(tvb, user, offset, user_length); - user[user_length] = '\0'; - if (tree) { - proto_tree_add_string(tree, hf_zbee_zdp_user, tvb, offset, user_length, user); - } + proto_tree_add_item_ret_string(tree, hf_zbee_zdp_user, tvb, offset, user_length, ENC_ASCII, wmem_packet_scope(), &user); offset += user_length; zbee_append_info(tree, pinfo, ", Nwk Addr: 0x%04x, Desc: \'%s\'", device, user); @@ -448,24 +456,26 @@ dissect_zbee_zdp_req_store_discovery(tvbuff_t *tvb, packet_info *pinfo, proto_tr guint offset = 0; guint i; - /*guint16 device;*/ guint64 ext_addr; - /*guint8 node_size;*/ - /*guint8 power_size;*/ - /*guint8 ep_count;*/ - guint8 simple_count; + guint32 simple_count; - /*device =*/ zbee_parse_uint(tree, hf_zbee_zdp_nwk_addr, tvb, &offset, (int)sizeof(guint16), NULL); + proto_tree_add_item(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN); + offset += 2; ext_addr = zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, (int)sizeof(guint64), NULL); - /*node_size =*/ zbee_parse_uint(tree, hf_zbee_zdp_disc_node_size, tvb, &offset, (int)sizeof(guint8), NULL); - /*power_size =*/ zbee_parse_uint(tree, hf_zbee_zdp_disc_power_size, tvb, &offset, (int)sizeof(guint8), NULL); - /*ep_count =*/ zbee_parse_uint(tree, hf_zbee_zdp_disc_ep_count, tvb, &offset, (int)sizeof(guint8), NULL); - simple_count= zbee_parse_uint(tree, hf_zbee_zdp_disc_simple_count, tvb, &offset, (int)sizeof(guint8), NULL); + proto_tree_add_item(tree, hf_zbee_zdp_disc_node_size, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; + proto_tree_add_item(tree, hf_zbee_zdp_disc_power_size, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; + proto_tree_add_item(tree, hf_zbee_zdp_disc_ep_count, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_disc_simple_count, tvb, offset, 1, ENC_LITTLE_ENDIAN, &simple_count); + offset += 1; field_tree = proto_tree_add_subtree(tree, tvb, offset, simple_count, ett_zbee_zdp_simple_sizes, NULL, "Simple Descriptor Sizes"); for (i=0; i<simple_count; i++) { - zbee_parse_uint(field_tree, hf_zbee_zdp_disc_simple_size, tvb, &offset, (int)sizeof(guint8), NULL); + proto_tree_add_item(field_tree, hf_zbee_zdp_disc_simple_size, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; } zbee_append_info(tree, pinfo, ", Nwk Addr: %s", eui64_to_display(wmem_packet_scope(), ext_addr)); @@ -485,10 +495,10 @@ void dissect_zbee_zdp_req_store_node_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint8 version) { guint offset = 0; - /*guint16 device;*/ guint64 ext_addr; - /*device =*/ zbee_parse_uint(tree, hf_zbee_zdp_nwk_addr, tvb, &offset, (int)sizeof(guint16), NULL); + proto_tree_add_item(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN); + offset += 2; ext_addr = zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, (int)sizeof(guint64), NULL); zdp_parse_node_desc(tree, pinfo, FALSE, ett_zbee_zdp_node, tvb, &offset, version); @@ -509,10 +519,10 @@ void dissect_zbee_zdp_req_store_power_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { guint offset = 0; - /*guint16 device;*/ guint64 ext_addr; - /*device =*/ zbee_parse_uint(tree, hf_zbee_zdp_nwk_addr, tvb, &offset, (int)sizeof(guint16), NULL); + proto_tree_add_item(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN); + offset += 2; ext_addr = zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, (int)sizeof(guint64), NULL); zdp_parse_power_desc(tree, ett_zbee_zdp_power, tvb, &offset); @@ -536,18 +546,20 @@ dissect_zbee_zdp_req_store_active_ep(tvbuff_t *tvb, packet_info *pinfo, proto_tr guint offset = 0; guint i; - /*guint16 device;*/ guint64 ext_addr; - guint8 ep_count; + guint32 ep_count; - /*device =*/ zbee_parse_uint(tree, hf_zbee_zdp_nwk_addr, tvb, &offset, (int)sizeof(guint16), NULL); + proto_tree_add_item(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN); + offset += 2; ext_addr = zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, (int)sizeof(guint64), NULL); - ep_count = zbee_parse_uint(tree, hf_zbee_zdp_ep_count, tvb, &offset, (int)sizeof(guint8), NULL); + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_disc_simple_count, tvb, offset, 1, ENC_LITTLE_ENDIAN, &ep_count); + offset += 1; field_tree = proto_tree_add_subtree(tree, tvb, offset, ep_count, ett_zbee_zdp_endpoint, NULL, "Active Endpoints"); for (i=0; i<ep_count; i++) { - (void)zbee_parse_uint(field_tree, hf_zbee_zdp_endpoint, tvb, &offset, (int)sizeof(guint8), NULL); + proto_tree_add_item(field_tree, hf_zbee_zdp_endpoint, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; } zbee_append_info(tree, pinfo, ", Device: %s", eui64_to_display(wmem_packet_scope(), ext_addr)); @@ -567,13 +579,13 @@ void dissect_zbee_zdp_req_store_simple_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint8 version) { guint offset = 0; - /*guint16 device;*/ guint64 ext_addr; - /*guint8 simple_len;*/ - /*device =*/ zbee_parse_uint(tree, hf_zbee_zdp_nwk_addr, tvb, &offset, (int)sizeof(guint16), NULL); + proto_tree_add_item(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN); + offset += 2; ext_addr = zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, (int)sizeof(guint64), NULL); - /*simple_len =*/ zbee_parse_uint(tree, hf_zbee_zdp_simple_length, tvb, &offset, (int)sizeof(guint8), NULL); + proto_tree_add_item(tree, hf_zbee_zdp_simple_length, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; zdp_parse_simple_desc(tree, ett_zbee_zdp_simple, tvb, &offset, version); zbee_append_info(tree, pinfo, ", Address: %s", eui64_to_display(wmem_packet_scope(), ext_addr)); @@ -593,10 +605,10 @@ void dissect_zbee_zdp_req_remove_node_cache(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { guint offset = 0; - /*guint16 device;*/ guint64 ext_addr; - /*device =*/ zbee_parse_uint(tree, hf_zbee_zdp_nwk_addr, tvb, &offset, (int)sizeof(guint16), NULL); + proto_tree_add_item(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN); + offset += 2; ext_addr = zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, (int)sizeof(guint64), NULL); zbee_append_info(tree, pinfo, ", Device: %s", eui64_to_display(wmem_packet_scope(), ext_addr)); @@ -616,10 +628,10 @@ void dissect_zbee_zdp_req_find_node_cache(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { guint offset = 0; - /*guint16 device;*/ guint64 ext_addr; - /*device =*/ zbee_parse_uint(tree, hf_zbee_zdp_nwk_addr, tvb, &offset, (int)sizeof(guint16), NULL); + proto_tree_add_item(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN); + offset += 2; ext_addr = zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, (int)sizeof(guint64), NULL); zbee_append_info(tree, pinfo, ", Address: %s", eui64_to_display(wmem_packet_scope(), ext_addr)); @@ -639,13 +651,14 @@ void dissect_zbee_zdp_req_ext_simple_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { guint offset = 0; - guint16 device; - guint8 endpt; - /*guint8 idx;*/ + guint32 device, endpt; - device = zbee_parse_uint(tree, hf_zbee_zdp_nwk_addr, tvb, &offset, (int)sizeof(guint16), NULL); - endpt = zbee_parse_uint(tree, hf_zbee_zdp_endpoint, tvb, &offset, (int)sizeof(guint8), NULL); - /*idx =*/ zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, (int)sizeof(guint8), NULL); + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN, &device); + offset += 2; + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_endpoint, tvb, offset, 1, ENC_LITTLE_ENDIAN, &endpt); + offset += 1; + proto_tree_add_item(tree, hf_zbee_zdp_index, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; zbee_append_info(tree, pinfo, ", Nwk Addr: 0x%04x, Endpoint: %d", device, endpt); @@ -664,11 +677,13 @@ void dissect_zbee_zdp_req_ext_active_ep(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { guint offset = 0; - guint16 device; + guint32 device; /*guint8 idx;*/ - device = zbee_parse_uint(tree, hf_zbee_zdp_nwk_addr, tvb, &offset, (int)sizeof(guint16), NULL); - /*idx =*/ zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, (int)sizeof(guint8), NULL); + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN, &device); + offset += 2; + proto_tree_add_item(tree, hf_zbee_zdp_index, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; zbee_append_info(tree, pinfo, ", Nwk Addr: 0x%04x", device); @@ -696,25 +711,27 @@ dissect_zbee_zdp_rsp_nwk_addr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre guint8 status; guint64 ext_addr; - guint16 device; - guint8 assoc; - /*guint8 idx;*/ + guint32 device, assoc; status = zdp_parse_status(tree, tvb, &offset); ext_addr = zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, (int)sizeof(guint64), NULL); - device = zbee_parse_uint(tree, hf_zbee_zdp_nwk_addr, tvb, &offset, (int)sizeof(guint16), NULL); + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN, &device); + offset += 2; if (tvb_bytes_exist(tvb, offset, 2*(int)sizeof(guint8))) { /* The presence of these fields depends on the request message. Include them if they exist. */ - assoc = zbee_parse_uint(tree, hf_zbee_zdp_assoc_device_count, tvb, &offset, (int)sizeof(guint8), NULL); - /*idx =*/ zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, (int)sizeof(guint8), NULL); + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_assoc_device_count, tvb, offset, 1, ENC_LITTLE_ENDIAN, &assoc); + offset += 1; + proto_tree_add_item(tree, hf_zbee_zdp_index, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; if ((tree) && (assoc)) { field_tree = proto_tree_add_subtree(tree, tvb, offset, assoc*(int)sizeof(guint16), ett_zbee_zdp_assoc_device, NULL, "Associated Device List"); } for (i=0; i<assoc; i++) { - (void)zbee_parse_uint(field_tree, hf_zbee_zdp_assoc_device, tvb, &offset, (int)sizeof(guint16), NULL); + proto_tree_add_item(field_tree, hf_zbee_zdp_assoc_device, tvb, offset, 2, ENC_LITTLE_ENDIAN); + offset += 2; } } @@ -743,25 +760,27 @@ dissect_zbee_zdp_rsp_ext_addr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre guint8 status; guint64 ext_addr; - guint16 device; - guint8 assoc; - /*guint8 idx;*/ + guint32 device, assoc; status = zdp_parse_status(tree, tvb, &offset); ext_addr = zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, (int)sizeof(guint64), NULL); - device = zbee_parse_uint(tree, hf_zbee_zdp_nwk_addr, tvb, &offset, (int)sizeof(guint16), NULL); + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN, &device); + offset += 2; if (tvb_bytes_exist(tvb, offset, 2*(int)sizeof(guint8))) { /* The presence of these fields depends on the request message. Include them if they exist. */ - assoc = zbee_parse_uint(tree, hf_zbee_zdp_assoc_device_count, tvb, &offset, (int)sizeof(guint8), NULL); - /*idx =*/ zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, (int)sizeof(guint8), NULL); + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_assoc_device_count, tvb, offset, 1, ENC_LITTLE_ENDIAN, &assoc); + offset += 1; + proto_tree_add_item(tree, hf_zbee_zdp_index, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; if ((tree) && (assoc)) { field_tree = proto_tree_add_subtree(tree, tvb, offset, assoc*(int)sizeof(guint16), ett_zbee_zdp_assoc_device, NULL, "Associated Device List"); } for (i=0; i<assoc; i++) { - (void)zbee_parse_uint(field_tree, hf_zbee_zdp_assoc_device, tvb, &offset, (int)sizeof(guint16), NULL); + proto_tree_add_item(field_tree, hf_zbee_zdp_assoc_device, tvb, offset, 2, ENC_LITTLE_ENDIAN); + offset += 2; } } @@ -787,10 +806,11 @@ dissect_zbee_zdp_rsp_node_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tr guint offset = 0; guint8 status; - guint16 device; + guint32 device; status = zdp_parse_status(tree, tvb, &offset); - device = zbee_parse_uint(tree, hf_zbee_zdp_nwk_addr, tvb, &offset, (int)sizeof(guint16), NULL); + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN, &device); + offset += 2; if (status == ZBEE_ZDP_STATUS_SUCCESS) { zdp_parse_node_desc(tree, pinfo, TRUE, ett_zbee_zdp_node, tvb, &offset, version); } @@ -815,10 +835,11 @@ dissect_zbee_zdp_rsp_power_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *t guint offset = 0; guint8 status; - guint16 device; + guint32 device; status = zdp_parse_status(tree, tvb, &offset); - device = zbee_parse_uint(tree, hf_zbee_zdp_nwk_addr, tvb, &offset, (int)sizeof(guint16), NULL); + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN, &device); + offset += 2; if (status == ZBEE_ZDP_STATUS_SUCCESS) { zdp_parse_power_desc(tree, ett_zbee_zdp_power, tvb, &offset); } @@ -844,11 +865,13 @@ dissect_zbee_zdp_rsp_simple_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree * guint8 status; /*guint8 length;*/ - guint16 device; + guint32 device; status = zdp_parse_status(tree, tvb, &offset); - device = zbee_parse_uint(tree, hf_zbee_zdp_nwk_addr, tvb, &offset, (int)sizeof(guint16), NULL); - /*length =*/ zbee_parse_uint(tree, hf_zbee_zdp_simple_length, tvb, &offset, (int)sizeof(guint8), NULL); + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN, &device); + offset += 2; + proto_tree_add_item(tree, hf_zbee_zdp_simple_length, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; if (status == ZBEE_ZDP_STATUS_SUCCESS) { zdp_parse_simple_desc(tree, ett_zbee_zdp_simple, tvb, &offset, version); } @@ -875,19 +898,22 @@ dissect_zbee_zdp_rsp_active_ep(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tr guint i; guint8 status; - guint16 device; - guint8 ep_count; + guint32 device, ep_count; status = zdp_parse_status(tree, tvb, &offset); - device = zbee_parse_uint(tree, hf_zbee_zdp_nwk_addr, tvb, &offset, (int)sizeof(guint16), NULL); - ep_count = zbee_parse_uint(tree, hf_zbee_zdp_ep_count, tvb, &offset, (int)sizeof(guint8), NULL); + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN, &device); + offset += 2; + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_ep_count, tvb, offset, 1, ENC_LITTLE_ENDIAN, &ep_count); + offset += 1; + if (tree && ep_count) { field_tree = proto_tree_add_subtree(tree, tvb, offset, ep_count*(int)sizeof(guint8), ett_zbee_zdp_endpoint, NULL, "Active Endpoint List"); } for (i=0; i<ep_count; i++) { - (void)zbee_parse_uint(field_tree, hf_zbee_zdp_endpoint, tvb, &offset, (int)sizeof(guint8), NULL); + proto_tree_add_item(field_tree, hf_zbee_zdp_endpoint, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; } zbee_append_info(tree, pinfo, ", Nwk Addr: 0x%04x", device); @@ -912,19 +938,21 @@ dissect_zbee_zdp_rsp_match_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *t guint i; guint8 status; - guint16 device; - guint8 ep_count; + guint32 device, ep_count; status = zdp_parse_status(tree, tvb, &offset); - device = zbee_parse_uint(tree, hf_zbee_zdp_nwk_addr, tvb, &offset, (int)sizeof(guint16), NULL); - ep_count = zbee_parse_uint(tree, hf_zbee_zdp_ep_count, tvb, &offset, (int)sizeof(guint8), NULL); + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN, &device); + offset += 2; + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_ep_count, tvb, offset, 1, ENC_LITTLE_ENDIAN, &ep_count); + offset += 1; if (tree && ep_count) { field_tree = proto_tree_add_subtree(tree, tvb, offset, ep_count*(int)sizeof(guint8), ett_zbee_zdp_endpoint, NULL, "Matching Endpoint List"); } for (i=0; i<ep_count; i++) { - (void)zbee_parse_uint(field_tree, hf_zbee_zdp_endpoint, tvb, &offset, (int)sizeof(guint8), NULL); + proto_tree_add_item(field_tree, hf_zbee_zdp_endpoint, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; } zbee_append_info(tree, pinfo, ", Nwk Addr: 0x%04x", device); @@ -947,12 +975,14 @@ dissect_zbee_zdp_rsp_complex_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree guint offset = 0; guint8 status; - guint8 length; - guint16 device; + guint32 device, length; status = zdp_parse_status(tree, tvb, &offset); - device = zbee_parse_uint(tree, hf_zbee_zdp_nwk_addr, tvb, &offset, (int)sizeof(guint16), NULL); - length = zbee_parse_uint(tree, hf_zbee_zdp_complex_length, tvb, &offset, (int)sizeof(guint8), NULL); + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN, &device); + offset += 2; + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_complex_length, tvb, offset, 1, ENC_LITTLE_ENDIAN, &length); + offset += 1; + if (length) { zdp_parse_complex_desc(tree, -1, tvb, &offset, length); } @@ -976,15 +1006,16 @@ dissect_zbee_zdp_rsp_user_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tr { guint offset = 0; guint8 status; - guint16 device; - guint8 user_length; + guint32 device, user_length; gchar *user; status = zdp_parse_status(tree, tvb, &offset); - device = zbee_parse_uint(tree, hf_zbee_zdp_nwk_addr, tvb, &offset, (int)sizeof(guint16), NULL); + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN, &device); + offset += 2; if ((version >= ZBEE_VERSION_2007) || (status == ZBEE_ZDP_STATUS_SUCCESS)) { /* In ZigBee 2003 & earlier, the length field is omitted if not successful. */ - user_length = zbee_parse_uint(tree, hf_zbee_zdp_user_length, tvb, &offset, (int)sizeof(guint8), NULL); + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_user_length, tvb, offset, 1, ENC_LITTLE_ENDIAN, &user_length); + offset += 1; } else user_length = 0; @@ -1016,12 +1047,13 @@ dissect_zbee_zdp_rsp_user_desc_conf(tvbuff_t *tvb, packet_info *pinfo, proto_tre { guint offset = 0; guint8 status; - guint16 device = 0; + guint32 device = 0; status = zdp_parse_status(tree, tvb, &offset); if (version >= ZBEE_VERSION_2007) { /* Device address present only on ZigBee 2006 & later. */ - device = zbee_parse_uint(tree, hf_zbee_zdp_nwk_addr, tvb, &offset, (int)sizeof(guint16), NULL); + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN, &device); + offset += 2; } zbee_append_info(tree, pinfo, ", Nwk Addr: 0x%04x", device); @@ -1221,12 +1253,12 @@ dissect_zbee_zdp_rsp_find_node_cache(tvbuff_t *tvb, packet_info *pinfo, proto_tr { guint offset = 0; - guint16 cache; - guint16 device; - /*guint64 ext_addr;*/ + guint32 device, cache; - cache = zbee_parse_uint(tree, hf_zbee_zdp_cache, tvb, &offset, (int)sizeof(guint16), NULL); - device = zbee_parse_uint(tree, hf_zbee_zdp_nwk_addr, tvb, &offset, (int)sizeof(guint16), NULL); + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_cache, tvb, offset, 2, ENC_LITTLE_ENDIAN, &cache); + offset += 2; + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN, &device); + offset += 2; /*ext_addr =*/ zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, (int)sizeof(guint64), NULL); zbee_append_info(tree, pinfo, ", Cache: 0x%04x", cache); @@ -1252,27 +1284,29 @@ dissect_zbee_zdp_rsp_ext_simple_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tr guint sizeof_cluster = (int)sizeof(guint16); guint8 status; - guint16 device; - guint16 cluster; - /*guint8 endpt;*/ - guint8 in_count; - guint8 out_count; - guint8 idx; + guint32 device, cluster, in_count, out_count, idx; status = zdp_parse_status(tree, tvb, &offset); - device = zbee_parse_uint(tree, hf_zbee_zdp_nwk_addr, tvb, &offset, (int)sizeof(guint16), NULL); - /*endpt =*/ zbee_parse_uint(tree, hf_zbee_zdp_endpoint, tvb, &offset, (int)sizeof(guint8), NULL); - in_count = zbee_parse_uint(tree, hf_zbee_zdp_in_count, tvb, &offset, (int)sizeof(guint8), NULL); - out_count = zbee_parse_uint(tree, hf_zbee_zdp_out_count, tvb, &offset, (int)sizeof(guint8), NULL); - idx = zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, (int)sizeof(guint8), NULL); + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN, &device); + offset += 2; + proto_tree_add_item(tree, hf_zbee_zdp_endpoint, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_in_count, tvb, offset, 1, ENC_LITTLE_ENDIAN, &in_count); + offset += 1; + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_out_count, tvb, offset, 1, ENC_LITTLE_ENDIAN, &out_count); + offset += 1; + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_index, tvb, offset, 1, ENC_LITTLE_ENDIAN, &idx); + offset += 1; /* Display the input cluster list. */ for (i=idx; (i<in_count) && tvb_bytes_exist(tvb, offset, sizeof_cluster); i++) { - cluster = zbee_parse_uint(tree, hf_zbee_zdp_in_cluster, tvb, &offset, sizeof_cluster, &ti); + ti = proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_in_cluster, tvb, offset, sizeof_cluster, ENC_LITTLE_ENDIAN, &cluster); + offset += sizeof_cluster; proto_item_append_text(ti, " (%s)", val_to_str(cluster, zbee_aps_cid_names, "Unknown Cluster")); } /* for */ for (i-=in_count; (i<out_count) && tvb_bytes_exist(tvb, offset, sizeof_cluster); i++) { - cluster = zbee_parse_uint(tree, hf_zbee_zdp_out_cluster, tvb, &offset, sizeof_cluster, &ti); + ti = proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_out_cluster, tvb, offset, sizeof_cluster, ENC_LITTLE_ENDIAN, &cluster); + offset += sizeof_cluster; proto_item_append_text(ti, " (%s)", val_to_str(cluster, zbee_aps_cid_names, "Unknown Cluster")); } /* for */ @@ -1298,20 +1332,22 @@ dissect_zbee_zdp_rsp_ext_active_ep(tvbuff_t *tvb, packet_info *pinfo, proto_tree guint i; guint8 status; - guint16 device; - guint8 ep_count; - guint8 idx; + guint32 device, ep_count, idx; status = zdp_parse_status(tree, tvb, &offset); - device = zbee_parse_uint(tree, hf_zbee_zdp_nwk_addr, tvb, &offset, (int)sizeof(guint16), NULL); - ep_count = zbee_parse_uint(tree, hf_zbee_zdp_ep_count, tvb, &offset, (int)sizeof(guint8), NULL); - idx = zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, (int)sizeof(guint8), NULL); + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN, &device); + offset += 2; + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_ep_count, tvb, offset, 1, ENC_LITTLE_ENDIAN, &ep_count); + offset += 1; + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_index, tvb, offset, 1, ENC_LITTLE_ENDIAN, &idx); + offset += 1; if (tree && ep_count) { field_tree = proto_tree_add_subtree(tree, tvb, offset, ep_count*(int)sizeof(guint8), ett_zbee_zdp_endpoint, NULL, "Active Endpoint List"); for (i=idx; (i<ep_count) && tvb_bytes_exist(tvb, offset, (int)sizeof(guint8)); i++) { - (void)zbee_parse_uint(field_tree, hf_zbee_zdp_endpoint, tvb, &offset, (int)sizeof(guint8), NULL); + proto_tree_add_item(field_tree, hf_zbee_zdp_endpoint, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; } } diff --git a/epan/dissectors/packet-zbee-zdp-management.c b/epan/dissectors/packet-zbee-zdp-management.c index 00b68bed82..8e4331c411 100644 --- a/epan/dissectors/packet-zbee-zdp-management.c +++ b/epan/dissectors/packet-zbee-zdp-management.c @@ -204,8 +204,6 @@ dissect_zbee_zdp_req_mgmt_nwk_disc(tvbuff_t *tvb, packet_info *pinfo, proto_tree guint offset = 0; guint32 channels; - /*guint8 duration;*/ - /*guint8 idx;*/ /* Get the channel bitmap. */ channels = tvb_get_letohl(tvb, offset); @@ -228,8 +226,10 @@ dissect_zbee_zdp_req_mgmt_nwk_disc(tvbuff_t *tvb, packet_info *pinfo, proto_tree } offset += 4; - /*duration =*/ zbee_parse_uint(tree, hf_zbee_zdp_duration, tvb, &offset, 1, NULL); - /*idx =*/ zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, 1, NULL); + proto_tree_add_item(tree, hf_zbee_zdp_duration, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; + proto_tree_add_item(tree, hf_zbee_zdp_index, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; /* Dump any leftover bytes. */ zdp_dump_excess(tvb, offset, pinfo, tree); @@ -246,9 +246,9 @@ void dissect_zbee_zdp_req_mgmt_lqi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { guint offset = 0; - /*guint8 idx;*/ - /*idx =*/ zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, 1, NULL); + proto_tree_add_item(tree, hf_zbee_zdp_index, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; /* Dump any leftover bytes. */ zdp_dump_excess(tvb, offset, pinfo, tree); @@ -265,9 +265,9 @@ void dissect_zbee_zdp_req_mgmt_rtg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { guint offset = 0; - /*guint8 idx;*/ - /*idx =*/ zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, 1, NULL); + proto_tree_add_item(tree, hf_zbee_zdp_index, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; /* Dump any leftover bytes. */ zdp_dump_excess(tvb, offset, pinfo, tree); @@ -284,9 +284,9 @@ void dissect_zbee_zdp_req_mgmt_bind(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { guint offset = 0; - /*guint8 idx;*/ - /*idx =*/ zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, 1, NULL); + proto_tree_add_item(tree, hf_zbee_zdp_index, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; /* Dump any leftover bytes. */ zdp_dump_excess(tvb, offset, pinfo, tree); @@ -357,11 +357,11 @@ void dissect_zbee_zdp_req_mgmt_permit_join(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { guint offset = 0; - /*guint8 duration;*/ - /*guint8 significance;*/ - /*duration =*/ zbee_parse_uint(tree, hf_zbee_zdp_duration, tvb, &offset, 1, NULL); - /*significance =*/ zbee_parse_uint(tree, hf_zbee_zdp_significance, tvb, &offset, 1, NULL); + proto_tree_add_item(tree, hf_zbee_zdp_duration, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; + proto_tree_add_item(tree, hf_zbee_zdp_significance, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; /* Dump any leftover bytes. */ zdp_dump_excess(tvb, offset, pinfo, tree); @@ -378,9 +378,9 @@ void dissect_zbee_zdp_req_mgmt_cache(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { guint offset = 0; - /*guint8 idx;*/ - /*idx =*/ zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, 1, NULL); + proto_tree_add_item(tree, hf_zbee_zdp_index, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; /* Dump any leftover bytes. */ zdp_dump_excess(tvb, offset, pinfo, tree); @@ -397,19 +397,25 @@ void dissect_zbee_zdp_req_mgmt_nwkupdate(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { guint offset = 0; - guint8 duration; + guint32 duration; zdp_parse_chanmask(tree, tvb, &offset, hf_zbee_zdp_channel_page, hf_zbee_zdp_channel_mask); - duration = zbee_parse_uint(tree, hf_zbee_zdp_duration, tvb, &offset, 1, NULL); + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_duration, tvb, offset, 1, ENC_LITTLE_ENDIAN, &duration); + offset += 1; + if (duration == ZBEE_ZDP_NWKUPDATE_PARAMETERS) { - zbee_parse_uint(tree, hf_zbee_zdp_update_id, tvb, &offset, 1, NULL); - zbee_parse_uint(tree, hf_zbee_zdp_manager, tvb, &offset, 2, NULL); + proto_tree_add_item(tree, hf_zbee_zdp_update_id, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; + proto_tree_add_item(tree, hf_zbee_zdp_manager, tvb, offset, 2, ENC_LITTLE_ENDIAN); + offset += 2; } else if (duration == ZBEE_ZDP_NWKUPDATE_CHANNEL_HOP) { - zbee_parse_uint(tree, hf_zbee_zdp_update_id, tvb, &offset, 1, NULL); + proto_tree_add_item(tree, hf_zbee_zdp_update_id, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; } else if (duration <= ZBEE_ZDP_NWKUPDATE_SCAN_MAX) { - zbee_parse_uint(tree, hf_zbee_zdp_scan_count, tvb, &offset, 1, NULL); + proto_tree_add_item(tree, hf_zbee_zdp_scan_count, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; } /* Dump any leftover bytes. */ @@ -427,25 +433,31 @@ void dissect_zbee_zdp_req_mgmt_nwkupdate_enh(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { guint offset = 0; - guint8 duration; - guint8 count; - int i; + guint32 i, duration, count; + + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_channel_page_count, tvb, offset, 1, ENC_LITTLE_ENDIAN, &count); + offset += 1; - count = zbee_parse_uint(tree, hf_zbee_zdp_channel_page_count, tvb, &offset, 1, NULL); for (i=0; i<count; i++) { zdp_parse_chanmask(tree, tvb, &offset, hf_zbee_zdp_channel_page, hf_zbee_zdp_channel_mask); } - duration = zbee_parse_uint(tree, hf_zbee_zdp_duration, tvb, &offset, 1, NULL); + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_duration, tvb, offset, 1, ENC_LITTLE_ENDIAN, &duration); + offset += 1; + if (duration == ZBEE_ZDP_NWKUPDATE_PARAMETERS) { - zbee_parse_uint(tree, hf_zbee_zdp_update_id, tvb, &offset, 1, NULL); - zbee_parse_uint(tree, hf_zbee_zdp_manager, tvb, &offset, 2, NULL); + proto_tree_add_item(tree, hf_zbee_zdp_update_id, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; + proto_tree_add_item(tree, hf_zbee_zdp_manager, tvb, offset, 2, ENC_LITTLE_ENDIAN); + offset += 2; } else if (duration == ZBEE_ZDP_NWKUPDATE_CHANNEL_HOP) { - zbee_parse_uint(tree, hf_zbee_zdp_update_id, tvb, &offset, 1, NULL); + proto_tree_add_item(tree, hf_zbee_zdp_update_id, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; } else if (duration <= ZBEE_ZDP_NWKUPDATE_SCAN_MAX) { - zbee_parse_uint(tree, hf_zbee_zdp_scan_count, tvb, &offset, 1, NULL); + proto_tree_add_item(tree, hf_zbee_zdp_scan_count, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; } /* Dump any leftover bytes. */ @@ -464,7 +476,8 @@ dissect_zbee_zdp_req_mgmt_ieee_join_list(tvbuff_t *tvb, packet_info *pinfo, prot { guint offset = 0; - zbee_parse_uint(tree, hf_zbee_zdp_ieee_join_start_index, tvb, &offset, 1, NULL); + proto_tree_add_item(tree, hf_zbee_zdp_ieee_join_start_index, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; /* Dump any leftover bytes. */ zdp_dump_excess(tvb, offset, pinfo, tree); @@ -486,17 +499,17 @@ dissect_zbee_zdp_rsp_mgmt_nwk_disc(tvbuff_t *tvb, packet_info *pinfo, proto_tree { proto_tree *field_tree = NULL; guint offset = 0; - guint i; guint8 status; - /*guint8 table_size;*/ - /*guint8 idx;*/ - guint8 table_count; + guint32 i, table_count; status = zdp_parse_status(tree, tvb, &offset); - /*table_size =*/ zbee_parse_uint(tree, hf_zbee_zdp_table_size, tvb, &offset, 1, NULL); - /*idx =*/ zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, 1, NULL); - table_count = zbee_parse_uint(tree, hf_zbee_zdp_table_count, tvb, &offset, 1, NULL); + proto_tree_add_item(tree, hf_zbee_zdp_table_size, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; + proto_tree_add_item(tree, hf_zbee_zdp_index, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_table_count, tvb, offset, 1, ENC_LITTLE_ENDIAN, &table_count); + offset += 1; if (tree && table_count) { field_tree = proto_tree_add_subtree(tree, tvb, offset, -1, ett_zbee_zdp_nwk, NULL, "Network List"); @@ -523,17 +536,17 @@ dissect_zbee_zdp_rsp_mgmt_lqi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre { proto_tree *field_tree = NULL; guint offset = 0; - guint i; guint8 status; - /*guint8 table_size;*/ - /*guint8 idx;*/ - guint8 table_count; + guint32 i, table_count; status = zdp_parse_status(tree, tvb, &offset); - /*table_size =*/ zbee_parse_uint(tree, hf_zbee_zdp_table_size, tvb, &offset, 1, NULL); - /*idx =*/ zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, 1, NULL); - table_count = zbee_parse_uint(tree, hf_zbee_zdp_table_count, tvb, &offset, 1, NULL); + proto_tree_add_item(tree, hf_zbee_zdp_table_size, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; + proto_tree_add_item(tree, hf_zbee_zdp_index, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_table_count, tvb, offset, 1, ENC_LITTLE_ENDIAN, &table_count); + offset += 1; if (table_count) { field_tree = proto_tree_add_subtree(tree, tvb, offset, -1, ett_zbee_zdp_lqi, NULL, "Neighbor Table"); @@ -561,17 +574,17 @@ dissect_zbee_zdp_rsp_mgmt_rtg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre proto_item *ti; proto_tree *field_tree = NULL; guint offset = 0; - guint i; guint8 status; - /*guint8 table_size;*/ - /*guint8 idx;*/ - guint8 table_count; + guint32 i, table_count; status = zdp_parse_status(tree, tvb, &offset); - /*table_size =*/ zbee_parse_uint(tree, hf_zbee_zdp_table_size, tvb, &offset, 1, NULL); - /*idx =*/ zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, 1, NULL); - table_count = zbee_parse_uint(tree, hf_zbee_zdp_table_count, tvb, &offset, 1, NULL); + proto_tree_add_item(tree, hf_zbee_zdp_table_size, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; + proto_tree_add_item(tree, hf_zbee_zdp_index, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_table_count, tvb, offset, 1, ENC_LITTLE_ENDIAN, &table_count); + offset += 1; if (tree && table_count) { ti = proto_tree_add_item(tree, hf_zbee_zdp_rtg, tvb, offset, -1, ENC_NA); @@ -599,17 +612,18 @@ dissect_zbee_zdp_rsp_mgmt_bind(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tr { proto_tree *field_tree = NULL; guint offset = 0; - guint i; guint8 status; - /*guint8 table_size;*/ - /*guint8 idx;*/ - guint8 table_count; + guint32 i, table_count; status = zdp_parse_status(tree, tvb, &offset); - /*table_size =*/ zbee_parse_uint(tree, hf_zbee_zdp_table_size, tvb, &offset, 1, NULL); - /*idx =*/ zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, 1, NULL); - table_count = zbee_parse_uint(tree, hf_zbee_zdp_table_count, tvb, &offset, 1, NULL); + proto_tree_add_item(tree, hf_zbee_zdp_table_size, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; + proto_tree_add_item(tree, hf_zbee_zdp_index, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_table_count, tvb, offset, 1, ENC_LITTLE_ENDIAN, &table_count); + offset += 1; + if (tree && table_count) { field_tree = proto_tree_add_subtree(tree, tvb, offset, -1, ett_zbee_zdp_bind, NULL, "Binding Table"); @@ -700,17 +714,17 @@ dissect_zbee_zdp_rsp_mgmt_cache(tvbuff_t *tvb, packet_info *pinfo, proto_tree *t proto_tree *field_tree = NULL; proto_tree *ti; guint offset = 0; - guint i; guint8 status; - /*guint8 table_size;*/ - /*guint8 idx;*/ - guint8 table_count; + guint32 i, table_count; status = zdp_parse_status(tree, tvb, &offset); - /*table_size =*/ zbee_parse_uint(tree, hf_zbee_zdp_table_size, tvb, &offset, 1, NULL); - /*idx =*/ zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, 1, NULL); - table_count = zbee_parse_uint(tree, hf_zbee_zdp_table_count, tvb, &offset, 1, NULL); + proto_tree_add_item(tree, hf_zbee_zdp_table_size, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; + proto_tree_add_item(tree, hf_zbee_zdp_index, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_table_count, tvb, offset, 1, ENC_LITTLE_ENDIAN, &table_count); + offset += 1; if (table_count) { field_tree = proto_tree_add_subtree(tree, tvb, offset, table_count*(2+8), @@ -747,16 +761,16 @@ dissect_zbee_zdp_rsp_mgmt_nwkupdate(tvbuff_t *tvb, packet_info *pinfo, proto_tre guint i, j; /*guint8 status;*/ - guint32 channels; - /*guint16 tx_total;*/ - /*guint16 tx_fail;*/ - guint8 channel_count; + guint32 channels, channel_count; /*status =*/ zdp_parse_status(tree, tvb, &offset); channels = zdp_parse_chanmask(tree, tvb, &offset, hf_zbee_zdp_channel_page, hf_zbee_zdp_channel_mask); - /*tx_total =*/ zbee_parse_uint(tree, hf_zbee_zdp_tx_total, tvb, &offset, 2, NULL); - /*tx_fail =*/ zbee_parse_uint(tree, hf_zbee_zdp_tx_fail, tvb, &offset, 2, NULL); - channel_count = zbee_parse_uint(tree, hf_zbee_zdp_channel_count, tvb, &offset, 1, NULL); + proto_tree_add_item(tree, hf_zbee_zdp_tx_total, tvb, offset, 2, ENC_LITTLE_ENDIAN); + offset += 2; + proto_tree_add_item(tree, hf_zbee_zdp_tx_fail, tvb, offset, 2, ENC_LITTLE_ENDIAN); + offset += 2; + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_channel_count, tvb, offset, 1, ENC_LITTLE_ENDIAN, &channel_count); + offset += 1; /* Display the channel list. */ for (i=0, j=0; i<(8*4); i++) { @@ -792,20 +806,24 @@ dissect_zbee_zdp_rsp_mgmt_nwkupdate(tvbuff_t *tvb, packet_info *pinfo, proto_tre void dissect_zbee_zdp_rsp_mgmt_ieee_join_list(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { - guint8 status; - guint8 list_total; - guint8 list_count; + guint32 i, status, list_total, list_count; guint offset = 0; - int i; - status = zbee_parse_uint(tree, hf_zbee_zdp_ieee_join_status, tvb, &offset, 1, NULL); + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_ieee_join_status, tvb, offset, 1, ENC_LITTLE_ENDIAN, &status); + offset += 1; if (status == 0x00) { - zbee_parse_uint(tree, hf_zbee_zdp_ieee_join_update_id, tvb, &offset, 1, NULL); - zbee_parse_uint(tree, hf_zbee_zdp_ieee_join_policy, tvb, &offset, 1, NULL); - list_total = zbee_parse_uint(tree, hf_zbee_zdp_ieee_join_list_total, tvb, &offset, 1, NULL); + proto_tree_add_item(tree, hf_zbee_zdp_ieee_join_update_id, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; + proto_tree_add_item(tree, hf_zbee_zdp_ieee_join_policy, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_ieee_join_list_total, tvb, offset, 1, ENC_LITTLE_ENDIAN, &list_total); + offset += 1; + if (list_total > 0) { - zbee_parse_uint(tree, hf_zbee_zdp_ieee_join_list_start, tvb, &offset, 1, NULL); - list_count = zbee_parse_uint(tree, hf_zbee_zdp_ieee_join_list_count, tvb, &offset, 1, NULL); + proto_tree_add_item(tree, hf_zbee_zdp_ieee_join_list_start, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; + proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_ieee_join_list_count, tvb, offset, 1, ENC_LITTLE_ENDIAN, &list_count); + offset += 1; for(i=0; i<list_count; i++) { zbee_parse_eui64(tree, hf_zbee_zdp_ieee_join_list_ieee, tvb, &offset, 8, NULL); diff --git a/epan/dissectors/packet-zbee-zdp.c b/epan/dissectors/packet-zbee-zdp.c index 915b18a346..22455b7f59 100644 --- a/epan/dissectors/packet-zbee-zdp.c +++ b/epan/dissectors/packet-zbee-zdp.c @@ -398,6 +398,15 @@ const value_string zbee_zdp_relationship_vals[] = { { 0, NULL } }; +static const range_string zbee_zcl_zdp_address_modes[] = { + { 0x0, 0x0, "Reserved" }, + { ZBEE_ZDP_ADDR_MODE_GROUP, ZBEE_ZDP_ADDR_MODE_GROUP, "Group" }, + { 0x02, 0x02, "Reserved" }, + { ZBEE_ZDP_ADDR_MODE_UNICAST, ZBEE_ZDP_ADDR_MODE_UNICAST, "Unicast" }, + { 0x03, 0xFF, "Reserved" }, + { 0, 0, NULL } +}; + /* if (tree) { if (type == 0x00) proto_item_append_text(ti, ", Type: Coordinator"); @@ -490,55 +499,6 @@ zbee_append_info(proto_item *item, packet_info *pinfo, const gchar *format, ...) } /* zbee_add_info */ /** - *ZigBee helper function. extracts an integer and displays it to the tree. - * - *@param tree pointer to data tree Wireshark uses to display packet. - *@param hfindex index to field information. - *@param tvb pointer to buffer containing raw packet. - *@param offset pointer to value of offset. - *@param length length of the value to extract. - *@param ti optional pointer to get the created proto item. - *@return the value read out of the tvbuff and added to the tree. -*/ -guint -zbee_parse_uint(proto_tree *tree, int hfindex, tvbuff_t *tvb, guint *offset, guint length, proto_item **ti) -{ - proto_item *item = NULL; - guint value = 0; - - /* Get the value. */ - if (length == 0) { - /* ??? */ - return 0; - } - else if (length == 1) { - value = tvb_get_guint8(tvb, *offset); - } - else if (length == 2) { - value = tvb_get_letohs(tvb, *offset); - } - else if (length == 3) { - value = tvb_get_letohs(tvb, *offset); - value += ((guint32)tvb_get_guint8(tvb, *offset + 2) << 16); - } - else { - value = tvb_get_letohl(tvb, *offset); - } - - /* Display it. */ - item = proto_tree_add_uint(tree, hfindex, tvb, *offset, length, value); - - /* Increment the offset. */ - *offset += length; - - /* return the item if requested. */ - if (ti) *ti = item; - - /* return the value. */ - return value; -} /* zbee_parse_uint */ - -/** *ZigBee helper function. extracts an EUI64 address and displays * *@param tree pointer to data tree Wireshark uses to display packet. @@ -770,9 +730,12 @@ zdp_parse_node_desc(proto_tree *tree, packet_info *pinfo, gboolean show_ver_flag /* Get and display the capability flags. */ /*capability =*/ zdp_parse_cinfo(field_tree, ett_zbee_zdp_cinfo, tvb, offset); - /*mfr_code =*/ zbee_parse_uint(field_tree, hf_zbee_zdp_node_manufacturer, tvb, offset, (int)sizeof(guint16), NULL); - /*max_buff =*/ zbee_parse_uint(field_tree, hf_zbee_zdp_node_max_buffer, tvb, offset, (int)sizeof(guint8), NULL); - /*max_incoming_transfer =*/ zbee_parse_uint(field_tree, hf_zbee_zdp_node_max_incoming_transfer, tvb, offset, 2, NULL); + proto_tree_add_item(field_tree, hf_zbee_zdp_node_manufacturer, tvb, *offset, 2, ENC_LITTLE_ENDIAN); + *offset += 2; + proto_tree_add_item(field_tree, hf_zbee_zdp_node_max_buffer, tvb, *offset, 1, ENC_LITTLE_ENDIAN); + *offset += 1; + proto_tree_add_item(field_tree, hf_zbee_zdp_node_max_incoming_transfer, tvb, *offset, 2, ENC_LITTLE_ENDIAN); + *offset += 2; /* Get and display the server flags. */ if (version >= ZBEE_VERSION_2007) { @@ -788,7 +751,8 @@ zdp_parse_node_desc(proto_tree *tree, packet_info *pinfo, gboolean show_ver_flag zbee_append_info(tree, pinfo, ", Rev: %d", (ver_flags >> ws_ctz(ZBEE_ZDP_NODE_SERVER_STACK_COMPL_REV))); } - zbee_parse_uint(field_tree, hf_zbee_zdp_node_max_outgoing_transfer, tvb, offset, 2, NULL); + proto_tree_add_item(field_tree, hf_zbee_zdp_node_max_outgoing_transfer, tvb, *offset, 2, ENC_LITTLE_ENDIAN); + *offset += 2; proto_tree_add_bitmask_with_flags(field_tree, tvb, *offset, hf_zbee_zdp_dcf, ett_zbee_zdp_descriptor_capability_field, descriptors, ENC_NA, BMT_NO_APPEND); *offset += 1; } @@ -859,41 +823,44 @@ zdp_parse_simple_desc(proto_tree *tree, gint ettindex, tvbuff_t *tvb, guint *off proto_tree *field_tree = NULL, *cluster_tree = NULL; guint i, sizeof_cluster; - /*guint8 endpoint;*/ - /*guint16 profile;*/ - /*guint16 app_device;*/ - /*guint8 app_version;*/ - guint8 in_count; - guint8 out_count; + guint32 in_count, out_count; if ((tree) && (ettindex != -1)) { field_tree = proto_tree_add_subtree(tree, tvb, *offset, -1, ettindex, &field_root, "Simple Descriptor"); } else field_tree = tree; - /*endpoint =*/ zbee_parse_uint(field_tree, hf_zbee_zdp_endpoint, tvb, offset, (int)sizeof(guint8), NULL); - /*profile =*/ zbee_parse_uint(field_tree, hf_zbee_zdp_profile, tvb, offset, (int)sizeof(guint16), NULL); - /*app_device =*/ zbee_parse_uint(field_tree, hf_zbee_zdp_simple_app_device, tvb, offset, (int)sizeof(guint16), NULL); - /*app_version =*/ zbee_parse_uint(field_tree, hf_zbee_zdp_simple_app_version, tvb, offset, (int)sizeof(guint8), NULL); + proto_tree_add_item(field_tree, hf_zbee_zdp_endpoint, tvb, *offset, 1, ENC_LITTLE_ENDIAN); + *offset += 1; + proto_tree_add_item(field_tree, hf_zbee_zdp_profile, tvb, *offset, 2, ENC_LITTLE_ENDIAN); + *offset += 2; + proto_tree_add_item(field_tree, hf_zbee_zdp_simple_app_device, tvb, *offset, 2, ENC_LITTLE_ENDIAN); + *offset += 2; + proto_tree_add_item(field_tree, hf_zbee_zdp_simple_app_version, tvb, *offset, 1, ENC_LITTLE_ENDIAN); + *offset += 1; sizeof_cluster = (version >= ZBEE_VERSION_2007)?(int)sizeof(guint16):(int)sizeof(guint8); - in_count = zbee_parse_uint(field_tree, hf_zbee_zdp_in_count, tvb, offset, (int)sizeof(guint8), NULL); + proto_tree_add_item_ret_uint(field_tree, hf_zbee_zdp_in_count, tvb, *offset, 1, ENC_LITTLE_ENDIAN, &in_count); + *offset += 1; if ((tree) && (in_count)) { cluster_tree = proto_tree_add_subtree(field_tree, tvb, *offset, in_count*sizeof_cluster, ett_zbee_zdp_node_in, NULL, "Input Cluster List"); } for (i=0; i<in_count && tvb_bytes_exist(tvb, *offset, sizeof_cluster); i++) { - zbee_parse_uint(cluster_tree, hf_zbee_zdp_in_cluster, tvb, offset, sizeof_cluster, NULL); + proto_tree_add_item(cluster_tree, hf_zbee_zdp_in_cluster, tvb, *offset, sizeof_cluster, ENC_LITTLE_ENDIAN); + *offset += sizeof_cluster; } - out_count = zbee_parse_uint(field_tree, hf_zbee_zdp_out_count, tvb, offset, (int)sizeof(guint8), NULL); + proto_tree_add_item_ret_uint(field_tree, hf_zbee_zdp_out_count, tvb, *offset, 1, ENC_LITTLE_ENDIAN, &out_count); + *offset += 1; if ((tree) && (out_count)) { cluster_tree = proto_tree_add_subtree(field_tree, tvb, *offset, out_count*sizeof_cluster, ett_zbee_zdp_node_out, NULL, "Output Cluster List"); } for (i=0; (i<out_count) && tvb_bytes_exist(tvb, *offset, sizeof_cluster); i++) { - zbee_parse_uint(cluster_tree, hf_zbee_zdp_out_cluster, tvb, offset, sizeof_cluster, NULL); + proto_tree_add_item(cluster_tree, hf_zbee_zdp_out_cluster, tvb, *offset, sizeof_cluster, ENC_LITTLE_ENDIAN); + *offset += sizeof_cluster; } if (tree && (ettindex != -1)) { @@ -1362,7 +1329,7 @@ void proto_register_zbee_zdp(void) NULL, HFILL }}, { &hf_zbee_zdp_addr_mode, - { "Address Mode", "zbee_zdp.addr_mode", FT_UINT8, BASE_DEC, NULL, 0x0, + { "Address Mode", "zbee_zdp.addr_mode", FT_UINT8, BASE_DEC|BASE_RANGE_STRING, RVALS(zbee_zcl_zdp_address_modes), 0x0, NULL, HFILL }}, { &hf_zbee_zdp_cluster, diff --git a/epan/dissectors/packet-zbee-zdp.h b/epan/dissectors/packet-zbee-zdp.h index 1d8aa35f11..08be43d6cd 100644 --- a/epan/dissectors/packet-zbee-zdp.h +++ b/epan/dissectors/packet-zbee-zdp.h @@ -332,7 +332,6 @@ extern gint ett_zbee_zdp_table_entry; */ extern const gchar *zdp_status_name (guint8 status); extern void zdp_dump_excess (tvbuff_t *tvb, guint offset, packet_info *pinfo, proto_tree *tree); -extern guint zbee_parse_uint (proto_tree *tree, int hfindex, tvbuff_t *tvb, guint *offset, guint length, proto_item **ti); extern guint64 zbee_parse_eui64 (proto_tree *tree, int hfindex, tvbuff_t *tvb, guint *offset, guint length, proto_item **ti); extern void zbee_append_info (proto_item *item, packet_info *pinfo, const gchar *format, ...) G_GNUC_PRINTF(3, 4); |