1 /* packet-zbee-zdp-management.c
2 * Dissector helper routines for the management services of the ZigBee Device Profile
3 * By Owen Kirby <osk@exegin.com>
4 * Copyright 2009 Exegin Technologies Limited
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1998 Gerald Combs
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
30 #endif /* HAVE_CONFIG_H */
36 #include <epan/packet.h>
38 #include "packet-zbee.h"
39 #include "packet-zbee-zdp.h"
41 /**************************************
43 **************************************
45 /*FUNCTION:------------------------------------------------------
49 * Parses and displays a single network descriptor
51 * tvbuff_t *tvb - pointer to buffer containing raw packet.
52 * packet_into *pinfo - pointer to packet information fields
53 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
56 *---------------------------------------------------------------
59 zdp_parse_nwk_desc(proto_tree *tree, tvbuff_t *tvb, guint *offset, packet_info *pinfo)
61 proto_item *ti = NULL;
73 if (pinfo->zbee_stack_vers >= ZBEE_VERSION_2007) {
74 /* Extended PAN Identifiers are used in ZigBee 2006 & later. */
75 ext_pan = tvb_get_letoh64(tvb, *offset + len);
76 if (tree) ti = proto_tree_add_text(tree, tvb, *offset, 0, "{Pan: %s", print_eui64(ext_pan));
77 len += sizeof(guint64);
80 /* Short PAN Identifiers are used in ZigBee 2003 and earlier. */
81 pan = tvb_get_letohs(tvb, *offset + len);
82 if (tree) ti = proto_tree_add_text(tree, tvb, *offset, 0, "{Pan: 0x%04x", pan);
83 len += sizeof(guint16);
86 channel = tvb_get_guint8(tvb, *offset + len);
87 if (tree) proto_item_append_text(ti, ", Channel: %d", channel);
88 len += sizeof(guint8);
90 profile = (tvb_get_guint8(tvb, *offset + len) & 0x0f) >> 0;
91 version = (tvb_get_guint8(tvb, *offset + len) & 0xf0) >> 4;
92 if (tree) proto_item_append_text(ti, ", Profile: 0x%01x, Version: %d", profile, version);
93 len += sizeof(guint8);
95 beacon = (tvb_get_guint8(tvb, *offset + len) & 0x0f) >> 0;
96 superframe = (tvb_get_guint8(tvb, *offset + len) & 0xf0) >> 4;
97 if ((tree) && (beacon == 0xf)) {
98 proto_item_append_text(ti, ", Beacons Disabled");
101 proto_item_append_text(ti, ", BeaconOrder: %d, SuperframeOrder: %d", beacon, superframe);
103 len += sizeof(guint8);
105 permit = tvb_get_guint8(tvb, *offset) & 0x01;
106 if (tree) proto_item_append_text(ti, ", PermitJoining: %s}", permit?"True":"False");
107 len += sizeof(guint8);
109 if (tree) proto_item_set_len(ti, len);
111 } /* zdp_parse_nwk_desc */
113 /*FUNCTION:------------------------------------------------------
115 * zdp_parse_neighbor_table_entry
117 * Parses and displays a neighbor table entry.
119 * tvbuff_t *tvb - pointer to buffer containing raw packet.
120 * packet_into *pinfo - pointer to packet information fields
121 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
124 *---------------------------------------------------------------
127 zdp_parse_neighbor_table_entry(proto_tree *tree, tvbuff_t *tvb, guint *offset, packet_info *pinfo)
129 proto_item *ti = NULL;
139 guint8 permit_joining;
143 if (pinfo->zbee_stack_vers >= ZBEE_VERSION_2007) {
144 /* ZigBee 2006 & later use an extended PAN Identifier. */
145 ext_pan = tvb_get_letoh64(tvb, *offset + len);
146 if (tree) ti = proto_tree_add_text(tree, tvb, *offset, 0, "{Extended PAN: %s", print_eui64(ext_pan));
147 len += sizeof(guint64);
150 /* ZigBee 2003 & earlier use a short PAN Identifier. */
151 pan = tvb_get_letohs(tvb, *offset + len);
152 if (tree) ti = proto_tree_add_text(tree, tvb, *offset, 0, "{PAN: 0x%04x", pan);
153 len += sizeof(guint16);
156 ext_addr = tvb_get_letoh64(tvb, *offset + len);
157 if (tree) proto_item_append_text(ti, ", Extended Addr: %s", print_eui64_oui(ext_addr));
158 len += sizeof(guint64);
160 device = tvb_get_letohs(tvb, *offset + len);
161 if (tree) proto_item_append_text(ti, ", Addr: 0x%04x", device);
162 len += sizeof(guint16);
164 if (pinfo->zbee_stack_vers >= ZBEE_VERSION_2007) {
165 type = (tvb_get_guint8(tvb, *offset + len) & 0x03) >> 0;
166 idle_rx = (tvb_get_guint8(tvb, *offset + len) & 0x0c) >> 2;
167 rel = (tvb_get_guint8(tvb, *offset + len) & 0x70) >> 4;
170 type = (tvb_get_guint8(tvb, *offset + len) & 0x03) >> 0;
171 idle_rx = (tvb_get_guint8(tvb, *offset + len) & 0x04) >> 2;
172 rel = (tvb_get_guint8(tvb, *offset + len) & 0x18) >> 3;
175 if (type == 0x00) proto_item_append_text(ti, ", Type: Coordinator");
176 else if (type == 0x01) proto_item_append_text(ti, ", Type: Router");
177 else if (type == 0x02) proto_item_append_text(ti, ", Type: End Device");
178 else proto_item_append_text(ti, ", Type: Unknown");
180 if (idle_rx == 0x00) proto_item_append_text(ti, ", Idle Rx: False");
181 else if (idle_rx==0x01) proto_item_append_text(ti, ", Idle Rx: True");
182 else proto_item_append_text(ti, ", Idle Rx: Unknown");
184 if (rel == 0x00) proto_item_append_text(ti, ", Relationship: Parent");
185 else if (rel == 0x01) proto_item_append_text(ti, ", Relationship: Child");
186 else if (rel == 0x02) proto_item_append_text(ti, ", Relationship: Sibling");
187 else if (rel == 0x03) proto_item_append_text(ti, ", Relationship: None");
188 else if (rel == 0x04) proto_item_append_text(ti, ", Relationship: Previous Child");
189 else proto_item_append_text(ti, ", Relationship: Unknown");
191 len += sizeof(guint8);
193 if (pinfo->zbee_stack_vers <= ZBEE_VERSION_2004) {
194 /* In ZigBee 2003 & earlier, the depth field is before the permit joining field. */
195 depth = tvb_get_guint8(tvb, *offset + len);
196 if (tree) proto_item_append_text(ti, ", Depth: %d", depth);
197 len += sizeof(guint8);
200 permit_joining = (tvb_get_guint8(tvb, *offset + len) & 0x03) >> 0;
202 if (permit_joining == 0x00) proto_item_append_text(ti, ", Permit Joining: False");
203 else if (permit_joining == 0x01)proto_item_append_text(ti, ", Permit Joining: True");
204 else proto_item_append_text(ti, ", Permit Joining: Unknown");
206 len += sizeof(guint8);
208 if (pinfo->zbee_stack_vers >= ZBEE_VERSION_2007) {
209 /* In ZigBee 2006 & later, the depth field is after the permit joining field. */
210 depth = tvb_get_guint8(tvb, *offset + len);
211 if (tree) proto_item_append_text(ti, ", Depth: %d", depth);
212 len += sizeof(guint8);
215 lqi = tvb_get_guint8(tvb, *offset + len);
216 if (tree) proto_item_append_text(ti, ", LQI: %d}", lqi);
217 len += sizeof(guint8);
219 if (tree) proto_item_set_len(ti, len);
221 } /* zdp_parse_neighbor_table_entry */
223 /*FUNCTION:------------------------------------------------------
225 * zdp_parse_routing_table_entry
227 * Parses and displays a routing table entry.
229 * tvbuff_t *tvb - pointer to buffer containing raw packet.
230 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
233 *---------------------------------------------------------------
236 zdp_parse_routing_table_entry(proto_tree *tree, tvbuff_t *tvb, guint *offset)
238 proto_item *ti = NULL;
245 dest = tvb_get_letohs(tvb, *offset + len);
246 if (tree) ti = proto_tree_add_text(tree, tvb, *offset, 2*sizeof(guint16) + sizeof(guint8), "{Destination: 0x%04x", dest);
247 len += sizeof(guint16);
249 status = tvb_get_guint8(tvb, *offset + len);
250 next = tvb_get_letohs(tvb, *offset + len + sizeof(guint8));
252 /* Display the next hop first, because it looks a lot cleaner that way. */
253 proto_item_append_text(ti, ", Next Hop: 0x%04x", next);
255 if (status == 0x00) proto_item_append_text(ti, ", Status: Active}");
256 else if (status == 0x01)proto_item_append_text(ti, ", Status: Discovery Underway}");
257 else if (status == 0x02)proto_item_append_text(ti, ", Status: Discovery Failed}");
258 else if (status == 0x03)proto_item_append_text(ti, ", Status: Inactive}");
259 else proto_item_append_text(ti, ", Status: Unknown}");
261 len += sizeof(guint8) + sizeof(guint16);
264 } /* zdp_parse_routing_table_entry */
266 /*FUNCTION:------------------------------------------------------
268 * zdp_parse_bind_table_entry
270 * Parses and displays a single binding table entry.
272 * tvbuff_t *tvb - pointer to buffer containing raw packet.
273 * packet_into *pinfo - pointer to packet information fields
274 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
277 *---------------------------------------------------------------
279 extern void zdp_parse_bind_table_entry(proto_tree *tree, tvbuff_t *tvb, guint *offset, packet_info *pinfo);
281 /**************************************
282 * MANAGEMENT REQUESTS
283 **************************************
285 /*FUNCTION:------------------------------------------------------
287 * dissect_zbee_zdp_req_mgmt_nwk_disc
289 * ZigBee Device Profile dissector for the network discovery
290 * request. Cluster ID = 0x0030.
292 * tvbuff_t *tvb - pointer to buffer containing raw packet.
293 * packet_into *pinfo - pointer to packet information fields
294 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
297 *---------------------------------------------------------------
300 dissect_zbee_zdp_req_mgmt_nwk_disc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
310 /* Get the channel bitmap. */
311 channels = tvb_get_letohl(tvb, offset);
314 ti = proto_tree_add_text(tree, tvb, offset, sizeof(guint32), "Scan Channels: ");
316 for (i=0; i<27; i++) {
317 if (channels & (1<<i)) {
318 if (first) proto_item_append_text(ti, "%d", i);
319 else proto_item_append_text(ti, ", %d", i);
320 if (channels & (2<<i)) {
321 while ((channels&(2<<i)) && (i<26)) i++;
322 proto_item_append_text(ti, "-%d", i);
327 if (first) proto_item_append_text(ti, "None");
329 offset += sizeof(guint32);
331 duration = zbee_parse_uint(tree, hf_zbee_zdp_duration, tvb, &offset, sizeof(guint8), NULL);
332 index = zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, sizeof(guint8), NULL);
334 /* Dump any leftover bytes. */
335 zdp_dump_excess(tvb, offset, pinfo, tree);
336 } /* dissect_zbee_zdp_req_mgmt_nwk_disc */
338 /*FUNCTION:------------------------------------------------------
340 * dissect_zbee_zdp_req_mgmt_lqi
342 * ZigBee Device Profile dissector for the link quality information
343 * request. Cluster ID = 0x0031.
345 * tvbuff_t *tvb - pointer to buffer containing raw packet.
346 * packet_into *pinfo - pointer to packet information fields
347 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
350 *---------------------------------------------------------------
353 dissect_zbee_zdp_req_mgmt_lqi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
358 index = zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, sizeof(guint8), NULL);
360 /* Dump any leftover bytes. */
361 zdp_dump_excess(tvb, offset, pinfo, tree);
362 } /* dissect_zbee_zdp_req_mgmt_lqi */
364 /*FUNCTION:------------------------------------------------------
366 * dissect_zbee_zdp_req_mgmt_rtg
368 * ZigBee Device Profile dissector for the routing table
369 * request. Cluster ID = 0x0032.
371 * tvbuff_t *tvb - pointer to buffer containing raw packet.
372 * packet_into *pinfo - pointer to packet information fields
373 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
376 *---------------------------------------------------------------
379 dissect_zbee_zdp_req_mgmt_rtg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
384 index = zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, sizeof(guint8), NULL);
386 /* Dump any leftover bytes. */
387 zdp_dump_excess(tvb, offset, pinfo, tree);
388 } /* dissect_zbee_zdp_req_mgmt_rtg */
390 /*FUNCTION:------------------------------------------------------
392 * dissect_zbee_zdp_req_mgmt_bind
394 * ZigBee Device Profile dissector for the binding table
395 * request. Cluster ID = 0x0033.
397 * tvbuff_t *tvb - pointer to buffer containing raw packet.
398 * packet_into *pinfo - pointer to packet information fields
399 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
402 *---------------------------------------------------------------
405 dissect_zbee_zdp_req_mgmt_bind(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
410 index = zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, sizeof(guint8), NULL);
412 /* Dump any leftover bytes. */
413 zdp_dump_excess(tvb, offset, pinfo, tree);
414 } /* dissect_zbee_zdp_req_mgmt_bind */
416 /*FUNCTION:------------------------------------------------------
418 * dissect_zbee_zdp_req_mgmt_leave
420 * ZigBee Device Profile dissector for the leave request.
421 * Cluster ID = 0x0034.
423 * tvbuff_t *tvb - pointer to buffer containing raw packet.
424 * packet_into *pinfo - pointer to packet information fields
425 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
428 *---------------------------------------------------------------
431 dissect_zbee_zdp_req_mgmt_leave(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
437 ext_addr = zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, sizeof(guint64), NULL);
438 if (pinfo->zbee_stack_vers >= ZBEE_VERSION_2007) {
439 /* Flags present on ZigBee 2006 & later. */
440 flags = tvb_get_guint8(tvb, offset);
442 proto_tree_add_boolean(tree, hf_zbee_zdp_leave_children, tvb, offset, sizeof(guint8), flags & ZBEE_ZDP_MGMT_LEAVE_CHILDREN);
443 proto_tree_add_boolean(tree, hf_zbee_zdp_leave_rejoin, tvb, offset, sizeof(guint8), flags & ZBEE_ZDP_MGMT_LEAVE_REJOIN);
445 offset += sizeof(guint8);
448 zbee_append_info(tree, pinfo, ", Device: %s", print_eui64_oui(ext_addr));
450 /* Dump any leftover bytes. */
451 zdp_dump_excess(tvb, offset, pinfo, tree);
452 } /* dissect_zbee_zdp_req_mgmt_bind */
454 /*FUNCTION:------------------------------------------------------
456 * dissect_zbee_zdp_req_mgmt_direct_join
458 * ZigBee Device Profile dissector for the direct join request.
459 * Cluster ID = 0x0035.
461 * tvbuff_t *tvb - pointer to buffer containing raw packet.
462 * packet_into *pinfo - pointer to packet information fields
463 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
466 *---------------------------------------------------------------
469 dissect_zbee_zdp_req_mgmt_direct_join(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
475 ext_addr = zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, sizeof(guint64), NULL);
476 cinfo = zdp_parse_cinfo(tree, ett_zbee_zdp_cinfo, tvb, &offset);
478 zbee_append_info(tree, pinfo, ", Device: %s", print_eui64_oui(ext_addr));
480 /* Dump any leftover bytes. */
481 zdp_dump_excess(tvb, offset, pinfo, tree);
482 } /* dissect_zbee_zdp_req_mgmt_direct_join */
484 /*FUNCTION:------------------------------------------------------
486 * dissect_zbee_zdp_req_mgmt_permit_join
488 * ZigBee Device Profile dissector for the permit joining
489 * request. Cluster ID = 0x0036.
491 * tvbuff_t *tvb - pointer to buffer containing raw packet.
492 * packet_into *pinfo - pointer to packet information fields
493 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
496 *---------------------------------------------------------------
499 dissect_zbee_zdp_req_mgmt_permit_join(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
505 duration = zbee_parse_uint(tree, hf_zbee_zdp_duration, tvb, &offset, sizeof(guint8), NULL);
506 significance = zbee_parse_uint(tree, hf_zbee_zdp_significance, tvb, &offset, sizeof(guint8), NULL);
508 /* Dump any leftover bytes. */
509 zdp_dump_excess(tvb, offset, pinfo, tree);
510 } /* dissect_zbee_zdp_req_mgmt_permit_join */
512 /*FUNCTION:------------------------------------------------------
514 * dissect_zbee_zdp_req_mgmt_cache
516 * ZigBee Device Profile dissector for the cache request.
517 * Cluster ID = 0x0037.
519 * tvbuff_t *tvb - pointer to buffer containing raw packet.
520 * packet_into *pinfo - pointer to packet information fields
521 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
524 *---------------------------------------------------------------
527 dissect_zbee_zdp_req_mgmt_cache(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
532 index = zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, sizeof(guint8), NULL);
534 /* Dump any leftover bytes. */
535 zdp_dump_excess(tvb, offset, pinfo, tree);
536 } /* dissect_zbee_zdp_req_mgmt_cache */
538 /*FUNCTION:------------------------------------------------------
540 * dissect_zbee_zdp_req_mgmt_nwkupdate
542 * ZigBee Device Profile dissector for the nwk update request.
543 * Cluster ID = 0x0038.
545 * tvbuff_t *tvb - pointer to buffer containing raw packet.
546 * packet_into *pinfo - pointer to packet information fields
547 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
550 *---------------------------------------------------------------
553 dissect_zbee_zdp_req_mgmt_nwkupdate(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
562 channels = zdp_parse_chanmask(tree, tvb, &offset);
563 duration = zbee_parse_uint(tree, hf_zbee_zdp_duration, tvb, &offset, sizeof(guint8), NULL);
564 if (duration == ZBEE_ZDP_NWKUPDATE_PARAMETERS) {
565 update_id = zbee_parse_uint(tree, hf_zbee_zdp_update_id, tvb, &offset, sizeof(guint8), NULL);
566 manager = zbee_parse_uint(tree, hf_zbee_zdp_manager, tvb, &offset, sizeof(guint16), NULL);
568 else if (duration == ZBEE_ZDP_NWKUPDATE_CHANNEL_HOP) {
569 update_id = zbee_parse_uint(tree, hf_zbee_zdp_update_id, tvb, &offset, sizeof(guint8), NULL);
571 else if (duration <= ZBEE_ZDP_NWKUPDATE_SCAN_MAX) {
572 count = zbee_parse_uint(tree, hf_zbee_zdp_scan_count, tvb, &offset, sizeof(guint8), NULL);
575 /* Dump any leftover bytes. */
576 zdp_dump_excess(tvb, offset, pinfo, tree);
577 } /* dissect_zbee_zdp_req_mgmt_nwkupdate */
579 /**************************************
580 * MANAGEMENT RESPONSES
581 **************************************
583 /*FUNCTION:------------------------------------------------------
585 * dissect_zbee_zdp_rsp_mgmt_nwk_disc
587 * ZigBee Device Profile dissector for the network discovery
588 * response. Cluster ID = 0x8030.
590 * tvbuff_t *tvb - pointer to buffer containing raw packet.
591 * packet_into *pinfo - pointer to packet information fields
592 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
595 *---------------------------------------------------------------
598 dissect_zbee_zdp_rsp_mgmt_nwk_disc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
601 proto_tree *field_tree = NULL;
610 status = zdp_parse_status(tree, tvb, &offset);
611 table_size = zbee_parse_uint(tree, hf_zbee_zdp_table_size, tvb, &offset, sizeof(guint8), NULL);
612 index = zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, sizeof(guint8), NULL);
613 table_count = zbee_parse_uint(tree, hf_zbee_zdp_table_count, tvb, &offset, sizeof(guint8), NULL);
615 if (tree && table_count) {
616 ti = proto_tree_add_text(tree, tvb, offset, tvb_length_remaining(tvb, offset), "Network List");
617 field_tree = proto_item_add_subtree(ti, ett_zbee_zdp_nwk);
619 for (i=0; i<table_count; i++) {
620 zdp_parse_nwk_desc(field_tree, tvb, &offset, pinfo);
623 zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
625 /* Dump any leftover bytes. */
626 zdp_dump_excess(tvb, offset, pinfo, tree);
627 } /* dissect_zbee_zdp_rsp_mgmt_nwk_disc */
629 /*FUNCTION:------------------------------------------------------
631 * dissect_zbee_zdp_rsp_mgmt_lqi
633 * ZigBee Device Profile dissector for the link quality information
634 * response. Cluster ID = 0x8031.
636 * tvbuff_t *tvb - pointer to buffer containing raw packet.
637 * packet_into *pinfo - pointer to packet information fields
638 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
641 *---------------------------------------------------------------
644 dissect_zbee_zdp_rsp_mgmt_lqi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
647 proto_tree *field_tree = NULL;
656 status = zdp_parse_status(tree, tvb, &offset);
657 table_size = zbee_parse_uint(tree, hf_zbee_zdp_table_size, tvb, &offset, sizeof(guint8), NULL);
658 index = zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, sizeof(guint8), NULL);
659 table_count = zbee_parse_uint(tree, hf_zbee_zdp_table_count, tvb, &offset, sizeof(guint8), NULL);
661 if (tree && table_count) {
662 ti = proto_tree_add_text(tree, tvb, offset, tvb_length_remaining(tvb, offset), "Neighbor Table");
663 field_tree = proto_item_add_subtree(ti, ett_zbee_zdp_lqi);
665 for (i=0; i<table_count; i++) {
666 zdp_parse_neighbor_table_entry(field_tree, tvb, &offset, pinfo);
669 zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
671 /* Dump any leftover bytes. */
672 zdp_dump_excess(tvb, offset, pinfo, tree);
673 } /* dissect_zbee_zdp_rsp_mgmt_lqi */
675 /*FUNCTION:------------------------------------------------------
677 * dissect_zbee_zdp_rsp_mgmt_rtg
679 * ZigBee Device Profile dissector for the routing table
680 * response. Cluster ID = 0x8032.
682 * tvbuff_t *tvb - pointer to buffer containing raw packet.
683 * packet_into *pinfo - pointer to packet information fields
684 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
687 *---------------------------------------------------------------
690 dissect_zbee_zdp_rsp_mgmt_rtg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
693 proto_tree *field_tree = NULL;
702 status = zdp_parse_status(tree, tvb, &offset);
703 table_size = zbee_parse_uint(tree, hf_zbee_zdp_table_size, tvb, &offset, sizeof(guint8), NULL);
704 index = zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, sizeof(guint8), NULL);
705 table_count = zbee_parse_uint(tree, hf_zbee_zdp_table_count, tvb, &offset, sizeof(guint8), NULL);
707 if (tree && table_count) {
708 ti = proto_tree_add_text(tree, tvb, offset, tvb_length_remaining(tvb, offset), "Routing Table");
709 field_tree = proto_item_add_subtree(ti, ett_zbee_zdp_rtg);
711 for (i=0; i<table_count; i++) {
712 zdp_parse_routing_table_entry(field_tree, tvb, &offset);
715 zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
717 /* Dump any leftover bytes. */
718 zdp_dump_excess(tvb, offset, pinfo, tree);
719 } /* dissect_zbee_zdp_rsp_mgmt_rtg */
721 /*FUNCTION:------------------------------------------------------
723 * dissect_zbee_zdp_rsp_mgmt_bind
725 * ZigBee Device Profile dissector for the binding table
726 * response. Cluster ID = 0x8033.
728 * tvbuff_t *tvb - pointer to buffer containing raw packet.
729 * packet_into *pinfo - pointer to packet information fields
730 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
733 *---------------------------------------------------------------
736 dissect_zbee_zdp_rsp_mgmt_bind(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
739 proto_tree *field_tree = NULL;
748 status = zdp_parse_status(tree, tvb, &offset);
749 table_size = zbee_parse_uint(tree, hf_zbee_zdp_table_size, tvb, &offset, sizeof(guint8), NULL);
750 index = zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, sizeof(guint8), NULL);
751 table_count = zbee_parse_uint(tree, hf_zbee_zdp_table_count, tvb, &offset, sizeof(guint8), NULL);
753 if (tree && table_count) {
754 ti = proto_tree_add_text(tree, tvb, offset, tvb_length_remaining(tvb, offset), "Binding Table");
755 field_tree = proto_item_add_subtree(ti, ett_zbee_zdp_bind);
757 for (i=0; i<table_count; i++) {
758 zdp_parse_bind_table_entry(field_tree, tvb, &offset, pinfo);
761 zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
763 /* Dump any leftover bytes. */
764 zdp_dump_excess(tvb, offset, pinfo, tree);
765 } /* dissect_zbee_zdp_rsp_mgmt_bind */
767 /*FUNCTION:------------------------------------------------------
769 * dissect_zbee_zdp_rsp_mgmt_leave
771 * ZigBee Device Profile dissector for the leave response.
772 * Cluster ID = 0x8034.
774 * tvbuff_t *tvb - pointer to buffer containing raw packet.
775 * packet_into *pinfo - pointer to packet information fields
776 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
779 *---------------------------------------------------------------
782 dissect_zbee_zdp_rsp_mgmt_leave(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
787 status = zdp_parse_status(tree, tvb, &offset);
789 zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
791 /* Dump any leftover bytes. */
792 zdp_dump_excess(tvb, offset, pinfo, tree);
793 } /* dissect_zbee_zdp_rsp_mgmt_bind */
795 /*FUNCTION:------------------------------------------------------
797 * dissect_zbee_zdp_rsp_mgmt_direct_join
799 * ZigBee Device Profile dissector for the direct join response.
800 * Cluster ID = 0x8035.
802 * tvbuff_t *tvb - pointer to buffer containing raw packet.
803 * packet_into *pinfo - pointer to packet information fields
804 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
807 *---------------------------------------------------------------
810 dissect_zbee_zdp_rsp_mgmt_direct_join(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
815 status = zdp_parse_status(tree, tvb, &offset);
817 zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
819 /* Dump any leftover bytes. */
820 zdp_dump_excess(tvb, offset, pinfo, tree);
821 } /* dissect_zbee_zdp_rsp_mgmt_direct_join */
823 /*FUNCTION:------------------------------------------------------
825 * dissect_zbee_zdp_rsp_mgmt_permit_join
827 * ZigBee Device Profile dissector for the permit joining response.
828 * Cluster ID = 0x8036.
830 * tvbuff_t *tvb - pointer to buffer containing raw packet.
831 * packet_into *pinfo - pointer to packet information fields
832 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
835 *---------------------------------------------------------------
838 dissect_zbee_zdp_rsp_mgmt_permit_join(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
843 status = zdp_parse_status(tree, tvb, &offset);
845 zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
847 /* Dump any leftover bytes. */
848 zdp_dump_excess(tvb, offset, pinfo, tree);
849 } /* dissect_zbee_zdp_rsp_mgmt_permit_join */
851 /*FUNCTION:------------------------------------------------------
853 * dissect_zbee_zdp_rsp_mgmt_cache
855 * ZigBee Device Profile dissector for the cache response.
856 * Cluster ID = 0x8037.
858 * tvbuff_t *tvb - pointer to buffer containing raw packet.
859 * packet_into *pinfo - pointer to packet information fields
860 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
863 *---------------------------------------------------------------
866 dissect_zbee_zdp_rsp_mgmt_cache(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
869 proto_tree *field_tree;
878 status = zdp_parse_status(tree, tvb, &offset);
879 table_size = zbee_parse_uint(tree, hf_zbee_zdp_table_size, tvb, &offset, sizeof(guint8), NULL);
880 index = zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, sizeof(guint8), NULL);
881 table_count = zbee_parse_uint(tree, hf_zbee_zdp_table_count, tvb, &offset, sizeof(guint8), NULL);
883 if (tree && table_count) {
884 ti = proto_tree_add_text(tree, tvb, offset, table_count*(sizeof(guint16)+sizeof(guint64)), "Discovery Cache");
885 field_tree = proto_item_add_subtree(ti, ett_zbee_zdp_cache);
887 for (i=0; i<table_count; i++) {
888 guint64 addr64 = tvb_get_letoh64(tvb, offset);
889 guint16 addr16 = tvb_get_letohs(tvb, offset+sizeof(guint64));
892 proto_tree_add_text(tree, tvb, offset, sizeof(guint16)+sizeof(guint64), "{%s = 0x%04x}", print_eui64_oui(addr64), addr16);
894 offset += sizeof(guint16)+sizeof(guint64);
897 zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
899 /* Dump any leftover bytes. */
900 zdp_dump_excess(tvb, offset, pinfo, tree);
901 } /* dissect_zbee_zdp_rsp_mgmt_bind */
903 /*FUNCTION:------------------------------------------------------
905 * dissect_zbee_zdp_rsp_mgmt_nwkupdate
907 * ZigBee Device Profile dissector for the nwk update notify.
908 * Cluster ID = 0x8038.
910 * tvbuff_t *tvb - pointer to buffer containing raw packet.
911 * packet_into *pinfo - pointer to packet information fields
912 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
915 *---------------------------------------------------------------
918 dissect_zbee_zdp_rsp_mgmt_nwkupdate(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
927 guint8 channel_count;
929 status = zdp_parse_status(tree, tvb, &offset);
930 channels = zdp_parse_chanmask(tree, tvb, &offset);
931 tx_total = zbee_parse_uint(tree, hf_zbee_zdp_tx_total, tvb, &offset, sizeof(guint16), NULL);
932 tx_fail = zbee_parse_uint(tree, hf_zbee_zdp_tx_fail, tvb, &offset, sizeof(guint16), NULL);
933 channel_count = zbee_parse_uint(tree, hf_zbee_zdp_channel_count, tvb, &offset, sizeof(guint8), NULL);
935 /* Display the channel list. */
936 for (i=0, j=0; i<(8*sizeof(guint32)); i++) {
939 if ( ! ((1<<i) & channels) ) {
940 /* Channel not scanned. */
943 if (j>=channel_count) {
944 /* Channel list has ended. */
947 /* Get and display the channel energy. */
948 energy = tvb_get_guint8(tvb, offset);
950 proto_tree_add_text(tree, tvb, offset, sizeof(guint8), "Channel %d Energy = 0x%02x", i, energy);
952 offset += sizeof(guint8);
953 /* Increment the number of channels we found energy values for. */
957 /* Dump any leftover bytes. */
958 zdp_dump_excess(tvb, offset, pinfo, tree);
959 } /* dissect_zbee_zdp_rsp_mgmt_nwkupdate */