Add FT_EUI64 Field Type
[obnox/wireshark/wip.git] / epan / dissectors / packet-zbee-zdp-discovery.c
1 /* packet-zbee-zdp-discovery.c
2  * Dissector helper routines for the discovery services of the ZigBee Device Profile
3  * By Owen Kirby <osk@exegin.com>
4  * Copyright 2009 Exegin Technologies Limited
5  *
6  * $Id$
7  *
8  * Wireshark - Network traffic analyzer
9  * By Gerald Combs <gerald@wireshark.org>
10  * Copyright 1998 Gerald Combs
11  *
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.
16  *
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.
21  *
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.
25  */
26
27 /*  Include Files */
28 #ifdef HAVE_CONFIG_H
29 #include "config.h"
30 #endif /* HAVE_CONFIG_H */
31
32 #include <stdlib.h>
33 #include <glib.h>
34 #include <gmodule.h>
35 #include <epan/packet.h>
36 #include <epan/addr_resolv.h>
37
38 #include "packet-zbee.h"
39 #include "packet-zbee-zdp.h"
40
41 /**************************************
42  * DISCOVERY REQUESTS
43  **************************************
44  */
45 /*FUNCTION:------------------------------------------------------
46  *  NAME
47  *      dissect_zbee_zdp_req_nwk_addr
48  *  DESCRIPTION
49  *      ZigBee Device Profile dissector for the network address
50  *      request. Cluster ID = 0x0000.
51  *  PARAMETERS
52  *      tvbuff_t *tvb       - pointer to buffer containing raw packet.
53  *      packet_into *pinfo  - pointer to packet information fields
54  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
55  *  RETURNS
56  *      void
57  *---------------------------------------------------------------
58  */
59 void
60 dissect_zbee_zdp_req_nwk_addr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
61 {
62     guint       offset = 0;
63
64     guint64 ext_addr;
65     guint8  req_type;
66     guint8  idx;
67
68     ext_addr = zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, sizeof(guint64), NULL);
69     req_type = zbee_parse_uint(tree, hf_zbee_zdp_req_type, tvb, &offset, sizeof(guint8), NULL);
70     idx      = zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, sizeof(guint8), NULL);
71
72     zbee_append_info(tree, pinfo, ", Device: %s", get_eui64_name(ext_addr));
73
74     /* Dump any leftover bytes. */
75     zdp_dump_excess(tvb, offset, pinfo, tree);
76 } /* dissect_zbee_zdp_req_nwk_addr */
77
78 /*FUNCTION:------------------------------------------------------
79  *  NAME
80  *      dissect_zbee_zdp_req_ext_addr
81  *  DESCRIPTION
82  *      ZigBee Device Profile dissector for the extended address
83  *      request. Cluster ID = 0x0001.
84  *  PARAMETERS
85  *      tvbuff_t *tvb       - pointer to buffer containing raw packet.
86  *      packet_into *pinfo  - pointer to packet information fields
87  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
88  *  RETURNS
89  *      void
90  *---------------------------------------------------------------
91  */
92 void
93 dissect_zbee_zdp_req_ext_addr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
94 {
95     guint       offset = 0;
96
97     guint16 device;
98     guint8  req_type;
99     guint8  idx;
100
101     device   = zbee_parse_uint(tree, hf_zbee_zdp_device, tvb, &offset, sizeof(guint16), NULL);
102     req_type = zbee_parse_uint(tree, hf_zbee_zdp_req_type, tvb, &offset, sizeof(guint8), NULL);
103     idx      = zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, sizeof(guint8), NULL);
104
105     zbee_append_info(tree, pinfo, ", Device: 0x%04x", device);
106
107     /* Dump any leftover bytes. */
108     zdp_dump_excess(tvb, offset, pinfo, tree);
109 } /* dissect_zbee_zdp_req_ext_addr */
110
111 /*FUNCTION:------------------------------------------------------
112  *  NAME
113  *      dissect_zbee_zdp_req_desc
114  *  DESCRIPTION
115  *      ZigBee Device Profile dissector for the descriptor
116  *      requests. Cluster ID = 0x0002.
117  *  PARAMETERS
118  *      tvbuff_t *tvb       - pointer to buffer containing raw packet.
119  *      packet_into *pinfo  - pointer to packet information fields
120  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
121  *  RETURNS
122  *      void
123  *---------------------------------------------------------------
124  */
125 void
126 dissect_zbee_zdp_req_node_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
127 {
128     guint   offset = 0;
129     guint16 device;
130
131     device = zbee_parse_uint(tree, hf_zbee_zdp_device, tvb, &offset, sizeof(guint16), NULL);
132
133     zbee_append_info(tree, pinfo, ", Device: 0x%04x", device);
134
135     /* Dump any leftover bytes. */
136     zdp_dump_excess(tvb, offset, pinfo, tree);
137 } /* dissect_zbee_zdp_req_node_desc */
138
139 /*FUNCTION:------------------------------------------------------
140  *  NAME
141  *      dissect_zbee_zdp_req_power_desc
142  *  DESCRIPTION
143  *      ZigBee Device Profile dissector for the node descriptor
144  *      request. Cluster ID = 0x0003.
145  *  PARAMETERS
146  *      tvbuff_t *tvb       - pointer to buffer containing raw packet.
147  *      packet_into *pinfo  - pointer to packet information fields
148  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
149  *  RETURNS
150  *      void
151  *---------------------------------------------------------------
152  */
153 void
154 dissect_zbee_zdp_req_power_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
155 {
156     guint   offset = 0;
157     guint16 device;
158
159     device = zbee_parse_uint(tree, hf_zbee_zdp_device, tvb, &offset, sizeof(guint16), NULL);
160
161     zbee_append_info(tree, pinfo, ", Device: 0x%04x", device);
162
163     /* Dump any leftover bytes. */
164     zdp_dump_excess(tvb, offset, pinfo, tree);
165 } /* dissect_zbee_zdp_req_power_desc */
166
167 /*FUNCTION:------------------------------------------------------
168  *  NAME
169  *      dissect_zbee_zdp_req_simple_desc
170  *  DESCRIPTION
171  *      ZigBee Device Profile dissector for the simple descriptor
172  *      request. Cluster ID = 0x0004.
173  *  PARAMETERS
174  *      tvbuff_t *tvb       - pointer to buffer containing raw packet.
175  *      packet_into *pinfo  - pointer to packet information fields
176  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
177  *  RETURNS
178  *      void
179  *---------------------------------------------------------------
180  */
181 void
182 dissect_zbee_zdp_req_simple_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
183 {
184     guint   offset = 0;
185     guint16 device;
186     guint8  endpt;
187
188     device = zbee_parse_uint(tree, hf_zbee_zdp_device, tvb, &offset, sizeof(guint16), NULL);
189     endpt  = zbee_parse_uint(tree, hf_zbee_zdp_endpoint, tvb, &offset, sizeof(guint8), NULL);
190
191     zbee_append_info(tree, pinfo, ", Device: 0x%04x, Endpoint: %d", device, endpt);
192
193     /* Dump any leftover bytes. */
194     zdp_dump_excess(tvb, offset, pinfo, tree);
195 } /* dissect_zbee_zdp_req_simple_desc */
196
197 /*FUNCTION:------------------------------------------------------
198  *  NAME
199  *      dissect_zbee_zdp_req_active_ep
200  *  DESCRIPTION
201  *      ZigBee Device Profile dissector for the active endpoint list
202  *      request. Cluster ID = 0x0005.
203  *  PARAMETERS
204  *      tvbuff_t *tvb       - pointer to buffer containing raw packet.
205  *      packet_into *pinfo  - pointer to packet information fields
206  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
207  *  RETURNS
208  *      void
209  *---------------------------------------------------------------
210  */
211 void
212 dissect_zbee_zdp_req_active_ep(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
213 {
214     guint   offset = 0;
215     guint16 device;
216
217     device = zbee_parse_uint(tree, hf_zbee_zdp_device, tvb, &offset, sizeof(guint16), NULL);
218
219     zbee_append_info(tree, pinfo, ", Device: 0x%04x", device);
220
221     /* Dump any leftover bytes. */
222     zdp_dump_excess(tvb, offset, pinfo, tree);
223 } /* dissect_zbee_zdp_req_active_ep */
224
225 /*FUNCTION:------------------------------------------------------
226  *  NAME
227  *      dissect_zbee_zdp_req_match_desc
228  *  DESCRIPTION
229  *      ZigBee Device Profile dissector for the matching descriptor
230  *      request. Cluster ID = 0x0006.
231  *  PARAMETERS
232  *      tvbuff_t *tvb       - pointer to buffer containing raw packet.
233  *      packet_into *pinfo  - pointer to packet information fields
234  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
235  *  RETURNS
236  *      void
237  *---------------------------------------------------------------
238  */
239 void
240 dissect_zbee_zdp_req_match_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
241 {
242     proto_item      *ti;
243     proto_tree      *field_tree = NULL;
244     guint           offset = 0, i;
245     guint           sizeof_cluster = (pinfo->zbee_stack_vers >= ZBEE_VERSION_2007)?sizeof(guint16):sizeof(guint8);
246
247     guint16 device;
248     guint16 profile;
249     guint8  in_count;
250     guint8  out_count;
251
252     device  = zbee_parse_uint(tree, hf_zbee_zdp_device, tvb, &offset, sizeof(guint16), NULL);
253     profile = zbee_parse_uint(tree, hf_zbee_zdp_profile, tvb, &offset, sizeof(guint16), NULL);
254
255     /* Add the input cluster list. */
256     in_count = zbee_parse_uint(tree, hf_zbee_zdp_in_count, tvb, &offset, sizeof(guint8), NULL);
257     if (tree && in_count) {
258         ti = proto_tree_add_text(tree, tvb, offset, in_count*sizeof_cluster, "Input Cluster List");
259         field_tree = proto_item_add_subtree(ti, ett_zbee_zdp_match_in);
260     }
261     for (i=0; i<in_count; i++) zbee_parse_uint(field_tree, hf_zbee_zdp_in_cluster, tvb, &offset, sizeof_cluster, NULL);
262
263     /* Add the output cluster list. */
264     out_count = zbee_parse_uint(tree, hf_zbee_zdp_out_count, tvb, &offset, sizeof(guint8), NULL);
265     if (tree && out_count) {
266         ti = proto_tree_add_text(tree, tvb, offset, out_count*sizeof_cluster, "Output Cluster List");
267         field_tree = proto_item_add_subtree(ti, ett_zbee_zdp_match_out);
268     }
269     for (i=0; i<out_count; i++) zbee_parse_uint(field_tree, hf_zbee_zdp_out_cluster, tvb, &offset, sizeof_cluster, NULL);
270
271     zbee_append_info(tree, pinfo, ", Device: 0x%04x, Profile: 0x%04x", device, profile);
272
273     /* Dump any leftover bytes. */
274     zdp_dump_excess(tvb, offset, pinfo, tree);
275 } /* dissect_zbee_zdp_req_simple_desc */
276
277 /*FUNCTION:------------------------------------------------------
278  *  NAME
279  *      dissect_zbee_zdp_req_complex_desc
280  *  DESCRIPTION
281  *      ZigBee Device Profile dissector for the complex descriptor
282  *      request. Cluster ID = 0x0010.
283  *  PARAMETERS
284  *      tvbuff_t *tvb       - pointer to buffer containing raw packet.
285  *      packet_into *pinfo  - pointer to packet information fields
286  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
287  *  RETURNS
288  *      void
289  *---------------------------------------------------------------
290  */
291 void
292 dissect_zbee_zdp_req_complex_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
293 {
294     guint   offset = 0;
295     guint16 device;
296
297     device = zbee_parse_uint(tree, hf_zbee_zdp_device, tvb, &offset, sizeof(guint16), NULL);
298
299     zbee_append_info(tree, pinfo, ", Device: 0x%04x", device);
300
301     /* Dump any leftover bytes. */
302     zdp_dump_excess(tvb, offset, pinfo, tree);
303 } /* dissect_zbee_zdp_req_complex_desc */
304
305 /*FUNCTION:------------------------------------------------------
306  *  NAME
307  *      dissect_zbee_zdp_req_user_desc
308  *  DESCRIPTION
309  *      ZigBee Device Profile dissector for the user descriptor
310  *      request. Cluster ID = 0x0011.
311  *  PARAMETERS
312  *      tvbuff_t *tvb       - pointer to buffer containing raw packet.
313  *      packet_into *pinfo  - pointer to packet information fields
314  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
315  *  RETURNS
316  *      void
317  *---------------------------------------------------------------
318  */
319 void
320 dissect_zbee_zdp_req_user_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
321 {
322     guint   offset = 0;
323     guint16 device;
324
325     device = zbee_parse_uint(tree, hf_zbee_zdp_device, tvb, &offset, sizeof(guint16), NULL);
326
327     zbee_append_info(tree, pinfo, ", Device: 0x%04x", device);
328
329     /* Dump any leftover bytes. */
330     zdp_dump_excess(tvb, offset, pinfo, tree);
331 } /* dissect_zbee_zdp_req_user_desc */
332
333 /*FUNCTION:------------------------------------------------------
334  *  NAME
335  *      dissect_zbee_zdp_req_discovery_cache
336  *  DESCRIPTION
337  *      ZigBee Device Profile dissector for the discovery cache
338  *      request. Cluster ID = 0x0012.
339  *  PARAMETERS
340  *      tvbuff_t *tvb       - pointer to buffer containing raw packet.
341  *      packet_into *pinfo  - pointer to packet information fields
342  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
343  *  RETURNS
344  *      void
345  *---------------------------------------------------------------
346  */
347 void
348 dissect_zbee_zdp_req_discovery_cache(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
349 {
350     guint   offset = 0;
351     guint16 device;
352     guint64 ext_addr;
353
354     device   = zbee_parse_uint(tree, hf_zbee_zdp_device, tvb, &offset, sizeof(guint16), NULL);
355     ext_addr = zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, sizeof(guint64), NULL);
356
357     zbee_append_info(tree, pinfo, ", Device: %s", get_eui64_name(ext_addr));
358
359     /* Dump any leftover bytes. */
360     zdp_dump_excess(tvb, offset, pinfo, tree);
361 } /* dissect_zbee_zdp_req_discovery_cache */
362
363 /*FUNCTION:------------------------------------------------------
364  *  NAME
365  *      dissect_zbee_zdp_device_annce
366  *  DESCRIPTION
367  *      ZigBee Device Profile dissector for the device announcement.
368  *      Cluster ID = 0x0013.
369  *  PARAMETERS
370  *      tvbuff_t *tvb       - pointer to buffer containing raw packet.
371  *      packet_into *pinfo  - pointer to packet information fields
372  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
373  *  RETURNS
374  *      void
375  *---------------------------------------------------------------
376  */
377 void
378 dissect_zbee_zdp_device_annce(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
379 {
380     guint   offset = 0;
381     guint16 device;
382     guint64 ext_addr;
383     guint8  capability;
384
385     device      = zbee_parse_uint(tree, hf_zbee_zdp_device, tvb, &offset, sizeof(guint16), NULL);
386     ext_addr    = zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, sizeof(guint64), NULL);
387     capability  = zdp_parse_cinfo(tree, ett_zbee_zdp_cinfo, tvb, &offset);
388
389     zbee_append_info(tree, pinfo, ", Device: %s", get_eui64_name(ext_addr));
390
391     /* Dump any leftover bytes. */
392     zdp_dump_excess(tvb, offset, pinfo, tree);
393 } /* dissect_zbee_zdp_device_annce */
394
395 /*FUNCTION:------------------------------------------------------
396  *  NAME
397  *      dissect_zbee_zdp_req_set_user_desc
398  *  DESCRIPTION
399  *      ZigBee Device Profile dissector for the end set user
400  *      descriptor request. Cluster ID = 0x0014.
401  *  PARAMETERS
402  *      tvbuff_t *tvb       - pointer to buffer containing raw packet.
403  *      packet_into *pinfo  - pointer to packet information fields
404  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
405  *  RETURNS
406  *      void
407  *---------------------------------------------------------------
408  */
409 void
410 dissect_zbee_zdp_req_set_user_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
411 {
412     guint   offset = 0;
413     guint16 device;
414     guint8  user_length;
415     gchar   *user;
416
417     device      = zbee_parse_uint(tree, hf_zbee_zdp_device, tvb, &offset, sizeof(guint16), NULL);
418     if (pinfo->zbee_stack_vers >= ZBEE_VERSION_2007) {
419         user_length = zbee_parse_uint(tree, hf_zbee_zdp_user_length, tvb, &offset, sizeof(guint8), NULL);
420     }
421     else {
422         /* No Length field in ZigBee 2003 & earlier, uses a fixed length of 16. */
423         user_length = 16;
424     }
425     user        = ep_alloc(user_length+1);
426     user        = tvb_memcpy(tvb, user, offset, user_length);
427     user[user_length] = '\0';
428     if (tree) {
429         proto_tree_add_string(tree, hf_zbee_zdp_user, tvb, offset, user_length, user);
430     }
431     offset += user_length;
432
433     zbee_append_info(tree, pinfo, ", Device: 0x%04x, Desc: \'%s\'", device, user);
434
435     /* Dump any leftover bytes. */
436     zdp_dump_excess(tvb, offset, pinfo, tree);
437 } /* dissect_zbee_zdp_req_set_user_desc */
438
439 /*FUNCTION:------------------------------------------------------
440  *  NAME
441  *      dissect_zbee_zdp_req_system_server_disc
442  *  DESCRIPTION
443  *      ZigBee Device Profile dissector for the system server
444  *      discovery request. Cluster ID = 0x0015.
445  *  PARAMETERS
446  *      tvbuff_t *tvb       - pointer to buffer containing raw packet.
447  *      packet_into *pinfo  - pointer to packet information fields
448  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
449  *  RETURNS
450  *      void
451  *---------------------------------------------------------------
452  */
453 void
454 dissect_zbee_zdp_req_system_server_disc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
455 {
456     guint   offset = 0;
457     guint16 server_flags;
458
459     server_flags = zdp_parse_server_flags(tree, ett_zbee_zdp_server, tvb, &offset);
460
461     /* Dump any leftover bytes. */
462     zdp_dump_excess(tvb, offset, pinfo, tree);
463 } /* dissect_zbee_zdp_req_system_server_disc */
464
465 /*FUNCTION:------------------------------------------------------
466  *  NAME
467  *      dissect_zbee_zdp_req_store_discovery
468  *  DESCRIPTION
469  *      ZigBee Device Profile dissector for the store node cache
470  *      request. Cluster ID = 0x0016.
471  *  PARAMETERS
472  *      tvbuff_t *tvb       - pointer to buffer containing raw packet.
473  *      packet_into *pinfo  - pointer to packet information fields
474  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
475  *  RETURNS
476  *      void
477  *---------------------------------------------------------------
478  */
479 void
480 dissect_zbee_zdp_req_store_discovery(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
481 {
482     proto_item  *ti;
483     proto_tree  *field_tree = NULL;
484     guint       offset = 0;
485     guint       i;
486
487     guint16 device;
488     guint64 ext_addr;
489     guint8  node_size;
490     guint8  power_size;
491     guint8  ep_count;
492     guint8  simple_count;
493
494     device      = zbee_parse_uint(tree, hf_zbee_zdp_device, tvb, &offset, sizeof(guint16), NULL);
495     ext_addr    = zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, sizeof(guint64), NULL);
496     node_size   = zbee_parse_uint(tree, hf_zbee_zdp_disc_node_size, tvb, &offset, sizeof(guint8), NULL);
497     power_size  = zbee_parse_uint(tree, hf_zbee_zdp_disc_power_size, tvb, &offset, sizeof(guint8), NULL);
498     ep_count    = zbee_parse_uint(tree, hf_zbee_zdp_disc_ep_count, tvb, &offset, sizeof(guint8), NULL);
499     simple_count= zbee_parse_uint(tree, hf_zbee_zdp_disc_simple_count, tvb, &offset, sizeof(guint8), NULL);
500
501     if (tree) {
502         ti = proto_tree_add_text(tree, tvb, offset, simple_count, "Simple Descriptor Sizes");
503         field_tree = proto_item_add_subtree(ti, ett_zbee_zdp_simple_sizes);
504     }
505     for (i=0; i<simple_count; i++) {
506         zbee_parse_uint(field_tree, hf_zbee_zdp_disc_simple_size, tvb, &offset, sizeof(guint8), NULL);
507     }
508
509     zbee_append_info(tree, pinfo, ", Device: %s", get_eui64_name(ext_addr));
510
511     /* Dump any leftover bytes. */
512     zdp_dump_excess(tvb, offset, pinfo, tree);
513 } /* dissect_zbee_zdp_req_store_discovery */
514
515 /*FUNCTION:------------------------------------------------------
516  *  NAME
517  *      dissect_zbee_zdp_req_store_node_desc
518  *  DESCRIPTION
519  *      ZigBee Device Profile dissector for the store node descriptor
520  *      request. Cluster ID = 0x0017.
521  *  PARAMETERS
522  *      tvbuff_t *tvb       - pointer to buffer containing raw packet.
523  *      packet_into *pinfo  - pointer to packet information fields
524  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
525  *  RETURNS
526  *      void
527  *---------------------------------------------------------------
528  */
529 void
530 dissect_zbee_zdp_req_store_node_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
531 {
532     guint   offset = 0;
533     guint16 device;
534     guint64 ext_addr;
535
536     device   = zbee_parse_uint(tree, hf_zbee_zdp_device, tvb, &offset, sizeof(guint16), NULL);
537     ext_addr = zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, sizeof(guint64), NULL);
538     zdp_parse_node_desc(tree, ett_zbee_zdp_node, tvb, &offset, pinfo);
539
540     zbee_append_info(tree, pinfo, ", Device: %s", get_eui64_name(ext_addr));
541
542     /* Dump any leftover bytes. */
543     zdp_dump_excess(tvb, offset, pinfo, tree);
544 } /* dissect_zbee_zdp_req_store_node_desc */
545
546 /*FUNCTION:------------------------------------------------------
547  *  NAME
548  *      dissect_zbee_zdp_req_store_power_desc
549  *  DESCRIPTION
550  *      ZigBee Device Profile dissector for the store power descriptor
551  *      request. Cluster ID = 0x0018.
552  *  PARAMETERS
553  *      tvbuff_t *tvb       - pointer to buffer containing raw packet.
554  *      packet_into *pinfo  - pointer to packet information fields
555  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
556  *  RETURNS
557  *      void
558  *---------------------------------------------------------------
559  */
560 void
561 dissect_zbee_zdp_req_store_power_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
562 {
563     guint   offset = 0;
564     guint16 device;
565     guint64 ext_addr;
566
567     device   = zbee_parse_uint(tree, hf_zbee_zdp_device, tvb, &offset, sizeof(guint16), NULL);
568     ext_addr = zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, sizeof(guint64), NULL);
569     zdp_parse_power_desc(tree, ett_zbee_zdp_power, tvb, &offset);
570
571     zbee_append_info(tree, pinfo, ", Device: %s", get_eui64_name(ext_addr));
572
573     /* Dump any leftover bytes. */
574     zdp_dump_excess(tvb, offset, pinfo, tree);
575 } /* dissect_zbee_zdp_req_store_power_desc */
576
577 /*FUNCTION:------------------------------------------------------
578  *  NAME
579  *      dissect_zbee_zdp_req_store_active_ep
580  *  DESCRIPTION
581  *      ZigBee Device Profile dissector for the store active endpoint
582  *      request. Cluster ID = 0x0019.
583  *  PARAMETERS
584  *      tvbuff_t *tvb       - pointer to buffer containing raw packet.
585  *      packet_into *pinfo  - pointer to packet information fields
586  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
587  *  RETURNS
588  *      void
589  *---------------------------------------------------------------
590  */
591 void
592 dissect_zbee_zdp_req_store_active_ep(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
593 {
594     proto_item  *ti;
595     proto_tree  *field_tree = NULL;
596     guint       offset = 0;
597     guint       i;
598
599     guint16     device;
600     guint64     ext_addr;
601     guint8      ep_count;
602
603     device   = zbee_parse_uint(tree, hf_zbee_zdp_device, tvb, &offset, sizeof(guint16), NULL);
604     ext_addr = zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, sizeof(guint64), NULL);
605     ep_count = zbee_parse_uint(tree, hf_zbee_zdp_ep_count, tvb, &offset, sizeof(guint8), NULL);
606
607     if (tree) {
608         ti = proto_tree_add_text(tree, tvb, offset, ep_count, "Active Endpoints");
609         field_tree = proto_item_add_subtree(ti, ett_zbee_zdp_endpoint);
610     }
611     for (i=0; i<ep_count; i++) {
612         (void)zbee_parse_uint(field_tree, hf_zbee_zdp_endpoint, tvb, &offset, sizeof(guint8), NULL);
613     }
614
615     zbee_append_info(tree, pinfo, ", Device: %s", get_eui64_name(ext_addr));
616
617     /* Dump any leftover bytes. */
618     zdp_dump_excess(tvb, offset, pinfo, tree);
619 } /* dissect_zbee_zdp_req_store_active_ep */
620
621 /*FUNCTION:------------------------------------------------------
622  *  NAME
623  *      dissect_zbee_zdp_req_store_simple_desc
624  *  DESCRIPTION
625  *      ZigBee Device Profile dissector for the store simple descriptor
626  *      request. Cluster ID = 0x001a.
627  *  PARAMETERS
628  *      tvbuff_t *tvb       - pointer to buffer containing raw packet.
629  *      packet_into *pinfo  - pointer to packet information fields
630  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
631  *  RETURNS
632  *      void
633  *---------------------------------------------------------------
634  */
635 void
636 dissect_zbee_zdp_req_store_simple_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
637 {
638     guint   offset = 0;
639     guint16 device;
640     guint64 ext_addr;
641     guint8  simple_len;
642
643     device      = zbee_parse_uint(tree, hf_zbee_zdp_device, tvb, &offset, sizeof(guint16), NULL);
644     ext_addr    = zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, sizeof(guint64), NULL);
645     simple_len  = zbee_parse_uint(tree, hf_zbee_zdp_simple_length, tvb, &offset, sizeof(guint8), NULL);
646     zdp_parse_simple_desc(tree, ett_zbee_zdp_simple, tvb, &offset, pinfo);
647
648     zbee_append_info(tree, pinfo, ", Device: %s", get_eui64_name(ext_addr));
649
650     /* Dump any leftover bytes. */
651     zdp_dump_excess(tvb, offset, pinfo, tree);
652 } /* dissect_zbee_zdp_req_store_simple_desc */
653
654 /*FUNCTION:------------------------------------------------------
655  *  NAME
656  *      dissect_zbee_zdp_req_remove_node_cache
657  *  DESCRIPTION
658  *      ZigBee Device Profile dissector for the remove node cache
659  *      request. Cluster ID = 0x001b.
660  *  PARAMETERS
661  *      tvbuff_t *tvb       - pointer to buffer containing raw packet.
662  *      packet_into *pinfo  - pointer to packet information fields
663  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
664  *  RETURNS
665  *      void
666  *---------------------------------------------------------------
667  */
668 void
669 dissect_zbee_zdp_req_remove_node_cache(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
670 {
671     guint   offset   = 0;
672     guint16 device;
673     guint64 ext_addr;
674
675     device   = zbee_parse_uint(tree, hf_zbee_zdp_device, tvb, &offset, sizeof(guint16), NULL);
676     ext_addr = zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, sizeof(guint64), NULL);
677
678     zbee_append_info(tree, pinfo, ", Device: %s", get_eui64_name(ext_addr));
679
680     /* Dump any leftover bytes. */
681     zdp_dump_excess(tvb, offset, pinfo, tree);
682 } /* dissect_zbee_zdp_req_remove_node_cache */
683
684 /*FUNCTION:------------------------------------------------------
685  *  NAME
686  *      dissect_zbee_zdp_req_find_node_cache
687  *  DESCRIPTION
688  *      ZigBee Device Profile dissector for the find node cache
689  *      request. Cluster ID = 0x001c.
690  *  PARAMETERS
691  *      tvbuff_t *tvb       - pointer to buffer containing raw packet.
692  *      packet_into *pinfo  - pointer to packet information fields
693  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
694  *  RETURNS
695  *      void
696  *---------------------------------------------------------------
697  */
698 void
699 dissect_zbee_zdp_req_find_node_cache(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
700 {
701     guint   offset = 0;
702     guint16 device;
703     guint64 ext_addr;
704
705     device   = zbee_parse_uint(tree, hf_zbee_zdp_device, tvb, &offset, sizeof(guint16), NULL);
706     ext_addr = zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, sizeof(guint64), NULL);
707
708     zbee_append_info(tree, pinfo, ", Device: %s", get_eui64_name(ext_addr));
709
710     /* Dump any leftover bytes. */
711     zdp_dump_excess(tvb, offset, pinfo, tree);
712 } /* dissect_zbee_zdp_req_find_node_cache */
713
714 /*FUNCTION:------------------------------------------------------
715  *  NAME
716  *      dissect_zbee_zdp_req_ext_simple_desc
717  *  DESCRIPTION
718  *      ZigBee Device Profile dissector for the extended simple
719  *      descriptor request. Cluster ID = 0x001d.
720  *  PARAMETERS
721  *      tvbuff_t *tvb       - pointer to buffer containing raw packet.
722  *      packet_into *pinfo  - pointer to packet information fields
723  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
724  *  RETURNS
725  *      void
726  *---------------------------------------------------------------
727  */
728 void
729 dissect_zbee_zdp_req_ext_simple_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
730 {
731     guint   offset = 0;
732     guint16 device;
733     guint8  endpt;
734     guint8  idx;
735
736     device = zbee_parse_uint(tree, hf_zbee_zdp_device, tvb, &offset, sizeof(guint16), NULL);
737     endpt  = zbee_parse_uint(tree, hf_zbee_zdp_endpoint, tvb, &offset, sizeof(guint8), NULL);
738     idx    = zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, sizeof(guint8), NULL);
739
740     zbee_append_info(tree, pinfo, ", Device: 0x%04x, Endpoint: %d", device, endpt);
741
742     /* Dump any leftover bytes. */
743     zdp_dump_excess(tvb, offset, pinfo, tree);
744 } /* dissect_zbee_zdp_req_ext_simple_desc */
745
746 /*FUNCTION:------------------------------------------------------
747  *  NAME
748  *      dissect_zbee_zdp_req_ext_active_ep
749  *  DESCRIPTION
750  *      ZigBee Device Profile dissector for the extended active
751  *      endpoint list request. Cluster ID = 0x001e.
752  *  PARAMETERS
753  *      tvbuff_t *tvb       - pointer to buffer containing raw packet.
754  *      packet_into *pinfo  - pointer to packet information fields
755  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
756  *  RETURNS
757  *      void
758  *---------------------------------------------------------------
759  */
760 void
761 dissect_zbee_zdp_req_ext_active_ep(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
762 {
763     guint   offset = 0;
764     guint16 device;
765     guint8  idx;
766
767     device = zbee_parse_uint(tree, hf_zbee_zdp_device, tvb, &offset, sizeof(guint16), NULL);
768     idx    = zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, sizeof(guint8), NULL);
769
770     zbee_append_info(tree, pinfo, ", Device: 0x%04x", device);
771
772     /* Dump any leftover bytes. */
773     zdp_dump_excess(tvb, offset, pinfo, tree);
774 } /* dissect_zbee_zdp_req_ext_active_ep */
775
776 /**************************************
777  * DISCOVERY RESPONSES
778  **************************************
779  */
780 /*FUNCTION:------------------------------------------------------
781  *  NAME
782  *      dissect_zbee_zdp_rsp_nwk_addr
783  *  DESCRIPTION
784  *      ZigBee Device Profile dissector for the network address
785  *      response. Cluster ID = 0x8000.
786  *  PARAMETERS
787  *      tvbuff_t *tvb       - pointer to buffer containing raw packet.
788  *      packet_into *pinfo  - pointer to packet information fields
789  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
790  *  RETURNS
791  *      void
792  *---------------------------------------------------------------
793  */
794 void
795 dissect_zbee_zdp_rsp_nwk_addr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
796 {
797     proto_item  *ti;
798     proto_tree  *field_tree = NULL;
799     guint       offset = 0;
800     guint       i;
801
802     guint8      status;
803     guint64     ext_addr;
804     guint16     device;
805     guint8      assoc;
806     guint8      idx;
807
808     status   = zdp_parse_status(tree, tvb, &offset);
809     ext_addr = zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, sizeof(guint64), NULL);
810     device   = zbee_parse_uint(tree, hf_zbee_zdp_device, tvb, &offset, sizeof(guint16), NULL);
811
812     if (tvb_bytes_exist(tvb, offset, 2*sizeof(guint8))) {
813         /* The presence of these fields depends on the request message. Include them if they exist. */
814         assoc    = zbee_parse_uint(tree, hf_zbee_zdp_assoc_device_count, tvb, &offset, sizeof(guint8), NULL);
815         idx      = zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, sizeof(guint8), NULL);
816
817         if ((tree) && (assoc)) {
818             ti = proto_tree_add_text(tree, tvb, offset, assoc*sizeof(guint16), "Associated Device List");
819             field_tree = proto_item_add_subtree(ti, ett_zbee_zdp_assoc_device);
820         }
821         for (i=0; i<assoc; i++) {
822             (void)zbee_parse_uint(field_tree, hf_zbee_zdp_assoc_device, tvb, &offset, sizeof(guint16), NULL);
823         }
824     }
825
826     zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
827     if (status == ZBEE_ZDP_STATUS_SUCCESS) {
828         zbee_append_info(tree, pinfo, ", Device: %s = 0x%04x", get_eui64_name(ext_addr), device);
829     }
830
831     /* Dump any leftover bytes. */
832     zdp_dump_excess(tvb, offset, pinfo, tree);
833 } /* dissect_zbee_zdp_rsp_nwk_addr */
834
835 /*FUNCTION:------------------------------------------------------
836  *  NAME
837  *      dissect_zbee_zdp_rsp_ext_addr
838  *  DESCRIPTION
839  *      ZigBee Device Profile dissector for the extended address
840  *      response. Cluster ID = 0x8001.
841  *  PARAMETERS
842  *      tvbuff_t *tvb       - pointer to buffer containing raw packet.
843  *      packet_into *pinfo  - pointer to packet information fields
844  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
845  *  RETURNS
846  *      void
847  *---------------------------------------------------------------
848  */
849 void
850 dissect_zbee_zdp_rsp_ext_addr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
851 {
852     proto_item  *ti;
853     proto_tree  *field_tree = NULL;
854     guint       offset = 0;
855     guint       i;
856
857     guint8      status;
858     guint64     ext_addr;
859     guint16     device;
860     guint8      assoc;
861     guint8      idx;
862
863     status   = zdp_parse_status(tree, tvb, &offset);
864     ext_addr = zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, sizeof(guint64), NULL);
865     device   = zbee_parse_uint(tree, hf_zbee_zdp_device, tvb, &offset, sizeof(guint16), NULL);
866
867     if (tvb_bytes_exist(tvb, offset, 2*sizeof(guint8))) {
868         /* The presence of these fields depends on the request message. Include them if they exist. */
869         assoc    = zbee_parse_uint(tree, hf_zbee_zdp_assoc_device_count, tvb, &offset, sizeof(guint8), NULL);
870         idx      = zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, sizeof(guint8), NULL);
871
872         if ((tree) && (assoc)) {
873             ti = proto_tree_add_text(tree, tvb, offset, assoc*sizeof(guint16), "Associated Device List");
874             field_tree = proto_item_add_subtree(ti, ett_zbee_zdp_assoc_device);
875         }
876         for (i=0; i<assoc; i++) {
877             (void)zbee_parse_uint(field_tree, hf_zbee_zdp_assoc_device, tvb, &offset, sizeof(guint16), NULL);
878         }
879     }
880
881     zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
882     if (status == ZBEE_ZDP_STATUS_SUCCESS) {
883         zbee_append_info(tree, pinfo, ", Device: 0x%04x = %s", device, get_eui64_name(ext_addr));
884     }
885
886     /* Dump any leftover bytes. */
887     zdp_dump_excess(tvb, offset, pinfo, tree);
888 } /* dissect_zbee_zdp_rsp_ext_addr */
889
890 /*FUNCTION:------------------------------------------------------
891  *  NAME
892  *      dissect_zbee_zdp_rsp_node_desc
893  *  DESCRIPTION
894  *      ZigBee Device Profile dissector for the node descriptor
895  *      response. Cluster ID = 0x8002.
896  *  PARAMETERS
897  *      tvbuff_t *tvb       - pointer to buffer containing raw packet.
898  *      packet_into *pinfo  - pointer to packet information fields
899  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
900  *  RETURNS
901  *      void
902  *---------------------------------------------------------------
903  */
904 void
905 dissect_zbee_zdp_rsp_node_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
906 {
907     guint       offset = 0;
908
909     guint8      status;
910     guint16     device;
911
912     status   = zdp_parse_status(tree, tvb, &offset);
913     device   = zbee_parse_uint(tree, hf_zbee_zdp_device, tvb, &offset, sizeof(guint16), NULL);
914     if (status == ZBEE_ZDP_STATUS_SUCCESS) {
915         zdp_parse_node_desc(tree, ett_zbee_zdp_node, tvb, &offset, pinfo);
916     }
917
918     zbee_append_info(tree, pinfo, ", Device: 0x%04x", device);
919     zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
920
921     /* Dump any leftover bytes. */
922     zdp_dump_excess(tvb, offset, pinfo, tree);
923 } /* dissect_zbee_zdp_rsp_node_desc */
924
925 /*FUNCTION:------------------------------------------------------
926  *  NAME
927  *      dissect_zbee_zdp_rsp_power_desc
928  *  DESCRIPTION
929  *      ZigBee Device Profile dissector for the power descriptor
930  *      response. Cluster ID = 0x8003.
931  *  PARAMETERS
932  *      tvbuff_t *tvb       - pointer to buffer containing raw packet.
933  *      packet_into *pinfo  - pointer to packet information fields
934  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
935  *  RETURNS
936  *      void
937  *---------------------------------------------------------------
938  */
939 void
940 dissect_zbee_zdp_rsp_power_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
941 {
942     guint       offset = 0;
943
944     guint8      status;
945     guint16     device;
946
947     status   = zdp_parse_status(tree, tvb, &offset);
948     device   = zbee_parse_uint(tree, hf_zbee_zdp_device, tvb, &offset, sizeof(guint16), NULL);
949     if (status == ZBEE_ZDP_STATUS_SUCCESS) {
950         zdp_parse_power_desc(tree, ett_zbee_zdp_power, tvb, &offset);
951     }
952
953     zbee_append_info(tree, pinfo, ", Device: 0x%04x", device);
954     zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
955
956     /* Dump any leftover bytes. */
957     zdp_dump_excess(tvb, offset, pinfo, tree);
958 } /* dissect_zbee_zdp_rsp_power_desc */
959
960 /*FUNCTION:------------------------------------------------------
961  *  NAME
962  *      dissect_zbee_zdp_rsp_simple_desc
963  *  DESCRIPTION
964  *      ZigBee Device Profile dissector for the simple descriptor
965  *      response. Cluster ID = 0x8004.
966  *  PARAMETERS
967  *      tvbuff_t *tvb       - pointer to buffer containing raw packet.
968  *      packet_into *pinfo  - pointer to packet information fields
969  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
970  *  RETURNS
971  *      void
972  *---------------------------------------------------------------
973  */
974 void
975 dissect_zbee_zdp_rsp_simple_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
976 {
977     guint       offset = 0;
978
979     guint8      status;
980     guint8      length;
981     guint16     device;
982
983     status   = zdp_parse_status(tree, tvb, &offset);
984     device   = zbee_parse_uint(tree, hf_zbee_zdp_device, tvb, &offset, sizeof(guint16), NULL);
985     length   = zbee_parse_uint(tree, hf_zbee_zdp_simple_length, tvb, &offset, sizeof(guint8), NULL);
986     if (status == ZBEE_ZDP_STATUS_SUCCESS) {
987         zdp_parse_simple_desc(tree, ett_zbee_zdp_simple, tvb, &offset, pinfo);
988     }
989
990     zbee_append_info(tree, pinfo, ", Device: 0x%04x", device);
991     zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
992
993     /* Dump any leftover bytes. */
994     zdp_dump_excess(tvb, offset, pinfo, tree);
995 } /* dissect_zbee_zdp_rsp_simple_desc */
996
997 /*FUNCTION:------------------------------------------------------
998  *  NAME
999  *      dissect_zbee_zdp_rsp_active_ep
1000  *  DESCRIPTION
1001  *      ZigBee Device Profile dissector for the active endpoint
1002  *      response. Cluster ID = 0x8005.
1003  *  PARAMETERS
1004  *      tvbuff_t *tvb       - pointer to buffer containing raw packet.
1005  *      packet_into *pinfo  - pointer to packet information fields
1006  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
1007  *  RETURNS
1008  *      void
1009  *---------------------------------------------------------------
1010  */
1011 void
1012 dissect_zbee_zdp_rsp_active_ep(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1013 {
1014     proto_item  *ti;
1015     proto_tree  *field_tree = NULL;
1016     guint       offset = 0;
1017     guint       i;
1018
1019     guint8      status;
1020     guint16     device;
1021     guint8      ep_count;
1022
1023     status   = zdp_parse_status(tree, tvb, &offset);
1024     device   = zbee_parse_uint(tree, hf_zbee_zdp_device, tvb, &offset, sizeof(guint16), NULL);
1025     ep_count = zbee_parse_uint(tree, hf_zbee_zdp_ep_count, tvb, &offset, sizeof(guint8), NULL);
1026
1027     if (tree && ep_count) {
1028         ti = proto_tree_add_text(tree, tvb, offset, ep_count*sizeof(guint8), "Active Endpoint List");
1029         field_tree = proto_item_add_subtree(ti, ett_zbee_zdp_endpoint);
1030     }
1031     for (i=0; i<ep_count; i++) {
1032         (void)zbee_parse_uint(field_tree, hf_zbee_zdp_endpoint, tvb, &offset, sizeof(guint8), NULL);
1033     }
1034
1035     zbee_append_info(tree, pinfo, ", Device: 0x%04x", device);
1036     zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
1037
1038     /* Dump any leftover bytes. */
1039     zdp_dump_excess(tvb, offset, pinfo, tree);
1040 } /* dissect_zbee_zdp_rsp_active_ep */
1041
1042 /*FUNCTION:------------------------------------------------------
1043  *  NAME
1044  *      dissect_zbee_zdp_rsp_match_desc
1045  *  DESCRIPTION
1046  *      ZigBee Device Profile dissector for the simple descriptor
1047  *      response. Cluster ID = 0x8003.
1048  *  PARAMETERS
1049  *      tvbuff_t *tvb       - pointer to buffer containing raw packet.
1050  *      packet_into *pinfo  - pointer to packet information fields
1051  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
1052  *  RETURNS
1053  *      void
1054  *---------------------------------------------------------------
1055  */
1056 void
1057 dissect_zbee_zdp_rsp_match_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1058 {
1059     proto_item  *ti;
1060     proto_tree  *field_tree = NULL;
1061     guint       offset = 0;
1062     guint       i;
1063
1064     guint8      status;
1065     guint16     device;
1066     guint8      ep_count;
1067
1068     status   = zdp_parse_status(tree, tvb, &offset);
1069     device   = zbee_parse_uint(tree, hf_zbee_zdp_device, tvb, &offset, sizeof(guint16), NULL);
1070     ep_count = zbee_parse_uint(tree, hf_zbee_zdp_ep_count, tvb, &offset, sizeof(guint8), NULL);
1071
1072     if (tree && ep_count) {
1073         ti = proto_tree_add_text(tree, tvb, offset, ep_count*sizeof(guint8), "Matching Endpoint List");
1074         field_tree = proto_item_add_subtree(ti, ett_zbee_zdp_endpoint);
1075     }
1076     for (i=0; i<ep_count; i++) {
1077         (void)zbee_parse_uint(field_tree, hf_zbee_zdp_endpoint, tvb, &offset, sizeof(guint8), NULL);
1078     }
1079
1080     zbee_append_info(tree, pinfo, ", Device: 0x%04x", device);
1081     zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
1082
1083     /* Dump any leftover bytes. */
1084     zdp_dump_excess(tvb, offset, pinfo, tree);
1085 } /* dissect_zbee_zdp_rsp_match_desc */
1086
1087 /*FUNCTION:------------------------------------------------------
1088  *  NAME
1089  *      dissect_zbee_zdp_rsp_complex_desc
1090  *  DESCRIPTION
1091  *      ZigBee Device Profile dissector for the complex descriptor
1092  *      response. Cluster ID = 0x8010.
1093  *  PARAMETERS
1094  *      tvbuff_t *tvb       - pointer to buffer containing raw packet.
1095  *      packet_into *pinfo  - pointer to packet information fields
1096  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
1097  *  RETURNS
1098  *      void
1099  *---------------------------------------------------------------
1100  */
1101 void
1102 dissect_zbee_zdp_rsp_complex_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1103 {
1104     guint       offset = 0;
1105
1106     guint8      status;
1107     guint8      length;
1108     guint16     device;
1109
1110     status   = zdp_parse_status(tree, tvb, &offset);
1111     device   = zbee_parse_uint(tree, hf_zbee_zdp_device, tvb, &offset, sizeof(guint16), NULL);
1112     length   = zbee_parse_uint(tree, hf_zbee_zdp_complex_length, tvb, &offset, sizeof(guint8), NULL);
1113     if (length) {
1114         zdp_parse_complex_desc(tree, -1, tvb, &offset, length);
1115     }
1116
1117     zbee_append_info(tree, pinfo, ", Device: 0x%04x", device);
1118     zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
1119
1120     /* Dump any leftover bytes. */
1121     zdp_dump_excess(tvb, offset, pinfo, tree);
1122 } /* dissect_zbee_zdp_rsp_complex_desc */
1123
1124 /*FUNCTION:------------------------------------------------------
1125  *  NAME
1126  *      dissect_zbee_zdp_rsp_user_desc
1127  *  DESCRIPTION
1128  *      ZigBee Device Profile dissector for the user descriptor
1129  *      response. Cluster ID = 0x8011.
1130  *  PARAMETERS
1131  *      tvbuff_t *tvb       - pointer to buffer containing raw packet.
1132  *      packet_into *pinfo  - pointer to packet information fields
1133  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
1134  *  RETURNS
1135  *      void
1136  *---------------------------------------------------------------
1137  */
1138 void
1139 dissect_zbee_zdp_rsp_user_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1140 {
1141     guint       offset = 0;
1142     guint8      status;
1143     guint16     device;
1144     guint8      user_length;
1145     gchar       *user;
1146
1147     status      = zdp_parse_status(tree, tvb, &offset);
1148     device      = zbee_parse_uint(tree, hf_zbee_zdp_device, tvb, &offset, sizeof(guint16), NULL);
1149     if ((pinfo->zbee_stack_vers >= ZBEE_VERSION_2007) || (status == ZBEE_ZDP_STATUS_SUCCESS)) {
1150         /* In ZigBee 2003 & earlier, the length field is omitted if not successful. */
1151         user_length = zbee_parse_uint(tree, hf_zbee_zdp_user_length, tvb, &offset, sizeof(guint8), NULL);
1152     }
1153     else user_length = 0;
1154
1155     user        = tvb_get_ephemeral_string(tvb, offset, user_length);
1156     if (tree) {
1157         proto_tree_add_string(tree, hf_zbee_zdp_user, tvb, offset, user_length, user);
1158     }
1159     offset += user_length;
1160
1161     zbee_append_info(tree, pinfo, ", Device: 0x%04x", device);
1162     if (status == ZBEE_ZDP_STATUS_SUCCESS) {
1163         zbee_append_info(tree, pinfo, ", Desc: \'%s\'", user);
1164     }
1165     zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
1166
1167     /* Dump any leftover bytes. */
1168     zdp_dump_excess(tvb, offset, pinfo, tree);
1169 } /* dissect_zbee_zdp_rsp_user_desc */
1170
1171 /*FUNCTION:------------------------------------------------------
1172  *  NAME
1173  *      dissect_zbee_zdp_rsp_user_desc_conf
1174  *  DESCRIPTION
1175  *      ZigBee Device Profile dissector for the set user descriptor
1176  *      confirmation. Cluster ID = 0x8014.
1177  *  PARAMETERS
1178  *      tvbuff_t *tvb       - pointer to buffer containing raw packet.
1179  *      packet_into *pinfo  - pointer to packet information fields
1180  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
1181  *  RETURNS
1182  *      void
1183  *---------------------------------------------------------------
1184  */
1185 void
1186 dissect_zbee_zdp_rsp_user_desc_conf(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1187 {
1188     guint       offset = 0;
1189     guint8      status;
1190     guint16     device = 0;
1191
1192     status      = zdp_parse_status(tree, tvb, &offset);
1193     if (pinfo->zbee_stack_vers >= ZBEE_VERSION_2007) {
1194         /* Device address present only on ZigBee 2006 & later. */
1195         device = zbee_parse_uint(tree, hf_zbee_zdp_device, tvb, &offset, sizeof(guint16), NULL);
1196     }
1197
1198     zbee_append_info(tree, pinfo, ", Device: 0x%04x", device);
1199     zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
1200
1201     /* Dump any leftover bytes. */
1202     zdp_dump_excess(tvb, offset, pinfo, tree);
1203 } /* dissect_zbee_zdp_rsp_user_desc_conf */
1204
1205 /*FUNCTION:------------------------------------------------------
1206  *  NAME
1207  *      dissect_zbee_zdp_rsp_discovery_cache
1208  *  DESCRIPTION
1209  *      ZigBee Device Profile dissector for the discovery cache
1210  *      response. Cluster ID = 0x8012.
1211  *  PARAMETERS
1212  *      tvbuff_t *tvb       - pointer to buffer containing raw packet.
1213  *      packet_into *pinfo  - pointer to packet information fields
1214  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
1215  *  RETURNS
1216  *      void
1217  *---------------------------------------------------------------
1218  */
1219 void
1220 dissect_zbee_zdp_rsp_discovery_cache(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1221 {
1222     guint       offset = 0;
1223
1224     guint8      status;
1225
1226     status      = zdp_parse_status(tree, tvb, &offset);
1227
1228     zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
1229
1230     /* Dump any leftover bytes. */
1231     zdp_dump_excess(tvb, offset, pinfo, tree);
1232 } /* dissect_zbee_zdp_rsp_discovery_cache */
1233
1234 /*FUNCTION:------------------------------------------------------
1235  *  NAME
1236  *      dissect_zbee_zdp_rsp_system_server_disc
1237  *  DESCRIPTION
1238  *      ZigBee Device Profile dissector for the system server discovery
1239  *      response. Cluster ID = 0x8015.
1240  *  PARAMETERS
1241  *      tvbuff_t *tvb       - pointer to buffer containing raw packet.
1242  *      packet_into *pinfo  - pointer to packet information fields
1243  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
1244  *  RETURNS
1245  *      void
1246  *---------------------------------------------------------------
1247  */
1248 void
1249 dissect_zbee_zdp_rsp_system_server_disc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1250 {
1251     guint       offset = 0;
1252
1253     guint8      status;
1254     guint16     server;
1255
1256     status   = zdp_parse_status(tree, tvb, &offset);
1257     server   = zdp_parse_server_flags(tree, ett_zbee_zdp_server, tvb, &offset);
1258
1259     zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
1260
1261     /* Dump any leftover bytes. */
1262     zdp_dump_excess(tvb, offset, pinfo, tree);
1263 } /* dissect_zbee_zdp_rsp_system_server_disc */
1264
1265 /*FUNCTION:------------------------------------------------------
1266  *  NAME
1267  *      dissect_zbee_zdp_rsp_discovery_store
1268  *  DESCRIPTION
1269  *      ZigBee Device Profile dissector for the discovery store
1270  *      response. Cluster ID = 0x8016.
1271  *  PARAMETERS
1272  *      tvbuff_t *tvb       - pointer to buffer containing raw packet.
1273  *      packet_into *pinfo  - pointer to packet information fields
1274  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
1275  *  RETURNS
1276  *      void
1277  *---------------------------------------------------------------
1278  */
1279 void
1280 dissect_zbee_zdp_rsp_discovery_store(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1281 {
1282     guint       offset = 0;
1283
1284     guint8      status;
1285
1286     status = zdp_parse_status(tree, tvb, &offset);
1287
1288     zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
1289
1290     /* Dump any leftover bytes. */
1291     zdp_dump_excess(tvb, offset, pinfo, tree);
1292 } /* dissect_zbee_zdp_rsp_discovery_store */
1293
1294 /*FUNCTION:------------------------------------------------------
1295  *  NAME
1296  *      dissect_zbee_zdp_rsp_store_node_desc
1297  *  DESCRIPTION
1298  *      ZigBee Device Profile dissector for the store node descriptor
1299  *      response. Cluster ID = 0x8017.
1300  *  PARAMETERS
1301  *      tvbuff_t *tvb       - pointer to buffer containing raw packet.
1302  *      packet_into *pinfo  - pointer to packet information fields
1303  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
1304  *  RETURNS
1305  *      void
1306  *---------------------------------------------------------------
1307  */
1308 void
1309 dissect_zbee_zdp_rsp_store_node_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1310 {
1311     guint       offset = 0;
1312
1313     guint8      status;
1314
1315     status      = zdp_parse_status(tree, tvb, &offset);
1316
1317     zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
1318
1319     /* Dump any leftover bytes. */
1320     zdp_dump_excess(tvb, offset, pinfo, tree);
1321 } /* dissect_zbee_zdp_rsp_store_node_desc */
1322
1323 /*FUNCTION:------------------------------------------------------
1324  *  NAME
1325  *      dissect_zbee_zdp_rsp_store_power_desc
1326  *  DESCRIPTION
1327  *      ZigBee Device Profile dissector for the store power descriptor
1328  *      response. Cluster ID = 0x8018.
1329  *  PARAMETERS
1330  *      tvbuff_t *tvb       - pointer to buffer containing raw packet.
1331  *      packet_into *pinfo  - pointer to packet information fields
1332  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
1333  *  RETURNS
1334  *      void
1335  *---------------------------------------------------------------
1336  */
1337 void
1338 dissect_zbee_zdp_rsp_store_power_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1339 {
1340     guint       offset = 0;
1341
1342     guint8      status;
1343
1344     status      = zdp_parse_status(tree, tvb, &offset);
1345
1346     zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
1347
1348     /* Dump any leftover bytes. */
1349     zdp_dump_excess(tvb, offset, pinfo, tree);
1350 } /* dissect_zbee_zdp_rsp_store_power_desc */
1351
1352 /*FUNCTION:------------------------------------------------------
1353  *  NAME
1354  *      dissect_zbee_zdp_rsp_store_active_ep
1355  *  DESCRIPTION
1356  *      ZigBee Device Profile dissector for the store active endpoints
1357  *      response. Cluster ID = 0x8019.
1358  *  PARAMETERS
1359  *      tvbuff_t *tvb       - pointer to buffer containing raw packet.
1360  *      packet_into *pinfo  - pointer to packet information fields
1361  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
1362  *  RETURNS
1363  *      void
1364  *---------------------------------------------------------------
1365  */
1366 void
1367 dissect_zbee_zdp_rsp_store_active_ep(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1368 {
1369     guint       offset = 0;
1370
1371     guint8      status;
1372
1373     status      = zdp_parse_status(tree, tvb, &offset);
1374
1375     zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
1376
1377     /* Dump any leftover bytes. */
1378     zdp_dump_excess(tvb, offset, pinfo, tree);
1379 } /* dissect_zbee_zdp_rsp_store_active_ep */
1380
1381 /*FUNCTION:------------------------------------------------------
1382  *  NAME
1383  *      dissect_zbee_zdp_rsp_store_simple_desc
1384  *  DESCRIPTION
1385  *      ZigBee Device Profile dissector for the store power descriptor
1386  *      response. Cluster ID = 0x801a.
1387  *  PARAMETERS
1388  *      tvbuff_t *tvb       - pointer to buffer containing raw packet.
1389  *      packet_into *pinfo  - pointer to packet information fields
1390  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
1391  *  RETURNS
1392  *      void
1393  *---------------------------------------------------------------
1394  */
1395 void
1396 dissect_zbee_zdp_rsp_store_simple_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1397 {
1398     guint       offset = 0;
1399
1400     guint8      status;
1401
1402     status      = zdp_parse_status(tree, tvb, &offset);
1403
1404     zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
1405
1406     /* Dump any leftover bytes. */
1407     zdp_dump_excess(tvb, offset, pinfo, tree);
1408 } /* dissect_zbee_zdp_rsp_store_simple_desc */
1409
1410 /*FUNCTION:------------------------------------------------------
1411  *  NAME
1412  *      dissect_zbee_zdp_rsp_remove_node_cache
1413  *  DESCRIPTION
1414  *      ZigBee Device Profile dissector for the remove node cache
1415  *      response. Cluster ID = 0x801b.
1416  *  PARAMETERS
1417  *      tvbuff_t *tvb       - pointer to buffer containing raw packet.
1418  *      packet_into *pinfo  - pointer to packet information fields
1419  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
1420  *  RETURNS
1421  *      void
1422  *---------------------------------------------------------------
1423  */
1424 void
1425 dissect_zbee_zdp_rsp_remove_node_cache(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1426 {
1427     guint       offset = 0;
1428
1429     guint8      status;
1430
1431     status      = zdp_parse_status(tree, tvb, &offset);
1432
1433     zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
1434
1435     /* Dump any leftover bytes. */
1436     zdp_dump_excess(tvb, offset, pinfo, tree);
1437 } /* dissect_zbee_zdp_rsp_remove_node_cache */
1438
1439 /*FUNCTION:------------------------------------------------------
1440  *  NAME
1441  *      dissect_zbee_zdp_rsp_find_node_cache
1442  *  DESCRIPTION
1443  *      ZigBee Device Profile dissector for the find node cache
1444  *      response. Cluster ID = 0x801c.
1445  *  PARAMETERS
1446  *      tvbuff_t *tvb       - pointer to buffer containing raw packet.
1447  *      packet_into *pinfo  - pointer to packet information fields
1448  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
1449  *  RETURNS
1450  *      void
1451  *---------------------------------------------------------------
1452  */
1453 void
1454 dissect_zbee_zdp_rsp_find_node_cache(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1455 {
1456     guint       offset = 0;
1457
1458     guint16     cache;
1459     guint16     device;
1460     guint64     ext_addr;
1461
1462     cache    = zbee_parse_uint(tree, hf_zbee_zdp_cache, tvb, &offset, sizeof(guint16), NULL);
1463     device   = zbee_parse_uint(tree, hf_zbee_zdp_device, tvb, &offset, sizeof(guint16), NULL);
1464     ext_addr = zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, sizeof(guint64), NULL);
1465
1466     zbee_append_info(tree, pinfo, ", Cache: 0x%04x", cache);
1467     zbee_append_info(tree, pinfo, ", Device: 0x%04x", device);
1468
1469     /* Dump any leftover bytes. */
1470     zdp_dump_excess(tvb, offset, pinfo, tree);
1471 } /* dissect_zbee_zdp_rsp_find_node_cache */
1472
1473 /*FUNCTION:------------------------------------------------------
1474  *  NAME
1475  *      dissect_zbee_zdp_rsp_ext_simple_desc
1476  *  DESCRIPTION
1477  *      ZigBee Device Profile dissector for the extended simple
1478  *      descriptor response. Cluster ID = 0x801d.
1479  *  PARAMETERS
1480  *      tvbuff_t *tvb       - pointer to buffer containing raw packet.
1481  *      packet_into *pinfo  - pointer to packet information fields
1482  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
1483  *  RETURNS
1484  *      void
1485  *---------------------------------------------------------------
1486  */
1487 void
1488 dissect_zbee_zdp_rsp_ext_simple_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1489 {
1490     guint       offset = 0;
1491     guint       i;
1492     guint       sizeof_cluster = sizeof(guint16);
1493
1494     guint8      status;
1495     guint16     device;
1496     guint8      endpt;
1497     guint8      in_count;
1498     guint8      out_count;
1499     guint8      idx;
1500
1501     status      = zdp_parse_status(tree, tvb, &offset);
1502     device      = zbee_parse_uint(tree, hf_zbee_zdp_device, tvb, &offset, sizeof(guint16), NULL);
1503     endpt       = zbee_parse_uint(tree, hf_zbee_zdp_endpoint, tvb, &offset, sizeof(guint8), NULL);
1504     in_count    = zbee_parse_uint(tree, hf_zbee_zdp_in_count, tvb, &offset, sizeof(guint8), NULL);
1505     out_count   = zbee_parse_uint(tree, hf_zbee_zdp_out_count, tvb, &offset, sizeof(guint8), NULL);
1506     idx         = zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, sizeof(guint8), NULL);
1507
1508     /* Display the input cluster list. */
1509     for (i=idx; (i<in_count) && tvb_bytes_exist(tvb, offset, sizeof_cluster); i++) {
1510         zbee_parse_uint(tree, hf_zbee_zdp_in_cluster, tvb, &offset, sizeof_cluster, NULL);
1511     } /* for */
1512     for (i-=in_count; (i<out_count) && tvb_bytes_exist(tvb, offset, sizeof_cluster); i++) {
1513         zbee_parse_uint(tree, hf_zbee_zdp_out_cluster, tvb, &offset, sizeof_cluster, NULL);
1514     } /* for */
1515
1516     zbee_append_info(tree, pinfo, ", Device: 0x%04x", device);
1517     zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
1518
1519     /* Dump any leftover bytes. */
1520     zdp_dump_excess(tvb, offset, pinfo, tree);
1521 } /* dissect_zbee_zdp_rsp_ext_simple_desc */
1522
1523 /*FUNCTION:------------------------------------------------------
1524  *  NAME
1525  *      dissect_zbee_zdp_rsp_ext_active_ep
1526  *  DESCRIPTION
1527  *      ZigBee Device Profile dissector for the extended active
1528  *      endpoint response. Cluster ID = 0x801e.
1529  *  PARAMETERS
1530  *      tvbuff_t *tvb       - pointer to buffer containing raw packet.
1531  *      packet_into *pinfo  - pointer to packet information fields
1532  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
1533  *  RETURNS
1534  *      void
1535  *---------------------------------------------------------------
1536  */
1537 void
1538 dissect_zbee_zdp_rsp_ext_active_ep(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1539 {
1540     proto_item  *ti;
1541     proto_tree  *field_tree = NULL;
1542     guint       offset = 0;
1543     guint       i;
1544
1545     guint8      status;
1546     guint16     device;
1547     guint8      ep_count;
1548     guint8      idx;
1549
1550     status   = zdp_parse_status(tree, tvb, &offset);
1551     device   = zbee_parse_uint(tree, hf_zbee_zdp_device, tvb, &offset, sizeof(guint16), NULL);
1552     ep_count = zbee_parse_uint(tree, hf_zbee_zdp_ep_count, tvb, &offset, sizeof(guint8), NULL);
1553     idx      = zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, sizeof(guint8), NULL);
1554
1555     if (tree && ep_count) {
1556         ti = proto_tree_add_text(tree, tvb, offset, ep_count*sizeof(guint8), "Active Endpoint List");
1557         field_tree = proto_item_add_subtree(ti, ett_zbee_zdp_endpoint);
1558         for (i=idx; (i<ep_count) && tvb_bytes_exist(tvb, offset, sizeof(guint8)); i++) {
1559             (void)zbee_parse_uint(field_tree, hf_zbee_zdp_endpoint, tvb, &offset, sizeof(guint8), NULL);
1560         }
1561     }
1562
1563     zbee_append_info(tree, pinfo, ", Device: 0x%04x", device);
1564     zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
1565
1566     /* Dump any leftover bytes. */
1567     zdp_dump_excess(tvb, offset, pinfo, tree);
1568 } /* dissect_zbee_zdp_rsp_ext_active_ep */