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 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 #ifndef PACKET_ZBEE_ZCL_H
28 #define PACKET_ZBEE_ZCL_H
30 /* Structure to contain the ZCL frame information */
34 gboolean disable_default_resp
;
43 #define ZBEE_ZCL_CMD_READ_ATTR 0x00
44 #define ZBEE_ZCL_CMD_READ_ATTR_RESP 0x01
45 #define ZBEE_ZCL_CMD_WRITE_ATTR 0x02
46 #define ZBEE_ZCL_CMD_WRITE_ATTR_UNDIVIDED 0x03
47 #define ZBEE_ZCL_CMD_WRITE_ATTR_RESP 0x04
48 #define ZBEE_ZCL_CMD_WRITE_ATTR_NO_RESP 0x05
49 #define ZBEE_ZCL_CMD_CONFIG_REPORT 0x06
50 #define ZBEE_ZCL_CMD_CONFIG_REPORT_RESP 0x07
51 #define ZBEE_ZCL_CMD_READ_REPORT_CONFIG 0x08
52 #define ZBEE_ZCL_CMD_READ_REPORT_CONFIG_RESP 0x09
53 #define ZBEE_ZCL_CMD_REPORT_ATTR 0x0a
54 #define ZBEE_ZCL_CMD_DEFAULT_RESP 0x0b
55 #define ZBEE_ZCL_CMD_DISCOVER_ATTR 0x0c
56 #define ZBEE_ZCL_CMD_DISCOVER_ATTR_RESP 0x0d
57 #define ZBEE_ZCL_CMD_READ_ATTR_STRUCT 0x0e
58 #define ZBEE_ZCL_CMD_WRITE_ATTR_STRUCT 0x0f
59 #define ZBEE_ZCL_CMD_WRITE_ATTR_STRUCT_RESP 0x10
62 #define ZBEE_ZCL_NO_DATA 0x00
64 #define ZBEE_ZCL_8_BIT_DATA 0x08
65 #define ZBEE_ZCL_16_BIT_DATA 0x09
66 #define ZBEE_ZCL_24_BIT_DATA 0x0a
67 #define ZBEE_ZCL_32_BIT_DATA 0x0b
68 #define ZBEE_ZCL_40_BIT_DATA 0x0c
69 #define ZBEE_ZCL_48_BIT_DATA 0x0d
70 #define ZBEE_ZCL_56_BIT_DATA 0x0e
71 #define ZBEE_ZCL_64_BIT_DATA 0x0f
73 #define ZBEE_ZCL_BOOLEAN 0x10
75 #define ZBEE_ZCL_8_BIT_BITMAP 0x18
76 #define ZBEE_ZCL_16_BIT_BITMAP 0x19
77 #define ZBEE_ZCL_24_BIT_BITMAP 0x1a
78 #define ZBEE_ZCL_32_BIT_BITMAP 0x1b
79 #define ZBEE_ZCL_40_BIT_BITMAP 0x1c
80 #define ZBEE_ZCL_48_BIT_BITMAP 0x1d
81 #define ZBEE_ZCL_56_BIT_BITMAP 0x1e
82 #define ZBEE_ZCL_64_BIT_BITMAP 0x1f
84 #define ZBEE_ZCL_8_BIT_UINT 0x20
85 #define ZBEE_ZCL_16_BIT_UINT 0x21
86 #define ZBEE_ZCL_24_BIT_UINT 0x22
87 #define ZBEE_ZCL_32_BIT_UINT 0x23
88 #define ZBEE_ZCL_40_BIT_UINT 0x24
89 #define ZBEE_ZCL_48_BIT_UINT 0x25
90 #define ZBEE_ZCL_56_BIT_UINT 0x26
91 #define ZBEE_ZCL_64_BIT_UINT 0x27
93 #define ZBEE_ZCL_8_BIT_INT 0x28
94 #define ZBEE_ZCL_16_BIT_INT 0x29
95 #define ZBEE_ZCL_24_BIT_INT 0x2a
96 #define ZBEE_ZCL_32_BIT_INT 0x2b
97 #define ZBEE_ZCL_40_BIT_INT 0x2c
98 #define ZBEE_ZCL_48_BIT_INT 0x2d
99 #define ZBEE_ZCL_56_BIT_INT 0x2e
100 #define ZBEE_ZCL_64_BIT_INT 0x2f
102 #define ZBEE_ZCL_8_BIT_ENUM 0x30
103 #define ZBEE_ZCL_16_BIT_ENUM 0x31
105 #define ZBEE_ZCL_SEMI_FLOAT 0x38
106 #define ZBEE_ZCL_SINGLE_FLOAT 0x39
107 #define ZBEE_ZCL_DOUBLE_FLOAT 0x3a
109 #define ZBEE_ZCL_OCTET_STRING 0x41
110 #define ZBEE_ZCL_CHAR_STRING 0x42
111 #define ZBEE_ZCL_LONG_OCTET_STRING 0x43
112 #define ZBEE_ZCL_LONG_CHAR_STRING 0x44
114 #define ZBEE_ZCL_ARRAY 0x48
115 #define ZBEE_ZCL_STRUCT 0x4c
117 #define ZBEE_ZCL_SET 0x50
118 #define ZBEE_ZCL_BAG 0x51
120 #define ZBEE_ZCL_TIME 0xe0
121 #define ZBEE_ZCL_DATE 0xe1
122 #define ZBEE_ZCL_UTC 0xe2
124 #define ZBEE_ZCL_CLUSTER_ID 0xe8
125 #define ZBEE_ZCL_ATTR_ID 0xe9
126 #define ZBEE_ZCL_BACNET_OID 0xea
128 #define ZBEE_ZCL_IEEE_ADDR 0xf0
129 #define ZBEE_ZCL_SECURITY_KEY 0xf1
131 #define ZBEE_ZCL_UNKNOWN 0xff
133 /* ZCL Miscellaneous */
134 #define ZBEE_ZCL_INVALID_STR_LENGTH 0xff
135 #define ZBEE_ZCL_INVALID_LONG_STR_LENGTH 0xffff
136 #define ZBEE_ZCL_NUM_INDIVIDUAL_ETT 2
137 #define ZBEE_ZCL_NUM_ATTR_ETT 64
138 #define ZBEE_ZCL_NUM_ARRAY_ELEM_ETT 16
139 #define ZBEE_ZCL_NUM_TOTAL_ETT (ZBEE_ZCL_NUM_INDIVIDUAL_ETT + ZBEE_ZCL_NUM_ATTR_ETT + ZBEE_ZCL_NUM_ARRAY_ELEM_ETT)
140 #define ZBEE_ZCL_DIR_REPORTED 0
141 #define ZBEE_ZCL_DIR_RECEIVED 1
142 /* seconds elapsed from year 1970 to 2000 */
143 #define ZBEE_ZCL_NSTIME_UTC_OFFSET (((3*365 + 366)*7 + 2*365)*24*3600)
144 #define IS_ANALOG_SUBTYPE(x) ( (x & 0xe0) == 0x20 || (x & 0xe0) == 0xe0 )
146 /* ZCL Status Enumerations */
147 #define ZBEE_ZCL_STAT_SUCCESS 0x00
148 #define ZBEE_ZCL_STAT_FAILURE 0x01
150 #define ZBEE_ZCL_STAT_NOT_AUTHORIZED 0x7e
151 #define ZBEE_ZCL_STAT_RESERVED_FIELD_NOT_ZERO 0x7f
152 #define ZBEE_ZCL_STAT_MALFORMED_CMD 0x80
153 #define ZBEE_ZCL_STAT_UNSUP_CLUSTER_CMD 0x81
154 #define ZBEE_ZCL_STAT_UNSUP_GENERAL_CMD 0x82
155 #define ZBEE_ZCL_STAT_UNSUP_MFR_CLUSTER_CMD 0x83
156 #define ZBEE_ZCL_STAT_UNSUP_MFR_GENERAL_CMD 0x84
157 #define ZBEE_ZCL_STAT_INVALID_FIELD 0x85
158 #define ZBEE_ZCL_STAT_UNSUPPORTED_ATTR 0x86
159 #define ZBEE_ZCL_STAT_INVALID_VALUE 0x87
160 #define ZBEE_ZCL_STAT_READ_ONLY 0x88
161 #define ZBEE_ZCL_STAT_INSUFFICIENT_SPACE 0x89
162 #define ZBEE_ZCL_STAT_DUPLICATE_EXISTS 0x8a
163 #define ZBEE_ZCL_STAT_NOT_FOUND 0x8b
164 #define ZBEE_ZCL_STAT_UNREPORTABLE_ATTR 0x8c
165 #define ZBEE_ZCL_STAT_INVALID_DATA_TYPE 0x8d
166 #define ZBEE_ZCL_STAT_INVALID_SELECTOR 0x8e
167 #define ZBEE_ZCL_STAT_WRITE_ONLY 0x8f
168 #define ZBEE_ZCL_STAT_INCONSISTENT_STARTUP_STATE 0x90
169 #define ZBEE_ZCL_STAT_DEFINED_OUT_OF_BAND 0x91
170 #define ZBEE_ZCL_STAT_HARDWARE_FAILURE 0xc0
171 #define ZBEE_ZCL_STAT_SOFTWARE_FAILURE 0xc1
172 #define ZBEE_ZCL_STAT_CALIBRATION_ERROR 0xc2
175 #define INT24_SIGN_BITS 0xffff8000
176 #define MONTHS_PER_YEAR 12
177 #define YEAR_OFFSET 1900
179 typedef void (*zbee_zcl_fn_attr_id
) (proto_tree
*tree
, tvbuff_t
*tvb
, guint
*offset
, guint16 attr_id
);
180 typedef void (*zbee_zcl_fn_attr_data
) (proto_tree
*tree
, tvbuff_t
*tvb
, guint
*offset
, guint16 attr_id
, guint data_type
);
182 typedef struct _zbee_zcl_cluster_desc
{
188 zbee_zcl_fn_attr_id fn_attr_id
;
189 zbee_zcl_fn_attr_data fn_attr_data
;
190 } zbee_zcl_cluster_desc
;
192 extern const value_string zbee_zcl_short_data_type_names
[];
194 /* Dissector functions */
195 extern void dissect_zcl_write_attr (tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, guint
*offset
);
196 extern void dissect_zcl_read_attr_resp (tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, guint
*offset
);
198 /* Helper functions */
199 void decode_zcl_time_in_seconds (gchar
*s
, guint16 value
);
200 void decode_zcl_time_in_minutes (gchar
*s
, guint16 value
);
201 void dissect_zcl_attr_data (tvbuff_t
*tvb
, proto_tree
*tree
, guint
*offset
, guint data_type
);
202 void zbee_zcl_init_cluster(int proto
, gint ett
, guint16 cluster_id
, zbee_zcl_fn_attr_id fn_attr_id
, zbee_zcl_fn_attr_data fn_attr_data
);
203 zbee_zcl_cluster_desc
*zbee_zcl_get_cluster_desc(guint16 cluster_id
);
205 #endif /* PACKET_ZBEE_ZCL_H*/