2 * Dissector routines for the ZigBee Cluster Library (ZCL)
3 * By Fred Fierling <fff@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 * Used Owen Kirby's packet-zbee-aps module as a template. Based
13 * on ZigBee Cluster Library Specification document 075123r02ZB
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
33 #endif /* HAVEHCONFIG_H */
37 #include <epan/packet.h>
39 #include "packet-zbee.h"
40 #include "packet-zbee-zcl.h"
42 /*************************
43 * Function Declarations *
44 *************************
46 /* Dissector Routines */
47 static void dissect_zbee_zcl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
49 /* Command Dissector Helpers */
50 static void dissect_zcl_read_attr (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint *offset);
51 static void dissect_zcl_read_attr_resp (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
53 static void dissect_zcl_write_attr (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint *offset);
54 static void dissect_zcl_write_attr_resp (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
56 static void dissect_zcl_config_report (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint *offset);
57 static void dissect_zcl_config_report_resp (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
59 static void dissect_zcl_read_report_config (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
61 static void dissect_zcl_read_report_config_resp (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
63 static void dissect_zcl_default_resp (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint *offset);
64 static void dissect_zcl_discover_attr (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint *offset);
65 static void dissect_zcl_discover_attr_resp (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
69 guint zbee_apf_transaction_len (tvbuff_t *tvb, guint offset, guint8 type);
70 static void dissect_zcl_attr_data_type_val (tvbuff_t *tvb, proto_tree *tree, guint *offset);
72 static guint dissect_zcl_attr_data_type (tvbuff_t *tvb, proto_tree *tree, guint *offset);
74 static void dissect_zcl_attr_data (tvbuff_t *tvb, proto_tree *tree, guint *offset, guint data_type);
75 static void dissect_zcl_attr_bytes (tvbuff_t *tvb, proto_tree *tree, guint *offset, guint length);
76 static guint dissect_zcl_attr_uint8 (tvbuff_t *tvb, proto_tree *tree, guint *offset, int *length);
77 static guint dissect_zcl_attr_uint16 (tvbuff_t *tvb, proto_tree *tree, guint *offset, int *length);
78 static void dissect_zcl_attr_id (tvbuff_t *tvb, proto_tree *tree, guint *offset);
79 static void dissect_zcl_big_int (tvbuff_t *tvb, proto_tree *tree, guint *offset, guint length,
80 gboolean signed_flag);
81 static void zcl_dump_data(tvbuff_t *tvb, guint offset, packet_info *pinfo, proto_tree *tree);
83 static guint64 tvb_get_letohi (tvbuff_t *tvb, guint offset, guint length, gboolean signed_flag);
89 /* Header Field Indices. */
90 static int proto_zbee_zcl = -1;
91 static int hf_zbee_zcl_fcf_frame_type = -1;
92 static int hf_zbee_zcl_fcf_mfr_spec = -1;
93 static int hf_zbee_zcl_fcf_dir = -1;
94 static int hf_zbee_zcl_fcf_disable_default_resp = -1;
95 static int hf_zbee_zcl_mfr_code = -1;
96 static int hf_zbee_zcl_tran_seqno = -1;
98 static int hf_zbee_zcl_cmd_id = -1;
99 static int hf_zbee_zcl_cs_cmd_id = -1;
100 static int hf_zbee_zcl_attr_id = -1;
101 static int hf_zbee_zcl_attr_data_type = -1;
102 static int hf_zbee_zcl_attr_boolean = -1;
103 static int hf_zbee_zcl_attr_uint8 = -1;
104 static int hf_zbee_zcl_attr_uint16 = -1;
105 static int hf_zbee_zcl_attr_uint24 = -1;
106 static int hf_zbee_zcl_attr_uint32 = -1;
107 static int hf_zbee_zcl_attr_uint64 = -1;
108 static int hf_zbee_zcl_attr_int8 = -1;
109 static int hf_zbee_zcl_attr_int16 = -1;
110 static int hf_zbee_zcl_attr_int24 = -1;
111 static int hf_zbee_zcl_attr_int32 = -1;
112 static int hf_zbee_zcl_attr_int64 = -1;
113 static int hf_zbee_zcl_attr_semi = -1;
114 static int hf_zbee_zcl_attr_float = -1;
115 static int hf_zbee_zcl_attr_double = -1;
116 static int hf_zbee_zcl_attr_bytes = -1;
117 static int hf_zbee_zcl_attr_minint = -1;
118 static int hf_zbee_zcl_attr_maxint = -1;
119 static int hf_zbee_zcl_attr_timeout = -1;
120 static int hf_zbee_zcl_attr_cid = -1;
121 static int hf_zbee_zcl_attr_hours = -1;
122 static int hf_zbee_zcl_attr_mins = -1;
123 static int hf_zbee_zcl_attr_secs = -1;
124 static int hf_zbee_zcl_attr_csecs = -1;
125 static int hf_zbee_zcl_attr_yy = -1;
126 static int hf_zbee_zcl_attr_mm = -1;
127 static int hf_zbee_zcl_attr_md = -1;
128 static int hf_zbee_zcl_attr_wd = -1;
129 static int hf_zbee_zcl_attr_utc = -1;
130 static int hf_zbee_zcl_attr_status = -1;
131 static int hf_zbee_zcl_attr_dir = -1;
132 static int hf_zbee_zcl_attr_dis = -1;
133 static int hf_zbee_zcl_attr_start = -1;
134 static int hf_zbee_zcl_attr_maxnum = -1;
135 static int hf_zbee_zcl_attr_str_len = -1;
136 static int hf_zbee_zcl_attr_str = -1;
137 static int hf_zbee_zcl_attr_ostr = -1;
139 /* Subtree indices. */
140 static gint ett_zbee_zcl = -1;
141 static gint ett_zbee_zcl_fcf = -1;
142 static gint ett_zbee_zcl_attr[ZBEE_ZCL_NUM_ATTR_ETT];
144 /* Dissector Handles. */
145 static dissector_handle_t data_handle;
147 /********************/
149 /********************/
150 /* Frame Type Names */
151 static const value_string zbee_zcl_frame_types[] = {
152 { ZBEE_ZCL_FCF_PROFILE_WIDE, "Profile-wide" },
153 { ZBEE_ZCL_FCF_CLUSTER_SPEC, "Cluster-specific" },
157 /* ZCL Command Names */
158 static const value_string zbee_zcl_cmd_names[] = {
159 { ZBEE_ZCL_CMD_READ_ATTR, "Read Attributes" },
160 { ZBEE_ZCL_CMD_READ_ATTR_RESP, "Read Attributes Response" },
161 { ZBEE_ZCL_CMD_WRITE_ATTR, "Write Attributes" },
162 { ZBEE_ZCL_CMD_WRITE_ATTR_UNDIVIDED, "Write Attributes Undivided" },
163 { ZBEE_ZCL_CMD_WRITE_ATTR_RESP, "Write Attributes Response" },
164 { ZBEE_ZCL_CMD_WRITE_ATTR_NO_RESP, "Write Attributes No Response" },
165 { ZBEE_ZCL_CMD_CONFIG_REPORT, "Configure Reporting" },
166 { ZBEE_ZCL_CMD_CONFIG_REPORT_RESP, "Configure Reporting Response" },
167 { ZBEE_ZCL_CMD_READ_REPORT_CONFIG, "Read Reporting Configuration" },
168 { ZBEE_ZCL_CMD_READ_REPORT_CONFIG_RESP, "Read Reporting Configuration Response" },
169 { ZBEE_ZCL_CMD_REPORT_ATTR, "Report Attributes" },
170 { ZBEE_ZCL_CMD_DEFAULT_RESP, "Default Response" },
171 { ZBEE_ZCL_CMD_DISCOVER_ATTR, "Discover Attributes" },
172 { ZBEE_ZCL_CMD_DISCOVER_ATTR_RESP, "Discover Attributes Response" },
173 { ZBEE_ZCL_CMD_READ_ATTR_STRUCT, "Read Attributes Structured" },
174 { ZBEE_ZCL_CMD_WRITE_ATTR_STRUCT, "Write Attributes Structured" },
175 { ZBEE_ZCL_CMD_WRITE_ATTR_STRUCT_RESP, "Write Attributes Structured Response" },
180 /* ZCL Cluster-Specific Command Names */
181 static const value_string zbee_zcl_cs_cmd_names[] = {
186 /* Manufacturer Name Table */
187 static const value_string zbee_mfr_code_names[] = {
189 { ZBEE_MFG_CODE_CIRRONET, ZBEE_MFG_CIRRONET },
190 { ZBEE_MFG_CODE_CHIPCON, ZBEE_MFG_CHIPCON },
191 { ZBEE_MFG_CODE_EMBER, ZBEE_MFG_EMBER },
192 { ZBEE_MFG_CODE_NTS, ZBEE_MFG_NTS },
193 { ZBEE_MFG_CODE_FREESCALE, ZBEE_MFG_FREESCALE },
194 { ZBEE_MFG_CODE_IPCOM, ZBEE_MFG_IPCOM },
195 { ZBEE_MFG_CODE_SAN_JUAN, ZBEE_MFG_SAN_JUAN },
196 { ZBEE_MFG_CODE_TUV, ZBEE_MFG_TUV },
197 { ZBEE_MFG_CODE_COMPXS, ZBEE_MFG_COMPXS },
198 { ZBEE_MFG_CODE_BM, ZBEE_MFG_BM },
199 { ZBEE_MFG_CODE_AWAREPOINT, ZBEE_MFG_AWAREPOINT },
200 { ZBEE_MFG_CODE_PHILIPS, ZBEE_MFG_PHILIPS },
201 { ZBEE_MFG_CODE_LUXOFT, ZBEE_MFG_LUXOFT },
202 { ZBEE_MFG_CODE_KORWIN, ZBEE_MFG_KORWIN },
203 { ZBEE_MFG_CODE_1_RF, ZBEE_MFG_1_RF },
204 { ZBEE_MFG_CODE_STG, ZBEE_MFG_STG },
205 { ZBEE_MFG_CODE_TELEGESIS, ZBEE_MFG_TELEGESIS },
206 { ZBEE_MFG_CODE_VISIONIC, ZBEE_MFG_VISIONIC },
207 { ZBEE_MFG_CODE_INSTA, ZBEE_MFG_INSTA },
208 { ZBEE_MFG_CODE_ATALUM, ZBEE_MFG_ATALUM },
209 { ZBEE_MFG_CODE_ATMEL, ZBEE_MFG_ATMEL },
210 { ZBEE_MFG_CODE_DEVELCO, ZBEE_MFG_DEVELCO },
211 { ZBEE_MFG_CODE_HONEYWELL, ZBEE_MFG_HONEYWELL },
213 { ZBEE_MFG_CODE_RENESAS, ZBEE_MFG_RENESAS },
214 { ZBEE_MFG_CODE_XANADU, ZBEE_MFG_XANADU },
215 { ZBEE_MFG_CODE_NEC, ZBEE_MFG_NEC },
216 { ZBEE_MFG_CODE_YAMATAKE, ZBEE_MFG_YAMATAKE },
217 { ZBEE_MFG_CODE_TENDRIL, ZBEE_MFG_TENDRIL },
218 { ZBEE_MFG_CODE_ASSA, ZBEE_MFG_ASSA },
219 { ZBEE_MFG_CODE_MAXSTREAM, ZBEE_MFG_MAXSTREAM },
220 { ZBEE_MFG_CODE_NEUROCOM, ZBEE_MFG_NEUROCOM },
222 { ZBEE_MFG_CODE_III, ZBEE_MFG_III },
223 { ZBEE_MFG_CODE_VANTAGE, ZBEE_MFG_VANTAGE },
224 { ZBEE_MFG_CODE_ICONTROL, ZBEE_MFG_ICONTROL },
225 { ZBEE_MFG_CODE_RAYMARINE, ZBEE_MFG_RAYMARINE },
226 { ZBEE_MFG_CODE_LSR, ZBEE_MFG_LSR },
227 { ZBEE_MFG_CODE_ONITY, ZBEE_MFG_ONITY },
228 { ZBEE_MFG_CODE_MONO, ZBEE_MFG_MONO },
229 { ZBEE_MFG_CODE_RFT, ZBEE_MFG_RFT },
230 { ZBEE_MFG_CODE_ITRON, ZBEE_MFG_ITRON },
231 { ZBEE_MFG_CODE_TRITECH, ZBEE_MFG_TRITECH },
232 { ZBEE_MFG_CODE_EMBEDIT, ZBEE_MFG_EMBEDIT },
233 { ZBEE_MFG_CODE_S3C, ZBEE_MFG_S3C },
234 { ZBEE_MFG_CODE_SIEMENS, ZBEE_MFG_SIEMENS },
235 { ZBEE_MFG_CODE_MINDTECH, ZBEE_MFG_MINDTECH },
236 { ZBEE_MFG_CODE_LGE, ZBEE_MFG_LGE },
237 { ZBEE_MFG_CODE_MITSUBISHI, ZBEE_MFG_MITSUBISHI },
239 { ZBEE_MFG_CODE_JOHNSON, ZBEE_MFG_JOHNSON },
240 { ZBEE_MFG_CODE_PRI, ZBEE_MFG_PRI },
241 { ZBEE_MFG_CODE_KNICK, ZBEE_MFG_KNICK },
242 { ZBEE_MFG_CODE_VICONICS, ZBEE_MFG_VICONICS },
243 { ZBEE_MFG_CODE_FLEXIPANEL, ZBEE_MFG_FLEXIPANEL },
245 { ZBEE_MFG_CODE_TRANE, ZBEE_MFG_TRANE },
246 { ZBEE_MFG_CODE_JENNIC, ZBEE_MFG_JENNIC },
247 { ZBEE_MFG_CODE_LIG, ZBEE_MFG_LIG },
248 { ZBEE_MFG_CODE_ALERTME, ZBEE_MFG_ALERTME },
249 { ZBEE_MFG_CODE_DAINTREE, ZBEE_MFG_DAINTREE },
250 { ZBEE_MFG_CODE_AIJI, ZBEE_MFG_AIJI },
251 { ZBEE_MFG_CODE_TEL_ITALIA, ZBEE_MFG_TEL_ITALIA },
252 { ZBEE_MFG_CODE_MIKROKRETS, ZBEE_MFG_MIKROKRETS },
253 { ZBEE_MFG_CODE_OKI, ZBEE_MFG_OKI },
254 { ZBEE_MFG_CODE_NEWPORT, ZBEE_MFG_NEWPORT },
256 { ZBEE_MFG_CODE_C4, ZBEE_MFG_C4 },
257 { ZBEE_MFG_CODE_STM, ZBEE_MFG_STM },
258 { ZBEE_MFG_CODE_ASN, ZBEE_MFG_ASN },
259 { ZBEE_MFG_CODE_DCSI, ZBEE_MFG_DCSI },
260 { ZBEE_MFG_CODE_FRANCE_TEL, ZBEE_MFG_FRANCE_TEL },
261 { ZBEE_MFG_CODE_MUNET, ZBEE_MFG_MUNET },
262 { ZBEE_MFG_CODE_AUTANI, ZBEE_MFG_AUTANI },
263 { ZBEE_MFG_CODE_COL_VNET, ZBEE_MFG_COL_VNET },
264 { ZBEE_MFG_CODE_AEROCOMM, ZBEE_MFG_AEROCOMM },
265 { ZBEE_MFG_CODE_SI_LABS, ZBEE_MFG_SI_LABS },
266 { ZBEE_MFG_CODE_INNCOM, ZBEE_MFG_INNCOM },
267 { ZBEE_MFG_CODE_CANNON, ZBEE_MFG_CANNON },
268 { ZBEE_MFG_CODE_SYNAPSE, ZBEE_MFG_SYNAPSE },
269 { ZBEE_MFG_CODE_FPS, ZBEE_MFG_FPS },
270 { ZBEE_MFG_CODE_CLS, ZBEE_MFG_CLS },
271 { ZBEE_MFG_CODE_CRANE, ZBEE_MFG_CRANE },
273 { ZBEE_MFG_CODE_MOBILARM, ZBEE_MFG_MOBILARM },
274 { ZBEE_MFG_CODE_IMONITOR, ZBEE_MFG_IMONITOR },
275 { ZBEE_MFG_CODE_BARTECH, ZBEE_MFG_BARTECH },
276 { ZBEE_MFG_CODE_MESHNETICS, ZBEE_MFG_MESHNETICS },
277 { ZBEE_MFG_CODE_LS_IND, ZBEE_MFG_LS_IND },
278 { ZBEE_MFG_CODE_CASON, ZBEE_MFG_CASON },
279 { ZBEE_MFG_CODE_WLESS_GLUE, ZBEE_MFG_WLESS_GLUE },
280 { ZBEE_MFG_CODE_ELSTER, ZBEE_MFG_ELSTER },
281 { ZBEE_MFG_CODE_SMS_TEC, ZBEE_MFG_SMS_TEC },
282 { ZBEE_MFG_CODE_ONSET, ZBEE_MFG_ONSET },
283 { ZBEE_MFG_CODE_RIGA, ZBEE_MFG_RIGA },
284 { ZBEE_MFG_CODE_ENERGATE, ZBEE_MFG_ENERGATE },
285 { ZBEE_MFG_CODE_CONMED, ZBEE_MFG_CONMED },
286 { ZBEE_MFG_CODE_POWERMAND, ZBEE_MFG_POWERMAND },
287 { ZBEE_MFG_CODE_SCHNEIDER, ZBEE_MFG_SCHNEIDER },
288 { ZBEE_MFG_CODE_EATON, ZBEE_MFG_EATON },
290 { ZBEE_MFG_CODE_TELULAR, ZBEE_MFG_TELULAR },
291 { ZBEE_MFG_CODE_DELPHI, ZBEE_MFG_DELPHI },
292 { ZBEE_MFG_CODE_EPISENSOR, ZBEE_MFG_EPISENSOR },
293 { ZBEE_MFG_CODE_LANDIS_GYR, ZBEE_MFG_LANDIS_GYR },
294 { ZBEE_MFG_CODE_KABA, ZBEE_MFG_KABA },
295 { ZBEE_MFG_CODE_SHURE, ZBEE_MFG_SHURE },
296 { ZBEE_MFG_CODE_COMVERGE, ZBEE_MFG_COMVERGE },
298 { ZBEE_MFG_CODE_HIDALGO, ZBEE_MFG_HIDALGO },
299 { ZBEE_MFG_CODE_AIR2APP, ZBEE_MFG_AIR2APP },
300 { ZBEE_MFG_CODE_AMX, ZBEE_MFG_AMX },
301 { ZBEE_MFG_CODE_EDMI, ZBEE_MFG_EDMI },
302 { ZBEE_MFG_CODE_CYAN, ZBEE_MFG_CYAN },
303 { ZBEE_MFG_CODE_SYS_SPA, ZBEE_MFG_SYS_SPA },
304 { ZBEE_MFG_CODE_TELIT, ZBEE_MFG_TELIT },
306 { ZBEE_MFG_CODE_KAGA, ZBEE_MFG_KAGA },
307 { ZBEE_MFG_CODE_4_NOKS, ZBEE_MFG_4_NOKS },
311 /* ZCL Attribute Status Names */
312 static const value_string zbee_zcl_status_names[] = {
313 { ZBEE_ZCL_STAT_SUCCESS, "Success"},
314 { ZBEE_ZCL_STAT_FAILURE, "Failure"},
316 { ZBEE_ZCL_STAT_NOT_AUTHORIZED, "Not Authorized"},
317 { ZBEE_ZCL_STAT_RESERVED_FIELD_NOT_ZERO, "Reserved Field Not Zero"},
318 { ZBEE_ZCL_STAT_MALFORMED_CMD, "Malformed Command"},
319 { ZBEE_ZCL_STAT_UNSUP_CLUSTER_CMD, "Unsupported Cluster Command"},
320 { ZBEE_ZCL_STAT_UNSUP_GENERAL_CMD, "Unsupported General Command"},
321 { ZBEE_ZCL_STAT_UNSUP_MFR_CLUSTER_CMD, "Unsupported Manufacturer Cluster Command"},
322 { ZBEE_ZCL_STAT_UNSUP_MFR_GENERAL_CMD, "Unsupported Manufacturer General Command"},
323 { ZBEE_ZCL_STAT_INVALID_FIELD, "Invalid Field"},
324 { ZBEE_ZCL_STAT_UNSUPPORTED_ATTR, "Unsupported Attribute"},
325 { ZBEE_ZCL_STAT_INSUFFICIENT_SPACE, "Insufficient Space"},
326 { ZBEE_ZCL_STAT_DUPLICATE_EXISTS, "Duplicate Exists"},
327 { ZBEE_ZCL_STAT_NOT_FOUND, "Not Found"},
328 { ZBEE_ZCL_STAT_UNREPORTABLE_ATTR, "Unreportable Attribute"},
329 { ZBEE_ZCL_STAT_INVALID_DATA_TYPE, "Invalid Data Type"},
330 { ZBEE_ZCL_STAT_INVALID_SELECTOR, "Invalid Selector"},
331 { ZBEE_ZCL_STAT_WRITE_ONLY, "Write Only"},
332 { ZBEE_ZCL_STAT_INCONSISTENT_STARTUP_STATE, "Inconsistent Startup State"},
333 { ZBEE_ZCL_STAT_DEFINED_OUT_OF_BAND, "Defined Out of Band"},
334 { ZBEE_ZCL_STAT_HARDWARE_FAILURE, "Hardware Failure"},
335 { ZBEE_ZCL_STAT_SOFTWARE_FAILURE, "Software Failure"},
337 { ZBEE_ZCL_STAT_CALIBRATION_ERROR, "Calibration Error"},
338 { ZBEE_ZCL_STAT_INVALID_VALUE, "Invalid Value"},
339 { ZBEE_ZCL_STAT_READ_ONLY, "Read Only"},
344 /* ZCL Attribute Data Names */
345 static const value_string zbee_zcl_data_type_names[] = {
346 { ZBEE_ZCL_NO_DATA, "No Data" },
347 { ZBEE_ZCL_8_BIT_DATA, "8-Bit Data" },
348 { ZBEE_ZCL_16_BIT_DATA, "16-Bit Data" },
349 { ZBEE_ZCL_24_BIT_DATA, "24-Bit Data" },
350 { ZBEE_ZCL_32_BIT_DATA, "32-Bit Data" },
351 { ZBEE_ZCL_40_BIT_DATA, "40-Bit Data" },
352 { ZBEE_ZCL_48_BIT_DATA, "48-Bit Data" },
353 { ZBEE_ZCL_56_BIT_DATA, "56-Bit Data" },
354 { ZBEE_ZCL_64_BIT_DATA, "64-Bit Data" },
356 { ZBEE_ZCL_BOOLEAN, "Boolean" },
358 { ZBEE_ZCL_8_BIT_BITMAP, "8-Bit Bitmap" },
359 { ZBEE_ZCL_16_BIT_BITMAP, "16-Bit Bitmap" },
360 { ZBEE_ZCL_24_BIT_BITMAP, "24-Bit Bitmap" },
361 { ZBEE_ZCL_32_BIT_BITMAP, "32-Bit Bitmap" },
362 { ZBEE_ZCL_40_BIT_BITMAP, "40-Bit Bitmap" },
363 { ZBEE_ZCL_48_BIT_BITMAP, "48-Bit Bitmap" },
364 { ZBEE_ZCL_56_BIT_BITMAP, "56-Bit Bitmap" },
365 { ZBEE_ZCL_64_BIT_BITMAP, "64-Bit Bitmap" },
367 { ZBEE_ZCL_8_BIT_UINT, "8-Bit Unsigned Integer" },
368 { ZBEE_ZCL_16_BIT_UINT, "16-Bit Unsigned Integer" },
369 { ZBEE_ZCL_24_BIT_UINT, "24-Bit Unsigned Integer" },
370 { ZBEE_ZCL_32_BIT_UINT, "32-Bit Unsigned Integer" },
371 { ZBEE_ZCL_40_BIT_UINT, "40-Bit Unsigned Integer" },
372 { ZBEE_ZCL_48_BIT_UINT, "48-Bit Unsigned Integer" },
373 { ZBEE_ZCL_56_BIT_UINT, "56-Bit Unsigned Integer" },
374 { ZBEE_ZCL_64_BIT_UINT, "64-Bit Unsigned Integer" },
376 { ZBEE_ZCL_8_BIT_INT, "8-Bit Signed Integer" },
377 { ZBEE_ZCL_16_BIT_INT, "16-Bit Signed Integer" },
378 { ZBEE_ZCL_24_BIT_INT, "24-Bit Signed Integer" },
379 { ZBEE_ZCL_32_BIT_INT, "32-Bit Signed Integer" },
380 { ZBEE_ZCL_40_BIT_INT, "40-Bit Signed Integer" },
381 { ZBEE_ZCL_48_BIT_INT, "48-Bit Signed Integer" },
382 { ZBEE_ZCL_56_BIT_INT, "56-Bit Signed Integer" },
383 { ZBEE_ZCL_64_BIT_INT, "64-Bit Signed Integer" },
385 { ZBEE_ZCL_8_BIT_ENUM, "8-Bit Enumeration" },
386 { ZBEE_ZCL_16_BIT_ENUM, "16-Bit Enumeration" },
388 { ZBEE_ZCL_SEMI_FLOAT, "Semi-precision Floating Point" },
389 { ZBEE_ZCL_SINGLE_FLOAT, "Single Precision Floating Point" },
390 { ZBEE_ZCL_DOUBLE_FLOAT, "Double Precision Floating Point" },
392 { ZBEE_ZCL_OCTET_STRING, "Octet String" },
393 { ZBEE_ZCL_CHAR_STRING, "Character String" },
394 { ZBEE_ZCL_LONG_OCTET_STRING, "Long Octet String" },
395 { ZBEE_ZCL_LONG_CHAR_STRING, "Long Character String" },
397 { ZBEE_ZCL_ARRAY, "Array" },
398 { ZBEE_ZCL_STRUCT, "Structure" },
400 { ZBEE_ZCL_SET, "Set Collection" },
401 { ZBEE_ZCL_BAG, "Bag Collection" },
403 { ZBEE_ZCL_TIME, "Time of Day" },
404 { ZBEE_ZCL_DATE, "Date" },
405 { ZBEE_ZCL_UTC, "UTC Time" },
407 { ZBEE_ZCL_CLUSTER_ID, "Cluster ID" },
408 { ZBEE_ZCL_ATTR_ID, "Attribute ID" },
409 { ZBEE_ZCL_BACNET_OID, "BACnet OID" },
411 { ZBEE_ZCL_IEEE_ADDR, "IEEE Address" },
412 { ZBEE_ZCL_SECURITY_KEY, "128-Bit Security Key" },
414 { ZBEE_ZCL_UNKNOWN, "Unknown" },
419 /* ZCL Attribute Short Data Names */
420 static const value_string zbee_zcl_short_data_type_names[] = {
421 { ZBEE_ZCL_NO_DATA, "No Data" },
422 { ZBEE_ZCL_8_BIT_DATA, "Data8" },
423 { ZBEE_ZCL_16_BIT_DATA, "Data16" },
424 { ZBEE_ZCL_24_BIT_DATA, "Data24" },
425 { ZBEE_ZCL_32_BIT_DATA, "Data32" },
426 { ZBEE_ZCL_40_BIT_DATA, "Data40" },
427 { ZBEE_ZCL_48_BIT_DATA, "Data48" },
428 { ZBEE_ZCL_56_BIT_DATA, "Data56" },
429 { ZBEE_ZCL_64_BIT_DATA, "Data64" },
431 { ZBEE_ZCL_BOOLEAN, "Boolean" },
433 { ZBEE_ZCL_8_BIT_BITMAP, "Bit8" },
434 { ZBEE_ZCL_16_BIT_BITMAP, "Bit16" },
435 { ZBEE_ZCL_24_BIT_BITMAP, "Bit24" },
436 { ZBEE_ZCL_32_BIT_BITMAP, "Bit32" },
437 { ZBEE_ZCL_40_BIT_BITMAP, "Bit40" },
438 { ZBEE_ZCL_48_BIT_BITMAP, "Bit48" },
439 { ZBEE_ZCL_56_BIT_BITMAP, "Bit56" },
440 { ZBEE_ZCL_64_BIT_BITMAP, "Bit64" },
442 { ZBEE_ZCL_8_BIT_UINT, "Uint8" },
443 { ZBEE_ZCL_16_BIT_UINT, "Uint16" },
444 { ZBEE_ZCL_24_BIT_UINT, "Uint24" },
445 { ZBEE_ZCL_32_BIT_UINT, "Uint32" },
446 { ZBEE_ZCL_40_BIT_UINT, "Uint40" },
447 { ZBEE_ZCL_48_BIT_UINT, "Uint48" },
448 { ZBEE_ZCL_56_BIT_UINT, "Uint56" },
449 { ZBEE_ZCL_64_BIT_UINT, "Uint64" },
451 { ZBEE_ZCL_8_BIT_INT, "Int8" },
452 { ZBEE_ZCL_16_BIT_INT, "Int16" },
453 { ZBEE_ZCL_24_BIT_INT, "Int24" },
454 { ZBEE_ZCL_32_BIT_INT, "Int32" },
455 { ZBEE_ZCL_40_BIT_INT, "Int40" },
456 { ZBEE_ZCL_48_BIT_INT, "Int48" },
457 { ZBEE_ZCL_56_BIT_INT, "Int56" },
458 { ZBEE_ZCL_64_BIT_INT, "Int64" },
460 { ZBEE_ZCL_8_BIT_ENUM, "Enum8" },
461 { ZBEE_ZCL_16_BIT_ENUM, "Enum16" },
463 { ZBEE_ZCL_SEMI_FLOAT, "Semi Float" },
464 { ZBEE_ZCL_SINGLE_FLOAT, "Float" },
465 { ZBEE_ZCL_DOUBLE_FLOAT, "Double Float" },
467 { ZBEE_ZCL_OCTET_STRING, "Oct String" },
468 { ZBEE_ZCL_CHAR_STRING, "Char String" },
469 { ZBEE_ZCL_LONG_OCTET_STRING, "Long Oct String" },
470 { ZBEE_ZCL_LONG_CHAR_STRING, "Long Char String" },
472 { ZBEE_ZCL_ARRAY, "Array" },
473 { ZBEE_ZCL_STRUCT, "Structure" },
475 { ZBEE_ZCL_SET, "Set" },
476 { ZBEE_ZCL_BAG, "Bag" },
478 { ZBEE_ZCL_TIME, "Time" },
479 { ZBEE_ZCL_DATE, "Date" },
480 { ZBEE_ZCL_UTC, "UTC" },
482 { ZBEE_ZCL_CLUSTER_ID, "Cluster" },
483 { ZBEE_ZCL_ATTR_ID, "Attribute" },
484 { ZBEE_ZCL_BACNET_OID, "BACnet" },
486 { ZBEE_ZCL_IEEE_ADDR, "EUI" },
487 { ZBEE_ZCL_SECURITY_KEY, "Key" },
489 { ZBEE_ZCL_UNKNOWN, "Unknown" },
494 /* ZCL Attribute English Weekday Names */
495 static const value_string zbee_zcl_wd_names[] = {
507 /* Attribute Direction Names */
508 static const value_string zbee_zcl_dir_names[] = {
515 /* Attribute Discovery Names */
516 static const value_string zbee_zcl_dis_names[] = {
523 /*FUNCTION:------------------------------------------------------
527 * ZigBee Cluster Library dissector for wireshark.
529 * tvbuff_t *tvb - pointer to buffer containing raw packet.
530 * packet_into *pinfo - pointer to packet information fields
531 * proto_tree *tree - pointer to data tree ethereal uses to display packet.
534 *---------------------------------------------------------------
536 static void dissect_zbee_zcl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
538 proto_tree *zcl_tree = NULL;
539 proto_tree *sub_tree = NULL;
541 proto_item *proto_root = NULL;
544 zbee_zcl_packet packet;
550 memset(&packet, 0, sizeof(zbee_zcl_packet));
552 /* Create the protocol tree */
554 proto_root = proto_tree_add_protocol_format(tree, proto_zbee_zcl, tvb, offset,
555 tvb_length(tvb), "ZigBee Cluster Library Frame");
557 zcl_tree = proto_item_add_subtree(proto_root, ett_zbee_zcl);
560 /* Clear info column */
561 col_clear(pinfo->cinfo, COL_INFO);
564 fcf = tvb_get_guint8(tvb, offset);
565 packet.frame_type = zbee_get_bit_field(fcf, ZBEE_ZCL_FCF_FRAME_TYPE);
566 packet.mfr_spec = zbee_get_bit_field(fcf, ZBEE_ZCL_FCF_MFR_SPEC);
567 packet.direction = zbee_get_bit_field(fcf, ZBEE_ZCL_FCF_DIRECTION);
568 packet.disable_default_resp = zbee_get_bit_field(fcf, ZBEE_ZCL_FCF_DISABLE_DEFAULT_RESP);
570 /* Display the FCF */
572 /* Create the subtree */
573 ti = proto_tree_add_text(zcl_tree, tvb, offset, sizeof(guint8),
574 "Frame Control Field: %s (0x%02x)",
575 val_to_str(packet.frame_type, zbee_zcl_frame_types, "Unknown"), fcf);
576 sub_tree = proto_item_add_subtree(ti, ett_zbee_zcl_fcf);
578 /* Add the frame type */
579 proto_tree_add_uint(sub_tree, hf_zbee_zcl_fcf_frame_type, tvb, offset, sizeof(guint8),
580 fcf & ZBEE_ZCL_FCF_FRAME_TYPE);
582 /* Add the manufacturer specific, direction, and disable default response flags */
583 proto_tree_add_boolean(sub_tree, hf_zbee_zcl_fcf_mfr_spec, tvb, offset,
584 sizeof(guint8), fcf & ZBEE_ZCL_FCF_MFR_SPEC);
586 proto_tree_add_boolean(sub_tree, hf_zbee_zcl_fcf_dir, tvb, offset, sizeof(guint8),
587 fcf & ZBEE_ZCL_FCF_DIRECTION);
589 proto_tree_add_boolean(sub_tree, hf_zbee_zcl_fcf_disable_default_resp, tvb, offset,
590 sizeof(guint8), fcf & ZBEE_ZCL_FCF_DISABLE_DEFAULT_RESP);
592 offset += sizeof(guint8);
594 /* If the manufacturer code is present, get and display it. */
595 if (packet.mfr_spec) {
596 packet.mfr_code = tvb_get_letohs(tvb, offset);
599 proto_tree_add_uint(zcl_tree, hf_zbee_zcl_mfr_code, tvb, offset, sizeof(guint16),
602 proto_item_append_text(proto_root, ", Mfr: %s (0x%04x)",
603 val_to_str(packet.mfr_code, zbee_mfr_code_names, "Unknown"),
606 offset += sizeof(guint16);
609 /* Add the transaction sequence number to the tree */
610 packet.tran_seqno = tvb_get_guint8(tvb, offset);
613 proto_tree_add_uint(zcl_tree, hf_zbee_zcl_tran_seqno, tvb, offset, sizeof(guint8),
616 offset += sizeof(guint8);
618 /* Display the command and sequence number on the proto root and info column. */
619 packet.cmd_id = tvb_get_guint8(tvb, offset);
621 /* Add command ID to the tree. */
622 if ( packet.frame_type == ZBEE_ZCL_FCF_PROFILE_WIDE ) {
624 proto_item_append_text(proto_root, ", Command: %s, Seq: %u",
625 val_to_str(packet.cmd_id, zbee_zcl_cmd_names, "Unknown Command"),
629 if ( check_col(pinfo->cinfo, COL_INFO) ) {
630 col_append_fstr(pinfo->cinfo, COL_INFO, "%s, Seq: %u",
631 val_to_str(packet.cmd_id, zbee_zcl_cmd_names, "Unknown Command"),
636 proto_tree_add_uint(zcl_tree, hf_zbee_zcl_cmd_id, tvb, offset, sizeof(guint8),
639 offset += sizeof(guint8);
642 proto_item_append_text(proto_root, ", Cluster-specific Command: 0x%02x, Seq: %u",
643 packet.cmd_id, packet.tran_seqno);
646 if ( check_col(pinfo->cinfo, COL_INFO) ) {
647 col_append_fstr(pinfo->cinfo, COL_INFO, "Command: 0x%02x, Seq: %u",
648 packet.cmd_id, packet.tran_seqno);
652 proto_tree_add_uint(zcl_tree, hf_zbee_zcl_cs_cmd_id, tvb, offset, sizeof(guint8),
655 offset += sizeof(guint8);
657 /* Don't decode cluster-specific commands */
658 zcl_dump_data(tvb, offset, pinfo, zcl_tree);
662 /* Handle the contents of the command frame. */
663 switch ( packet.cmd_id ) {
664 case ZBEE_ZCL_CMD_READ_ATTR:
665 dissect_zcl_read_attr(tvb, pinfo, zcl_tree, &offset);
668 case ZBEE_ZCL_CMD_READ_ATTR_RESP:
669 dissect_zcl_read_attr_resp(tvb, pinfo, zcl_tree, &offset);
672 case ZBEE_ZCL_CMD_WRITE_ATTR:
673 case ZBEE_ZCL_CMD_WRITE_ATTR_UNDIVIDED:
674 case ZBEE_ZCL_CMD_WRITE_ATTR_NO_RESP:
675 case ZBEE_ZCL_CMD_REPORT_ATTR:
676 dissect_zcl_write_attr(tvb, pinfo, zcl_tree, &offset);
679 case ZBEE_ZCL_CMD_WRITE_ATTR_RESP:
680 dissect_zcl_write_attr_resp(tvb, pinfo, zcl_tree, &offset);
683 case ZBEE_ZCL_CMD_CONFIG_REPORT:
684 dissect_zcl_config_report(tvb, pinfo, zcl_tree, &offset);
687 case ZBEE_ZCL_CMD_CONFIG_REPORT_RESP:
688 dissect_zcl_config_report_resp(tvb, pinfo, zcl_tree, &offset);
691 case ZBEE_ZCL_CMD_READ_REPORT_CONFIG:
692 dissect_zcl_read_report_config(tvb, pinfo, zcl_tree, &offset);
695 case ZBEE_ZCL_CMD_READ_REPORT_CONFIG_RESP:
696 dissect_zcl_read_report_config_resp(tvb, pinfo, zcl_tree, &offset);
699 case ZBEE_ZCL_CMD_DEFAULT_RESP:
700 dissect_zcl_default_resp(tvb, pinfo, zcl_tree, &offset);
703 case ZBEE_ZCL_CMD_DISCOVER_ATTR:
704 dissect_zcl_discover_attr(tvb, pinfo, zcl_tree, &offset);
707 case ZBEE_ZCL_CMD_DISCOVER_ATTR_RESP:
708 dissect_zcl_discover_attr_resp(tvb, pinfo, zcl_tree, &offset);
711 /* BUGBUG: don't dissect these for now */
712 case ZBEE_ZCL_CMD_READ_ATTR_STRUCT:
713 case ZBEE_ZCL_CMD_WRITE_ATTR_STRUCT:
714 case ZBEE_ZCL_CMD_WRITE_ATTR_STRUCT_RESP:
716 zcl_dump_data(tvb, offset, pinfo, zcl_tree);
721 } /* dissect_zbee_zcl */
723 /*FUNCTION:------------------------------------------------------
725 * dissect_zcl_read_attr
727 * Helper dissector for ZCL Read Attributes and
728 * Write Attributes No Response commands.
730 * tvbuff_t *tvb - pointer to buffer containing raw packet.
731 * packet_info *pinfo - pointer to packet information fields
732 * proto_tree *tree - pointer to data tree ethereal uses to display packet.
733 * offset - pointer to offset from caller
735 * guint - offset after command dissection.
736 *---------------------------------------------------------------
738 static void dissect_zcl_read_attr(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, guint *offset)
742 tvb_len = tvb_length(tvb);
743 while ( *offset < tvb_len ) {
744 /* Dissect the attribute identifier */
745 dissect_zcl_attr_id(tvb, tree, offset);
749 } /* dissect_zcl_read_attr */
751 /*FUNCTION:------------------------------------------------------
753 * dissect_zcl_read_attr_resp
755 * Helper dissector for ZCL Read Attributes Response command.
757 * tvbuff_t *tvb - pointer to buffer containing raw packet.
758 * packet_info *pinfo - pointer to packet information fields
759 * proto_tree *tree - pointer to data tree ethereal uses to display packet.
760 * offset - pointer to offset from caller
762 * guint - offset after command dissection.
763 *---------------------------------------------------------------
765 static void dissect_zcl_read_attr_resp(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, guint *offset)
767 proto_item *ti = NULL;
768 proto_tree *sub_tree = NULL;
773 tvb_len = tvb_length(tvb);
774 while ( *offset < tvb_len && i < ZBEE_ZCL_NUM_ATTR_ETT ) {
777 /* Create subtree for attribute status field */
778 ti = proto_tree_add_text(tree, tvb, *offset, 0, "Status Record");
779 sub_tree = proto_item_add_subtree(ti, ett_zbee_zcl_attr[i]);
783 /* Dissect the attribute identifier */
784 dissect_zcl_attr_id(tvb, sub_tree, offset);
786 /* Dissect the status and optionally the data type and value */
787 if ( dissect_zcl_attr_uint8(tvb, sub_tree, offset, &hf_zbee_zcl_attr_status)
788 == ZBEE_ZCL_STAT_SUCCESS ) {
790 /* Dissect the attribute data type and data */
791 dissect_zcl_attr_data_type_val(tvb, sub_tree, offset);
796 } /* dissect_zcl_read_attr_resp */
798 /*FUNCTION:------------------------------------------------------
800 * dissect_zcl_write_attr
802 * Helper dissector for ZCL Report Attribute commands.
804 * tvbuff_t *tvb - pointer to buffer containing raw packet.
805 * packet_info *pinfo - pointer to packet information fields
806 * proto_tree *tree - pointer to data tree ethereal uses to display packet.
807 * offset - pointer to offset from caller
809 * guint - offset after command dissection.
810 *---------------------------------------------------------------
812 static void dissect_zcl_write_attr(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, guint *offset)
814 proto_item *ti = NULL;
815 proto_tree *sub_tree = NULL;
820 tvb_len = tvb_length(tvb);
821 while ( *offset < tvb_len && i < ZBEE_ZCL_NUM_ATTR_ETT ) {
824 /* Create subtree for attribute status field */
825 ti = proto_tree_add_text(tree, tvb, *offset, 0, "Attribute Field");
826 sub_tree = proto_item_add_subtree(ti, ett_zbee_zcl_attr[i]);
829 /* Dissect the attribute identifier */
830 dissect_zcl_attr_id(tvb, sub_tree, offset);
832 /* Dissect the attribute data type and data */
833 dissect_zcl_attr_data_type_val(tvb, sub_tree, offset);
837 } /* dissect_zcl_write_attr */
839 /*FUNCTION:------------------------------------------------------
841 * dissect_zcl_write_attr_resp
843 * Helper dissector for ZCL Write Attribute Response command.
845 * tvbuff_t *tvb - pointer to buffer containing raw packet.
846 * packet_info *pinfo - pointer to packet information fields
847 * proto_tree *tree - pointer to data tree ethereal uses to display packet.
848 * offset - pointer to offset from caller
850 * guint - offset after command dissection.
851 *---------------------------------------------------------------
853 static void dissect_zcl_write_attr_resp(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, guint *offset)
855 proto_item *ti = NULL;
856 proto_tree *sub_tree = NULL;
861 tvb_len = tvb_length(tvb);
862 while ( *offset < tvb_len && i < ZBEE_ZCL_NUM_ATTR_ETT ) {
865 /* Create subtree for attribute status field */
866 ti = proto_tree_add_text(tree, tvb, *offset, 0, "Status Record");
867 sub_tree = proto_item_add_subtree(ti, ett_zbee_zcl_attr[i]);
871 /* Dissect the status */
872 if ( dissect_zcl_attr_uint8(tvb, sub_tree, offset, &hf_zbee_zcl_attr_status) !=
873 ZBEE_ZCL_STAT_SUCCESS ) {
875 /* Dissect the failed attribute identifier */
876 dissect_zcl_attr_id(tvb, sub_tree, offset);
881 } /* dissect_zcl_write_attr_resp */
883 /*FUNCTION:------------------------------------------------------
885 * dissect_zcl_read_report_config_resp
887 * Helper dissector for ZCL Report Attribute commands.
889 * tvbuff_t *tvb - pointer to buffer containing raw packet.
890 * packet_info *pinfo - pointer to packet information fields
891 * proto_tree *tree - pointer to data tree ethereal uses to display packet.
892 * offset - pointer to offset from caller
893 *---------------------------------------------------------------
895 static void dissect_zcl_read_report_config_resp(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
898 proto_item *ti = NULL;
899 proto_tree *sub_tree = NULL;
907 tvb_len = tvb_length(tvb);
908 while ( *offset < tvb_len && i < ZBEE_ZCL_NUM_ATTR_ETT ) {
911 /* Create subtree for attribute status field */
912 ti = proto_tree_add_text(tree, tvb, *offset, 3, "Reporting Configuration Record");
913 sub_tree = proto_item_add_subtree(ti, ett_zbee_zcl_attr[i]);
916 /* Dissect the status */
917 attr_status = dissect_zcl_attr_uint8(tvb, sub_tree, offset, &hf_zbee_zcl_attr_status);
919 /* Dissect the direction and any reported configuration */
920 attr_dir = dissect_zcl_attr_uint8(tvb, sub_tree, offset, &hf_zbee_zcl_attr_dir);
922 /* Dissect the attribute id */
923 dissect_zcl_attr_id(tvb, sub_tree, offset);
925 if ( attr_status == ZBEE_ZCL_STAT_SUCCESS ) {
926 if ( attr_dir == ZBEE_ZCL_DIR_REPORTED ) {
928 /* Dissect the attribute data type */
929 data_type = dissect_zcl_attr_uint8(tvb, sub_tree, offset,
930 &hf_zbee_zcl_attr_data_type);
932 /* Dissect minimum reporting interval */
933 dissect_zcl_attr_uint16(tvb, sub_tree, offset, &hf_zbee_zcl_attr_minint);
935 /* Dissect maximum reporting interval */
936 dissect_zcl_attr_uint16(tvb, sub_tree, offset, &hf_zbee_zcl_attr_maxint);
938 if ( IS_ANALOG_SUBTYPE(data_type) ) {
939 /* Dissect reportable change */
940 dissect_zcl_attr_data(tvb, sub_tree, offset, data_type);
944 /* Dissect timeout period */
945 dissect_zcl_attr_uint16(tvb, sub_tree, offset, &hf_zbee_zcl_attr_timeout);
951 } /* dissect_zcl_read_report_config_resp */
953 /*FUNCTION:------------------------------------------------------
955 * dissect_zcl_config_report
957 * Helper dissector for ZCL Report Attribute commands.
959 * tvbuff_t *tvb - pointer to buffer containing raw packet.
960 * packet_info *pinfo - pointer to packet information fields
961 * proto_tree *tree - pointer to data tree ethereal uses to display packet.
962 * offset - pointer to offset from caller
963 *---------------------------------------------------------------
965 static void dissect_zcl_config_report(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, guint *offset)
967 proto_item *ti = NULL;
968 proto_tree *sub_tree = NULL;
974 tvb_len = tvb_length(tvb);
975 while ( *offset < tvb_len && i < ZBEE_ZCL_NUM_ATTR_ETT ) {
978 /* Create subtree for attribute status field */
979 ti = proto_tree_add_text(tree, tvb, *offset, 3, "Reporting Configuration Record");
980 sub_tree = proto_item_add_subtree(ti, ett_zbee_zcl_attr[i]);
984 /* Dissect the direction and any reported configuration */
985 if ( dissect_zcl_attr_uint8(tvb, sub_tree, offset, &hf_zbee_zcl_attr_dir)
986 == ZBEE_ZCL_DIR_REPORTED ) {
988 /* Dissect the attribute id */
989 dissect_zcl_attr_id(tvb, sub_tree, offset);
991 /* Dissect the attribute data type */
992 data_type = dissect_zcl_attr_uint8(tvb, sub_tree, offset, &hf_zbee_zcl_attr_data_type);
994 /* Dissect minimum reporting interval */
995 dissect_zcl_attr_uint16(tvb, sub_tree, offset, &hf_zbee_zcl_attr_minint);
997 /* Dissect maximum reporting interval */
998 dissect_zcl_attr_uint16(tvb, sub_tree, offset, &hf_zbee_zcl_attr_maxint);
1000 if ( IS_ANALOG_SUBTYPE(data_type) ) {
1001 /* Dissect reportable change */
1002 dissect_zcl_attr_data(tvb, sub_tree, offset, data_type);
1006 /* Dissect the attribute id */
1007 dissect_zcl_attr_id(tvb, sub_tree, offset);
1009 /* Dissect timeout period */
1010 dissect_zcl_attr_uint16(tvb, sub_tree, offset, &hf_zbee_zcl_attr_timeout);
1015 } /* dissect_zcl_config_report */
1017 /*FUNCTION:------------------------------------------------------
1019 * dissect_zcl_config_report_resp
1021 * Helper dissector for ZCL Report Attribute commands.
1023 * tvbuff_t *tvb - pointer to buffer containing raw packet.
1024 * packet_info *pinfo - pointer to packet information fields
1025 * proto_tree *tree - pointer to data tree ethereal uses to display packet.
1026 * offset - pointer to offset from caller
1028 * guint - offset after command dissection.
1029 *---------------------------------------------------------------
1031 static void dissect_zcl_config_report_resp(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
1034 proto_item *ti = NULL;
1035 proto_tree *sub_tree = NULL;
1040 tvb_len = tvb_length(tvb);
1041 while ( *offset < tvb_len && i < ZBEE_ZCL_NUM_ATTR_ETT ) {
1044 /* Create subtree for attribute status field */
1045 ti = proto_tree_add_text(tree, tvb, *offset, 3, "Attribute Status Record");
1046 sub_tree = proto_item_add_subtree(ti, ett_zbee_zcl_attr[i]);
1050 /* Dissect the status */
1051 if ( dissect_zcl_attr_uint8(tvb, sub_tree, offset, &hf_zbee_zcl_attr_status) !=
1052 ZBEE_ZCL_STAT_SUCCESS ) {
1053 /* Dissect the direction on error */
1054 dissect_zcl_attr_uint8(tvb, sub_tree, offset, &hf_zbee_zcl_attr_dir);
1056 /* Dissect the attribute identifier on error */
1057 dissect_zcl_attr_id(tvb, sub_tree, offset);
1062 } /* dissect_zcl_config_report_resp */
1064 /*FUNCTION:------------------------------------------------------
1066 * dissect_zcl_read_report_config
1068 * Helper dissector for ZCL Read Report Configuration command.
1070 * tvbuff_t *tvb - pointer to buffer containing raw packet.
1071 * packet_info *pinfo - pointer to packet information fields
1072 * proto_tree *tree - pointer to data tree ethereal uses to display packet.
1073 * offset - pointer to offset from caller
1075 * guint - offset after command dissection.
1076 *---------------------------------------------------------------
1078 static void dissect_zcl_read_report_config(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
1081 proto_item *ti = NULL;
1082 proto_tree *sub_tree = NULL;
1087 tvb_len = tvb_length(tvb);
1088 while ( *offset < tvb_len && i < ZBEE_ZCL_NUM_ATTR_ETT ) {
1091 /* Create subtree for attribute status field */
1092 ti = proto_tree_add_text(tree, tvb, *offset, 3, "Attribute Status Record");
1093 sub_tree = proto_item_add_subtree(ti, ett_zbee_zcl_attr[i]);
1097 /* Dissect the direction */
1098 dissect_zcl_attr_uint8(tvb, sub_tree, offset, &hf_zbee_zcl_attr_dir);
1100 /* Dissect the attribute identifier */
1101 dissect_zcl_attr_id(tvb, sub_tree, offset);
1105 } /* dissect_zcl_read_report_config */
1107 /*FUNCTION:------------------------------------------------------
1109 * dissect_zcl_default_resp
1111 * Helper dissector for ZCL Default Response command.
1113 * tvbuff_t *tvb - pointer to buffer containing raw packet.
1114 * packet_info *pinfo - pointer to packet information fields
1115 * proto_tree *tree - pointer to data tree ethereal uses to display packet.
1116 * offset - pointer to offset from caller
1119 *---------------------------------------------------------------
1121 static void dissect_zcl_default_resp(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, guint *offset)
1125 /* Dissect the command identifier */
1126 cmd_id = tvb_get_guint8(tvb, *offset);
1129 proto_tree_add_uint(tree, hf_zbee_zcl_cmd_id, tvb, *offset, sizeof(guint8), cmd_id);
1132 *offset += sizeof(guint8);
1134 /* Dissect the status */
1135 dissect_zcl_attr_uint8(tvb, tree, offset, &hf_zbee_zcl_attr_status);
1138 } /* dissect_zcl_default_resp */
1140 /*FUNCTION:------------------------------------------------------
1142 * dissect_zcl_discover_attr
1144 * Helper dissector for ZCL Discover Attributes command.
1146 * tvbuff_t *tvb - pointer to buffer containing raw packet.
1147 * packet_info *pinfo - pointer to packet information fields
1148 * proto_tree *tree - pointer to data tree ethereal uses to display packet.
1149 * offset - pointer to offset from caller
1152 *---------------------------------------------------------------
1154 static void dissect_zcl_discover_attr(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, guint *offset)
1156 /* Dissect the starting attribute identifier */
1157 dissect_zcl_attr_uint16(tvb, tree, offset, &hf_zbee_zcl_attr_start);
1159 /* Dissect the number of maximum attribute identifiers */
1160 dissect_zcl_attr_uint8(tvb, tree, offset, &hf_zbee_zcl_attr_maxnum);
1163 } /* dissect_zcl_discover_attr */
1166 /*FUNCTION:------------------------------------------------------
1168 * dissect_zcl_discover_attr_resp
1170 * Helper dissector for ZCL Discover Attributes command.
1172 * tvbuff_t *tvb - pointer to buffer containing raw packet.
1173 * packet_info *pinfo - pointer to packet information fields
1174 * proto_tree *tree - pointer to data tree ethereal uses to display packet.
1175 * offset - pointer to offset from caller
1178 *---------------------------------------------------------------
1180 static void dissect_zcl_discover_attr_resp(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
1183 proto_item *ti = NULL;
1184 proto_tree *sub_tree = NULL;
1189 dissect_zcl_attr_uint8(tvb, sub_tree, offset, &hf_zbee_zcl_attr_dis);
1191 tvb_len = tvb_length(tvb);
1192 while ( *offset < tvb_len && i < ZBEE_ZCL_NUM_ATTR_ETT ) {
1195 /* Create subtree for attribute status field */
1196 ti = proto_tree_add_text(tree, tvb, *offset, 3, "Attribute Status Record");
1197 sub_tree = proto_item_add_subtree(ti, ett_zbee_zcl_attr[i]);
1200 /* Dissect the attribute identifier */
1201 dissect_zcl_attr_id(tvb, sub_tree, offset);
1203 /* Dissect the number of maximum attribute identifiers */
1204 dissect_zcl_attr_uint8(tvb, sub_tree, offset, &hf_zbee_zcl_attr_data_type);
1209 } /* dissect_zcl_discover_attr_resp */
1212 /*FUNCTION:------------------------------------------------------
1214 * dissect_zcl_attr_data_type
1216 * Helper dissector for ZCL Attribute commands.
1218 * tvbuff_t *tvb - pointer to buffer containing raw packet.
1219 * proto_tree *tree - pointer to data tree ethereal uses to display packet.
1220 * offset - offset into the tvb to begin dissection.
1222 * guint - attribute data type
1223 *---------------------------------------------------------------
1225 static guint dissect_zcl_attr_data_type(tvbuff_t *tvb, proto_tree *tree, guint *offset)
1227 guint attr_data_type;
1229 /* Dissect attribute data type */
1230 attr_data_type = tvb_get_guint8(tvb, *offset);
1233 proto_tree_add_uint(tree, hf_zbee_zcl_attr_data_type, tvb, *offset, sizeof(guint8),
1236 *offset += sizeof(guint8);
1238 return attr_data_type;
1239 } /* dissect_zcl_attr_data_type */
1242 /*FUNCTION:------------------------------------------------------
1244 * dissect_zcl_attr_id
1246 * Dissects Attribute ID field. This could be done with the
1247 * dissect_zcl_attr_uint16 function, but we leave it separate
1248 * so we can dissect the attr_id with a hash in the future.
1250 * tvbuff_t *tvb - pointer to buffer containing raw packet.
1251 * proto_tree *tree - pointer to data tree ethereal uses to display packet.
1252 * offset - offset into the tvb to begin dissection.
1255 *---------------------------------------------------------------
1257 static void dissect_zcl_attr_id(tvbuff_t *tvb, proto_tree *tree, guint *offset)
1261 attr_id = tvb_get_letohs(tvb, *offset);
1263 /* add it to tree */
1265 /* Add the identifier */
1266 proto_tree_add_uint(tree, hf_zbee_zcl_attr_id, tvb, *offset, sizeof(guint16),
1269 *offset += sizeof(guint16);
1272 } /* dissect_zcl_attr_id */
1274 /*FUNCTION:------------------------------------------------------
1276 * dissect_zcl_attr_data_type_val
1278 * Helper dissector for ZCL Attribute commands.
1280 * tvbuff_t *tvb - pointer to buffer containing raw packet.
1281 * proto_tree *tree - pointer to data tree ethereal uses to display packet.
1282 * offset - offset into the tvb to begin dissection.
1285 *---------------------------------------------------------------
1287 static void dissect_zcl_attr_data_type_val(tvbuff_t *tvb, proto_tree *tree, guint *offset)
1289 dissect_zcl_attr_data(tvb, tree, offset,
1290 dissect_zcl_attr_uint8(tvb, tree, offset, &hf_zbee_zcl_attr_data_type) );
1293 } /* dissect_zcl_attr_data_type_val */
1295 /*FUNCTION:------------------------------------------------------
1297 * dissect_zcl_attr_data
1299 * Dissects the various types of ZCL attribute data.
1301 * tvbuff_t *tvb - pointer to buffer containing raw packet.
1302 * packet_info *pinfo - pointer to packet information fields
1303 * proto_tree *tree - pointer to data tree ethereal uses to display packet.
1304 * offset - offset into the tvb to begin dissection.
1305 * data_type - the type of ZCL data in the packet buffer
1308 *---------------------------------------------------------------
1310 static void dissect_zcl_attr_data(tvbuff_t *tvb, proto_tree *tree, guint *offset, guint data_type)
1313 guint64 attr_uint64;
1316 guint8 *attr_string;
1317 guint8 attr_uint8[4];
1319 gdouble attr_double;
1327 /* Dissect attribute data type and data */
1328 switch ( data_type ) {
1329 case ZBEE_ZCL_NO_DATA:
1332 case ZBEE_ZCL_8_BIT_DATA:
1333 case ZBEE_ZCL_8_BIT_BITMAP:
1334 dissect_zcl_attr_bytes(tvb, tree, offset, 1);
1337 case ZBEE_ZCL_8_BIT_UINT:
1338 case ZBEE_ZCL_8_BIT_ENUM:
1340 /* Display 8 bit unsigned integer */
1341 attr_uint = tvb_get_guint8(tvb, *offset);
1344 proto_item_append_text(tree, ", %s: %u",
1345 val_to_str(data_type, zbee_zcl_short_data_type_names, "Reserved"), attr_uint);
1347 proto_tree_add_uint(tree, hf_zbee_zcl_attr_uint8, tvb, *offset, sizeof(guint8),
1351 *offset += sizeof(guint8);
1354 case ZBEE_ZCL_8_BIT_INT:
1355 /* Display 8 bit integer */
1357 attr_int = (gint8)tvb_get_guint8(tvb, *offset);
1360 proto_item_append_text(tree, ", %s: %-d",
1361 val_to_str(data_type, zbee_zcl_short_data_type_names, "Reserved"), attr_int);
1363 proto_tree_add_int(tree, hf_zbee_zcl_attr_int8, tvb, *offset, sizeof(gint8),
1367 *offset += sizeof(gint8);
1370 case ZBEE_ZCL_BOOLEAN:
1372 attr_uint = tvb_get_guint8(tvb, *offset);
1375 proto_item_append_text(tree, ", %s: 0x%02x",
1376 val_to_str(data_type, zbee_zcl_short_data_type_names, "Reserved"), attr_uint);
1378 proto_tree_add_uint(tree, hf_zbee_zcl_attr_boolean, tvb, *offset, sizeof(guint8),
1381 *offset += sizeof(guint8);
1384 case ZBEE_ZCL_16_BIT_DATA:
1385 case ZBEE_ZCL_16_BIT_BITMAP:
1386 dissect_zcl_attr_bytes(tvb, tree, offset, 2);
1389 case ZBEE_ZCL_16_BIT_UINT:
1390 case ZBEE_ZCL_16_BIT_ENUM:
1391 /* Display 16 bit unsigned integer */
1393 attr_uint = tvb_get_letohs(tvb, *offset);
1396 proto_item_append_text(tree, ", %s: %u",
1397 val_to_str(data_type, zbee_zcl_short_data_type_names, "Reserved"), attr_uint);
1399 proto_tree_add_uint(tree, hf_zbee_zcl_attr_uint16, tvb, *offset, sizeof(guint16),
1402 *offset += sizeof(guint16);
1405 case ZBEE_ZCL_16_BIT_INT:
1406 /* Display 16 bit integer */
1408 attr_int = (gint16)tvb_get_letohs(tvb, *offset);
1411 proto_item_append_text(tree, ", %s: %-d",
1412 val_to_str(data_type, zbee_zcl_short_data_type_names, "Reserved"), attr_int);
1414 proto_tree_add_int(tree, hf_zbee_zcl_attr_int16, tvb, *offset, sizeof(gint16),
1417 *offset += sizeof(gint16);
1420 case ZBEE_ZCL_24_BIT_DATA:
1421 case ZBEE_ZCL_24_BIT_BITMAP:
1422 dissect_zcl_attr_bytes(tvb, tree, offset, 3);
1425 case ZBEE_ZCL_24_BIT_UINT:
1426 /* Display 24 bit unsigned integer */
1428 attr_uint = tvb_get_letoh24(tvb, *offset);
1431 proto_item_append_text(tree, ", %s: %u",
1432 val_to_str(data_type, zbee_zcl_short_data_type_names, "Reserved"), attr_uint);
1434 proto_tree_add_uint(tree, hf_zbee_zcl_attr_uint24, tvb, *offset, 3,
1440 case ZBEE_ZCL_24_BIT_INT:
1441 /* Display 24 bit signed integer */
1443 attr_int = (gint)tvb_get_letoh24(tvb, *offset);
1444 /* sign extend into int32 */
1445 if (attr_int & INT24_SIGN_BITS) attr_int |= INT24_SIGN_BITS;
1448 proto_item_append_text(tree, ", %s: %-d",
1449 val_to_str(data_type, zbee_zcl_short_data_type_names, "Reserved"), attr_int);
1451 proto_tree_add_int(tree, hf_zbee_zcl_attr_int24, tvb, *offset, 3,
1457 case ZBEE_ZCL_32_BIT_DATA:
1458 case ZBEE_ZCL_32_BIT_BITMAP:
1459 dissect_zcl_attr_bytes(tvb, tree, offset, 4);
1462 case ZBEE_ZCL_32_BIT_UINT:
1463 /* Display 32 bit unsigned integer */
1465 attr_uint = tvb_get_letohl(tvb, *offset);
1468 proto_item_append_text(tree, ", %s: %u",
1469 val_to_str(data_type, zbee_zcl_short_data_type_names, "Reserved"), attr_uint);
1471 proto_tree_add_uint(tree, hf_zbee_zcl_attr_uint32, tvb, *offset, sizeof(guint),
1474 *offset += sizeof(guint);
1477 case ZBEE_ZCL_32_BIT_INT:
1478 /* Display 32 bit signed integer */
1480 attr_int = (gint)tvb_get_letohl(tvb, *offset);
1483 proto_item_append_text(tree, ", %s: %-d",
1484 val_to_str(data_type, zbee_zcl_short_data_type_names, "Reserved"), attr_int);
1486 proto_tree_add_int(tree, hf_zbee_zcl_attr_int32, tvb, *offset, sizeof(gint),
1489 *offset += sizeof(gint);
1492 case ZBEE_ZCL_40_BIT_DATA:
1493 case ZBEE_ZCL_40_BIT_BITMAP:
1494 dissect_zcl_attr_bytes(tvb, tree, offset, 5);
1497 case ZBEE_ZCL_40_BIT_UINT:
1498 dissect_zcl_big_int(tvb, tree, offset, 5, FALSE);
1501 case ZBEE_ZCL_40_BIT_INT:
1502 dissect_zcl_big_int(tvb, tree, offset, 5, TRUE);
1505 case ZBEE_ZCL_48_BIT_DATA:
1506 case ZBEE_ZCL_48_BIT_BITMAP:
1507 dissect_zcl_attr_bytes(tvb, tree, offset, 6);
1510 case ZBEE_ZCL_48_BIT_UINT:
1511 dissect_zcl_big_int(tvb, tree, offset, 6, FALSE);
1514 case ZBEE_ZCL_48_BIT_INT:
1515 dissect_zcl_big_int(tvb, tree, offset, 6, TRUE);
1518 case ZBEE_ZCL_56_BIT_DATA:
1519 case ZBEE_ZCL_56_BIT_BITMAP:
1520 dissect_zcl_attr_bytes(tvb, tree, offset, 7);
1523 case ZBEE_ZCL_56_BIT_UINT:
1524 dissect_zcl_big_int(tvb, tree, offset, 7, FALSE);
1527 case ZBEE_ZCL_56_BIT_INT:
1528 dissect_zcl_big_int(tvb, tree, offset, 7, TRUE);
1531 case ZBEE_ZCL_64_BIT_DATA:
1532 case ZBEE_ZCL_64_BIT_BITMAP:
1533 dissect_zcl_attr_bytes(tvb, tree, offset, 8);
1536 case ZBEE_ZCL_64_BIT_UINT:
1537 dissect_zcl_big_int(tvb, tree, offset, 8, FALSE);
1540 case ZBEE_ZCL_64_BIT_INT:
1541 dissect_zcl_big_int(tvb, tree, offset, 8, TRUE);
1544 case ZBEE_ZCL_SEMI_FLOAT:
1546 dissect_zcl_attr_bytes(tvb, tree, offset, 2);
1549 case ZBEE_ZCL_SINGLE_FLOAT:
1550 attr_float = tvb_get_letohieee_float(tvb, *offset);
1553 proto_item_append_text(tree, ", %s: %g",
1554 val_to_str(data_type, zbee_zcl_short_data_type_names, "Reserved"), attr_float);
1556 proto_tree_add_item(tree, hf_zbee_zcl_attr_float, tvb, *offset, 4, TRUE);
1561 case ZBEE_ZCL_DOUBLE_FLOAT:
1562 attr_double = tvb_get_letohieee_double(tvb, *offset);
1565 proto_item_append_text(tree, ", Double: %lg", attr_double);
1567 proto_tree_add_item(tree, hf_zbee_zcl_attr_double, tvb, *offset, 8, TRUE);
1572 case ZBEE_ZCL_OCTET_STRING:
1574 /* Display octet string */
1575 attr_uint = tvb_get_guint8(tvb, *offset); /* string length */
1576 if (attr_uint == ZBEE_ZCL_INVALID_STR_LENGTH) attr_uint = 0;
1579 proto_tree_add_uint(tree, hf_zbee_zcl_attr_str_len, tvb, *offset, sizeof(guint8),
1582 *offset += sizeof(guint8);
1584 attr_string = tvb_bytes_to_str_punct(tvb, *offset, attr_uint, ':');
1586 proto_item_append_text(tree, ", Octets: %s", attr_string);
1588 proto_tree_add_string(tree, hf_zbee_zcl_attr_ostr, tvb, *offset, attr_uint,
1591 *offset += attr_uint;
1594 case ZBEE_ZCL_CHAR_STRING:
1596 /* Display string */
1597 attr_uint = tvb_get_guint8(tvb, *offset); /* string length */
1598 if (attr_uint == ZBEE_ZCL_INVALID_STR_LENGTH) attr_uint = 0;
1601 proto_tree_add_uint(tree, hf_zbee_zcl_attr_str_len, tvb, *offset, sizeof(guint8),
1604 *offset += sizeof(guint8);
1606 attr_string = tvb_get_ephemeral_string(tvb, *offset, attr_uint);
1608 proto_item_append_text(tree, ", String: %s", attr_string);
1610 proto_tree_add_string(tree, hf_zbee_zcl_attr_str, tvb, *offset, attr_uint,
1613 *offset += attr_uint;
1616 case ZBEE_ZCL_LONG_OCTET_STRING:
1618 /* Display long octet string */
1619 attr_uint = tvb_get_letohs(tvb, *offset); /* string length */
1620 if (attr_uint == ZBEE_ZCL_INVALID_LONG_STR_LENGTH) attr_uint = 0;
1623 proto_tree_add_uint(tree, hf_zbee_zcl_attr_str_len, tvb, *offset, sizeof(guint16),
1626 *offset += sizeof(guint16);
1628 attr_string = tvb_bytes_to_str_punct(tvb, *offset, attr_uint, ':');
1630 proto_item_append_text(tree, ", Octets: %s", attr_string);
1632 proto_tree_add_string(tree, hf_zbee_zcl_attr_ostr, tvb, *offset, attr_uint,
1635 *offset += attr_uint;
1638 case ZBEE_ZCL_LONG_CHAR_STRING:
1640 /* Display long string */
1641 attr_uint = tvb_get_letohs(tvb, *offset); /* string length */
1642 if (attr_uint == ZBEE_ZCL_INVALID_LONG_STR_LENGTH) attr_uint = 0;
1645 proto_tree_add_uint(tree, hf_zbee_zcl_attr_str_len, tvb, *offset, sizeof(guint16),
1648 *offset += sizeof(guint16);
1650 attr_string = tvb_get_ephemeral_string(tvb, *offset, attr_uint);
1652 proto_item_append_text(tree, ", String: %s", attr_string);
1654 proto_tree_add_string(tree, hf_zbee_zcl_attr_str, tvb, *offset, attr_uint,
1657 *offset += attr_uint;
1661 /* Dissect Time of Day */
1662 attr_uint8[0] = dissect_zcl_attr_uint8(tvb, tree, offset, &hf_zbee_zcl_attr_hours);
1663 attr_uint8[1] = dissect_zcl_attr_uint8(tvb, tree, offset, &hf_zbee_zcl_attr_mins);
1664 attr_uint8[2] = dissect_zcl_attr_uint8(tvb, tree, offset, &hf_zbee_zcl_attr_secs);
1665 attr_uint8[3] = dissect_zcl_attr_uint8(tvb, tree, offset, &hf_zbee_zcl_attr_csecs);
1668 proto_item_append_text(tree, ", Time: %u:%u:%u.%u",
1669 attr_uint8[0], attr_uint8[1], attr_uint8[2], attr_uint8[3]);
1675 attr_uint8[0] = dissect_zcl_attr_uint8(tvb, tree, offset, &hf_zbee_zcl_attr_yy);
1676 attr_uint8[1] = dissect_zcl_attr_uint8(tvb, tree, offset, &hf_zbee_zcl_attr_mm);
1677 attr_uint8[2] = dissect_zcl_attr_uint8(tvb, tree, offset, &hf_zbee_zcl_attr_md);
1678 attr_uint8[3] = dissect_zcl_attr_uint8(tvb, tree, offset, &hf_zbee_zcl_attr_wd);
1681 proto_item_append_text(tree, ", Date: %u/%u/%u %s",
1682 attr_uint8[0]+1900, attr_uint8[1], attr_uint8[2],
1683 val_to_str(attr_uint8[3], zbee_zcl_wd_names, "Invalid Weekday") );
1689 attr_time.secs = (guint32)tvb_get_letohl(tvb, *offset);
1690 attr_time.secs += ZBEE_ZCL_NSTIME_UTC_OFFSET;
1691 attr_time.nsecs = 0;
1694 proto_item_append_text(tree, ", %s",
1695 val_to_str(data_type, zbee_zcl_short_data_type_names, "Reserved") );
1697 proto_tree_add_time(tree, hf_zbee_zcl_attr_utc, tvb, *offset, sizeof(guint),
1701 *offset += sizeof(guint32);
1704 case ZBEE_ZCL_CLUSTER_ID:
1705 dissect_zcl_attr_uint16(tvb, tree, offset, &hf_zbee_zcl_attr_cid);
1708 case ZBEE_ZCL_ATTR_ID:
1709 dissect_zcl_attr_id(tvb, tree, offset);
1712 case ZBEE_ZCL_BACNET_OID:
1713 dissect_zcl_attr_bytes(tvb, tree, offset, 4);
1716 case ZBEE_ZCL_IEEE_ADDR:
1717 dissect_zcl_attr_bytes(tvb, tree, offset, 8);
1720 case ZBEE_ZCL_SECURITY_KEY:
1721 dissect_zcl_attr_bytes(tvb, tree, offset, 16);
1729 } /* dissect_zcl_attr_data */
1731 /*FUNCTION:------------------------------------------------------
1733 * dissect_zcl_big_int
1735 * Dissects int or uint of up to 64 bits.
1737 * tvbuff_t *tvb - pointer to buffer containing raw packet.
1738 * packet_info *pinfo - pointer to packet information fields
1739 * proto_tree *tree - pointer to data tree ethereal uses to display packet.
1740 * offset - offset into the tvb to begin dissection.
1741 * signed_flag - if TRUE, dissect a signed int
1744 *---------------------------------------------------------------
1746 static void dissect_zcl_big_int(tvbuff_t *tvb, proto_tree *tree, guint *offset, guint length,
1747 gboolean signed_flag)
1749 guint64 attr_uint64;
1751 attr_uint64 = tvb_get_letohi(tvb, *offset, length, signed_flag);
1753 /* add it to tree */
1755 if ( signed_flag ) {
1756 proto_item_append_text(tree, ", Int: %" G_GINT64_MODIFIER "d", (gint64)attr_uint64);
1758 proto_tree_add_int64(tree, hf_zbee_zcl_attr_int64, tvb, *offset, length,
1759 (gint64)attr_uint64);
1761 proto_item_append_text(tree, ", Uint: %" G_GINT64_MODIFIER "u", attr_uint64);
1763 proto_tree_add_uint64(tree, hf_zbee_zcl_attr_uint64, tvb, *offset, length,
1771 } /* dissect_zcl_big_int */
1773 /*FUNCTION:------------------------------------------------------
1775 * dissect_zcl_attr_uint8
1777 * Helper dissector for ZCL Attribute commands.
1779 * tvbuff_t *tvb - pointer to buffer containing raw packet.
1780 * proto_tree *tree - pointer to data tree ethereal uses to display packet.
1781 * offset - offset into the tvb to begin dissection.
1782 * hf_zbee_zcl - pointer to header field index
1784 * guint - dissected data
1785 *---------------------------------------------------------------
1787 static guint dissect_zcl_attr_uint8(tvbuff_t *tvb, proto_tree *tree, guint *offset, int *hf_zbee_zcl)
1791 attr_uint = tvb_get_guint8(tvb, *offset);
1794 proto_tree_add_uint(tree, *hf_zbee_zcl, tvb, *offset, sizeof(guint8), attr_uint);
1799 } /* dissect_zcl_attr_uint8 */
1801 /*FUNCTION:------------------------------------------------------
1803 * dissect_zcl_attr_uint16
1805 * Helper dissector for ZCL Attribute commands.
1807 * tvbuff_t *tvb - pointer to buffer containing raw packet.
1808 * proto_tree *tree - pointer to data tree ethereal uses to display packet.
1809 * offset - offset into the tvb to begin dissection.
1810 * hf_zbee_zcl - pointer to header field index
1812 * guint - field value
1813 *---------------------------------------------------------------
1815 static guint dissect_zcl_attr_uint16(tvbuff_t *tvb, proto_tree *tree, guint *offset, int *hf_zbee_zcl)
1819 attr_uint = tvb_get_letohs(tvb, *offset);
1822 proto_tree_add_uint(tree, *hf_zbee_zcl, tvb, *offset, sizeof(guint16), attr_uint);
1824 *offset += sizeof(guint16);
1827 } /* dissect_zcl_attr_uint16 */
1829 /*FUNCTION:------------------------------------------------------
1831 * dissect_zcl_attr_bytes
1833 * Helper dissector for ZCL Attribute commands.
1835 * tvbuff_t *tvb - pointer to buffer containing raw packet.
1836 * proto_tree *tree - pointer to data tree ethereal uses to display packet.
1837 * offset - offset into the tvb to begin dissection.
1838 * length - number of bytes to dissect
1841 *---------------------------------------------------------------
1843 static void dissect_zcl_attr_bytes(tvbuff_t *tvb, proto_tree *tree, guint *offset, guint length)
1846 proto_tree_add_bytes(tree, hf_zbee_zcl_attr_bytes, tvb, *offset, length,
1847 tvb_get_ptr(tvb, *offset, length));
1852 } /* dissect_dcl_attr_bytes */
1854 /*FUNCTION:------------------------------------------------------
1858 * Helper functions dumps any remaining data into the data dissector.
1860 * tvbuff_t *tvb - pointer to buffer containing raw packet.
1861 * guint offset - offset after parsing last item.
1862 * packet_info *pinfo - packet information structure.
1863 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
1866 *---------------------------------------------------------------
1868 static void zcl_dump_data(tvbuff_t *tvb, guint offset, packet_info *pinfo, proto_tree *tree)
1870 proto_tree *root = proto_tree_get_root(tree);
1871 guint length = tvb_length_remaining(tvb, offset);
1872 tvbuff_t *remainder;
1875 remainder = tvb_new_subset(tvb, offset, length, length);
1876 call_dissector(data_handle, remainder, pinfo, root);
1878 } /* zcl_dump_data */
1880 /*FUNCTION:------------------------------------------------------
1884 * Gets little endian int or uint of up to 8 bytes from tvb buffer.
1886 * tvbuff_t *tvb - pointer to buffer containing raw packet.
1887 * offset - offset into the tvb to begin dissection.
1888 * length - length of int or uint in bytes
1889 * signed_flag - if TRUE, get a signed int
1891 * guint64 - value retrieved from tvb buffer
1892 *---------------------------------------------------------------
1894 static guint64 tvb_get_letohi(tvbuff_t *tvb, guint offset, guint length, gboolean signed_flag)
1899 DISSECTOR_ASSERT((length>=1) && (length<=8));
1903 /* build big int of length bytes */
1904 while ( length-- ) {
1905 result += (guint64)tvb_get_guint8(tvb, offset) << shift;
1906 offset += sizeof(guint8);
1910 if ( signed_flag && (result >> (shift - 1)) ) {
1911 /* sign extend remaining bytes */
1912 while ( shift < (sizeof(guint64) * 8) ) {
1913 result += (guint64)0xff << shift;
1919 } /* tvb_get_letohi */
1921 /*FUNCTION:------------------------------------------------------
1923 * proto_register_zbee_zcl
1925 * ZigBee ZCL protocol registration routine.
1930 *---------------------------------------------------------------
1932 void proto_register_zbee_zcl(void)
1936 static const true_false_string tfs_client_server = {
1941 static hf_register_info hf[] = {
1942 { &hf_zbee_zcl_fcf_frame_type,
1943 { "Frame Type", "zbee.zcl.type", FT_UINT8, BASE_HEX, VALS(zbee_zcl_frame_types),
1944 ZBEE_ZCL_FCF_FRAME_TYPE, NULL, HFILL }},
1946 { &hf_zbee_zcl_fcf_mfr_spec,
1947 { "Manufacturer Specific", "zbee.zcl.ms", FT_BOOLEAN, 8, NULL,
1948 ZBEE_ZCL_FCF_MFR_SPEC, NULL, HFILL }},
1950 { &hf_zbee_zcl_fcf_dir,
1951 { "Direction", "zbee.zcl.dir", FT_BOOLEAN, 8, TFS(&tfs_client_server),
1952 ZBEE_ZCL_FCF_DIRECTION, NULL, HFILL }},
1954 { &hf_zbee_zcl_fcf_disable_default_resp,
1955 { "Disable Default Response", "zbee.zcl.ddr", FT_BOOLEAN, 8, NULL,
1956 ZBEE_ZCL_FCF_DISABLE_DEFAULT_RESP, NULL, HFILL }},
1958 { &hf_zbee_zcl_mfr_code,
1959 { "Manufacturer Code", "zbee.zcl.cmd.mc", FT_UINT16, BASE_HEX,
1960 VALS(zbee_mfr_code_names), 0x0, "Assigned manufacturer code.", HFILL }},
1962 { &hf_zbee_zcl_tran_seqno,
1963 { "Sequence Number", "zbee.zcl.cmd.tsn", FT_UINT8, BASE_DEC, NULL, 0x0,
1966 { &hf_zbee_zcl_cmd_id,
1967 { "Command", "zbee.zcl.cmd.id", FT_UINT8, BASE_HEX, VALS(zbee_zcl_cmd_names),
1968 0x0, NULL, HFILL }},
1970 { &hf_zbee_zcl_cs_cmd_id,
1971 { "Command", "zbee.zcl.cs.cmd.id", FT_UINT8, BASE_HEX, VALS(zbee_zcl_cs_cmd_names) /*"Unknown"*/,
1972 0x0, NULL, HFILL }},
1974 { &hf_zbee_zcl_attr_id,
1975 { "Attribute", "zbee.zcl.attr.id", FT_UINT16, BASE_HEX, NULL, 0x0,
1978 { &hf_zbee_zcl_attr_data_type,
1979 { "Data Type", "zbee.zcl.attr.data.type", FT_UINT8, BASE_HEX,
1980 VALS(zbee_zcl_data_type_names), 0x0, NULL, HFILL }},
1982 { &hf_zbee_zcl_attr_boolean,
1983 { "Boolean", "zbee.zcl.attr.boolean", FT_BOOLEAN, 8, TFS(&tfs_true_false), 0xff,
1986 { &hf_zbee_zcl_attr_uint8,
1987 { "Uint8", "zbee.zcl.attr.uint8", FT_UINT8, BASE_DEC_HEX, NULL, 0x0,
1990 { &hf_zbee_zcl_attr_uint16,
1991 { "Uint16", "zbee.zcl.attr.uint16", FT_UINT16, BASE_DEC_HEX, NULL, 0x0,
1994 { &hf_zbee_zcl_attr_uint24,
1995 { "Uint24", "zbee.zcl.attr.uint24", FT_UINT24, BASE_DEC_HEX, NULL, 0x0,
1998 { &hf_zbee_zcl_attr_uint32,
1999 { "Uint32", "zbee.zcl.attr.uint32", FT_UINT32, BASE_DEC_HEX, NULL, 0x0,
2002 { &hf_zbee_zcl_attr_uint64,
2003 { "Uint64", "zbee.zcl.attr.uint64", FT_UINT64, BASE_DEC_HEX, NULL, 0x0,
2006 { &hf_zbee_zcl_attr_int8,
2007 { "Int8", "zbee.zcl.attr.int8", FT_INT8, BASE_DEC, NULL, 0x0,
2010 { &hf_zbee_zcl_attr_int16,
2011 { "Int16", "zbee.zcl.attr.int16", FT_INT16, BASE_DEC, NULL, 0x0,
2014 { &hf_zbee_zcl_attr_int24,
2015 { "Int24", "zbee.zcl.attr.int24", FT_INT24, BASE_DEC, NULL, 0x0,
2018 { &hf_zbee_zcl_attr_int32,
2019 { "Int32", "zbee.zcl.attr.int32", FT_INT32, BASE_DEC, NULL, 0x0,
2022 { &hf_zbee_zcl_attr_int64,
2023 { "Int64", "zbee.zcl.attr.int64", FT_INT64, BASE_DEC, NULL, 0x0,
2026 { &hf_zbee_zcl_attr_semi,
2027 { "Semi Float", "zbee.zcl.attr.float", FT_FLOAT, BASE_NONE, NULL, 0x0,
2030 { &hf_zbee_zcl_attr_float,
2031 { "Float", "zbee.zcl.attr.float", FT_FLOAT, BASE_NONE, NULL, 0x0,
2034 { &hf_zbee_zcl_attr_double,
2035 { "Double Float", "zbee.zcl.attr.float", FT_DOUBLE, BASE_NONE, NULL, 0x0,
2038 { &hf_zbee_zcl_attr_bytes,
2039 { "Bytes", "zbee.zcl.attr.bytes", FT_BYTES, BASE_NONE, NULL, 0x0,
2042 { &hf_zbee_zcl_attr_minint,
2043 { "Minimum Interval", "zbee.zcl.attr.minint", FT_UINT16, BASE_DEC, NULL, 0x0,
2046 { &hf_zbee_zcl_attr_maxint,
2047 { "Maximum Interval", "zbee.zcl.attr.maxint", FT_UINT16, BASE_DEC, NULL, 0x0,
2050 { &hf_zbee_zcl_attr_timeout,
2051 { "Timeout", "zbee.zcl.attr.timeout", FT_UINT16, BASE_DEC, NULL, 0x0,
2054 { &hf_zbee_zcl_attr_hours,
2055 { "Hours", "zbee.zcl.attr.hours", FT_UINT8, BASE_DEC, NULL, 0x0,
2058 { &hf_zbee_zcl_attr_mins,
2059 { "Minutes", "zbee.zcl.attr.mins", FT_UINT8, BASE_DEC, NULL, 0x0,
2062 { &hf_zbee_zcl_attr_secs,
2063 { "Seconds", "zbee.zcl.attr.secs", FT_UINT8, BASE_DEC, NULL, 0x0,
2066 { &hf_zbee_zcl_attr_csecs,
2067 { "Centiseconds", "zbee.zcl.attr.csecs", FT_UINT8, BASE_DEC, NULL, 0x0,
2070 { &hf_zbee_zcl_attr_yy,
2071 { "Year", "zbee.zcl.attr.yy", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
2073 { &hf_zbee_zcl_attr_mm,
2074 { "Month", "zbee.zcl.attr.mm", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
2076 { &hf_zbee_zcl_attr_md,
2077 { "Day of Month", "zbee.zcl.attr.md", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
2079 { &hf_zbee_zcl_attr_wd,
2080 { "Day of Week", "zbee.zcl.attr.wd", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
2082 { &hf_zbee_zcl_attr_utc,
2083 { "UTC", "zbee.zcl.attr.utc", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0, NULL, HFILL }},
2085 { &hf_zbee_zcl_attr_status,
2086 { "Status", "zbee.zcl.attr.status", FT_UINT8, BASE_HEX, VALS(zbee_zcl_status_names),
2087 0x0, NULL, HFILL }},
2089 { &hf_zbee_zcl_attr_dir,
2090 { "Direction", "zbee.zcl.attr.dir", FT_UINT8, BASE_HEX, VALS(zbee_zcl_dir_names),
2091 0x0, NULL, HFILL }},
2093 { &hf_zbee_zcl_attr_dis,
2094 { "Discovery", "zbee.zcl.attr.dis", FT_UINT8, BASE_HEX, VALS(zbee_zcl_dis_names),
2095 0x0, NULL, HFILL }},
2097 { &hf_zbee_zcl_attr_cid,
2098 { "Cluster", "zbee.zcl.attr.cid", FT_UINT16, BASE_HEX, NULL, 0x0,
2101 { &hf_zbee_zcl_attr_start,
2102 { "Start Attribute", "zbee.zcl.attr.start", FT_UINT16, BASE_HEX, NULL, 0x0,
2105 { &hf_zbee_zcl_attr_maxnum,
2106 { "Maxiumum Number", "zbee.zcl.attr.maxnum", FT_UINT8, BASE_DEC, NULL, 0x0,
2109 { &hf_zbee_zcl_attr_str_len,
2110 { "Length", "zbee.zcl.attr.str.len", FT_UINT8, BASE_DEC, NULL, 0x0,
2113 { &hf_zbee_zcl_attr_str,
2114 { "String", "zbee.zcl.attr.str", FT_STRING, BASE_NONE, NULL, 0x0,
2117 { &hf_zbee_zcl_attr_ostr,
2118 { "Octet String", "zbee.zcl.attr.ostr", FT_STRING, BASE_NONE, NULL, 0x0,
2123 gint *ett[ZBEE_ZCL_NUM_INDIVIDUAL_ETT + ZBEE_ZCL_NUM_ATTR_ETT];
2125 ett[0] = &ett_zbee_zcl;
2126 ett[1] = &ett_zbee_zcl_fcf;
2128 j = ZBEE_ZCL_NUM_INDIVIDUAL_ETT;
2130 /* initialize attribute subtree types */
2131 for ( i = 0; i < ZBEE_ZCL_NUM_ATTR_ETT; i++, j++) {
2132 ett_zbee_zcl_attr[i] = -1;
2133 ett[j] = &ett_zbee_zcl_attr[i];
2136 /* Register ZigBee ZCL protocol with Wireshark. */
2137 proto_zbee_zcl = proto_register_protocol("ZigBee Cluster Library", "ZigBee ZCL", "zbee.zcl");
2138 proto_register_field_array(proto_zbee_zcl, hf, array_length(hf));
2139 proto_register_subtree_array(ett, array_length(ett));
2141 /* Register the ZCL dissector and subdissector list. */
2142 register_dissector("zbee.zcl", dissect_zbee_zcl, proto_zbee_zcl);
2144 } /* proto_register_zbee_zcl */
2146 /*FUNCTION:------------------------------------------------------
2148 * proto_reg_handoff_zbee_zcl
2150 * Finds the dissectors used in this module.
2155 *---------------------------------------------------------------
2157 void proto_reg_handoff_zbee_zcl(void)
2159 dissector_handle_t zbee_zcl_handle;
2161 /* Find the dissectors we need. */
2162 data_handle = find_dissector("data");
2164 /* Register our dissector for the appropriate profiles. */
2165 zbee_zcl_handle = find_dissector("zbee.zcl");
2166 dissector_add("zbee.profile", ZBEE_PROFILE_IPM, zbee_zcl_handle);
2167 dissector_add("zbee.profile", ZBEE_PROFILE_T1, zbee_zcl_handle);
2168 dissector_add("zbee.profile", ZBEE_PROFILE_HA, zbee_zcl_handle);
2169 dissector_add("zbee.profile", ZBEE_PROFILE_CBA, zbee_zcl_handle);
2170 dissector_add("zbee.profile", ZBEE_PROFILE_WSN, zbee_zcl_handle);
2171 dissector_add("zbee.profile", ZBEE_PROFILE_TA, zbee_zcl_handle);
2172 dissector_add("zbee.profile", ZBEE_PROFILE_HC, zbee_zcl_handle);
2173 dissector_add("zbee.profile", ZBEE_PROFILE_SE, zbee_zcl_handle);
2175 dissector_add("zbee.profile", ZBEE_PROFILE_C4_CL, zbee_zcl_handle);
2176 } /* proto_reg_handoff_zbee_zcl */