dd3969de706f862523a2c3dd479990b28b2468a7
[obnox/wireshark/wip.git] / epan / dissectors / packet-zbee-zdp.c
1 /* packet-zbee-zdp.c
2  * Dissector routines for the ZigBee Device Profile (ZDP)
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/expert.h>
37
38 #include "packet-zbee.h"
39 #include "packet-zbee-zdp.h"
40
41 /*************************/
42 /* Function Declarations */
43 /*************************/
44 /* Local Helper routines. */
45 static guint16 zdp_convert_2003cluster     (guint8 cluster);
46
47 /* Message dissector routines. */
48 extern void dissect_zbee_zdp_req_nwk_addr           (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
49 extern void dissect_zbee_zdp_req_ext_addr           (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
50 extern void dissect_zbee_zdp_req_node_desc          (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
51 extern void dissect_zbee_zdp_req_power_desc         (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
52 extern void dissect_zbee_zdp_req_simple_desc        (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
53 extern void dissect_zbee_zdp_req_active_ep          (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
54 extern void dissect_zbee_zdp_req_match_desc         (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
55 extern void dissect_zbee_zdp_req_complex_desc       (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
56 extern void dissect_zbee_zdp_req_user_desc          (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
57 extern void dissect_zbee_zdp_req_discovery_cache    (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
58 extern void dissect_zbee_zdp_device_annce           (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
59 extern void dissect_zbee_zdp_req_set_user_desc      (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
60 extern void dissect_zbee_zdp_req_system_server_disc (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
61 extern void dissect_zbee_zdp_req_store_discovery    (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
62 extern void dissect_zbee_zdp_req_store_node_desc    (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
63 extern void dissect_zbee_zdp_req_store_power_desc   (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
64 extern void dissect_zbee_zdp_req_store_active_ep    (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
65 extern void dissect_zbee_zdp_req_store_simple_desc  (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
66 extern void dissect_zbee_zdp_req_remove_node_cache  (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
67 extern void dissect_zbee_zdp_req_find_node_cache    (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
68 extern void dissect_zbee_zdp_req_ext_simple_desc    (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
69 extern void dissect_zbee_zdp_req_ext_active_ep      (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
70
71 extern void dissect_zbee_zdp_req_end_device_bind    (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
72 extern void dissect_zbee_zdp_req_bind               (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
73 extern void dissect_zbee_zdp_req_unbind             (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
74 extern void dissect_zbee_zdp_req_bind_register      (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
75 extern void dissect_zbee_zdp_req_replace_device     (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
76 extern void dissect_zbee_zdp_req_store_bak_bind_entry   (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
77 extern void dissect_zbee_zdp_req_remove_bak_bind_entry  (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
78 extern void dissect_zbee_zdp_req_backup_bind_table  (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
79 extern void dissect_zbee_zdp_req_recover_bind_table (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
80 extern void dissect_zbee_zdp_req_backup_source_bind (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
81 extern void dissect_zbee_zdp_req_recover_source_bind(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
82
83 extern void dissect_zbee_zdp_req_mgmt_nwk_disc      (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
84 extern void dissect_zbee_zdp_req_mgmt_lqi           (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
85 extern void dissect_zbee_zdp_req_mgmt_rtg           (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
86 extern void dissect_zbee_zdp_req_mgmt_bind          (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
87 extern void dissect_zbee_zdp_req_mgmt_leave         (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
88 extern void dissect_zbee_zdp_req_mgmt_direct_join   (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
89 extern void dissect_zbee_zdp_req_mgmt_permit_join   (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
90 extern void dissect_zbee_zdp_req_mgmt_cache         (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
91 extern void dissect_zbee_zdp_req_mgmt_nwkupdate     (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
92
93 extern void dissect_zbee_zdp_rsp_nwk_addr           (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
94 extern void dissect_zbee_zdp_rsp_ext_addr           (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
95 extern void dissect_zbee_zdp_rsp_node_desc          (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
96 extern void dissect_zbee_zdp_rsp_power_desc         (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
97 extern void dissect_zbee_zdp_rsp_simple_desc        (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
98 extern void dissect_zbee_zdp_rsp_active_ep          (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
99 extern void dissect_zbee_zdp_rsp_match_desc         (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
100 extern void dissect_zbee_zdp_rsp_complex_desc       (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
101 extern void dissect_zbee_zdp_rsp_user_desc          (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
102 extern void dissect_zbee_zdp_rsp_user_desc_conf     (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
103 extern void dissect_zbee_zdp_rsp_discovery_cache    (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
104 extern void dissect_zbee_zdp_rsp_system_server_disc (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
105 extern void dissect_zbee_zdp_rsp_discovery_store    (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
106 extern void dissect_zbee_zdp_rsp_store_node_desc    (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
107 extern void dissect_zbee_zdp_rsp_store_power_desc   (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
108 extern void dissect_zbee_zdp_rsp_store_active_ep    (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
109 extern void dissect_zbee_zdp_rsp_store_simple_desc  (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
110 extern void dissect_zbee_zdp_rsp_remove_node_cache  (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
111 extern void dissect_zbee_zdp_rsp_find_node_cache    (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
112 extern void dissect_zbee_zdp_rsp_ext_simple_desc    (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
113 extern void dissect_zbee_zdp_rsp_ext_active_ep      (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
114
115 extern void dissect_zbee_zdp_rsp_end_device_bind    (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
116 extern void dissect_zbee_zdp_rsp_bind               (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
117 extern void dissect_zbee_zdp_rsp_unbind             (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
118 extern void dissect_zbee_zdp_rsp_bind_register      (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
119 extern void dissect_zbee_zdp_rsp_replace_device     (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
120 extern void dissect_zbee_zdp_rsp_store_bak_bind_entry   (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
121 extern void dissect_zbee_zdp_rsp_remove_bak_bind_entry  (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
122 extern void dissect_zbee_zdp_rsp_backup_bind_table  (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
123 extern void dissect_zbee_zdp_rsp_recover_bind_table (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
124 extern void dissect_zbee_zdp_rsp_backup_source_bind (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
125 extern void dissect_zbee_zdp_rsp_recover_source_bind(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
126
127 extern void dissect_zbee_zdp_rsp_mgmt_nwk_disc      (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
128 extern void dissect_zbee_zdp_rsp_mgmt_lqi           (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
129 extern void dissect_zbee_zdp_rsp_mgmt_rtg           (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
130 extern void dissect_zbee_zdp_rsp_mgmt_bind          (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
131 extern void dissect_zbee_zdp_rsp_mgmt_leave         (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
132 extern void dissect_zbee_zdp_rsp_mgmt_direct_join   (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
133 extern void dissect_zbee_zdp_rsp_mgmt_permit_join   (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
134 extern void dissect_zbee_zdp_rsp_mgmt_cache         (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
135 extern void dissect_zbee_zdp_rsp_mgmt_nwkupdate     (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
136
137 /**************************************
138  * Field Indicies
139  **************************************
140  */
141 /* Global field indicies. */
142 int proto_zbee_zdp = -1;
143 int hf_zbee_zdp_seqno = -1;
144 int hf_zbee_zdp_length = -1; /* Deprecates since ZigBee 2006. */
145
146 /* General indicies. */
147 int hf_zbee_zdp_ext_addr = -1;
148 int hf_zbee_zdp_device = -1;
149 int hf_zbee_zdp_req_type = -1;
150 int hf_zbee_zdp_index = -1;
151 int hf_zbee_zdp_status = -1;
152 int hf_zbee_zdp_ep_count = -1;
153 int hf_zbee_zdp_endpoint = -1;
154 int hf_zbee_zdp_profile = -1;
155 int hf_zbee_zdp_cluster = -1;
156 int hf_zbee_zdp_addr_mode = -1;
157 int hf_zbee_zdp_table_size = -1;
158 int hf_zbee_zdp_table_count = -1;
159 int hf_zbee_zdp_in_count = -1;
160 int hf_zbee_zdp_out_count = -1;
161 int hf_zbee_zdp_in_cluster = -1;
162 int hf_zbee_zdp_out_cluster = -1;
163 int hf_zbee_zdp_assoc_device_count = -1;
164 int hf_zbee_zdp_assoc_device = -1;
165
166 /* Capability information indicies. */
167 int hf_zbee_zdp_cinfo_alloc = -1;
168 int hf_zbee_zdp_cinfo_security = -1;
169 int hf_zbee_zdp_cinfo_idle_rx = -1;
170 int hf_zbee_zdp_cinfo_power = -1;
171 int hf_zbee_zdp_cinfo_ffd = -1;
172 int hf_zbee_zdp_cinfo_alt_coord = -1;
173
174 /* Server mode flag indicies. */
175 int hf_zbee_zdp_server_pri_trust = -1;
176 int hf_zbee_zdp_server_bak_trust = -1;
177 int hf_zbee_zdp_server_pri_bind = -1;
178 int hf_zbee_zdp_server_bak_bind = -1;
179 int hf_zbee_zdp_server_pri_disc = -1;
180 int hf_zbee_zdp_server_bak_disc = -1;
181
182 /* Node descriptor indicies. */
183 int hf_zbee_zdp_node_type = -1;
184 int hf_zbee_zdp_node_complex = -1;
185 int hf_zbee_zdp_node_user = -1;
186 int hf_zbee_zdp_node_freq_868 = -1;
187 int hf_zbee_zdp_node_freq_900 = -1;
188 int hf_zbee_zdp_node_freq_2400 = -1;
189 int hf_zbee_zdp_node_manufacturer = -1;
190 int hf_zbee_zdp_node_max_buffer = -1;
191 int hf_zbee_zdp_node_max_transfer = -1;
192
193 /* Power descriptor indicies. */
194 int hf_zbee_zdp_power_mode = -1;
195 int hf_zbee_zdp_power_avail_ac = -1;
196 int hf_zbee_zdp_power_avail_recharge = -1;
197 int hf_zbee_zdp_power_avail_dispose = -1;
198 int hf_zbee_zdp_power_source_ac = -1;
199 int hf_zbee_zdp_power_source_recharge = -1;
200 int hf_zbee_zdp_power_source_dispose = -1;
201 int hf_zbee_zdp_power_level = -1;
202
203 /* Simple descriptor indicies. */
204 int hf_zbee_zdp_simple_app_device = -1;
205 int hf_zbee_zdp_simple_app_version = -1;
206 int hf_zbee_zdp_simple_length = -1;
207
208 /* Complex descriptor indicies. */
209 int hf_zbee_zdp_complex_length = -1;
210 int hf_zbee_zdp_complex_tag = -1;
211 int hf_zbee_zdp_complex = -1;
212
213 /* User descriptor indicies. */
214 int hf_zbee_zdp_user = -1;
215 int hf_zbee_zdp_user_length = -1;
216
217 /* Discovery indicies. */
218 int hf_zbee_zdp_cache = -1;
219 int hf_zbee_zdp_disc_node_size = -1;
220 int hf_zbee_zdp_disc_power_size = -1;
221 int hf_zbee_zdp_disc_ep_count = -1;
222 int hf_zbee_zdp_disc_simple_count = -1;
223 int hf_zbee_zdp_disc_simple_size = -1;
224
225 /* Binding indicies. */
226 int hf_zbee_zdp_target = -1;
227 int hf_zbee_zdp_target64 = -1;
228 int hf_zbee_zdp_target_ep = -1;
229 int hf_zbee_zdp_replacement = -1;
230 int hf_zbee_zdp_replacement_ep = -1;
231 int hf_zbee_zdp_bind_src = -1;
232 int hf_zbee_zdp_bind_src64 = -1;
233 int hf_zbee_zdp_bind_src_ep = -1;
234 int hf_zbee_zdp_bind_dst = -1;
235 int hf_zbee_zdp_bind_dst64 = -1;
236 int hf_zbee_zdp_bind_dst_ep = -1;
237
238 /* Network Management indicies. */
239 int hf_zbee_zdp_duration = -1;
240 int hf_zbee_zdp_leave_children = -1;
241 int hf_zbee_zdp_leave_rejoin = -1;
242 int hf_zbee_zdp_significance = -1;
243 int hf_zbee_zdp_scan_count = -1;
244 int hf_zbee_zdp_update_id = -1;
245 int hf_zbee_zdp_manager = -1;
246 int hf_zbee_zdp_tx_total = -1;
247 int hf_zbee_zdp_tx_fail = -1;
248 int hf_zbee_zdp_channel_count = -1;
249
250 /* Subtree indicies. */
251 gint ett_zbee_zdp = -1;
252 gint ett_zbee_zdp_endpoint = -1;
253 gint ett_zbee_zdp_match_in = -1;
254 gint ett_zbee_zdp_match_out = -1;
255 gint ett_zbee_zdp_node = -1;
256 gint ett_zbee_zdp_node_in = -1;
257 gint ett_zbee_zdp_node_out = -1;
258 gint ett_zbee_zdp_power = -1;
259 gint ett_zbee_zdp_simple = -1;
260 gint ett_zbee_zdp_complex = -1;
261 gint ett_zbee_zdp_cinfo = -1;
262 gint ett_zbee_zdp_server = -1;
263 gint ett_zbee_zdp_simple_sizes = -1;
264 gint ett_zbee_zdp_bind = -1;
265 gint ett_zbee_zdp_bind_end_in = -1;
266 gint ett_zbee_zdp_bind_end_out = -1;
267 gint ett_zbee_zdp_bind_table = -1;
268 gint ett_zbee_zdp_bind_source = -1;
269 gint ett_zbee_zdp_channels = -1;
270 gint ett_zbee_zdp_assoc_device = -1;
271 gint ett_zbee_zdp_nwk = -1;
272 gint ett_zbee_zdp_lqi = -1;
273 gint ett_zbee_zdp_rtg = -1;
274 gint ett_zbee_zdp_cache = -1;
275
276 /* Data dissector handle. */
277 static dissector_handle_t  data_handle;
278
279 /**************************************
280  * Value Strings
281  **************************************
282  */
283 static const value_string zbee_zdp_req_types[] = {
284     { ZBEE_ZDP_REQ_TYPE_SINGLE,     "Single Device Response" },
285     { ZBEE_ZDP_REQ_TYPE_EXTENDED,   "Extended Response" },
286     { 0, NULL }
287 };
288
289 static const value_string zbee_zdp_cluster_names[] = {
290     { ZBEE_ZDP_REQ_NWK_ADDR,            "Network Address Request" },
291     { ZBEE_ZDP_REQ_IEEE_ADDR,           "Extended Address Request" },
292     { ZBEE_ZDP_REQ_NODE_DESC,           "Node Descriptor Request" },
293     { ZBEE_ZDP_REQ_POWER_DESC,          "Power Descriptor Request" },
294     { ZBEE_ZDP_REQ_SIMPLE_DESC,         "Simple Descriptor Request" },
295     { ZBEE_ZDP_REQ_ACTIVE_EP,           "Active Endpoint Request" },
296     { ZBEE_ZDP_REQ_MATCH_DESC,          "Match Descriptor Request" },
297     { ZBEE_ZDP_REQ_COMPLEX_DESC,        "Complex Descriptor Request" },
298     { ZBEE_ZDP_REQ_USER_DESC,           "User Descriptor Request" },
299     { ZBEE_ZDP_REQ_DISCOVERY_CACHE,     "Discovery Cache Request" },
300     { ZBEE_ZDP_REQ_DEVICE_ANNCE,        "Device Announcement" },
301     { ZBEE_ZDP_REQ_SET_USER_DESC,       "Set User Descriptor Request" },
302     { ZBEE_ZDP_REQ_SYSTEM_SERVER_DISC,  "Server Discovery Request" },
303     { ZBEE_ZDP_REQ_STORE_DISCOVERY,     "Store Discovery Request" },
304     { ZBEE_ZDP_REQ_STORE_NODE_DESC,     "Store Node Descriptor Request" },
305     { ZBEE_ZDP_REQ_STORE_POWER_DESC,    "Store Power Descriptor Request" },
306     { ZBEE_ZDP_REQ_STORE_ACTIVE_EP,     "Store Active Endpoints Request" },
307     { ZBEE_ZDP_REQ_STORE_SIMPLE_DESC,   "Store Simple Descriptor Request" },
308     { ZBEE_ZDP_REQ_REMOVE_NODE_CACHE,   "Remove Node Cache Request" },
309     { ZBEE_ZDP_REQ_FIND_NODE_CACHE,     "Find Node Cache Request" },
310     { ZBEE_ZDP_REQ_EXT_SIMPLE_DESC,     "Extended Simple Descriptor Request" },
311     { ZBEE_ZDP_REQ_EXT_ACTIVE_EP,       "Extended Active Endpoint Request" },
312     { ZBEE_ZDP_REQ_END_DEVICE_BIND,     "End Device Bind Request" },
313     { ZBEE_ZDP_REQ_BIND,                "Bind Request" },
314     { ZBEE_ZDP_REQ_UNBIND,              "Unbind Request" },
315     { ZBEE_ZDP_REQ_BIND_REGISTER,       "Bind Register Request" },
316     { ZBEE_ZDP_REQ_REPLACE_DEVICE,      "Replace Device Request" },
317     { ZBEE_ZDP_REQ_STORE_BAK_BIND_ENTRY,    "Store Backup Binding Request" },
318     { ZBEE_ZDP_REQ_REMOVE_BAK_BIND_ENTRY,   "Remove Backup Binding Request" },
319     { ZBEE_ZDP_REQ_BACKUP_BIND_TABLE,   "Backup Binding Table Request" },
320     { ZBEE_ZDP_REQ_RECOVER_BIND_TABLE,  "Recover Binding Table Request" },
321     { ZBEE_ZDP_REQ_BACKUP_SOURCE_BIND,  "Backup Source Binding Request" },
322     { ZBEE_ZDP_REQ_RECOVER_SOURCE_BIND, "Recover Source Binding Request" },
323     { ZBEE_ZDP_REQ_MGMT_NWK_DISC,       "Network Discovery Request" },
324     { ZBEE_ZDP_REQ_MGMT_LQI,            "Link Quality Request" },
325     { ZBEE_ZDP_REQ_MGMT_RTG,            "Routing Table Request" },
326     { ZBEE_ZDP_REQ_MGMT_BIND,           "Binding Table Request" },
327     { ZBEE_ZDP_REQ_MGMT_LEAVE,          "Leave Request" },
328     { ZBEE_ZDP_REQ_MGMT_DIRECT_JOIN,    "Direct Join Request" },
329     { ZBEE_ZDP_REQ_MGMT_PERMIT_JOIN,    "Permit Join Request" },
330     { ZBEE_ZDP_REQ_MGMT_CACHE,          "Cache Request" },
331     { ZBEE_ZDP_REQ_MGMT_NWKUPDATE,      "Network Update Request" },
332
333     { ZBEE_ZDP_RSP_NWK_ADDR,            "Network Address Response" },
334     { ZBEE_ZDP_RSP_IEEE_ADDR,           "Extended Address Response" },
335     { ZBEE_ZDP_RSP_NODE_DESC,           "Node Descriptor Response" },
336     { ZBEE_ZDP_RSP_POWER_DESC,          "Power Descriptor Response" },
337     { ZBEE_ZDP_RSP_SIMPLE_DESC,         "Simple Descriptor Response" },
338     { ZBEE_ZDP_RSP_ACTIVE_EP,           "Active Endpoint Response" },
339     { ZBEE_ZDP_RSP_MATCH_DESC,          "Match Descriptor Response" },
340     { ZBEE_ZDP_RSP_COMPLEX_DESC,        "Complex Descriptor Response" },
341     { ZBEE_ZDP_RSP_USER_DESC,           "User Descriptor Request" },
342     { ZBEE_ZDP_RSP_DISCOVERY_CACHE,     "Discovery Cache Response" },
343     { ZBEE_ZDP_RSP_CONF_USER_DESC,      "Set User Descriptor Confirm" },
344     { ZBEE_ZDP_RSP_SYSTEM_SERVER_DISC,  "Server Discovery Response" },
345     { ZBEE_ZDP_RSP_STORE_DISCOVERY,     "Store Discovery Response" },
346     { ZBEE_ZDP_RSP_STORE_NODE_DESC,     "Store Node Descriptor Response" },
347     { ZBEE_ZDP_RSP_STORE_POWER_DESC,    "Store Power Descriptor Response" },
348     { ZBEE_ZDP_RSP_STORE_ACTIVE_EP,     "Store Active Endpoints Response" },
349     { ZBEE_ZDP_RSP_STORE_SIMPLE_DESC,   "Store Simple Descriptor Response" },
350     { ZBEE_ZDP_RSP_REMOVE_NODE_CACHE,   "Remove Node Cache Response" },
351     { ZBEE_ZDP_RSP_FIND_NODE_CACHE,     "Find Node Cache Response" },
352     { ZBEE_ZDP_RSP_EXT_SIMPLE_DESC,     "Extended Simple Descriptor Response" },
353     { ZBEE_ZDP_RSP_EXT_ACTIVE_EP,       "Extended Active Endpoint Response" },
354     { ZBEE_ZDP_RSP_END_DEVICE_BIND,     "End Device Bind Response" },
355     { ZBEE_ZDP_RSP_BIND,                "Bind Response" },
356     { ZBEE_ZDP_RSP_UNBIND,              "Unbind Response" },
357     { ZBEE_ZDP_RSP_BIND_REGISTER,       "Bind Register Response" },
358     { ZBEE_ZDP_RSP_REPLACE_DEVICE,      "Replace Device Response" },
359     { ZBEE_ZDP_RSP_STORE_BAK_BIND_ENTRY,    "Store Backup Binding Response" },
360     { ZBEE_ZDP_RSP_REMOVE_BAK_BIND_ENTRY,   "Remove Backup Binding Response" },
361     { ZBEE_ZDP_RSP_BACKUP_BIND_TABLE,   "Backup Binding Table Response" },
362     { ZBEE_ZDP_RSP_RECOVER_BIND_TABLE,  "Recover Binding Table Response" },
363     { ZBEE_ZDP_RSP_BACKUP_SOURCE_BIND,  "Backup Source Binding Response" },
364     { ZBEE_ZDP_RSP_RECOVER_SOURCE_BIND, "Recover Source Binding Response" },
365     { ZBEE_ZDP_RSP_MGMT_NWK_DISC,       "Network Discovery Response" },
366     { ZBEE_ZDP_RSP_MGMT_LQI,            "Link Quality Response" },
367     { ZBEE_ZDP_RSP_MGMT_RTG,            "Routing Table Response" },
368     { ZBEE_ZDP_RSP_MGMT_BIND,           "Binding Table Response" },
369     { ZBEE_ZDP_RSP_MGMT_LEAVE,          "Leave Response" },
370     { ZBEE_ZDP_RSP_MGMT_DIRECT_JOIN,    "Direct Join Response" },
371     { ZBEE_ZDP_RSP_MGMT_PERMIT_JOIN,    "Permit Join Response" },
372     { ZBEE_ZDP_RSP_MGMT_CACHE,          "Cache Response" },
373     { ZBEE_ZDP_RSP_MGMT_NWKUPDATE,      "Network Update Notify" },
374     { 0, NULL }
375 };
376
377 static const value_string zbee_zdp_status_names[] = {
378     { ZBEE_ZDP_STATUS_SUCCESS,          "Success" },
379     { ZBEE_ZDP_STATUS_INV_REQUESTTYPE,  "Invalid Request Type" },
380     { ZBEE_ZDP_STATUS_DEVICE_NOT_FOUND, "Device Not Found" },
381     { ZBEE_ZDP_STATUS_INVALID_EP,       "Invalid Endpoint" },
382     { ZBEE_ZDP_STATUS_NOT_ACTIVE,       "Not Active" },
383     { ZBEE_ZDP_STATUS_NOT_SUPPORTED,    "Not Supported" },
384     { ZBEE_ZDP_STATUS_TIMEOUT,          "Timeout" },
385     { ZBEE_ZDP_STATUS_NO_MATCH,         "No Match" },
386     { ZBEE_ZDP_STATUS_NO_ENTRY,         "No Entry" },
387     { ZBEE_ZDP_STATUS_NO_DESCRIPTOR,    "No Descriptor" },
388     { ZBEE_ZDP_STATUS_INSUFFICIENT_SPACE,   "Insufficient Space" },
389     { ZBEE_ZDP_STATUS_NOT_PERMITTED,    "Not Permitted" },
390     { ZBEE_ZDP_STATUS_TABLE_FULL,       "Table Full" },
391     { 0, NULL }
392 };
393
394 /*FUNCTION:------------------------------------------------------
395  *  NAME
396  *      zdp_status_name
397  *  DESCRIPTION
398  *      Returns a status name for a given status value.
399  *  PARAMETERS
400  *      guint8  status;
401  *  RETURNS
402  *      const gchar *
403  *---------------------------------------------------------------
404  */
405 const gchar *
406 zdp_status_name(guint8 status)
407 {
408     return val_to_str(status, zbee_zdp_status_names, "Reserved");
409 } /* zdp_status_name */
410
411 /*FUNCTION:------------------------------------------------------
412  *  NAME
413  *      zdp_convert_2003cluster
414  *  DESCRIPTION
415  *      Converts a ZigBee 2003 & earlier cluster ID to a 2006
416  *      cluster ID. This change is necessary because the cluster
417  *      ID field was enlarged from 8 to 16 bits in 2006, and the
418  *      values for the response messages was changed.
419  *  PARAMETERS
420  *      guint8  cluster;
421  *  RETURNS
422  *      guint16
423  *---------------------------------------------------------------
424  */
425 static guint16
426 zdp_convert_2003cluster(guint8 cluster)
427 {
428     guint16 cluster16 = (guint16)cluster;
429
430     if (cluster16 & ZBEE_ZDP_MSG_RESPONSE_BIT_2003) {
431         /* Clear the 2003 request bit. */
432         cluster16 &= ~(ZBEE_ZDP_MSG_RESPONSE_BIT_2003);
433         /* Set the 2006 request bit. */
434         cluster16 |= (ZBEE_ZDP_MSG_RESPONSE_BIT);
435     }
436     return cluster16;
437 } /* zdp_convert_2003cluster */
438
439 /*FUNCTION:------------------------------------------------------
440  *  NAME
441  *      zdp_dump_excess
442  *  DESCRIPTION
443  *      Helper functions dumps any excess data into the data dissector.
444  *  PARAMETERS
445  *      tvbuff_t    *tvb    - pointer to buffer containing raw packet.
446  *      guint       offset  - offset after parsing last item.
447  *      packet_info *pinfo  - packet information structure.
448  *      proto_tree  *tree   - pointer to data tree Wireshark uses to display packet.
449  *  RETURNS
450  *      void
451  *---------------------------------------------------------------
452  */
453 void
454 zdp_dump_excess(tvbuff_t *tvb, guint offset, packet_info *pinfo, proto_tree *tree)
455 {
456     proto_tree  *root = proto_tree_get_root(tree);
457     guint       length = tvb_length_remaining(tvb, offset);
458     tvbuff_t    *excess;
459
460     if (length > 0) {
461         excess = tvb_new_subset(tvb, offset, length, length);
462         call_dissector(data_handle, excess, pinfo, root);
463     }
464 } /* zdp_dump_excess */
465
466 /*FUNCTION:------------------------------------------------------
467  *  NAME
468  *      zbee_append_info
469  *  DESCRIPTION
470  *      ZigBee helper function. Appends the info to the info column
471  *      and proto item.
472  *  PARAMETERS
473  *      proto_item  *item   - item to display info on.
474  *      packet_info *pinfo  - packet info struct.
475  *      const gchar *format - format string.
476  *      ...                 - variable argument list.
477  *  RETURNS
478  *      none
479  *---------------------------------------------------------------
480  */
481 void
482 zbee_append_info(proto_item *item, packet_info *pinfo, const gchar *format, ...)
483 {
484     static gchar    buffer[512];
485     va_list         ap;
486
487     va_start(ap, format);
488     g_vsnprintf(buffer, 512, format, ap);
489     va_end(ap);
490
491     if (item) {
492         proto_item_append_text(item, "%s", buffer);
493     }
494     col_append_str(pinfo->cinfo, COL_INFO, buffer);
495 } /* zbee_add_info */
496
497 /*FUNCTION:------------------------------------------------------
498  *  NAME
499  *      zbee_parse_uint
500  *  DESCRIPTION
501  *      ZigBee helper function. extracts an integer and displays it to the tree.
502  *  PARAMETERS
503  *      proto_tree  *tree   - pointer to data tree Wireshark uses to display packet.
504  *      int         hfindex - index to field information.
505  *      tvbuff_t    *tvb    - pointer to buffer containing raw packet.
506  *      guint       *offset - pointer to value of offset.
507  *      guint       length  - length of the value to extract.
508  *      proto_item  **ti    - optional pointer to get the created proto item.
509  *  RETURNS
510  *      guint   - the value read out of the tvbuff and added to the tree.
511  *---------------------------------------------------------------
512  */
513 guint
514 zbee_parse_uint(proto_tree *tree, int hfindex, tvbuff_t *tvb, guint *offset, guint length, proto_item **ti)
515 {
516     proto_item          *item = NULL;
517     guint               value = 0;
518
519     /* Get the value. */
520     if (length == 0) {
521         /* ??? */
522         return 0;
523     }
524     else if (length == 1) {
525         value = tvb_get_guint8(tvb, *offset);
526     }
527     else if (length == 2) {
528         value = tvb_get_letohs(tvb, *offset);
529     }
530     else if (length == 3) {
531         value = tvb_get_letohs(tvb, *offset);
532         value += ((guint32)tvb_get_guint8(tvb, *offset + 2) << 16);
533     }
534     else {
535         value = tvb_get_letohl(tvb, *offset);
536     }
537
538     /* Display it. */
539     if (tree) {
540         item = proto_tree_add_uint(tree, hfindex, tvb, *offset, length, value);
541     }
542
543     /* Increment the offset. */
544     *offset += length;
545
546     /* return the item if requested. */
547     if (ti) *ti = item;
548
549     /* return the value. */
550     return value;
551 } /* zbee_parse_uint */
552
553 /*FUNCTION:------------------------------------------------------
554  *  NAME
555  *      zbee_parse_eui64
556  *  DESCRIPTION
557  *      ZigBee helper function. extracts an EUI64 address and displays
558  *      it to the tree.
559  *  PARAMETERS
560  *      proto_tree  *tree   - pointer to data tree Wireshark uses to display packet.
561  *      int         hfindex - index to field information.
562  *      tvbuff_t    *tvb    - pointer to buffer containing raw packet.
563  *      guint       *offset - pointer to value of offset.
564  *      guint       length  - length of the value to extract.
565  *      proto_item  **ti    - optional pointer to get the created proto item.
566  *  RETURNS
567  *      guint64   - the value read out of the tvbuff and added to the tree.
568  *---------------------------------------------------------------
569  */
570 guint64
571 zbee_parse_eui64(proto_tree *tree, int hfindex, tvbuff_t *tvb, guint *offset, guint length, proto_item **ti)
572 {
573     proto_item          *item = NULL;
574     guint64             value;
575
576     /* Get the value. */
577     value = tvb_get_letoh64(tvb, *offset);
578
579     /* Display it. */
580     if (tree) {
581         item = proto_tree_add_eui64(tree, hfindex, tvb, *offset, length, value);
582     }
583
584     /* Increment the offset. */
585     *offset += sizeof(guint64);
586
587     /* return the item if requested. */
588     if (ti) *ti = item;
589
590     /* return the value. */
591     return value;
592 } /* zbee_parse_eui64 */
593
594 /*FUNCTION:------------------------------------------------------
595  *  NAME
596  *      zdp_parse_status
597  *  DESCRIPTION
598  *      Parses and displays the status value.
599  *  PARAMETERS
600  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
601  *      tvbuff_t   *tvb     - pointer to buffer containing raw packet.
602  *      guint      *offset  - offset into the tvb to find the status value.
603  *  RETURNS
604  *      guint8
605  *---------------------------------------------------------------
606  */
607 guint8
608 zdp_parse_status(proto_tree *tree, tvbuff_t *tvb, guint *offset)
609 {
610     guint8      status;
611
612     /* Get and display the flags. */
613     status = tvb_get_guint8(tvb, *offset);
614     if (tree) {
615         proto_tree_add_uint(tree, hf_zbee_zdp_status, tvb, *offset, sizeof(guint8), status);
616     }
617     *offset += sizeof(guint8);
618
619     return status;
620 } /* zdp_parse_status */
621
622 /*FUNCTION:------------------------------------------------------
623  *  NAME
624  *      zdp_parse_chanmask
625  *  DESCRIPTION
626  *      Parses and displays the a channel mask.
627  *  PARAMETERS
628  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
629  *      tvbuff_t   *tvb     - pointer to buffer containing raw packet.
630  *      guint      *offset  - offset into the tvb to find the status value.
631  *  RETURNS
632  *      guint32
633  *---------------------------------------------------------------
634  */
635 guint32
636 zdp_parse_chanmask(proto_tree *tree, tvbuff_t *tvb, guint *offset)
637 {
638     int         i;
639     guint32     mask;
640     proto_item  *ti;
641
642     /* Get and display the channel mask. */
643     mask = tvb_get_letohl(tvb, *offset);
644     if (tree) {
645         ti = proto_tree_add_text(tree, tvb, *offset, sizeof(guint32), "Channels: ");
646
647         /* Check if there are any channels to display. */
648         if (mask==0) {
649             proto_item_append_text(ti, "None");
650         }
651         /* Display the first channel #. */
652         for (i=0; i<(8*(int)sizeof(guint32)); i++) {
653             if ((1<<i) & mask) {
654                 proto_item_append_text(ti, "%d", i++);
655                 break;
656             }
657         } /* for */
658         /* Display the rest of the channels. */
659         for (;i<(8*(int)sizeof(guint32)); i++) {
660             if (!((1<<i) & mask)) {
661                 /* This channel isn't selected. */
662                 continue;
663             }
664             /* If the previous channel wasn't selected, then display the
665              * channel number.
666              */
667             if ( ! ((1<<(i-1)) & mask) ) {
668                 proto_item_append_text(ti, ", %d", i);
669             }
670             /*
671              * If the next channel is selected too, skip past it and display
672              * a range of values instead.
673              */
674             if ((2<<i) & mask) {
675                 while ((2<<i) & mask) i++;
676                 proto_item_append_text(ti, "-%d", i);
677             }
678         } /* for */
679     }
680     *offset += sizeof(guint32);
681
682     return mask;
683 } /* zdp_parse_chanmask */
684
685 /*FUNCTION:------------------------------------------------------
686  *  NAME
687  *      zdp_parse_cinfo
688  *  DESCRIPTION
689  *      Parses and displays MAC capability info flags.
690  *  PARAMETERS
691  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
692  *      gint       ettindex - subtree index to create the node descriptor in, or -1
693  *                              to create it without a subtree.
694  *      tvbuff_t   *tvb     - pointer to buffer containing raw packet.
695  *      guint      *offset  - offset into the tvb to find the node descriptor.
696  *  RETURNS
697  *      guint8
698  *---------------------------------------------------------------
699  */
700 guint8
701 zdp_parse_cinfo(proto_tree *tree, gint ettindex, tvbuff_t *tvb, guint *offset)
702 {
703     proto_item  *ti;
704     proto_tree  *field_tree;
705     guint8      flags;
706
707     /* Get and display the flags. */
708     flags = tvb_get_guint8(tvb, *offset);
709     if (tree) {
710         if (ettindex != -1) {
711             ti = proto_tree_add_text(tree, tvb, *offset, sizeof(guint8), "Capability Information");
712             field_tree = proto_item_add_subtree(ti, ettindex);
713         }
714         else field_tree = tree;
715
716         proto_tree_add_boolean(field_tree, hf_zbee_zdp_cinfo_alt_coord, tvb, *offset, sizeof(guint8), flags & ZBEE_CINFO_ALT_COORD);
717         proto_tree_add_boolean(field_tree, hf_zbee_zdp_cinfo_ffd, tvb, *offset, sizeof(guint8), flags & ZBEE_CINFO_FFD);
718         proto_tree_add_boolean(field_tree, hf_zbee_zdp_cinfo_power, tvb, *offset, sizeof(guint8), flags & ZBEE_CINFO_POWER);
719         proto_tree_add_boolean(field_tree, hf_zbee_zdp_cinfo_idle_rx, tvb, *offset, sizeof(guint8), flags & ZBEE_CINFO_IDLE_RX);
720         proto_tree_add_boolean(field_tree, hf_zbee_zdp_cinfo_security, tvb, *offset, sizeof(guint8), flags & ZBEE_CINFO_SECURITY);
721         proto_tree_add_boolean(field_tree, hf_zbee_zdp_cinfo_alloc, tvb, *offset, sizeof(guint8), flags & ZBEE_CINFO_ALLOC);
722     }
723     *offset += sizeof(guint8);
724
725     return flags;
726 } /* zdp_parse_cinfo */
727
728 /*FUNCTION:------------------------------------------------------
729  *  NAME
730  *      zdp_parse_server_flags
731  *  DESCRIPTION
732  *      Parses and displays server mode flags.
733  *  PARAMETERS
734  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
735  *      gint       ettindex - subtree index to create the node descriptor in, or -1
736  *                              to create it without a subtree.
737  *      tvbuff_t   *tvb     - pointer to buffer containing raw packet.
738  *      guint      *offset  - offset into the tvb to find the node descriptor.
739  *  RETURNS
740  *      guint16
741  *---------------------------------------------------------------
742  */
743 guint16
744 zdp_parse_server_flags(proto_tree *tree, gint ettindex, tvbuff_t *tvb, guint *offset)
745 {
746     proto_item  *ti;
747     proto_tree  *field_tree;
748     guint16      flags;
749
750     /* Get and display the flags. */
751     flags = tvb_get_letohs(tvb, *offset);
752     if (tree) {
753         if (ettindex != -1) {
754             ti = proto_tree_add_text(tree, tvb, *offset, sizeof(guint8), "Server Flags");
755             field_tree = proto_item_add_subtree(ti, ettindex);
756         }
757         else field_tree = tree;
758
759         proto_tree_add_boolean(field_tree, hf_zbee_zdp_server_pri_trust, tvb, *offset, sizeof(guint16), flags & ZBEE_ZDP_NODE_SERVER_PRIMARY_TRUST);
760         proto_tree_add_boolean(field_tree, hf_zbee_zdp_server_bak_trust, tvb, *offset, sizeof(guint16), flags & ZBEE_ZDP_NODE_SERVER_BACKUP_TRUST);
761         proto_tree_add_boolean(field_tree, hf_zbee_zdp_server_pri_bind, tvb, *offset, sizeof(guint16), flags & ZBEE_ZDP_NODE_SERVER_PRIMARY_BIND);
762         proto_tree_add_boolean(field_tree, hf_zbee_zdp_server_bak_bind, tvb, *offset, sizeof(guint16), flags & ZBEE_ZDP_NODE_SERVER_BACKUP_BIND);
763         proto_tree_add_boolean(field_tree, hf_zbee_zdp_server_pri_disc, tvb, *offset, sizeof(guint16), flags & ZBEE_ZDP_NODE_SERVER_PRIMARY_DISC);
764         proto_tree_add_boolean(field_tree, hf_zbee_zdp_server_bak_disc, tvb, *offset, sizeof(guint16), flags & ZBEE_ZDP_NODE_SERVER_BACKUP_DISC);
765     }
766     *offset += sizeof(guint16);
767
768     return flags;
769 } /* zdp_parse_server_flags */
770
771 /*FUNCTION:------------------------------------------------------
772  *  NAME
773  *      zdp_parse_node_desc
774  *  DESCRIPTION
775  *      Parses and displays a node descriptor to the the specified
776  *      tree.
777  *  PARAMETERS
778  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
779  *      gint       ettindex - subtree index to create the node descriptor in, or -1
780  *                              to create it without a subtree.
781  *      tvbuff_t   *tvb     - pointer to buffer containing raw packet.
782  *      guint      *offset  - offset into the tvb to find the node descriptor.
783  *      packet_info *pinfo  - packet information structure.
784  *  RETURNS
785  *      void
786  *---------------------------------------------------------------
787  */
788 void
789 zdp_parse_node_desc(proto_tree *tree, gint ettindex, tvbuff_t *tvb, guint *offset, packet_info *pinfo)
790 {
791     proto_item  *ti;
792     proto_item  *field_root = NULL;
793     proto_tree  *field_tree = NULL;
794
795     guint16     flags;
796     guint8      capability;
797     guint16     mfr_code;
798     guint8      max_buff;
799     guint16     max_transfer;
800
801     if ((tree) && (ettindex != -1)) {
802         field_root = proto_tree_add_text(tree, tvb, *offset, tvb_length_remaining(tvb, *offset), "Node Descriptor");
803         field_tree = proto_item_add_subtree(field_root, ettindex);
804     }
805     else field_tree = tree;
806
807     /* Get and display the flags. */
808     flags = tvb_get_letohs(tvb, *offset);
809     if (tree) {
810         guint16 type = flags & ZBEE_ZDP_NODE_TYPE;
811         ti = proto_tree_add_uint(field_tree, hf_zbee_zdp_node_type, tvb, *offset, sizeof(guint16), type);
812         proto_tree_add_boolean(field_tree, hf_zbee_zdp_node_complex, tvb, *offset, sizeof(guint16), flags & ZBEE_ZDP_NODE_COMPLEX);
813         proto_tree_add_boolean(field_tree, hf_zbee_zdp_node_user, tvb, *offset, sizeof(guint16), flags & ZBEE_ZDP_NODE_USER);
814         proto_tree_add_boolean(field_tree, hf_zbee_zdp_node_freq_868, tvb, *offset, sizeof(guint16), flags & ZBEE_ZDP_NODE_FREQ_868MHZ);
815         proto_tree_add_boolean(field_tree, hf_zbee_zdp_node_freq_900, tvb, *offset, sizeof(guint16), flags & ZBEE_ZDP_NODE_FREQ_900MHZ);
816         proto_tree_add_boolean(field_tree, hf_zbee_zdp_node_freq_2400, tvb, *offset, sizeof(guint16), flags & ZBEE_ZDP_NODE_FREQ_2400MHZ);
817
818         /* Enumerate the type field. */
819         if (type == ZBEE_ZDP_NODE_TYPE_COORD)    proto_item_append_text(ti, " (Coordinator)");
820         else if (type == ZBEE_ZDP_NODE_TYPE_FFD) proto_item_append_text(ti, " (Router)");
821         else if (type == ZBEE_ZDP_NODE_TYPE_RFD) proto_item_append_text(ti, " (End Device)");
822         else proto_item_append_text(ti, " (Reserved)");
823     }
824     *offset += sizeof(guint16);
825
826     /* Get and display the capability flags. */
827     capability      = zdp_parse_cinfo(field_tree, ett_zbee_zdp_cinfo, tvb, offset);
828     mfr_code        = zbee_parse_uint(field_tree, hf_zbee_zdp_node_manufacturer, tvb, offset, sizeof(guint16), NULL);
829     max_buff        = zbee_parse_uint(field_tree, hf_zbee_zdp_node_max_buffer, tvb, offset, sizeof(guint8), NULL);
830     max_transfer    = zbee_parse_uint(field_tree, hf_zbee_zdp_node_max_transfer, tvb, offset, sizeof(guint16), NULL);
831
832     /* Get and display the server flags. */
833     if (pinfo->zbee_stack_vers >= ZBEE_VERSION_2007) {
834         zdp_parse_server_flags(field_tree, ett_zbee_zdp_server, tvb, offset);
835     }
836
837     /* Correct the length of the subtree. */
838     if (tree && (ettindex != -1)) {
839         proto_item_set_len(field_root, *offset);
840     }
841
842 } /* zdp_parse_node_desc */
843
844 /*FUNCTION:------------------------------------------------------
845  *  NAME
846  *      zdp_parse_power_desc
847  *  DESCRIPTION
848  *      Parses and displays a node descriptor to the the specified
849  *      tree.
850  *  PARAMETERS
851  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
852  *      gint       ettindex - subtree index to create the node descriptor in, or -1
853  *                              to create it without a subtree.
854  *      tvbuff_t   *tvb     - pointer to buffer containing raw packet.
855  *      guint      *offset  - offset into the tvb to find the node descriptor.
856  *      packet_info *pinfo  - packet information structure.
857  *  RETURNS
858  *      void
859  *---------------------------------------------------------------
860  */
861 void
862 zdp_parse_power_desc(proto_tree *tree, gint ettindex, tvbuff_t *tvb, guint *offset)
863 {
864     proto_item  *ti;
865     proto_tree  *field_tree;
866
867     guint16     flags;
868     guint16     mode;
869     guint16     level;
870
871     if ((tree) && (ettindex != -1)) {
872         ti = proto_tree_add_text(tree, tvb, *offset, sizeof(guint16), "Power Descriptor");
873         field_tree = proto_item_add_subtree(ti, ettindex);
874     }
875     else field_tree = tree;
876
877     flags = tvb_get_letohs(tvb, *offset);
878     mode  = flags & ZBEE_ZDP_POWER_MODE;
879     level = flags & ZBEE_ZDP_POWER_LEVEL;
880     if (tree) {
881         ti = proto_tree_add_uint(field_tree, hf_zbee_zdp_power_mode, tvb, *offset, sizeof(guint16), mode);
882         if (mode == ZBEE_ZDP_POWER_MODE_RX_ON)              proto_item_append_text(ti, " (Receiver Always On)");
883         else if (mode == ZBEE_ZDP_POWER_MODE_RX_PERIODIC)   proto_item_append_text(ti, " (Receiver Periodically On)");
884         else if (mode == ZBEE_ZDP_POWER_MODE_RX_STIMULATE)  proto_item_append_text(ti, " (Receiver On When Stimulated)");
885         else proto_item_append_text(ti, " (Reserved)");
886
887         proto_tree_add_boolean(field_tree, hf_zbee_zdp_power_avail_ac, tvb, *offset, sizeof(guint16), flags & ZBEE_ZDP_POWER_AVAIL_AC);
888         proto_tree_add_boolean(field_tree, hf_zbee_zdp_power_avail_recharge, tvb, *offset, sizeof(guint16), flags & ZBEE_ZDP_POWER_AVAIL_RECHARGEABLE);
889         proto_tree_add_boolean(field_tree, hf_zbee_zdp_power_avail_dispose, tvb, *offset, sizeof(guint16), flags & ZBEE_ZDP_POWER_AVAIL_DISPOSEABLE);
890
891         proto_tree_add_boolean(field_tree, hf_zbee_zdp_power_source_ac, tvb, *offset, sizeof(guint16), flags & ZBEE_ZDP_POWER_SOURCE_AC);
892         proto_tree_add_boolean(field_tree, hf_zbee_zdp_power_source_recharge, tvb, *offset, sizeof(guint16), flags & ZBEE_ZDP_POWER_SOURCE_RECHARGEABLE);
893         proto_tree_add_boolean(field_tree, hf_zbee_zdp_power_source_dispose, tvb, *offset, sizeof(guint16), flags & ZBEE_ZDP_POWER_SOURCE_DISPOSEABLE);
894
895         if (level == ZBEE_ZDP_POWER_LEVEL_FULL)
896             proto_tree_add_uint_format_value(field_tree, hf_zbee_zdp_power_level, tvb, *offset, sizeof(guint16), level, "Full");
897         else if (level == ZBEE_ZDP_POWER_LEVEL_OK)
898             proto_tree_add_uint_format_value(field_tree, hf_zbee_zdp_power_level, tvb, *offset, sizeof(guint16), level, "OK");
899         else if (level == ZBEE_ZDP_POWER_LEVEL_LOW)
900             proto_tree_add_uint_format_value(field_tree, hf_zbee_zdp_power_level, tvb, *offset, sizeof(guint16), level, "Low");
901         else if (level == ZBEE_ZDP_POWER_LEVEL_CRITICAL)
902             proto_tree_add_uint_format_value(field_tree, hf_zbee_zdp_power_level, tvb, *offset, sizeof(guint16), level, "Critical");
903         else proto_tree_add_uint_format_value(field_tree, hf_zbee_zdp_power_level, tvb, *offset, sizeof(guint16), level, "Reserved");
904     }
905     *offset += sizeof(guint16);
906 } /* zdp_parse_power_desc */
907
908 /*FUNCTION:------------------------------------------------------
909  *  NAME
910  *      zdp_parse_simple_desc
911  *  DESCRIPTION
912  *      Parses and displays a simple descriptor to the the specified
913  *      tree.
914  *  PARAMETERS
915  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
916  *      gint       ettindex - subtree index to create the node descriptor in, or -1
917  *                              to create it without a subtree.
918  *      tvbuff_t   *tvb     - pointer to buffer containing raw packet.
919  *      guint      *offset  - offset into the tvb to find the node descriptor.
920  *      packet_info *pinfo  - packet information structure.
921  *  RETURNS
922  *      void
923  *---------------------------------------------------------------
924  */
925 void
926 zdp_parse_simple_desc(proto_tree *tree, gint ettindex, tvbuff_t *tvb, guint *offset, packet_info *pinfo)
927 {
928     proto_item  *ti;
929     proto_item  *field_root = NULL;
930     proto_tree  *field_tree = NULL, *cluster_tree = NULL;
931     guint       i, sizeof_cluster;
932
933     guint8      endpoint;
934     guint16     profile;
935     guint16     app_device;
936     guint8      app_version;
937     guint8      in_count;
938     guint8      out_count;
939
940     if ((tree) && (ettindex != -1)) {
941         field_root = proto_tree_add_text(tree, tvb, *offset, tvb_length_remaining(tvb, *offset), "Simple Descriptor");
942         field_tree = proto_item_add_subtree(field_root, ettindex);
943     }
944     else field_tree = tree;
945
946     endpoint    = zbee_parse_uint(field_tree, hf_zbee_zdp_endpoint, tvb, offset, sizeof(guint8), NULL);
947     profile     = zbee_parse_uint(field_tree, hf_zbee_zdp_profile, tvb, offset, sizeof(guint16), NULL);
948     app_device  = zbee_parse_uint(field_tree, hf_zbee_zdp_simple_app_device, tvb, offset, sizeof(guint16), NULL);
949     app_version = zbee_parse_uint(field_tree, hf_zbee_zdp_simple_app_version, tvb, offset, sizeof(guint8), NULL);
950
951     sizeof_cluster = (pinfo->zbee_stack_vers >= ZBEE_VERSION_2007)?sizeof(guint16):sizeof(guint8);
952
953     in_count    = zbee_parse_uint(field_tree, hf_zbee_zdp_in_count, tvb, offset, sizeof(guint8), NULL);
954     if ((tree) && (in_count)) {
955         ti = proto_tree_add_text(field_tree, tvb, *offset, in_count*sizeof_cluster, "Input Cluster List");
956         cluster_tree = proto_item_add_subtree(ti, ett_zbee_zdp_node_in);
957     }
958     for (i=0; i<in_count && tvb_bytes_exist(tvb, *offset, sizeof_cluster); i++) {
959         zbee_parse_uint(cluster_tree, hf_zbee_zdp_in_cluster, tvb, offset, sizeof_cluster, NULL);
960     }
961
962     out_count = zbee_parse_uint(field_tree, hf_zbee_zdp_out_count, tvb, offset, sizeof(guint8), NULL);
963     if ((tree) && (out_count)) {
964         ti = proto_tree_add_text(field_tree, tvb, *offset, in_count*sizeof_cluster, "Output Cluster List");
965         cluster_tree = proto_item_add_subtree(ti, ett_zbee_zdp_node_out);
966     }
967     for (i=0; (i<out_count) && tvb_bytes_exist(tvb, *offset, sizeof_cluster); i++) {
968         zbee_parse_uint(cluster_tree, hf_zbee_zdp_out_cluster, tvb, offset, sizeof_cluster, NULL);
969     }
970
971     if (tree && (ettindex != -1)) {
972         proto_item_set_len(field_root, *offset);
973     }
974 } /* zdp_parse_simple_desc */
975
976 /*FUNCTION:------------------------------------------------------
977  *  NAME
978  *      zdp_parse_complex_desc
979  *  DESCRIPTION
980  *      Parses and displays a simple descriptor to the the specified
981  *      tree.
982  *  PARAMETERS
983  *      proto_tree  *tree    - pointer to data tree Wireshark uses to display packet.
984  *      gint        ettindex - subtree index to create the node descriptor in, or -1
985  *                              to create it without a subtree.
986  *      tvbuff_t    *tvb     - pointer to buffer containing raw packet.
987  *      guint       *offset  - offset into the tvb to find the node descriptor.
988  *      guint       length   - length of the complex descriptor.
989  *      packet_info *pinfo   - packet information structure.
990  *  RETURNS
991  *      void
992  *---------------------------------------------------------------
993  */
994 void
995 zdp_parse_complex_desc(proto_tree *tree, gint ettindex, tvbuff_t *tvb, guint *offset, guint length)
996 {
997     enum {
998         tag_charset = 1,
999         tag_mfr_name = 2,
1000         tag_model_name = 3,
1001         tag_serial_no = 4,
1002         tag_url = 5,
1003         tag_icon = 6,
1004         tag_icon_url = 7
1005     };
1006
1007     const gchar *tag_name[] = {
1008         "Reserved Tag",
1009         "languageChar",
1010         "manufacturerName",
1011         "modelName",
1012         "serialNumber",
1013         "deviceURL",
1014         "icon",
1015         "outliner"
1016     };
1017
1018     const gint max_len = 128;
1019
1020     proto_item  *field_root;
1021     proto_tree  *field_tree;
1022
1023     gchar   *str = ep_alloc(length);
1024     gchar   *complex = ep_alloc(max_len);
1025     guint8  tag;
1026
1027     if ((tree) && (ettindex != -1)) {
1028         field_root = proto_tree_add_text(tree, tvb, *offset, length, "Complex Descriptor");
1029         field_tree = proto_item_add_subtree(field_root, ettindex);
1030     }
1031     else field_tree = tree;
1032
1033     tag = tvb_get_guint8(tvb, *offset);
1034     if (tag == tag_charset) {
1035         gchar   lang_str[3];
1036         guint8  charset  = tvb_get_guint8(tvb, *offset + 3);
1037         gchar   *charset_str;
1038
1039         if (charset == 0x00) charset_str = "ASCII";
1040         else                 charset_str = "Unknown Character Set";
1041
1042         lang_str[0] = tvb_get_guint8(tvb, *offset + 1);
1043         lang_str[1] = tvb_get_guint8(tvb, *offset + 2);
1044         lang_str[2] = '\0';
1045
1046         g_snprintf(complex, max_len, "<%s>%s, %s</%s>", tag_name[tag_charset], lang_str, charset_str, tag_name[tag_charset]);
1047     }
1048     else if (tag == tag_icon) {
1049         /* TODO: */
1050         g_snprintf(complex, max_len, "<%s>FixMe</%s>", tag_name[tag_icon], tag_name[tag_icon]);
1051     }
1052     else {
1053         tvb_memcpy(tvb, str, *offset+1, length-1);
1054         str[length-1] = '\0';
1055         /* Handles all string type XML tags. */
1056         if (tag <= tag_icon_url) {
1057             g_snprintf(complex, max_len, "<%s>%s</%s>", tag_name[tag], str, tag_name[tag]);
1058         }
1059         else {
1060             g_snprintf(complex, max_len, "<%s>%s</%s>", tag_name[0], str, tag_name[0]);
1061         }
1062     }
1063     if (tree) {
1064         proto_tree_add_string(field_tree, hf_zbee_zdp_complex, tvb, *offset, length, complex);
1065     }
1066     *offset += (length);
1067 } /* zdp_parse_complex_desc */
1068
1069 /*FUNCTION:------------------------------------------------------
1070  *  NAME
1071  *      dissect_zbee_zdp
1072  *  DESCRIPTION
1073  *      ZigBee Device Profile dissector for wireshark.
1074  *  PARAMETERS
1075  *      tvbuff_t *tvb       - pointer to buffer containing raw packet.
1076  *      packet_into *pinfo  - pointer to packet information fields
1077  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
1078  *  RETURNS
1079  *      void
1080  *---------------------------------------------------------------
1081  */
1082 static void
1083 dissect_zbee_zdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1084 {
1085     proto_tree      *zdp_tree = NULL;
1086     proto_item      *proto_root;
1087     tvbuff_t        *zdp_tvb;
1088
1089     guint8          seqno;
1090     guint16         cluster;
1091     guint           offset = 0;
1092
1093     /* Create the protocol tree. */
1094     if (tree) {
1095         proto_root = proto_tree_add_protocol_format(tree, proto_zbee_zdp, tvb, offset, tvb_length(tvb), "ZigBee Device Profile");
1096         zdp_tree = proto_item_add_subtree(proto_root, ett_zbee_zdp);
1097     }
1098 #if 0
1099     /* Overwrite the protocol column */
1100     col_set_str(pinfo->cinfo, COL_PROTOCOL, "ZigBee ZDP");
1101 #endif
1102     /* Get and display the sequence number. */
1103     seqno = tvb_get_guint8(tvb, offset);
1104     if (tree) {
1105         proto_tree_add_uint(zdp_tree, hf_zbee_zdp_seqno, tvb, offset, sizeof(guint8), seqno);
1106     }
1107     offset += sizeof(guint8);
1108
1109     if (pinfo->zbee_stack_vers <= ZBEE_VERSION_2004) {
1110         /* ZigBee 2004 and earlier had different cluster identifiers, need to convert
1111          * them into the ZigBee 2006 & later values. */
1112         cluster = zdp_convert_2003cluster((guint8)pinfo->zbee_cluster_id);
1113     }
1114     else {
1115         cluster = pinfo->zbee_cluster_id;
1116     }
1117
1118     /* Update info. */
1119     if (tree) {
1120         proto_item_append_text(zdp_tree, ", %s", val_to_str(cluster, zbee_zdp_cluster_names, "Unknown Cluster"));
1121     }
1122     if (check_col(pinfo->cinfo, COL_INFO)) {
1123         col_set_str(pinfo->cinfo, COL_INFO, val_to_str_const(cluster, zbee_zdp_cluster_names, "Unknown Cluster"));
1124     }
1125
1126     /* Create a new tvb for the zdp message. */
1127     zdp_tvb = tvb_new_subset_remaining(tvb, offset);
1128
1129     switch (cluster) {
1130         case ZBEE_ZDP_REQ_NWK_ADDR:
1131             dissect_zbee_zdp_req_nwk_addr(zdp_tvb, pinfo, zdp_tree);
1132             break;
1133         case ZBEE_ZDP_REQ_IEEE_ADDR:
1134             dissect_zbee_zdp_req_ext_addr(zdp_tvb, pinfo, zdp_tree);
1135             break;
1136         case ZBEE_ZDP_REQ_NODE_DESC:
1137             dissect_zbee_zdp_req_node_desc(zdp_tvb, pinfo, zdp_tree);
1138             break;
1139         case ZBEE_ZDP_REQ_POWER_DESC:
1140             dissect_zbee_zdp_req_power_desc(zdp_tvb, pinfo, zdp_tree);
1141             break;
1142         case ZBEE_ZDP_REQ_SIMPLE_DESC:
1143             dissect_zbee_zdp_req_simple_desc(zdp_tvb, pinfo, zdp_tree);
1144             break;
1145         case ZBEE_ZDP_REQ_ACTIVE_EP:
1146             dissect_zbee_zdp_req_active_ep(zdp_tvb, pinfo, zdp_tree);
1147             break;
1148         case ZBEE_ZDP_REQ_MATCH_DESC:
1149             dissect_zbee_zdp_req_match_desc(zdp_tvb, pinfo, zdp_tree);
1150             break;
1151         case ZBEE_ZDP_REQ_COMPLEX_DESC:
1152             dissect_zbee_zdp_req_complex_desc(zdp_tvb, pinfo, zdp_tree);
1153             break;
1154         case ZBEE_ZDP_REQ_USER_DESC:
1155             dissect_zbee_zdp_req_user_desc(zdp_tvb, pinfo, zdp_tree);
1156             break;
1157         case ZBEE_ZDP_REQ_DISCOVERY_CACHE:
1158             dissect_zbee_zdp_req_discovery_cache(zdp_tvb, pinfo, zdp_tree);
1159             break;
1160         case ZBEE_ZDP_REQ_DEVICE_ANNCE:
1161             dissect_zbee_zdp_device_annce(zdp_tvb, pinfo, zdp_tree);
1162             break;
1163         case ZBEE_ZDP_REQ_SET_USER_DESC:
1164             dissect_zbee_zdp_req_set_user_desc(zdp_tvb, pinfo, zdp_tree);
1165             break;
1166         case ZBEE_ZDP_REQ_SYSTEM_SERVER_DISC:
1167             dissect_zbee_zdp_req_system_server_disc(zdp_tvb, pinfo, zdp_tree);
1168             break;
1169         case ZBEE_ZDP_REQ_STORE_DISCOVERY:
1170             dissect_zbee_zdp_req_store_discovery(zdp_tvb, pinfo, zdp_tree);
1171             break;
1172         case ZBEE_ZDP_REQ_STORE_NODE_DESC:
1173             dissect_zbee_zdp_req_store_node_desc(zdp_tvb, pinfo, zdp_tree);
1174             break;
1175         case ZBEE_ZDP_REQ_STORE_POWER_DESC:
1176             dissect_zbee_zdp_req_store_power_desc(zdp_tvb, pinfo, zdp_tree);
1177             break;
1178         case ZBEE_ZDP_REQ_STORE_ACTIVE_EP:
1179             dissect_zbee_zdp_req_store_active_ep(zdp_tvb, pinfo, zdp_tree);
1180             break;
1181         case ZBEE_ZDP_REQ_STORE_SIMPLE_DESC:
1182             dissect_zbee_zdp_req_store_simple_desc(zdp_tvb, pinfo, zdp_tree);
1183             break;
1184         case ZBEE_ZDP_REQ_REMOVE_NODE_CACHE:
1185             dissect_zbee_zdp_req_remove_node_cache(zdp_tvb, pinfo, zdp_tree);
1186             break;
1187         case ZBEE_ZDP_REQ_FIND_NODE_CACHE:
1188             dissect_zbee_zdp_req_find_node_cache(zdp_tvb, pinfo, zdp_tree);
1189             break;
1190         case ZBEE_ZDP_REQ_EXT_SIMPLE_DESC:
1191             dissect_zbee_zdp_req_ext_simple_desc(zdp_tvb, pinfo, zdp_tree);
1192             break;
1193         case ZBEE_ZDP_REQ_EXT_ACTIVE_EP:
1194             dissect_zbee_zdp_req_ext_active_ep(zdp_tvb, pinfo, zdp_tree);
1195             break;
1196         case ZBEE_ZDP_REQ_END_DEVICE_BIND:
1197             dissect_zbee_zdp_req_end_device_bind(zdp_tvb, pinfo, zdp_tree);
1198             break;
1199         case ZBEE_ZDP_REQ_BIND:
1200             dissect_zbee_zdp_req_bind(zdp_tvb, pinfo, zdp_tree);
1201             break;
1202         case ZBEE_ZDP_REQ_UNBIND:
1203             dissect_zbee_zdp_req_unbind(zdp_tvb, pinfo, zdp_tree);
1204             break;
1205         case ZBEE_ZDP_REQ_BIND_REGISTER:
1206             dissect_zbee_zdp_req_bind_register(zdp_tvb, pinfo, zdp_tree);
1207             break;
1208         case ZBEE_ZDP_REQ_REPLACE_DEVICE:
1209             dissect_zbee_zdp_req_replace_device(zdp_tvb, pinfo, zdp_tree);
1210             break;
1211         case ZBEE_ZDP_REQ_STORE_BAK_BIND_ENTRY:
1212             dissect_zbee_zdp_req_store_bak_bind_entry(zdp_tvb, pinfo, zdp_tree);
1213             break;
1214         case ZBEE_ZDP_REQ_REMOVE_BAK_BIND_ENTRY:
1215             dissect_zbee_zdp_req_remove_bak_bind_entry(zdp_tvb, pinfo, zdp_tree);
1216             break;
1217         case ZBEE_ZDP_REQ_BACKUP_BIND_TABLE:
1218             dissect_zbee_zdp_req_backup_bind_table(zdp_tvb, pinfo, zdp_tree);
1219             break;
1220         case ZBEE_ZDP_REQ_RECOVER_BIND_TABLE:
1221             dissect_zbee_zdp_req_recover_bind_table(zdp_tvb, pinfo, zdp_tree);
1222             break;
1223         case ZBEE_ZDP_REQ_BACKUP_SOURCE_BIND:
1224             dissect_zbee_zdp_req_backup_source_bind(zdp_tvb, pinfo, zdp_tree);
1225             break;
1226         case ZBEE_ZDP_REQ_RECOVER_SOURCE_BIND:
1227             dissect_zbee_zdp_req_recover_source_bind(zdp_tvb, pinfo, zdp_tree);
1228             break;
1229         case ZBEE_ZDP_REQ_MGMT_NWK_DISC:
1230             dissect_zbee_zdp_req_mgmt_nwk_disc(zdp_tvb, pinfo, zdp_tree);
1231             break;
1232         case ZBEE_ZDP_REQ_MGMT_LQI:
1233             dissect_zbee_zdp_req_mgmt_lqi(zdp_tvb, pinfo, zdp_tree);
1234             break;
1235         case ZBEE_ZDP_REQ_MGMT_RTG:
1236             dissect_zbee_zdp_req_mgmt_rtg(zdp_tvb, pinfo, zdp_tree);
1237             break;
1238         case ZBEE_ZDP_REQ_MGMT_BIND:
1239             dissect_zbee_zdp_req_mgmt_bind(zdp_tvb, pinfo, zdp_tree);
1240             break;
1241         case ZBEE_ZDP_REQ_MGMT_LEAVE:
1242             dissect_zbee_zdp_req_mgmt_leave(zdp_tvb, pinfo, zdp_tree);
1243             break;
1244         case ZBEE_ZDP_REQ_MGMT_DIRECT_JOIN:
1245             dissect_zbee_zdp_req_mgmt_direct_join(zdp_tvb, pinfo, zdp_tree);
1246             break;
1247         case ZBEE_ZDP_REQ_MGMT_PERMIT_JOIN:
1248             dissect_zbee_zdp_req_mgmt_permit_join(zdp_tvb, pinfo, zdp_tree);
1249             break;
1250         case ZBEE_ZDP_REQ_MGMT_CACHE:
1251             dissect_zbee_zdp_req_mgmt_cache(zdp_tvb, pinfo, zdp_tree);
1252             break;
1253         case ZBEE_ZDP_REQ_MGMT_NWKUPDATE:
1254             dissect_zbee_zdp_req_mgmt_nwkupdate(zdp_tvb, pinfo, zdp_tree);
1255             break;
1256         case ZBEE_ZDP_RSP_NWK_ADDR:
1257             dissect_zbee_zdp_rsp_nwk_addr(zdp_tvb, pinfo, zdp_tree);
1258             break;
1259         case ZBEE_ZDP_RSP_IEEE_ADDR:
1260             dissect_zbee_zdp_rsp_ext_addr(zdp_tvb, pinfo, zdp_tree);
1261             break;
1262         case ZBEE_ZDP_RSP_NODE_DESC:
1263             dissect_zbee_zdp_rsp_node_desc(zdp_tvb, pinfo, zdp_tree);
1264             break;
1265         case ZBEE_ZDP_RSP_POWER_DESC:
1266             dissect_zbee_zdp_rsp_power_desc(zdp_tvb, pinfo, zdp_tree);
1267             break;
1268         case ZBEE_ZDP_RSP_SIMPLE_DESC:
1269             dissect_zbee_zdp_rsp_simple_desc(zdp_tvb, pinfo, zdp_tree);
1270             break;
1271         case ZBEE_ZDP_RSP_ACTIVE_EP:
1272             dissect_zbee_zdp_rsp_active_ep(zdp_tvb, pinfo, zdp_tree);
1273             break;
1274         case ZBEE_ZDP_RSP_MATCH_DESC:
1275             dissect_zbee_zdp_rsp_match_desc(zdp_tvb, pinfo, zdp_tree);
1276             break;
1277         case ZBEE_ZDP_RSP_COMPLEX_DESC:
1278             dissect_zbee_zdp_rsp_complex_desc(zdp_tvb, pinfo, zdp_tree);
1279             break;
1280         case ZBEE_ZDP_RSP_USER_DESC:
1281             dissect_zbee_zdp_rsp_user_desc(zdp_tvb, pinfo, zdp_tree);
1282             break;
1283         case ZBEE_ZDP_RSP_DISCOVERY_CACHE:
1284             dissect_zbee_zdp_rsp_discovery_cache(zdp_tvb, pinfo, zdp_tree);
1285             break;
1286         case ZBEE_ZDP_RSP_CONF_USER_DESC:
1287             dissect_zbee_zdp_rsp_user_desc_conf(zdp_tvb, pinfo, zdp_tree);
1288             break;
1289         case ZBEE_ZDP_RSP_SYSTEM_SERVER_DISC:
1290             dissect_zbee_zdp_rsp_system_server_disc(zdp_tvb, pinfo, zdp_tree);
1291             break;
1292         case ZBEE_ZDP_RSP_STORE_DISCOVERY:
1293             dissect_zbee_zdp_rsp_discovery_store(zdp_tvb, pinfo, zdp_tree);
1294             break;
1295         case ZBEE_ZDP_RSP_STORE_NODE_DESC:
1296             dissect_zbee_zdp_rsp_store_node_desc(zdp_tvb, pinfo, zdp_tree);
1297             break;
1298         case ZBEE_ZDP_RSP_STORE_POWER_DESC:
1299             dissect_zbee_zdp_rsp_store_power_desc(zdp_tvb, pinfo, zdp_tree);
1300             break;
1301         case ZBEE_ZDP_RSP_STORE_ACTIVE_EP:
1302             dissect_zbee_zdp_rsp_store_active_ep(zdp_tvb, pinfo, zdp_tree);
1303             break;
1304         case ZBEE_ZDP_RSP_STORE_SIMPLE_DESC:
1305             dissect_zbee_zdp_rsp_store_simple_desc(zdp_tvb, pinfo, zdp_tree);
1306             break;
1307         case ZBEE_ZDP_RSP_REMOVE_NODE_CACHE:
1308             dissect_zbee_zdp_rsp_remove_node_cache(zdp_tvb, pinfo, zdp_tree);
1309             break;
1310         case ZBEE_ZDP_RSP_FIND_NODE_CACHE:
1311             dissect_zbee_zdp_rsp_find_node_cache(zdp_tvb, pinfo, zdp_tree);
1312             break;
1313         case ZBEE_ZDP_RSP_EXT_SIMPLE_DESC:
1314             dissect_zbee_zdp_rsp_ext_simple_desc(zdp_tvb, pinfo, zdp_tree);
1315             break;
1316         case ZBEE_ZDP_RSP_EXT_ACTIVE_EP:
1317             dissect_zbee_zdp_rsp_ext_active_ep(zdp_tvb, pinfo, zdp_tree);
1318             break;
1319         case ZBEE_ZDP_RSP_END_DEVICE_BIND:
1320             dissect_zbee_zdp_rsp_end_device_bind(zdp_tvb, pinfo, zdp_tree);
1321             break;
1322         case ZBEE_ZDP_RSP_BIND:
1323             dissect_zbee_zdp_rsp_bind(zdp_tvb, pinfo, zdp_tree);
1324             break;
1325         case ZBEE_ZDP_RSP_UNBIND:
1326             dissect_zbee_zdp_rsp_unbind(zdp_tvb, pinfo, zdp_tree);
1327             break;
1328         case ZBEE_ZDP_RSP_BIND_REGISTER:
1329             dissect_zbee_zdp_rsp_bind_register(zdp_tvb, pinfo, zdp_tree);
1330             break;
1331         case ZBEE_ZDP_RSP_REPLACE_DEVICE:
1332             dissect_zbee_zdp_rsp_replace_device(zdp_tvb, pinfo, zdp_tree);
1333             break;
1334         case ZBEE_ZDP_RSP_STORE_BAK_BIND_ENTRY:
1335             dissect_zbee_zdp_rsp_store_bak_bind_entry(zdp_tvb, pinfo, zdp_tree);
1336             break;
1337         case ZBEE_ZDP_RSP_REMOVE_BAK_BIND_ENTRY:
1338             dissect_zbee_zdp_rsp_remove_bak_bind_entry(zdp_tvb, pinfo, zdp_tree);
1339             break;
1340         case ZBEE_ZDP_RSP_BACKUP_BIND_TABLE:
1341             dissect_zbee_zdp_rsp_backup_bind_table(zdp_tvb, pinfo, zdp_tree);
1342             break;
1343         case ZBEE_ZDP_RSP_RECOVER_BIND_TABLE:
1344             dissect_zbee_zdp_rsp_recover_bind_table(zdp_tvb, pinfo, zdp_tree);
1345             break;
1346         case ZBEE_ZDP_RSP_BACKUP_SOURCE_BIND:
1347             dissect_zbee_zdp_rsp_backup_source_bind(zdp_tvb, pinfo, zdp_tree);
1348             break;
1349         case ZBEE_ZDP_RSP_RECOVER_SOURCE_BIND:
1350             dissect_zbee_zdp_rsp_recover_source_bind(zdp_tvb, pinfo, zdp_tree);
1351             break;
1352         case ZBEE_ZDP_RSP_MGMT_NWK_DISC:
1353             dissect_zbee_zdp_rsp_mgmt_nwk_disc(zdp_tvb, pinfo, zdp_tree);
1354             break;
1355         case ZBEE_ZDP_RSP_MGMT_LQI:
1356             dissect_zbee_zdp_rsp_mgmt_lqi(zdp_tvb, pinfo, zdp_tree);
1357             break;
1358         case ZBEE_ZDP_RSP_MGMT_RTG:
1359             dissect_zbee_zdp_rsp_mgmt_rtg(zdp_tvb, pinfo, zdp_tree);
1360             break;
1361         case ZBEE_ZDP_RSP_MGMT_BIND:
1362             dissect_zbee_zdp_rsp_mgmt_bind(zdp_tvb, pinfo, zdp_tree);
1363             break;
1364         case ZBEE_ZDP_RSP_MGMT_LEAVE:
1365             dissect_zbee_zdp_rsp_mgmt_leave(zdp_tvb, pinfo, zdp_tree);
1366             break;
1367         case ZBEE_ZDP_RSP_MGMT_DIRECT_JOIN:
1368             dissect_zbee_zdp_rsp_mgmt_direct_join(zdp_tvb, pinfo, zdp_tree);
1369             break;
1370         case ZBEE_ZDP_RSP_MGMT_PERMIT_JOIN:
1371             dissect_zbee_zdp_rsp_mgmt_permit_join(zdp_tvb, pinfo, zdp_tree);
1372             break;
1373         case ZBEE_ZDP_RSP_MGMT_CACHE:
1374             dissect_zbee_zdp_rsp_mgmt_cache(zdp_tvb, pinfo, zdp_tree);
1375             break;
1376         case ZBEE_ZDP_RSP_MGMT_NWKUPDATE:
1377             dissect_zbee_zdp_rsp_mgmt_nwkupdate(zdp_tvb, pinfo, zdp_tree);
1378             break;
1379         default:
1380             /* Invalid Cluster Identifier. */
1381             call_dissector(data_handle, zdp_tvb, pinfo, tree);
1382             break;
1383     } /* switch */
1384 } /* dissect_zbee_zdp */
1385
1386 /*FUNCTION:------------------------------------------------------
1387  *  NAME
1388  *      proto_register_zbee_zdp
1389  *  DESCRIPTION
1390  *      ZigBee Device Profile protocol registration routine.
1391  *  PARAMETERS
1392  *      none
1393  *  RETURNS
1394  *      void
1395  *---------------------------------------------------------------
1396  */
1397 void proto_register_zbee_zdp(void)
1398 {
1399     static hf_register_info hf[] = {
1400         { &hf_zbee_zdp_seqno,
1401         { "Sequence Number",            "zbee.zdp.seqno", FT_UINT8, BASE_DEC, NULL, 0x0,
1402             NULL, HFILL }},
1403
1404         { &hf_zbee_zdp_length,
1405         { "Length",                     "zbee.zdp.length", FT_UINT8, BASE_DEC, NULL, 0x0,
1406             NULL, HFILL }},
1407
1408         { &hf_zbee_zdp_ext_addr,
1409         { "Extended Address",           "zbee.zdp.ext_addr", FT_UINT64, BASE_HEX, NULL, 0x0,
1410             NULL, HFILL }},
1411
1412         { &hf_zbee_zdp_device,
1413         { "Device",                     "zbee.zdp.device", FT_UINT16, BASE_HEX, NULL, 0x0,
1414             NULL, HFILL }},
1415
1416         { &hf_zbee_zdp_req_type,
1417         { "Request Type",               "zbee.zdp.req_type", FT_UINT8, BASE_DEC, VALS(zbee_zdp_req_types), 0x0,
1418             NULL, HFILL }},
1419
1420         { &hf_zbee_zdp_index,
1421         { "Index",                      "zbee.zdp.index", FT_UINT8, BASE_DEC, NULL, 0x0,
1422             NULL, HFILL }},
1423
1424         { &hf_zbee_zdp_status,
1425         { "Status",                     "zbee.zdp.status", FT_UINT8, BASE_DEC, VALS(zbee_zdp_status_names), 0x0,
1426             NULL, HFILL }},
1427
1428         { &hf_zbee_zdp_endpoint,
1429         { "Endpoint",                   "zbee.zdp.endpoint", FT_UINT8, BASE_DEC, NULL, 0x0,
1430             NULL, HFILL }},
1431
1432         { &hf_zbee_zdp_ep_count,
1433         { "Endpoint Count",             "zbee.zdp.ep_count", FT_UINT8, BASE_DEC, NULL, 0x0,
1434             NULL, HFILL }},
1435
1436         { &hf_zbee_zdp_profile,
1437         { "Profile",                    "zbee.zdp.profile", FT_UINT16, BASE_HEX, NULL, 0x0,
1438             NULL, HFILL }},
1439
1440         { &hf_zbee_zdp_addr_mode,
1441         { "Address Mode",               "zbee.zdp.addr_mode", FT_UINT8, BASE_DEC, NULL, 0x0,
1442             NULL, HFILL }},
1443
1444         { &hf_zbee_zdp_cluster,
1445         { "Cluster",                    "zbee.zdp.cluster", FT_UINT16, BASE_DEC, NULL, 0x0,
1446             NULL, HFILL }},
1447
1448         { &hf_zbee_zdp_table_size,
1449         { "Table Size",                 "zbee.zdp.table_size", FT_UINT16, BASE_DEC, NULL, 0x0,
1450             "Number of entries in the table.", HFILL }},
1451
1452         { &hf_zbee_zdp_table_count,
1453         { "Table Count",                "zbee.zdp.table_count", FT_UINT16, BASE_DEC, NULL, 0x0,
1454             "Number of table entries included in this message.", HFILL }},
1455
1456         { &hf_zbee_zdp_in_count,
1457         { "Input Cluster Count",        "zbee.zdp.in_count", FT_UINT8, BASE_DEC, NULL, 0x0,
1458             NULL, HFILL }},
1459
1460         { &hf_zbee_zdp_out_count,
1461         { "Output Cluster Count",       "zbee.zdp.out_count", FT_UINT8, BASE_DEC, NULL, 0x0,
1462             NULL, HFILL }},
1463
1464         { &hf_zbee_zdp_in_cluster,
1465         { "Input Cluster",              "zbee.zdp.in_cluster", FT_UINT16, BASE_DEC, NULL, 0x0,
1466             NULL, HFILL }},
1467
1468         { &hf_zbee_zdp_out_cluster,
1469         { "Output Cluster",             "zbee.zdp.out_cluster", FT_UINT16, BASE_DEC, NULL, 0x0,
1470             NULL, HFILL }},
1471
1472         { &hf_zbee_zdp_assoc_device_count,
1473         { "Associated Device Count",    "zbee.zdp.assoc_device_count", FT_UINT8, BASE_DEC, NULL, 0x0,
1474             NULL, HFILL }},
1475
1476         { &hf_zbee_zdp_assoc_device,
1477         { "Associated Device",          "zbee.zdp.assoc_device", FT_UINT16, BASE_HEX, NULL, 0x0,
1478             NULL, HFILL }},
1479
1480         { &hf_zbee_zdp_cinfo_alt_coord,
1481         { "Alternate Coordinator",      "zbee.zdp.cinfo.alt_coord", FT_BOOLEAN, 8, NULL, ZBEE_CINFO_ALT_COORD,
1482             "Indicates that the device is able to operate as a PAN coordinator.", HFILL }},
1483
1484         { &hf_zbee_zdp_cinfo_ffd,
1485         { "Full-Function Device",       "zbee.zdp.cinfo.ffd", FT_BOOLEAN, 8, NULL, ZBEE_CINFO_FFD,
1486             NULL, HFILL }},
1487
1488         { &hf_zbee_zdp_cinfo_power,
1489         { "AC Power",                   "zbee.zdp.cinfo.power", FT_BOOLEAN, 8, NULL, ZBEE_CINFO_POWER,
1490             "Indicates this device is using AC/Mains power.", HFILL }},
1491
1492         { &hf_zbee_zdp_cinfo_idle_rx,
1493         { "Rx On When Idle",            "zbee.zdp.cinfo.power", FT_BOOLEAN, 8, NULL, ZBEE_CINFO_IDLE_RX,
1494             "Indicates the receiver is active when the device is idle.", HFILL }},
1495
1496         { &hf_zbee_zdp_cinfo_security,
1497         { "Security Capability",        "zbee.zdp.cinfo.security", FT_BOOLEAN, 8, NULL, ZBEE_CINFO_SECURITY,
1498             "Indicates this device is capable of performing encryption/decryption.", HFILL }},
1499
1500         { &hf_zbee_zdp_cinfo_alloc,
1501         { "Allocate Short Address",     "zbee.zdp.cinfo.alloc", FT_BOOLEAN, 8, NULL, ZBEE_CINFO_ALLOC,
1502             "Flag requesting the parent to allocate a short address for this device.", HFILL }},
1503
1504         { &hf_zbee_zdp_server_pri_trust,
1505         { "Primary Trust Center",       "zbee.zdp.server.pri_trust", FT_BOOLEAN, 16, NULL, ZBEE_ZDP_NODE_SERVER_PRIMARY_TRUST,
1506             NULL, HFILL }},
1507
1508         { &hf_zbee_zdp_server_bak_trust,
1509         { "Backup Trust Center",        "zbee.zdp.server.bak_trust", FT_BOOLEAN, 16, NULL, ZBEE_ZDP_NODE_SERVER_BACKUP_TRUST,
1510             NULL, HFILL }},
1511
1512         { &hf_zbee_zdp_server_pri_bind,
1513         { "Primary Binding Table Cache","zbee.zdp.server.pri_bind", FT_BOOLEAN, 16, NULL, ZBEE_ZDP_NODE_SERVER_PRIMARY_BIND,
1514             NULL, HFILL }},
1515
1516         { &hf_zbee_zdp_server_bak_bind,
1517         { "Backup Binding Table Cache", "zbee.zdp.server.bak_bind", FT_BOOLEAN, 16, NULL, ZBEE_ZDP_NODE_SERVER_BACKUP_BIND,
1518             NULL, HFILL }},
1519
1520         { &hf_zbee_zdp_server_pri_disc,
1521         { "Primary Discovery Cache",    "zbee.zdp.server.pri_disc", FT_BOOLEAN, 16, NULL, ZBEE_ZDP_NODE_SERVER_PRIMARY_DISC,
1522             NULL, HFILL }},
1523
1524         { &hf_zbee_zdp_server_bak_disc,
1525         { "Backup Discovery Cache",     "zbee.zdp.server.bak_bind", FT_BOOLEAN, 16, NULL, ZBEE_ZDP_NODE_SERVER_BACKUP_DISC,
1526             NULL, HFILL }},
1527
1528         { &hf_zbee_zdp_node_type,
1529         { "Type",                       "zbee.zdp.node.type", FT_UINT16, BASE_DEC, NULL, ZBEE_ZDP_NODE_TYPE,
1530             NULL, HFILL }},
1531
1532         { &hf_zbee_zdp_node_complex,
1533         { "Complex Descriptor",         "zbee.zdp.node.complex", FT_BOOLEAN, 16, NULL, ZBEE_ZDP_NODE_COMPLEX,
1534             NULL, HFILL }},
1535
1536         { &hf_zbee_zdp_node_user,
1537         { "User Descriptor",            "zbee.zdp.node.user", FT_BOOLEAN, 16, NULL, ZBEE_ZDP_NODE_USER,
1538             NULL, HFILL }},
1539
1540         { &hf_zbee_zdp_node_freq_868,
1541         { "868MHz Band",                "zbee.zdp.node.freq.868mhz", FT_BOOLEAN, 16, NULL, ZBEE_ZDP_NODE_FREQ_868MHZ,
1542             NULL, HFILL }},
1543
1544         { &hf_zbee_zdp_node_freq_900,
1545         { "900MHz Band",                "zbee.zdp.node.freq.900mhz", FT_BOOLEAN, 16, NULL, ZBEE_ZDP_NODE_FREQ_900MHZ,
1546             NULL, HFILL }},
1547
1548         { &hf_zbee_zdp_node_freq_2400,
1549         { "2.4GHz Band",                "zbee.zdp.node.freq.2400mhz", FT_BOOLEAN, 16, NULL, ZBEE_ZDP_NODE_FREQ_2400MHZ,
1550             NULL, HFILL }},
1551
1552         { &hf_zbee_zdp_node_manufacturer,
1553         { "Manufacturer Code",          "zbee.zdp.node.manufacturer", FT_UINT16, BASE_HEX, NULL, 0x0,
1554             NULL, HFILL }},
1555
1556         { &hf_zbee_zdp_node_max_buffer,
1557         { "Max Buffer Size",            "zbee.zdp.node.max_buffer", FT_UINT8, BASE_DEC, NULL, 0x0,
1558             NULL, HFILL }},
1559
1560         { &hf_zbee_zdp_node_max_transfer,
1561         { "Max Transfer Size",          "zbee.zdp.node.max_transfer", FT_UINT16, BASE_DEC, NULL, 0x0,
1562             NULL, HFILL }},
1563
1564         { &hf_zbee_zdp_power_mode,
1565         { "Mode",                       "zbee.zdp.power.mode", FT_UINT16, BASE_DEC, NULL, ZBEE_ZDP_POWER_MODE,
1566             NULL, HFILL }},
1567
1568         { &hf_zbee_zdp_power_avail_ac,
1569         { "Available AC Power",         "zbee.zdp.power.avail.ac", FT_BOOLEAN, 16, NULL, ZBEE_ZDP_POWER_AVAIL_AC,
1570             NULL, HFILL }},
1571
1572         { &hf_zbee_zdp_power_avail_recharge,
1573         { "Available Rechargeable Battery", "zbee.zdp.power.avail.rech", FT_BOOLEAN, 16, NULL, ZBEE_ZDP_POWER_AVAIL_RECHARGEABLE,
1574             NULL, HFILL }},
1575
1576         { &hf_zbee_zdp_power_avail_dispose,
1577         { "Available Disposeable Battery",  "zbee.zdp.power.avail.disp", FT_BOOLEAN, 16, NULL, ZBEE_ZDP_POWER_AVAIL_DISPOSEABLE,
1578             NULL, HFILL }},
1579
1580         { &hf_zbee_zdp_power_source_ac,
1581         { "Using AC Power",             "zbee.zdp.power.source.ac", FT_BOOLEAN, 16, NULL, ZBEE_ZDP_POWER_SOURCE_AC,
1582             NULL, HFILL }},
1583
1584         { &hf_zbee_zdp_power_source_recharge,
1585         { "Using Rechargeable Battery", "zbee.zdp.power.source.ac", FT_BOOLEAN, 16, NULL, ZBEE_ZDP_POWER_SOURCE_RECHARGEABLE,
1586             NULL, HFILL }},
1587
1588         { &hf_zbee_zdp_power_source_dispose,
1589         { "Using Disposeable Battery",  "zbee.zdp.power.source.ac", FT_BOOLEAN, 16, NULL, ZBEE_ZDP_POWER_SOURCE_DISPOSEABLE,
1590             NULL, HFILL }},
1591
1592         { &hf_zbee_zdp_power_level,
1593         { "Level",                      "zbee.zdp.power.level", FT_UINT16, BASE_DEC, NULL, ZBEE_ZDP_POWER_LEVEL,
1594             NULL, HFILL }},
1595
1596         { &hf_zbee_zdp_simple_app_device,
1597         { "Application Device",         "zbee.zdp.app.device", FT_UINT16, BASE_HEX, NULL, 0x0,
1598             NULL, HFILL }},
1599
1600         { &hf_zbee_zdp_simple_app_version,
1601         { "Application Version",        "zbee.zdp.app.version", FT_UINT16, BASE_HEX, NULL, 0x0,
1602             NULL, HFILL }},
1603
1604         { &hf_zbee_zdp_complex_length,
1605         { "Complex Descriptor Length",  "zbee.zdp.complex_length", FT_UINT8, BASE_DEC, NULL, 0x0,
1606             NULL, HFILL }},
1607
1608         { &hf_zbee_zdp_complex,
1609         { "Complex Descriptor",         "zbee.zdp.complex", FT_STRING, BASE_NONE, NULL, 0x0,
1610             NULL, HFILL }},
1611
1612         { &hf_zbee_zdp_user,
1613         { "User Descriptor",            "zbee.zdp.user", FT_STRING, BASE_NONE, NULL, 0x0,
1614             NULL, HFILL }},
1615
1616         { &hf_zbee_zdp_user_length,
1617         { "User Descriptor Length",     "zbee.zdp.user_length", FT_UINT8, BASE_DEC, NULL, 0x0,
1618             NULL, HFILL }},
1619
1620         { &hf_zbee_zdp_simple_length,
1621         { "Simple Descriptor Length",   "zbee.zdp.simple_length", FT_UINT8, BASE_DEC, NULL, 0x0,
1622             NULL, HFILL }},
1623
1624         { &hf_zbee_zdp_disc_node_size,
1625         { "Node Descriptor Size",       "zbee.zdp.node_size", FT_UINT8, BASE_DEC, NULL, 0x0,
1626             NULL, HFILL }},
1627
1628         { &hf_zbee_zdp_disc_power_size,
1629         { "Power Descriptor Size",      "zbee.zdp.power_size", FT_UINT8, BASE_DEC, NULL, 0x0,
1630             NULL, HFILL }},
1631
1632         { &hf_zbee_zdp_cache,
1633         { "Cache",                      "zbee.zdp.cache", FT_UINT16, BASE_HEX, NULL, 0x0,
1634             "Address of the device containing the discovery cache.", HFILL }},
1635
1636         { &hf_zbee_zdp_disc_ep_count,
1637         { "Active Endpoint Count",      "zbee.zdp.ep_count", FT_UINT8, BASE_DEC, NULL, 0x0,
1638             NULL, HFILL }},
1639
1640         { &hf_zbee_zdp_disc_simple_count,
1641         { "Simple Descriptor Count",    "zbee.zdp.simple_count", FT_UINT8, BASE_DEC, NULL, 0x0,
1642             NULL, HFILL }},
1643
1644         { &hf_zbee_zdp_disc_simple_size,
1645         { "Simple Descriptor Size",     "zbee.zdp.simple_size", FT_UINT8, BASE_DEC, NULL, 0x0,
1646             NULL, HFILL }},
1647
1648         { &hf_zbee_zdp_target,
1649         { "Target",                     "zbee.zdp.target", FT_UINT16, BASE_HEX, NULL, 0x0,
1650             NULL, HFILL }},
1651
1652         { &hf_zbee_zdp_target64,
1653         { "Target",                     "zbee.zdp.target64", FT_UINT64, BASE_HEX, NULL, 0x0,
1654             NULL, HFILL }},
1655
1656         { &hf_zbee_zdp_target_ep,
1657         { "Target Endpoint",            "zbee.zdp.target_ep", FT_UINT8, BASE_DEC, NULL, 0x0,
1658             NULL, HFILL }},
1659
1660         { &hf_zbee_zdp_replacement,
1661         { "Replacement",                "zbee.zdp.replacement", FT_UINT64, BASE_HEX, NULL, 0x0,
1662             NULL, HFILL }},
1663
1664         { &hf_zbee_zdp_replacement_ep,
1665         { "Replacement Endpoint",       "zbee.zdp.replacement_ep", FT_UINT8, BASE_DEC, NULL, 0x0,
1666             NULL, HFILL }},
1667
1668         { &hf_zbee_zdp_bind_src,
1669         { "Source",                     "zbee.zdp.bind.src", FT_UINT16, BASE_HEX, NULL, 0x0,
1670             NULL, HFILL }},
1671
1672         { &hf_zbee_zdp_bind_src64,
1673         { "Source",                     "zbee.zdp.bind.src64", FT_UINT64, BASE_HEX, NULL, 0x0,
1674             NULL, HFILL }},
1675
1676         { &hf_zbee_zdp_bind_src_ep,
1677         { "Source Endpoint",            "zbee.zdp.bind.src_ep", FT_UINT8, BASE_DEC, NULL, 0x0,
1678             NULL, HFILL }},
1679
1680         { &hf_zbee_zdp_bind_dst,
1681         { "Destination",                "zbee.zdp.bind.dst", FT_UINT16, BASE_HEX, NULL, 0x0,
1682             NULL, HFILL }},
1683
1684         { &hf_zbee_zdp_bind_dst64,
1685         { "Destination",                "zbee.zdp.bind.dst64", FT_UINT64, BASE_HEX, NULL, 0x0,
1686             NULL, HFILL }},
1687
1688         { &hf_zbee_zdp_bind_dst_ep,
1689         { "Destination Endpoint",       "zbee.zdp.bind.dst_ep", FT_UINT8, BASE_DEC, NULL, 0x0,
1690             NULL, HFILL }},
1691
1692         { &hf_zbee_zdp_duration,
1693         { "Duration",                   "zbee.zdp.duration", FT_UINT8, BASE_DEC, NULL, 0x0,
1694             NULL, HFILL }},
1695
1696         { &hf_zbee_zdp_leave_children,
1697         { "Remove Children",            "zbee.zdp.leave.children", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
1698             NULL, HFILL }},
1699
1700         { &hf_zbee_zdp_leave_rejoin,
1701         { "Rejoin",                     "zbee.zdp.leave.rejoin", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
1702             NULL, HFILL }},
1703
1704         { &hf_zbee_zdp_significance,
1705         { "Significance",               "zbee.zdp.significance", FT_UINT8, BASE_DEC, NULL, 0x0,
1706             NULL, HFILL }},
1707
1708         { &hf_zbee_zdp_scan_count,
1709         { "Scan Count",                 "zbee.zdp.scan_count", FT_UINT8, BASE_DEC, NULL, 0x0,
1710             NULL, HFILL }},
1711
1712         { &hf_zbee_zdp_update_id,
1713         { "Update ID",                  "zbee.zdp.update_id", FT_UINT8, BASE_DEC, NULL, 0x0,
1714             NULL, HFILL }},
1715
1716         { &hf_zbee_zdp_manager,
1717         { "Network Manager",            "zbee.zdp.manager", FT_UINT16, BASE_HEX, NULL, 0x0,
1718             NULL, HFILL }},
1719
1720         { &hf_zbee_zdp_tx_total,
1721         { "Total Transmissions",        "zbee.zdp.tx_total", FT_UINT16, BASE_DEC, NULL, 0x0,
1722             NULL, HFILL }},
1723
1724         { &hf_zbee_zdp_tx_fail,
1725         { "Failed Transmissions",       "zbee.zdp.tx_fail", FT_UINT16, BASE_DEC, NULL, 0x0,
1726             NULL, HFILL }},
1727
1728         { &hf_zbee_zdp_channel_count,
1729         { "Channel List Count",         "zbee.zdp.channel_count", FT_UINT8, BASE_DEC, NULL, 0x0,
1730             NULL, HFILL }}
1731     };
1732
1733     /*  APS subtrees */
1734     static gint *ett[] = {
1735         &ett_zbee_zdp,
1736         &ett_zbee_zdp_endpoint,
1737         &ett_zbee_zdp_match_in,
1738         &ett_zbee_zdp_match_out,
1739         &ett_zbee_zdp_node,
1740         &ett_zbee_zdp_node_in,
1741         &ett_zbee_zdp_node_out,
1742         &ett_zbee_zdp_power,
1743         &ett_zbee_zdp_simple,
1744         &ett_zbee_zdp_complex,
1745         &ett_zbee_zdp_cinfo,
1746         &ett_zbee_zdp_server,
1747         &ett_zbee_zdp_simple_sizes,
1748         &ett_zbee_zdp_bind,
1749         &ett_zbee_zdp_bind_end_in,
1750         &ett_zbee_zdp_bind_end_out,
1751         &ett_zbee_zdp_bind_table,
1752         &ett_zbee_zdp_bind_source,
1753         &ett_zbee_zdp_channels,
1754         &ett_zbee_zdp_assoc_device,
1755         &ett_zbee_zdp_nwk,
1756         &ett_zbee_zdp_lqi,
1757         &ett_zbee_zdp_rtg,
1758         &ett_zbee_zdp_cache
1759     };
1760
1761     /* Register ZigBee ZDP protocol with Wireshark. */
1762     proto_zbee_zdp = proto_register_protocol("ZigBee Device Profile", "ZigBee ZDP", "zbee.zdp");
1763     proto_register_field_array(proto_zbee_zdp, hf, array_length(hf));
1764     proto_register_subtree_array(ett, array_length(ett));
1765
1766     /* Register the ZDP dissector. */
1767     register_dissector("zbee.zdp", dissect_zbee_zdp, proto_zbee_zdp);
1768 } /* proto_register_zbee_zdp */
1769
1770 /*FUNCTION:------------------------------------------------------
1771  *  NAME
1772  *      proto_reg_handoff_zbee_zdp
1773  *  DESCRIPTION
1774  *      Registers the Zigbee Device Profile dissector with Wireshark.
1775  *  PARAMETERS
1776  *      none
1777  *  RETURNS
1778  *      void
1779  *---------------------------------------------------------------
1780  */
1781 void proto_reg_handoff_zbee_zdp(void)
1782 {
1783     dissector_handle_t  zdp_handle;
1784
1785     /* Find the other dissectors we need. */
1786     data_handle     = find_dissector("data");
1787
1788     /* Register our dissector with the ZigBee application dissectors. */
1789     zdp_handle = find_dissector("zbee.zdp");
1790     dissector_add_uint("zbee.profile", ZBEE_ZDP_PROFILE, zdp_handle);
1791 } /* proto_reg_handoff_zbee_zdp */