Enhance ZigBee Routing Table

Make field filterable and use value_string for status

Based from capture available in bug 9855

Need to continue... lot of enhance is possible in ZigBee dissector...

Change-Id: I0ac84e05a7b8b54e9879abbb7495034318188394
Reviewed-on: https://code.wireshark.org/review/631
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
This commit is contained in:
Alexis La Goutte 2014-03-13 12:52:41 +01:00
parent ba32257cb6
commit e204e9aefb
3 changed files with 55 additions and 15 deletions

View File

@ -230,31 +230,30 @@ zdp_parse_neighbor_table_entry(proto_tree *tree, tvbuff_t *tvb, guint *offset, g
static void
zdp_parse_routing_table_entry(proto_tree *tree, tvbuff_t *tvb, guint *offset)
{
proto_item *ti = NULL;
guint len = 0;
proto_item *ti;
proto_tree *field_tree;
guint16 dest;
guint8 status;
guint16 next;
ti = proto_tree_add_item(tree, hf_zbee_zdp_rtg_entry, tvb, *offset + len, 2 + 1 + 2, ENC_NA);
field_tree = proto_item_add_subtree(ti, ett_zbee_zdp_rtg);
proto_tree_add_item(field_tree, hf_zbee_zdp_rtg_destination, tvb, *offset + len, 2, ENC_LITTLE_ENDIAN);
dest = tvb_get_letohs(tvb, *offset + len);
if (tree) ti = proto_tree_add_text(tree, tvb, *offset, 2*2 + 1, "{Destination: 0x%04x", dest);
len += 2;
proto_tree_add_item(field_tree, hf_zbee_zdp_rtg_status, tvb, *offset + len , 1, ENC_LITTLE_ENDIAN);
status = tvb_get_guint8(tvb, *offset + len);
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);
len += 1;
if (status == 0x00) proto_item_append_text(ti, ", Status: Active}");
else if (status == 0x01)proto_item_append_text(ti, ", Status: Discovery Underway}");
else if (status == 0x02)proto_item_append_text(ti, ", Status: Discovery Failed}");
else if (status == 0x03)proto_item_append_text(ti, ", Status: Inactive}");
else proto_item_append_text(ti, ", Status: Unknown}");
}
len += 1 + 2;
proto_tree_add_item(field_tree, hf_zbee_zdp_rtg_next_hop, tvb, *offset + len , 2, ENC_LITTLE_ENDIAN);
next = tvb_get_letohs(tvb, *offset + len);
len += 2;
/* Display the next hop first, because it looks a lot cleaner that way. */
proto_item_append_text(ti, " {Destination: 0x%04x, Next Hop: 0x%04x, Status: %s}", dest, next, val_to_str_const(status, zbee_zdp_rtg_status_vals, "Unknown"));
*offset += len;
} /* zdp_parse_routing_table_entry */
@ -686,7 +685,7 @@ dissect_zbee_zdp_rsp_mgmt_rtg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre
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");
ti = proto_tree_add_item(tree, hf_zbee_zdp_rtg, tvb, offset, -1, ENC_NA);
field_tree = proto_item_add_subtree(ti, ett_zbee_zdp_rtg);
}
for (i=0; i<table_count; i++) {

View File

@ -160,6 +160,13 @@ static int hf_zbee_zdp_complex = -1;
int hf_zbee_zdp_tx_fail = -1;
int hf_zbee_zdp_channel_count = -1;
/* Routing Table */
int hf_zbee_zdp_rtg = -1;
int hf_zbee_zdp_rtg_entry = -1;
int hf_zbee_zdp_rtg_destination = -1;
int hf_zbee_zdp_rtg_next_hop = -1;
int hf_zbee_zdp_rtg_status = -1;
/* Subtree indicies. */
static gint ett_zbee_zdp = -1;
gint ett_zbee_zdp_endpoint = -1;
@ -303,6 +310,14 @@ static const value_string zbee_zdp_status_names[] = {
{ 0, NULL }
};
const value_string zbee_zdp_rtg_status_vals[] = {
{ 0x00, "Active" },
{ 0x01, "Discovery Underway" },
{ 0x02, "Discovery Failed" },
{ 0x03, "Inactive" },
{ 0, NULL }
};
/*FUNCTION:------------------------------------------------------
* NAME
* zdp_status_name
@ -1657,7 +1672,24 @@ void proto_register_zbee_zdp(void)
{ &hf_zbee_zdp_channel_count,
{ "Channel List Count", "zbee_zdp.channel_count", FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_zbee_zdp_rtg,
{ "Routing Table", "zbee_zdp.routing", FT_NONE, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_zbee_zdp_rtg_entry,
{ "Routing Table Entry", "zbee_zdp.routing.entry", FT_NONE, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_zbee_zdp_rtg_destination,
{ "Destination", "zbee_zdp.routing.destination", FT_UINT16, BASE_HEX, NULL, 0x0,
NULL, HFILL }},
{ &hf_zbee_zdp_rtg_status,
{ "Status", "zbee_zdp.routing.status", FT_UINT8, BASE_DEC, VALS(zbee_zdp_rtg_status_vals), 0x0,
NULL, HFILL }},
{ &hf_zbee_zdp_rtg_next_hop,
{ "Next Hop", "zbee_zdp.routing.next_hop", FT_UINT16, BASE_HEX, NULL, 0x0,
NULL, HFILL }}
};
/* APS subtrees */

View File

@ -246,6 +246,14 @@ extern int hf_zbee_zdp_tx_total;
extern int hf_zbee_zdp_tx_fail;
extern int hf_zbee_zdp_channel_count;
/* Routing Table */
extern int hf_zbee_zdp_rtg;
extern int hf_zbee_zdp_rtg_entry;
extern int hf_zbee_zdp_rtg_destination;
extern int hf_zbee_zdp_rtg_next_hop;
extern int hf_zbee_zdp_rtg_status;
/* Subtree indicies. */
extern gint ett_zbee_zdp_endpoint;
extern gint ett_zbee_zdp_match_in;
@ -378,5 +386,6 @@ extern void dissect_zbee_zdp_rsp_mgmt_nwkupdate (tvbuff_t *tvb, packet_info
extern void zdp_parse_bind_table_entry(proto_tree *tree, tvbuff_t *tvb, guint *offset, guint8 version);
extern const value_string zbee_zdp_cluster_names[];
extern const value_string zbee_zdp_rtg_status_vals[];
#endif /* PACKET_ZBEE_ZDP_H */