diff options
-rw-r--r-- | epan/dissectors/packet-zbee-zdp-management.c | 128 |
1 files changed, 64 insertions, 64 deletions
diff --git a/epan/dissectors/packet-zbee-zdp-management.c b/epan/dissectors/packet-zbee-zdp-management.c index 175e5adc6f..4513f268c0 100644 --- a/epan/dissectors/packet-zbee-zdp-management.c +++ b/epan/dissectors/packet-zbee-zdp-management.c @@ -69,23 +69,23 @@ zdp_parse_nwk_desc(proto_tree *tree, tvbuff_t *tvb, guint *offset, guint8 versio /* 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 += (int)sizeof(guint64); + len += 8; } else { /* 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 += (int)sizeof(guint16); + len += 2; } channel = tvb_get_guint8(tvb, *offset + len); if (tree) proto_item_append_text(ti, ", Channel: %d", channel); - len += (int)sizeof(guint8); + len += 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 += (int)sizeof(guint8); + len += 1; beacon = (tvb_get_guint8(tvb, *offset + len) & 0x0f) >> 0; superframe = (tvb_get_guint8(tvb, *offset + len) & 0xf0) >> 4; @@ -95,11 +95,11 @@ zdp_parse_nwk_desc(proto_tree *tree, tvbuff_t *tvb, guint *offset, guint8 versio else if (tree) { proto_item_append_text(ti, ", BeaconOrder: %d, SuperframeOrder: %d", beacon, superframe); } - len += (int)sizeof(guint8); + len += 1; permit = tvb_get_guint8(tvb, *offset) & 0x01; if (tree) proto_item_append_text(ti, ", PermitJoining: %s}", permit?"True":"False"); - len += (int)sizeof(guint8); + len += 1; if (tree) proto_item_set_len(ti, len); *offset += len; @@ -139,22 +139,22 @@ zdp_parse_neighbor_table_entry(proto_tree *tree, tvbuff_t *tvb, guint *offset, g /* 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)); - len += (int)sizeof(guint64); + len += 8; } else { /* 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); - len += (int)sizeof(guint16); + len += 2; } ext_addr = tvb_get_letoh64(tvb, *offset + len); if (tree) proto_item_append_text(ti, ", Extended Addr: %s", get_eui64_name(ext_addr)); - len += (int)sizeof(guint64); + len += 8; device = tvb_get_letohs(tvb, *offset + len); if (tree) proto_item_append_text(ti, ", Addr: 0x%04x", device); - len += (int)sizeof(guint16); + len += 2; if (version >= ZBEE_VERSION_2007) { type = (tvb_get_guint8(tvb, *offset + len) & 0x03) >> 0; @@ -183,13 +183,13 @@ zdp_parse_neighbor_table_entry(proto_tree *tree, tvbuff_t *tvb, guint *offset, g else if (rel == 0x04) proto_item_append_text(ti, ", Relationship: Previous Child"); else proto_item_append_text(ti, ", Relationship: Unknown"); } - len += (int)sizeof(guint8); + 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); - len += (int)sizeof(guint8); + len += 1; } permit_joining = (tvb_get_guint8(tvb, *offset + len) & 0x03) >> 0; @@ -198,18 +198,18 @@ zdp_parse_neighbor_table_entry(proto_tree *tree, tvbuff_t *tvb, guint *offset, g else if (permit_joining == 0x01)proto_item_append_text(ti, ", Permit Joining: True"); else proto_item_append_text(ti, ", Permit Joining: Unknown"); } - len += (int)sizeof(guint8); + 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); - len += (int)sizeof(guint8); + len += 1; } lqi = tvb_get_guint8(tvb, *offset + len); if (tree) proto_item_append_text(ti, ", LQI: %d}", lqi); - len += (int)sizeof(guint8); + len += 1; if (tree) proto_item_set_len(ti, len); *offset += len; @@ -238,11 +238,11 @@ zdp_parse_routing_table_entry(proto_tree *tree, tvbuff_t *tvb, guint *offset) guint16 next; dest = tvb_get_letohs(tvb, *offset + len); - if (tree) ti = proto_tree_add_text(tree, tvb, *offset, 2*(int)sizeof(guint16) + (int)sizeof(guint8), "{Destination: 0x%04x", dest); - len += (int)sizeof(guint16); + if (tree) ti = proto_tree_add_text(tree, tvb, *offset, 2*2 + 1, "{Destination: 0x%04x", dest); + len += 2; status = tvb_get_guint8(tvb, *offset + len); - next = tvb_get_letohs(tvb, *offset + len + (int)sizeof(guint8)); + next = tvb_get_letohs(tvb, *offset + len + 1); if (tree) { /* Display the next hop first, because it looks a lot cleaner that way. */ proto_item_append_text(ti, ", Next Hop: 0x%04x", next); @@ -253,7 +253,7 @@ zdp_parse_routing_table_entry(proto_tree *tree, tvbuff_t *tvb, guint *offset) else if (status == 0x03)proto_item_append_text(ti, ", Status: Inactive}"); else proto_item_append_text(ti, ", Status: Unknown}"); } - len += (int)sizeof(guint8) + (int)sizeof(guint16); + len += 1 + 2; *offset += len; } /* zdp_parse_routing_table_entry */ @@ -292,7 +292,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, (int)sizeof(guint32), "Scan Channels: "); + ti = proto_tree_add_text(tree, tvb, offset, 4, "Scan Channels: "); for (i=0; i<27; i++) { if (channels & (1<<i)) { @@ -307,10 +307,10 @@ dissect_zbee_zdp_req_mgmt_nwk_disc(tvbuff_t *tvb, packet_info *pinfo, proto_tree } if (first) proto_item_append_text(ti, "None"); } - offset += (int)sizeof(guint32); + offset += 4; - /*duration =*/ zbee_parse_uint(tree, hf_zbee_zdp_duration, tvb, &offset, (int)sizeof(guint8), NULL); - /*idx =*/ zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, (int)sizeof(guint8), NULL); + /*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); /* Dump any leftover bytes. */ zdp_dump_excess(tvb, offset, pinfo, tree); @@ -336,7 +336,7 @@ dissect_zbee_zdp_req_mgmt_lqi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre guint offset = 0; /*guint8 idx;*/ - /*idx =*/ zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, (int)sizeof(guint8), NULL); + /*idx =*/ zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, 1, NULL); /* Dump any leftover bytes. */ zdp_dump_excess(tvb, offset, pinfo, tree); @@ -362,7 +362,7 @@ dissect_zbee_zdp_req_mgmt_rtg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre guint offset = 0; /*guint8 idx;*/ - /*idx =*/ zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, (int)sizeof(guint8), NULL); + /*idx =*/ zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, 1, NULL); /* Dump any leftover bytes. */ zdp_dump_excess(tvb, offset, pinfo, tree); @@ -388,7 +388,7 @@ dissect_zbee_zdp_req_mgmt_bind(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tr guint offset = 0; /*guint8 idx;*/ - /*idx =*/ zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, (int)sizeof(guint8), NULL); + /*idx =*/ zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, 1, NULL); /* Dump any leftover bytes. */ zdp_dump_excess(tvb, offset, pinfo, tree); @@ -415,15 +415,15 @@ dissect_zbee_zdp_req_mgmt_leave(tvbuff_t *tvb, packet_info *pinfo, proto_tree *t guint64 ext_addr; guint8 flags; - ext_addr = zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, (int)sizeof(guint64), NULL); + ext_addr = zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, 8, NULL); if (version >= ZBEE_VERSION_2007) { /* Flags present on ZigBee 2006 & later. */ flags = tvb_get_guint8(tvb, offset); if (tree) { - proto_tree_add_boolean(tree, hf_zbee_zdp_leave_children, tvb, offset, (int)sizeof(guint8), flags & ZBEE_ZDP_MGMT_LEAVE_CHILDREN); - proto_tree_add_boolean(tree, hf_zbee_zdp_leave_rejoin, tvb, offset, (int)sizeof(guint8), flags & ZBEE_ZDP_MGMT_LEAVE_REJOIN); + proto_tree_add_boolean(tree, hf_zbee_zdp_leave_children, tvb, offset, 1, flags & ZBEE_ZDP_MGMT_LEAVE_CHILDREN); + proto_tree_add_boolean(tree, hf_zbee_zdp_leave_rejoin, tvb, offset, 1, flags & ZBEE_ZDP_MGMT_LEAVE_REJOIN); } - offset += (int)sizeof(guint8); + offset += 1; } zbee_append_info(tree, pinfo, ", Device: %s", get_eui64_name(ext_addr)); @@ -453,7 +453,7 @@ dissect_zbee_zdp_req_mgmt_direct_join(tvbuff_t *tvb, packet_info *pinfo, proto_t guint64 ext_addr; /*guint8 cinfo;*/ - ext_addr = zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, (int)sizeof(guint64), NULL); + ext_addr = zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, 8, NULL); /*cinfo =*/ zdp_parse_cinfo(tree, ett_zbee_zdp_cinfo, tvb, &offset); zbee_append_info(tree, pinfo, ", Device: %s", get_eui64_name(ext_addr)); @@ -483,8 +483,8 @@ dissect_zbee_zdp_req_mgmt_permit_join(tvbuff_t *tvb, packet_info *pinfo, proto_t /*guint8 duration;*/ /*guint8 significance;*/ - /*duration =*/ zbee_parse_uint(tree, hf_zbee_zdp_duration, tvb, &offset, (int)sizeof(guint8), NULL); - /*significance =*/ zbee_parse_uint(tree, hf_zbee_zdp_significance, tvb, &offset, (int)sizeof(guint8), NULL); + /*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); /* Dump any leftover bytes. */ zdp_dump_excess(tvb, offset, pinfo, tree); @@ -510,7 +510,7 @@ dissect_zbee_zdp_req_mgmt_cache(tvbuff_t *tvb, packet_info *pinfo, proto_tree *t guint offset = 0; /*guint8 idx;*/ - /*idx =*/ zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, (int)sizeof(guint8), NULL); + /*idx =*/ zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, 1, NULL); /* Dump any leftover bytes. */ zdp_dump_excess(tvb, offset, pinfo, tree); @@ -541,16 +541,16 @@ dissect_zbee_zdp_req_mgmt_nwkupdate(tvbuff_t *tvb, packet_info *pinfo, proto_tre /*guint16 manager;*/ /*channels =*/ zdp_parse_chanmask(tree, tvb, &offset); - duration = zbee_parse_uint(tree, hf_zbee_zdp_duration, tvb, &offset, (int)sizeof(guint8), NULL); + 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, (int)sizeof(guint8), NULL); - /*manager =*/ zbee_parse_uint(tree, hf_zbee_zdp_manager, tvb, &offset, (int)sizeof(guint16), NULL); + /*update_id =*/ zbee_parse_uint(tree, hf_zbee_zdp_update_id, tvb, &offset, 1, NULL); + /*manager =*/ zbee_parse_uint(tree, hf_zbee_zdp_manager, tvb, &offset, 2, NULL); } else if (duration == ZBEE_ZDP_NWKUPDATE_CHANNEL_HOP) { - /*update_id =*/ zbee_parse_uint(tree, hf_zbee_zdp_update_id, tvb, &offset, (int)sizeof(guint8), NULL); + /*update_id =*/ zbee_parse_uint(tree, hf_zbee_zdp_update_id, tvb, &offset, 1, NULL); } else if (duration <= ZBEE_ZDP_NWKUPDATE_SCAN_MAX) { - /*count =*/ zbee_parse_uint(tree, hf_zbee_zdp_scan_count, tvb, &offset, (int)sizeof(guint8), NULL); + /*count =*/ zbee_parse_uint(tree, hf_zbee_zdp_scan_count, tvb, &offset, 1, NULL); } /* Dump any leftover bytes. */ @@ -589,9 +589,9 @@ dissect_zbee_zdp_rsp_mgmt_nwk_disc(tvbuff_t *tvb, packet_info *pinfo, proto_tree guint8 table_count; status = zdp_parse_status(tree, tvb, &offset); - /*table_size =*/ zbee_parse_uint(tree, hf_zbee_zdp_table_size, tvb, &offset, (int)sizeof(guint8), NULL); - /*idx =*/ zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, (int)sizeof(guint8), NULL); - table_count = zbee_parse_uint(tree, hf_zbee_zdp_table_count, tvb, &offset, (int)sizeof(guint8), NULL); + /*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); if (tree && table_count) { ti = proto_tree_add_text(tree, tvb, offset, tvb_length_remaining(tvb, offset), "Network List"); @@ -635,9 +635,9 @@ dissect_zbee_zdp_rsp_mgmt_lqi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre guint8 table_count; status = zdp_parse_status(tree, tvb, &offset); - /*table_size =*/ zbee_parse_uint(tree, hf_zbee_zdp_table_size, tvb, &offset, (int)sizeof(guint8), NULL); - /*idx =*/ zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, (int)sizeof(guint8), NULL); - table_count = zbee_parse_uint(tree, hf_zbee_zdp_table_count, tvb, &offset, (int)sizeof(guint8), NULL); + /*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); if (tree && table_count) { ti = proto_tree_add_text(tree, tvb, offset, tvb_length_remaining(tvb, offset), "Neighbor Table"); @@ -681,9 +681,9 @@ dissect_zbee_zdp_rsp_mgmt_rtg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre guint8 table_count; status = zdp_parse_status(tree, tvb, &offset); - /*table_size =*/ zbee_parse_uint(tree, hf_zbee_zdp_table_size, tvb, &offset, (int)sizeof(guint8), NULL); - /*idx =*/ zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, (int)sizeof(guint8), NULL); - table_count = zbee_parse_uint(tree, hf_zbee_zdp_table_count, tvb, &offset, (int)sizeof(guint8), NULL); + /*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); if (tree && table_count) { ti = proto_tree_add_text(tree, tvb, offset, tvb_length_remaining(tvb, offset), "Routing Table"); @@ -727,9 +727,9 @@ dissect_zbee_zdp_rsp_mgmt_bind(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tr guint8 table_count; status = zdp_parse_status(tree, tvb, &offset); - /*table_size =*/ zbee_parse_uint(tree, hf_zbee_zdp_table_size, tvb, &offset, (int)sizeof(guint8), NULL); - /*idx =*/ zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, (int)sizeof(guint8), NULL); - table_count = zbee_parse_uint(tree, hf_zbee_zdp_table_count, tvb, &offset, (int)sizeof(guint8), NULL); + /*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); if (tree && table_count) { ti = proto_tree_add_text(tree, tvb, offset, tvb_length_remaining(tvb, offset), "Binding Table"); @@ -857,24 +857,24 @@ dissect_zbee_zdp_rsp_mgmt_cache(tvbuff_t *tvb, packet_info *pinfo, proto_tree *t guint8 table_count; status = zdp_parse_status(tree, tvb, &offset); - /*table_size =*/ zbee_parse_uint(tree, hf_zbee_zdp_table_size, tvb, &offset, (int)sizeof(guint8), NULL); - /*idx =*/ zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, (int)sizeof(guint8), NULL); - table_count = zbee_parse_uint(tree, hf_zbee_zdp_table_count, tvb, &offset, (int)sizeof(guint8), NULL); + /*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); if (tree && table_count) { - ti = proto_tree_add_text(tree, tvb, offset, table_count*((int)sizeof(guint16)+(int)sizeof(guint64)), "Discovery Cache"); + ti = proto_tree_add_text(tree, tvb, offset, table_count*(2+8), "Discovery Cache"); field_tree = proto_item_add_subtree(ti, ett_zbee_zdp_cache); } else { field_tree = NULL; } for (i=0; i<table_count; i++) { guint64 addr64 = tvb_get_letoh64(tvb, offset); - guint16 addr16 = tvb_get_letohs(tvb, offset+(int)sizeof(guint64)); + guint16 addr16 = tvb_get_letohs(tvb, offset+8); if (field_tree) { - proto_tree_add_text(field_tree, tvb, offset, (int)sizeof(guint16)+(int)sizeof(guint64), "{%s = 0x%04x}", get_eui64_name(addr64), addr16); + proto_tree_add_text(field_tree, tvb, offset, 2+8, "{%s = 0x%04x}", get_eui64_name(addr64), addr16); } - offset += (int)sizeof(guint16)+(int)sizeof(guint64); + offset += 2+8; } /* for */ zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status)); @@ -911,12 +911,12 @@ dissect_zbee_zdp_rsp_mgmt_nwkupdate(tvbuff_t *tvb, packet_info *pinfo, proto_tre /*status =*/ zdp_parse_status(tree, tvb, &offset); channels = zdp_parse_chanmask(tree, tvb, &offset); - /*tx_total =*/ zbee_parse_uint(tree, hf_zbee_zdp_tx_total, tvb, &offset, (int)sizeof(guint16), NULL); - /*tx_fail =*/ zbee_parse_uint(tree, hf_zbee_zdp_tx_fail, tvb, &offset, (int)sizeof(guint16), NULL); - channel_count = zbee_parse_uint(tree, hf_zbee_zdp_channel_count, tvb, &offset, (int)sizeof(guint8), NULL); + /*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); /* Display the channel list. */ - for (i=0, j=0; i<(8*(int)sizeof(guint32)); i++) { + for (i=0, j=0; i<(8*4); i++) { guint8 energy; if ( ! ((1<<i) & channels) ) { @@ -930,9 +930,9 @@ 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, (int)sizeof(guint8), "Channel %d Energy = 0x%02x", i, energy); + proto_tree_add_text(tree, tvb, offset, 1, "Channel %d Energy = 0x%02x", i, energy); } - offset += (int)sizeof(guint8); + offset += 1; /* Increment the number of channels we found energy values for. */ j++; } /* for */ |