2 * Dissector routines for the ZigBee Device Profile (ZDP)
3 * By Owen Kirby <osk@exegin.com>
4 * Copyright 2009 Exegin Technologies Limited
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1998 Gerald Combs
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
30 #endif /* HAVE_CONFIG_H */
35 #include <epan/packet.h>
36 #include <epan/expert.h>
38 #include "packet-zbee.h"
39 #include "packet-zbee-zdp.h"
41 /*************************/
42 /* Function Declarations */
43 /*************************/
44 /* Local Helper routines. */
45 static guint16 zdp_convert_2003cluster (guint8 cluster);
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);
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);
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);
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);
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);
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);
137 /**************************************
139 **************************************
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. */
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;
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;
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;
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;
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;
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;
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;
213 /* User descriptor indicies. */
214 int hf_zbee_zdp_user = -1;
215 int hf_zbee_zdp_user_length = -1;
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;
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;
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;
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;
276 /* Data dissector handle. */
277 static dissector_handle_t data_handle;
279 /**************************************
281 **************************************
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" },
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" },
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" },
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" },
394 /*FUNCTION:------------------------------------------------------
398 * Returns a status name for a given status value.
403 *---------------------------------------------------------------
406 zdp_status_name(guint8 status)
408 return val_to_str(status, zbee_zdp_status_names, "Reserved");
409 } /* zdp_status_name */
411 /*FUNCTION:------------------------------------------------------
413 * zdp_convert_2003cluster
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.
423 *---------------------------------------------------------------
426 zdp_convert_2003cluster(guint8 cluster)
428 guint16 cluster16 = (guint16)cluster;
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);
437 } /* zdp_convert_2003cluster */
439 /*FUNCTION:------------------------------------------------------
443 * Helper functions dumps any excess data into the data dissector.
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.
451 *---------------------------------------------------------------
454 zdp_dump_excess(tvbuff_t *tvb, guint offset, packet_info *pinfo, proto_tree *tree)
456 proto_tree *root = proto_tree_get_root(tree);
457 guint length = tvb_length_remaining(tvb, offset);
461 excess = tvb_new_subset(tvb, offset, length, length);
462 call_dissector(data_handle, excess, pinfo, root);
464 } /* zdp_dump_excess */
466 /*FUNCTION:------------------------------------------------------
470 * ZigBee helper function. Appends the info to the info column
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.
479 *---------------------------------------------------------------
482 zbee_append_info(proto_item *item, packet_info *pinfo, const gchar *format, ...)
484 static gchar buffer[512];
487 va_start(ap, format);
488 g_vsnprintf(buffer, 512, format, ap);
492 proto_item_append_text(item, "%s", buffer);
494 col_append_str(pinfo->cinfo, COL_INFO, buffer);
495 } /* zbee_add_info */
497 /*FUNCTION:------------------------------------------------------
501 * ZigBee helper function. extracts an integer and displays it to the tree.
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.
510 * guint - the value read out of the tvbuff and added to the tree.
511 *---------------------------------------------------------------
514 zbee_parse_uint(proto_tree *tree, int hfindex, tvbuff_t *tvb, guint *offset, guint length, proto_item **ti)
516 proto_item *item = NULL;
524 else if (length == 1) {
525 value = tvb_get_guint8(tvb, *offset);
527 else if (length == 2) {
528 value = tvb_get_letohs(tvb, *offset);
530 else if (length == 3) {
531 value = tvb_get_letohs(tvb, *offset);
532 value += ((guint32)tvb_get_guint8(tvb, *offset + 2) << 16);
535 value = tvb_get_letohl(tvb, *offset);
540 item = proto_tree_add_uint(tree, hfindex, tvb, *offset, length, value);
543 /* Increment the offset. */
546 /* return the item if requested. */
549 /* return the value. */
551 } /* zbee_parse_uint */
553 /*FUNCTION:------------------------------------------------------
557 * ZigBee helper function. extracts an EUI64 address and displays
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.
567 * guint64 - the value read out of the tvbuff and added to the tree.
568 *---------------------------------------------------------------
571 zbee_parse_eui64(proto_tree *tree, int hfindex, tvbuff_t *tvb, guint *offset, guint length, proto_item **ti)
573 proto_item *item = NULL;
577 value = tvb_get_letoh64(tvb, *offset);
581 item = proto_tree_add_eui64(tree, hfindex, tvb, *offset, length, value);
584 /* Increment the offset. */
585 *offset += sizeof(guint64);
587 /* return the item if requested. */
590 /* return the value. */
592 } /* zbee_parse_eui64 */
594 /*FUNCTION:------------------------------------------------------
598 * Parses and displays the status value.
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.
605 *---------------------------------------------------------------
608 zdp_parse_status(proto_tree *tree, tvbuff_t *tvb, guint *offset)
612 /* Get and display the flags. */
613 status = tvb_get_guint8(tvb, *offset);
615 proto_tree_add_uint(tree, hf_zbee_zdp_status, tvb, *offset, sizeof(guint8), status);
617 *offset += sizeof(guint8);
620 } /* zdp_parse_status */
622 /*FUNCTION:------------------------------------------------------
626 * Parses and displays the a channel mask.
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.
633 *---------------------------------------------------------------
636 zdp_parse_chanmask(proto_tree *tree, tvbuff_t *tvb, guint *offset)
642 /* Get and display the channel mask. */
643 mask = tvb_get_letohl(tvb, *offset);
645 ti = proto_tree_add_text(tree, tvb, *offset, sizeof(guint32), "Channels: ");
647 /* Check if there are any channels to display. */
649 proto_item_append_text(ti, "None");
651 /* Display the first channel #. */
652 for (i=0; i<(8*(int)sizeof(guint32)); i++) {
654 proto_item_append_text(ti, "%d", i++);
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. */
664 /* If the previous channel wasn't selected, then display the
667 if ( ! ((1<<(i-1)) & mask) ) {
668 proto_item_append_text(ti, ", %d", i);
671 * If the next channel is selected too, skip past it and display
672 * a range of values instead.
675 while ((2<<i) & mask) i++;
676 proto_item_append_text(ti, "-%d", i);
680 *offset += sizeof(guint32);
683 } /* zdp_parse_chanmask */
685 /*FUNCTION:------------------------------------------------------
689 * Parses and displays MAC capability info flags.
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.
698 *---------------------------------------------------------------
701 zdp_parse_cinfo(proto_tree *tree, gint ettindex, tvbuff_t *tvb, guint *offset)
704 proto_tree *field_tree;
707 /* Get and display the flags. */
708 flags = tvb_get_guint8(tvb, *offset);
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);
714 else field_tree = tree;
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);
723 *offset += sizeof(guint8);
726 } /* zdp_parse_cinfo */
728 /*FUNCTION:------------------------------------------------------
730 * zdp_parse_server_flags
732 * Parses and displays server mode flags.
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.
741 *---------------------------------------------------------------
744 zdp_parse_server_flags(proto_tree *tree, gint ettindex, tvbuff_t *tvb, guint *offset)
747 proto_tree *field_tree;
750 /* Get and display the flags. */
751 flags = tvb_get_letohs(tvb, *offset);
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);
757 else field_tree = tree;
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);
766 *offset += sizeof(guint16);
769 } /* zdp_parse_server_flags */
771 /*FUNCTION:------------------------------------------------------
773 * zdp_parse_node_desc
775 * Parses and displays a node descriptor to the the specified
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.
786 *---------------------------------------------------------------
789 zdp_parse_node_desc(proto_tree *tree, gint ettindex, tvbuff_t *tvb, guint *offset, packet_info *pinfo)
792 proto_item *field_root = NULL;
793 proto_tree *field_tree = NULL;
799 guint16 max_transfer;
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);
805 else field_tree = tree;
807 /* Get and display the flags. */
808 flags = tvb_get_letohs(tvb, *offset);
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);
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)");
824 *offset += sizeof(guint16);
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);
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);
837 /* Correct the length of the subtree. */
838 if (tree && (ettindex != -1)) {
839 proto_item_set_len(field_root, *offset);
842 } /* zdp_parse_node_desc */
844 /*FUNCTION:------------------------------------------------------
846 * zdp_parse_power_desc
848 * Parses and displays a node descriptor to the the specified
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.
859 *---------------------------------------------------------------
862 zdp_parse_power_desc(proto_tree *tree, gint ettindex, tvbuff_t *tvb, guint *offset)
865 proto_tree *field_tree;
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);
875 else field_tree = tree;
877 flags = tvb_get_letohs(tvb, *offset);
878 mode = flags & ZBEE_ZDP_POWER_MODE;
879 level = flags & ZBEE_ZDP_POWER_LEVEL;
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)");
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);
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);
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");
905 *offset += sizeof(guint16);
906 } /* zdp_parse_power_desc */
908 /*FUNCTION:------------------------------------------------------
910 * zdp_parse_simple_desc
912 * Parses and displays a simple descriptor to the the specified
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.
923 *---------------------------------------------------------------
926 zdp_parse_simple_desc(proto_tree *tree, gint ettindex, tvbuff_t *tvb, guint *offset, packet_info *pinfo)
929 proto_item *field_root = NULL;
930 proto_tree *field_tree = NULL, *cluster_tree = NULL;
931 guint i, sizeof_cluster;
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);
944 else field_tree = tree;
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);
951 sizeof_cluster = (pinfo->zbee_stack_vers >= ZBEE_VERSION_2007)?sizeof(guint16):sizeof(guint8);
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);
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);
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);
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);
971 if (tree && (ettindex != -1)) {
972 proto_item_set_len(field_root, *offset);
974 } /* zdp_parse_simple_desc */
976 /*FUNCTION:------------------------------------------------------
978 * zdp_parse_complex_desc
980 * Parses and displays a simple descriptor to the the specified
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.
992 *---------------------------------------------------------------
995 zdp_parse_complex_desc(proto_tree *tree, gint ettindex, tvbuff_t *tvb, guint *offset, guint length)
1007 const gchar *tag_name[] = {
1018 const gint max_len = 128;
1020 proto_item *field_root;
1021 proto_tree *field_tree;
1023 gchar *str = ep_alloc(length);
1024 gchar *complex = ep_alloc(max_len);
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);
1031 else field_tree = tree;
1033 tag = tvb_get_guint8(tvb, *offset);
1034 if (tag == tag_charset) {
1036 guint8 charset = tvb_get_guint8(tvb, *offset + 3);
1039 if (charset == 0x00) charset_str = "ASCII";
1040 else charset_str = "Unknown Character Set";
1042 lang_str[0] = tvb_get_guint8(tvb, *offset + 1);
1043 lang_str[1] = tvb_get_guint8(tvb, *offset + 2);
1046 g_snprintf(complex, max_len, "<%s>%s, %s</%s>", tag_name[tag_charset], lang_str, charset_str, tag_name[tag_charset]);
1048 else if (tag == tag_icon) {
1050 g_snprintf(complex, max_len, "<%s>FixMe</%s>", tag_name[tag_icon], tag_name[tag_icon]);
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]);
1060 g_snprintf(complex, max_len, "<%s>%s</%s>", tag_name[0], str, tag_name[0]);
1064 proto_tree_add_string(field_tree, hf_zbee_zdp_complex, tvb, *offset, length, complex);
1066 *offset += (length);
1067 } /* zdp_parse_complex_desc */
1069 /*FUNCTION:------------------------------------------------------
1073 * ZigBee Device Profile dissector for wireshark.
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.
1080 *---------------------------------------------------------------
1083 dissect_zbee_zdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1085 proto_tree *zdp_tree = NULL;
1086 proto_item *proto_root;
1093 /* Create the protocol 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);
1099 /* Overwrite the protocol column */
1100 col_set_str(pinfo->cinfo, COL_PROTOCOL, "ZigBee ZDP");
1102 /* Get and display the sequence number. */
1103 seqno = tvb_get_guint8(tvb, offset);
1105 proto_tree_add_uint(zdp_tree, hf_zbee_zdp_seqno, tvb, offset, sizeof(guint8), seqno);
1107 offset += sizeof(guint8);
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);
1115 cluster = pinfo->zbee_cluster_id;
1120 proto_item_append_text(zdp_tree, ", %s", val_to_str(cluster, zbee_zdp_cluster_names, "Unknown Cluster"));
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"));
1126 /* Create a new tvb for the zdp message. */
1127 zdp_tvb = tvb_new_subset_remaining(tvb, offset);
1130 case ZBEE_ZDP_REQ_NWK_ADDR:
1131 dissect_zbee_zdp_req_nwk_addr(zdp_tvb, pinfo, zdp_tree);
1133 case ZBEE_ZDP_REQ_IEEE_ADDR:
1134 dissect_zbee_zdp_req_ext_addr(zdp_tvb, pinfo, zdp_tree);
1136 case ZBEE_ZDP_REQ_NODE_DESC:
1137 dissect_zbee_zdp_req_node_desc(zdp_tvb, pinfo, zdp_tree);
1139 case ZBEE_ZDP_REQ_POWER_DESC:
1140 dissect_zbee_zdp_req_power_desc(zdp_tvb, pinfo, zdp_tree);
1142 case ZBEE_ZDP_REQ_SIMPLE_DESC:
1143 dissect_zbee_zdp_req_simple_desc(zdp_tvb, pinfo, zdp_tree);
1145 case ZBEE_ZDP_REQ_ACTIVE_EP:
1146 dissect_zbee_zdp_req_active_ep(zdp_tvb, pinfo, zdp_tree);
1148 case ZBEE_ZDP_REQ_MATCH_DESC:
1149 dissect_zbee_zdp_req_match_desc(zdp_tvb, pinfo, zdp_tree);
1151 case ZBEE_ZDP_REQ_COMPLEX_DESC:
1152 dissect_zbee_zdp_req_complex_desc(zdp_tvb, pinfo, zdp_tree);
1154 case ZBEE_ZDP_REQ_USER_DESC:
1155 dissect_zbee_zdp_req_user_desc(zdp_tvb, pinfo, zdp_tree);
1157 case ZBEE_ZDP_REQ_DISCOVERY_CACHE:
1158 dissect_zbee_zdp_req_discovery_cache(zdp_tvb, pinfo, zdp_tree);
1160 case ZBEE_ZDP_REQ_DEVICE_ANNCE:
1161 dissect_zbee_zdp_device_annce(zdp_tvb, pinfo, zdp_tree);
1163 case ZBEE_ZDP_REQ_SET_USER_DESC:
1164 dissect_zbee_zdp_req_set_user_desc(zdp_tvb, pinfo, zdp_tree);
1166 case ZBEE_ZDP_REQ_SYSTEM_SERVER_DISC:
1167 dissect_zbee_zdp_req_system_server_disc(zdp_tvb, pinfo, zdp_tree);
1169 case ZBEE_ZDP_REQ_STORE_DISCOVERY:
1170 dissect_zbee_zdp_req_store_discovery(zdp_tvb, pinfo, zdp_tree);
1172 case ZBEE_ZDP_REQ_STORE_NODE_DESC:
1173 dissect_zbee_zdp_req_store_node_desc(zdp_tvb, pinfo, zdp_tree);
1175 case ZBEE_ZDP_REQ_STORE_POWER_DESC:
1176 dissect_zbee_zdp_req_store_power_desc(zdp_tvb, pinfo, zdp_tree);
1178 case ZBEE_ZDP_REQ_STORE_ACTIVE_EP:
1179 dissect_zbee_zdp_req_store_active_ep(zdp_tvb, pinfo, zdp_tree);
1181 case ZBEE_ZDP_REQ_STORE_SIMPLE_DESC:
1182 dissect_zbee_zdp_req_store_simple_desc(zdp_tvb, pinfo, zdp_tree);
1184 case ZBEE_ZDP_REQ_REMOVE_NODE_CACHE:
1185 dissect_zbee_zdp_req_remove_node_cache(zdp_tvb, pinfo, zdp_tree);
1187 case ZBEE_ZDP_REQ_FIND_NODE_CACHE:
1188 dissect_zbee_zdp_req_find_node_cache(zdp_tvb, pinfo, zdp_tree);
1190 case ZBEE_ZDP_REQ_EXT_SIMPLE_DESC:
1191 dissect_zbee_zdp_req_ext_simple_desc(zdp_tvb, pinfo, zdp_tree);
1193 case ZBEE_ZDP_REQ_EXT_ACTIVE_EP:
1194 dissect_zbee_zdp_req_ext_active_ep(zdp_tvb, pinfo, zdp_tree);
1196 case ZBEE_ZDP_REQ_END_DEVICE_BIND:
1197 dissect_zbee_zdp_req_end_device_bind(zdp_tvb, pinfo, zdp_tree);
1199 case ZBEE_ZDP_REQ_BIND:
1200 dissect_zbee_zdp_req_bind(zdp_tvb, pinfo, zdp_tree);
1202 case ZBEE_ZDP_REQ_UNBIND:
1203 dissect_zbee_zdp_req_unbind(zdp_tvb, pinfo, zdp_tree);
1205 case ZBEE_ZDP_REQ_BIND_REGISTER:
1206 dissect_zbee_zdp_req_bind_register(zdp_tvb, pinfo, zdp_tree);
1208 case ZBEE_ZDP_REQ_REPLACE_DEVICE:
1209 dissect_zbee_zdp_req_replace_device(zdp_tvb, pinfo, zdp_tree);
1211 case ZBEE_ZDP_REQ_STORE_BAK_BIND_ENTRY:
1212 dissect_zbee_zdp_req_store_bak_bind_entry(zdp_tvb, pinfo, zdp_tree);
1214 case ZBEE_ZDP_REQ_REMOVE_BAK_BIND_ENTRY:
1215 dissect_zbee_zdp_req_remove_bak_bind_entry(zdp_tvb, pinfo, zdp_tree);
1217 case ZBEE_ZDP_REQ_BACKUP_BIND_TABLE:
1218 dissect_zbee_zdp_req_backup_bind_table(zdp_tvb, pinfo, zdp_tree);
1220 case ZBEE_ZDP_REQ_RECOVER_BIND_TABLE:
1221 dissect_zbee_zdp_req_recover_bind_table(zdp_tvb, pinfo, zdp_tree);
1223 case ZBEE_ZDP_REQ_BACKUP_SOURCE_BIND:
1224 dissect_zbee_zdp_req_backup_source_bind(zdp_tvb, pinfo, zdp_tree);
1226 case ZBEE_ZDP_REQ_RECOVER_SOURCE_BIND:
1227 dissect_zbee_zdp_req_recover_source_bind(zdp_tvb, pinfo, zdp_tree);
1229 case ZBEE_ZDP_REQ_MGMT_NWK_DISC:
1230 dissect_zbee_zdp_req_mgmt_nwk_disc(zdp_tvb, pinfo, zdp_tree);
1232 case ZBEE_ZDP_REQ_MGMT_LQI:
1233 dissect_zbee_zdp_req_mgmt_lqi(zdp_tvb, pinfo, zdp_tree);
1235 case ZBEE_ZDP_REQ_MGMT_RTG:
1236 dissect_zbee_zdp_req_mgmt_rtg(zdp_tvb, pinfo, zdp_tree);
1238 case ZBEE_ZDP_REQ_MGMT_BIND:
1239 dissect_zbee_zdp_req_mgmt_bind(zdp_tvb, pinfo, zdp_tree);
1241 case ZBEE_ZDP_REQ_MGMT_LEAVE:
1242 dissect_zbee_zdp_req_mgmt_leave(zdp_tvb, pinfo, zdp_tree);
1244 case ZBEE_ZDP_REQ_MGMT_DIRECT_JOIN:
1245 dissect_zbee_zdp_req_mgmt_direct_join(zdp_tvb, pinfo, zdp_tree);
1247 case ZBEE_ZDP_REQ_MGMT_PERMIT_JOIN:
1248 dissect_zbee_zdp_req_mgmt_permit_join(zdp_tvb, pinfo, zdp_tree);
1250 case ZBEE_ZDP_REQ_MGMT_CACHE:
1251 dissect_zbee_zdp_req_mgmt_cache(zdp_tvb, pinfo, zdp_tree);
1253 case ZBEE_ZDP_REQ_MGMT_NWKUPDATE:
1254 dissect_zbee_zdp_req_mgmt_nwkupdate(zdp_tvb, pinfo, zdp_tree);
1256 case ZBEE_ZDP_RSP_NWK_ADDR:
1257 dissect_zbee_zdp_rsp_nwk_addr(zdp_tvb, pinfo, zdp_tree);
1259 case ZBEE_ZDP_RSP_IEEE_ADDR:
1260 dissect_zbee_zdp_rsp_ext_addr(zdp_tvb, pinfo, zdp_tree);
1262 case ZBEE_ZDP_RSP_NODE_DESC:
1263 dissect_zbee_zdp_rsp_node_desc(zdp_tvb, pinfo, zdp_tree);
1265 case ZBEE_ZDP_RSP_POWER_DESC:
1266 dissect_zbee_zdp_rsp_power_desc(zdp_tvb, pinfo, zdp_tree);
1268 case ZBEE_ZDP_RSP_SIMPLE_DESC:
1269 dissect_zbee_zdp_rsp_simple_desc(zdp_tvb, pinfo, zdp_tree);
1271 case ZBEE_ZDP_RSP_ACTIVE_EP:
1272 dissect_zbee_zdp_rsp_active_ep(zdp_tvb, pinfo, zdp_tree);
1274 case ZBEE_ZDP_RSP_MATCH_DESC:
1275 dissect_zbee_zdp_rsp_match_desc(zdp_tvb, pinfo, zdp_tree);
1277 case ZBEE_ZDP_RSP_COMPLEX_DESC:
1278 dissect_zbee_zdp_rsp_complex_desc(zdp_tvb, pinfo, zdp_tree);
1280 case ZBEE_ZDP_RSP_USER_DESC:
1281 dissect_zbee_zdp_rsp_user_desc(zdp_tvb, pinfo, zdp_tree);
1283 case ZBEE_ZDP_RSP_DISCOVERY_CACHE:
1284 dissect_zbee_zdp_rsp_discovery_cache(zdp_tvb, pinfo, zdp_tree);
1286 case ZBEE_ZDP_RSP_CONF_USER_DESC:
1287 dissect_zbee_zdp_rsp_user_desc_conf(zdp_tvb, pinfo, zdp_tree);
1289 case ZBEE_ZDP_RSP_SYSTEM_SERVER_DISC:
1290 dissect_zbee_zdp_rsp_system_server_disc(zdp_tvb, pinfo, zdp_tree);
1292 case ZBEE_ZDP_RSP_STORE_DISCOVERY:
1293 dissect_zbee_zdp_rsp_discovery_store(zdp_tvb, pinfo, zdp_tree);
1295 case ZBEE_ZDP_RSP_STORE_NODE_DESC:
1296 dissect_zbee_zdp_rsp_store_node_desc(zdp_tvb, pinfo, zdp_tree);
1298 case ZBEE_ZDP_RSP_STORE_POWER_DESC:
1299 dissect_zbee_zdp_rsp_store_power_desc(zdp_tvb, pinfo, zdp_tree);
1301 case ZBEE_ZDP_RSP_STORE_ACTIVE_EP:
1302 dissect_zbee_zdp_rsp_store_active_ep(zdp_tvb, pinfo, zdp_tree);
1304 case ZBEE_ZDP_RSP_STORE_SIMPLE_DESC:
1305 dissect_zbee_zdp_rsp_store_simple_desc(zdp_tvb, pinfo, zdp_tree);
1307 case ZBEE_ZDP_RSP_REMOVE_NODE_CACHE:
1308 dissect_zbee_zdp_rsp_remove_node_cache(zdp_tvb, pinfo, zdp_tree);
1310 case ZBEE_ZDP_RSP_FIND_NODE_CACHE:
1311 dissect_zbee_zdp_rsp_find_node_cache(zdp_tvb, pinfo, zdp_tree);
1313 case ZBEE_ZDP_RSP_EXT_SIMPLE_DESC:
1314 dissect_zbee_zdp_rsp_ext_simple_desc(zdp_tvb, pinfo, zdp_tree);
1316 case ZBEE_ZDP_RSP_EXT_ACTIVE_EP:
1317 dissect_zbee_zdp_rsp_ext_active_ep(zdp_tvb, pinfo, zdp_tree);
1319 case ZBEE_ZDP_RSP_END_DEVICE_BIND:
1320 dissect_zbee_zdp_rsp_end_device_bind(zdp_tvb, pinfo, zdp_tree);
1322 case ZBEE_ZDP_RSP_BIND:
1323 dissect_zbee_zdp_rsp_bind(zdp_tvb, pinfo, zdp_tree);
1325 case ZBEE_ZDP_RSP_UNBIND:
1326 dissect_zbee_zdp_rsp_unbind(zdp_tvb, pinfo, zdp_tree);
1328 case ZBEE_ZDP_RSP_BIND_REGISTER:
1329 dissect_zbee_zdp_rsp_bind_register(zdp_tvb, pinfo, zdp_tree);
1331 case ZBEE_ZDP_RSP_REPLACE_DEVICE:
1332 dissect_zbee_zdp_rsp_replace_device(zdp_tvb, pinfo, zdp_tree);
1334 case ZBEE_ZDP_RSP_STORE_BAK_BIND_ENTRY:
1335 dissect_zbee_zdp_rsp_store_bak_bind_entry(zdp_tvb, pinfo, zdp_tree);
1337 case ZBEE_ZDP_RSP_REMOVE_BAK_BIND_ENTRY:
1338 dissect_zbee_zdp_rsp_remove_bak_bind_entry(zdp_tvb, pinfo, zdp_tree);
1340 case ZBEE_ZDP_RSP_BACKUP_BIND_TABLE:
1341 dissect_zbee_zdp_rsp_backup_bind_table(zdp_tvb, pinfo, zdp_tree);
1343 case ZBEE_ZDP_RSP_RECOVER_BIND_TABLE:
1344 dissect_zbee_zdp_rsp_recover_bind_table(zdp_tvb, pinfo, zdp_tree);
1346 case ZBEE_ZDP_RSP_BACKUP_SOURCE_BIND:
1347 dissect_zbee_zdp_rsp_backup_source_bind(zdp_tvb, pinfo, zdp_tree);
1349 case ZBEE_ZDP_RSP_RECOVER_SOURCE_BIND:
1350 dissect_zbee_zdp_rsp_recover_source_bind(zdp_tvb, pinfo, zdp_tree);
1352 case ZBEE_ZDP_RSP_MGMT_NWK_DISC:
1353 dissect_zbee_zdp_rsp_mgmt_nwk_disc(zdp_tvb, pinfo, zdp_tree);
1355 case ZBEE_ZDP_RSP_MGMT_LQI:
1356 dissect_zbee_zdp_rsp_mgmt_lqi(zdp_tvb, pinfo, zdp_tree);
1358 case ZBEE_ZDP_RSP_MGMT_RTG:
1359 dissect_zbee_zdp_rsp_mgmt_rtg(zdp_tvb, pinfo, zdp_tree);
1361 case ZBEE_ZDP_RSP_MGMT_BIND:
1362 dissect_zbee_zdp_rsp_mgmt_bind(zdp_tvb, pinfo, zdp_tree);
1364 case ZBEE_ZDP_RSP_MGMT_LEAVE:
1365 dissect_zbee_zdp_rsp_mgmt_leave(zdp_tvb, pinfo, zdp_tree);
1367 case ZBEE_ZDP_RSP_MGMT_DIRECT_JOIN:
1368 dissect_zbee_zdp_rsp_mgmt_direct_join(zdp_tvb, pinfo, zdp_tree);
1370 case ZBEE_ZDP_RSP_MGMT_PERMIT_JOIN:
1371 dissect_zbee_zdp_rsp_mgmt_permit_join(zdp_tvb, pinfo, zdp_tree);
1373 case ZBEE_ZDP_RSP_MGMT_CACHE:
1374 dissect_zbee_zdp_rsp_mgmt_cache(zdp_tvb, pinfo, zdp_tree);
1376 case ZBEE_ZDP_RSP_MGMT_NWKUPDATE:
1377 dissect_zbee_zdp_rsp_mgmt_nwkupdate(zdp_tvb, pinfo, zdp_tree);
1380 /* Invalid Cluster Identifier. */
1381 call_dissector(data_handle, zdp_tvb, pinfo, tree);
1384 } /* dissect_zbee_zdp */
1386 /*FUNCTION:------------------------------------------------------
1388 * proto_register_zbee_zdp
1390 * ZigBee Device Profile protocol registration routine.
1395 *---------------------------------------------------------------
1397 void proto_register_zbee_zdp(void)
1399 static hf_register_info hf[] = {
1400 { &hf_zbee_zdp_seqno,
1401 { "Sequence Number", "zbee.zdp.seqno", FT_UINT8, BASE_DEC, NULL, 0x0,
1404 { &hf_zbee_zdp_length,
1405 { "Length", "zbee.zdp.length", FT_UINT8, BASE_DEC, NULL, 0x0,
1408 { &hf_zbee_zdp_ext_addr,
1409 { "Extended Address", "zbee.zdp.ext_addr", FT_UINT64, BASE_HEX, NULL, 0x0,
1412 { &hf_zbee_zdp_device,
1413 { "Device", "zbee.zdp.device", FT_UINT16, BASE_HEX, NULL, 0x0,
1416 { &hf_zbee_zdp_req_type,
1417 { "Request Type", "zbee.zdp.req_type", FT_UINT8, BASE_DEC, VALS(zbee_zdp_req_types), 0x0,
1420 { &hf_zbee_zdp_index,
1421 { "Index", "zbee.zdp.index", FT_UINT8, BASE_DEC, NULL, 0x0,
1424 { &hf_zbee_zdp_status,
1425 { "Status", "zbee.zdp.status", FT_UINT8, BASE_DEC, VALS(zbee_zdp_status_names), 0x0,
1428 { &hf_zbee_zdp_endpoint,
1429 { "Endpoint", "zbee.zdp.endpoint", FT_UINT8, BASE_DEC, NULL, 0x0,
1432 { &hf_zbee_zdp_ep_count,
1433 { "Endpoint Count", "zbee.zdp.ep_count", FT_UINT8, BASE_DEC, NULL, 0x0,
1436 { &hf_zbee_zdp_profile,
1437 { "Profile", "zbee.zdp.profile", FT_UINT16, BASE_HEX, NULL, 0x0,
1440 { &hf_zbee_zdp_addr_mode,
1441 { "Address Mode", "zbee.zdp.addr_mode", FT_UINT8, BASE_DEC, NULL, 0x0,
1444 { &hf_zbee_zdp_cluster,
1445 { "Cluster", "zbee.zdp.cluster", FT_UINT16, BASE_DEC, NULL, 0x0,
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 }},
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 }},
1456 { &hf_zbee_zdp_in_count,
1457 { "Input Cluster Count", "zbee.zdp.in_count", FT_UINT8, BASE_DEC, NULL, 0x0,
1460 { &hf_zbee_zdp_out_count,
1461 { "Output Cluster Count", "zbee.zdp.out_count", FT_UINT8, BASE_DEC, NULL, 0x0,
1464 { &hf_zbee_zdp_in_cluster,
1465 { "Input Cluster", "zbee.zdp.in_cluster", FT_UINT16, BASE_DEC, NULL, 0x0,
1468 { &hf_zbee_zdp_out_cluster,
1469 { "Output Cluster", "zbee.zdp.out_cluster", FT_UINT16, BASE_DEC, NULL, 0x0,
1472 { &hf_zbee_zdp_assoc_device_count,
1473 { "Associated Device Count", "zbee.zdp.assoc_device_count", FT_UINT8, BASE_DEC, NULL, 0x0,
1476 { &hf_zbee_zdp_assoc_device,
1477 { "Associated Device", "zbee.zdp.assoc_device", FT_UINT16, BASE_HEX, NULL, 0x0,
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 }},
1484 { &hf_zbee_zdp_cinfo_ffd,
1485 { "Full-Function Device", "zbee.zdp.cinfo.ffd", FT_BOOLEAN, 8, NULL, ZBEE_CINFO_FFD,
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 }},
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 }},
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 }},
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 }},
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,
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,
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,
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,
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,
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,
1528 { &hf_zbee_zdp_node_type,
1529 { "Type", "zbee.zdp.node.type", FT_UINT16, BASE_DEC, NULL, ZBEE_ZDP_NODE_TYPE,
1532 { &hf_zbee_zdp_node_complex,
1533 { "Complex Descriptor", "zbee.zdp.node.complex", FT_BOOLEAN, 16, NULL, ZBEE_ZDP_NODE_COMPLEX,
1536 { &hf_zbee_zdp_node_user,
1537 { "User Descriptor", "zbee.zdp.node.user", FT_BOOLEAN, 16, NULL, ZBEE_ZDP_NODE_USER,
1540 { &hf_zbee_zdp_node_freq_868,
1541 { "868MHz Band", "zbee.zdp.node.freq.868mhz", FT_BOOLEAN, 16, NULL, ZBEE_ZDP_NODE_FREQ_868MHZ,
1544 { &hf_zbee_zdp_node_freq_900,
1545 { "900MHz Band", "zbee.zdp.node.freq.900mhz", FT_BOOLEAN, 16, NULL, ZBEE_ZDP_NODE_FREQ_900MHZ,
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,
1552 { &hf_zbee_zdp_node_manufacturer,
1553 { "Manufacturer Code", "zbee.zdp.node.manufacturer", FT_UINT16, BASE_HEX, NULL, 0x0,
1556 { &hf_zbee_zdp_node_max_buffer,
1557 { "Max Buffer Size", "zbee.zdp.node.max_buffer", FT_UINT8, BASE_DEC, NULL, 0x0,
1560 { &hf_zbee_zdp_node_max_transfer,
1561 { "Max Transfer Size", "zbee.zdp.node.max_transfer", FT_UINT16, BASE_DEC, NULL, 0x0,
1564 { &hf_zbee_zdp_power_mode,
1565 { "Mode", "zbee.zdp.power.mode", FT_UINT16, BASE_DEC, NULL, ZBEE_ZDP_POWER_MODE,
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,
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,
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,
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,
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,
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,
1592 { &hf_zbee_zdp_power_level,
1593 { "Level", "zbee.zdp.power.level", FT_UINT16, BASE_DEC, NULL, ZBEE_ZDP_POWER_LEVEL,
1596 { &hf_zbee_zdp_simple_app_device,
1597 { "Application Device", "zbee.zdp.app.device", FT_UINT16, BASE_HEX, NULL, 0x0,
1600 { &hf_zbee_zdp_simple_app_version,
1601 { "Application Version", "zbee.zdp.app.version", FT_UINT16, BASE_HEX, NULL, 0x0,
1604 { &hf_zbee_zdp_complex_length,
1605 { "Complex Descriptor Length", "zbee.zdp.complex_length", FT_UINT8, BASE_DEC, NULL, 0x0,
1608 { &hf_zbee_zdp_complex,
1609 { "Complex Descriptor", "zbee.zdp.complex", FT_STRING, BASE_NONE, NULL, 0x0,
1612 { &hf_zbee_zdp_user,
1613 { "User Descriptor", "zbee.zdp.user", FT_STRING, BASE_NONE, NULL, 0x0,
1616 { &hf_zbee_zdp_user_length,
1617 { "User Descriptor Length", "zbee.zdp.user_length", FT_UINT8, BASE_DEC, NULL, 0x0,
1620 { &hf_zbee_zdp_simple_length,
1621 { "Simple Descriptor Length", "zbee.zdp.simple_length", FT_UINT8, BASE_DEC, NULL, 0x0,
1624 { &hf_zbee_zdp_disc_node_size,
1625 { "Node Descriptor Size", "zbee.zdp.node_size", FT_UINT8, BASE_DEC, NULL, 0x0,
1628 { &hf_zbee_zdp_disc_power_size,
1629 { "Power Descriptor Size", "zbee.zdp.power_size", FT_UINT8, BASE_DEC, NULL, 0x0,
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 }},
1636 { &hf_zbee_zdp_disc_ep_count,
1637 { "Active Endpoint Count", "zbee.zdp.ep_count", FT_UINT8, BASE_DEC, NULL, 0x0,
1640 { &hf_zbee_zdp_disc_simple_count,
1641 { "Simple Descriptor Count", "zbee.zdp.simple_count", FT_UINT8, BASE_DEC, NULL, 0x0,
1644 { &hf_zbee_zdp_disc_simple_size,
1645 { "Simple Descriptor Size", "zbee.zdp.simple_size", FT_UINT8, BASE_DEC, NULL, 0x0,
1648 { &hf_zbee_zdp_target,
1649 { "Target", "zbee.zdp.target", FT_UINT16, BASE_HEX, NULL, 0x0,
1652 { &hf_zbee_zdp_target64,
1653 { "Target", "zbee.zdp.target64", FT_UINT64, BASE_HEX, NULL, 0x0,
1656 { &hf_zbee_zdp_target_ep,
1657 { "Target Endpoint", "zbee.zdp.target_ep", FT_UINT8, BASE_DEC, NULL, 0x0,
1660 { &hf_zbee_zdp_replacement,
1661 { "Replacement", "zbee.zdp.replacement", FT_UINT64, BASE_HEX, NULL, 0x0,
1664 { &hf_zbee_zdp_replacement_ep,
1665 { "Replacement Endpoint", "zbee.zdp.replacement_ep", FT_UINT8, BASE_DEC, NULL, 0x0,
1668 { &hf_zbee_zdp_bind_src,
1669 { "Source", "zbee.zdp.bind.src", FT_UINT16, BASE_HEX, NULL, 0x0,
1672 { &hf_zbee_zdp_bind_src64,
1673 { "Source", "zbee.zdp.bind.src64", FT_UINT64, BASE_HEX, NULL, 0x0,
1676 { &hf_zbee_zdp_bind_src_ep,
1677 { "Source Endpoint", "zbee.zdp.bind.src_ep", FT_UINT8, BASE_DEC, NULL, 0x0,
1680 { &hf_zbee_zdp_bind_dst,
1681 { "Destination", "zbee.zdp.bind.dst", FT_UINT16, BASE_HEX, NULL, 0x0,
1684 { &hf_zbee_zdp_bind_dst64,
1685 { "Destination", "zbee.zdp.bind.dst64", FT_UINT64, BASE_HEX, NULL, 0x0,
1688 { &hf_zbee_zdp_bind_dst_ep,
1689 { "Destination Endpoint", "zbee.zdp.bind.dst_ep", FT_UINT8, BASE_DEC, NULL, 0x0,
1692 { &hf_zbee_zdp_duration,
1693 { "Duration", "zbee.zdp.duration", FT_UINT8, BASE_DEC, NULL, 0x0,
1696 { &hf_zbee_zdp_leave_children,
1697 { "Remove Children", "zbee.zdp.leave.children", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
1700 { &hf_zbee_zdp_leave_rejoin,
1701 { "Rejoin", "zbee.zdp.leave.rejoin", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
1704 { &hf_zbee_zdp_significance,
1705 { "Significance", "zbee.zdp.significance", FT_UINT8, BASE_DEC, NULL, 0x0,
1708 { &hf_zbee_zdp_scan_count,
1709 { "Scan Count", "zbee.zdp.scan_count", FT_UINT8, BASE_DEC, NULL, 0x0,
1712 { &hf_zbee_zdp_update_id,
1713 { "Update ID", "zbee.zdp.update_id", FT_UINT8, BASE_DEC, NULL, 0x0,
1716 { &hf_zbee_zdp_manager,
1717 { "Network Manager", "zbee.zdp.manager", FT_UINT16, BASE_HEX, NULL, 0x0,
1720 { &hf_zbee_zdp_tx_total,
1721 { "Total Transmissions", "zbee.zdp.tx_total", FT_UINT16, BASE_DEC, NULL, 0x0,
1724 { &hf_zbee_zdp_tx_fail,
1725 { "Failed Transmissions", "zbee.zdp.tx_fail", FT_UINT16, BASE_DEC, NULL, 0x0,
1728 { &hf_zbee_zdp_channel_count,
1729 { "Channel List Count", "zbee.zdp.channel_count", FT_UINT8, BASE_DEC, NULL, 0x0,
1734 static gint *ett[] = {
1736 &ett_zbee_zdp_endpoint,
1737 &ett_zbee_zdp_match_in,
1738 &ett_zbee_zdp_match_out,
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,
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,
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));
1766 /* Register the ZDP dissector. */
1767 register_dissector("zbee.zdp", dissect_zbee_zdp, proto_zbee_zdp);
1768 } /* proto_register_zbee_zdp */
1770 /*FUNCTION:------------------------------------------------------
1772 * proto_reg_handoff_zbee_zdp
1774 * Registers the Zigbee Device Profile dissector with Wireshark.
1779 *---------------------------------------------------------------
1781 void proto_reg_handoff_zbee_zdp(void)
1783 dissector_handle_t zdp_handle;
1785 /* Find the other dissectors we need. */
1786 data_handle = find_dissector("data");
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 */