MSWSP: add two more Property Sets
[wireshark-wip.git] / epan / dissectors / packet-zbee-aps.c
blob1d20756b86bf94f8208d280c9009fb441404fef3
1 /* packet-zbee-aps.c
2 * Dissector routines for the ZigBee Application Support Sub-layer (APS)
3 * By Owen Kirby <osk@exegin.com>
4 * Copyright 2009 Exegin Technologies Limited
6 * $Id$
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1998 Gerald Combs
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 /* Include Files */
28 #include "config.h"
30 #include <string.h>
31 #include <glib.h>
33 #include <epan/packet.h>
34 #include <epan/exceptions.h>
35 #include <epan/prefs.h> /* req'd for packet-zbee-security.h */
36 #include <epan/expert.h>
37 #include <epan/wmem/wmem.h>
38 #include <epan/reassemble.h>
40 #include "packet-zbee.h"
41 #include "packet-zbee-nwk.h"
42 #include "packet-zbee-security.h"
43 #include "packet-zbee-aps.h"
45 /*************************
46 * Function Declarations *
47 *************************
49 /* Dissector Routines */
50 static void dissect_zbee_aps_cmd (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint8 version);
52 /* Command Dissector Helpers */
53 static guint dissect_zbee_aps_skke_challenge (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset);
54 static guint dissect_zbee_aps_skke_data (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset);
55 static guint dissect_zbee_aps_transport_key (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset);
56 static guint dissect_zbee_aps_update_device (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset, guint8 version);
57 static guint dissect_zbee_aps_remove_device (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset);
58 static guint dissect_zbee_aps_request_key (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset);
59 static guint dissect_zbee_aps_switch_key (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset);
60 static guint dissect_zbee_aps_auth_challenge (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset);
61 static guint dissect_zbee_aps_auth_data (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset);
62 static guint dissect_zbee_aps_tunnel (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset);
64 /* Helper routine. */
65 static guint zbee_apf_transaction_len (tvbuff_t *tvb, guint offset, guint8 type);
67 static void proto_init_zbee_aps(void);
68 void proto_reg_handoff_zbee_aps(void);
69 void proto_register_zbee_aps(void);
71 /********************
72 * Global Variables *
73 ********************
75 /* Field indices. */
76 static int proto_zbee_aps = -1;
77 static int hf_zbee_aps_fcf_frame_type = -1;
78 static int hf_zbee_aps_fcf_delivery = -1;
79 static int hf_zbee_aps_fcf_indirect_mode = -1; /* ZigBee 2004 and earlier. */
80 static int hf_zbee_aps_fcf_ack_format = -1; /* ZigBee 2007 and later. */
81 static int hf_zbee_aps_fcf_security = -1;
82 static int hf_zbee_aps_fcf_ack_req = -1;
83 static int hf_zbee_aps_fcf_ext_header = -1;
84 static int hf_zbee_aps_dst = -1;
85 static int hf_zbee_aps_group = -1;
86 static int hf_zbee_aps_cluster = -1;
87 static int hf_zbee_aps_profile = -1;
88 static int hf_zbee_aps_src = -1;
89 static int hf_zbee_aps_counter = -1;
90 static int hf_zbee_aps_fragmentation = -1;
91 static int hf_zbee_aps_block_number = -1;
93 static int hf_zbee_aps_cmd_id = -1;
94 static int hf_zbee_aps_cmd_initiator = -1;
95 static int hf_zbee_aps_cmd_responder = -1;
96 static int hf_zbee_aps_cmd_partner = -1;
97 static int hf_zbee_aps_cmd_initiator_flag = -1;
98 static int hf_zbee_aps_cmd_device = -1;
99 static int hf_zbee_aps_cmd_challenge = -1;
100 static int hf_zbee_aps_cmd_mac = -1;
101 static int hf_zbee_aps_cmd_key = -1;
102 static int hf_zbee_aps_cmd_key_type = -1;
103 static int hf_zbee_aps_cmd_dst = -1;
104 static int hf_zbee_aps_cmd_src = -1;
105 static int hf_zbee_aps_cmd_seqno = -1;
106 static int hf_zbee_aps_cmd_short_addr = -1;
107 static int hf_zbee_aps_cmd_device_status = -1;
108 static int hf_zbee_aps_cmd_ea_key_type = -1;
109 static int hf_zbee_aps_cmd_ea_data = -1;
111 /* Field indices for ZigBee 2003 & earlier Application Framework. */
112 static int proto_zbee_apf = -1;
113 static int hf_zbee_apf_count = -1;
114 static int hf_zbee_apf_type = -1;
116 /* Subtree indices. */
117 static gint ett_zbee_aps = -1;
118 static gint ett_zbee_aps_fcf = -1;
119 static gint ett_zbee_aps_ext = -1;
120 static gint ett_zbee_aps_cmd = -1;
122 /* Fragmentation indices. */
123 static int hf_zbee_aps_fragments = -1;
124 static int hf_zbee_aps_fragment = -1;
125 static int hf_zbee_aps_fragment_overlap = -1;
126 static int hf_zbee_aps_fragment_overlap_conflicts = -1;
127 static int hf_zbee_aps_fragment_multiple_tails = -1;
128 static int hf_zbee_aps_fragment_too_long_fragment = -1;
129 static int hf_zbee_aps_fragment_error = -1;
130 static int hf_zbee_aps_fragment_count = -1;
131 static int hf_zbee_aps_reassembled_in = -1;
132 static int hf_zbee_aps_reassembled_length = -1;
133 static gint ett_zbee_aps_fragment = -1;
134 static gint ett_zbee_aps_fragments = -1;
136 /* Subtree indices for the ZigBee 2004 & earlier Application Framework. */
137 static gint ett_zbee_apf = -1;
139 static expert_field ei_zbee_aps_invalid_delivery_mode = EI_INIT;
140 static expert_field ei_zbee_aps_missing_payload = EI_INIT;
142 /* Dissector Handles. */
143 static dissector_handle_t zbee_aps_handle;
144 static dissector_handle_t zbee_apf_handle;
146 /* Subdissector Handles. */
147 static dissector_handle_t data_handle;
149 /* Dissector List. */
150 static dissector_table_t zbee_aps_dissector_table;
152 /* Reassembly table. */
153 static reassembly_table zbee_aps_reassembly_table;
155 static const fragment_items zbee_aps_frag_items = {
156 /* Fragment subtrees */
157 &ett_zbee_aps_fragment,
158 &ett_zbee_aps_fragments,
159 /* Fragment fields */
160 &hf_zbee_aps_fragments,
161 &hf_zbee_aps_fragment,
162 &hf_zbee_aps_fragment_overlap,
163 &hf_zbee_aps_fragment_overlap_conflicts,
164 &hf_zbee_aps_fragment_multiple_tails,
165 &hf_zbee_aps_fragment_too_long_fragment,
166 &hf_zbee_aps_fragment_error,
167 &hf_zbee_aps_fragment_count,
168 /* Reassembled in field */
169 &hf_zbee_aps_reassembled_in,
170 /* Reassembled length field */
171 &hf_zbee_aps_reassembled_length,
172 /* Reassembled data field */
173 NULL,
174 /* Tag */
175 "APS Message fragments"
178 /********************/
179 /* Field Names */
180 /********************/
181 /* Frame Type Names */
182 static const value_string zbee_aps_frame_types[] = {
183 { ZBEE_APS_FCF_DATA, "Data" },
184 { ZBEE_APS_FCF_CMD, "Command" },
185 { ZBEE_APS_FCF_ACK, "Ack" },
186 { 0, NULL }
189 /* Delivery Mode Names */
190 static const value_string zbee_aps_delivery_modes[] = {
191 { ZBEE_APS_FCF_UNICAST, "Unicast" },
192 { ZBEE_APS_FCF_INDIRECT, "Indirect" },
193 { ZBEE_APS_FCF_BCAST, "Broadcast" },
194 { ZBEE_APS_FCF_GROUP, "Group" },
195 { 0, NULL }
198 /* Fragmentation Mode Names */
199 static const value_string zbee_aps_fragmentation_modes[] = {
200 { ZBEE_APS_EXT_FCF_FRAGMENT_NONE, "None" },
201 { ZBEE_APS_EXT_FCF_FRAGMENT_FIRST, "First Block" },
202 { ZBEE_APS_EXT_FCF_FRAGMENT_MIDDLE, "Middle Block" },
203 { 0, NULL }
206 /* APS Command Names */
207 static const value_string zbee_aps_cmd_names[] = {
208 { ZBEE_APS_CMD_SKKE1, "SKKE-1" },
209 { ZBEE_APS_CMD_SKKE2, "SKKE-2" },
210 { ZBEE_APS_CMD_SKKE3, "SKKE-3" },
211 { ZBEE_APS_CMD_SKKE4, "SKKE-4" },
212 { ZBEE_APS_CMD_TRANSPORT_KEY, "Transport Key" },
213 { ZBEE_APS_CMD_UPDATE_DEVICE, "Update Device" },
214 { ZBEE_APS_CMD_REMOVE_DEVICE, "Remove Device" },
215 { ZBEE_APS_CMD_REQUEST_KEY, "Request Key" },
216 { ZBEE_APS_CMD_SWITCH_KEY, "Switch Key" },
217 { ZBEE_APS_CMD_EA_INIT_CHLNG, "EA Initiator Challenge" },
218 { ZBEE_APS_CMD_EA_RESP_CHLNG, "EA Responder Challenge" },
219 { ZBEE_APS_CMD_EA_INIT_MAC_DATA,"EA Initiator MAC" },
220 { ZBEE_APS_CMD_EA_RESP_MAC_DATA,"EA Responder MAC" },
221 { ZBEE_APS_CMD_TUNNEL, "Tunnel" },
222 { 0, NULL }
225 /* APS Key Names */
226 static const value_string zbee_aps_key_names[] = {
227 { ZBEE_APS_CMD_KEY_TC_MASTER, "Trust Center Master Key" },
228 { ZBEE_APS_CMD_KEY_STANDARD_NWK, "Standard Network Key" },
229 { ZBEE_APS_CMD_KEY_APP_MASTER, "Application Master Key" },
230 { ZBEE_APS_CMD_KEY_APP_LINK, "Application Link Key" },
231 { ZBEE_APS_CMD_KEY_TC_LINK, "Trust Center Link Key" },
232 { ZBEE_APS_CMD_KEY_HIGH_SEC_NWK, "High-Security Network Key" },
233 { 0, NULL }
236 /* APS Key Names (Entity-Authentication). */
237 static const value_string zbee_aps_ea_key_names[] = {
238 { ZBEE_APS_CMD_EA_KEY_NWK, "Network Key" },
239 { ZBEE_APS_CMD_EA_KEY_LINK, "Link Key" },
240 { 0, NULL }
243 /* Update Device Status Names */
244 static const value_string zbee_aps_update_status_names[] = {
245 { ZBEE_APS_CMD_UPDATE_STANDARD_SEC_REJOIN, "Standard security, secured rejoin" },
246 { ZBEE_APS_CMD_UPDATE_STANDARD_UNSEC_JOIN, "Standard security, unsecured join" },
247 { ZBEE_APS_CMD_UPDATE_LEAVE, "Device left" },
248 { ZBEE_APS_CMD_UPDATE_STANDARD_UNSEC_REJOIN,"Standard security, unsecured rejoin" },
249 { ZBEE_APS_CMD_UPDATE_HIGH_SEC_REJOIN, "High security, secured rejoin" },
250 { ZBEE_APS_CMD_UPDATE_HIGH_UNSEC_JOIN, "High security, unsecured join" },
251 { ZBEE_APS_CMD_UPDATE_HIGH_UNSEC_REJOIN, "High security, unsecured rejoin" },
252 { 0, NULL }
255 /* Outdated ZigBee 2004 Value Strings. */
256 static const value_string zbee_apf_type_names[] = {
257 { ZBEE_APP_TYPE_KVP, "Key-Value Pair" },
258 { ZBEE_APP_TYPE_MSG, "Message" },
259 { 0, NULL }
262 #if 0
263 static const value_string zbee_apf_kvp_command_names[] = {
264 { ZBEE_APP_KVP_SET, "Set" },
265 { ZBEE_APP_KVP_EVENT, "Event" },
266 { ZBEE_APP_KVP_GET_ACK, "Get Acknowledgement" },
267 { ZBEE_APP_KVP_SET_ACK, "Set Acknowledgement" },
268 { ZBEE_APP_KVP_EVENT_ACK, "Event Acknowledgement" },
269 { ZBEE_APP_KVP_GET_RESP, "Get Response" },
270 { ZBEE_APP_KVP_SET_RESP, "Set Response" },
271 { ZBEE_APP_KVP_EVENT_RESP, "Event Response" },
272 { 0, NULL }
274 #endif
276 #if 0
277 static const value_string zbee_apf_kvp_type_names[] = {
278 { ZBEE_APP_KVP_NO_DATA, "No Data" },
279 { ZBEE_APP_KVP_UINT8, "8-bit Unsigned Integer" },
280 { ZBEE_APP_KVP_INT8, "8-bit Signed Integer" },
281 { ZBEE_APP_KVP_UINT16, "16-bit Unsigned Integer" },
282 { ZBEE_APP_KVP_INT16, "16-bit Signed Integer" },
283 { ZBEE_APP_KVP_FLOAT16, "16-bit Floating Point" },
284 { ZBEE_APP_KVP_ABS_TIME, "Absolute Time" },
285 { ZBEE_APP_KVP_REL_TIME, "Relative Time" },
286 { ZBEE_APP_KVP_CHAR_STRING, "Character String" },
287 { ZBEE_APP_KVP_OCT_STRING, "Octet String" },
288 { 0, NULL }
290 #endif
292 /* ZigBee Application Profile ID Names */
293 const range_string zbee_aps_apid_names[] = {
294 { ZBEE_DEVICE_PROFILE, ZBEE_DEVICE_PROFILE, "ZigBee Device Profile" },
296 { ZBEE_PROFILE_IPM, ZBEE_PROFILE_IPM, "Industrial Plant Monitoring" },
298 { ZBEE_PROFILE_T1, ZBEE_PROFILE_T1, "Test Profile #1" },
299 { ZBEE_PROFILE_HA, ZBEE_PROFILE_HA, "Home Automation" },
300 { ZBEE_PROFILE_CBA, ZBEE_PROFILE_CBA, "Commercial Building Automation" },
301 { ZBEE_PROFILE_WSN, ZBEE_PROFILE_WSN, "Wireless Sensor Network" },
302 { ZBEE_PROFILE_TA, ZBEE_PROFILE_TA, "Telecom Automation" },
303 { ZBEE_PROFILE_HC, ZBEE_PROFILE_HC, "Health Care" },
304 { ZBEE_PROFILE_SE, ZBEE_PROFILE_SE, "Smart Energy" },
305 { ZBEE_PROFILE_STD_MIN, ZBEE_PROFILE_STD_MAX, "Unknown ZigBee Standard" },
307 { ZBEE_PROFILE_T2, ZBEE_PROFILE_T2, "Test Profile #2" },
308 { ZBEE_PROFILE_RSVD0_MIN, ZBEE_PROFILE_RSVD0_MAX, "Unknown ZigBee Reserved" },
309 { ZBEE_PROFILE_RSVD1_MIN, ZBEE_PROFILE_RSVD1_MAX, "Unknown ZigBee Reserved" },
311 { ZBEE_PROFILE_IEEE_1451_5, ZBEE_PROFILE_IEEE_1451_5, "IEEE_1451_5" },
313 { ZBEE_PROFILE_MFR_SPEC_ORG_MIN, ZBEE_PROFILE_MFR_SPEC_ORG_MAX,
314 "Unallocated Manufacturer-Specific" },
316 { ZBEE_PROFILE_IEEE_1451_5, ZBEE_PROFILE_IEEE_1451_5, "IEEE_1451_5" },
318 /* Manufacturer Allocations */
319 { ZBEE_PROFILE_CIRRONET_0_MIN, ZBEE_PROFILE_CIRRONET_0_MAX, ZBEE_MFG_CIRRONET },
320 { ZBEE_PROFILE_CHIPCON_MIN, ZBEE_PROFILE_CHIPCON_MAX, ZBEE_MFG_CHIPCON },
321 { ZBEE_PROFILE_EMBER_MIN, ZBEE_PROFILE_EMBER_MAX, ZBEE_MFG_EMBER },
322 { ZBEE_PROFILE_NTS_MIN, ZBEE_PROFILE_NTS_MAX, ZBEE_MFG_CHIPCON },
323 { ZBEE_PROFILE_FREESCALE_MIN, ZBEE_PROFILE_FREESCALE_MAX, ZBEE_MFG_FREESCALE },
324 { ZBEE_PROFILE_IPCOM_MIN, ZBEE_PROFILE_IPCOM_MAX, ZBEE_MFG_IPCOM },
325 { ZBEE_PROFILE_SAN_JUAN_MIN, ZBEE_PROFILE_SAN_JUAN_MAX, ZBEE_MFG_SAN_JUAN },
326 { ZBEE_PROFILE_TUV_MIN, ZBEE_PROFILE_TUV_MAX, ZBEE_MFG_TUV },
327 { ZBEE_PROFILE_COMPXS_MIN, ZBEE_PROFILE_COMPXS_MAX, ZBEE_MFG_COMPXS },
328 { ZBEE_PROFILE_BM_MIN, ZBEE_PROFILE_BM_MAX, ZBEE_MFG_BM },
329 { ZBEE_PROFILE_AWAREPOINT_MIN, ZBEE_PROFILE_AWAREPOINT_MAX, ZBEE_MFG_AWAREPOINT },
330 { ZBEE_PROFILE_SAN_JUAN_1_MIN, ZBEE_PROFILE_SAN_JUAN_1_MAX, ZBEE_MFG_SAN_JUAN },
331 { ZBEE_PROFILE_PHILIPS_MIN, ZBEE_PROFILE_PHILIPS_MAX, ZBEE_MFG_PHILIPS },
332 { ZBEE_PROFILE_LUXOFT_MIN, ZBEE_PROFILE_LUXOFT_MAX, ZBEE_MFG_LUXOFT },
333 { ZBEE_PROFILE_KORWIN_MIN, ZBEE_PROFILE_KORWIN_MAX, ZBEE_MFG_KORWIN },
334 { ZBEE_PROFILE_1_RF_MIN, ZBEE_PROFILE_1_RF_MAX, ZBEE_MFG_1_RF },
335 { ZBEE_PROFILE_STG_MIN, ZBEE_PROFILE_STG_MAX, ZBEE_MFG_STG },
336 { ZBEE_PROFILE_TELEGESIS_MIN, ZBEE_PROFILE_TELEGESIS_MAX, ZBEE_MFG_TELEGESIS },
337 { ZBEE_PROFILE_CIRRONET_1_MIN, ZBEE_PROFILE_CIRRONET_1_MAX, ZBEE_MFG_CIRRONET },
338 { ZBEE_PROFILE_VISIONIC_MIN, ZBEE_PROFILE_VISIONIC_MAX, ZBEE_MFG_VISIONIC },
339 { ZBEE_PROFILE_INSTA_MIN, ZBEE_PROFILE_INSTA_MAX, ZBEE_MFG_INSTA },
340 { ZBEE_PROFILE_ATALUM_MIN, ZBEE_PROFILE_ATALUM_MAX, ZBEE_MFG_ATALUM },
341 { ZBEE_PROFILE_ATMEL_MIN, ZBEE_PROFILE_ATMEL_MAX, ZBEE_MFG_ATMEL },
342 { ZBEE_PROFILE_DEVELCO_MIN, ZBEE_PROFILE_DEVELCO_MAX, ZBEE_MFG_DEVELCO },
343 { ZBEE_PROFILE_HONEYWELL_MIN, ZBEE_PROFILE_HONEYWELL_MAX, ZBEE_MFG_HONEYWELL },
344 { ZBEE_PROFILE_NEC_MIN, ZBEE_PROFILE_NEC_MAX, ZBEE_MFG_NEC },
345 { ZBEE_PROFILE_YAMATAKE_MIN, ZBEE_PROFILE_YAMATAKE_MAX, ZBEE_MFG_YAMATAKE },
346 { ZBEE_PROFILE_TENDRIL_MIN, ZBEE_PROFILE_TENDRIL_MAX, ZBEE_MFG_TENDRIL },
347 { ZBEE_PROFILE_ASSA_MIN, ZBEE_PROFILE_ASSA_MAX, ZBEE_MFG_ASSA },
348 { ZBEE_PROFILE_MAXSTREAM_MIN, ZBEE_PROFILE_MAXSTREAM_MAX, ZBEE_MFG_MAXSTREAM },
349 { ZBEE_PROFILE_XANADU_MIN, ZBEE_PROFILE_XANADU_MAX, ZBEE_MFG_XANADU },
350 { ZBEE_PROFILE_NEUROCOM_MIN, ZBEE_PROFILE_NEUROCOM_MAX, ZBEE_MFG_NEUROCOM },
351 { ZBEE_PROFILE_III_MIN, ZBEE_PROFILE_III_MAX, ZBEE_MFG_III },
352 { ZBEE_PROFILE_VANTAGE_MIN, ZBEE_PROFILE_VANTAGE_MAX, ZBEE_MFG_VANTAGE },
353 { ZBEE_PROFILE_ICONTROL_MIN, ZBEE_PROFILE_ICONTROL_MAX, ZBEE_MFG_ICONTROL },
354 { ZBEE_PROFILE_RAYMARINE_MIN, ZBEE_PROFILE_RAYMARINE_MAX, ZBEE_MFG_RAYMARINE },
355 { ZBEE_PROFILE_RENESAS_MIN, ZBEE_PROFILE_RENESAS_MAX, ZBEE_MFG_RENESAS },
356 { ZBEE_PROFILE_LSR_MIN, ZBEE_PROFILE_LSR_MAX, ZBEE_MFG_LSR },
357 { ZBEE_PROFILE_ONITY_MIN, ZBEE_PROFILE_ONITY_MAX, ZBEE_MFG_ONITY },
358 { ZBEE_PROFILE_MONO_MIN, ZBEE_PROFILE_MONO_MAX, ZBEE_MFG_MONO },
359 { ZBEE_PROFILE_RFT_MIN, ZBEE_PROFILE_RFT_MAX, ZBEE_MFG_RFT },
360 { ZBEE_PROFILE_ITRON_MIN, ZBEE_PROFILE_ITRON_MAX, ZBEE_MFG_ITRON },
361 { ZBEE_PROFILE_TRITECH_MIN, ZBEE_PROFILE_TRITECH_MAX, ZBEE_MFG_TRITECH },
362 { ZBEE_PROFILE_EMBEDIT_MIN, ZBEE_PROFILE_EMBEDIT_MAX, ZBEE_MFG_EMBEDIT },
363 { ZBEE_PROFILE_S3C_MIN, ZBEE_PROFILE_S3C_MAX, ZBEE_MFG_S3C },
364 { ZBEE_PROFILE_SIEMENS_MIN, ZBEE_PROFILE_SIEMENS_MAX, ZBEE_MFG_SIEMENS },
365 { ZBEE_PROFILE_MINDTECH_MIN, ZBEE_PROFILE_MINDTECH_MAX, ZBEE_MFG_MINDTECH },
366 { ZBEE_PROFILE_LGE_MIN, ZBEE_PROFILE_LGE_MAX, ZBEE_MFG_LGE },
367 { ZBEE_PROFILE_MITSUBISHI_MIN, ZBEE_PROFILE_MITSUBISHI_MAX, ZBEE_MFG_MITSUBISHI },
368 { ZBEE_PROFILE_JOHNSON_MIN, ZBEE_PROFILE_JOHNSON_MAX, ZBEE_MFG_JOHNSON },
369 { ZBEE_PROFILE_PRI_MIN, ZBEE_PROFILE_PRI_MAX, ZBEE_MFG_PRI },
370 { ZBEE_PROFILE_KNICK_MIN, ZBEE_PROFILE_KNICK_MAX, ZBEE_MFG_KNICK },
371 { ZBEE_PROFILE_VICONICS_MIN, ZBEE_PROFILE_VICONICS_MAX, ZBEE_MFG_VICONICS },
372 { ZBEE_PROFILE_FLEXIPANEL_MIN, ZBEE_PROFILE_FLEXIPANEL_MAX, ZBEE_MFG_FLEXIPANEL },
373 { ZBEE_PROFILE_TRANE_MIN, ZBEE_PROFILE_TRANE_MAX, ZBEE_MFG_TRANE },
374 { ZBEE_PROFILE_JENNIC_MIN, ZBEE_PROFILE_JENNIC_MAX, ZBEE_MFG_JENNIC },
375 { ZBEE_PROFILE_LIG_MIN, ZBEE_PROFILE_LIG_MAX, ZBEE_MFG_LIG },
376 { ZBEE_PROFILE_ALERTME_MIN, ZBEE_PROFILE_ALERTME_MAX, ZBEE_MFG_ALERTME },
377 { ZBEE_PROFILE_DAINTREE_MIN, ZBEE_PROFILE_DAINTREE_MAX, ZBEE_MFG_DAINTREE },
378 { ZBEE_PROFILE_AIJI_MIN, ZBEE_PROFILE_AIJI_MAX, ZBEE_MFG_AIJI },
379 { ZBEE_PROFILE_TEL_ITALIA_MIN, ZBEE_PROFILE_TEL_ITALIA_MAX, ZBEE_MFG_TEL_ITALIA },
380 { ZBEE_PROFILE_MIKROKRETS_MIN, ZBEE_PROFILE_MIKROKRETS_MAX, ZBEE_MFG_MIKROKRETS },
381 { ZBEE_PROFILE_OKI_MIN, ZBEE_PROFILE_OKI_MAX, ZBEE_MFG_OKI },
382 { ZBEE_PROFILE_NEWPORT_MIN, ZBEE_PROFILE_NEWPORT_MAX, ZBEE_MFG_NEWPORT },
384 { ZBEE_PROFILE_C4_CL, ZBEE_PROFILE_C4_CL, ZBEE_MFG_C4 " Cluster Library"},
385 { ZBEE_PROFILE_C4_MIN, ZBEE_PROFILE_C4_MAX, ZBEE_MFG_C4 },
387 { ZBEE_PROFILE_STM_MIN, ZBEE_PROFILE_STM_MAX, ZBEE_MFG_STM },
388 { ZBEE_PROFILE_ASN_0_MIN, ZBEE_PROFILE_ASN_0_MAX, ZBEE_MFG_ASN },
389 { ZBEE_PROFILE_DCSI_MIN, ZBEE_PROFILE_DCSI_MAX, ZBEE_MFG_DCSI },
390 { ZBEE_PROFILE_FRANCE_TEL_MIN, ZBEE_PROFILE_FRANCE_TEL_MAX, ZBEE_MFG_FRANCE_TEL },
391 { ZBEE_PROFILE_MUNET_MIN, ZBEE_PROFILE_MUNET_MAX, ZBEE_MFG_MUNET },
392 { ZBEE_PROFILE_AUTANI_MIN, ZBEE_PROFILE_AUTANI_MAX, ZBEE_MFG_AUTANI },
393 { ZBEE_PROFILE_COL_VNET_MIN, ZBEE_PROFILE_COL_VNET_MAX, ZBEE_MFG_COL_VNET },
394 { ZBEE_PROFILE_AEROCOMM_MIN, ZBEE_PROFILE_AEROCOMM_MAX, ZBEE_MFG_AEROCOMM },
395 { ZBEE_PROFILE_SI_LABS_MIN, ZBEE_PROFILE_SI_LABS_MAX, ZBEE_MFG_SI_LABS },
396 { ZBEE_PROFILE_INNCOM_MIN, ZBEE_PROFILE_INNCOM_MAX, ZBEE_MFG_INNCOM },
397 { ZBEE_PROFILE_CANNON_MIN, ZBEE_PROFILE_CANNON_MAX, ZBEE_MFG_CANNON },
398 { ZBEE_PROFILE_SYNAPSE_MIN, ZBEE_PROFILE_SYNAPSE_MAX, ZBEE_MFG_SYNAPSE },
399 { ZBEE_PROFILE_FPS_MIN, ZBEE_PROFILE_FPS_MAX, ZBEE_MFG_FPS },
400 { ZBEE_PROFILE_CLS_MIN, ZBEE_PROFILE_CLS_MAX, ZBEE_MFG_CLS },
401 { ZBEE_PROFILE_CRANE_MIN, ZBEE_PROFILE_CRANE_MAX, ZBEE_MFG_CRANE },
402 { ZBEE_PROFILE_ASN_1_MIN, ZBEE_PROFILE_ASN_1_MAX, ZBEE_MFG_ASN },
403 { ZBEE_PROFILE_MOBILARM_MIN, ZBEE_PROFILE_MOBILARM_MAX, ZBEE_MFG_MOBILARM },
404 { ZBEE_PROFILE_IMONITOR_MIN, ZBEE_PROFILE_IMONITOR_MAX, ZBEE_MFG_IMONITOR },
405 { ZBEE_PROFILE_BARTECH_MIN, ZBEE_PROFILE_BARTECH_MAX, ZBEE_MFG_BARTECH },
406 { ZBEE_PROFILE_MESHNETICS_MIN, ZBEE_PROFILE_MESHNETICS_MAX, ZBEE_MFG_MESHNETICS },
407 { ZBEE_PROFILE_LS_IND_MIN, ZBEE_PROFILE_LS_IND_MAX, ZBEE_MFG_LS_IND },
408 { ZBEE_PROFILE_CASON_MIN, ZBEE_PROFILE_CASON_MAX, ZBEE_MFG_CASON },
409 { ZBEE_PROFILE_WLESS_GLUE_MIN, ZBEE_PROFILE_WLESS_GLUE_MAX, ZBEE_MFG_WLESS_GLUE },
410 { ZBEE_PROFILE_ELSTER_MIN, ZBEE_PROFILE_ELSTER_MAX, ZBEE_MFG_ELSTER },
411 { ZBEE_PROFILE_ONSET_MIN, ZBEE_PROFILE_ONSET_MAX, ZBEE_MFG_ONSET },
412 { ZBEE_PROFILE_RIGA_MIN, ZBEE_PROFILE_RIGA_MAX, ZBEE_MFG_RIGA },
413 { ZBEE_PROFILE_ENERGATE_MIN, ZBEE_PROFILE_ENERGATE_MAX, ZBEE_MFG_ENERGATE },
414 { ZBEE_PROFILE_VANTAGE_1_MIN, ZBEE_PROFILE_VANTAGE_1_MAX, ZBEE_MFG_VANTAGE },
415 { ZBEE_PROFILE_CONMED_MIN, ZBEE_PROFILE_CONMED_MAX, ZBEE_MFG_CONMED },
416 { ZBEE_PROFILE_SMS_TEC_MIN, ZBEE_PROFILE_SMS_TEC_MAX, ZBEE_MFG_SMS_TEC },
417 { ZBEE_PROFILE_POWERMAND_MIN, ZBEE_PROFILE_POWERMAND_MAX, ZBEE_MFG_POWERMAND },
418 { ZBEE_PROFILE_SCHNEIDER_MIN, ZBEE_PROFILE_SCHNEIDER_MAX, ZBEE_MFG_SCHNEIDER },
419 { ZBEE_PROFILE_EATON_MIN, ZBEE_PROFILE_EATON_MAX, ZBEE_MFG_EATON },
420 { ZBEE_PROFILE_TELULAR_MIN, ZBEE_PROFILE_TELULAR_MAX, ZBEE_MFG_TELULAR },
421 { ZBEE_PROFILE_DELPHI_MIN, ZBEE_PROFILE_DELPHI_MAX, ZBEE_MFG_DELPHI },
422 { ZBEE_PROFILE_EPISENSOR_MIN, ZBEE_PROFILE_EPISENSOR_MAX, ZBEE_MFG_EPISENSOR },
423 { ZBEE_PROFILE_LANDIS_GYR_MIN, ZBEE_PROFILE_LANDIS_GYR_MAX, ZBEE_MFG_LANDIS_GYR },
424 { ZBEE_PROFILE_SHURE_MIN, ZBEE_PROFILE_SHURE_MAX, ZBEE_MFG_SHURE },
425 { ZBEE_PROFILE_COMVERGE_MIN, ZBEE_PROFILE_COMVERGE_MAX, ZBEE_MFG_COMVERGE },
426 { ZBEE_PROFILE_KABA_MIN, ZBEE_PROFILE_KABA_MAX, ZBEE_MFG_KABA },
427 { ZBEE_PROFILE_HIDALGO_MIN, ZBEE_PROFILE_HIDALGO_MAX, ZBEE_MFG_HIDALGO },
428 { ZBEE_PROFILE_AIR2APP_MIN, ZBEE_PROFILE_AIR2APP_MAX, ZBEE_MFG_AIR2APP },
429 { ZBEE_PROFILE_AMX_MIN, ZBEE_PROFILE_AMX_MAX, ZBEE_MFG_AMX },
430 { ZBEE_PROFILE_EDMI_MIN, ZBEE_PROFILE_EDMI_MAX, ZBEE_MFG_EDMI },
431 { ZBEE_PROFILE_CYAN_MIN, ZBEE_PROFILE_CYAN_MAX, ZBEE_MFG_CYAN },
432 { ZBEE_PROFILE_SYS_SPA_MIN, ZBEE_PROFILE_SYS_SPA_MAX, ZBEE_MFG_SYS_SPA },
433 { ZBEE_PROFILE_TELIT_MIN, ZBEE_PROFILE_TELIT_MAX, ZBEE_MFG_TELIT },
434 { ZBEE_PROFILE_KAGA_MIN, ZBEE_PROFILE_KAGA_MAX, ZBEE_MFG_KAGA },
435 { ZBEE_PROFILE_4_NOKS_MIN, ZBEE_PROFILE_4_NOKS_MAX, ZBEE_MFG_4_NOKS },
436 { ZBEE_PROFILE_PROFILE_SYS_MIN, ZBEE_PROFILE_PROFILE_SYS_MAX, ZBEE_MFG_PROFILE_SYS },
437 { ZBEE_PROFILE_FREESTYLE_MIN, ZBEE_PROFILE_FREESTYLE_MAX, ZBEE_MFG_FREESTYLE },
438 { ZBEE_PROFILE_REMOTE_MIN, ZBEE_PROFILE_REMOTE_MAX, ZBEE_MFG_REMOTE },
439 { ZBEE_PROFILE_WAVECOM_MIN, ZBEE_PROFILE_WAVECOM_MAX, ZBEE_MFG_WAVECOM },
440 { ZBEE_PROFILE_ENERGY_OPT_MIN, ZBEE_PROFILE_ENERGY_OPT_MAX, ZBEE_MFG_ENERGY_OPT },
441 { ZBEE_PROFILE_GE_MIN, ZBEE_PROFILE_GE_MAX, ZBEE_MFG_GE },
442 { ZBEE_PROFILE_MESHWORKS_MIN, ZBEE_PROFILE_MESHWORKS_MAX, ZBEE_MFG_MESHWORKS },
443 { ZBEE_PROFILE_ELLIPS_MIN, ZBEE_PROFILE_ELLIPS_MAX, ZBEE_MFG_ELLIPS },
444 { ZBEE_PROFILE_CEDO_MIN, ZBEE_PROFILE_CEDO_MAX, ZBEE_MFG_CEDO },
445 { ZBEE_PROFILE_A_D_MIN, ZBEE_PROFILE_A_D_MAX, ZBEE_MFG_A_D },
446 { ZBEE_PROFILE_CARRIER_MIN, ZBEE_PROFILE_CARRIER_MAX, ZBEE_MFG_CARRIER },
447 { ZBEE_PROFILE_PASSIVESYS_MIN, ZBEE_PROFILE_PASSIVESYS_MAX, ZBEE_MFG_PASSIVESYS },
448 { ZBEE_PROFILE_HOME_AUTO_MIN, ZBEE_PROFILE_HOME_AUTO_MAX, ZBEE_MFG_HOME_AUTO },
449 { ZBEE_PROFILE_SUNRISE_MIN, ZBEE_PROFILE_SUNRISE_MAX, ZBEE_MFG_SUNRISE },
450 { ZBEE_PROFILE_MEMTEC_MIN, ZBEE_PROFILE_MEMTEC_MAX, ZBEE_MFG_MEMTEC },
451 { ZBEE_PROFILE_BRITISH_GAS_MIN, ZBEE_PROFILE_BRITISH_GAS_MAX, ZBEE_MFG_BRITISH_GAS },
452 { ZBEE_PROFILE_SENTEC_MIN, ZBEE_PROFILE_SENTEC_MAX, ZBEE_MFG_SENTEC },
453 { ZBEE_PROFILE_NAVETAS_MIN, ZBEE_PROFILE_NAVETAS_MAX, ZBEE_MFG_NAVETAS },
454 { ZBEE_PROFILE_ENERNOC_MIN, ZBEE_PROFILE_ENERNOC_MAX, ZBEE_MFG_ENERNOC },
455 { ZBEE_PROFILE_ELTAV_MIN, ZBEE_PROFILE_ELTAV_MAX, ZBEE_MFG_ELTAV },
456 { ZBEE_PROFILE_XSTREAMHD_MIN, ZBEE_PROFILE_XSTREAMHD_MAX, ZBEE_MFG_XSTREAMHD },
457 { ZBEE_PROFILE_GREEN_MIN, ZBEE_PROFILE_GREEN_MAX, ZBEE_MFG_GREEN },
458 { ZBEE_PROFILE_OMRON_MIN, ZBEE_PROFILE_OMRON_MAX, ZBEE_MFG_OMRON },
459 { ZBEE_PROFILE_NEC_TOKIN_MIN, ZBEE_PROFILE_NEC_TOKIN_MAX, ZBEE_MFG_NEC_TOKIN },
460 { ZBEE_PROFILE_PEEL_MIN, ZBEE_PROFILE_PEEL_MAX, ZBEE_MFG_PEEL },
461 { ZBEE_PROFILE_ELECTROLUX_MIN, ZBEE_PROFILE_ELECTROLUX_MAX, ZBEE_MFG_ELECTROLUX },
462 { ZBEE_PROFILE_SAMSUNG_MIN, ZBEE_PROFILE_SAMSUNG_MAX, ZBEE_MFG_SAMSUNG },
463 { ZBEE_PROFILE_MAINSTREAM_MIN, ZBEE_PROFILE_MAINSTREAM_MAX, ZBEE_MFG_MAINSTREAM },
465 { 0, 0, NULL }
468 /* ZigBee Application Profile ID Abbreviations */
469 const range_string zbee_aps_apid_abbrs[] = {
470 { ZBEE_DEVICE_PROFILE, ZBEE_DEVICE_PROFILE, "ZDP" },
471 { ZBEE_PROFILE_IPM, ZBEE_PROFILE_IPM, "IPM" },
472 { ZBEE_PROFILE_T1, ZBEE_PROFILE_T1, "T1" },
473 { ZBEE_PROFILE_HA, ZBEE_PROFILE_HA, "HA" },
474 { ZBEE_PROFILE_CBA, ZBEE_PROFILE_CBA, "CBA" },
475 { ZBEE_PROFILE_WSN, ZBEE_PROFILE_WSN, "WSN" },
476 { ZBEE_PROFILE_TA, ZBEE_PROFILE_TA, "TA" },
477 { ZBEE_PROFILE_HC, ZBEE_PROFILE_HC, "HC" },
478 { ZBEE_PROFILE_SE, ZBEE_PROFILE_SE, "SE" },
479 { ZBEE_PROFILE_T2, ZBEE_PROFILE_T2, "T2" },
481 /* Manufacturer Allocations */
482 { ZBEE_PROFILE_C4_MIN, ZBEE_PROFILE_C4_MAX, "C4" },
484 { 0, 0, NULL }
487 /* ZCL Cluster Names */
488 /* BUGBUG: big enough to hash? */
489 const value_string zbee_aps_cid_names[] = {
491 /* General */
492 { ZBEE_ZCL_CID_BASIC, "Basic"},
493 { ZBEE_ZCL_CID_POWER_CONFIG, "Power Configuration"},
494 { ZBEE_ZCL_CID_DEVICE_TEMP_CONFIG, "Device Temperature Configuration"},
495 { ZBEE_ZCL_CID_IDENTIFY, "Identify"},
496 { ZBEE_ZCL_CID_GROUPS, "Groups"},
497 { ZBEE_ZCL_CID_SCENES, "Scenes"},
498 { ZBEE_ZCL_CID_ON_OFF, "On/Off"},
499 { ZBEE_ZCL_CID_ON_OFF_SWITCH_CONFIG, "On/Off Switch Configuration"},
500 { ZBEE_ZCL_CID_LEVEL_CONTROL, "Level Control"},
501 { ZBEE_ZCL_CID_ALARMS, "Alarms"},
502 { ZBEE_ZCL_CID_TIME, "Time"},
503 { ZBEE_ZCL_CID_RSSI_LOCATION, "RSSI Location"},
504 { ZBEE_ZCL_CID_ANALOG_INPUT_BASIC, "Analog Input (Basic)"},
505 { ZBEE_ZCL_CID_ANALOG_OUTPUT_BASIC, "Analog Output (Basic)"},
506 { ZBEE_ZCL_CID_ANALOG_VALUE_BASIC, "Analog Value (Basic)"},
507 { ZBEE_ZCL_CID_BINARY_INPUT_BASIC, "Binary Input (Basic)"},
508 { ZBEE_ZCL_CID_BINARY_OUTPUT_BASIC, "Binary Output (Basic)"},
509 { ZBEE_ZCL_CID_BINARY_VALUE_BASIC, "Binary Value (Basic)"},
510 { ZBEE_ZCL_CID_MULTISTATE_INPUT_BASIC, "Multistate Input (Basic)"},
511 { ZBEE_ZCL_CID_MULTISTATE_OUTPUT_BASIC, "Multistate Output (Basic)"},
512 { ZBEE_ZCL_CID_MULTISTATE_VALUE_BASIC, "Multistate Value (Basic)"},
513 { ZBEE_ZCL_CID_COMMISSIONING, "Commissioning"},
514 { ZBEE_ZCL_CID_PARTITION, "Partition"},
515 /* */
516 { ZBEE_ZCL_CID_POWER_PROFILE, "Power Profile"},
517 { ZBEE_ZCL_CID_APPLIANCE_CONTROL, "Appliance Control"},
519 /* Closures */
520 { ZBEE_ZCL_CID_SHADE_CONFIG, "Shade Configuration"},
521 { ZBEE_ZCL_CID_DOOR_LOCK, "Door Lock"},
523 /* HVAC */
524 { ZBEE_ZCL_CID_PUMP_CONFIG_CONTROL, "Pump Configuration Control"},
525 { ZBEE_ZCL_CID_THERMOSTAT, "Thermostat"},
526 { ZBEE_ZCL_CID_FAN_CONTROL, "Fan Control"},
527 { ZBEE_ZCL_CID_DEHUMIDIFICATION_CONTROL, "Dehumidification Control"},
528 { ZBEE_ZCL_CID_THERMOSTAT_UI_CONFIG, "Thermostat User Interface Configuration"},
530 /* Lighting */
531 { ZBEE_ZCL_CID_COLOR_CONTROL, "Color Control"},
532 { ZBEE_ZCL_CID_BALLAST_CONFIG, "Ballast Configuration"},
534 /* Measurement and Sensing */
535 { ZBEE_ZCL_CID_ILLUMINANCE_MEASUREMENT, "Illuminance Measurement"},
536 { ZBEE_ZCL_CID_ILLUMINANCE_LEVEL_SENSING, "Illuminance Level Sensing"},
537 { ZBEE_ZCL_CID_TEMPERATURE_MEASUREMENT, "Temperature Measurement"},
538 { ZBEE_ZCL_CID_PRESSURE_MEASUREMENT, "Pressure Measurement"},
539 { ZBEE_ZCL_CID_FLOW_MEASUREMENT, "Flow Measurement"},
540 { ZBEE_ZCL_CID_REL_HUMIDITY_MEASUREMENT, "Relative Humidity Measurement"},
541 { ZBEE_ZCL_CID_OCCUPANCY_SENSING, "Occupancy Sensing"},
543 /* Security and Safety */
544 { ZBEE_ZCL_CID_IAS_ZONE, "Intruder Alarm System Zone"},
545 { ZBEE_ZCL_CID_IAS_ACE, "Intruder Alarm System ACE"},
546 { ZBEE_ZCL_CID_IAS_WD, "Intruder Alarm System WD"},
548 /* Protocol Interfaces */
549 { ZBEE_ZCL_CID_GENERIC_TUNNEL, "BACnet Generic Tunnel"},
550 { ZBEE_ZCL_CID_BACNET_PROTOCOL_TUNNEL, "BACnet Protocol Tunnel"},
551 { ZBEE_ZCL_CID_BACNET_ANALOG_INPUT_REG, "BACnet Analog Input (Regular)"},
552 { ZBEE_ZCL_CID_BACNET_ANALOG_INPUT_EXT, "BACnet Analog Input (Extended)"},
553 { ZBEE_ZCL_CID_BACNET_ANALOG_OUTPUT_REG, "BACnet Analog Output (Regular)"},
554 { ZBEE_ZCL_CID_BACNET_ANALOG_OUTPUT_EXT, "BACnet Analog Output (Extended)"},
555 { ZBEE_ZCL_CID_BACNET_ANALOG_VALUE_REG, "BACnet Analog Value (Regular)"},
556 { ZBEE_ZCL_CID_BACNET_ANALOG_VALUE_EXT, "BACnet Analog Value (Extended)"},
557 { ZBEE_ZCL_CID_BACNET_BINARY_INPUT_REG, "BACnet Binary Input (Regular)"},
558 { ZBEE_ZCL_CID_BACNET_BINARY_INPUT_EXT, "BACnet Binary Input (Extended)"},
559 { ZBEE_ZCL_CID_BACNET_BINARY_OUTPUT_REG, "BACnet Binary Output (Regular)"},
560 { ZBEE_ZCL_CID_BACNET_BINARY_OUTPUT_EXT, "BACnet Binary Output (Extended)"},
561 { ZBEE_ZCL_CID_BACNET_BINARY_VALUE_REG, "BACnet Binary Value (Regular)"},
562 { ZBEE_ZCL_CID_BACNET_BINARY_VALUE_EXT, "BACnet Binary Value (Extended)"},
563 { ZBEE_ZCL_CID_BACNET_MULTISTATE_INPUT_REG, "BACnet Multistage Input (Regular)"},
564 { ZBEE_ZCL_CID_BACNET_MULTISTATE_INPUT_EXT, "BACnet Multistage Input (Extended)"},
565 { ZBEE_ZCL_CID_BACNET_MULTISTATE_OUTPUT_REG, "BACnet Multistage Output (Regular)"},
566 { ZBEE_ZCL_CID_BACNET_MULTISTATE_OUTPUT_EXT, "BACnet Multistage Output (Extended)"},
567 { ZBEE_ZCL_CID_BACNET_MULTISTATE_VALUE_REG, "BACnet Multistage Value (Regular)"},
568 { ZBEE_ZCL_CID_BACNET_MULTISTATE_VALUE_EXT, "BACnet Multistage Value (Extended)"},
570 /* Smart Energy */
571 { ZBEE_ZCL_CID_PRICE, "Price"},
572 { ZBEE_ZCL_CID_DEMAND_RESPONSE_LOAD_CONTROL, "Demand Response and Load Control"},
573 { ZBEE_ZCL_CID_SIMPLE_METERING, "Simple Metering"},
574 { ZBEE_ZCL_CID_MESSAGE, "Message"},
575 { ZBEE_ZCL_CID_SMART_ENERGY_TUNNELING, "Smart Energy Tunneling"},
576 { ZBEE_ZCL_CID_PRE_PAYMENT, "Pre-Payment"},
578 /* ZCL Cluster IDs - Home Automation */
579 {ZBEE_ZCL_CID_APPLIANCE_IDENTIFICATION, "Appliance Identification"},
580 {ZBEE_ZCL_CID_METER_IDENTIFICATION, "Meter Identification"},
581 {ZBEE_ZCL_CID_APPLIANCE_EVENTS_AND_ALERT, "Appliance Events And Alerts"},
582 {ZBEE_ZCL_CID_APPLIANCE_STATISTICS, "Appliance Statistics"},
584 { 0, NULL }
587 /*FUNCTION:------------------------------------------------------
588 * NAME
589 * dissect_zbee_aps
590 * DESCRIPTION
591 * ZigBee Application Support Sublayer dissector for wireshark.
592 * PARAMETERS
593 * tvbuff_t *tvb - pointer to buffer containing raw packet.
594 * packet_info *pinfo - pointer to packet information fields
595 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
596 * RETURNS
597 * void
598 *---------------------------------------------------------------
600 static int
601 dissect_zbee_aps(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
603 tvbuff_t *payload_tvb = NULL;
604 dissector_handle_t profile_handle = NULL;
606 proto_tree *aps_tree;
607 proto_tree *field_tree = NULL;
608 proto_item *proto_root;
609 proto_item *ti;
611 zbee_aps_packet packet;
612 zbee_nwk_packet *nwk = (zbee_nwk_packet *)data;
614 guint8 fcf;
615 guint8 offset = 0;
617 /* Init. */
618 memset(&packet, 0, sizeof(zbee_aps_packet));
620 /* Create the protocol tree */
621 proto_root = proto_tree_add_protocol_format(tree, proto_zbee_aps, tvb, offset, tvb_length(tvb), "ZigBee Application Support Layer");
622 aps_tree = proto_item_add_subtree(proto_root, ett_zbee_aps);
624 /* Set the protocol column, if the NWK layer hasn't already done so. */
625 col_set_str(pinfo->cinfo, COL_PROTOCOL, "ZigBee");
627 /* Get the FCF */
628 fcf = tvb_get_guint8(tvb, offset);
629 packet.type = zbee_get_bit_field(fcf, ZBEE_APS_FCF_FRAME_TYPE);
630 packet.delivery = zbee_get_bit_field(fcf, ZBEE_APS_FCF_DELIVERY_MODE);
631 packet.indirect_mode = zbee_get_bit_field(fcf, ZBEE_APS_FCF_INDIRECT_MODE);
632 packet.ack_format = zbee_get_bit_field(fcf, ZBEE_APS_FCF_ACK_FORMAT);
633 packet.security = zbee_get_bit_field(fcf, ZBEE_APS_FCF_SECURITY);
634 packet.ack_req = zbee_get_bit_field(fcf, ZBEE_APS_FCF_ACK_REQ);
635 packet.ext_header = zbee_get_bit_field(fcf, ZBEE_APS_FCF_EXT_HEADER);
637 /* Display the frame type to the proto root and info column. */
638 if (tree) {
639 proto_item_append_text(proto_root, " %s", val_to_str_const(packet.type, zbee_aps_frame_types, "Unknown Type"));
641 col_set_str(pinfo->cinfo, COL_INFO, "APS: ");
642 col_append_str(pinfo->cinfo, COL_INFO, val_to_str_const(packet.type, zbee_aps_frame_types, "Unknown Frame Type"));
644 /* Display the FCF */
645 if (tree) {
646 /* Create the subtree */
647 ti = proto_tree_add_text(aps_tree, tvb, offset, 1, "Frame Control Field: %s (0x%02x)",
648 val_to_str_const(packet.type, zbee_aps_frame_types, "Unknown"), fcf);
649 field_tree = proto_item_add_subtree(ti, ett_zbee_aps_fcf);
651 /* Add the frame type and delivery mode. */
652 proto_tree_add_uint(field_tree, hf_zbee_aps_fcf_frame_type, tvb, offset, 1, fcf & ZBEE_APS_FCF_FRAME_TYPE);
653 proto_tree_add_uint(field_tree, hf_zbee_aps_fcf_delivery, tvb, offset, 1, fcf & ZBEE_APS_FCF_DELIVERY_MODE);
655 if (nwk->version >= ZBEE_VERSION_2007) {
656 /* ZigBee 2007 and later uses an ack mode flag. */
657 if (packet.type == ZBEE_APS_FCF_ACK) {
658 proto_tree_add_boolean(field_tree, hf_zbee_aps_fcf_ack_format, tvb, offset, 1,
659 fcf & ZBEE_APS_FCF_ACK_FORMAT);
662 else {
663 /* ZigBee 2004, uses indirect mode. */
664 if (packet.delivery == ZBEE_APS_FCF_INDIRECT) {
665 proto_tree_add_boolean(field_tree, hf_zbee_aps_fcf_indirect_mode, tvb, offset, 1,
666 fcf & ZBEE_APS_FCF_INDIRECT_MODE);
670 /* Add the rest of the flags */
671 proto_tree_add_boolean(field_tree, hf_zbee_aps_fcf_security, tvb, offset, 1, fcf & ZBEE_APS_FCF_SECURITY);
672 proto_tree_add_boolean(field_tree, hf_zbee_aps_fcf_ack_req, tvb, offset, 1, fcf & ZBEE_APS_FCF_ACK_REQ);
673 proto_tree_add_boolean(field_tree, hf_zbee_aps_fcf_ext_header, tvb, offset, 1, fcf & ZBEE_APS_FCF_EXT_HEADER);
675 offset += 1;
677 /* Check if the endpoint addressing fields are present. */
678 switch (packet.type) {
679 case ZBEE_APS_FCF_DATA:
680 /* Endpoint addressing must exist to some extent on data frames. */
681 break;
683 case ZBEE_APS_FCF_ACK:
684 if ((nwk->version >= ZBEE_VERSION_2007) && (packet.ack_format)) {
685 /* Command Ack: endpoint addressing does not exist. */
686 goto dissect_zbee_aps_no_endpt;
688 break;
690 default:
691 case ZBEE_APS_FCF_CMD:
692 /* Endpoint addressing does not exist for these frames. */
693 goto dissect_zbee_aps_no_endpt;
694 } /* switch */
696 /* Determine whether the source and/or destination endpoints are present.
697 * We should only get here for endpoint-addressed data or ack frames.
699 if ((packet.delivery == ZBEE_APS_FCF_UNICAST) || (packet.delivery == ZBEE_APS_FCF_BCAST)) {
700 /* Source and destination endpoints exist. (Although, I strongly
701 * disagree with the presence of the endpoint in broadcast delivery
702 * mode).
704 packet.dst_present = TRUE;
705 packet.src_present = TRUE;
707 else if ((packet.delivery == ZBEE_APS_FCF_INDIRECT) && (nwk->version <= ZBEE_VERSION_2004)) {
708 /* Indirect addressing was removed in ZigBee 2006, basically because it
709 * was a useless, broken feature which only complicated things. Treat
710 * this mode as invalid for ZigBee 2006 and later. When using indirect
711 * addressing, only one of the source and destination endpoints exist,
712 * and is controlled by the setting of indirect_mode.
714 packet.dst_present = (!packet.indirect_mode);
715 packet.src_present = (packet.indirect_mode);
717 else if ((packet.delivery == ZBEE_APS_FCF_GROUP) && (nwk->version >= ZBEE_VERSION_2007)) {
718 /* Group addressing was added in ZigBee 2006, and contains only the
719 * source endpoint. (IMO, Broacast deliveries should do the same).
721 packet.dst_present = FALSE;
722 packet.src_present = TRUE;
724 else {
725 /* Illegal Delivery Mode. */
726 expert_add_info(pinfo, proto_root, &ei_zbee_aps_invalid_delivery_mode);
727 return tvb_length(tvb);
731 /* If the destination endpoint is present, get and display it. */
732 if (packet.dst_present) {
733 packet.dst = tvb_get_guint8(tvb, offset);
734 if (tree) {
735 proto_tree_add_uint(aps_tree, hf_zbee_aps_dst, tvb, offset, 1, packet.dst);
736 proto_item_append_text(proto_root, ", Dst Endpt: %d", packet.dst);
738 offset += 1;
740 /* Update the info column. */
741 col_append_fstr(pinfo->cinfo, COL_INFO, ", Dst Endpt: %d", packet.dst);
744 /* If the group address is present, display it. */
745 if (packet.delivery == ZBEE_APS_FCF_GROUP) {
746 packet.group = tvb_get_letohs(tvb, offset);
747 if (tree) {
748 proto_tree_add_uint(aps_tree, hf_zbee_aps_group, tvb, offset,2, packet.group);
749 proto_item_append_text(proto_root, ", Group: 0x%04x", packet.group);
751 offset +=2;
753 /* Update the info column. */
754 col_append_fstr(pinfo->cinfo, COL_INFO, ", Group: 0x%04x", packet.group);
757 /* Get and display the cluster ID. */
758 if (nwk->version >= ZBEE_VERSION_2007) {
759 /* Cluster ID is 16-bits long in ZigBee 2007 and later. */
760 nwk->cluster_id = tvb_get_letohs(tvb, offset);
761 proto_tree_add_item(aps_tree, hf_zbee_aps_cluster, tvb, offset,2, ENC_LITTLE_ENDIAN);
762 offset +=2;
764 else {
765 /* Cluster ID is 8-bits long in ZigBee 2004 and earlier. */
766 nwk->cluster_id = tvb_get_guint8(tvb, offset);
767 proto_tree_add_uint_format_value(aps_tree, hf_zbee_aps_cluster, tvb, offset,
768 1, nwk->cluster_id, "0x%02x", nwk->cluster_id);
769 offset += 1;
772 /* Get and display the profile ID. */
773 packet.profile = tvb_get_letohs(tvb, offset);
774 profile_handle = dissector_get_uint_handle(zbee_aps_dissector_table, packet.profile);
775 if (tree) {
776 proto_tree_add_uint(aps_tree, hf_zbee_aps_profile, tvb, offset,2,
777 packet.profile);
778 /* Update the protocol root and info column later, after the source endpoint
779 * so that the source and destination will be back-to-back in the text.
782 offset +=2;
784 /* The source endpoint is present for all cases except indirect /w indirect_mode == FALSE */
785 if ((packet.delivery != ZBEE_APS_FCF_INDIRECT) || (!packet.indirect_mode)) {
786 packet.src = tvb_get_guint8(tvb, offset);
787 if (tree) {
788 proto_tree_add_uint(aps_tree, hf_zbee_aps_src, tvb, offset, 1, packet.src);
789 proto_item_append_text(proto_root, ", Src Endpt: %d", packet.src);
791 offset += 1;
793 /* Update the info column. */
794 col_append_fstr(pinfo->cinfo, COL_INFO, ", Src Endpt: %d", packet.src);
797 /* Display the profile ID now that the source endpoint was listed. */
798 if (packet.type == ZBEE_APS_FCF_DATA) {
799 col_append_fstr(pinfo->cinfo, COL_PROTOCOL, " %s",
800 rval_to_str(packet.profile, zbee_aps_apid_abbrs, ""));
803 /* Jump here if there is no endpoint addressing in this frame. */
804 dissect_zbee_aps_no_endpt:
806 /* Get and display the APS counter. Only present on ZigBee 2007 and later. */
807 if (nwk->version >= ZBEE_VERSION_2007) {
808 packet.counter = tvb_get_guint8(tvb, offset);
809 if (tree) {
810 proto_tree_add_uint(aps_tree, hf_zbee_aps_counter, tvb, offset, 1, packet.counter);
812 offset += 1;
815 /* Get and display the extended header, if present. */
816 if (packet.ext_header) {
817 fcf = tvb_get_guint8(tvb, offset);
818 packet.fragmentation = fcf & ZBEE_APS_EXT_FCF_FRAGMENT;
819 if (tree) {
820 /* Create a subtree */
821 ti = proto_tree_add_text(aps_tree, tvb, offset, 1, "Extended Frame Control Field (0x%02x)", fcf);
822 field_tree = proto_item_add_subtree(ti, ett_zbee_aps_fcf);
824 /* Display the fragmentation sub-field. */
825 proto_tree_add_uint(field_tree, hf_zbee_aps_fragmentation, tvb, offset, 1, packet.fragmentation);
827 offset += 1;
829 /* If fragmentation is enabled, get and display the block number. */
830 if (packet.fragmentation != ZBEE_APS_EXT_FCF_FRAGMENT_NONE) {
831 packet.block_number = tvb_get_guint8(tvb, offset);
832 if (tree) {
833 proto_tree_add_uint(field_tree, hf_zbee_aps_block_number, tvb, offset, 1, packet.block_number);
835 offset += 1;
838 /* If fragmentation is enabled, and this is an acknowledgement,
839 * get and display the ack bitfield.
841 if ((packet.fragmentation != ZBEE_APS_EXT_FCF_FRAGMENT_NONE) && (packet.type == ZBEE_APS_FCF_ACK)) {
842 packet.ack_bitfield = tvb_get_guint8(tvb, offset);
843 if (tree) {
844 int i, mask;
845 gchar tmp[16];
846 for (i=0; i<8; i++) {
847 mask = (1<<i);
848 decode_bitfield_value(tmp, packet.ack_bitfield, mask, 8);
849 proto_tree_add_text(field_tree, tvb, offset, 1, "%sBlock %d: %s",
850 tmp, packet.block_number+i, (packet.ack_bitfield & mask)?"Acknowledged":"Not Acknowledged");
851 } /* for */
853 offset += 1;
856 else {
857 /* Ensure the fragmentation mode is set off, so that the reassembly handler
858 * doesn't get called.
860 packet.fragmentation = ZBEE_APS_EXT_FCF_FRAGMENT_NONE;
863 /* If a payload is present, and security is enabled, decrypt the payload. */
864 if ((offset < tvb_length(tvb)) && packet.security) {
865 payload_tvb = dissect_zbee_secure(tvb, pinfo, aps_tree, offset);
866 if (payload_tvb == NULL) {
867 /* If Payload_tvb is NULL, then the security dissector cleaned up. */
868 return tvb_length(tvb);
871 /* If the payload exists, create a tvb subset. */
872 else if (offset < tvb_length(tvb)) {
873 payload_tvb = tvb_new_subset_remaining(tvb, offset);
876 /* If the payload exists, and the packet is fragmented, attempt reassembly. */
877 if ((payload_tvb) && (packet.fragmentation != ZBEE_APS_EXT_FCF_FRAGMENT_NONE)) {
878 guint32 msg_id;
879 guint32 block_num;
880 fragment_head *frag_msg = NULL;
881 tvbuff_t *new_tvb;
883 /* Set the fragmented flag. */
884 pinfo->fragmented = TRUE;
886 /* The source address and APS Counter pair form a unique identifier
887 * for each message (fragmented or not). Hash these two together to
888 * create the message id for the fragmentation handler.
890 msg_id = ((nwk->src)<<8) + packet.counter;
892 /* If this is the first block of a fragmented message, than the block
893 * number field is the maximum number of blocks in the message. Otherwise
894 * the block number is the block being sent.
896 if (packet.fragmentation == ZBEE_APS_EXT_FCF_FRAGMENT_FIRST) {
897 fragment_set_tot_len(&zbee_aps_reassembly_table, pinfo, msg_id, NULL, packet.block_number);
898 block_num = 0; /* first packet. */
900 else {
901 block_num = packet.block_number;
904 /* Add this fragment to the reassembly handler. */
905 frag_msg = fragment_add_seq_check(&zbee_aps_reassembly_table,
906 payload_tvb, 0, pinfo, msg_id, NULL,
907 block_num, tvb_length(payload_tvb), TRUE);
909 new_tvb = process_reassembled_data(payload_tvb, 0, pinfo, "Reassembled ZigBee APS" ,
910 frag_msg, &zbee_aps_frag_items, NULL, aps_tree);
912 /* Update the info column regarding the fragmentation. */
913 if (frag_msg) col_append_str(pinfo->cinfo, COL_INFO, " (Message Reassembled)");
914 else col_append_fstr(pinfo->cinfo, COL_INFO, " (Message fragment %u)", packet.counter);
916 if (new_tvb) {
917 /* The reassembly handler defragmented the message, and created a new tvbuff. */
918 payload_tvb = new_tvb;
920 else {
921 /* The reassembly handler could not defragment the message. */
922 call_dissector(data_handle, payload_tvb, pinfo, tree);
923 return tvb_length(tvb);
927 /* Handle the packet type. */
928 switch (packet.type) {
929 case ZBEE_APS_FCF_DATA:
930 if (!payload_tvb) {
931 break;
933 if (nwk->version <= ZBEE_VERSION_2004) {
935 * In ZigBee 2004, an "application framework" sits between the
936 * APS and application. Call a subdissector to handle it.
938 nwk->private_data = profile_handle;
939 profile_handle = zbee_apf_handle;
941 else if (profile_handle == NULL) {
942 /* Could not locate a profile dissector. */
943 break;
945 call_dissector_with_data(profile_handle, payload_tvb, pinfo, tree, nwk);
946 return tvb_length(tvb);
948 case ZBEE_APS_FCF_CMD:
949 if (!payload_tvb) {
950 /* Command packets MUST contain a payload. */
951 expert_add_info(pinfo, proto_root, &ei_zbee_aps_missing_payload);
952 THROW(BoundsError);
953 return tvb_length(tvb);
955 dissect_zbee_aps_cmd(payload_tvb, pinfo, aps_tree, nwk->version);
956 return tvb_length(tvb);
958 case ZBEE_APS_FCF_ACK:
959 /* Acks should never contain a payload. */
960 break;
962 default:
963 /* Illegal frame type. */
964 break;
965 } /* switch */
967 * If we get this far, then no subdissectors have been called, use the data
968 * dissector to display the leftover bytes, if any.
970 if (payload_tvb) {
971 call_dissector(data_handle, payload_tvb, pinfo, tree);
974 return tvb_length(tvb);
975 } /* dissect_zbee_aps */
977 /*FUNCTION:------------------------------------------------------
978 * NAME
979 * dissect_zbee_aps_cmd
980 * DESCRIPTION
981 * ZigBee APS sub-dissector for APS Command frames
982 * PARAMETERS
983 * tvbuff_t *tvb - pointer to buffer containing raw packet.
984 * packet_into *pinfo - pointer to packet information fields
985 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
986 * proto_item *proto_root - pointer to the root of the APS tree
987 * RETURNS
988 * void
989 *---------------------------------------------------------------
991 static void dissect_zbee_aps_cmd(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint8 version)
993 proto_item *cmd_root = NULL;
994 proto_tree *cmd_tree = NULL;
996 guint offset = 0;
997 guint8 cmd_id = tvb_get_guint8(tvb, offset);
999 /* Create a subtree for the APS Command frame, and add the command ID to it. */
1000 if(tree){
1001 cmd_root = proto_tree_add_text(tree, tvb, offset, tvb_length(tvb), "Command Frame: %s", val_to_str_const(cmd_id, zbee_aps_cmd_names, "Unknown"));
1002 cmd_tree = proto_item_add_subtree(cmd_root, ett_zbee_aps_cmd);
1004 /* Add the command ID. */
1005 proto_tree_add_uint(cmd_tree, hf_zbee_aps_cmd_id, tvb, offset, 1, cmd_id);
1007 offset += 1;
1009 /* Add the command name to the info column. */
1010 col_set_str(pinfo->cinfo, COL_INFO, val_to_str_const(cmd_id, zbee_aps_cmd_names, "Unknown Command"));
1012 /* Handle the contents of the command frame. */
1013 switch(cmd_id){
1014 case ZBEE_APS_CMD_SKKE1:
1015 case ZBEE_APS_CMD_SKKE2:
1016 offset = dissect_zbee_aps_skke_challenge(tvb, pinfo, cmd_tree, offset);
1017 break;
1019 case ZBEE_APS_CMD_SKKE3:
1020 case ZBEE_APS_CMD_SKKE4:
1021 offset = dissect_zbee_aps_skke_data(tvb, pinfo, cmd_tree, offset);
1022 break;
1024 case ZBEE_APS_CMD_TRANSPORT_KEY:
1025 /* Transport Key Command. */
1026 offset = dissect_zbee_aps_transport_key(tvb, pinfo, cmd_tree, offset);
1027 break;
1029 case ZBEE_APS_CMD_UPDATE_DEVICE:
1030 /* Update Device Command. */
1031 offset = dissect_zbee_aps_update_device(tvb, pinfo, cmd_tree, offset, version);
1032 break;
1034 case ZBEE_APS_CMD_REMOVE_DEVICE:
1035 /* Remove Device. */
1036 offset = dissect_zbee_aps_remove_device(tvb, pinfo, cmd_tree, offset);
1037 break;
1039 case ZBEE_APS_CMD_REQUEST_KEY:
1040 /* Request Key Command. */
1041 offset = dissect_zbee_aps_request_key(tvb, pinfo, cmd_tree, offset);
1042 break;
1044 case ZBEE_APS_CMD_SWITCH_KEY:
1045 /* Switch Key Command. */
1046 offset = dissect_zbee_aps_switch_key(tvb, pinfo, cmd_tree, offset);
1047 break;
1049 case ZBEE_APS_CMD_EA_INIT_CHLNG:
1050 case ZBEE_APS_CMD_EA_RESP_CHLNG:
1051 /* Entity Authentication Challenge Command. */
1052 offset = dissect_zbee_aps_auth_challenge(tvb, pinfo, cmd_tree, offset);
1053 break;
1055 case ZBEE_APS_CMD_EA_INIT_MAC_DATA:
1056 case ZBEE_APS_CMD_EA_RESP_MAC_DATA:
1057 /* Entity Authentication Data Command. */
1058 offset = dissect_zbee_aps_auth_data(tvb, pinfo, cmd_tree, offset);
1059 break;
1061 case ZBEE_APS_CMD_TUNNEL:
1062 /* Tunnel Command. */
1063 offset = dissect_zbee_aps_tunnel(tvb, pinfo, cmd_tree, offset);
1064 break;
1066 default:
1067 break;
1068 } /* switch */
1070 /* Check for any excess bytes. */
1071 if (offset < tvb_length(tvb)) {
1072 /* There are leftover bytes! */
1073 guint leftover_len = tvb_length(tvb) - offset;
1074 proto_tree *root = NULL;
1075 tvbuff_t *leftover_tvb = tvb_new_subset(tvb, offset, leftover_len, leftover_len);
1077 if (tree) {
1078 /* Get the APS Root. */
1079 root = proto_tree_get_root(tree);
1081 /* Correct the length of the command tree. */
1082 proto_item_set_len(cmd_root, offset);
1085 /* Dump the leftover to the data dissector. */
1086 call_dissector(data_handle, leftover_tvb, pinfo, root);
1088 } /* dissect_zbee_aps_cmd */
1090 /*FUNCTION:------------------------------------------------------
1091 * NAME
1092 * dissect_zbee_aps_skke_challenge
1093 * DESCRIPTION
1094 * Helper dissector for the SKKE Challenge commands (SKKE1 and
1095 * SKKE2).
1096 * PARAMETERS
1097 * tvbuff_t *tvb - pointer to buffer containing raw packet.
1098 * packet_into *pinfo - pointer to packet information fields
1099 * proto_tree *tree - pointer to the command subtree.
1100 * offset - offset into the tvb to begin dissection.
1101 * RETURNS
1102 * guint - offset after command dissection.
1103 *---------------------------------------------------------------
1105 static guint
1106 dissect_zbee_aps_skke_challenge(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, guint offset)
1109 /* Get and display the initiator address. */
1110 if (tree) {
1111 proto_tree_add_item(tree, hf_zbee_aps_cmd_initiator, tvb, offset, 8, ENC_LITTLE_ENDIAN);
1113 offset += 8;
1115 /* Get and display the responder address. */
1116 if (tree) {
1117 proto_tree_add_item(tree, hf_zbee_aps_cmd_responder, tvb, offset, 8, ENC_LITTLE_ENDIAN);
1119 offset += 8;
1121 /* Get and display the SKKE data. */
1122 if (tree) {
1123 proto_tree_add_item(tree, hf_zbee_aps_cmd_challenge, tvb, offset, ZBEE_APS_CMD_SKKE_DATA_LENGTH, ENC_NA);
1125 offset += ZBEE_APS_CMD_SKKE_DATA_LENGTH;
1127 /* Done */
1128 return offset;
1129 } /* dissect_zbee_aps_skke_challenge */
1131 /*FUNCTION:------------------------------------------------------
1132 * NAME
1133 * dissect_zbee_aps_skke_data
1134 * DESCRIPTION
1135 * Helper dissector for the SKKE Data commands (SKKE3 and
1136 * SKKE4).
1137 * PARAMETERS
1138 * tvbuff_t *tvb - pointer to buffer containing raw packet.
1139 * packet_into *pinfo - pointer to packet information fields
1140 * proto_tree *tree - pointer to the command subtree.
1141 * offset - offset into the tvb to begin dissection.
1142 * RETURNS
1143 * guint - offset after command dissection.
1144 *---------------------------------------------------------------
1146 static guint
1147 dissect_zbee_aps_skke_data(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, guint offset)
1150 /* Get and display the initiator address. */
1152 if (tree) {
1153 proto_tree_add_item(tree, hf_zbee_aps_cmd_initiator, tvb, offset, 8, ENC_LITTLE_ENDIAN);
1155 offset += 8;
1157 /* Get and display the responder address. */
1158 if (tree) {
1159 proto_tree_add_item(tree, hf_zbee_aps_cmd_responder, tvb, offset, 8, ENC_LITTLE_ENDIAN);
1161 offset += 8;
1163 /* Get and display the SKKE data. */
1164 if (tree) {
1165 proto_tree_add_item(tree, hf_zbee_aps_cmd_mac, tvb, offset, ZBEE_APS_CMD_SKKE_DATA_LENGTH, ENC_NA);
1167 offset += ZBEE_APS_CMD_SKKE_DATA_LENGTH;
1169 /* Done */
1170 return offset;
1171 } /* dissect_zbee_aps_skke_data */
1173 /*FUNCTION:------------------------------------------------------
1174 * NAME
1175 * dissect_zbee_aps_transport_key
1176 * DESCRIPTION
1177 * Helper dissector for the Transport Key command.
1178 * PARAMETERS
1179 * tvbuff_t *tvb - pointer to buffer containing raw packet.
1180 * packet_into *pinfo - pointer to packet information fields
1181 * proto_tree *tree - pointer to the command subtree.
1182 * offset - offset into the tvb to begin dissection.
1183 * RETURNS
1184 * guint - offset after command dissection.
1185 *---------------------------------------------------------------
1187 static guint
1188 dissect_zbee_aps_transport_key(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, guint offset)
1190 guint8 key_type;
1191 guint8 key[ZBEE_APS_CMD_KEY_LENGTH];
1192 GSList **nwk_keyring;
1193 key_record_t key_record;
1194 zbee_nwk_hints_t *nwk_hints;
1195 guint i;
1197 /* Get and display the key type. */
1198 key_type = tvb_get_guint8(tvb, offset);
1199 if (tree) {
1200 proto_tree_add_uint(tree, hf_zbee_aps_cmd_key_type, tvb, offset, 1, key_type);
1202 offset += 1;
1204 /* Coincidentally, all the key descriptors start with the key. So
1205 * get and display it.
1207 for (i=0; i<ZBEE_APS_CMD_KEY_LENGTH ; i++) {
1208 key[i] = tvb_get_guint8(tvb, offset+i);
1209 } /* for */
1210 if (tree) {
1211 proto_tree_add_item(tree, hf_zbee_aps_cmd_key, tvb, offset, ZBEE_APS_CMD_KEY_LENGTH, ENC_NA);
1213 offset += ZBEE_APS_CMD_KEY_LENGTH;
1215 /* Update the key ring for this pan */
1216 if ( !pinfo->fd->flags.visited && (nwk_hints = (zbee_nwk_hints_t *)p_get_proto_data(pinfo->fd,
1217 proto_get_id_by_filter_name(ZBEE_PROTOABBREV_NWK), 0))) {
1219 nwk_keyring = (GSList **)g_hash_table_lookup(zbee_table_nwk_keyring, &nwk_hints->src_pan);
1220 if ( !nwk_keyring ) {
1221 /* Create an empty key ring for this pan. Use g_malloc0() because we must free
1222 * GSLists after a capture is closed and wireshark frees seasonal memory
1223 * with se_free_all() before calling the registered init routine.
1225 nwk_keyring = (GSList **)g_malloc0(sizeof(GSList*));
1226 g_hash_table_insert(zbee_table_nwk_keyring,
1227 g_memdup(&nwk_hints->src_pan, sizeof(nwk_hints->src_pan)), nwk_keyring);
1230 if ( nwk_keyring ) {
1231 if ( !*nwk_keyring ||
1232 memcmp( ((key_record_t *)((GSList *)(*nwk_keyring))->data)->key, &key,
1233 ZBEE_APS_CMD_KEY_LENGTH) ) {
1234 /* Store a new or different key in the key ring */
1235 key_record.frame_num = pinfo->fd->num;
1236 key_record.label = NULL;
1237 memcpy(&key_record.key, &key, ZBEE_APS_CMD_KEY_LENGTH);
1238 *nwk_keyring = g_slist_prepend(*nwk_keyring, wmem_memdup(wmem_file_scope(),
1239 &key_record, sizeof(key_record_t)));
1244 /* Parse the rest of the key descriptor. */
1245 switch (key_type) {
1246 case ZBEE_APS_CMD_KEY_STANDARD_NWK:
1247 case ZBEE_APS_CMD_KEY_HIGH_SEC_NWK: {
1248 /* Network Key */
1249 guint8 seqno;
1251 /* Get and display the sequence number. */
1252 seqno = tvb_get_guint8(tvb, offset);
1253 if (tree) {
1254 proto_tree_add_uint(tree, hf_zbee_aps_cmd_seqno, tvb, offset, 1, seqno);
1256 offset += 1;
1258 /* Get and display the destination address. */
1259 if (tree) {
1260 proto_tree_add_item(tree, hf_zbee_aps_cmd_dst, tvb, offset, 8, ENC_LITTLE_ENDIAN);
1262 offset += 8;
1264 /* Get and display the source address. */
1265 if (tree) {
1266 proto_tree_add_item(tree, hf_zbee_aps_cmd_src, tvb, offset, 8, ENC_LITTLE_ENDIAN);
1268 offset += 8;
1270 break;
1272 case ZBEE_APS_CMD_KEY_TC_MASTER:
1273 case ZBEE_APS_CMD_KEY_TC_LINK:{
1274 /* Trust Center master key. */
1276 /* Get and display the destination address. */
1277 if (tree) {
1278 proto_tree_add_item(tree, hf_zbee_aps_cmd_dst, tvb, offset, 8, ENC_LITTLE_ENDIAN);
1280 offset += 8;
1282 /* Get and display the source address. */
1283 if (tree) {
1284 proto_tree_add_item(tree, hf_zbee_aps_cmd_src, tvb, offset, 8, ENC_LITTLE_ENDIAN);
1286 offset += 8;
1288 break;
1290 case ZBEE_APS_CMD_KEY_APP_MASTER:
1291 case ZBEE_APS_CMD_KEY_APP_LINK:{
1292 /* Application master or link key, both have the same format. */
1293 guint8 initiator;
1295 /* get and display the partner address. */
1296 if (tree) {
1297 proto_tree_add_item(tree, hf_zbee_aps_cmd_partner, tvb, offset, 8, ENC_LITTLE_ENDIAN);
1299 offset += 8;
1301 /* get and display the initiator flag. */
1302 initiator = tvb_get_guint8(tvb, offset);
1303 if (tree) {
1304 proto_tree_add_boolean(tree, hf_zbee_aps_cmd_initiator_flag, tvb, offset, 1, initiator);
1306 offset += 1;
1308 break;
1310 default:
1311 break;
1312 } /* switch */
1314 /* Done */
1315 return offset;
1316 } /* dissect_zbee_aps_transport_key */
1318 /*FUNCTION:------------------------------------------------------
1319 * NAME
1320 * dissect_zbee_aps_update_device
1321 * DESCRIPTION
1322 * Helper dissector for the Update Device command.
1323 * PARAMETERS
1324 * tvbuff_t *tvb - pointer to buffer containing raw packet.
1325 * packet_into *pinfo - pointer to packet information fields
1326 * proto_tree *tree - pointer to the command subtree.
1327 * offset - offset into the tvb to begin dissection.
1328 * RETURNS
1329 * guint - offset after command dissection.
1330 *---------------------------------------------------------------
1332 static guint
1333 dissect_zbee_aps_update_device(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, guint offset, guint8 version)
1335 /* Get and display the device address. */
1336 proto_tree_add_item(tree, hf_zbee_aps_cmd_device, tvb, offset, 8, ENC_LITTLE_ENDIAN);
1337 offset += 8;
1339 /* Get and display the short address. Only on ZigBee 2006 and later. */
1340 if (version >= ZBEE_VERSION_2007) {
1341 proto_tree_add_item(tree, hf_zbee_aps_cmd_short_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN);
1342 offset +=2;
1345 /* Get and display the status. */
1346 proto_tree_add_item(tree, hf_zbee_aps_cmd_device_status, tvb, offset, 1, ENC_NA);
1347 offset += 1;
1349 /* Done */
1350 return offset;
1351 } /* dissect_zbee_aps_update_device */
1353 /*FUNCTION:------------------------------------------------------
1354 * NAME
1355 * dissect_zbee_aps_remove_device
1356 * DESCRIPTION
1357 * Helper dissector for the Remove Device command.
1358 * PARAMETERS
1359 * tvbuff_t *tvb - pointer to buffer containing raw packet.
1360 * packet_into *pinfo - pointer to packet information fields
1361 * proto_tree *tree - pointer to the command subtree.
1362 * offset - offset into the tvb to begin dissection.
1363 * RETURNS
1364 * guint - offset after command dissection.
1365 *---------------------------------------------------------------
1367 static guint
1368 dissect_zbee_aps_remove_device(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, guint offset)
1371 /* Get and display the device address. */
1372 if(tree){
1373 proto_tree_add_item(tree, hf_zbee_aps_cmd_device, tvb, offset, 8, ENC_LITTLE_ENDIAN);
1375 offset += 8;
1377 /* Done */
1378 return offset;
1379 } /* dissect_zbee_aps_remove_device */
1381 /*FUNCTION:------------------------------------------------------
1382 * NAME
1383 * dissect_zbee_aps_request_key
1384 * DESCRIPTION
1385 * Helper dissector for the Request Key command.
1386 * PARAMETERS
1387 * tvbuff_t *tvb - pointer to buffer containing raw packet.
1388 * packet_into *pinfo - pointer to packet information fields
1389 * proto_tree *tree - pointer to the command subtree.
1390 * offset - offset into the tvb to begin dissection.
1391 * RETURNS
1392 * guint - offset after command dissection.
1393 *---------------------------------------------------------------
1395 static guint
1396 dissect_zbee_aps_request_key(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, guint offset)
1398 guint8 key_type;
1400 /* Get and display the key type. */
1401 key_type = tvb_get_guint8(tvb, offset);
1402 if (tree) {
1403 proto_tree_add_uint(tree, hf_zbee_aps_cmd_key_type, tvb, offset, 1, key_type);
1405 offset += 1;
1407 /* Get and display the partner address. Only present on application master key. */
1408 if (key_type == ZBEE_APS_CMD_KEY_APP_MASTER) {
1409 if (tree) {
1410 proto_tree_add_item(tree, hf_zbee_aps_cmd_partner, tvb, offset, 8, ENC_LITTLE_ENDIAN);
1412 offset += 8;
1415 /* Done */
1416 return offset;
1417 } /* dissect_zbee_aps_request_key */
1419 /*FUNCTION:------------------------------------------------------
1420 * NAME
1421 * dissect_zbee_aps_switch_key
1422 * DESCRIPTION
1423 * Helper dissector for the Switch Key command.
1424 * PARAMETERS
1425 * tvbuff_t *tvb - pointer to buffer containing raw packet.
1426 * packet_into *pinfo - pointer to packet information fields
1427 * proto_tree *tree - pointer to the command subtree.
1428 * offset - offset into the tvb to begin dissection.
1429 * RETURNS
1430 * guint - offset after command dissection.
1431 *---------------------------------------------------------------
1433 static guint
1434 dissect_zbee_aps_switch_key(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, guint offset)
1436 guint8 seqno;
1438 /* Get and display the sequence number. */
1439 seqno = tvb_get_guint8(tvb, offset);
1440 if (tree) {
1441 proto_tree_add_uint(tree, hf_zbee_aps_cmd_seqno, tvb, offset, 1, seqno);
1443 offset += 1;
1445 /* Done */
1446 return offset;
1447 } /* dissect_zbee_aps_switch_key */
1449 /*FUNCTION:------------------------------------------------------
1450 * NAME
1451 * dissect_zbee_aps_auth_challenge
1452 * DESCRIPTION
1453 * Helper dissector for the Entity-Authentication Initiator
1454 * or Responder challenge commands.
1455 * PARAMETERS
1456 * tvbuff_t *tvb - pointer to buffer containing raw packet.
1457 * packet_into *pinfo - pointer to packet information fields
1458 * proto_tree *tree - pointer to the command subtree.
1459 * offset - offset into the tvb to begin dissection.
1460 * RETURNS
1461 * guint - offset after command dissection.
1462 *---------------------------------------------------------------
1464 static guint
1465 dissect_zbee_aps_auth_challenge(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, guint offset)
1467 guint8 key_type;
1468 guint8 key_seqno;
1470 /* Get and display the key type. */
1471 key_type = tvb_get_guint8(tvb, offset);
1472 if (tree) {
1473 proto_tree_add_uint(tree, hf_zbee_aps_cmd_ea_key_type, tvb, offset, 1, key_type);
1475 offset += 1;
1477 /* If using the network key, display the key sequence number. */
1478 if (key_type == ZBEE_APS_CMD_EA_KEY_NWK) {
1479 key_seqno = tvb_get_guint8(tvb, offset);
1480 if (tree) {
1481 proto_tree_add_uint(tree, hf_zbee_aps_cmd_seqno, tvb, offset, 1, key_seqno);
1483 offset += 1;
1486 /* Get and display the initiator address. */
1487 if (tree) {
1488 proto_tree_add_item(tree, hf_zbee_aps_cmd_initiator, tvb, offset, 8, ENC_LITTLE_ENDIAN);
1490 offset += 8;
1492 /* Get and display the responder address. */
1493 if (tree) {
1494 proto_tree_add_item(tree, hf_zbee_aps_cmd_responder, tvb, offset, 8, ENC_LITTLE_ENDIAN);
1496 offset += 8;
1498 /* Get and display the challenge. */
1499 if (tree) {
1500 proto_tree_add_item(tree, hf_zbee_aps_cmd_challenge, tvb, offset, ZBEE_APS_CMD_EA_CHALLENGE_LENGTH, ENC_NA);
1502 offset += ZBEE_APS_CMD_EA_CHALLENGE_LENGTH;
1504 /* Done*/
1505 return offset;
1506 } /* dissect_zbee_aps_auth_challenge */
1508 /*FUNCTION:------------------------------------------------------
1509 * NAME
1510 * dissect_zbee_aps_auth_data
1511 * DESCRIPTION
1512 * Helper dissector for the Entity-Authentication Initiator
1513 * or Responder data commands.
1514 * PARAMETERS
1515 * tvbuff_t *tvb - pointer to buffer containing raw packet.
1516 * packet_into *pinfo - pointer to packet information fields
1517 * proto_tree *tree - pointer to the command subtree.
1518 * offset - offset into the tvb to begin dissection.
1519 * RETURNS
1520 * guint - offset after command dissection.
1521 *---------------------------------------------------------------
1523 static guint
1524 dissect_zbee_aps_auth_data(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, guint offset)
1526 guint8 data_type;
1528 /* Display the MAC. */
1529 if (tree) {
1530 proto_tree_add_item(tree, hf_zbee_aps_cmd_mac, tvb, offset, ZBEE_APS_CMD_EA_MAC_LENGTH, ENC_NA);
1532 offset += ZBEE_APS_CMD_EA_MAC_LENGTH;
1534 /* Get and display the data type. */
1535 data_type = tvb_get_guint8(tvb, offset);
1536 if (tree) {
1537 /* Note! We're interpreting the DataType field to be the same as
1538 * KeyType field in the challenge frames. So far, this seems
1539 * consistent, although ZigBee appears to have left some holes
1540 * in the definition of the DataType and Data fields (ie: what
1541 * happens when KeyType == Link Key?)
1543 proto_tree_add_uint(tree, hf_zbee_aps_cmd_ea_key_type, tvb, offset, 1, data_type);
1545 offset += 1;
1547 /* Display the data field. */
1548 if (tree) {
1549 proto_tree_add_item(tree, hf_zbee_aps_cmd_ea_data, tvb, offset, ZBEE_APS_CMD_EA_DATA_LENGTH, ENC_NA);
1551 offset += ZBEE_APS_CMD_EA_DATA_LENGTH;
1553 /* Done */
1554 return offset;
1555 } /* dissect_zbee_aps_auth_data */
1557 /*FUNCTION:------------------------------------------------------
1558 * NAME
1559 * dissect_zbee_aps_auth_data
1560 * DESCRIPTION
1561 * Helper dissector for the Tunnel command.
1562 * PARAMETERS
1563 * tvbuff_t *tvb - pointer to buffer containing raw packet.
1564 * packet_into *pinfo - pointer to packet information fields
1565 * proto_tree *tree - pointer to the command subtree.
1566 * offset - offset into the tvb to begin dissection.
1567 * RETURNS
1568 * guint - offset after command dissection.
1569 *---------------------------------------------------------------
1571 static guint
1572 dissect_zbee_aps_tunnel(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset)
1574 proto_tree *root = NULL;
1575 tvbuff_t *tunnel_tvb;
1577 /* Get and display the destination address. */
1578 if (tree) {
1579 proto_tree_add_item(tree, hf_zbee_aps_cmd_dst, tvb, offset, 8, ENC_LITTLE_ENDIAN);
1581 offset += 8;
1583 /* The remainder is a tunneled APS frame. */
1584 tunnel_tvb = tvb_new_subset_remaining(tvb, offset);
1585 if (tree) root = proto_tree_get_root(tree);
1586 call_dissector(zbee_aps_handle, tunnel_tvb, pinfo, root);
1587 offset = tvb_length(tvb);
1589 /* Done */
1590 return offset;
1591 } /* dissect_zbee_aps_tunnel */
1593 /*FUNCTION:------------------------------------------------------
1594 * NAME
1595 * dissect_zbee_apf
1596 * DESCRIPTION
1597 * ZigBee Application Framework dissector for Wireshark. Note
1598 * that the Application Framework is deprecated as of ZigBee
1599 * 2006.
1600 * PARAMETERS
1601 * tvbuff_t *tvb - pointer to buffer containing raw packet.
1602 * packet_into *pinfo - pointer to packet information fields
1603 * proto_tree *tree - pointer to data tree.
1604 * RETURNS
1605 * void
1606 *---------------------------------------------------------------
1608 static int dissect_zbee_apf(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
1610 proto_tree *apf_tree = NULL;
1611 proto_item *proto_root;
1613 guint8 count;
1614 guint8 type;
1615 guint offset = 0;
1616 guint i;
1618 tvbuff_t *app_tvb;
1619 dissector_handle_t app_dissector = NULL;
1620 zbee_nwk_packet *nwk = (zbee_nwk_packet *)data;
1622 if (nwk != NULL)
1623 app_dissector = (dissector_handle_t)(nwk->private_data);
1625 /* Create the tree for the application framework. */
1626 if (tree) {
1627 proto_root = proto_tree_add_protocol_format(tree, proto_zbee_apf, tvb, 0,
1628 tvb_length(tvb), "ZigBee Application Framework");
1629 apf_tree = proto_item_add_subtree(proto_root, ett_zbee_apf);
1632 /* Get the count and type. */
1633 count = zbee_get_bit_field(tvb_get_guint8(tvb, offset), ZBEE_APP_COUNT);
1634 type = zbee_get_bit_field(tvb_get_guint8(tvb, offset), ZBEE_APP_TYPE);
1635 if (tree) {
1636 proto_tree_add_uint(apf_tree, hf_zbee_apf_count, tvb, offset, 1, count);
1637 proto_tree_add_uint(apf_tree, hf_zbee_apf_type, tvb, offset, 1, type);
1639 offset += 1;
1641 /* Ensure the application dissector exists. */
1642 if (app_dissector == NULL) {
1643 /* No dissector for this profile. */
1644 goto dissect_app_end;
1647 /* Handle the transactions. */
1648 for (i=0; i<count; i++) {
1649 guint length;
1651 /* Create a tvb for this transaction. */
1652 length = zbee_apf_transaction_len(tvb, offset, type);
1653 app_tvb = tvb_new_subset(tvb, offset, length, length);
1655 /* Call the application dissector. */
1656 call_dissector_with_data(app_dissector, app_tvb, pinfo, tree, data);
1658 /* Adjust the offset. */
1659 offset += length;
1662 dissect_app_end:
1663 if (offset < tvb_length(tvb)) {
1664 /* There are bytes remaining! */
1665 app_tvb = tvb_new_subset_remaining(tvb, offset);
1666 call_dissector(data_handle, app_tvb, pinfo, tree);
1669 return tvb_length(tvb);
1670 } /* dissect_zbee_apf */
1672 /*FUNCTION:------------------------------------------------------
1673 * NAME
1674 * zbee_apf_transaction_len
1675 * DESCRIPTION
1676 * Peeks into the application framework, and determines the
1677 * length of the transaction. Used only with the kludge that is
1678 * the ZigBee 2004 & earlier application framework.
1679 * PARAMETERS
1680 * tvbuff_t *tvb - packet buffer.
1681 * guint offset - offset into the buffer.
1682 * guint type - message type: KVP or MSG.
1683 * RETURNS
1684 * guint
1685 *---------------------------------------------------------------
1687 static guint
1688 zbee_apf_transaction_len(tvbuff_t *tvb, guint offset, guint8 type)
1690 if (type == ZBEE_APP_TYPE_KVP) {
1691 /* KVP Type. */
1692 /* | 1 Byte | 1 Byte | 2 Bytes | 0/1 Bytes | Variable |
1693 * | SeqNo | Cmd/Data Type | Attribute | Error Code | Data |
1695 guint8 kvp_cmd = zbee_get_bit_field(tvb_get_guint8(tvb, offset+1), ZBEE_APP_KVP_CMD);
1696 guint8 kvp_type = zbee_get_bit_field(tvb_get_guint8(tvb, offset+1), ZBEE_APP_KVP_TYPE);
1697 guint kvp_len = ZBEE_APP_KVP_OVERHEAD;
1699 /* Add the length of the error code, if present. */
1700 switch (kvp_cmd) {
1701 case ZBEE_APP_KVP_SET_RESP:
1702 case ZBEE_APP_KVP_EVENT_RESP:
1703 /* Error Code Present. */
1704 kvp_len += 1;
1705 /* Data Not Present. */
1706 return kvp_len;
1707 case ZBEE_APP_KVP_GET_RESP:
1708 /* Error Code Present. */
1709 kvp_len += 1;
1710 /* Data Present. */
1711 break;
1712 case ZBEE_APP_KVP_SET:
1713 case ZBEE_APP_KVP_SET_ACK:
1714 case ZBEE_APP_KVP_EVENT:
1715 case ZBEE_APP_KVP_EVENT_ACK:
1716 /* No Error Code Present. */
1717 /* Data Present. */
1718 break;
1719 case ZBEE_APP_KVP_GET_ACK:
1720 default:
1721 /* No Error Code Present. */
1722 /* No Data Present. */
1723 return kvp_len;
1724 } /* switch */
1726 /* Add the length of the data. */
1727 switch (kvp_type) {
1728 case ZBEE_APP_KVP_ABS_TIME:
1729 case ZBEE_APP_KVP_REL_TIME:
1730 kvp_len += 4;
1731 break;
1732 case ZBEE_APP_KVP_UINT16:
1733 case ZBEE_APP_KVP_INT16:
1734 case ZBEE_APP_KVP_FLOAT16:
1735 kvp_len += 2;
1736 break;
1737 case ZBEE_APP_KVP_UINT8:
1738 case ZBEE_APP_KVP_INT8:
1739 kvp_len += 1;
1740 break;
1741 case ZBEE_APP_KVP_CHAR_STRING:
1742 case ZBEE_APP_KVP_OCT_STRING:
1743 /* Variable Length Types, first byte is the length-1 */
1744 kvp_len += tvb_get_guint8(tvb, offset+kvp_len)+1;
1745 break;
1746 case ZBEE_APP_KVP_NO_DATA:
1747 default:
1748 break;
1749 } /* switch */
1751 return kvp_len;
1753 else {
1754 /* Message Type. */
1755 /* | 1 Byte | 1 Byte | Length Bytes |
1756 * | SeqNo | Length | Message |
1758 return (tvb_get_guint8(tvb, offset+1) + 2);
1760 } /* zbee_apf_transaction_len */
1762 /*FUNCTION:------------------------------------------------------
1763 * NAME
1764 * proto_register_zbee_aps
1765 * DESCRIPTION
1766 * ZigBee APS protocol registration routine.
1767 * PARAMETERS
1768 * none
1769 * RETURNS
1770 * void
1771 *---------------------------------------------------------------
1773 void proto_register_zbee_aps(void)
1775 static hf_register_info hf[] = {
1776 { &hf_zbee_aps_fcf_frame_type,
1777 { "Frame Type", "zbee_aps.type", FT_UINT8, BASE_HEX, VALS(zbee_aps_frame_types), ZBEE_APS_FCF_FRAME_TYPE,
1778 NULL, HFILL }},
1780 { &hf_zbee_aps_fcf_delivery,
1781 { "Delivery Mode", "zbee_aps.delivery", FT_UINT8, BASE_HEX, VALS(zbee_aps_delivery_modes), ZBEE_APS_FCF_DELIVERY_MODE,
1782 NULL, HFILL }},
1784 { &hf_zbee_aps_fcf_indirect_mode,
1785 { "Indirect Address Mode", "zbee_aps.indirect_mode", FT_BOOLEAN, 8, NULL, ZBEE_APS_FCF_INDIRECT_MODE,
1786 NULL, HFILL }},
1788 { &hf_zbee_aps_fcf_ack_format,
1789 { "Acknowledgement Format", "zbee_aps.ack_format", FT_BOOLEAN, 8, NULL, ZBEE_APS_FCF_ACK_FORMAT,
1790 NULL, HFILL }},
1792 { &hf_zbee_aps_fcf_security,
1793 { "Security", "zbee_aps.security", FT_BOOLEAN, 8, NULL, ZBEE_APS_FCF_SECURITY,
1794 "Whether security operations are performed on the APS payload.", HFILL }},
1796 { &hf_zbee_aps_fcf_ack_req,
1797 { "Acknowledgement Request","zbee_aps.ack_req", FT_BOOLEAN, 8, NULL, ZBEE_APS_FCF_ACK_REQ,
1798 "Flag requesting an acknowledgement frame for this packet.", HFILL }},
1800 { &hf_zbee_aps_fcf_ext_header,
1801 { "Extended Header", "zbee_aps.ext_header", FT_BOOLEAN, 8, NULL, ZBEE_APS_FCF_EXT_HEADER,
1802 NULL, HFILL }},
1804 { &hf_zbee_aps_dst,
1805 { "Destination Endpoint", "zbee_aps.dst", FT_UINT8, BASE_DEC, NULL, 0x0,
1806 NULL, HFILL }},
1808 { &hf_zbee_aps_group,
1809 { "Group", "zbee_aps.group", FT_UINT16, BASE_HEX, NULL, 0x0,
1810 NULL, HFILL }},
1812 { &hf_zbee_aps_cluster,
1813 { "Cluster", "zbee_aps.cluster", FT_UINT16, BASE_HEX,
1814 VALS(zbee_aps_cid_names), 0x0, NULL, HFILL }},
1816 { &hf_zbee_aps_profile,
1817 { "Profile", "zbee_aps.profile", FT_UINT16, BASE_HEX | BASE_RANGE_STRING,
1818 RVALS(zbee_aps_apid_names), 0x0, NULL, HFILL }},
1820 { &hf_zbee_aps_src,
1821 { "Source Endpoint", "zbee_aps.src", FT_UINT8, BASE_DEC, NULL, 0x0,
1822 NULL, HFILL }},
1824 { &hf_zbee_aps_counter,
1825 { "Counter", "zbee_aps.counter", FT_UINT8, BASE_DEC, NULL, 0x0,
1826 NULL, HFILL }},
1828 { &hf_zbee_aps_fragmentation,
1829 { "Fragmentation", "zbee_aps.fragmentation", FT_UINT8, BASE_HEX, VALS(zbee_aps_fragmentation_modes), ZBEE_APS_EXT_FCF_FRAGMENT,
1830 NULL, HFILL }},
1832 { &hf_zbee_aps_block_number,
1833 { "Block Number", "zbee_aps.block", FT_UINT8, BASE_DEC, NULL, 0x0,
1834 "A block identifier within a fragmented transmission, or the number of expected blocks if the first block.", HFILL }},
1836 { &hf_zbee_aps_cmd_id,
1837 { "Command Identifier", "zbee_aps.cmd.id", FT_UINT8, BASE_HEX, VALS(zbee_aps_cmd_names), 0x0,
1838 NULL, HFILL }},
1840 { &hf_zbee_aps_cmd_initiator,
1841 { "Initiator Address", "zbee_aps.cmd.initiator", FT_EUI64, BASE_NONE, NULL, 0x0,
1842 "The extended address of the device to initiate the SKKE procedure", HFILL }},
1844 { &hf_zbee_aps_cmd_responder,
1845 { "Responder Address", "zbee_aps.cmd.responder", FT_EUI64, BASE_NONE, NULL, 0x0,
1846 "The extended address of the device responding to the SKKE procedure", HFILL }},
1848 { &hf_zbee_aps_cmd_partner,
1849 { "Partner Address", "zbee_aps.cmd.partner", FT_EUI64, BASE_NONE, NULL, 0x0,
1850 "The partner to use this key with for link-level security.", HFILL }},
1852 { &hf_zbee_aps_cmd_initiator_flag,
1853 { "Initiator", "zbee_aps.cmd.init_flag", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
1854 "Inidicates the destination of the transport-key command requested this key.", HFILL }},
1856 { &hf_zbee_aps_cmd_device,
1857 { "Device Address", "zbee_aps.cmd.device", FT_EUI64, BASE_NONE, NULL, 0x0,
1858 "The device whose status is being updated.", HFILL }},
1860 { &hf_zbee_aps_cmd_challenge,
1861 { "Challenge", "zbee_aps.cmd.challenge", FT_BYTES, BASE_NONE, NULL, 0x0,
1862 "Random challenge value used during SKKE and authentication.", HFILL }},
1864 { &hf_zbee_aps_cmd_mac,
1865 { "Message Authentication Code", "zbee_aps.cmd.mac", FT_BYTES, BASE_NONE, NULL, 0x0,
1866 "Message authentication values used during SKKE and authentication.", HFILL }},
1868 { &hf_zbee_aps_cmd_key,
1869 { "Key", "zbee_aps.cmd.key", FT_BYTES, BASE_NONE, NULL, 0x0,
1870 NULL, HFILL }},
1872 { &hf_zbee_aps_cmd_key_type,
1873 { "Key Type", "zbee_aps.cmd.key_type", FT_UINT8, BASE_HEX,
1874 VALS(zbee_aps_key_names), 0x0, NULL, HFILL }},
1876 { &hf_zbee_aps_cmd_dst,
1877 { "Extended Destination", "zbee_aps.cmd.dst", FT_EUI64, BASE_NONE, NULL, 0x0,
1878 NULL, HFILL }},
1880 { &hf_zbee_aps_cmd_src,
1881 { "Extended Source", "zbee_aps.cmd.src", FT_EUI64, BASE_NONE, NULL, 0x0,
1882 NULL, HFILL }},
1884 { &hf_zbee_aps_cmd_seqno,
1885 { "Sequence Number", "zbee_aps.cmd.seqno", FT_UINT8, BASE_DEC, NULL, 0x0,
1886 "The key sequence number associated with the network key.", HFILL }},
1888 { &hf_zbee_aps_cmd_short_addr,
1889 { "Device Address", "zbee_aps.cmd.addr", FT_UINT16, BASE_HEX, NULL, 0x0,
1890 "The device whose status is being updated.", HFILL }},
1892 { &hf_zbee_aps_cmd_device_status,
1893 { "Device Status", "zbee_aps.cmd.status", FT_UINT8, BASE_HEX,
1894 VALS(zbee_aps_update_status_names), 0x0,
1895 "Update device status.", HFILL }},
1897 { &hf_zbee_aps_cmd_ea_key_type,
1898 { "Key Type", "zbee_aps.cmd.ea.key_type", FT_UINT8, BASE_HEX,
1899 VALS(zbee_aps_ea_key_names), 0x0,
1900 NULL, HFILL }},
1902 { &hf_zbee_aps_cmd_ea_data,
1903 { "Data", "zbee_aps.cmd.ea.data", FT_BYTES, BASE_NONE, NULL, 0x0,
1904 "Additional data used in entity authentication. Typically this will be the outgoing frame counter associated with the key used for entity authentication.", HFILL }},
1906 { &hf_zbee_aps_fragments,
1907 { "Message fragments", "zbee_aps.fragments", FT_NONE, BASE_NONE, NULL, 0x0,
1908 NULL, HFILL }},
1910 { &hf_zbee_aps_fragment,
1911 { "Message fragment", "zbee_aps.fragment", FT_FRAMENUM, BASE_NONE, NULL, 0x0,
1912 NULL, HFILL }},
1914 { &hf_zbee_aps_fragment_overlap,
1915 { "Message fragment overlap", "zbee_aps.fragment.overlap", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
1916 NULL, HFILL }},
1918 { &hf_zbee_aps_fragment_overlap_conflicts,
1919 { "Message fragment overlapping with conflicting data", "zbee_aps.fragment.overlap.conflicts", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
1920 NULL, HFILL }},
1922 { &hf_zbee_aps_fragment_multiple_tails,
1923 { "Message has multiple tail fragments", "zbee_aps.fragment.multiple_tails", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
1924 NULL, HFILL }},
1926 { &hf_zbee_aps_fragment_too_long_fragment,
1927 { "Message fragment too long", "zbee_aps.fragment.too_long_fragment", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
1928 NULL, HFILL }},
1930 { &hf_zbee_aps_fragment_error,
1931 { "Message defragmentation error", "zbee_aps.fragment.error", FT_FRAMENUM, BASE_NONE, NULL, 0x0,
1932 NULL, HFILL }},
1934 { &hf_zbee_aps_fragment_count,
1935 { "Message fragment count", "zbee_aps.fragment.count", FT_UINT32, BASE_DEC, NULL, 0x0,
1936 NULL, HFILL }},
1938 { &hf_zbee_aps_reassembled_in,
1939 { "Reassembled in", "zbee_aps.reassembled.in", FT_FRAMENUM, BASE_NONE, NULL, 0x0,
1940 NULL, HFILL }},
1942 { &hf_zbee_aps_reassembled_length,
1943 { "Reassembled ZigBee APS length", "zbee_aps.reassembled.length", FT_UINT32, BASE_DEC, NULL, 0x0,
1944 NULL, HFILL }}
1947 static hf_register_info hf_apf[] = {
1948 { &hf_zbee_apf_count,
1949 { "Count", "zbee_apf.count", FT_UINT8, BASE_DEC, NULL, 0x0,
1950 NULL, HFILL }},
1952 { &hf_zbee_apf_type,
1953 { "Type", "zbee_apf.type", FT_UINT8, BASE_HEX,
1954 VALS(zbee_apf_type_names), 0x0, NULL, HFILL }}
1957 /* APS subtrees */
1958 static gint *ett[] = {
1959 &ett_zbee_aps,
1960 &ett_zbee_aps_fcf,
1961 &ett_zbee_aps_ext,
1962 &ett_zbee_aps_cmd,
1963 &ett_zbee_aps_fragment,
1964 &ett_zbee_aps_fragments
1967 static gint *ett_apf[] = {
1968 &ett_zbee_apf
1971 static ei_register_info ei[] = {
1972 { &ei_zbee_aps_invalid_delivery_mode, { "zbee_aps.invalid_delivery_mode", PI_PROTOCOL, PI_WARN, "Invalid Delivery Mode", EXPFILL }},
1973 { &ei_zbee_aps_missing_payload, { "zbee_aps.missing_payload", PI_MALFORMED, PI_ERROR, "Missing Payload", EXPFILL }},
1976 expert_module_t* expert_zbee_aps;
1978 /* Register ZigBee APS protocol with Wireshark. */
1979 proto_zbee_aps = proto_register_protocol("ZigBee Application Support Layer", "ZigBee APS", ZBEE_PROTOABBREV_APS);
1980 proto_register_field_array(proto_zbee_aps, hf, array_length(hf));
1981 proto_register_subtree_array(ett, array_length(ett));
1982 expert_zbee_aps = expert_register_protocol(proto_zbee_aps);
1983 expert_register_field_array(expert_zbee_aps, ei, array_length(ei));
1985 /* Register the APS dissector and subdissector list. */
1986 zbee_aps_dissector_table = register_dissector_table("zbee.profile", "ZigBee Profile ID", FT_UINT16, BASE_HEX);
1987 zbee_aps_handle = new_register_dissector(ZBEE_PROTOABBREV_APS, dissect_zbee_aps, proto_zbee_aps);
1989 /* Register the init routine. */
1990 register_init_routine(proto_init_zbee_aps);
1992 /* Register the ZigBee Application Framework protocol with Wireshark. */
1993 proto_zbee_apf = proto_register_protocol("ZigBee Application Framework", "ZigBee APF", ZBEE_PROTOABBREV_APF);
1994 proto_register_field_array(proto_zbee_apf, hf_apf, array_length(hf_apf));
1995 proto_register_subtree_array(ett_apf, array_length(ett_apf));
1997 /* Register the App dissector. */
1998 zbee_apf_handle = new_register_dissector(ZBEE_PROTOABBREV_APF, dissect_zbee_apf, proto_zbee_apf);
1999 } /* proto_register_zbee_aps */
2001 /*FUNCTION:------------------------------------------------------
2002 * NAME
2003 * proto_reg_handoff_zbee_aps
2004 * DESCRIPTION
2005 * Registers the zigbee APS dissector with Wireshark.
2006 * PARAMETERS
2007 * none
2008 * RETURNS
2009 * void
2010 *---------------------------------------------------------------
2012 void proto_reg_handoff_zbee_aps(void)
2014 /* Find the other dissectors we need. */
2015 data_handle = find_dissector("data");
2016 } /* proto_reg_handoff_zbee_aps */
2018 /*FUNCTION:------------------------------------------------------
2019 * NAME
2020 * proto_init_zbee_aps
2021 * DESCRIPTION
2022 * Initializes the APS dissectors prior to beginning protocol
2023 * dissection.
2024 * PARAMETERS
2025 * none
2026 * RETURNS
2027 * void
2028 *---------------------------------------------------------------
2030 static void proto_init_zbee_aps(void)
2032 reassembly_table_init(&zbee_aps_reassembly_table,
2033 &addresses_reassembly_table_functions);
2034 } /* proto_init_zbee_aps */