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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
32 #include <epan/packet.h>
33 #include <epan/addr_resolv.h>
35 #include "packet-zbee.h"
36 #include "packet-zbee-zdp.h"
38 /**************************************
40 **************************************
42 /*FUNCTION:------------------------------------------------------
46 * Parses and displays a single network descriptor
48 * tvbuff_t *tvb - pointer to buffer containing raw packet.
49 * packet_into *pinfo - pointer to packet information fields
50 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
53 *---------------------------------------------------------------
56 zdp_parse_nwk_desc(proto_tree
*tree
, tvbuff_t
*tvb
, guint
*offset
, guint8 version
)
58 proto_item
*ti
= NULL
;
65 guint8 profile_version
;
70 if (version
>= ZBEE_VERSION_2007
) {
71 /* Extended PAN Identifiers are used in ZigBee 2006 & later. */
72 ext_pan
= tvb_get_letoh64(tvb
, *offset
+ len
);
73 if (tree
) ti
= proto_tree_add_text(tree
, tvb
, *offset
, 0, "{Pan: %s", eui64_to_str(ext_pan
));
74 len
+= (int)sizeof(guint64
);
77 /* Short PAN Identifiers are used in ZigBee 2003 and earlier. */
78 pan
= tvb_get_letohs(tvb
, *offset
+ len
);
79 if (tree
) ti
= proto_tree_add_text(tree
, tvb
, *offset
, 0, "{Pan: 0x%04x", pan
);
80 len
+= (int)sizeof(guint16
);
83 channel
= tvb_get_guint8(tvb
, *offset
+ len
);
84 if (tree
) proto_item_append_text(ti
, ", Channel: %d", channel
);
85 len
+= (int)sizeof(guint8
);
87 profile
= (tvb_get_guint8(tvb
, *offset
+ len
) & 0x0f) >> 0;
88 profile_version
= (tvb_get_guint8(tvb
, *offset
+ len
) & 0xf0) >> 4;
89 if (tree
) proto_item_append_text(ti
, ", Profile: 0x%01x, Version: %d", profile
, profile_version
);
90 len
+= (int)sizeof(guint8
);
92 beacon
= (tvb_get_guint8(tvb
, *offset
+ len
) & 0x0f) >> 0;
93 superframe
= (tvb_get_guint8(tvb
, *offset
+ len
) & 0xf0) >> 4;
94 if ((tree
) && (beacon
== 0xf)) {
95 proto_item_append_text(ti
, ", Beacons Disabled");
98 proto_item_append_text(ti
, ", BeaconOrder: %d, SuperframeOrder: %d", beacon
, superframe
);
100 len
+= (int)sizeof(guint8
);
102 permit
= tvb_get_guint8(tvb
, *offset
) & 0x01;
103 if (tree
) proto_item_append_text(ti
, ", PermitJoining: %s}", permit
?"True":"False");
104 len
+= (int)sizeof(guint8
);
106 if (tree
) proto_item_set_len(ti
, len
);
108 } /* zdp_parse_nwk_desc */
110 /*FUNCTION:------------------------------------------------------
112 * zdp_parse_neighbor_table_entry
114 * Parses and displays a neighbor table entry.
116 * tvbuff_t *tvb - pointer to buffer containing raw packet.
117 * packet_into *pinfo - pointer to packet information fields
118 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
121 *---------------------------------------------------------------
124 zdp_parse_neighbor_table_entry(proto_tree
*tree
, tvbuff_t
*tvb
, guint
*offset
, guint8 version
)
126 proto_item
*ti
= NULL
;
136 guint8 permit_joining
;
140 if (version
>= ZBEE_VERSION_2007
) {
141 /* ZigBee 2006 & later use an extended PAN Identifier. */
142 ext_pan
= tvb_get_letoh64(tvb
, *offset
+ len
);
143 if (tree
) ti
= proto_tree_add_text(tree
, tvb
, *offset
, 0, "{Extended PAN: %s", eui64_to_str(ext_pan
));
144 len
+= (int)sizeof(guint64
);
147 /* ZigBee 2003 & earlier use a short PAN Identifier. */
148 pan
= tvb_get_letohs(tvb
, *offset
+ len
);
149 if (tree
) ti
= proto_tree_add_text(tree
, tvb
, *offset
, 0, "{PAN: 0x%04x", pan
);
150 len
+= (int)sizeof(guint16
);
153 ext_addr
= tvb_get_letoh64(tvb
, *offset
+ len
);
154 if (tree
) proto_item_append_text(ti
, ", Extended Addr: %s", get_eui64_name(ext_addr
));
155 len
+= (int)sizeof(guint64
);
157 device
= tvb_get_letohs(tvb
, *offset
+ len
);
158 if (tree
) proto_item_append_text(ti
, ", Addr: 0x%04x", device
);
159 len
+= (int)sizeof(guint16
);
161 if (version
>= ZBEE_VERSION_2007
) {
162 type
= (tvb_get_guint8(tvb
, *offset
+ len
) & 0x03) >> 0;
163 idle_rx
= (tvb_get_guint8(tvb
, *offset
+ len
) & 0x0c) >> 2;
164 rel
= (tvb_get_guint8(tvb
, *offset
+ len
) & 0x70) >> 4;
167 type
= (tvb_get_guint8(tvb
, *offset
+ len
) & 0x03) >> 0;
168 idle_rx
= (tvb_get_guint8(tvb
, *offset
+ len
) & 0x04) >> 2;
169 rel
= (tvb_get_guint8(tvb
, *offset
+ len
) & 0x18) >> 3;
172 if (type
== 0x00) proto_item_append_text(ti
, ", Type: Coordinator");
173 else if (type
== 0x01) proto_item_append_text(ti
, ", Type: Router");
174 else if (type
== 0x02) proto_item_append_text(ti
, ", Type: End Device");
175 else proto_item_append_text(ti
, ", Type: Unknown");
177 if (idle_rx
== 0x00) proto_item_append_text(ti
, ", Idle Rx: False");
178 else if (idle_rx
==0x01) proto_item_append_text(ti
, ", Idle Rx: True");
179 else proto_item_append_text(ti
, ", Idle Rx: Unknown");
181 if (rel
== 0x00) proto_item_append_text(ti
, ", Relationship: Parent");
182 else if (rel
== 0x01) proto_item_append_text(ti
, ", Relationship: Child");
183 else if (rel
== 0x02) proto_item_append_text(ti
, ", Relationship: Sibling");
184 else if (rel
== 0x03) proto_item_append_text(ti
, ", Relationship: None");
185 else if (rel
== 0x04) proto_item_append_text(ti
, ", Relationship: Previous Child");
186 else proto_item_append_text(ti
, ", Relationship: Unknown");
188 len
+= (int)sizeof(guint8
);
190 if (version
<= ZBEE_VERSION_2004
) {
191 /* In ZigBee 2003 & earlier, the depth field is before the permit joining field. */
192 depth
= tvb_get_guint8(tvb
, *offset
+ len
);
193 if (tree
) proto_item_append_text(ti
, ", Depth: %d", depth
);
194 len
+= (int)sizeof(guint8
);
197 permit_joining
= (tvb_get_guint8(tvb
, *offset
+ len
) & 0x03) >> 0;
199 if (permit_joining
== 0x00) proto_item_append_text(ti
, ", Permit Joining: False");
200 else if (permit_joining
== 0x01)proto_item_append_text(ti
, ", Permit Joining: True");
201 else proto_item_append_text(ti
, ", Permit Joining: Unknown");
203 len
+= (int)sizeof(guint8
);
205 if (version
>= ZBEE_VERSION_2007
) {
206 /* In ZigBee 2006 & later, the depth field is after the permit joining field. */
207 depth
= tvb_get_guint8(tvb
, *offset
+ len
);
208 if (tree
) proto_item_append_text(ti
, ", Depth: %d", depth
);
209 len
+= (int)sizeof(guint8
);
212 lqi
= tvb_get_guint8(tvb
, *offset
+ len
);
213 if (tree
) proto_item_append_text(ti
, ", LQI: %d}", lqi
);
214 len
+= (int)sizeof(guint8
);
216 if (tree
) proto_item_set_len(ti
, len
);
218 } /* zdp_parse_neighbor_table_entry */
220 /*FUNCTION:------------------------------------------------------
222 * zdp_parse_routing_table_entry
224 * Parses and displays a routing table entry.
226 * tvbuff_t *tvb - pointer to buffer containing raw packet.
227 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
230 *---------------------------------------------------------------
233 zdp_parse_routing_table_entry(proto_tree
*tree
, tvbuff_t
*tvb
, guint
*offset
)
235 proto_item
*ti
= NULL
;
242 dest
= tvb_get_letohs(tvb
, *offset
+ len
);
243 if (tree
) ti
= proto_tree_add_text(tree
, tvb
, *offset
, 2*(int)sizeof(guint16
) + (int)sizeof(guint8
), "{Destination: 0x%04x", dest
);
244 len
+= (int)sizeof(guint16
);
246 status
= tvb_get_guint8(tvb
, *offset
+ len
);
247 next
= tvb_get_letohs(tvb
, *offset
+ len
+ (int)sizeof(guint8
));
249 /* Display the next hop first, because it looks a lot cleaner that way. */
250 proto_item_append_text(ti
, ", Next Hop: 0x%04x", next
);
252 if (status
== 0x00) proto_item_append_text(ti
, ", Status: Active}");
253 else if (status
== 0x01)proto_item_append_text(ti
, ", Status: Discovery Underway}");
254 else if (status
== 0x02)proto_item_append_text(ti
, ", Status: Discovery Failed}");
255 else if (status
== 0x03)proto_item_append_text(ti
, ", Status: Inactive}");
256 else proto_item_append_text(ti
, ", Status: Unknown}");
258 len
+= (int)sizeof(guint8
) + (int)sizeof(guint16
);
261 } /* zdp_parse_routing_table_entry */
263 /*FUNCTION:------------------------------------------------------
265 * zdp_parse_bind_table_entry
267 * Parses and displays a single binding table entry.
269 * tvbuff_t *tvb - pointer to buffer containing raw packet.
270 * packet_into *pinfo - pointer to packet information fields
271 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
274 *---------------------------------------------------------------
276 extern void zdp_parse_bind_table_entry(proto_tree
*tree
, tvbuff_t
*tvb
, guint
*offset
, guint8 version
);
278 /**************************************
279 * MANAGEMENT REQUESTS
280 **************************************
282 /*FUNCTION:------------------------------------------------------
284 * dissect_zbee_zdp_req_mgmt_nwk_disc
286 * ZigBee Device Profile dissector for the network discovery
287 * request. Cluster ID = 0x0030.
289 * tvbuff_t *tvb - pointer to buffer containing raw packet.
290 * packet_into *pinfo - pointer to packet information fields
291 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
294 *---------------------------------------------------------------
297 dissect_zbee_zdp_req_mgmt_nwk_disc(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
307 /* Get the channel bitmap. */
308 channels
= tvb_get_letohl(tvb
, offset
);
311 ti
= proto_tree_add_text(tree
, tvb
, offset
, (int)sizeof(guint32
), "Scan Channels: ");
313 for (i
=0; i
<27; i
++) {
314 if (channels
& (1<<i
)) {
315 if (first
) proto_item_append_text(ti
, "%d", i
);
316 else proto_item_append_text(ti
, ", %d", i
);
317 if (channels
& (2<<i
)) {
318 while ((channels
&(2<<i
)) && (i
<26)) i
++;
319 proto_item_append_text(ti
, "-%d", i
);
324 if (first
) proto_item_append_text(ti
, "None");
326 offset
+= (int)sizeof(guint32
);
328 /*duration =*/ zbee_parse_uint(tree
, hf_zbee_zdp_duration
, tvb
, &offset
, (int)sizeof(guint8
), NULL
);
329 /*idx =*/ zbee_parse_uint(tree
, hf_zbee_zdp_index
, tvb
, &offset
, (int)sizeof(guint8
), NULL
);
331 /* Dump any leftover bytes. */
332 zdp_dump_excess(tvb
, offset
, pinfo
, tree
);
333 } /* dissect_zbee_zdp_req_mgmt_nwk_disc */
335 /*FUNCTION:------------------------------------------------------
337 * dissect_zbee_zdp_req_mgmt_lqi
339 * ZigBee Device Profile dissector for the link quality information
340 * request. Cluster ID = 0x0031.
342 * tvbuff_t *tvb - pointer to buffer containing raw packet.
343 * packet_into *pinfo - pointer to packet information fields
344 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
347 *---------------------------------------------------------------
350 dissect_zbee_zdp_req_mgmt_lqi(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
355 /*idx =*/ zbee_parse_uint(tree
, hf_zbee_zdp_index
, tvb
, &offset
, (int)sizeof(guint8
), NULL
);
357 /* Dump any leftover bytes. */
358 zdp_dump_excess(tvb
, offset
, pinfo
, tree
);
359 } /* dissect_zbee_zdp_req_mgmt_lqi */
361 /*FUNCTION:------------------------------------------------------
363 * dissect_zbee_zdp_req_mgmt_rtg
365 * ZigBee Device Profile dissector for the routing table
366 * request. Cluster ID = 0x0032.
368 * tvbuff_t *tvb - pointer to buffer containing raw packet.
369 * packet_into *pinfo - pointer to packet information fields
370 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
373 *---------------------------------------------------------------
376 dissect_zbee_zdp_req_mgmt_rtg(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
381 /*idx =*/ zbee_parse_uint(tree
, hf_zbee_zdp_index
, tvb
, &offset
, (int)sizeof(guint8
), NULL
);
383 /* Dump any leftover bytes. */
384 zdp_dump_excess(tvb
, offset
, pinfo
, tree
);
385 } /* dissect_zbee_zdp_req_mgmt_rtg */
387 /*FUNCTION:------------------------------------------------------
389 * dissect_zbee_zdp_req_mgmt_bind
391 * ZigBee Device Profile dissector for the binding table
392 * request. Cluster ID = 0x0033.
394 * tvbuff_t *tvb - pointer to buffer containing raw packet.
395 * packet_into *pinfo - pointer to packet information fields
396 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
399 *---------------------------------------------------------------
402 dissect_zbee_zdp_req_mgmt_bind(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
407 /*idx =*/ zbee_parse_uint(tree
, hf_zbee_zdp_index
, tvb
, &offset
, (int)sizeof(guint8
), NULL
);
409 /* Dump any leftover bytes. */
410 zdp_dump_excess(tvb
, offset
, pinfo
, tree
);
411 } /* dissect_zbee_zdp_req_mgmt_bind */
413 /*FUNCTION:------------------------------------------------------
415 * dissect_zbee_zdp_req_mgmt_leave
417 * ZigBee Device Profile dissector for the leave request.
418 * Cluster ID = 0x0034.
420 * tvbuff_t *tvb - pointer to buffer containing raw packet.
421 * packet_into *pinfo - pointer to packet information fields
422 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
425 *---------------------------------------------------------------
428 dissect_zbee_zdp_req_mgmt_leave(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, guint8 version
)
434 ext_addr
= zbee_parse_eui64(tree
, hf_zbee_zdp_ext_addr
, tvb
, &offset
, (int)sizeof(guint64
), NULL
);
435 if (version
>= ZBEE_VERSION_2007
) {
436 /* Flags present on ZigBee 2006 & later. */
437 flags
= tvb_get_guint8(tvb
, offset
);
439 proto_tree_add_boolean(tree
, hf_zbee_zdp_leave_children
, tvb
, offset
, (int)sizeof(guint8
), flags
& ZBEE_ZDP_MGMT_LEAVE_CHILDREN
);
440 proto_tree_add_boolean(tree
, hf_zbee_zdp_leave_rejoin
, tvb
, offset
, (int)sizeof(guint8
), flags
& ZBEE_ZDP_MGMT_LEAVE_REJOIN
);
442 offset
+= (int)sizeof(guint8
);
445 zbee_append_info(tree
, pinfo
, ", Device: %s", get_eui64_name(ext_addr
));
447 /* Dump any leftover bytes. */
448 zdp_dump_excess(tvb
, offset
, pinfo
, tree
);
449 } /* dissect_zbee_zdp_req_mgmt_bind */
451 /*FUNCTION:------------------------------------------------------
453 * dissect_zbee_zdp_req_mgmt_direct_join
455 * ZigBee Device Profile dissector for the direct join request.
456 * Cluster ID = 0x0035.
458 * tvbuff_t *tvb - pointer to buffer containing raw packet.
459 * packet_into *pinfo - pointer to packet information fields
460 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
463 *---------------------------------------------------------------
466 dissect_zbee_zdp_req_mgmt_direct_join(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
472 ext_addr
= zbee_parse_eui64(tree
, hf_zbee_zdp_ext_addr
, tvb
, &offset
, (int)sizeof(guint64
), NULL
);
473 /*cinfo =*/ zdp_parse_cinfo(tree
, ett_zbee_zdp_cinfo
, tvb
, &offset
);
475 zbee_append_info(tree
, pinfo
, ", Device: %s", get_eui64_name(ext_addr
));
477 /* Dump any leftover bytes. */
478 zdp_dump_excess(tvb
, offset
, pinfo
, tree
);
479 } /* dissect_zbee_zdp_req_mgmt_direct_join */
481 /*FUNCTION:------------------------------------------------------
483 * dissect_zbee_zdp_req_mgmt_permit_join
485 * ZigBee Device Profile dissector for the permit joining
486 * request. Cluster ID = 0x0036.
488 * tvbuff_t *tvb - pointer to buffer containing raw packet.
489 * packet_into *pinfo - pointer to packet information fields
490 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
493 *---------------------------------------------------------------
496 dissect_zbee_zdp_req_mgmt_permit_join(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
500 /*guint8 significance;*/
502 /*duration =*/ zbee_parse_uint(tree
, hf_zbee_zdp_duration
, tvb
, &offset
, (int)sizeof(guint8
), NULL
);
503 /*significance =*/ zbee_parse_uint(tree
, hf_zbee_zdp_significance
, tvb
, &offset
, (int)sizeof(guint8
), NULL
);
505 /* Dump any leftover bytes. */
506 zdp_dump_excess(tvb
, offset
, pinfo
, tree
);
507 } /* dissect_zbee_zdp_req_mgmt_permit_join */
509 /*FUNCTION:------------------------------------------------------
511 * dissect_zbee_zdp_req_mgmt_cache
513 * ZigBee Device Profile dissector for the cache request.
514 * Cluster ID = 0x0037.
516 * tvbuff_t *tvb - pointer to buffer containing raw packet.
517 * packet_into *pinfo - pointer to packet information fields
518 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
521 *---------------------------------------------------------------
524 dissect_zbee_zdp_req_mgmt_cache(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
529 /*idx =*/ zbee_parse_uint(tree
, hf_zbee_zdp_index
, tvb
, &offset
, (int)sizeof(guint8
), NULL
);
531 /* Dump any leftover bytes. */
532 zdp_dump_excess(tvb
, offset
, pinfo
, tree
);
533 } /* dissect_zbee_zdp_req_mgmt_cache */
535 /*FUNCTION:------------------------------------------------------
537 * dissect_zbee_zdp_req_mgmt_nwkupdate
539 * ZigBee Device Profile dissector for the nwk update request.
540 * Cluster ID = 0x0038.
542 * tvbuff_t *tvb - pointer to buffer containing raw packet.
543 * packet_into *pinfo - pointer to packet information fields
544 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
547 *---------------------------------------------------------------
550 dissect_zbee_zdp_req_mgmt_nwkupdate(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
553 /*guint32 channels;*/
556 /*guint8 update_id;*/
559 /*channels =*/ zdp_parse_chanmask(tree
, tvb
, &offset
);
560 duration
= zbee_parse_uint(tree
, hf_zbee_zdp_duration
, tvb
, &offset
, (int)sizeof(guint8
), NULL
);
561 if (duration
== ZBEE_ZDP_NWKUPDATE_PARAMETERS
) {
562 /*update_id =*/ zbee_parse_uint(tree
, hf_zbee_zdp_update_id
, tvb
, &offset
, (int)sizeof(guint8
), NULL
);
563 /*manager =*/ zbee_parse_uint(tree
, hf_zbee_zdp_manager
, tvb
, &offset
, (int)sizeof(guint16
), NULL
);
565 else if (duration
== ZBEE_ZDP_NWKUPDATE_CHANNEL_HOP
) {
566 /*update_id =*/ zbee_parse_uint(tree
, hf_zbee_zdp_update_id
, tvb
, &offset
, (int)sizeof(guint8
), NULL
);
568 else if (duration
<= ZBEE_ZDP_NWKUPDATE_SCAN_MAX
) {
569 /*count =*/ zbee_parse_uint(tree
, hf_zbee_zdp_scan_count
, tvb
, &offset
, (int)sizeof(guint8
), NULL
);
572 /* Dump any leftover bytes. */
573 zdp_dump_excess(tvb
, offset
, pinfo
, tree
);
574 } /* dissect_zbee_zdp_req_mgmt_nwkupdate */
576 /**************************************
577 * MANAGEMENT RESPONSES
578 **************************************
580 /*FUNCTION:------------------------------------------------------
582 * dissect_zbee_zdp_rsp_mgmt_nwk_disc
584 * ZigBee Device Profile dissector for the network discovery
585 * response. Cluster ID = 0x8030.
587 * tvbuff_t *tvb - pointer to buffer containing raw packet.
588 * packet_into *pinfo - pointer to packet information fields
589 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
592 *---------------------------------------------------------------
595 dissect_zbee_zdp_rsp_mgmt_nwk_disc(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, guint8 version
)
598 proto_tree
*field_tree
= NULL
;
603 /*guint8 table_size;*/
607 status
= zdp_parse_status(tree
, tvb
, &offset
);
608 /*table_size =*/ zbee_parse_uint(tree
, hf_zbee_zdp_table_size
, tvb
, &offset
, (int)sizeof(guint8
), NULL
);
609 /*idx =*/ zbee_parse_uint(tree
, hf_zbee_zdp_index
, tvb
, &offset
, (int)sizeof(guint8
), NULL
);
610 table_count
= zbee_parse_uint(tree
, hf_zbee_zdp_table_count
, tvb
, &offset
, (int)sizeof(guint8
), NULL
);
612 if (tree
&& table_count
) {
613 ti
= proto_tree_add_text(tree
, tvb
, offset
, tvb_length_remaining(tvb
, offset
), "Network List");
614 field_tree
= proto_item_add_subtree(ti
, ett_zbee_zdp_nwk
);
616 for (i
=0; i
<table_count
; i
++) {
617 zdp_parse_nwk_desc(field_tree
, tvb
, &offset
, version
);
620 zbee_append_info(tree
, pinfo
, ", Status: %s", zdp_status_name(status
));
622 /* Dump any leftover bytes. */
623 zdp_dump_excess(tvb
, offset
, pinfo
, tree
);
624 } /* dissect_zbee_zdp_rsp_mgmt_nwk_disc */
626 /*FUNCTION:------------------------------------------------------
628 * dissect_zbee_zdp_rsp_mgmt_lqi
630 * ZigBee Device Profile dissector for the link quality information
631 * response. Cluster ID = 0x8031.
633 * tvbuff_t *tvb - pointer to buffer containing raw packet.
634 * packet_into *pinfo - pointer to packet information fields
635 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
638 *---------------------------------------------------------------
641 dissect_zbee_zdp_rsp_mgmt_lqi(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, guint8 version
)
644 proto_tree
*field_tree
= NULL
;
649 /*guint8 table_size;*/
653 status
= zdp_parse_status(tree
, tvb
, &offset
);
654 /*table_size =*/ zbee_parse_uint(tree
, hf_zbee_zdp_table_size
, tvb
, &offset
, (int)sizeof(guint8
), NULL
);
655 /*idx =*/ zbee_parse_uint(tree
, hf_zbee_zdp_index
, tvb
, &offset
, (int)sizeof(guint8
), NULL
);
656 table_count
= zbee_parse_uint(tree
, hf_zbee_zdp_table_count
, tvb
, &offset
, (int)sizeof(guint8
), NULL
);
658 if (tree
&& table_count
) {
659 ti
= proto_tree_add_text(tree
, tvb
, offset
, tvb_length_remaining(tvb
, offset
), "Neighbor Table");
660 field_tree
= proto_item_add_subtree(ti
, ett_zbee_zdp_lqi
);
662 for (i
=0; i
<table_count
; i
++) {
663 zdp_parse_neighbor_table_entry(field_tree
, tvb
, &offset
, version
);
666 zbee_append_info(tree
, pinfo
, ", Status: %s", zdp_status_name(status
));
668 /* Dump any leftover bytes. */
669 zdp_dump_excess(tvb
, offset
, pinfo
, tree
);
670 } /* dissect_zbee_zdp_rsp_mgmt_lqi */
672 /*FUNCTION:------------------------------------------------------
674 * dissect_zbee_zdp_rsp_mgmt_rtg
676 * ZigBee Device Profile dissector for the routing table
677 * response. Cluster ID = 0x8032.
679 * tvbuff_t *tvb - pointer to buffer containing raw packet.
680 * packet_into *pinfo - pointer to packet information fields
681 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
684 *---------------------------------------------------------------
687 dissect_zbee_zdp_rsp_mgmt_rtg(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
690 proto_tree
*field_tree
= NULL
;
695 /*guint8 table_size;*/
699 status
= zdp_parse_status(tree
, tvb
, &offset
);
700 /*table_size =*/ zbee_parse_uint(tree
, hf_zbee_zdp_table_size
, tvb
, &offset
, (int)sizeof(guint8
), NULL
);
701 /*idx =*/ zbee_parse_uint(tree
, hf_zbee_zdp_index
, tvb
, &offset
, (int)sizeof(guint8
), NULL
);
702 table_count
= zbee_parse_uint(tree
, hf_zbee_zdp_table_count
, tvb
, &offset
, (int)sizeof(guint8
), NULL
);
704 if (tree
&& table_count
) {
705 ti
= proto_tree_add_text(tree
, tvb
, offset
, tvb_length_remaining(tvb
, offset
), "Routing Table");
706 field_tree
= proto_item_add_subtree(ti
, ett_zbee_zdp_rtg
);
708 for (i
=0; i
<table_count
; i
++) {
709 zdp_parse_routing_table_entry(field_tree
, tvb
, &offset
);
712 zbee_append_info(tree
, pinfo
, ", Status: %s", zdp_status_name(status
));
714 /* Dump any leftover bytes. */
715 zdp_dump_excess(tvb
, offset
, pinfo
, tree
);
716 } /* dissect_zbee_zdp_rsp_mgmt_rtg */
718 /*FUNCTION:------------------------------------------------------
720 * dissect_zbee_zdp_rsp_mgmt_bind
722 * ZigBee Device Profile dissector for the binding table
723 * response. Cluster ID = 0x8033.
725 * tvbuff_t *tvb - pointer to buffer containing raw packet.
726 * packet_into *pinfo - pointer to packet information fields
727 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
730 *---------------------------------------------------------------
733 dissect_zbee_zdp_rsp_mgmt_bind(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, guint8 version
)
736 proto_tree
*field_tree
= NULL
;
741 /*guint8 table_size;*/
745 status
= zdp_parse_status(tree
, tvb
, &offset
);
746 /*table_size =*/ zbee_parse_uint(tree
, hf_zbee_zdp_table_size
, tvb
, &offset
, (int)sizeof(guint8
), NULL
);
747 /*idx =*/ zbee_parse_uint(tree
, hf_zbee_zdp_index
, tvb
, &offset
, (int)sizeof(guint8
), NULL
);
748 table_count
= zbee_parse_uint(tree
, hf_zbee_zdp_table_count
, tvb
, &offset
, (int)sizeof(guint8
), NULL
);
750 if (tree
&& table_count
) {
751 ti
= proto_tree_add_text(tree
, tvb
, offset
, tvb_length_remaining(tvb
, offset
), "Binding Table");
752 field_tree
= proto_item_add_subtree(ti
, ett_zbee_zdp_bind
);
754 for (i
=0; i
<table_count
; i
++) {
755 zdp_parse_bind_table_entry(field_tree
, tvb
, &offset
, version
);
758 zbee_append_info(tree
, pinfo
, ", Status: %s", zdp_status_name(status
));
760 /* Dump any leftover bytes. */
761 zdp_dump_excess(tvb
, offset
, pinfo
, tree
);
762 } /* dissect_zbee_zdp_rsp_mgmt_bind */
764 /*FUNCTION:------------------------------------------------------
766 * dissect_zbee_zdp_rsp_mgmt_leave
768 * ZigBee Device Profile dissector for the leave response.
769 * Cluster ID = 0x8034.
771 * tvbuff_t *tvb - pointer to buffer containing raw packet.
772 * packet_into *pinfo - pointer to packet information fields
773 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
776 *---------------------------------------------------------------
779 dissect_zbee_zdp_rsp_mgmt_leave(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
784 status
= zdp_parse_status(tree
, tvb
, &offset
);
786 zbee_append_info(tree
, pinfo
, ", Status: %s", zdp_status_name(status
));
788 /* Dump any leftover bytes. */
789 zdp_dump_excess(tvb
, offset
, pinfo
, tree
);
790 } /* dissect_zbee_zdp_rsp_mgmt_bind */
792 /*FUNCTION:------------------------------------------------------
794 * dissect_zbee_zdp_rsp_mgmt_direct_join
796 * ZigBee Device Profile dissector for the direct join response.
797 * Cluster ID = 0x8035.
799 * tvbuff_t *tvb - pointer to buffer containing raw packet.
800 * packet_into *pinfo - pointer to packet information fields
801 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
804 *---------------------------------------------------------------
807 dissect_zbee_zdp_rsp_mgmt_direct_join(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
812 status
= zdp_parse_status(tree
, tvb
, &offset
);
814 zbee_append_info(tree
, pinfo
, ", Status: %s", zdp_status_name(status
));
816 /* Dump any leftover bytes. */
817 zdp_dump_excess(tvb
, offset
, pinfo
, tree
);
818 } /* dissect_zbee_zdp_rsp_mgmt_direct_join */
820 /*FUNCTION:------------------------------------------------------
822 * dissect_zbee_zdp_rsp_mgmt_permit_join
824 * ZigBee Device Profile dissector for the permit joining response.
825 * Cluster ID = 0x8036.
827 * tvbuff_t *tvb - pointer to buffer containing raw packet.
828 * packet_into *pinfo - pointer to packet information fields
829 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
832 *---------------------------------------------------------------
835 dissect_zbee_zdp_rsp_mgmt_permit_join(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
840 status
= zdp_parse_status(tree
, tvb
, &offset
);
842 zbee_append_info(tree
, pinfo
, ", Status: %s", zdp_status_name(status
));
844 /* Dump any leftover bytes. */
845 zdp_dump_excess(tvb
, offset
, pinfo
, tree
);
846 } /* dissect_zbee_zdp_rsp_mgmt_permit_join */
848 /*FUNCTION:------------------------------------------------------
850 * dissect_zbee_zdp_rsp_mgmt_cache
852 * ZigBee Device Profile dissector for the cache response.
853 * Cluster ID = 0x8037.
855 * tvbuff_t *tvb - pointer to buffer containing raw packet.
856 * packet_into *pinfo - pointer to packet information fields
857 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
860 *---------------------------------------------------------------
863 dissect_zbee_zdp_rsp_mgmt_cache(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
866 proto_tree
*field_tree
;
871 /*guint8 table_size;*/
875 status
= zdp_parse_status(tree
, tvb
, &offset
);
876 /*table_size =*/ zbee_parse_uint(tree
, hf_zbee_zdp_table_size
, tvb
, &offset
, (int)sizeof(guint8
), NULL
);
877 /*idx =*/ zbee_parse_uint(tree
, hf_zbee_zdp_index
, tvb
, &offset
, (int)sizeof(guint8
), NULL
);
878 table_count
= zbee_parse_uint(tree
, hf_zbee_zdp_table_count
, tvb
, &offset
, (int)sizeof(guint8
), NULL
);
880 if (tree
&& table_count
) {
881 ti
= proto_tree_add_text(tree
, tvb
, offset
, table_count
*((int)sizeof(guint16
)+(int)sizeof(guint64
)), "Discovery Cache");
882 field_tree
= proto_item_add_subtree(ti
, ett_zbee_zdp_cache
);
886 for (i
=0; i
<table_count
; i
++) {
887 guint64 addr64
= tvb_get_letoh64(tvb
, offset
);
888 guint16 addr16
= tvb_get_letohs(tvb
, offset
+(int)sizeof(guint64
));
891 proto_tree_add_text(field_tree
, tvb
, offset
, (int)sizeof(guint16
)+(int)sizeof(guint64
), "{%s = 0x%04x}", get_eui64_name(addr64
), addr16
);
893 offset
+= (int)sizeof(guint16
)+(int)sizeof(guint64
);
896 zbee_append_info(tree
, pinfo
, ", Status: %s", zdp_status_name(status
));
898 /* Dump any leftover bytes. */
899 zdp_dump_excess(tvb
, offset
, pinfo
, tree
);
900 } /* dissect_zbee_zdp_rsp_mgmt_bind */
902 /*FUNCTION:------------------------------------------------------
904 * dissect_zbee_zdp_rsp_mgmt_nwkupdate
906 * ZigBee Device Profile dissector for the nwk update notify.
907 * Cluster ID = 0x8038.
909 * tvbuff_t *tvb - pointer to buffer containing raw packet.
910 * packet_into *pinfo - pointer to packet information fields
911 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
914 *---------------------------------------------------------------
917 dissect_zbee_zdp_rsp_mgmt_nwkupdate(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
924 /*guint16 tx_total;*/
926 guint8 channel_count
;
928 /*status =*/ zdp_parse_status(tree
, tvb
, &offset
);
929 channels
= zdp_parse_chanmask(tree
, tvb
, &offset
);
930 /*tx_total =*/ zbee_parse_uint(tree
, hf_zbee_zdp_tx_total
, tvb
, &offset
, (int)sizeof(guint16
), NULL
);
931 /*tx_fail =*/ zbee_parse_uint(tree
, hf_zbee_zdp_tx_fail
, tvb
, &offset
, (int)sizeof(guint16
), NULL
);
932 channel_count
= zbee_parse_uint(tree
, hf_zbee_zdp_channel_count
, tvb
, &offset
, (int)sizeof(guint8
), NULL
);
934 /* Display the channel list. */
935 for (i
=0, j
=0; i
<(8*(int)sizeof(guint32
)); i
++) {
938 if ( ! ((1<<i
) & channels
) ) {
939 /* Channel not scanned. */
942 if (j
>=channel_count
) {
943 /* Channel list has ended. */
946 /* Get and display the channel energy. */
947 energy
= tvb_get_guint8(tvb
, offset
);
949 proto_tree_add_text(tree
, tvb
, offset
, (int)sizeof(guint8
), "Channel %d Energy = 0x%02x", i
, energy
);
951 offset
+= (int)sizeof(guint8
);
952 /* Increment the number of channels we found energy values for. */
956 /* Dump any leftover bytes. */
957 zdp_dump_excess(tvb
, offset
, pinfo
, tree
);
958 } /* dissect_zbee_zdp_rsp_mgmt_nwkupdate */