aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-zbee-zdp-management.c
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2014-12-26 09:44:30 -0500
committerMichael Mann <mmann78@netscape.net>2014-12-26 20:41:49 +0000
commit4cf6583b9e5bc7fa5d6f6ac17cdc1f634ae1567e (patch)
treeba6086800171711931385b8ab402fc6e6f5e0083 /epan/dissectors/packet-zbee-zdp-management.c
parenta442a1c0e815fd61416cf408bd74d85a042ccc6a (diff)
Remove proto_tree_add_text from ZigBee dissectors.
Change-Id: I0488cb0ab33f2cc6dee227f1bfacec58eafc4190 Reviewed-on: https://code.wireshark.org/review/6055 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/dissectors/packet-zbee-zdp-management.c')
-rw-r--r--epan/dissectors/packet-zbee-zdp-management.c166
1 files changed, 57 insertions, 109 deletions
diff --git a/epan/dissectors/packet-zbee-zdp-management.c b/epan/dissectors/packet-zbee-zdp-management.c
index 3bf1d00e8d..c4d9ae7c32 100644
--- a/epan/dissectors/packet-zbee-zdp-management.c
+++ b/epan/dissectors/packet-zbee-zdp-management.c
@@ -51,56 +51,42 @@
static void
zdp_parse_nwk_desc(proto_tree *tree, tvbuff_t *tvb, guint *offset, guint8 version)
{
- proto_item *ti = NULL;
- guint len = 0;
+ proto_tree *network_tree;
+ proto_item *ti;
- guint64 ext_pan;
- guint16 pan;
- guint8 channel;
- guint8 profile;
- guint8 profile_version;
guint8 beacon;
- guint8 superframe;
- gboolean permit;
if (version >= ZBEE_VERSION_2007) {
+ network_tree = proto_tree_add_subtree(tree, tvb, *offset, 12, ett_zbee_zdp_nwk_desc, NULL, "Network descriptor");
/* Extended PAN Identifiers are used in ZigBee 2006 & later. */
- ext_pan = tvb_get_letoh64(tvb, *offset + len);
- if (tree) ti = proto_tree_add_text(tree, tvb, *offset, 0, "{Pan: %s", eui64_to_str(ext_pan));
- len += 8;
+ proto_tree_add_item(network_tree, hf_zbee_zdp_pan_eui64, tvb, *offset, 8, ENC_LITTLE_ENDIAN);
+ *offset += 8;
}
else {
+ network_tree = proto_tree_add_subtree(tree, tvb, *offset, 6, ett_zbee_zdp_nwk_desc, NULL, "Network descriptor");
/* Short PAN Identifiers are used in ZigBee 2003 and earlier. */
- pan = tvb_get_letohs(tvb, *offset + len);
- if (tree) ti = proto_tree_add_text(tree, tvb, *offset, 0, "{Pan: 0x%04x", pan);
- len += 2;
+ proto_tree_add_item(network_tree, hf_zbee_zdp_pan_uint, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
+ *offset += 2;
}
- channel = tvb_get_guint8(tvb, *offset + len);
- if (tree) proto_item_append_text(ti, ", Channel: %d", channel);
- len += 1;
+ proto_tree_add_item(network_tree, hf_zbee_zdp_channel, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
+ *offset += 1;
- profile = (tvb_get_guint8(tvb, *offset + len) & 0x0f) >> 0;
- profile_version = (tvb_get_guint8(tvb, *offset + len) & 0xf0) >> 4;
- if (tree) proto_item_append_text(ti, ", Profile: 0x%01x, Version: %d", profile, profile_version);
- len += 1;
+ proto_tree_add_item(network_tree, hf_zbee_zdp_profile, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
+ proto_tree_add_item(network_tree, hf_zbee_zdp_profile_version, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
+ *offset += 1;
- beacon = (tvb_get_guint8(tvb, *offset + len) & 0x0f) >> 0;
- superframe = (tvb_get_guint8(tvb, *offset + len) & 0xf0) >> 4;
- if ((tree) && (beacon == 0xf)) {
- proto_item_append_text(ti, ", Beacons Disabled");
- }
- else if (tree) {
- proto_item_append_text(ti, ", BeaconOrder: %d, SuperframeOrder: %d", beacon, superframe);
+ ti = proto_tree_add_item(network_tree, hf_zbee_zdp_beacon, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
+ proto_tree_add_item(network_tree, hf_zbee_zdp_superframe, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
+ beacon = tvb_get_guint8(tvb, *offset) & 0x0f;
+ if (beacon == 0xf) {
+ proto_item_append_text(ti, " (Beacons Disabled)");
}
- len += 1;
+ *offset += 1;
- permit = tvb_get_guint8(tvb, *offset) & 0x01;
- if (tree) proto_item_append_text(ti, ", PermitJoining: %s}", permit?"True":"False");
- len += 1;
+ proto_tree_add_item(network_tree, hf_zbee_zdp_permit_joining, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
+ *offset += 1;
- if (tree) proto_item_set_len(ti, len);
- *offset += len;
} /* zdp_parse_nwk_desc */
/*FUNCTION:------------------------------------------------------
@@ -119,94 +105,57 @@ zdp_parse_nwk_desc(proto_tree *tree, tvbuff_t *tvb, guint *offset, guint8 versio
static void
zdp_parse_neighbor_table_entry(proto_tree *tree, tvbuff_t *tvb, guint *offset, guint8 version)
{
+ proto_tree *table_tree;
proto_item *ti = NULL;
guint len = 0;
- guint64 ext_pan;
- guint16 pan;
- guint64 ext_addr;
- guint16 device;
- guint8 type;
- guint8 idle_rx;
- guint8 rel;
- guint8 permit_joining;
- guint8 depth;
- guint8 lqi;
-
if (version >= ZBEE_VERSION_2007) {
+ table_tree = proto_tree_add_subtree(tree, tvb, *offset, 8, ett_zbee_zdp_table_entry, &ti, "Table Entry");
/* ZigBee 2006 & later use an extended PAN Identifier. */
- ext_pan = tvb_get_letoh64(tvb, *offset + len);
- if (tree) ti = proto_tree_add_text(tree, tvb, *offset, 0, "{Extended PAN: %s", eui64_to_str(ext_pan));
+ proto_tree_add_item(table_tree, hf_zbee_zdp_extended_pan, tvb, *offset, 8, ENC_LITTLE_ENDIAN);
len += 8;
}
else {
+ table_tree = proto_tree_add_subtree(tree, tvb, *offset, 2, ett_zbee_zdp_table_entry, &ti, "Table Entry");
/* ZigBee 2003 & earlier use a short PAN Identifier. */
- pan = tvb_get_letohs(tvb, *offset + len);
- if (tree) ti = proto_tree_add_text(tree, tvb, *offset, 0, "{PAN: 0x%04x", pan);
+ proto_tree_add_item(table_tree, hf_zbee_zdp_pan_uint, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
len += 2;
}
- ext_addr = tvb_get_letoh64(tvb, *offset + len);
- if (tree) proto_item_append_text(ti, ", Extended Addr: %s", ep_eui64_to_display(ext_addr));
+ proto_tree_add_item(table_tree, hf_zbee_zdp_ext_addr, tvb, *offset + len, 8, ENC_LITTLE_ENDIAN);
len += 8;
- device = tvb_get_letohs(tvb, *offset + len);
- if (tree) proto_item_append_text(ti, ", Addr: 0x%04x", device);
+ proto_tree_add_item(table_tree, hf_zbee_zdp_addr, tvb, *offset + len, 2, ENC_LITTLE_ENDIAN);
len += 2;
if (version >= ZBEE_VERSION_2007) {
- type = (tvb_get_guint8(tvb, *offset + len) & 0x03) >> 0;
- idle_rx = (tvb_get_guint8(tvb, *offset + len) & 0x0c) >> 2;
- rel = (tvb_get_guint8(tvb, *offset + len) & 0x70) >> 4;
+ proto_tree_add_item(table_tree, hf_zbee_zdp_table_entry_type, tvb, *offset + len, 1, ENC_NA);
+ proto_tree_add_item(table_tree, hf_zbee_zdp_table_entry_idle_rx_0c, tvb, *offset + len, 1, ENC_NA);
+ proto_tree_add_item(table_tree, hf_zbee_zdp_table_entry_relationship_70, tvb, *offset + len, 1, ENC_NA);
}
else {
- type = (tvb_get_guint8(tvb, *offset + len) & 0x03) >> 0;
- idle_rx = (tvb_get_guint8(tvb, *offset + len) & 0x04) >> 2;
- rel = (tvb_get_guint8(tvb, *offset + len) & 0x18) >> 3;
- }
- if (tree) {
- if (type == 0x00) proto_item_append_text(ti, ", Type: Coordinator");
- else if (type == 0x01) proto_item_append_text(ti, ", Type: Router");
- else if (type == 0x02) proto_item_append_text(ti, ", Type: End Device");
- else proto_item_append_text(ti, ", Type: Unknown");
-
- if (idle_rx == 0x00) proto_item_append_text(ti, ", Idle Rx: False");
- else if (idle_rx==0x01) proto_item_append_text(ti, ", Idle Rx: True");
- else proto_item_append_text(ti, ", Idle Rx: Unknown");
-
- if (rel == 0x00) proto_item_append_text(ti, ", Relationship: Parent");
- else if (rel == 0x01) proto_item_append_text(ti, ", Relationship: Child");
- else if (rel == 0x02) proto_item_append_text(ti, ", Relationship: Sibling");
- else if (rel == 0x03) proto_item_append_text(ti, ", Relationship: None");
- else if (rel == 0x04) proto_item_append_text(ti, ", Relationship: Previous Child");
- else proto_item_append_text(ti, ", Relationship: Unknown");
+ proto_tree_add_item(table_tree, hf_zbee_zdp_table_entry_type, tvb, *offset + len, 1, ENC_NA);
+ proto_tree_add_item(table_tree, hf_zbee_zdp_table_entry_idle_rx_04, tvb, *offset + len, 1, ENC_NA);
+ proto_tree_add_item(table_tree, hf_zbee_zdp_table_entry_relationship_18, tvb, *offset + len, 1, ENC_NA);
}
len += 1;
if (version <= ZBEE_VERSION_2004) {
/* In ZigBee 2003 & earlier, the depth field is before the permit joining field. */
- depth = tvb_get_guint8(tvb, *offset + len);
- if (tree) proto_item_append_text(ti, ", Depth: %d", depth);
+ proto_tree_add_item(table_tree, hf_zbee_zdp_depth, tvb, *offset + len, 1, ENC_NA);
len += 1;
}
- permit_joining = (tvb_get_guint8(tvb, *offset + len) & 0x03) >> 0;
- if (tree) {
- if (permit_joining == 0x00) proto_item_append_text(ti, ", Permit Joining: False");
- else if (permit_joining == 0x01)proto_item_append_text(ti, ", Permit Joining: True");
- else proto_item_append_text(ti, ", Permit Joining: Unknown");
- }
+ proto_tree_add_item(table_tree, hf_zbee_zdp_permit_joining_03, tvb, *offset + len, 1, ENC_NA);
len += 1;
if (version >= ZBEE_VERSION_2007) {
/* In ZigBee 2006 & later, the depth field is after the permit joining field. */
- depth = tvb_get_guint8(tvb, *offset + len);
- if (tree) proto_item_append_text(ti, ", Depth: %d", depth);
+ proto_tree_add_item(table_tree, hf_zbee_zdp_depth, tvb, *offset + len, 1, ENC_NA);
len += 1;
}
- lqi = tvb_get_guint8(tvb, *offset + len);
- if (tree) proto_item_append_text(ti, ", LQI: %d}", lqi);
+ proto_tree_add_item(table_tree, hf_zbee_zdp_lqi, tvb, *offset + len, 1, ENC_NA);
len += 1;
if (tree) proto_item_set_len(ti, len);
@@ -275,7 +224,7 @@ zdp_parse_routing_table_entry(proto_tree *tree, tvbuff_t *tvb, guint *offset)
*---------------------------------------------------------------
*/
void
-dissect_zbee_zdp_req_mgmt_nwk_disc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+dissect_zbee_zdp_req_mgmt_nwk_disc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int hf_channel)
{
proto_item *ti;
guint i;
@@ -289,7 +238,7 @@ dissect_zbee_zdp_req_mgmt_nwk_disc(tvbuff_t *tvb, packet_info *pinfo, proto_tree
channels = tvb_get_letohl(tvb, offset);
if (tree) {
gboolean first = 1;
- ti = proto_tree_add_text(tree, tvb, offset, 4, "Scan Channels: ");
+ ti = proto_tree_add_uint_format(tree, hf_channel, tvb, offset, 4, channels, "Scan Channels: ");
for (i=0; i<27; i++) {
if (channels & (1<<i)) {
@@ -537,7 +486,7 @@ dissect_zbee_zdp_req_mgmt_nwkupdate(tvbuff_t *tvb, packet_info *pinfo, proto_tre
/*guint8 update_id;*/
/*guint16 manager;*/
- /*channels =*/ zdp_parse_chanmask(tree, tvb, &offset);
+ /*channels =*/ zdp_parse_chanmask(tree, tvb, &offset, hf_zbee_zdp_channel_mask);
duration = zbee_parse_uint(tree, hf_zbee_zdp_duration, tvb, &offset, 1, NULL);
if (duration == ZBEE_ZDP_NWKUPDATE_PARAMETERS) {
/*update_id =*/ zbee_parse_uint(tree, hf_zbee_zdp_update_id, tvb, &offset, 1, NULL);
@@ -633,12 +582,12 @@ dissect_zbee_zdp_rsp_mgmt_lqi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre
/*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);
- if (tree && table_count) {
+ if (table_count) {
field_tree = proto_tree_add_subtree(tree, tvb, offset, -1, ett_zbee_zdp_lqi, NULL, "Neighbor Table");
+ for (i=0; i<table_count; i++) {
+ zdp_parse_neighbor_table_entry(field_tree, tvb, &offset, version);
+ }
}
- for (i=0; i<table_count; i++) {
- zdp_parse_neighbor_table_entry(field_tree, tvb, &offset, version);
- } /* for */
zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
@@ -838,6 +787,7 @@ void
dissect_zbee_zdp_rsp_mgmt_cache(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
proto_tree *field_tree = NULL;
+ proto_tree *ti;
guint offset = 0;
guint i;
@@ -851,20 +801,20 @@ dissect_zbee_zdp_rsp_mgmt_cache(tvbuff_t *tvb, packet_info *pinfo, proto_tree *t
/*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);
- if (tree && table_count) {
+ if (table_count) {
field_tree = proto_tree_add_subtree(tree, tvb, offset, table_count*(2+8),
ett_zbee_zdp_cache, NULL, "Discovery Cache");
- }
- for (i=0; i<table_count; i++) {
- guint64 addr64 = tvb_get_letoh64(tvb, offset);
- guint16 addr16 = tvb_get_letohs(tvb, offset+8);
+ for (i=0; i<table_count; i++) {
+ guint16 addr16 = tvb_get_letohs(tvb, offset+8);
- if (field_tree) {
- proto_tree_add_text(field_tree, tvb, offset, 2+8, "{%s = 0x%04x}", ep_eui64_to_display(addr64), addr16);
+ ti = proto_tree_add_item(field_tree, hf_zbee_zdp_cache_address, tvb, offset, 8, ENC_LITTLE_ENDIAN);
+ /* XXX - make 16-bit address filterable? */
+ proto_item_append_text(ti, " = 0x%04x", addr16);
+ proto_item_set_len(ti, 8+2);
+ offset += 2+8;
}
- offset += 2+8;
- } /* for */
+ }
zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
@@ -899,7 +849,7 @@ dissect_zbee_zdp_rsp_mgmt_nwkupdate(tvbuff_t *tvb, packet_info *pinfo, proto_tre
guint8 channel_count;
/*status =*/ zdp_parse_status(tree, tvb, &offset);
- channels = zdp_parse_chanmask(tree, tvb, &offset);
+ channels = zdp_parse_chanmask(tree, tvb, &offset, 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);
@@ -918,9 +868,7 @@ dissect_zbee_zdp_rsp_mgmt_nwkupdate(tvbuff_t *tvb, packet_info *pinfo, proto_tre
}
/* Get and display the channel energy. */
energy = tvb_get_guint8(tvb, offset);
- if (tree) {
- proto_tree_add_text(tree, tvb, offset, 1, "Channel %d Energy = 0x%02x", i, energy);
- }
+ proto_tree_add_uint_format(tree, hf_zbee_zdp_channel_energy, tvb, offset, 1, energy, "Channel %d Energy: 0x%02x", i, energy);
offset += 1;
/* Increment the number of channels we found energy values for. */
j++;