epan/dissectors/pidl/ C99 drsuapi
[wireshark-sm.git] / epan / dissectors / packet-zbee-zcl-ha.c
blobef029f53d643d79f1d75174647c655f101ec5cc4
1 /* packet-zbee-zcl-ha.c
2 * Dissector routines for the ZigBee ZCL HA clusters like
3 * Appliance Identification, Meter Identification ...
4 * By Fabio Tarabelloni <fabio.tarabelloni@reloc.it>
5 * Copyright 2013 RELOC s.r.l.
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * SPDX-License-Identifier: GPL-2.0-or-later
14 /* Include Files */
15 #include "config.h"
17 #include <epan/packet.h>
18 #include <epan/to_str.h>
19 #include <wsutil/epochs.h>
21 #include "packet-zbee.h"
22 #include "packet-zbee-aps.h"
23 #include "packet-zbee-zcl.h"
25 /* ########################################################################## */
26 /* #### (0x0B00) APPLIANCE IDENTIFICATION CLUSTER ########################### */
27 /* ########################################################################## */
29 /*************************/
30 /* Defines */
31 /*************************/
33 #define ZBEE_ZCL_APPL_IDT_NUM_GENERIC_ETT 2
34 #define ZBEE_ZCL_APPL_IDT_NUM_ETT ZBEE_ZCL_APPL_IDT_NUM_GENERIC_ETT
36 /* Attributes */
37 #define ZBEE_ZCL_ATTR_ID_APPL_IDT_BASIC_IDENT 0x0000 /* Basic Identification */
38 #define ZBEE_ZCL_ATTR_ID_APPL_IDT_COMPANY_NAME 0x0010 /* Company Name */
39 #define ZBEE_ZCL_ATTR_ID_APPL_IDT_COMPANY_ID 0x0011 /* Company ID */
40 #define ZBEE_ZCL_ATTR_ID_APPL_IDT_BRAND_NAME 0x0012 /* Brand Name */
41 #define ZBEE_ZCL_ATTR_ID_APPL_IDT_BRAND_ID 0x0013 /* Brand ID */
42 #define ZBEE_ZCL_ATTR_ID_APPL_IDT_MODEL 0x0014 /* Model */
43 #define ZBEE_ZCL_ATTR_ID_APPL_IDT_PART_NUM 0x0015 /* Part Number */
44 #define ZBEE_ZCL_ATTR_ID_APPL_IDT_PROD_REV 0x0016 /* Product Revision */
45 #define ZBEE_ZCL_ATTR_ID_APPL_IDT_SW_REV 0x0017 /* Software Revision */
46 #define ZBEE_ZCL_ATTR_ID_APPL_IDT_PROD_TYPE_NAME 0x0018 /* Product Type Name */
47 #define ZBEE_ZCL_ATTR_ID_APPL_IDT_PROD_TYPE_ID 0x0019 /* Product Type ID */
48 #define ZBEE_ZCL_ATTR_ID_APPL_IDT_CECED_SPEC_VER 0x001A /* CECED Specification Version */
50 /* Server Commands Received - None */
52 /* Server Commands Generated - None */
54 /* Companies Id */
55 #define ZBEE_ZCL_APPL_IDT_COMPANY_ID_IC 0x4943 /* Indesit Company */
57 /* Brands Id */
58 #define ZBEE_ZCL_APPL_IDT_BRAND_ID_AR 0x4152 /* Ariston */
59 #define ZBEE_ZCL_APPL_IDT_BRAND_ID_IN 0x494E /* Indesit */
60 #define ZBEE_ZCL_APPL_IDT_BRAND_ID_SC 0x5343 /* Scholtes */
61 #define ZBEE_ZCL_APPL_IDT_BRAND_ID_ST 0x5354 /* Stinol */
63 /* Product Types Id */
64 #define ZBEE_ZCL_APPL_IDT_PROD_TYPE_ID_WG 0x0000 /* WhiteGoods */
65 #define ZBEE_ZCL_APPL_IDT_PROD_TYPE_ID_DW 0x5601 /* Dishwasher */
66 #define ZBEE_ZCL_APPL_IDT_PROD_TYPE_ID_TD 0x5602 /* Tumble Dryer */
67 #define ZBEE_ZCL_APPL_IDT_PROD_TYPE_ID_WD 0x5603 /* Washer Dryer */
68 #define ZBEE_ZCL_APPL_IDT_PROD_TYPE_ID_WM 0x5604 /* Washing Machine */
69 #define ZBEE_ZCL_APPL_IDT_PROD_TYPE_ID_GO 0x5E01 /* Oven */
70 #define ZBEE_ZCL_APPL_IDT_PROD_TYPE_ID_HB 0x5E03 /* Hobs */
71 #define ZBEE_ZCL_APPL_IDT_PROD_TYPE_ID_OV 0x5E06 /* Electrical Oven */
72 #define ZBEE_ZCL_APPL_IDT_PROD_TYPE_ID_IH 0x5E09 /* Induction Hobs */
73 #define ZBEE_ZCL_APPL_IDT_PROD_TYPE_ID_RF 0x6601 /* Refrigerator Freezer */
75 /* Product Name Types Id */
76 #define ZBEE_ZCL_APPL_IDT_PROD_TYPE_NAME_ID_WG 0x0000 /* WhiteGoods */
77 #define ZBEE_ZCL_APPL_IDT_PROD_TYPE_NAME_ID_DW 0x4457 /* Dishwasher */
78 #define ZBEE_ZCL_APPL_IDT_PROD_TYPE_NAME_ID_TD 0x5444 /* Tumble Dryer */
79 #define ZBEE_ZCL_APPL_IDT_PROD_TYPE_NAME_ID_WD 0x5744 /* Washer Dryer */
80 #define ZBEE_ZCL_APPL_IDT_PROD_TYPE_NAME_ID_WM 0x574D /* Washing Machine */
81 #define ZBEE_ZCL_APPL_IDT_PROD_TYPE_NAME_ID_GO 0x474F /* Oven */
82 #define ZBEE_ZCL_APPL_IDT_PROD_TYPE_NAME_ID_HB 0x4842 /* Hobs */
83 #define ZBEE_ZCL_APPL_IDT_PROD_TYPE_NAME_ID_OV 0x4F56 /* Electrical Oven */
84 #define ZBEE_ZCL_APPL_IDT_PROD_TYPE_NAME_ID_IH 0x4948 /* Induction Hobs */
85 #define ZBEE_ZCL_APPL_IDT_PROD_TYPE_NAME_ID_RF 0x5246 /* Refrigerator Freezer */
87 /* CECED Specification Version values */
88 #define ZBEE_ZCL_APPL_IDT_CECED_SPEC_VAL_1_0_NOT_CERT 0x10 /* Compliant with v1.0, not certified */
89 #define ZBEE_ZCL_APPL_IDT_CECED_SPEC_VAL_1_0_CERT 0x1A /* Compliant with v1.0, certified */
91 /*************************/
92 /* Function Declarations */
93 /*************************/
95 void proto_register_zbee_zcl_appl_idt(void);
96 void proto_reg_handoff_zbee_zcl_appl_idt(void);
98 /* Command Dissector Helpers */
99 static void dissect_zcl_appl_idt_attr_data(proto_tree *tree, tvbuff_t *tvb, unsigned *offset, uint16_t attr_id, unsigned data_type, bool client_attr);
101 /* Private functions prototype */
103 /*************************/
104 /* Global Variables */
105 /*************************/
107 /* Initialize the protocol and registered fields */
108 static int proto_zbee_zcl_appl_idt;
110 static int hf_zbee_zcl_appl_idt_attr_id;
111 static int hf_zbee_zcl_appl_idt_company_id;
112 static int hf_zbee_zcl_appl_idt_brand_id;
113 static int hf_zbee_zcl_appl_idt_string_len;
114 static int hf_zbee_zcl_appl_idt_prod_type_name;
115 static int hf_zbee_zcl_appl_idt_prod_type_id;
116 static int hf_zbee_zcl_appl_idt_ceced_spec_ver;
118 /* Initialize the subtree pointers */
119 static int ett_zbee_zcl_appl_idt;
120 static int ett_zbee_zcl_appl_idt_basic;
122 /* Attributes */
123 static const value_string zbee_zcl_appl_idt_attr_names[] = {
124 { ZBEE_ZCL_ATTR_ID_APPL_IDT_BASIC_IDENT, "Basic Identification" },
125 { ZBEE_ZCL_ATTR_ID_APPL_IDT_COMPANY_NAME, "Company Name" },
126 { ZBEE_ZCL_ATTR_ID_APPL_IDT_COMPANY_ID, "Company Id" },
127 { ZBEE_ZCL_ATTR_ID_APPL_IDT_BRAND_NAME, "Brand Name" },
128 { ZBEE_ZCL_ATTR_ID_APPL_IDT_BRAND_ID, "Brand Id" },
129 { ZBEE_ZCL_ATTR_ID_APPL_IDT_MODEL, "Model" },
130 { ZBEE_ZCL_ATTR_ID_APPL_IDT_PART_NUM, "Part Number" },
131 { ZBEE_ZCL_ATTR_ID_APPL_IDT_PROD_REV, "Product Revision" },
132 { ZBEE_ZCL_ATTR_ID_APPL_IDT_SW_REV, "Software Revision" },
133 { ZBEE_ZCL_ATTR_ID_APPL_IDT_PROD_TYPE_NAME, "Product Type Name" },
134 { ZBEE_ZCL_ATTR_ID_APPL_IDT_PROD_TYPE_ID, "Product Type Id" },
135 { ZBEE_ZCL_ATTR_ID_APPL_IDT_CECED_SPEC_VER, "CECED Specification Version" },
136 { 0, NULL }
139 /* Company Names */
140 static const value_string zbee_zcl_appl_idt_company_names[] = {
141 { ZBEE_ZCL_APPL_IDT_COMPANY_ID_IC, "Indesit Company" },
142 { 0, NULL }
145 /* Brand Names */
146 static const value_string zbee_zcl_appl_idt_brand_names[] = {
147 { ZBEE_ZCL_APPL_IDT_BRAND_ID_AR, "Ariston" },
148 { ZBEE_ZCL_APPL_IDT_BRAND_ID_IN, "Indesit" },
149 { ZBEE_ZCL_APPL_IDT_BRAND_ID_SC, "Scholtes" },
150 { ZBEE_ZCL_APPL_IDT_BRAND_ID_ST, "Stinol" },
151 { 0, NULL }
154 /* Product Type Names */
155 static const value_string zbee_zcl_appl_idt_prod_type_names[] = {
156 { ZBEE_ZCL_APPL_IDT_PROD_TYPE_ID_WG, "WhiteGoods" },
157 { ZBEE_ZCL_APPL_IDT_PROD_TYPE_ID_DW, "Dishwasher" },
158 { ZBEE_ZCL_APPL_IDT_PROD_TYPE_ID_TD, "Tumble Dryer" },
159 { ZBEE_ZCL_APPL_IDT_PROD_TYPE_ID_WD, "Washer Dryer" },
160 { ZBEE_ZCL_APPL_IDT_PROD_TYPE_ID_WM, "Washing Machine" },
161 { ZBEE_ZCL_APPL_IDT_PROD_TYPE_ID_GO, "Oven" },
162 { ZBEE_ZCL_APPL_IDT_PROD_TYPE_ID_HB, "Hobs" },
163 { ZBEE_ZCL_APPL_IDT_PROD_TYPE_ID_OV, "Electrical Oven" },
164 { ZBEE_ZCL_APPL_IDT_PROD_TYPE_ID_IH, "Induction Hobs" },
165 { ZBEE_ZCL_APPL_IDT_PROD_TYPE_ID_RF, "Refrigerator Freezer" },
166 { 0, NULL }
169 /* Product Type Name Names */
170 static const value_string zbee_zcl_appl_idt_prod_type_name_names[] = {
171 { ZBEE_ZCL_APPL_IDT_PROD_TYPE_NAME_ID_WG, "WhiteGoods" },
172 { ZBEE_ZCL_APPL_IDT_PROD_TYPE_NAME_ID_DW, "Dishwasher" },
173 { ZBEE_ZCL_APPL_IDT_PROD_TYPE_NAME_ID_TD, "Tumble Dryer" },
174 { ZBEE_ZCL_APPL_IDT_PROD_TYPE_NAME_ID_WD, "Washer Dryer" },
175 { ZBEE_ZCL_APPL_IDT_PROD_TYPE_NAME_ID_WM, "Washing Machine" },
176 { ZBEE_ZCL_APPL_IDT_PROD_TYPE_NAME_ID_GO, "Oven" },
177 { ZBEE_ZCL_APPL_IDT_PROD_TYPE_NAME_ID_HB, "Hobs" },
178 { ZBEE_ZCL_APPL_IDT_PROD_TYPE_NAME_ID_OV, "Electrical Oven" },
179 { ZBEE_ZCL_APPL_IDT_PROD_TYPE_NAME_ID_IH, "Induction Hobs" },
180 { ZBEE_ZCL_APPL_IDT_PROD_TYPE_NAME_ID_RF, "Refrigerator Freezer" },
181 { 0, NULL }
184 /* CECED Specification Version Names */
185 static const value_string zbee_zcl_appl_idt_ceced_spec_ver_names[] = {
186 { ZBEE_ZCL_APPL_IDT_CECED_SPEC_VAL_1_0_NOT_CERT, "Compliant with v1.0, not certified" },
187 { ZBEE_ZCL_APPL_IDT_CECED_SPEC_VAL_1_0_CERT, "Compliant with v1.0, certified" },
188 { 0, NULL }
191 /*************************/
192 /* Function Bodies */
193 /*************************/
196 *ZigBee ZCL Appliance Identification cluster dissector for wireshark.
198 *@param tvb pointer to buffer containing raw packet.
199 *@param pinfo pointer to packet information fields
200 *@param tree pointer to data tree Wireshark uses to display packet.
202 static int
203 dissect_zbee_zcl_appl_idt(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void* data _U_)
205 return tvb_captured_length(tvb);
206 } /*dissect_zbee_zcl_appl_idt*/
209 *This function is called by ZCL foundation dissector in order to decode
211 *@param tree pointer to data tree Wireshark uses to display packet.
212 *@param tvb pointer to buffer containing raw packet.
213 *@param offset pointer to buffer offset
214 *@param attr_id attribute identifier
215 *@param data_type attribute data type
216 *@param client_attr ZCL client
218 void
219 dissect_zcl_appl_idt_attr_data(proto_tree *tree, tvbuff_t *tvb, unsigned *offset, uint16_t attr_id, unsigned data_type, bool client_attr)
221 proto_tree *sub_tree;
222 uint64_t value64;
224 /* Dissect attribute data type and data */
225 switch ( attr_id ) {
227 case ZBEE_ZCL_ATTR_ID_APPL_IDT_BASIC_IDENT:
228 value64 = tvb_get_letoh56(tvb, *offset);
229 sub_tree = proto_tree_add_subtree_format(tree, tvb, *offset, 8, ett_zbee_zcl_appl_idt_basic, NULL,
230 "Basic Identification: 0x%" PRIx64, value64);
232 proto_tree_add_item(sub_tree, hf_zbee_zcl_appl_idt_company_id, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
233 *offset += 2;
234 proto_tree_add_item(sub_tree, hf_zbee_zcl_appl_idt_brand_id, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
235 *offset += 2;
236 proto_tree_add_item(sub_tree, hf_zbee_zcl_appl_idt_prod_type_id, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
237 *offset += 2;
238 proto_tree_add_item(sub_tree, hf_zbee_zcl_appl_idt_ceced_spec_ver, tvb, *offset, 1, ENC_NA);
239 *offset += 1;
240 break;
242 case ZBEE_ZCL_ATTR_ID_APPL_IDT_COMPANY_ID:
243 proto_tree_add_item(tree, hf_zbee_zcl_appl_idt_company_id, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
244 *offset += 2;
245 break;
247 case ZBEE_ZCL_ATTR_ID_APPL_IDT_BRAND_ID:
248 proto_tree_add_item(tree, hf_zbee_zcl_appl_idt_brand_id, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
249 *offset += 2;
250 break;
252 case ZBEE_ZCL_ATTR_ID_APPL_IDT_PROD_TYPE_NAME:
253 proto_tree_add_item(tree, hf_zbee_zcl_appl_idt_string_len, tvb, *offset, 1, ENC_NA);
254 *offset += 1;
255 proto_tree_add_item(tree, hf_zbee_zcl_appl_idt_prod_type_name, tvb, *offset, 2, ENC_BIG_ENDIAN);
256 *offset += 2;
257 break;
259 case ZBEE_ZCL_ATTR_ID_APPL_IDT_PROD_TYPE_ID:
260 proto_tree_add_item(tree, hf_zbee_zcl_appl_idt_prod_type_id, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
261 *offset += 2;
262 break;
264 case ZBEE_ZCL_ATTR_ID_APPL_IDT_CECED_SPEC_VER:
265 proto_tree_add_item(tree, hf_zbee_zcl_appl_idt_ceced_spec_ver, tvb, *offset, 1, ENC_NA);
266 *offset += 1;
267 break;
269 default:
270 dissect_zcl_attr_data(tvb, tree, offset, data_type, client_attr);
271 break;
274 } /*dissect_zcl_appl_idt_attr_data*/
277 *This function registers the ZCL Appliance Identification dissector
280 void
281 proto_register_zbee_zcl_appl_idt(void)
283 static hf_register_info hf[] = {
285 { &hf_zbee_zcl_appl_idt_attr_id,
286 { "Attribute", "zbee_zcl_ha.applident.attr_id", FT_UINT16, BASE_HEX, VALS(zbee_zcl_appl_idt_attr_names),
287 0x00, NULL, HFILL } },
289 { &hf_zbee_zcl_appl_idt_company_id,
290 { "Company ID", "zbee_zcl_ha.applident.attr.company.id", FT_UINT16, BASE_HEX, VALS(zbee_zcl_appl_idt_company_names),
291 0x00, NULL, HFILL } },
293 { &hf_zbee_zcl_appl_idt_brand_id,
294 { "Brand ID", "zbee_zcl_ha.applident.attr.brand.id", FT_UINT16, BASE_HEX, VALS(zbee_zcl_appl_idt_brand_names),
295 0x00, NULL, HFILL } },
297 { &hf_zbee_zcl_appl_idt_string_len,
298 { "Length", "zbee_zcl_ha.applident.string.len", FT_UINT8, BASE_HEX, NULL,
299 0x00, NULL, HFILL } },
301 { &hf_zbee_zcl_appl_idt_prod_type_name,
302 { "Product Type Name", "zbee_zcl_ha.applident.attr.prod_type.name", FT_UINT16, BASE_HEX, VALS(zbee_zcl_appl_idt_prod_type_name_names),
303 0x00, NULL, HFILL } },
305 { &hf_zbee_zcl_appl_idt_prod_type_id,
306 { "Product Type ID", "zbee_zcl_ha.applident.attr.prod_type.id", FT_UINT16, BASE_HEX, VALS(zbee_zcl_appl_idt_prod_type_names),
307 0x00, NULL, HFILL } },
309 { &hf_zbee_zcl_appl_idt_ceced_spec_ver,
310 { "CECED Spec. Version", "zbee_zcl_ha.applident.attr.ceced_spec_ver", FT_UINT8, BASE_HEX, VALS(zbee_zcl_appl_idt_ceced_spec_ver_names),
311 0x00, NULL, HFILL } }
315 /* ZCL Appliance Identification subtrees */
316 int *ett[ZBEE_ZCL_APPL_IDT_NUM_ETT];
318 ett[0] = &ett_zbee_zcl_appl_idt;
319 ett[1] = &ett_zbee_zcl_appl_idt_basic;
321 /* Register the ZigBee ZCL Appliance Identification cluster protocol name and description */
322 proto_zbee_zcl_appl_idt = proto_register_protocol("ZigBee ZCL Appliance Identification", "ZCL Appliance Identification", ZBEE_PROTOABBREV_ZCL_APPLIDT);
323 proto_register_field_array(proto_zbee_zcl_appl_idt, hf, array_length(hf));
324 proto_register_subtree_array(ett, array_length(ett));
326 /* Register the ZigBee ZCL Appliance Identification dissector. */
327 register_dissector(ZBEE_PROTOABBREV_ZCL_APPLIDT, dissect_zbee_zcl_appl_idt, proto_zbee_zcl_appl_idt);
328 } /*proto_register_zbee_zcl_appl_idt*/
331 *Hands off the Zcl Appliance Identification dissector.
334 void
335 proto_reg_handoff_zbee_zcl_appl_idt(void)
337 zbee_zcl_init_cluster( ZBEE_PROTOABBREV_ZCL_APPLIDT,
338 proto_zbee_zcl_appl_idt,
339 ett_zbee_zcl_appl_idt,
340 ZBEE_ZCL_CID_APPLIANCE_IDENTIFICATION,
341 ZBEE_MFG_CODE_NONE,
342 hf_zbee_zcl_appl_idt_attr_id,
343 hf_zbee_zcl_appl_idt_attr_id,
344 -1, -1,
345 (zbee_zcl_fn_attr_data)dissect_zcl_appl_idt_attr_data
347 } /*proto_reg_handoff_zbee_zcl_appl_idt*/
349 /* ########################################################################## */
350 /* #### (0x0B01) METER IDENTIFICATION CLUSTER ############################### */
351 /* ########################################################################## */
353 /*************************/
354 /* Defines */
355 /*************************/
357 /* Attributes */
358 #define ZBEE_ZCL_ATTR_ID_MET_IDT_COMPANY_NAME 0x0000 /* Company Name */
359 #define ZBEE_ZCL_ATTR_ID_MET_IDT_METER_TYPE_ID 0x0001 /* Meter Type ID */
360 #define ZBEE_ZCL_ATTR_ID_MET_IDT_DATA_QUALITY_ID 0x0004 /* Data Quality ID */
361 #define ZBEE_ZCL_ATTR_ID_MET_IDT_CUSTOMER_NAME 0x0005 /* Customer Name */
362 #define ZBEE_ZCL_ATTR_ID_MET_IDT_MODEL 0x0006 /* Model */
363 #define ZBEE_ZCL_ATTR_ID_MET_IDT_PART_NUM 0x0007 /* Part Number */
364 #define ZBEE_ZCL_ATTR_ID_MET_IDT_PRODUCT_REVISION 0x0008 /* Product Revision */
365 #define ZBEE_ZCL_ATTR_ID_MET_IDT_SW_REVISION 0x000a /* Software Revision */
366 #define ZBEE_ZCL_ATTR_ID_MET_IDT_UTILITY_NAME 0x000b /* Utility Name */
367 #define ZBEE_ZCL_ATTR_ID_MET_IDT_POD 0x000c /* POD */
368 #define ZBEE_ZCL_ATTR_ID_MET_IDT_AVAILABLE_PWR 0x000d /* Available Power */
369 #define ZBEE_ZCL_ATTR_ID_MET_IDT_PWR_TH 0x000e /* Power Threshold */
371 /* Server Commands Received - None */
373 /* Server Commands Generated - None */
376 /* Meter Type IDs */
377 #define ZBEE_ZCL_MET_IDT_MET_TYPE_UTILITY_1_METER 0x0000 /* Utility Primary Meter */
378 #define ZBEE_ZCL_MET_IDT_MET_TYPE_UTILITY_P_METER 0x0001 /* Utility Production Meter */
379 #define ZBEE_ZCL_MET_IDT_MET_TYPE_UTILITY_2_METER 0x0002 /* Utility Secondary Meter */
380 #define ZBEE_ZCL_MET_IDT_MET_TYPE_PRIVATE_1_METER 0x0100 /* Private Primary Meter */
381 #define ZBEE_ZCL_MET_IDT_MET_TYPE_PRIVATE_P_METER 0x0101 /* Private Primary Meter */
382 #define ZBEE_ZCL_MET_IDT_MET_TYPE_PRIVATE_2_METER 0x0102 /* Private Primary Meter */
383 #define ZBEE_ZCL_MET_IDT_MET_TYPE_GENERIC_METER 0x0110 /* Generic Meter */
386 /* Data Quality IDs */
387 #define ZBEE_ZCL_MET_IDT_DATA_QLTY_ALL_DATA_CERTIF 0x0000 /* All Data Certified */
388 #define ZBEE_ZCL_MET_IDT_DATA_QLTY_ALL_CERTIF_WO_INST_PWR 0x0001 /* Only Instantaneous Power not Certified */
389 #define ZBEE_ZCL_MET_IDT_DATA_QLTY_ALL_CERTIF_WO_CUM_CONS 0x0002 /* Only Cumulated Consumption not Certified */
390 #define ZBEE_ZCL_MET_IDT_DATA_QLTY_NOT_CERTIF_DATA 0x0003 /* Not Certified Data */
392 /*************************/
393 /* Function Declarations */
394 /*************************/
396 void proto_register_zbee_zcl_met_idt(void);
397 void proto_reg_handoff_zbee_zcl_met_idt(void);
399 /* Command Dissector Helpers */
400 static void dissect_zcl_met_idt_attr_data (proto_tree *tree, tvbuff_t *tvb, unsigned *offset, uint16_t attr_id, unsigned data_type, bool client_attr);
402 /* Private functions prototype */
404 /*************************/
405 /* Global Variables */
406 /*************************/
408 /* Initialize the protocol and registered fields */
409 static int proto_zbee_zcl_met_idt;
411 static int hf_zbee_zcl_met_idt_attr_id;
412 static int hf_zbee_zcl_met_idt_meter_type_id;
413 static int hf_zbee_zcl_met_idt_data_quality_id;
415 /* Initialize the subtree pointers */
416 static int ett_zbee_zcl_met_idt;
418 /* Attributes */
419 static const value_string zbee_zcl_met_idt_attr_names[] = {
420 { ZBEE_ZCL_ATTR_ID_MET_IDT_COMPANY_NAME, "Company Name" },
421 { ZBEE_ZCL_ATTR_ID_MET_IDT_METER_TYPE_ID, "Meter Type ID" },
422 { ZBEE_ZCL_ATTR_ID_MET_IDT_DATA_QUALITY_ID, "Data Quality ID" },
423 { ZBEE_ZCL_ATTR_ID_MET_IDT_CUSTOMER_NAME, "Customer Name" },
424 { ZBEE_ZCL_ATTR_ID_MET_IDT_MODEL, "Model" },
425 { ZBEE_ZCL_ATTR_ID_MET_IDT_PART_NUM, "Part Number" },
426 { ZBEE_ZCL_ATTR_ID_MET_IDT_PRODUCT_REVISION, "Product Revision" },
427 { ZBEE_ZCL_ATTR_ID_MET_IDT_SW_REVISION, "Software Revision" },
428 { ZBEE_ZCL_ATTR_ID_MET_IDT_UTILITY_NAME, "Utility Name" },
429 { ZBEE_ZCL_ATTR_ID_MET_IDT_POD, "POD" },
430 { ZBEE_ZCL_ATTR_ID_MET_IDT_AVAILABLE_PWR, "Available Power" },
431 { ZBEE_ZCL_ATTR_ID_MET_IDT_PWR_TH, "Power Threshold" },
432 { 0, NULL }
435 /* Meter Type IDs */
436 static const value_string zbee_zcl_met_idt_meter_type_names[] = {
437 { ZBEE_ZCL_MET_IDT_MET_TYPE_UTILITY_1_METER, "Utility Primary Meter" },
438 { ZBEE_ZCL_MET_IDT_MET_TYPE_UTILITY_P_METER, "Meter Type ID" },
439 { ZBEE_ZCL_MET_IDT_MET_TYPE_UTILITY_2_METER, "Data Quality ID" },
440 { ZBEE_ZCL_MET_IDT_MET_TYPE_PRIVATE_1_METER, "Customer Name" },
441 { ZBEE_ZCL_MET_IDT_MET_TYPE_PRIVATE_P_METER, "Model" },
442 { ZBEE_ZCL_MET_IDT_MET_TYPE_PRIVATE_2_METER, "Part Number" },
443 { ZBEE_ZCL_MET_IDT_MET_TYPE_GENERIC_METER, "Product Revision" },
444 { 0, NULL }
447 /* Data Quality IDs */
448 static const value_string zbee_zcl_met_idt_data_quality_names[] = {
449 { ZBEE_ZCL_MET_IDT_DATA_QLTY_ALL_DATA_CERTIF, "All Data Certified" },
450 { ZBEE_ZCL_MET_IDT_DATA_QLTY_ALL_CERTIF_WO_INST_PWR, "Only Instantaneous Power not Certified" },
451 { ZBEE_ZCL_MET_IDT_DATA_QLTY_ALL_CERTIF_WO_CUM_CONS, "Only Cumulated Consumption not Certified" },
452 { ZBEE_ZCL_MET_IDT_DATA_QLTY_NOT_CERTIF_DATA, "Not Certified Data" },
453 { 0, NULL }
456 /*************************/
457 /* Function Bodies */
458 /*************************/
461 *ZigBee ZCL Meter Identification cluster dissector for wireshark.
463 *@param tvb pointer to buffer containing raw packet.
464 *@param pinfo pointer to packet information fields
465 *@param tree pointer to data tree Wireshark uses to display packet.
467 static int
468 dissect_zbee_zcl_met_idt(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void* data _U_)
470 return tvb_captured_length(tvb);
471 } /*dissect_zbee_zcl_met_idt*/
474 *This function is called by ZCL foundation dissector in order to decode
476 *@param tree pointer to data tree Wireshark uses to display packet.
477 *@param tvb pointer to buffer containing raw packet.
478 *@param offset pointer to buffer offset
479 *@param attr_id attribute identifier
480 *@param data_type attribute data type
481 *@param client_attr ZCL client
483 void
484 dissect_zcl_met_idt_attr_data (proto_tree *tree, tvbuff_t *tvb, unsigned *offset, uint16_t attr_id, unsigned data_type, bool client_attr)
486 /* Dissect attribute data type and data */
487 switch ( attr_id ) {
489 case ZBEE_ZCL_ATTR_ID_MET_IDT_METER_TYPE_ID:
490 proto_tree_add_item(tree, hf_zbee_zcl_met_idt_meter_type_id, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
491 *offset += 2;
492 break;
494 case ZBEE_ZCL_ATTR_ID_MET_IDT_DATA_QUALITY_ID:
495 proto_tree_add_item(tree, hf_zbee_zcl_met_idt_data_quality_id, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
496 *offset += 2;
497 break;
499 default:
500 dissect_zcl_attr_data(tvb, tree, offset, data_type, client_attr);
501 break;
504 } /*dissect_zcl_met_idt_attr_data*/
507 *This function registers the ZCL Meter Identification dissector
510 void
511 proto_register_zbee_zcl_met_idt(void)
513 static hf_register_info hf[] = {
515 { &hf_zbee_zcl_met_idt_attr_id,
516 { "Attribute", "zbee_zcl_ha.metidt.attr_id", FT_UINT16, BASE_HEX, VALS(zbee_zcl_met_idt_attr_names),
517 0x00, NULL, HFILL } },
519 { &hf_zbee_zcl_met_idt_meter_type_id,
520 { "Meter Type ID", "zbee_zcl_ha.metidt.attr.meter_type.id", FT_UINT16, BASE_HEX, VALS(zbee_zcl_met_idt_meter_type_names),
521 0x00, NULL, HFILL } },
523 { &hf_zbee_zcl_met_idt_data_quality_id,
524 { "Data Quality ID", "zbee_zcl_ha.metidt.attr.data_quality.id", FT_UINT16, BASE_HEX, VALS(zbee_zcl_met_idt_data_quality_names),
525 0x00, NULL, HFILL } }
529 /* ZCL Meter Identification subtrees */
530 int *ett[] = {
531 &ett_zbee_zcl_met_idt
534 /* Register the ZigBee ZCL Meter Identification cluster protocol name and description */
535 proto_zbee_zcl_met_idt = proto_register_protocol("ZigBee ZCL Meter Identification", "ZCL Meter Identification", ZBEE_PROTOABBREV_ZCL_METIDT);
536 proto_register_field_array(proto_zbee_zcl_met_idt, hf, array_length(hf));
537 proto_register_subtree_array(ett, array_length(ett));
539 /* Register the ZigBee ZCL Meter Identification dissector. */
540 register_dissector(ZBEE_PROTOABBREV_ZCL_METIDT, dissect_zbee_zcl_met_idt, proto_zbee_zcl_met_idt);
541 } /*proto_register_zbee_zcl_met_idt*/
544 *Hands off the Zcl Meter Identification dissector.
547 void
548 proto_reg_handoff_zbee_zcl_met_idt(void)
550 zbee_zcl_init_cluster( ZBEE_PROTOABBREV_ZCL_METIDT,
551 proto_zbee_zcl_met_idt,
552 ett_zbee_zcl_met_idt,
553 ZBEE_ZCL_CID_METER_IDENTIFICATION,
554 ZBEE_MFG_CODE_NONE,
555 hf_zbee_zcl_met_idt_attr_id,
556 hf_zbee_zcl_met_idt_attr_id,
557 -1, -1,
558 (zbee_zcl_fn_attr_data)dissect_zcl_met_idt_attr_data
560 } /*proto_reg_handoff_zbee_zcl_met_idt*/
562 /* ########################################################################## */
563 /* #### (0x0B02) APPLIANCE EVENTS AND ALERT CLUSTER ######################### */
564 /* ########################################################################## */
566 /*************************/
567 /* Defines */
568 /*************************/
570 #define ZBEE_ZCL_APPL_EVTALT_NUM_GENERIC_ETT 1
571 #define ZBEE_ZCL_APPL_EVTALT_NUM_STRUCT_ETT 15
572 #define ZBEE_ZCL_APPL_EVTALT_NUM_ETT (ZBEE_ZCL_APPL_EVTALT_NUM_GENERIC_ETT + \
573 ZBEE_ZCL_APPL_EVTALT_NUM_STRUCT_ETT)
574 /* Attributes - None */
576 /* Server Commands Received */
577 #define ZBEE_ZCL_CMD_ID_APPL_EVTALT_GET_ALERTS_CMD 0x00 /* Get Alerts */
579 /* Server Commands Generated */
580 #define ZBEE_ZCL_CMD_ID_APPL_EVTALT_GET_ALERTS_RSP_CMD 0x00 /* Get Alerts Response */
581 #define ZBEE_ZCL_CMD_ID_APPL_EVTALT_ALERTS_NOTIF_CMD 0x01 /* Alerts Notification */
582 #define ZBEE_ZCL_CMD_ID_APPL_EVTALT_EVENT_NOTIF_CMD 0x02 /* Event Notification */
584 /* Alert Count masks */
585 #define ZBEE_ZCL_APPL_EVTALT_COUNT_NUM_MASK 0x0F /* Number of Alerts : [0..3] */
586 #define ZBEE_ZCL_APPL_EVTALT_COUNT_TYPE_MASK 0xF0 /* Type of Alerts : [4..7] */
588 /* Alert structure masks */
589 #define ZBEE_ZCL_APPL_EVTALT_ALERT_ID_MASK 0x0000FF /* Alerts Id : [0..7] */
590 #define ZBEE_ZCL_APPL_EVTALT_CATEGORY_MASK 0x000F00 /* Category : [8..11] */
591 #define ZBEE_ZCL_APPL_EVTALT_STATUS_MASK 0x003000 /* Presence / Recovery: [12..13] */
592 #define ZBEE_ZCL_APPL_EVTALT_RESERVED_MASK 0x00C000 /* Reserved : [14..15] */
593 #define ZBEE_ZCL_APPL_EVTALT_PROPRIETARY_MASK 0xFF0000 /* Non-Standardized / Proprietary : [16..23] */
595 /* Category values */
596 #define ZBEE_ZCL_APPL_EVTALT_CATEGORY_RESERVED 0x00 /* Reserved */
597 #define ZBEE_ZCL_APPL_EVTALT_CATEGORY_WARNING 0x01 /* Warning */
598 #define ZBEE_ZCL_APPL_EVTALT_CATEGORY_DANGER 0x02 /* Danger */
599 #define ZBEE_ZCL_APPL_EVTALT_CATEGORY_FAILURE 0x03 /* Failure */
601 /* Status values */
602 #define ZBEE_ZCL_APPL_EVTALT_STATUS_RECOVERY 0x00 /* Recovery */
603 #define ZBEE_ZCL_APPL_EVTALT_STATUS_PRESENCE 0x01 /* Presence */
605 /* Event Identification */
606 #define ZBEE_ZCL_APPL_EVTALT_EVENT_END_OF_CYCLE 0x01 /* End Of Cycle */
607 #define ZBEE_ZCL_APPL_EVTALT_EVENT_RESERVED_1 0x02 /* Reserved */
608 #define ZBEE_ZCL_APPL_EVTALT_EVENT_RESERVED_2 0x03 /* Reserved */
609 #define ZBEE_ZCL_APPL_EVTALT_EVENT_TEMP_REACHED 0x04 /* Temperature Reached */
610 #define ZBEE_ZCL_APPL_EVTALT_EVENT_END_OF_COOKING 0x05 /* End Of Cooking */
611 #define ZBEE_ZCL_APPL_EVTALT_EVENT_SW_OFF 0x06 /* Switching Off */
612 #define ZBEE_ZCL_APPL_EVTALT_EVENT_WRONG_DATA 0xf7 /* Wrong Data */
614 /*************************/
615 /* Function Declarations */
616 /*************************/
618 void proto_register_zbee_zcl_appl_evtalt(void);
619 void proto_reg_handoff_zbee_zcl_appl_evtalt(void);
621 /* Command Dissector Helpers */
622 static void dissect_zcl_appl_evtalt_get_alerts_rsp (tvbuff_t *tvb, proto_tree *tree, unsigned *offset);
623 static void dissect_zcl_appl_evtalt_event_notif (tvbuff_t *tvb, proto_tree *tree, unsigned *offset);
625 /*************************/
626 /* Global Variables */
627 /*************************/
628 /* Initialize the protocol and registered fields */
629 static int proto_zbee_zcl_appl_evtalt;
631 static int hf_zbee_zcl_appl_evtalt_srv_tx_cmd_id;
632 static int hf_zbee_zcl_appl_evtalt_srv_rx_cmd_id;
633 static int hf_zbee_zcl_appl_evtalt_count_num;
634 static int hf_zbee_zcl_appl_evtalt_count_type;
635 static int hf_zbee_zcl_appl_evtalt_alert_id;
636 static int hf_zbee_zcl_appl_evtalt_category;
637 static int hf_zbee_zcl_appl_evtalt_status;
638 static int hf_zbee_zcl_appl_evtalt_reserved;
639 static int hf_zbee_zcl_appl_evtalt_proprietary;
640 static int hf_zbee_zcl_appl_evtalt_event_hdr;
641 static int hf_zbee_zcl_appl_evtalt_event_id;
643 /* Initialize the subtree pointers */
644 static int ett_zbee_zcl_appl_evtalt;
645 static int ett_zbee_zcl_appl_evtalt_alerts_struct[ZBEE_ZCL_APPL_EVTALT_NUM_STRUCT_ETT];
647 /* Server Commands Received */
648 static const value_string zbee_zcl_appl_evtalt_srv_rx_cmd_names[] = {
649 { ZBEE_ZCL_CMD_ID_APPL_EVTALT_GET_ALERTS_CMD, "Get Alerts" },
650 { 0, NULL }
653 /* Server Commands Generated */
654 static const value_string zbee_zcl_appl_evtalt_srv_tx_cmd_names[] = {
655 { ZBEE_ZCL_CMD_ID_APPL_EVTALT_GET_ALERTS_RSP_CMD, "Get Alerts Response" },
656 { ZBEE_ZCL_CMD_ID_APPL_EVTALT_ALERTS_NOTIF_CMD, "Alerts Notification" },
657 { ZBEE_ZCL_CMD_ID_APPL_EVTALT_EVENT_NOTIF_CMD, "Event Notification" },
658 { 0, NULL }
661 /* Event Identification */
662 static const value_string zbee_zcl_appl_evtalt_event_id_names[] = {
663 { ZBEE_ZCL_APPL_EVTALT_EVENT_END_OF_CYCLE, "End Of Cycle" },
664 { ZBEE_ZCL_APPL_EVTALT_EVENT_RESERVED_1, "Reserved" },
665 { ZBEE_ZCL_APPL_EVTALT_EVENT_RESERVED_2, "Reserved" },
666 { ZBEE_ZCL_APPL_EVTALT_EVENT_TEMP_REACHED, "Temperature Reached" },
667 { ZBEE_ZCL_APPL_EVTALT_EVENT_END_OF_COOKING, "End Of Cooking" },
668 { ZBEE_ZCL_APPL_EVTALT_EVENT_SW_OFF, "Switching Off" },
669 { ZBEE_ZCL_APPL_EVTALT_EVENT_WRONG_DATA, "Wrong Data" },
670 { 0, NULL }
673 /* Category values */
674 static const value_string zbee_zcl_appl_evtalt_category_names[] = {
675 { ZBEE_ZCL_APPL_EVTALT_CATEGORY_RESERVED, "Reserved" },
676 { ZBEE_ZCL_APPL_EVTALT_CATEGORY_WARNING, "Warning" },
677 { ZBEE_ZCL_APPL_EVTALT_CATEGORY_DANGER, "Danger" },
678 { ZBEE_ZCL_APPL_EVTALT_CATEGORY_FAILURE, "Failure" },
679 { 0, NULL }
682 /* Status values */
683 static const value_string zbee_zcl_appl_evtalt_status_names[] = {
684 { ZBEE_ZCL_APPL_EVTALT_STATUS_RECOVERY, "Recovery" },
685 { ZBEE_ZCL_APPL_EVTALT_STATUS_PRESENCE, "Presence" },
686 { 0, NULL }
689 /*************************/
690 /* Function Bodies */
691 /*************************/
694 *ZigBee ZCL Appliance Events and Alerts cluster dissector for wireshark.
696 *@param tvb pointer to buffer containing raw packet.
697 *@param pinfo pointer to packet information fields
698 *@param tree pointer to data tree Wireshark uses to display packet.
700 static int
701 dissect_zbee_zcl_appl_evtalt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
703 proto_tree *payload_tree;
704 zbee_zcl_packet *zcl;
705 unsigned offset = 0;
706 uint8_t cmd_id;
707 int rem_len;
709 /* Reject the packet if data is NULL */
710 if (data == NULL)
711 return 0;
712 zcl = (zbee_zcl_packet *)data;
713 cmd_id = zcl->cmd_id;
715 /* Create a subtree for the ZCL Command frame, and add the command ID to it. */
716 if (zcl->direction == ZBEE_ZCL_FCF_TO_SERVER) {
717 /* Append the command name to the info column. */
718 col_append_fstr(pinfo->cinfo, COL_INFO, "%s, Seq: %u",
719 val_to_str_const(cmd_id, zbee_zcl_appl_evtalt_srv_rx_cmd_names, "Unknown Command"),
720 zcl->tran_seqno);
722 /* Add the command ID. */
723 proto_tree_add_item(tree, hf_zbee_zcl_appl_evtalt_srv_rx_cmd_id, tvb, offset, 1, ENC_LITTLE_ENDIAN);
725 /* Check is this command has a payload, than add the payload tree */
726 rem_len = tvb_reported_length_remaining(tvb, ++offset);
727 if (rem_len > 0) {
728 /*payload_tree = */proto_tree_add_subtree(tree, tvb, offset, rem_len, ett_zbee_zcl_appl_evtalt, NULL, "Payload");
730 /* Call the appropriate command dissector */
731 switch (cmd_id) {
732 case ZBEE_ZCL_CMD_ID_APPL_EVTALT_GET_ALERTS_CMD:
733 /* No payload */
734 break;
736 default:
737 break;
741 else { /* ZBEE_ZCL_FCF_TO_CLIENT */
742 /* Append the command name to the info column. */
743 col_append_fstr(pinfo->cinfo, COL_INFO, "%s, Seq: %u",
744 val_to_str_const(cmd_id, zbee_zcl_appl_evtalt_srv_tx_cmd_names, "Unknown Command"),
745 zcl->tran_seqno);
747 /* Add the command ID. */
748 proto_tree_add_item(tree, hf_zbee_zcl_appl_evtalt_srv_tx_cmd_id, tvb, offset, 1, ENC_LITTLE_ENDIAN);
750 /* Check is this command has a payload, than add the payload tree */
751 rem_len = tvb_reported_length_remaining(tvb, ++offset);
752 if (rem_len > 0) {
753 payload_tree = proto_tree_add_subtree(tree, tvb, offset, rem_len, ett_zbee_zcl_appl_evtalt, NULL, "Payload");
755 /* Call the appropriate command dissector */
756 switch (cmd_id) {
757 case ZBEE_ZCL_CMD_ID_APPL_EVTALT_GET_ALERTS_RSP_CMD:
758 case ZBEE_ZCL_CMD_ID_APPL_EVTALT_ALERTS_NOTIF_CMD:
759 dissect_zcl_appl_evtalt_get_alerts_rsp(tvb, payload_tree, &offset);
760 break;
762 case ZBEE_ZCL_CMD_ID_APPL_EVTALT_EVENT_NOTIF_CMD:
763 dissect_zcl_appl_evtalt_event_notif(tvb, payload_tree, &offset);
764 break;
766 default:
767 break;
772 return tvb_captured_length(tvb);
773 } /*dissect_zbee_zcl_appl_evtalt*/
776 *This function is called in order to decode alerts structure payload
778 *@param tvb pointer to buffer containing raw packet.
779 *@param tree pointer to data tree Wireshark uses to display packet.
780 *@param offset offset in the tvb buffer
782 static void
783 dissect_zcl_appl_evtalt_alerts_struct(tvbuff_t *tvb, proto_tree *tree, unsigned *offset)
785 proto_tree_add_item(tree, hf_zbee_zcl_appl_evtalt_alert_id, tvb, *offset, 3, ENC_BIG_ENDIAN);
786 proto_tree_add_item(tree, hf_zbee_zcl_appl_evtalt_category, tvb, *offset, 3, ENC_BIG_ENDIAN);
787 proto_tree_add_item(tree, hf_zbee_zcl_appl_evtalt_status, tvb, *offset, 3, ENC_BIG_ENDIAN);
788 proto_tree_add_item(tree, hf_zbee_zcl_appl_evtalt_reserved, tvb, *offset, 3, ENC_BIG_ENDIAN);
789 proto_tree_add_item(tree, hf_zbee_zcl_appl_evtalt_proprietary, tvb, *offset, 3, ENC_BIG_ENDIAN);
790 *offset += 3;
791 } /*dissect_zcl_appl_evtalt_alerts_struct*/
794 *This function is called in order to decode the GetAlertsRespose payload
796 *@param tvb pointer to buffer containing raw packet.
797 *@param tree pointer to data tree Wireshark uses to display packet.
798 *@param offset offset in the tvb buffer
800 static void
801 dissect_zcl_appl_evtalt_get_alerts_rsp(tvbuff_t *tvb, proto_tree *tree, unsigned *offset)
803 proto_tree *sub_tree = NULL;
804 unsigned i;
805 uint8_t count;
807 /* Retrieve "Alert Count" field */
808 count = tvb_get_uint8(tvb, *offset) & ZBEE_ZCL_APPL_EVTALT_COUNT_NUM_MASK;
809 proto_tree_add_item(tree, hf_zbee_zcl_appl_evtalt_count_num, tvb, *offset, 1, ENC_NA);
810 proto_tree_add_item(tree, hf_zbee_zcl_appl_evtalt_count_type, tvb, *offset, 1, ENC_NA);
811 *offset += 1;
813 /* Alerts structure decoding */
814 for ( i=0 ; i<count ; i++)
816 /* Create subtree */
817 sub_tree = proto_tree_add_subtree_format(tree, tvb, *offset, 1,
818 ett_zbee_zcl_appl_evtalt_alerts_struct[i], NULL, "Alerts Structure #%u", i);
820 dissect_zcl_appl_evtalt_alerts_struct(tvb, sub_tree, offset);
822 } /*dissect_zcl_appl_evtalt_get_alerts_rsp*/
825 *This function is called in order to decode the EventNotification payload
827 *@param tvb pointer to buffer containing raw packet.
828 *@param tree pointer to data tree Wireshark uses to display packet.
829 *@param offset offset in the tvb buffer
831 static void
832 dissect_zcl_appl_evtalt_event_notif(tvbuff_t *tvb, proto_tree *tree, unsigned *offset)
834 /* Retrieve "Event Header" field */
835 proto_tree_add_item(tree, hf_zbee_zcl_appl_evtalt_event_hdr, tvb, *offset, 1, ENC_NA);
836 *offset += 1;
837 /* Retrieve "Event Identification" field */
838 proto_tree_add_item(tree, hf_zbee_zcl_appl_evtalt_event_id, tvb, *offset, 1, ENC_NA);
839 *offset += 1;
840 } /*dissect_zcl_appl_evtalt_event_notif*/
843 *This function registers the ZCL Appliance Events and Alert dissector
846 void
847 proto_register_zbee_zcl_appl_evtalt(void)
849 unsigned i, j;
851 static hf_register_info hf[] = {
853 { &hf_zbee_zcl_appl_evtalt_srv_tx_cmd_id,
854 { "Command", "zbee_zcl_ha.applevtalt.cmd.srv_tx.id", FT_UINT8, BASE_HEX, VALS(zbee_zcl_appl_evtalt_srv_tx_cmd_names),
855 0x0, NULL, HFILL } },
857 { &hf_zbee_zcl_appl_evtalt_srv_rx_cmd_id,
858 { "Command", "zbee_zcl_ha.applevtalt.cmd.srv_rx.id", FT_UINT8, BASE_HEX, VALS(zbee_zcl_appl_evtalt_srv_rx_cmd_names),
859 0x0, NULL, HFILL } },
861 { &hf_zbee_zcl_appl_evtalt_count_num,
862 { "Number of Alerts", "zbee_zcl_ha.applevtalt.count.num", FT_UINT8, BASE_DEC, NULL,
863 ZBEE_ZCL_APPL_EVTALT_COUNT_NUM_MASK, NULL, HFILL } },
865 { &hf_zbee_zcl_appl_evtalt_count_type,
866 { "Type of Alerts", "zbee_zcl_ha.applevtalt.count.type", FT_UINT8, BASE_DEC, NULL,
867 ZBEE_ZCL_APPL_EVTALT_COUNT_TYPE_MASK, NULL, HFILL } },
869 { &hf_zbee_zcl_appl_evtalt_alert_id,
870 { "Alert Id", "zbee_zcl_ha.applevtalt.alert_id", FT_UINT24, BASE_HEX, NULL,
871 ZBEE_ZCL_APPL_EVTALT_ALERT_ID_MASK, NULL, HFILL } },
873 { &hf_zbee_zcl_appl_evtalt_category,
874 { "Category", "zbee_zcl_ha.applevtalt.category", FT_UINT24, BASE_HEX, VALS(zbee_zcl_appl_evtalt_category_names),
875 ZBEE_ZCL_APPL_EVTALT_CATEGORY_MASK, NULL, HFILL } },
877 { &hf_zbee_zcl_appl_evtalt_status,
878 { "Status", "zbee_zcl_ha.applevtalt.status", FT_UINT24, BASE_HEX, VALS(zbee_zcl_appl_evtalt_status_names),
879 ZBEE_ZCL_APPL_EVTALT_STATUS_MASK, NULL, HFILL } },
881 { &hf_zbee_zcl_appl_evtalt_reserved,
882 { "Reserved", "zbee_zcl_ha.applevtalt.reserved", FT_UINT24, BASE_HEX, NULL,
883 ZBEE_ZCL_APPL_EVTALT_RESERVED_MASK, NULL, HFILL } },
885 { &hf_zbee_zcl_appl_evtalt_proprietary,
886 { "Proprietary", "zbee_zcl_ha.applevtalt.proprietary", FT_UINT24, BASE_HEX, NULL,
887 ZBEE_ZCL_APPL_EVTALT_PROPRIETARY_MASK, NULL, HFILL } },
889 { &hf_zbee_zcl_appl_evtalt_event_hdr,
890 { "Event Header", "zbee_zcl_ha.applevtalt.event.header", FT_UINT8, BASE_HEX, NULL,
891 0x00, NULL, HFILL } },
893 { &hf_zbee_zcl_appl_evtalt_event_id,
894 { "Event Id", "zbee_zcl_ha.applevtalt.event.id", FT_UINT8, BASE_HEX, VALS(zbee_zcl_appl_evtalt_event_id_names),
895 0x00, NULL, HFILL } }
899 /* ZCL Appliance Events And Alerts subtrees */
900 int *ett[ZBEE_ZCL_APPL_EVTALT_NUM_ETT];
902 ett[0] = &ett_zbee_zcl_appl_evtalt;
904 /* initialize attribute subtree types */
905 for ( i = 0, j = ZBEE_ZCL_APPL_EVTALT_NUM_GENERIC_ETT; i < ZBEE_ZCL_APPL_EVTALT_NUM_STRUCT_ETT; i++, j++) {
906 ett[j] = &ett_zbee_zcl_appl_evtalt_alerts_struct[i];
909 /* Register the ZigBee ZCL Appliance Events And Alerts cluster protocol name and description */
910 proto_zbee_zcl_appl_evtalt = proto_register_protocol("ZigBee ZCL Appliance Events & Alert", "ZCL Appliance Events & Alert", ZBEE_PROTOABBREV_ZCL_APPLEVTALT);
911 proto_register_field_array(proto_zbee_zcl_appl_evtalt, hf, array_length(hf));
912 proto_register_subtree_array(ett, array_length(ett));
914 /* Register the ZigBee ZCL Appliance Control dissector. */
915 register_dissector(ZBEE_PROTOABBREV_ZCL_APPLEVTALT, dissect_zbee_zcl_appl_evtalt, proto_zbee_zcl_appl_evtalt);
916 } /*proto_register_zbee_zcl_appl_evtalt*/
919 *Hands off the Zcl Appliance Events And Alerts dissector.
922 void
923 proto_reg_handoff_zbee_zcl_appl_evtalt(void)
925 zbee_zcl_init_cluster( ZBEE_PROTOABBREV_ZCL_APPLEVTALT,
926 proto_zbee_zcl_appl_evtalt,
927 ett_zbee_zcl_appl_evtalt,
928 ZBEE_ZCL_CID_APPLIANCE_EVENTS_AND_ALERT,
929 ZBEE_MFG_CODE_NONE,
930 -1, -1,
931 hf_zbee_zcl_appl_evtalt_srv_rx_cmd_id,
932 hf_zbee_zcl_appl_evtalt_srv_tx_cmd_id,
933 NULL
935 } /*proto_reg_handoff_zbee_zcl_appl_evtalt*/
937 /* ########################################################################## */
938 /* #### (0x0B03) APPLIANCE STATISTICS CLUSTER ############################### */
939 /* ########################################################################## */
941 /*************************/
942 /* Defines */
943 /*************************/
945 #define ZBEE_ZCL_APPL_STATS_NUM_GENERIC_ETT 1
946 #define ZBEE_ZCL_APPL_STATS_NUM_LOGS_ETT 16
947 #define ZBEE_ZCL_APPL_STATS_NUM_ETT (ZBEE_ZCL_APPL_STATS_NUM_GENERIC_ETT + \
948 ZBEE_ZCL_APPL_STATS_NUM_LOGS_ETT)
950 /* Attributes */
951 #define ZBEE_ZCL_ATTR_ID_APPL_STATS_LOG_MAX_SIZE 0x0000 /* Log Max Size */
952 #define ZBEE_ZCL_ATTR_ID_APPL_STATS_LOG_QUEUE_MAX_SIZE 0x0001 /* Log Queue Max Size */
954 /* Server Commands Received */
955 #define ZBEE_ZCL_CMD_ID_APPL_STATS_LOG_REQ 0x00 /* Log Request */
956 #define ZBEE_ZCL_CMD_ID_APPL_STATS_LOG_QUEUE_REQ 0x01 /* Log Queue Request */
958 /* Server Commands Generated - None */
959 #define ZBEE_ZCL_CMD_ID_APPL_STATS_LOG_NOTIF 0x00 /* Log Notification */
960 #define ZBEE_ZCL_CMD_ID_APPL_STATS_LOG_RSP 0x01 /* Log Response */
961 #define ZBEE_ZCL_CMD_ID_APPL_STATS_LOG_QUEUE_RSP 0x02 /* Log Queue Response */
962 #define ZBEE_ZCL_CMD_ID_APPL_STATS_STATS_AVAILABLE 0x03 /* Statistics Available */
964 /* Others */
965 #define ZBEE_ZCL_APPL_STATS_INVALID_TIME 0xffffffff /* Invalid UTC Time */
967 /*************************/
968 /* Function Declarations */
969 /*************************/
971 void proto_register_zbee_zcl_appl_stats(void);
972 void proto_reg_handoff_zbee_zcl_appl_stats(void);
974 /* Command Dissector Helpers */
975 static void dissect_zcl_appl_stats_log_req (tvbuff_t *tvb, proto_tree *tree, unsigned *offset);
976 static void dissect_zcl_appl_stats_log_rsp (tvbuff_t *tvb, proto_tree *tree, unsigned *offset);
977 static void dissect_zcl_appl_stats_log_queue_rsp (tvbuff_t *tvb, proto_tree *tree, unsigned *offset);
979 /* Private functions prototype */
980 static void decode_zcl_appl_stats_utc_time (char *s, uint32_t value);
982 /*************************/
983 /* Global Variables */
984 /*************************/
985 /* Initialize the protocol and registered fields */
986 static int proto_zbee_zcl_appl_stats;
988 static int hf_zbee_zcl_appl_stats_attr_id;
989 static int hf_zbee_zcl_appl_stats_srv_tx_cmd_id;
990 static int hf_zbee_zcl_appl_stats_srv_rx_cmd_id;
991 static int hf_zbee_zcl_appl_stats_utc_time;
992 static int hf_zbee_zcl_appl_stats_log_length;
993 static int hf_zbee_zcl_appl_stats_log_payload;
994 static int hf_zbee_zcl_appl_stats_log_queue_size;
995 static int hf_zbee_zcl_appl_stats_log_id;
997 /* Initialize the subtree pointers */
998 static int ett_zbee_zcl_appl_stats;
999 static int ett_zbee_zcl_appl_stats_logs[ZBEE_ZCL_APPL_STATS_NUM_LOGS_ETT];
1001 /* Attributes */
1002 static const value_string zbee_zcl_appl_stats_attr_names[] = {
1003 { ZBEE_ZCL_ATTR_ID_APPL_STATS_LOG_MAX_SIZE, "Log Max Size" },
1004 { ZBEE_ZCL_ATTR_ID_APPL_STATS_LOG_QUEUE_MAX_SIZE, "Log Queue Max Size" },
1005 { 0, NULL }
1008 /* Server Commands Received */
1009 static const value_string zbee_zcl_appl_stats_srv_rx_cmd_names[] = {
1010 { ZBEE_ZCL_CMD_ID_APPL_STATS_LOG_REQ, "Log Request" },
1011 { ZBEE_ZCL_CMD_ID_APPL_STATS_LOG_QUEUE_REQ, "Log Queue Request" },
1012 { 0, NULL }
1015 /* Server Commands Generated */
1016 static const value_string zbee_zcl_appl_stats_srv_tx_cmd_names[] = {
1017 { ZBEE_ZCL_CMD_ID_APPL_STATS_LOG_NOTIF, "Log Notification" },
1018 { ZBEE_ZCL_CMD_ID_APPL_STATS_LOG_RSP, "Log Response" },
1019 { ZBEE_ZCL_CMD_ID_APPL_STATS_LOG_QUEUE_RSP, "Log Queue Response" },
1020 { ZBEE_ZCL_CMD_ID_APPL_STATS_STATS_AVAILABLE, "Statistics Available" },
1021 { 0, NULL }
1024 /*************************/
1025 /* Function Bodies */
1026 /*************************/
1029 *ZigBee ZCL Appliance Statistics cluster dissector for wireshark.
1031 *@param tvb pointer to buffer containing raw packet.
1032 *@param pinfo pointer to packet information fields
1033 *@param tree pointer to data tree Wireshark uses to display packet.
1035 static int
1036 dissect_zbee_zcl_appl_stats (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
1038 proto_tree *payload_tree;
1039 zbee_zcl_packet *zcl;
1040 unsigned offset = 0;
1041 uint8_t cmd_id;
1042 int rem_len;
1044 /* Reject the packet if data is NULL */
1045 if (data == NULL)
1046 return 0;
1047 zcl = (zbee_zcl_packet *)data;
1048 cmd_id = zcl->cmd_id;
1050 /* Create a subtree for the ZCL Command frame, and add the command ID to it. */
1051 if (zcl->direction == ZBEE_ZCL_FCF_TO_SERVER) {
1052 /* Append the command name to the info column. */
1053 col_append_fstr(pinfo->cinfo, COL_INFO, "%s, Seq: %u",
1054 val_to_str_const(cmd_id, zbee_zcl_appl_stats_srv_rx_cmd_names, "Unknown Command"),
1055 zcl->tran_seqno);
1057 /* Add the command ID. */
1058 proto_tree_add_item(tree, hf_zbee_zcl_appl_stats_srv_rx_cmd_id, tvb, offset, 1, ENC_LITTLE_ENDIAN);
1060 /* Check is this command has a payload, than add the payload tree */
1061 rem_len = tvb_reported_length_remaining(tvb, ++offset);
1062 if (rem_len > 0) {
1063 payload_tree = proto_tree_add_subtree(tree, tvb, offset, rem_len, ett_zbee_zcl_appl_stats, NULL, "Payload");
1065 /* Call the appropriate command dissector */
1066 switch (cmd_id) {
1067 case ZBEE_ZCL_CMD_ID_APPL_STATS_LOG_REQ:
1068 dissect_zcl_appl_stats_log_req(tvb, payload_tree, &offset);
1069 break;
1071 case ZBEE_ZCL_CMD_ID_APPL_STATS_LOG_QUEUE_REQ:
1072 /* No payload */
1073 break;
1075 default:
1076 break;
1080 else { /* ZBEE_ZCL_FCF_TO_CLIENT */
1081 /* Append the command name to the info column. */
1082 col_append_fstr(pinfo->cinfo, COL_INFO, "%s, Seq: %u",
1083 val_to_str_const(cmd_id, zbee_zcl_appl_stats_srv_tx_cmd_names, "Unknown Command"),
1084 zcl->tran_seqno);
1086 /* Add the command ID. */
1087 proto_tree_add_item(tree, hf_zbee_zcl_appl_stats_srv_tx_cmd_id, tvb, offset, 1, ENC_LITTLE_ENDIAN);
1089 /* Check is this command has a payload, than add the payload tree */
1090 rem_len = tvb_reported_length_remaining(tvb, ++offset);
1091 if (rem_len > 0) {
1092 payload_tree = proto_tree_add_subtree(tree, tvb, offset, rem_len, ett_zbee_zcl_appl_stats, NULL, "Payload");
1094 /* Call the appropriate command dissector */
1095 switch (cmd_id) {
1096 case ZBEE_ZCL_CMD_ID_APPL_STATS_LOG_NOTIF:
1097 case ZBEE_ZCL_CMD_ID_APPL_STATS_LOG_RSP:
1098 dissect_zcl_appl_stats_log_rsp(tvb, payload_tree, &offset);
1099 break;
1101 case ZBEE_ZCL_CMD_ID_APPL_STATS_LOG_QUEUE_RSP:
1102 case ZBEE_ZCL_CMD_ID_APPL_STATS_STATS_AVAILABLE:
1103 dissect_zcl_appl_stats_log_queue_rsp(tvb, payload_tree, &offset);
1104 break;
1106 default:
1107 break;
1112 return tvb_captured_length(tvb);
1113 } /*dissect_zbee_zcl_appl_stats*/
1116 *This function is called in order to decode "LogRequest" payload command.
1118 *@param tvb pointer to buffer containing raw packet.
1119 *@param tree pointer to data tree Wireshark uses to display packet.
1120 *@param offset pointer to buffer offset
1122 static void
1123 dissect_zcl_appl_stats_log_req(tvbuff_t *tvb, proto_tree *tree, unsigned *offset)
1125 /* Retrieve 'Log ID' field */
1126 proto_tree_add_item(tree, hf_zbee_zcl_appl_stats_log_id, tvb, *offset, 4, ENC_LITTLE_ENDIAN);
1127 *offset += 4;
1128 } /*dissect_zcl_appl_stats_log_req*/
1131 *This function is called in order to decode "LogNotification" and
1133 *@param tvb pointer to buffer containing raw packet.
1134 *@param tree pointer to data tree Wireshark uses to display packet.
1135 *@param offset pointer to buffer offset
1137 static void
1138 dissect_zcl_appl_stats_log_rsp(tvbuff_t *tvb, proto_tree *tree, unsigned *offset)
1140 uint32_t log_len;
1142 /* Retrieve 'UTCTime' field */
1143 proto_tree_add_item(tree, hf_zbee_zcl_appl_stats_utc_time, tvb, *offset, 4, ENC_LITTLE_ENDIAN);
1144 *offset += 4;
1146 /* Retrieve 'Log ID' field */
1147 proto_tree_add_item(tree, hf_zbee_zcl_appl_stats_log_id, tvb, *offset, 4, ENC_LITTLE_ENDIAN);
1148 *offset += 4;
1150 /* Retrieve 'Log Length' field */
1151 log_len = tvb_get_letohl(tvb, *offset);
1152 proto_tree_add_item(tree, hf_zbee_zcl_appl_stats_log_length, tvb, *offset, 4, ENC_LITTLE_ENDIAN);
1153 *offset += 4;
1155 /* Retrieve 'Log Payload' field */
1156 proto_tree_add_item(tree, hf_zbee_zcl_appl_stats_log_payload, tvb, *offset, log_len, ENC_NA);
1157 *offset += log_len;
1158 }/*dissect_zcl_appl_stats_log_rsp*/
1161 *This function is called in order to decode "LogQueueResponse" and
1163 *@param tvb pointer to buffer containing raw packet.
1164 *@param tree pointer to data tree Wireshark uses to display packet.
1165 *@param offset pointer to buffer offset
1167 static void
1168 dissect_zcl_appl_stats_log_queue_rsp(tvbuff_t *tvb, proto_tree *tree, unsigned *offset)
1170 int list_len;
1172 /* Retrieve 'Log Queue Size' field */
1173 proto_tree_add_item(tree, hf_zbee_zcl_appl_stats_log_queue_size, tvb, *offset, 1, ENC_NA);
1174 *offset += 1;
1176 /* Dissect the attribute id list */
1177 list_len = tvb_reported_length_remaining(tvb, *offset);
1178 if ( list_len > 0 ) {
1179 while ( *offset < (unsigned)list_len ) {
1180 /* Retrieve 'Log ID' field */
1181 proto_tree_add_item(tree, hf_zbee_zcl_appl_stats_log_id, tvb, *offset, 4, ENC_LITTLE_ENDIAN);
1182 *offset += 4;
1185 }/*dissect_zcl_appl_stats_log_queue_rsp*/
1188 *This function decodes utc time, with peculiarity case for
1190 *@param s string to display
1191 *@param value value to decode
1193 static void
1194 decode_zcl_appl_stats_utc_time(char *s, uint32_t value)
1196 if (value == ZBEE_ZCL_APPL_STATS_INVALID_TIME)
1197 snprintf(s, ITEM_LABEL_LENGTH, "Invalid UTC Time");
1198 else {
1199 char *utc_time;
1200 value += EPOCH_DELTA_2000_01_01_00_00_00_UTC;
1201 utc_time = abs_time_secs_to_str (NULL, value, ABSOLUTE_TIME_LOCAL, true);
1202 snprintf(s, ITEM_LABEL_LENGTH, "%s", utc_time);
1203 wmem_free(NULL, utc_time);
1205 } /* decode_zcl_appl_stats_utc_time */
1208 *This function registers the ZCL Appliance Statistics dissector
1211 void
1212 proto_register_zbee_zcl_appl_stats(void)
1214 unsigned i, j;
1216 static hf_register_info hf[] = {
1218 { &hf_zbee_zcl_appl_stats_attr_id,
1219 { "Attribute", "zbee_zcl_ha.applstats.attr_id", FT_UINT16, BASE_HEX, VALS(zbee_zcl_appl_stats_attr_names),
1220 0x0, NULL, HFILL } },
1222 { &hf_zbee_zcl_appl_stats_srv_tx_cmd_id,
1223 { "Command", "zbee_zcl_ha.applstats.cmd.srv_tx.id", FT_UINT8, BASE_HEX, VALS(zbee_zcl_appl_stats_srv_tx_cmd_names),
1224 0x0, NULL, HFILL } },
1226 { &hf_zbee_zcl_appl_stats_srv_rx_cmd_id,
1227 { "Command", "zbee_zcl_ha.applstats.cmd.srv_rx.id", FT_UINT8, BASE_HEX, VALS(zbee_zcl_appl_stats_srv_rx_cmd_names),
1228 0x0, NULL, HFILL } },
1230 { &hf_zbee_zcl_appl_stats_utc_time,
1231 { "UTC Time", "zbee_zcl_ha.applstats.utc_time", FT_UINT32, BASE_CUSTOM, CF_FUNC(decode_zcl_appl_stats_utc_time),
1232 0x0, NULL, HFILL }},
1234 { &hf_zbee_zcl_appl_stats_log_length,
1235 { "Log Length", "zbee_zcl_ha.applstats.log.length", FT_UINT32, BASE_DEC, NULL,
1236 0x0, NULL, HFILL } },
1238 { &hf_zbee_zcl_appl_stats_log_id,
1239 { "Log ID", "zbee_zcl_ha.applstats.log.id", FT_UINT32, BASE_DEC, NULL,
1240 0x0, NULL, HFILL } },
1242 { &hf_zbee_zcl_appl_stats_log_queue_size,
1243 { "Log Queue Size", "zbee_zcl_ha.applstats.log_queue_size", FT_UINT8, BASE_DEC, NULL,
1244 0x0, NULL, HFILL } },
1246 { &hf_zbee_zcl_appl_stats_log_payload,
1247 { "Log Payload", "zbee_zcl_ha.applstats.log.payload", FT_BYTES, SEP_COLON, NULL,
1248 0x00, NULL, HFILL } },
1252 /* ZCL ApplianceStatistics subtrees */
1253 static int *ett[ZBEE_ZCL_APPL_STATS_NUM_ETT];
1255 ett[0] = &ett_zbee_zcl_appl_stats;
1257 /* initialize attribute subtree types */
1258 for ( i = 0, j = ZBEE_ZCL_APPL_STATS_NUM_GENERIC_ETT; i < ZBEE_ZCL_APPL_STATS_NUM_LOGS_ETT; i++, j++ ) {
1259 ett[j] = &ett_zbee_zcl_appl_stats_logs[i];
1262 /* Register the ZigBee ZCL Appliance Statistics cluster protocol name and description */
1263 proto_zbee_zcl_appl_stats = proto_register_protocol("ZigBee ZCL Appliance Statistics", "ZCL Appliance Statistics", ZBEE_PROTOABBREV_ZCL_APPLSTATS);
1264 proto_register_field_array(proto_zbee_zcl_appl_stats, hf, array_length(hf));
1265 proto_register_subtree_array(ett, array_length(ett));
1267 /* Register the ZigBee ZCL Appliance Statistics dissector. */
1268 register_dissector(ZBEE_PROTOABBREV_ZCL_APPLSTATS, dissect_zbee_zcl_appl_stats, proto_zbee_zcl_appl_stats);
1269 } /* proto_register_zbee_zcl_appl_stats */
1272 *Hands off the Zcl Appliance Statistics cluster dissector.
1275 void
1276 proto_reg_handoff_zbee_zcl_appl_stats(void)
1278 zbee_zcl_init_cluster( ZBEE_PROTOABBREV_ZCL_APPLSTATS,
1279 proto_zbee_zcl_appl_stats,
1280 ett_zbee_zcl_appl_stats,
1281 ZBEE_ZCL_CID_APPLIANCE_STATISTICS,
1282 ZBEE_MFG_CODE_NONE,
1283 hf_zbee_zcl_appl_stats_attr_id,
1284 hf_zbee_zcl_appl_stats_attr_id,
1285 hf_zbee_zcl_appl_stats_srv_rx_cmd_id,
1286 hf_zbee_zcl_appl_stats_srv_tx_cmd_id,
1287 NULL
1289 } /*proto_reg_handoff_zbee_zcl_appl_stats*/
1292 * Editor modelines - https://www.wireshark.org/tools/modelines.html
1294 * Local variables:
1295 * c-basic-offset: 4
1296 * tab-width: 8
1297 * indent-tabs-mode: nil
1298 * End:
1300 * vi: set shiftwidth=4 tabstop=8 expandtab:
1301 * :indentSize=4:tabSize=8:noTabs=true: