Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-zbee-zdp-discovery.c
blob87510881d72cac301c2cd2353b777f8d556ba5dc
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
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * SPDX-License-Identifier: GPL-2.0-or-later
13 /* Include Files */
14 #include "config.h"
16 #include <epan/packet.h>
17 #include <epan/addr_resolv.h>
18 #include "packet-zbee.h"
19 #include "packet-zbee-zdp.h"
20 #include "packet-zbee-aps.h"
21 #include "packet-zbee-tlv.h"
23 /**************************************
24 * DISCOVERY REQUESTS
25 **************************************
27 /**
28 *ZigBee Device Profile dissector for the network address
30 *@param tvb pointer to buffer containing raw packet.
31 *@param pinfo pointer to packet information fields
32 *@param tree pointer to data tree Wireshark uses to display packet.
34 void
35 dissect_zbee_zdp_req_nwk_addr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
37 unsigned offset = 0;
39 uint64_t ext_addr;
41 ext_addr = zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, sizeof(uint64_t), NULL);
42 proto_tree_add_item(tree, hf_zbee_zdp_req_type, tvb, offset, 1, ENC_LITTLE_ENDIAN);
43 offset += 1;
44 proto_tree_add_item(tree, hf_zbee_zdp_index, tvb, offset, 1, ENC_LITTLE_ENDIAN);
45 offset += 1;
47 zbee_append_info(tree, pinfo, ", Address: %s", eui64_to_display(pinfo->pool, ext_addr));
49 /* Dump any leftover bytes. */
50 zdp_dump_excess(tvb, offset, pinfo, tree);
51 } /* dissect_zbee_zdp_req_nwk_addr */
53 /**
54 *ZigBee Device Profile dissector for the extended address
56 *@param tvb pointer to buffer containing raw packet.
57 *@param pinfo pointer to packet information fields
58 *@param tree pointer to data tree Wireshark uses to display packet.
60 void
61 dissect_zbee_zdp_req_ext_addr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
63 unsigned offset = 0;
65 uint32_t device;
67 proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN, &device);
68 offset += 2;
69 proto_tree_add_item(tree, hf_zbee_zdp_req_type, tvb, offset, 1, ENC_LITTLE_ENDIAN);
70 offset += 1;
71 proto_tree_add_item(tree, hf_zbee_zdp_index, tvb, offset, 1, ENC_LITTLE_ENDIAN);
72 offset += 1;
74 zbee_append_info(tree, pinfo, ", Nwk Addr: 0x%04x", device);
76 /* Dump any leftover bytes. */
77 zdp_dump_excess(tvb, offset, pinfo, tree);
78 } /* dissect_zbee_zdp_req_ext_addr */
80 /**
81 *ZigBee Device Profile dissector for the descriptor
83 *@param tvb pointer to buffer containing raw packet.
84 *@param pinfo pointer to packet information fields
85 *@param tree pointer to data tree Wireshark uses to display packet.
87 void
88 dissect_zbee_zdp_req_node_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
90 unsigned offset = 0;
91 uint32_t device;
93 proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN, &device);
94 offset += 2;
96 zbee_append_info(tree, pinfo, ", Nwk Addr: 0x%04x", device);
98 offset = dissect_zbee_tlvs(tvb, pinfo, tree, offset, NULL, ZBEE_TLV_SRC_TYPE_ZBEE_ZDP, ZBEE_ZDP_REQ_NODE_DESC);
100 /* Dump any leftover bytes. */
101 zdp_dump_excess(tvb, offset, pinfo, tree);
102 } /* dissect_zbee_zdp_req_node_desc */
105 *ZigBee Device Profile dissector for the node descriptor
107 *@param tvb pointer to buffer containing raw packet.
108 *@param pinfo pointer to packet information fields
109 *@param tree pointer to data tree Wireshark uses to display packet.
111 void
112 dissect_zbee_zdp_req_power_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
114 unsigned offset = 0;
115 uint32_t device;
117 proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN, &device);
118 offset += 2;
120 zbee_append_info(tree, pinfo, ", Nwk Addr: 0x%04x", device);
122 /* Dump any leftover bytes. */
123 zdp_dump_excess(tvb, offset, pinfo, tree);
124 } /* dissect_zbee_zdp_req_power_desc */
127 *ZigBee Device Profile dissector for the simple descriptor
129 *@param tvb pointer to buffer containing raw packet.
130 *@param pinfo pointer to packet information fields
131 *@param tree pointer to data tree Wireshark uses to display packet.
133 void
134 dissect_zbee_zdp_req_simple_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
136 unsigned offset = 0;
137 uint32_t device, endpt;
139 proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN, &device);
140 offset += 2;
141 proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_endpoint, tvb, offset, 1, ENC_LITTLE_ENDIAN, &endpt);
142 offset += 1;
144 zbee_append_info(tree, pinfo, ", Nwk Addr: 0x%04x, Endpoint: %d", device, endpt);
146 /* Dump any leftover bytes. */
147 zdp_dump_excess(tvb, offset, pinfo, tree);
148 } /* dissect_zbee_zdp_req_simple_desc */
151 *ZigBee Device Profile dissector for the active endpoint list
153 *@param tvb pointer to buffer containing raw packet.
154 *@param pinfo pointer to packet information fields
155 *@param tree pointer to data tree Wireshark uses to display packet.
157 void
158 dissect_zbee_zdp_req_active_ep(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
160 unsigned offset = 0;
161 uint32_t device;
163 proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN, &device);
164 offset += 2;
166 zbee_append_info(tree, pinfo, ", Nwk Addr: 0x%04x", device);
168 /* Dump any leftover bytes. */
169 zdp_dump_excess(tvb, offset, pinfo, tree);
170 } /* dissect_zbee_zdp_req_active_ep */
173 *ZigBee Device Profile dissector for the matching descriptor
175 *@param tvb pointer to buffer containing raw packet.
176 *@param pinfo pointer to packet information fields
177 *@param tree pointer to data tree Wireshark uses to display packet.
179 void
180 dissect_zbee_zdp_req_match_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, uint8_t version)
182 proto_item *ti;
183 proto_tree *field_tree = NULL;
184 unsigned offset = 0, i;
185 unsigned sizeof_cluster = (version >= ZBEE_VERSION_2007)?(int)sizeof(uint16_t):(int)sizeof(uint8_t);
187 uint32_t device, profile, cluster, in_count, out_count;
189 proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN, &device);
190 offset += 2;
191 proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_profile, tvb, offset, 2, ENC_LITTLE_ENDIAN, &profile);
192 offset += 2;
194 /* Add the input cluster list. */
195 proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_in_count, tvb, offset, 1, ENC_LITTLE_ENDIAN, &in_count);
196 offset += 1;
197 if (tree && in_count) {
198 field_tree = proto_tree_add_subtree(tree, tvb, offset, in_count*sizeof_cluster,
199 ett_zbee_zdp_match_in, NULL, "Input Cluster List");
201 for (i=0; i<in_count; i++) {
202 ti = proto_tree_add_item_ret_uint(field_tree, hf_zbee_zdp_in_cluster, tvb, offset, sizeof_cluster, ENC_LITTLE_ENDIAN, &cluster);
203 offset += sizeof_cluster;
204 proto_item_append_text(ti, " (%s)", rval_to_str_const(cluster, zbee_aps_cid_names, "Unknown Cluster"));
207 /* Add the output cluster list. */
208 proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_out_count, tvb, offset, 1, ENC_LITTLE_ENDIAN, &out_count);
209 offset += 1;
210 if (tree && out_count) {
211 field_tree = proto_tree_add_subtree(tree, tvb, offset, out_count*sizeof_cluster, ett_zbee_zdp_match_out, NULL, "Output Cluster List");
213 for (i=0; i<out_count; i++) {
214 ti = proto_tree_add_item_ret_uint(field_tree, hf_zbee_zdp_out_cluster, tvb, offset, sizeof_cluster, ENC_LITTLE_ENDIAN, &cluster);
215 offset += sizeof_cluster;
216 proto_item_append_text(ti, " (%s)", rval_to_str_const(cluster, zbee_aps_cid_names, "Unknown Cluster"));
219 zbee_append_info(tree, pinfo, ", Nwk Addr: 0x%04x, Profile: 0x%04x", device, profile);
221 /* Dump any leftover bytes. */
222 zdp_dump_excess(tvb, offset, pinfo, tree);
223 } /* dissect_zbee_zdp_req_simple_desc */
226 *ZigBee Device Profile dissector for the complex descriptor
228 *@param tvb pointer to buffer containing raw packet.
229 *@param pinfo pointer to packet information fields
230 *@param tree pointer to data tree Wireshark uses to display packet.
232 void
233 dissect_zbee_zdp_req_complex_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
235 unsigned offset = 0;
236 uint32_t device;
238 proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN, &device);
239 offset += 2;
241 zbee_append_info(tree, pinfo, ", Nwk Addr: 0x%04x", device);
243 /* Dump any leftover bytes. */
244 zdp_dump_excess(tvb, offset, pinfo, tree);
245 } /* dissect_zbee_zdp_req_complex_desc */
248 *ZigBee Device Profile dissector for the user descriptor
250 *@param tvb pointer to buffer containing raw packet.
251 *@param pinfo pointer to packet information fields
252 *@param tree pointer to data tree Wireshark uses to display packet.
254 void
255 dissect_zbee_zdp_req_user_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
257 unsigned offset = 0;
258 uint32_t device;
260 proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN, &device);
261 offset += 2;
263 zbee_append_info(tree, pinfo, ", Nwk Addr: 0x%04x", device);
265 /* Dump any leftover bytes. */
266 zdp_dump_excess(tvb, offset, pinfo, tree);
267 } /* dissect_zbee_zdp_req_user_desc */
270 *ZigBee Device Profile dissector for the discovery cache
272 *@param tvb pointer to buffer containing raw packet.
273 *@param pinfo pointer to packet information fields
274 *@param tree pointer to data tree Wireshark uses to display packet.
276 void
277 dissect_zbee_zdp_req_discovery_cache(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
279 unsigned offset = 0;
280 uint64_t ext_addr;
282 proto_tree_add_item(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN);
283 offset += 2;
284 ext_addr = zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, (int)sizeof(uint64_t), NULL);
286 zbee_append_info(tree, pinfo, ", Ext Addr: %s", eui64_to_display(pinfo->pool, ext_addr));
288 /* Dump any leftover bytes. */
289 zdp_dump_excess(tvb, offset, pinfo, tree);
290 } /* dissect_zbee_zdp_req_discovery_cache */
293 *ZigBee Device Profile dissector for the device announcement.
295 *@param tvb pointer to buffer containing raw packet.
296 *@param pinfo pointer to packet information fields
297 *@param tree pointer to data tree Wireshark uses to display packet.
299 void
300 dissect_zbee_zdp_device_annce(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
302 unsigned offset = 0;
303 uint64_t ext_addr;
304 uint32_t short_addr;
305 /*uint8_t capability;*/
307 proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN, &short_addr);
308 offset += 2;
309 ext_addr = zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, (int)sizeof(uint64_t), NULL);
310 /*capability =*/ zdp_parse_cinfo(tree, ett_zbee_zdp_cinfo, tvb, &offset);
312 zbee_append_info(tree, pinfo, ", Nwk Addr: 0x%04x, Ext Addr: %s", short_addr, eui64_to_display(pinfo->pool, ext_addr));
314 /* Dump any leftover bytes. */
315 zdp_dump_excess(tvb, offset, pinfo, tree);
316 } /* dissect_zbee_zdp_device_annce */
319 *ZigBee Device Profile dissector for the parent announce
321 *@param tvb pointer to buffer containing raw packet.
322 *@param pinfo pointer to packet information fields
323 *@param tree pointer to data tree Wireshark uses to display packet.
325 void
326 dissect_zbee_zdp_parent_annce(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
328 unsigned offset = 0;
329 unsigned n_children;
330 unsigned i;
331 uint64_t ext_addr;
333 proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_number_of_children, tvb, offset, 1, ENC_LITTLE_ENDIAN, &n_children);
334 offset += 1;
336 zbee_append_info(tree, pinfo, ", # children %d :", n_children);
337 for (i = 0 ; i < n_children ; ++i)
339 ext_addr = zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, (int)sizeof(uint64_t), NULL);
340 if (i == 0)
342 zbee_append_info(tree, pinfo, n_children == 1 ? " %s" : " %s ...", eui64_to_display(pinfo->pool, ext_addr));
346 /* Dump any leftover bytes. */
347 zdp_dump_excess(tvb, offset, pinfo, tree);
348 } /* dissect_zbee_zdp_parent_annce */
352 *ZigBee Device Profile dissector for the parent announce rsp
354 *@param tvb pointer to buffer containing raw packet.
355 *@param pinfo pointer to packet information fields
356 *@param tree pointer to data tree Wireshark uses to display packet.
358 void
359 dissect_zbee_zdp_rsp_parent_annce(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
361 unsigned offset = 0;
362 unsigned n_children;
363 unsigned i;
364 uint64_t ext_addr;
365 uint8_t status;
367 status = zdp_parse_status(tree, tvb, &offset);
368 proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_number_of_children, tvb, offset, 1, ENC_LITTLE_ENDIAN, &n_children);
369 offset += 1;
370 zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
371 zbee_append_info(tree, pinfo, ", # children %d :", n_children);
372 for (i = 0 ; i < n_children ; ++i)
374 ext_addr = zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, (int)sizeof(uint64_t), NULL);
375 if (i == 0)
377 zbee_append_info(tree, pinfo, n_children == 1 ? " %s" : " %s ...", eui64_to_display(pinfo->pool, ext_addr));
381 /* Dump any leftover bytes. */
382 zdp_dump_excess(tvb, offset, pinfo, tree);
383 } /* dissect_zbee_zdp_rsp_parent_annce */
386 *ZigBee Device Profile dissector for the end set user
388 *@param tvb pointer to buffer containing raw packet.
389 *@param pinfo pointer to packet information fields
390 *@param tree pointer to data tree Wireshark uses to display packet.
392 void
393 dissect_zbee_zdp_req_set_user_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, uint8_t version)
395 unsigned offset = 0;
396 uint32_t device, user_length;
397 const uint8_t *user;
399 proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN, &device);
400 offset += 2;
401 if (version >= ZBEE_VERSION_2007) {
402 proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_user_length, tvb, offset, 1, ENC_LITTLE_ENDIAN, &user_length);
403 offset += 1;
405 else {
406 /* No Length field in ZigBee 2003 & earlier, uses a fixed length of 16. */
407 user_length = 16;
409 proto_tree_add_item_ret_string(tree, hf_zbee_zdp_user, tvb, offset, user_length, ENC_ASCII, pinfo->pool, &user);
410 offset += user_length;
412 zbee_append_info(tree, pinfo, ", Nwk Addr: 0x%04x, Desc: \'%s\'", device, user);
414 /* Dump any leftover bytes. */
415 zdp_dump_excess(tvb, offset, pinfo, tree);
416 } /* dissect_zbee_zdp_req_set_user_desc */
419 *ZigBee Device Profile dissector for the system server
421 *@param tvb pointer to buffer containing raw packet.
422 *@param pinfo pointer to packet information fields
423 *@param tree pointer to data tree Wireshark uses to display packet.
425 void
426 dissect_zbee_zdp_req_system_server_disc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
428 unsigned offset = 0;
429 /*uint16_t server_flags;*/
431 /*server_flags =*/ zdp_parse_server_flags(tree, ett_zbee_zdp_server, tvb, &offset);
433 /* Dump any leftover bytes. */
434 zdp_dump_excess(tvb, offset, pinfo, tree);
435 } /* dissect_zbee_zdp_req_system_server_disc */
438 *ZigBee Device Profile dissector for the store node cache
440 *@param tvb pointer to buffer containing raw packet.
441 *@param pinfo pointer to packet information fields
442 *@param tree pointer to data tree Wireshark uses to display packet.
444 void
445 dissect_zbee_zdp_req_store_discovery(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
447 proto_tree *field_tree;
448 unsigned offset = 0;
449 unsigned i;
451 uint64_t ext_addr;
452 uint32_t simple_count;
454 proto_tree_add_item(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN);
455 offset += 2;
456 ext_addr = zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, (int)sizeof(uint64_t), NULL);
457 proto_tree_add_item(tree, hf_zbee_zdp_disc_node_size, tvb, offset, 1, ENC_LITTLE_ENDIAN);
458 offset += 1;
459 proto_tree_add_item(tree, hf_zbee_zdp_disc_power_size, tvb, offset, 1, ENC_LITTLE_ENDIAN);
460 offset += 1;
461 proto_tree_add_item(tree, hf_zbee_zdp_disc_ep_count, tvb, offset, 1, ENC_LITTLE_ENDIAN);
462 offset += 1;
463 proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_disc_simple_count, tvb, offset, 1, ENC_LITTLE_ENDIAN, &simple_count);
464 offset += 1;
466 field_tree = proto_tree_add_subtree(tree, tvb, offset, simple_count, ett_zbee_zdp_simple_sizes, NULL, "Simple Descriptor Sizes");
468 for (i=0; i<simple_count; i++) {
469 proto_tree_add_item(field_tree, hf_zbee_zdp_disc_simple_size, tvb, offset, 1, ENC_LITTLE_ENDIAN);
470 offset += 1;
473 zbee_append_info(tree, pinfo, ", Ext Addr: %s", eui64_to_display(pinfo->pool, ext_addr));
475 /* Dump any leftover bytes. */
476 zdp_dump_excess(tvb, offset, pinfo, tree);
477 } /* dissect_zbee_zdp_req_store_discovery */
480 *ZigBee Device Profile dissector for the store node descriptor
482 *@param tvb pointer to buffer containing raw packet.
483 *@param pinfo pointer to packet information fields
484 *@param tree pointer to data tree Wireshark uses to display packet.
486 void
487 dissect_zbee_zdp_req_store_node_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, uint8_t version)
489 unsigned offset = 0;
490 uint64_t ext_addr;
492 proto_tree_add_item(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN);
493 offset += 2;
494 ext_addr = zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, (int)sizeof(uint64_t), NULL);
495 zdp_parse_node_desc(tree, pinfo, false, ett_zbee_zdp_node, tvb, &offset, version);
497 zbee_append_info(tree, pinfo, ", Address: %s", eui64_to_display(pinfo->pool, ext_addr));
499 /* Dump any leftover bytes. */
500 zdp_dump_excess(tvb, offset, pinfo, tree);
501 } /* dissect_zbee_zdp_req_store_node_desc */
504 *ZigBee Device Profile dissector for the store power descriptor
506 *@param tvb pointer to buffer containing raw packet.
507 *@param pinfo pointer to packet information fields
508 *@param tree pointer to data tree Wireshark uses to display packet.
510 void
511 dissect_zbee_zdp_req_store_power_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
513 unsigned offset = 0;
514 uint64_t ext_addr;
516 proto_tree_add_item(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN);
517 offset += 2;
518 ext_addr = zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, (int)sizeof(uint64_t), NULL);
519 zdp_parse_power_desc(tree, ett_zbee_zdp_power, tvb, &offset);
521 zbee_append_info(tree, pinfo, ", Address: %s", eui64_to_display(pinfo->pool, ext_addr));
523 /* Dump any leftover bytes. */
524 zdp_dump_excess(tvb, offset, pinfo, tree);
525 } /* dissect_zbee_zdp_req_store_power_desc */
528 *ZigBee Device Profile dissector for the store active endpoint
530 *@param tvb pointer to buffer containing raw packet.
531 *@param pinfo pointer to packet information fields
532 *@param tree pointer to data tree Wireshark uses to display packet.
534 void
535 dissect_zbee_zdp_req_store_active_ep(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
537 proto_tree *field_tree;
538 unsigned offset = 0;
539 unsigned i;
541 uint64_t ext_addr;
542 uint32_t ep_count;
544 proto_tree_add_item(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN);
545 offset += 2;
546 ext_addr = zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, (int)sizeof(uint64_t), NULL);
547 proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_disc_simple_count, tvb, offset, 1, ENC_LITTLE_ENDIAN, &ep_count);
548 offset += 1;
550 field_tree = proto_tree_add_subtree(tree, tvb, offset, ep_count, ett_zbee_zdp_endpoint, NULL, "Active Endpoints");
552 for (i=0; i<ep_count; i++) {
553 proto_tree_add_item(field_tree, hf_zbee_zdp_endpoint, tvb, offset, 1, ENC_LITTLE_ENDIAN);
554 offset += 1;
557 zbee_append_info(tree, pinfo, ", Device: %s", eui64_to_display(pinfo->pool, ext_addr));
559 /* Dump any leftover bytes. */
560 zdp_dump_excess(tvb, offset, pinfo, tree);
561 } /* dissect_zbee_zdp_req_store_active_ep */
564 *ZigBee Device Profile dissector for the store simple descriptor
566 *@param tvb pointer to buffer containing raw packet.
567 *@param pinfo pointer to packet information fields
568 *@param tree pointer to data tree Wireshark uses to display packet.
570 void
571 dissect_zbee_zdp_req_store_simple_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, uint8_t version)
573 unsigned offset = 0;
574 uint64_t ext_addr;
576 proto_tree_add_item(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN);
577 offset += 2;
578 ext_addr = zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, (int)sizeof(uint64_t), NULL);
579 proto_tree_add_item(tree, hf_zbee_zdp_simple_length, tvb, offset, 1, ENC_LITTLE_ENDIAN);
580 offset += 1;
581 zdp_parse_simple_desc(tree, ett_zbee_zdp_simple, tvb, &offset, version);
583 zbee_append_info(tree, pinfo, ", Address: %s", eui64_to_display(pinfo->pool, ext_addr));
585 /* Dump any leftover bytes. */
586 zdp_dump_excess(tvb, offset, pinfo, tree);
587 } /* dissect_zbee_zdp_req_store_simple_desc */
590 *ZigBee Device Profile dissector for the remove node cache
592 *@param tvb pointer to buffer containing raw packet.
593 *@param pinfo pointer to packet information fields
594 *@param tree pointer to data tree Wireshark uses to display packet.
596 void
597 dissect_zbee_zdp_req_remove_node_cache(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
599 unsigned offset = 0;
600 uint64_t ext_addr;
602 proto_tree_add_item(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN);
603 offset += 2;
604 ext_addr = zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, (int)sizeof(uint64_t), NULL);
606 zbee_append_info(tree, pinfo, ", Device: %s", eui64_to_display(pinfo->pool, ext_addr));
608 /* Dump any leftover bytes. */
609 zdp_dump_excess(tvb, offset, pinfo, tree);
610 } /* dissect_zbee_zdp_req_remove_node_cache */
613 *ZigBee Device Profile dissector for the find node cache
615 *@param tvb pointer to buffer containing raw packet.
616 *@param pinfo pointer to packet information fields
617 *@param tree pointer to data tree Wireshark uses to display packet.
619 void
620 dissect_zbee_zdp_req_find_node_cache(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
622 unsigned offset = 0;
623 uint64_t ext_addr;
625 proto_tree_add_item(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN);
626 offset += 2;
627 ext_addr = zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, (int)sizeof(uint64_t), NULL);
629 zbee_append_info(tree, pinfo, ", Address: %s", eui64_to_display(pinfo->pool, ext_addr));
631 /* Dump any leftover bytes. */
632 zdp_dump_excess(tvb, offset, pinfo, tree);
633 } /* dissect_zbee_zdp_req_find_node_cache */
636 *ZigBee Device Profile dissector for the extended simple
638 *@param tvb pointer to buffer containing raw packet.
639 *@param pinfo pointer to packet information fields
640 *@param tree pointer to data tree Wireshark uses to display packet.
642 void
643 dissect_zbee_zdp_req_ext_simple_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
645 unsigned offset = 0;
646 uint32_t device, endpt;
648 proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN, &device);
649 offset += 2;
650 proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_endpoint, tvb, offset, 1, ENC_LITTLE_ENDIAN, &endpt);
651 offset += 1;
652 proto_tree_add_item(tree, hf_zbee_zdp_index, tvb, offset, 1, ENC_LITTLE_ENDIAN);
653 offset += 1;
655 zbee_append_info(tree, pinfo, ", Nwk Addr: 0x%04x, Endpoint: %d", device, endpt);
657 /* Dump any leftover bytes. */
658 zdp_dump_excess(tvb, offset, pinfo, tree);
659 } /* dissect_zbee_zdp_req_ext_simple_desc */
662 *ZigBee Device Profile dissector for the extended active
664 *@param tvb pointer to buffer containing raw packet.
665 *@param pinfo pointer to packet information fields
666 *@param tree pointer to data tree Wireshark uses to display packet.
668 void
669 dissect_zbee_zdp_req_ext_active_ep(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
671 unsigned offset = 0;
672 uint32_t device;
673 /*uint8_t idx;*/
675 proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN, &device);
676 offset += 2;
677 proto_tree_add_item(tree, hf_zbee_zdp_index, tvb, offset, 1, ENC_LITTLE_ENDIAN);
678 offset += 1;
680 zbee_append_info(tree, pinfo, ", Nwk Addr: 0x%04x", device);
682 /* Dump any leftover bytes. */
683 zdp_dump_excess(tvb, offset, pinfo, tree);
684 } /* dissect_zbee_zdp_req_ext_active_ep */
686 /**************************************
687 * DISCOVERY RESPONSES
688 **************************************
691 *ZigBee Device Profile dissector for the network address
693 *@param tvb pointer to buffer containing raw packet.
694 *@param pinfo pointer to packet information fields
695 *@param tree pointer to data tree Wireshark uses to display packet.
697 void
698 dissect_zbee_zdp_rsp_nwk_addr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
700 proto_tree *field_tree = NULL;
701 unsigned offset = 0;
702 unsigned i;
704 uint8_t status;
705 uint64_t ext_addr;
706 uint32_t device, assoc;
708 status = zdp_parse_status(tree, tvb, &offset);
709 ext_addr = zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, (int)sizeof(uint64_t), NULL);
710 proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN, &device);
711 offset += 2;
713 if (tvb_bytes_exist(tvb, offset, 1)) {
714 /* The presence of these fields depends on the request message. Include them if they exist. */
715 proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_assoc_device_count, tvb, offset, 1, ENC_LITTLE_ENDIAN, &assoc);
716 offset += 1;
718 if ((tree) && (assoc)) {
719 proto_tree_add_item(tree, hf_zbee_zdp_index, tvb, offset, 1, ENC_LITTLE_ENDIAN);
720 offset += 1;
722 field_tree = proto_tree_add_subtree(tree, tvb, offset, assoc*(int)sizeof(uint16_t),
723 ett_zbee_zdp_assoc_device, NULL, "Associated Device List");
725 for (i=0; i<assoc; i++) {
726 proto_tree_add_item(field_tree, hf_zbee_zdp_assoc_device, tvb, offset, 2, ENC_LITTLE_ENDIAN);
727 offset += 2;
732 zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
733 if (status == ZBEE_ZDP_STATUS_SUCCESS) {
734 zbee_append_info(tree, pinfo, ", Address: %s = 0x%04x", eui64_to_display(pinfo->pool, ext_addr), device);
737 /* Dump any leftover bytes. */
738 zdp_dump_excess(tvb, offset, pinfo, tree);
739 } /* dissect_zbee_zdp_rsp_nwk_addr */
742 *ZigBee Device Profile dissector for the extended address
744 *@param tvb pointer to buffer containing raw packet.
745 *@param pinfo pointer to packet information fields
746 *@param tree pointer to data tree Wireshark uses to display packet.
748 void
749 dissect_zbee_zdp_rsp_ext_addr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
751 proto_tree *field_tree = NULL;
752 unsigned offset = 0;
753 unsigned i;
755 uint8_t status;
756 uint64_t ext_addr;
757 uint32_t device, assoc;
759 status = zdp_parse_status(tree, tvb, &offset);
760 ext_addr = zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, (int)sizeof(uint64_t), NULL);
761 proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN, &device);
762 offset += 2;
764 if (tvb_bytes_exist(tvb, offset, 1)) {
765 /* The presence of these fields depends on the request message. Include them if they exist. */
766 proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_assoc_device_count, tvb, offset, 1, ENC_LITTLE_ENDIAN, &assoc);
767 offset += 1;
769 if ((tree) && (assoc)) {
770 proto_tree_add_item(tree, hf_zbee_zdp_index, tvb, offset, 1, ENC_LITTLE_ENDIAN);
771 offset += 1;
773 field_tree = proto_tree_add_subtree(tree, tvb, offset, assoc*(int)sizeof(uint16_t),
774 ett_zbee_zdp_assoc_device, NULL, "Associated Device List");
776 for (i=0; i<assoc; i++) {
777 proto_tree_add_item(field_tree, hf_zbee_zdp_assoc_device, tvb, offset, 2, ENC_LITTLE_ENDIAN);
778 offset += 2;
782 zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
783 if (status == ZBEE_ZDP_STATUS_SUCCESS) {
784 zbee_append_info(tree, pinfo, ", Nwk Addr: 0x%04x = %s", device, eui64_to_display(pinfo->pool, ext_addr));
787 /* Dump any leftover bytes. */
788 zdp_dump_excess(tvb, offset, pinfo, tree);
789 } /* dissect_zbee_zdp_rsp_ext_addr */
792 *ZigBee Device Profile dissector for the node descriptor
794 *@param tvb pointer to buffer containing raw packet.
795 *@param pinfo pointer to packet information fields
796 *@param tree pointer to data tree Wireshark uses to display packet.
798 void
799 dissect_zbee_zdp_rsp_node_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, uint8_t version)
801 unsigned offset = 0;
803 uint8_t status;
804 uint32_t device;
806 status = zdp_parse_status(tree, tvb, &offset);
807 proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN, &device);
808 offset += 2;
809 if (status == ZBEE_ZDP_STATUS_SUCCESS) {
810 zdp_parse_node_desc(tree, pinfo, true, ett_zbee_zdp_node, tvb, &offset, version);
813 zbee_append_info(tree, pinfo, ", Nwk Addr: 0x%04x", device);
814 zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
816 offset = dissect_zbee_tlvs(tvb, pinfo, tree, offset, NULL, ZBEE_TLV_SRC_TYPE_ZBEE_ZDP, ZBEE_ZDP_RSP_NODE_DESC);
818 /* Dump any leftover bytes. */
819 zdp_dump_excess(tvb, offset, pinfo, tree);
820 } /* dissect_zbee_zdp_rsp_node_desc */
823 *ZigBee Device Profile dissector for the power descriptor
825 *@param tvb pointer to buffer containing raw packet.
826 *@param pinfo pointer to packet information fields
827 *@param tree pointer to data tree Wireshark uses to display packet.
829 void
830 dissect_zbee_zdp_rsp_power_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
832 unsigned offset = 0;
834 uint8_t status;
835 uint32_t device;
837 status = zdp_parse_status(tree, tvb, &offset);
838 proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN, &device);
839 offset += 2;
840 if (status == ZBEE_ZDP_STATUS_SUCCESS) {
841 zdp_parse_power_desc(tree, ett_zbee_zdp_power, tvb, &offset);
844 zbee_append_info(tree, pinfo, ", Nwk Addr: 0x%04x", device);
845 zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
847 /* Dump any leftover bytes. */
848 zdp_dump_excess(tvb, offset, pinfo, tree);
849 } /* dissect_zbee_zdp_rsp_power_desc */
852 *ZigBee Device Profile dissector for the simple descriptor
854 *@param tvb pointer to buffer containing raw packet.
855 *@param pinfo pointer to packet information fields
856 *@param tree pointer to data tree Wireshark uses to display packet.
858 void
859 dissect_zbee_zdp_rsp_simple_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, uint8_t version)
861 unsigned offset = 0;
863 uint8_t status;
864 /*uint8_t length;*/
865 uint32_t device;
867 status = zdp_parse_status(tree, tvb, &offset);
868 proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN, &device);
869 offset += 2;
870 proto_tree_add_item(tree, hf_zbee_zdp_simple_length, tvb, offset, 1, ENC_LITTLE_ENDIAN);
871 offset += 1;
872 if (status == ZBEE_ZDP_STATUS_SUCCESS) {
873 zdp_parse_simple_desc(tree, ett_zbee_zdp_simple, tvb, &offset, version);
876 zbee_append_info(tree, pinfo, ", Nwk Addr: 0x%04x", device);
877 zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
879 /* Dump any leftover bytes. */
880 zdp_dump_excess(tvb, offset, pinfo, tree);
881 } /* dissect_zbee_zdp_rsp_simple_desc */
884 *ZigBee Device Profile dissector for the active endpoint
886 *@param tvb pointer to buffer containing raw packet.
887 *@param pinfo pointer to packet information fields
888 *@param tree pointer to data tree Wireshark uses to display packet.
890 void
891 dissect_zbee_zdp_rsp_active_ep(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
893 proto_tree *field_tree = NULL;
894 unsigned offset = 0;
895 unsigned i;
897 uint8_t status;
898 uint32_t device, ep_count;
900 status = zdp_parse_status(tree, tvb, &offset);
901 proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN, &device);
902 offset += 2;
903 proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_ep_count, tvb, offset, 1, ENC_LITTLE_ENDIAN, &ep_count);
904 offset += 1;
907 if (tree && ep_count) {
908 field_tree = proto_tree_add_subtree(tree, tvb, offset, ep_count*(int)sizeof(uint8_t),
909 ett_zbee_zdp_endpoint, NULL, "Active Endpoint List");
911 for (i=0; i<ep_count; i++) {
912 proto_tree_add_item(field_tree, hf_zbee_zdp_endpoint, tvb, offset, 1, ENC_LITTLE_ENDIAN);
913 offset += 1;
916 zbee_append_info(tree, pinfo, ", Nwk Addr: 0x%04x", device);
917 zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
919 /* Dump any leftover bytes. */
920 zdp_dump_excess(tvb, offset, pinfo, tree);
921 } /* dissect_zbee_zdp_rsp_active_ep */
924 *ZigBee Device Profile dissector for the simple descriptor
926 *@param tvb pointer to buffer containing raw packet.
927 *@param pinfo pointer to packet information fields
928 *@param tree pointer to data tree Wireshark uses to display packet.
930 void
931 dissect_zbee_zdp_rsp_match_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
933 proto_tree *field_tree = NULL;
934 unsigned offset = 0;
935 unsigned i;
937 uint8_t status;
938 uint32_t device, ep_count;
940 status = zdp_parse_status(tree, tvb, &offset);
941 proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN, &device);
942 offset += 2;
943 proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_ep_count, tvb, offset, 1, ENC_LITTLE_ENDIAN, &ep_count);
944 offset += 1;
946 if (tree && ep_count) {
947 field_tree = proto_tree_add_subtree(tree, tvb, offset, ep_count*(int)sizeof(uint8_t),
948 ett_zbee_zdp_endpoint, NULL, "Matching Endpoint List");
950 for (i=0; i<ep_count; i++) {
951 proto_tree_add_item(field_tree, hf_zbee_zdp_endpoint, tvb, offset, 1, ENC_LITTLE_ENDIAN);
952 offset += 1;
955 zbee_append_info(tree, pinfo, ", Nwk Addr: 0x%04x", device);
956 zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
958 /* Dump any leftover bytes. */
959 zdp_dump_excess(tvb, offset, pinfo, tree);
960 } /* dissect_zbee_zdp_rsp_match_desc */
963 *ZigBee Device Profile dissector for the complex descriptor
965 *@param tvb pointer to buffer containing raw packet.
966 *@param pinfo pointer to packet information fields
967 *@param tree pointer to data tree Wireshark uses to display packet.
969 void
970 dissect_zbee_zdp_rsp_complex_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
972 unsigned offset = 0;
974 uint8_t status;
975 uint32_t device, length;
977 status = zdp_parse_status(tree, tvb, &offset);
979 if ((status == ZBEE_ZDP_STATUS_SUCCESS) || (tvb_bytes_exist(tvb, offset, 2))) {
980 proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN, &device);
981 zbee_append_info(tree, pinfo, ", Nwk Addr: 0x%04x", device);
982 offset += 2;
984 if ((status == ZBEE_ZDP_STATUS_SUCCESS) || (tvb_bytes_exist(tvb, offset, 1))) {
985 proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_complex_length, tvb, offset, 1, ENC_LITTLE_ENDIAN, &length);
986 offset += 1;
988 if (length) {
989 zdp_parse_complex_desc(pinfo, tree, -1, tvb, &offset, length);
993 /* Dump any leftover bytes. */
994 zdp_dump_excess(tvb, offset, pinfo, tree);
997 zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
999 } /* dissect_zbee_zdp_rsp_complex_desc */
1002 *ZigBee Device Profile dissector for the user descriptor
1004 *@param tvb pointer to buffer containing raw packet.
1005 *@param pinfo pointer to packet information fields
1006 *@param tree pointer to data tree Wireshark uses to display packet.
1008 void
1009 dissect_zbee_zdp_rsp_user_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, uint8_t version)
1011 unsigned offset = 0;
1012 uint8_t status;
1013 uint32_t device, user_length;
1014 char *user;
1016 status = zdp_parse_status(tree, tvb, &offset);
1017 if ((status == ZBEE_ZDP_STATUS_SUCCESS) || (tvb_bytes_exist(tvb, offset, 2))) {
1018 proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN, &device);
1019 zbee_append_info(tree, pinfo, ", Nwk Addr: 0x%04x", device);
1020 offset += 2;
1022 if ((version >= ZBEE_VERSION_2007) || (status == ZBEE_ZDP_STATUS_SUCCESS)) {
1023 /* In ZigBee 2003 & earlier, the length field is omitted if not successful. */
1024 proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_user_length, tvb, offset, 1, ENC_LITTLE_ENDIAN, &user_length);
1025 offset += 1;
1027 else user_length = 0;
1029 user = tvb_get_string_enc(pinfo->pool, tvb, offset, user_length, ENC_ASCII);
1030 if (tree) {
1031 proto_tree_add_string(tree, hf_zbee_zdp_user, tvb, offset, user_length, user);
1033 offset += user_length;
1035 if (status == ZBEE_ZDP_STATUS_SUCCESS) {
1036 zbee_append_info(tree, pinfo, ", Desc: \'%s\'", user);
1038 zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
1040 /* Dump any leftover bytes. */
1041 zdp_dump_excess(tvb, offset, pinfo, tree);
1042 } /* dissect_zbee_zdp_rsp_user_desc */
1045 *ZigBee Device Profile dissector for the set user descriptor
1047 *@param tvb pointer to buffer containing raw packet.
1048 *@param pinfo pointer to packet information fields
1049 *@param tree pointer to data tree Wireshark uses to display packet.
1051 void
1052 dissect_zbee_zdp_rsp_user_desc_conf(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, uint8_t version)
1054 unsigned offset = 0;
1055 uint8_t status;
1056 uint32_t device = 0;
1058 status = zdp_parse_status(tree, tvb, &offset);
1059 if (version >= ZBEE_VERSION_2007) {
1060 if ((status == ZBEE_ZDP_STATUS_SUCCESS) || (tvb_bytes_exist(tvb, offset, 2))) {
1061 /* Device address present only on ZigBee 2006 & later. */
1062 proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN, &device);
1063 zbee_append_info(tree, pinfo, ", Nwk Addr: 0x%04x", device);
1064 offset += 2;
1068 zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
1070 /* Dump any leftover bytes. */
1071 zdp_dump_excess(tvb, offset, pinfo, tree);
1072 } /* dissect_zbee_zdp_rsp_user_desc_conf */
1075 *ZigBee Device Profile dissector for the discovery cache
1077 *@param tvb pointer to buffer containing raw packet.
1078 *@param pinfo pointer to packet information fields
1079 *@param tree pointer to data tree Wireshark uses to display packet.
1081 void
1082 dissect_zbee_zdp_rsp_discovery_cache(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1084 unsigned offset = 0;
1085 uint8_t status;
1087 status = zdp_parse_status(tree, tvb, &offset);
1088 zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
1090 /* Dump any leftover bytes. */
1091 zdp_dump_excess(tvb, offset, pinfo, tree);
1092 } /* dissect_zbee_zdp_rsp_discovery_cache */
1095 *ZigBee Device Profile dissector for the system server discovery
1097 *@param tvb pointer to buffer containing raw packet.
1098 *@param pinfo pointer to packet information fields
1099 *@param tree pointer to data tree Wireshark uses to display packet.
1101 void
1102 dissect_zbee_zdp_rsp_system_server_disc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1104 unsigned offset = 0;
1105 uint8_t status;
1107 status = zdp_parse_status(tree, tvb, &offset);
1109 if ((status == ZBEE_ZDP_STATUS_SUCCESS) || (tvb_bytes_exist(tvb, offset, 2))) {
1110 zdp_parse_server_flags(tree, ett_zbee_zdp_server, tvb, &offset);
1113 zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
1115 /* Dump any leftover bytes. */
1116 zdp_dump_excess(tvb, offset, pinfo, tree);
1117 } /* dissect_zbee_zdp_rsp_system_server_disc */
1120 *ZigBee Device Profile dissector for the discovery store
1122 *@param tvb pointer to buffer containing raw packet.
1123 *@param pinfo pointer to packet information fields
1124 *@param tree pointer to data tree Wireshark uses to display packet.
1126 void
1127 dissect_zbee_zdp_rsp_discovery_store(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1129 unsigned offset = 0;
1130 uint8_t status;
1132 status = zdp_parse_status(tree, tvb, &offset);
1133 zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
1135 /* Dump any leftover bytes. */
1136 zdp_dump_excess(tvb, offset, pinfo, tree);
1137 } /* dissect_zbee_zdp_rsp_discovery_store */
1140 *ZigBee Device Profile dissector for the store node descriptor
1142 *@param tvb pointer to buffer containing raw packet.
1143 *@param pinfo pointer to packet information fields
1144 *@param tree pointer to data tree Wireshark uses to display packet.
1146 void
1147 dissect_zbee_zdp_rsp_store_node_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1149 unsigned offset = 0;
1150 uint8_t status;
1152 status = zdp_parse_status(tree, tvb, &offset);
1153 zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
1155 /* Dump any leftover bytes. */
1156 zdp_dump_excess(tvb, offset, pinfo, tree);
1157 } /* dissect_zbee_zdp_rsp_store_node_desc */
1160 *ZigBee Device Profile dissector for the store power descriptor
1162 *@param tvb pointer to buffer containing raw packet.
1163 *@param pinfo pointer to packet information fields
1164 *@param tree pointer to data tree Wireshark uses to display packet.
1166 void
1167 dissect_zbee_zdp_rsp_store_power_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1169 unsigned offset = 0;
1170 uint8_t status;
1172 status = zdp_parse_status(tree, tvb, &offset);
1173 zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
1175 /* Dump any leftover bytes. */
1176 zdp_dump_excess(tvb, offset, pinfo, tree);
1177 } /* dissect_zbee_zdp_rsp_store_power_desc */
1180 *ZigBee Device Profile dissector for the store active endpoints
1182 *@param tvb pointer to buffer containing raw packet.
1183 *@param pinfo pointer to packet information fields
1184 *@param tree pointer to data tree Wireshark uses to display packet.
1186 void
1187 dissect_zbee_zdp_rsp_store_active_ep(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1189 unsigned offset = 0;
1190 uint8_t status;
1192 status = zdp_parse_status(tree, tvb, &offset);
1193 zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
1195 /* Dump any leftover bytes. */
1196 zdp_dump_excess(tvb, offset, pinfo, tree);
1197 } /* dissect_zbee_zdp_rsp_store_active_ep */
1200 *ZigBee Device Profile dissector for the store power descriptor
1202 *@param tvb pointer to buffer containing raw packet.
1203 *@param pinfo pointer to packet information fields
1204 *@param tree pointer to data tree Wireshark uses to display packet.
1206 void
1207 dissect_zbee_zdp_rsp_store_simple_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1209 unsigned offset = 0;
1210 uint8_t status;
1212 status = zdp_parse_status(tree, tvb, &offset);
1213 zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
1215 /* Dump any leftover bytes. */
1216 zdp_dump_excess(tvb, offset, pinfo, tree);
1217 } /* dissect_zbee_zdp_rsp_store_simple_desc */
1220 *ZigBee Device Profile dissector for the remove node cache
1222 *@param tvb pointer to buffer containing raw packet.
1223 *@param pinfo pointer to packet information fields
1224 *@param tree pointer to data tree Wireshark uses to display packet.
1226 void
1227 dissect_zbee_zdp_rsp_remove_node_cache(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1229 unsigned offset = 0;
1230 uint8_t status;
1232 status = zdp_parse_status(tree, tvb, &offset);
1233 zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
1235 /* Dump any leftover bytes. */
1236 zdp_dump_excess(tvb, offset, pinfo, tree);
1237 } /* dissect_zbee_zdp_rsp_remove_node_cache */
1240 *ZigBee Device Profile dissector for the find node cache
1242 *@param tvb pointer to buffer containing raw packet.
1243 *@param pinfo pointer to packet information fields
1244 *@param tree pointer to data tree Wireshark uses to display packet.
1246 void
1247 dissect_zbee_zdp_rsp_find_node_cache(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1249 unsigned offset = 0;
1250 uint32_t device, cache;
1252 /* Find Node Cache does NOT start with status */
1253 proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_cache, tvb, offset, 2, ENC_LITTLE_ENDIAN, &cache);
1254 offset += 2;
1255 proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN, &device);
1256 offset += 2;
1257 /*ext_addr =*/ zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, (int)sizeof(uint64_t), NULL);
1259 zbee_append_info(tree, pinfo, ", Cache: 0x%04x", cache);
1260 zbee_append_info(tree, pinfo, ", Nwk Addr: 0x%04x", device);
1262 /* Dump any leftover bytes. */
1263 zdp_dump_excess(tvb, offset, pinfo, tree);
1264 } /* dissect_zbee_zdp_rsp_find_node_cache */
1267 *ZigBee Device Profile dissector for the extended simple
1269 *@param tvb pointer to buffer containing raw packet.
1270 *@param pinfo pointer to packet information fields
1271 *@param tree pointer to data tree Wireshark uses to display packet.
1273 void
1274 dissect_zbee_zdp_rsp_ext_simple_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1276 proto_item *ti;
1277 unsigned offset = 0;
1278 unsigned i;
1279 unsigned sizeof_cluster = (int)sizeof(uint16_t);
1280 uint8_t status;
1281 uint32_t device, cluster, in_count, out_count, idx;
1283 status = zdp_parse_status(tree, tvb, &offset);
1284 if ((status == ZBEE_ZDP_STATUS_SUCCESS) || (tvb_bytes_exist(tvb, offset, 2))) {
1285 proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN, &device);
1286 zbee_append_info(tree, pinfo, ", Nwk Addr: 0x%04x", device);
1287 offset += 2;
1290 if (status == ZBEE_ZDP_STATUS_SUCCESS) {
1291 proto_tree_add_item(tree, hf_zbee_zdp_endpoint, tvb, offset, 1, ENC_LITTLE_ENDIAN);
1292 offset += 1;
1293 proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_in_count, tvb, offset, 1, ENC_LITTLE_ENDIAN, &in_count);
1294 offset += 1;
1295 proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_out_count, tvb, offset, 1, ENC_LITTLE_ENDIAN, &out_count);
1296 offset += 1;
1297 proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_index, tvb, offset, 1, ENC_LITTLE_ENDIAN, &idx);
1298 offset += 1;
1300 /* Display the input cluster list. */
1301 for (i=idx; (i<in_count) && tvb_bytes_exist(tvb, offset, sizeof_cluster); i++) {
1302 ti = proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_in_cluster, tvb, offset, sizeof_cluster, ENC_LITTLE_ENDIAN, &cluster);
1303 offset += sizeof_cluster;
1304 proto_item_append_text(ti, " (%s)", rval_to_str_const(cluster, zbee_aps_cid_names, "Unknown Cluster"));
1305 } /* for */
1306 for (i-=in_count; (i<out_count) && tvb_bytes_exist(tvb, offset, sizeof_cluster); i++) {
1307 ti = proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_out_cluster, tvb, offset, sizeof_cluster, ENC_LITTLE_ENDIAN, &cluster);
1308 offset += sizeof_cluster;
1309 proto_item_append_text(ti, " (%s)", rval_to_str_const(cluster, zbee_aps_cid_names, "Unknown Cluster"));
1310 } /* for */
1312 zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
1314 /* Dump any leftover bytes. */
1315 zdp_dump_excess(tvb, offset, pinfo, tree);
1316 } /* dissect_zbee_zdp_rsp_ext_simple_desc */
1319 *ZigBee Device Profile dissector for the extended active
1321 *@param tvb pointer to buffer containing raw packet.
1322 *@param pinfo pointer to packet information fields
1323 *@param tree pointer to data tree Wireshark uses to display packet.
1325 void
1326 dissect_zbee_zdp_rsp_ext_active_ep(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1328 proto_tree *field_tree = NULL;
1329 unsigned offset = 0;
1330 unsigned i;
1332 uint8_t status;
1333 uint32_t device, ep_count, idx;
1335 status = zdp_parse_status(tree, tvb, &offset);
1336 if ((status == ZBEE_ZDP_STATUS_SUCCESS) || (tvb_bytes_exist(tvb, offset, 2))) {
1337 proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN, &device);
1338 zbee_append_info(tree, pinfo, ", Nwk Addr: 0x%04x", device);
1339 offset += 2;
1342 /* on success require both, when unsuccessful okay to skip both but not just one */
1343 if ((status == ZBEE_ZDP_STATUS_SUCCESS) || (tvb_bytes_exist(tvb, offset, 1))) {
1344 proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_ep_count, tvb, offset, 1, ENC_LITTLE_ENDIAN, &ep_count);
1345 offset += 1;
1346 proto_tree_add_item_ret_uint(tree, hf_zbee_zdp_index, tvb, offset, 1, ENC_LITTLE_ENDIAN, &idx);
1347 offset += 1;
1349 if (tree && ep_count) {
1350 field_tree = proto_tree_add_subtree(tree, tvb, offset, ep_count*(int)sizeof(uint8_t),
1351 ett_zbee_zdp_endpoint, NULL, "Active Endpoint List");
1352 for (i=idx; (i<ep_count) && tvb_bytes_exist(tvb, offset, (int)sizeof(uint8_t)); i++) {
1353 proto_tree_add_item(field_tree, hf_zbee_zdp_endpoint, tvb, offset, 1, ENC_LITTLE_ENDIAN);
1354 offset += 1;
1359 zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status));
1361 /* Dump any leftover bytes. */
1362 zdp_dump_excess(tvb, offset, pinfo, tree);
1363 } /* dissect_zbee_zdp_rsp_ext_active_ep */
1366 * Editor modelines - https://www.wireshark.org/tools/modelines.html
1368 * Local variables:
1369 * c-basic-offset: 4
1370 * tab-width: 8
1371 * indent-tabs-mode: nil
1372 * End:
1374 * vi: set shiftwidth=4 tabstop=8 expandtab:
1375 * :indentSize=4:tabSize=8:noTabs=true: