Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-zbee-zcl-misc.c
blob5f31df8a32f4e731889c5f420adcd233a65dbbe0
1 /* packet-zbee-zcl-misc.c
2 * Dissector routines for the ZigBee ZCL SE clusters like
3 * Messaging
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"
18 #include <epan/packet.h>
19 #include <epan/tfs.h>
20 #include <wsutil/array.h>
22 #include "packet-zbee.h"
23 #include "packet-zbee-aps.h"
24 #include "packet-zbee-zcl.h"
26 /* ########################################################################## */
27 /* #### (0x0201) THERMOSTAT CLUSTER ######################################### */
28 /* ########################################################################## */
30 /* Cluster-specific commands and parameters */
31 #define ZBEE_ZCL_CSC_POLL_CONTROL_C_CIR 0x00
32 #define ZBEE_ZCL_CSC_POLL_CONTROL_C_FPS 0x01
33 #define ZBEE_ZCL_CSC_POLL_CONTROL_C_SLPI 0x02
34 #define ZBEE_ZCL_CSC_POLL_CONTROL_C_SSPI 0x03
35 #define ZBEE_ZCL_CSC_POLL_CONTROL_S_CI 0x00
36 #define ZBEE_ZCL_CSC_THERMOSTAT_C_CWS 0x03
37 #define ZBEE_ZCL_CSC_THERMOSTAT_C_GWS 0x02
38 #define ZBEE_ZCL_CSC_THERMOSTAT_C_SRL 0x00
39 #define ZBEE_ZCL_CSC_THERMOSTAT_C_SWS 0x01
40 #define ZBEE_ZCL_CSC_THERMOSTAT_C_SWS_DOW_AV 0x80
41 #define ZBEE_ZCL_CSC_THERMOSTAT_C_SWS_DOW_FR 0x20
42 #define ZBEE_ZCL_CSC_THERMOSTAT_C_SWS_DOW_MO 0x02
43 #define ZBEE_ZCL_CSC_THERMOSTAT_C_SWS_DOW_SA 0x40
44 #define ZBEE_ZCL_CSC_THERMOSTAT_C_SWS_DOW_SU 0x01
45 #define ZBEE_ZCL_CSC_THERMOSTAT_C_SWS_DOW_TH 0x10
46 #define ZBEE_ZCL_CSC_THERMOSTAT_C_SWS_DOW_TU 0x04
47 #define ZBEE_ZCL_CSC_THERMOSTAT_C_SWS_DOW_WE 0x08
48 #define ZBEE_ZCL_CSC_THERMOSTAT_C_SWS_SP_B 0x03
49 #define ZBEE_ZCL_CSC_THERMOSTAT_C_SWS_SP_C 0x02
50 #define ZBEE_ZCL_CSC_THERMOSTAT_C_SWS_SP_H 0x01
51 #define ZBEE_ZCL_CSC_THERMOSTAT_S_GWSR 0x00
53 #define ZBEE_ZCL_THERMOSTAT_NUM_ETT 3
55 /* Thermostat Information Attributes */
56 #define ZBEE_ZCL_ATTR_ID_THERMOSTAT_LOCAL_TEMP 0x0000
57 #define ZBEE_ZCL_ATTR_ID_THERMOSTAT_OUTDOOR_TEMP 0x0001
58 #define ZBEE_ZCL_ATTR_ID_THERMOSTAT_OCCUPANCY 0x0002
59 #define ZBEE_ZCL_ATTR_ID_THERMOSTAT_ABS_MIN_HEAT_SETPOINT 0x0003
60 #define ZBEE_ZCL_ATTR_ID_THERMOSTAT_ABS_MAX_HEAT_SETPOINT 0x0004
61 #define ZBEE_ZCL_ATTR_ID_THERMOSTAT_ABS_MIN_COOL_SETPOINT 0x0005
62 #define ZBEE_ZCL_ATTR_ID_THERMOSTAT_ABS_MAX_COOL_SETPOINT 0x0006
63 #define ZBEE_ZCL_ATTR_ID_THERMOSTAT_PI_COOL_DEMAND 0x0007
64 #define ZBEE_ZCL_ATTR_ID_THERMOSTAT_PI_HEAT_DEMAND 0x0008
65 #define ZBEE_ZCL_ATTR_ID_THERMOSTAT_HVAC_TYPE_CONFIG 0x0009
66 /* Thermostat Settings Attributes */
67 #define ZBEE_ZCL_ATTR_ID_THERMOSTAT_LOCAL_TEMP_CALIBRATION 0x0010
68 #define ZBEE_ZCL_ATTR_ID_THERMOSTAT_OCCUPIED_COOL_SETPOINT 0x0011
69 #define ZBEE_ZCL_ATTR_ID_THERMOSTAT_OCCUPIED_HEAT_SETPOINT 0x0012
70 #define ZBEE_ZCL_ATTR_ID_THERMOSTAT_UNOCCUPIED_COOL_SETPOINT 0x0013
71 #define ZBEE_ZCL_ATTR_ID_THERMOSTAT_UNOCCUPIED_HEAT_SETPOINT 0x0014
72 #define ZBEE_ZCL_ATTR_ID_THERMOSTAT_MIN_HEAT_SETPOINT 0x0015
73 #define ZBEE_ZCL_ATTR_ID_THERMOSTAT_MAX_HEAT_SETPOINT 0x0016
74 #define ZBEE_ZCL_ATTR_ID_THERMOSTAT_MIN_COOL_SETPOINT 0x0017
75 #define ZBEE_ZCL_ATTR_ID_THERMOSTAT_MAX_COOL_SETPOINT 0x0018
76 #define ZBEE_ZCL_ATTR_ID_THERMOSTAT_MIN_SETPOINT_DEADBAND 0x0019
77 #define ZBEE_ZCL_ATTR_ID_THERMOSTAT_REMOTE_SENSING 0x001A
78 #define ZBEE_ZCL_ATTR_ID_THERMOSTAT_CONTROL_SEQUENCE 0x001B
79 #define ZBEE_ZCL_ATTR_ID_THERMOSTAT_SYSTEM_MODE 0x001C
80 #define ZBEE_ZCL_ATTR_ID_THERMOSTAT_ALARM_MASK 0x001D
81 #define ZBEE_ZCL_ATTR_ID_THERMOSTAT_RUNNING_MODE 0x001E
82 /* Schedule & HVAC Relay Attributes. */
83 #define ZBEE_ZCL_ATTR_ID_THERMOSTAT_START_OF_WEEK 0x0020
84 #define ZBEE_ZCL_ATTR_ID_THERMOSTAT_NUM_WEEKLY_TRANSITIONS 0x0021
85 #define ZBEE_ZCL_ATTR_ID_THERMOSTAT_NUM_DAILY_TRANSITIONS 0x0022
86 #define ZBEE_ZCL_ATTR_ID_THERMOSTAT_SETPOINT_HOLD 0x0023
87 #define ZBEE_ZCL_ATTR_ID_THERMOSTAT_SETPOINT_HOLD_DURATION 0x0024
88 #define ZBEE_ZCL_ATTR_ID_THERMOSTAT_PROGRAMMING_MODE 0x0025
89 #define ZBEE_ZCL_ATTR_ID_THERMOSTAT_RUNNING_STATE 0x0029
90 /* Setpoint Change Tracking Attributes. */
91 #define ZBEE_ZCL_ATTR_ID_THERMOSTAT_SETPOINT_CHANGE_SOURCE 0x0030
92 #define ZBEE_ZCL_ATTR_ID_THERMOSTAT_SETPOINT_CHANGE_AMOUNT 0x0031
93 #define ZBEE_ZCL_ATTR_ID_THERMOSTAT_SETPOINT_CHANGE_TIME 0x0032
94 #define ZBEE_ZCL_ATTR_ID_THERMOSTAT_OCCUPIED_SETBACK 0x0034
95 #define ZBEE_ZCL_ATTR_ID_THERMOSTAT_OCCUPIED_SETBACK_MIN 0x0035
96 #define ZBEE_ZCL_ATTR_ID_THERMOSTAT_OCCUPIED_SETBACK_MAX 0x0036
97 #define ZBEE_ZCL_ATTR_ID_THERMOSTAT_UNOCCUPIED_SETBACK 0x0037
98 #define ZBEE_ZCL_ATTR_ID_THERMOSTAT_UNOCCUPIED_SETBACK_MIN 0x0038
99 #define ZBEE_ZCL_ATTR_ID_THERMOSTAT_UNOCCUPIED_SETBACK_MAX 0x0039
100 #define ZBEE_ZCL_ATTR_ID_THERMOSTAT_EMERGENCY_HEAT_DELTA 0x003a
101 /* Air Conditioning Attributes. */
102 #define ZBEE_ZCL_ATTR_ID_THERMOSTAT_AC_TYPE 0x0040
103 #define ZBEE_ZCL_ATTR_ID_THERMOSTAT_AC_CAPACITY 0x0041
104 #define ZBEE_ZCL_ATTR_ID_THERMOSTAT_AC_REFRIGERANT_TYPE 0x0042
105 #define ZBEE_ZCL_ATTR_ID_THERMOSTAT_AC_COMPRESSOR_TYPE 0x0043
106 #define ZBEE_ZCL_ATTR_ID_THERMOSTAT_AC_ERROR_CODE 0x0044
107 #define ZBEE_ZCL_ATTR_ID_THERMOSTAT_AC_LOUVER_POSITION 0x0045
108 #define ZBEE_ZCL_ATTR_ID_THERMOSTAT_AC_COIL_TEMPERATURE 0x0046
109 #define ZBEE_ZCL_ATTR_ID_THERMOSTAT_AC_CAPACITY_FORMAT 0x0047
111 static const value_string zbee_zcl_thermostat_attr_names[] = {
112 { ZBEE_ZCL_ATTR_ID_THERMOSTAT_LOCAL_TEMP, "LocalTemperature" },
113 { ZBEE_ZCL_ATTR_ID_THERMOSTAT_OUTDOOR_TEMP, "OutdoorTemperature" },
114 { ZBEE_ZCL_ATTR_ID_THERMOSTAT_OCCUPANCY, "Occupancy" },
115 { ZBEE_ZCL_ATTR_ID_THERMOSTAT_ABS_MIN_HEAT_SETPOINT, "AbsMinHeatSetpointLimit" },
116 { ZBEE_ZCL_ATTR_ID_THERMOSTAT_ABS_MAX_HEAT_SETPOINT, "AbsMaxHeatSetpointLimit" },
117 { ZBEE_ZCL_ATTR_ID_THERMOSTAT_ABS_MIN_COOL_SETPOINT, "AbsMinCoolSetpointLimit" },
118 { ZBEE_ZCL_ATTR_ID_THERMOSTAT_ABS_MAX_COOL_SETPOINT, "AbsMaxCoolSetpointLimit" },
119 { ZBEE_ZCL_ATTR_ID_THERMOSTAT_PI_COOL_DEMAND, "PICoolingDemand" },
120 { ZBEE_ZCL_ATTR_ID_THERMOSTAT_PI_HEAT_DEMAND, "PIHeatingDemand" },
121 { ZBEE_ZCL_ATTR_ID_THERMOSTAT_HVAC_TYPE_CONFIG, "HVACSystemTypeConfiguration" },
122 { ZBEE_ZCL_ATTR_ID_THERMOSTAT_LOCAL_TEMP_CALIBRATION, "LocalTemperatureCalibration" },
123 { ZBEE_ZCL_ATTR_ID_THERMOSTAT_OCCUPIED_COOL_SETPOINT, "OccupiedCoolingSetpoint" },
124 { ZBEE_ZCL_ATTR_ID_THERMOSTAT_OCCUPIED_HEAT_SETPOINT, "OccupiedHeatingSetpoint" },
125 { ZBEE_ZCL_ATTR_ID_THERMOSTAT_UNOCCUPIED_COOL_SETPOINT, "UnoccupiedCoolingSetpoint" },
126 { ZBEE_ZCL_ATTR_ID_THERMOSTAT_UNOCCUPIED_HEAT_SETPOINT, "UnoccupiedHeatingSetpoint" },
127 { ZBEE_ZCL_ATTR_ID_THERMOSTAT_MIN_HEAT_SETPOINT, "MinHeatSetpointLimit" },
128 { ZBEE_ZCL_ATTR_ID_THERMOSTAT_MAX_HEAT_SETPOINT, "MaxHeatSetpointLimit" },
129 { ZBEE_ZCL_ATTR_ID_THERMOSTAT_MIN_COOL_SETPOINT, "MinCoolSetpointLimit" },
130 { ZBEE_ZCL_ATTR_ID_THERMOSTAT_MAX_COOL_SETPOINT, "MaxCoolSetpointLimit" },
131 { ZBEE_ZCL_ATTR_ID_THERMOSTAT_MIN_SETPOINT_DEADBAND, "MinSetpointDeadBand" },
132 { ZBEE_ZCL_ATTR_ID_THERMOSTAT_REMOTE_SENSING, "RemoteSensing" },
133 { ZBEE_ZCL_ATTR_ID_THERMOSTAT_CONTROL_SEQUENCE, "ControlSequenceOfOperation" },
134 { ZBEE_ZCL_ATTR_ID_THERMOSTAT_SYSTEM_MODE, "SystemMode" },
135 { ZBEE_ZCL_ATTR_ID_THERMOSTAT_ALARM_MASK, "AlarmMask" },
136 { ZBEE_ZCL_ATTR_ID_THERMOSTAT_RUNNING_MODE, "ThermostatRunningMode" },
137 { ZBEE_ZCL_ATTR_ID_THERMOSTAT_START_OF_WEEK, "StartOfWeek" },
138 { ZBEE_ZCL_ATTR_ID_THERMOSTAT_NUM_WEEKLY_TRANSITIONS, "NumberOfWeeklyTransitions" },
139 { ZBEE_ZCL_ATTR_ID_THERMOSTAT_NUM_DAILY_TRANSITIONS, "NumberOfDailyTransitions" },
140 { ZBEE_ZCL_ATTR_ID_THERMOSTAT_SETPOINT_HOLD, "TemperatureSetpointHold" },
141 { ZBEE_ZCL_ATTR_ID_THERMOSTAT_SETPOINT_HOLD_DURATION, "TemperatureSetpointHoldDuration" },
142 { ZBEE_ZCL_ATTR_ID_THERMOSTAT_PROGRAMMING_MODE, "ThermostatProgrammingOperationMode" },
143 { ZBEE_ZCL_ATTR_ID_THERMOSTAT_RUNNING_STATE, "ThermostatRunningState" },
144 { ZBEE_ZCL_ATTR_ID_THERMOSTAT_SETPOINT_CHANGE_SOURCE, "SetpointChangeSource" },
145 { ZBEE_ZCL_ATTR_ID_THERMOSTAT_SETPOINT_CHANGE_AMOUNT, "SetpointChangeAmount" },
146 { ZBEE_ZCL_ATTR_ID_THERMOSTAT_SETPOINT_CHANGE_TIME, "SetpointChangeTime" },
147 { ZBEE_ZCL_ATTR_ID_THERMOSTAT_OCCUPIED_SETBACK, "OccupiedSetback" },
148 { ZBEE_ZCL_ATTR_ID_THERMOSTAT_OCCUPIED_SETBACK_MIN, "OccupiedSetbackMin" },
149 { ZBEE_ZCL_ATTR_ID_THERMOSTAT_OCCUPIED_SETBACK_MAX, "OccupiedSetbackMax" },
150 { ZBEE_ZCL_ATTR_ID_THERMOSTAT_UNOCCUPIED_SETBACK, "UnoccupiedSetback" },
151 { ZBEE_ZCL_ATTR_ID_THERMOSTAT_UNOCCUPIED_SETBACK_MIN, "UnoccupiedSetbackMin" },
152 { ZBEE_ZCL_ATTR_ID_THERMOSTAT_UNOCCUPIED_SETBACK_MAX, "UnoccupiedSetbackMax" },
153 { ZBEE_ZCL_ATTR_ID_THERMOSTAT_EMERGENCY_HEAT_DELTA, "EmergencyHeatDelta" },
154 { ZBEE_ZCL_ATTR_ID_THERMOSTAT_AC_TYPE, "AcType" },
155 { ZBEE_ZCL_ATTR_ID_THERMOSTAT_AC_CAPACITY, "AcCapacity" },
156 { ZBEE_ZCL_ATTR_ID_THERMOSTAT_AC_REFRIGERANT_TYPE, "AcRefrigerantType" },
157 { ZBEE_ZCL_ATTR_ID_THERMOSTAT_AC_COMPRESSOR_TYPE, "AcCompressorType" },
158 { ZBEE_ZCL_ATTR_ID_THERMOSTAT_AC_ERROR_CODE, "AcErrorCode" },
159 { ZBEE_ZCL_ATTR_ID_THERMOSTAT_AC_LOUVER_POSITION, "AcLouverPosition" },
160 { ZBEE_ZCL_ATTR_ID_THERMOSTAT_AC_COIL_TEMPERATURE, "AcCoilTemperature" },
161 { ZBEE_ZCL_ATTR_ID_THERMOSTAT_AC_CAPACITY_FORMAT, "AcCapacityFormat" },
162 { 0, NULL }
165 /* RemoteSensing bitmask. */
166 #define ZBEE_ZCL_THERMOSTAT_REMOTE_SENSE_LOCAL 0x01
167 #define ZBEE_ZCL_THERMOSTAT_REMOTE_SENSE_OUTDOOR 0x02
168 #define ZBEE_ZCL_THERMOSTAT_REMOTE_SENSE_OCCUPANCY 0x04
170 #define ZBEE_ZCL_THERMOSTAT_ALARM_INIT_FAILURE 0x01
171 #define ZBEE_ZCL_THERMOSTAT_ALARM_HARDWARE_FAILURE 0x02
172 #define ZBEE_ZCL_THERMOSTAT_ALARM_CALIBRATION_FAILURE 0x04
174 /* Programming operation mode bits. */
175 #define ZBEE_ZCL_THERMOSTAT_PROGRAM_MODE_SCHEDULE 0x01
176 #define ZBEE_ZCL_THERMOSTAT_PROGRAM_MODE_AUTO 0x02
177 #define ZBEE_ZCL_THERMOSTAT_PROGRAM_MODE_ENERGY_STAR 0x04
179 /* HVAC Running State bits. */
180 #define ZBEE_ZCL_THERMOSTAT_RUNNING_STATE_HEAT 0x0001
181 #define ZBEE_ZCL_THERMOSTAT_RUNNING_STATE_COOL 0x0002
182 #define ZBEE_ZCL_THERMOSTAT_RUNNING_STATE_FAN 0x0004
183 #define ZBEE_ZCL_THERMOSTAT_RUNNING_STATE_HEAT2 0x0008
184 #define ZBEE_ZCL_THERMOSTAT_RUNNING_STATE_COOL2 0x0010
185 #define ZBEE_ZCL_THERMOSTAT_RUNNING_STATE_FAN2 0x0020
186 #define ZBEE_ZCL_THERMOSTAT_RUNNING_STATE_FAN3 0x0040
188 /* Client-to-server commands. */
189 #define ZBEE_ZCL_CMD_ID_THERMOSTAT_SETPOINT 0x00
190 #define ZBEE_ZCL_CMD_ID_THERMOSTAT_SET_SCHEDULE 0x01
191 #define ZBEE_ZCL_CMD_ID_THERMOSTAT_GET_SCHEDULE 0x02
192 #define ZBEE_ZCL_CMD_ID_THERMOSTAT_CLEAR_SCHEDULE 0x03
193 #define ZBEE_ZCL_CMD_ID_THERMOSTAT_GET_RELAY_LOG 0x04
194 static const value_string zbee_zcl_thermostat_srv_rx_cmd_names[] = {
195 { ZBEE_ZCL_CMD_ID_THERMOSTAT_SETPOINT, "Setpoint Raise/Lower" },
196 { ZBEE_ZCL_CMD_ID_THERMOSTAT_SET_SCHEDULE, "Set Weekly Schedule" },
197 { ZBEE_ZCL_CMD_ID_THERMOSTAT_GET_SCHEDULE, "Get Weekly Schedule" },
198 { ZBEE_ZCL_CMD_ID_THERMOSTAT_CLEAR_SCHEDULE, "Clear Weekly Schedule" },
199 { ZBEE_ZCL_CMD_ID_THERMOSTAT_GET_RELAY_LOG, "Get Relay Status Log" },
200 { 0, NULL }
203 #define ZBEE_ZCL_CMD_ID_THERMOSTAT_GET_SCHEDULE_RESPONSE 0x00
204 #define ZBEE_ZCL_CMD_ID_THERMOSTAT_GET_RELAY_LOG_RESPONSE 0x01
205 static const value_string zbee_zcl_thermostat_srv_tx_cmd_names[] = {
206 { ZBEE_ZCL_CMD_ID_THERMOSTAT_GET_SCHEDULE_RESPONSE, "Get Weekly Schedule Response" },
207 { ZBEE_ZCL_CMD_ID_THERMOSTAT_GET_RELAY_LOG_RESPONSE,"Get Relay Status Log Response" },
208 { 0, NULL }
211 #define ZBEE_ZCL_CMD_THERMOSTAT_SCHEDULE_MODE_SEQUENCE_HEAT 0x01
212 #define ZBEE_ZCL_CMD_THERMOSTAT_SCHEDULE_MODE_SEQUENCE_COOL 0x02
214 /* Setpoint mode names. */
215 static const value_string zbee_zcl_thermostat_setpoint_mode_names[] = {
216 { 0, "Heat" },
217 { 1, "Cool" },
218 { 2, "Both" },
219 { 0, NULL }
222 /*************************/
223 /* Global Variables */
224 /*************************/
225 static int proto_zbee_zcl_thermostat;
227 static int hf_zbee_zcl_thermostat_attr_id;
228 static int hf_zbee_zcl_thermostat_srv_rx_cmd_id;
229 static int hf_zbee_zcl_thermostat_srv_tx_cmd_id;
230 static int hf_zbee_zcl_thermostat_setpoint_mode;
231 static int hf_zbee_zcl_thermostat_setpoint_amount;
233 static int hf_zbee_zcl_thermostat_schedule_num_trans;
234 static int hf_zbee_zcl_thermostat_schedule_day_sequence;
235 static int hf_zbee_zcl_thermostat_schedule_day_sunday;
236 static int hf_zbee_zcl_thermostat_schedule_day_monday;
237 static int hf_zbee_zcl_thermostat_schedule_day_tuesday;
238 static int hf_zbee_zcl_thermostat_schedule_day_wednesday;
239 static int hf_zbee_zcl_thermostat_schedule_day_thursday;
240 static int hf_zbee_zcl_thermostat_schedule_day_friday;
241 static int hf_zbee_zcl_thermostat_schedule_day_saturday;
242 static int hf_zbee_zcl_thermostat_schedule_day_vacation;
243 static int hf_zbee_zcl_thermostat_schedule_mode_sequence;
244 static int hf_zbee_zcl_thermostat_schedule_mode_heat;
245 static int hf_zbee_zcl_thermostat_schedule_mode_cool;
246 static int hf_zbee_zcl_thermostat_schedule_time;
247 static int hf_zbee_zcl_thermostat_schedule_heat;
248 static int hf_zbee_zcl_thermostat_schedule_cool;
250 static int ett_zbee_zcl_thermostat;
251 static int ett_zbee_zcl_thermostat_schedule_days;
252 static int ett_zbee_zcl_thermostat_schedule_mode;
254 /*************************/
255 /* Function Declarations */
256 /*************************/
257 void proto_register_zbee_zcl_thermostat(void);
258 void proto_reg_handoff_zbee_zcl_thermostat(void);
260 /* Attribute Dissector Helpers */
261 static void dissect_zcl_thermostat_attr_data(proto_tree *tree, tvbuff_t *tvb, unsigned *offset, uint16_t attr_id, unsigned data_type, bool client_attr);
263 static int dissect_zcl_thermostat_schedule(proto_tree *tree, tvbuff_t *tvb, unsigned offset);
264 static void dissect_zcl_thermostat_schedule_days(proto_tree *tree, tvbuff_t *tvb, unsigned offset);
265 static void dissect_zcl_thermostat_schedule_mode(proto_tree *tree, tvbuff_t *tvb, unsigned offset);
268 *Helper function to dissect a Thermostat scheduling days bitmask.
270 *@param tree pointer to data tree Wireshark uses to display packet.
271 *@param tvb pointer to buffer containing raw packet.
272 *@param offset payload offset of the ZoneStatus value.
274 static void
275 dissect_zcl_thermostat_schedule_days(proto_tree *tree, tvbuff_t *tvb, unsigned offset)
278 static int * const thermostat_schedule_days[] = {
279 &hf_zbee_zcl_thermostat_schedule_day_sunday,
280 &hf_zbee_zcl_thermostat_schedule_day_monday,
281 &hf_zbee_zcl_thermostat_schedule_day_tuesday,
282 &hf_zbee_zcl_thermostat_schedule_day_wednesday,
283 &hf_zbee_zcl_thermostat_schedule_day_thursday,
284 &hf_zbee_zcl_thermostat_schedule_day_friday,
285 &hf_zbee_zcl_thermostat_schedule_day_saturday,
286 &hf_zbee_zcl_thermostat_schedule_day_vacation,
287 NULL
290 proto_tree_add_bitmask(tree, tvb, offset, hf_zbee_zcl_thermostat_schedule_day_sequence,
291 ett_zbee_zcl_thermostat_schedule_days, thermostat_schedule_days, ENC_NA);
293 } /* dissect_zcl_thermostat_schedule_days */
296 *Helper function to dissect a Thermostat scheduling mode bitmask.
298 *@param tree pointer to data tree Wireshark uses to display packet.
299 *@param tvb pointer to buffer containing raw packet.
300 *@param offset payload offset of the ZoneStatus value.
302 static void
303 dissect_zcl_thermostat_schedule_mode(proto_tree *tree, tvbuff_t *tvb, unsigned offset)
306 static int * const thermostat_schedule_modes[] = {
307 &hf_zbee_zcl_thermostat_schedule_mode_heat,
308 &hf_zbee_zcl_thermostat_schedule_mode_cool,
309 NULL
312 proto_tree_add_bitmask(tree, tvb, offset, hf_zbee_zcl_thermostat_schedule_mode_sequence,
313 ett_zbee_zcl_thermostat_schedule_mode, thermostat_schedule_modes, ENC_NA);
317 *Helper function to dissect a Thermostat schedule, which has
319 *@param tree pointer to data tree Wireshark uses to display packet.
320 *@param tvb pointer to buffer containing raw packet.
321 *@param offset payload offset of the ZoneStatus value.
322 *@return length of parsed data.
324 static int
325 dissect_zcl_thermostat_schedule(proto_tree *tree, tvbuff_t *tvb, unsigned offset)
327 unsigned start = offset;
328 uint8_t num_transitions;
329 uint8_t mode_sequence;
330 int i;
332 num_transitions = tvb_get_uint8(tvb, offset);
333 proto_tree_add_uint(tree, hf_zbee_zcl_thermostat_schedule_num_trans, tvb, offset, 1,
334 num_transitions);
335 offset++;
337 dissect_zcl_thermostat_schedule_days(tree, tvb, offset);
338 offset++;
340 mode_sequence = tvb_get_uint8(tvb, offset);
341 dissect_zcl_thermostat_schedule_mode(tree, tvb, offset);
342 offset++;
344 /* Parse the list of setpoint transitions. */
345 for (i = 0; i < num_transitions; i++) {
346 nstime_t tv;
347 tv.secs = tvb_get_letohs(tvb, offset) * 60;
348 tv.nsecs = 0;
349 proto_tree_add_time(tree, hf_zbee_zcl_thermostat_schedule_time, tvb, offset, 2, &tv);
350 offset += 2;
352 if (mode_sequence & ZBEE_ZCL_CMD_THERMOSTAT_SCHEDULE_MODE_SEQUENCE_HEAT) {
353 float setpoint = tvb_get_letohis(tvb, offset);
354 proto_tree_add_float(tree, hf_zbee_zcl_thermostat_schedule_heat,
355 tvb, offset, 2, (setpoint / 100.0f));
356 offset += 2;
358 if (mode_sequence & ZBEE_ZCL_CMD_THERMOSTAT_SCHEDULE_MODE_SEQUENCE_COOL) {
359 float setpoint = tvb_get_letohis(tvb, offset);
360 proto_tree_add_float(tree, hf_zbee_zcl_thermostat_schedule_cool,
361 tvb, offset, 2, (setpoint / 100.0f));
362 offset += 2;
364 } /* for */
366 /* Return the number of bytes parsed. */
367 return (offset - start);
368 } /* dissect_zcl_thermostat_cmd_schedule */
371 *ZigBee ZCL Thermostat cluster dissector for wireshark.
373 *@param tvb pointer to buffer containing raw packet.
374 *@param pinfo pointer to packet information fields
375 *@param tree pointer to data tree Wireshark uses to display packet.
376 *@param data pointer to ZCL packet structure.
377 *@return length of parsed data.
379 static int
380 dissect_zbee_zcl_thermostat(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
382 zbee_zcl_packet *zcl;
383 unsigned offset = 0;
384 uint8_t cmd_id;
385 float amount;
387 /* Reject the packet if data is NULL */
388 if (data == NULL)
389 return 0;
390 zcl = (zbee_zcl_packet *)data;
391 cmd_id = zcl->cmd_id;
393 if (zcl->direction == ZBEE_ZCL_FCF_TO_SERVER) {
394 /* Append the command name to the info column. */
395 col_append_fstr(pinfo->cinfo, COL_INFO, "%s, Seq: %u",
396 val_to_str_const(cmd_id, zbee_zcl_thermostat_srv_rx_cmd_names, "Unknown Command"),
397 zcl->tran_seqno);
399 /* Add the command ID. */
400 proto_tree_add_item(tree, hf_zbee_zcl_thermostat_srv_rx_cmd_id, tvb, offset, 1, ENC_LITTLE_ENDIAN);
401 offset++;
403 /* Handle the command dissection. */
404 switch (cmd_id) {
405 case ZBEE_ZCL_CMD_ID_THERMOSTAT_SETPOINT:
406 /* Setpoint Raise/Lower. */
407 proto_tree_add_item(tree, hf_zbee_zcl_thermostat_setpoint_mode,
408 tvb, offset, 1, ENC_NA);
409 offset++;
410 amount = tvb_get_int8(tvb, offset);
411 proto_tree_add_float(tree, hf_zbee_zcl_thermostat_setpoint_amount,
412 tvb, offset, 1, (amount / 100.0f));
413 offset++;
414 break;
416 case ZBEE_ZCL_CMD_ID_THERMOSTAT_GET_SCHEDULE:
417 /* Get Weekly Schedule. */
418 dissect_zcl_thermostat_schedule_days(tree, tvb, offset);
419 offset++;
420 dissect_zcl_thermostat_schedule_mode(tree, tvb, offset);
421 offset++;
422 break;
424 case ZBEE_ZCL_CMD_ID_THERMOSTAT_SET_SCHEDULE:
425 /* Set Weekly Schedule. */
426 dissect_zcl_thermostat_schedule(tree, tvb, offset);
427 break;
429 case ZBEE_ZCL_CMD_ID_THERMOSTAT_CLEAR_SCHEDULE:
430 case ZBEE_ZCL_CMD_ID_THERMOSTAT_GET_RELAY_LOG:
431 /* No Payload - fall-through. */
432 default:
433 break;
434 } /* switch */
435 } else {
436 /* Append the command name to the info column. */
437 col_append_fstr(pinfo->cinfo, COL_INFO, "%s, Seq: %u",
438 val_to_str_const(cmd_id, zbee_zcl_thermostat_srv_tx_cmd_names, "Unknown Command"),
439 zcl->tran_seqno);
441 /* Add the command ID. */
442 proto_tree_add_item(tree, hf_zbee_zcl_thermostat_srv_tx_cmd_id, tvb, offset, 1, ENC_LITTLE_ENDIAN);
443 offset++;
445 /* Handle the command dissection. */
446 switch (cmd_id) {
447 case ZBEE_ZCL_CMD_ID_THERMOSTAT_GET_SCHEDULE_RESPONSE:
448 /* Get Weekly Schedule Response. */
449 dissect_zcl_thermostat_schedule(tree, tvb, offset);
450 break;
452 case ZBEE_ZCL_CMD_ID_THERMOSTAT_GET_RELAY_LOG_RESPONSE:
453 /* TODO: Implement Me! */
454 default:
455 break;
456 } /* switch */
459 return tvb_captured_length(tvb);
460 } /* dissect_zbee_zcl_thermostat */
463 *This function is called by ZCL foundation dissector in order to decode
465 *@param tree pointer to data tree Wireshark uses to display packet.
466 *@param tvb pointer to buffer containing raw packet.
467 *@param offset pointer to buffer offset
468 *@param attr_id attribute identifier
469 *@param data_type attribute data type
470 *@param client_attr ZCL client
472 static void
473 dissect_zcl_thermostat_attr_data(proto_tree *tree, tvbuff_t *tvb, unsigned *offset, uint16_t attr_id, unsigned data_type, bool client_attr)
475 /* Dissect attribute data type and data */
476 switch (attr_id) {
477 default:
478 dissect_zcl_attr_data(tvb, tree, offset, data_type, client_attr);
479 break;
481 } /*dissect_zcl_thermostat_attr_data*/
484 *ZigBee ZCL IAS Zone cluste protocol registration.
487 void
488 proto_register_zbee_zcl_thermostat(void)
490 /* Setup list of header fields */
491 static hf_register_info hf[] = {
493 { &hf_zbee_zcl_thermostat_attr_id,
494 { "Attribute", "zbee_zcl_hvac.thermostat.attr_id", FT_UINT16, BASE_HEX, VALS(zbee_zcl_thermostat_attr_names),
495 0x0, NULL, HFILL } },
497 { &hf_zbee_zcl_thermostat_srv_rx_cmd_id,
498 { "Command", "zbee_zcl_hvac.thermostat.cmd.srv_rx.id", FT_UINT8, BASE_HEX,
499 VALS(zbee_zcl_thermostat_srv_rx_cmd_names), 0x0, NULL, HFILL }},
501 { &hf_zbee_zcl_thermostat_srv_tx_cmd_id,
502 { "Command", "zbee_zcl_hvac.thermostat.cmd.srv_tx.id", FT_UINT8, BASE_HEX,
503 VALS(zbee_zcl_thermostat_srv_tx_cmd_names), 0x0, NULL, HFILL }},
505 { &hf_zbee_zcl_thermostat_setpoint_mode,
506 { "Mode", "zbee_zcl_hvac.thermostat.mode", FT_UINT8, BASE_HEX,
507 VALS(zbee_zcl_thermostat_setpoint_mode_names), 0x0, NULL, HFILL }},
509 { &hf_zbee_zcl_thermostat_setpoint_amount,
510 { "Amount", "zbee_zcl_hvac.thermostat.amount", FT_FLOAT, BASE_NONE, NULL, 0x0, NULL, HFILL }},
512 { &hf_zbee_zcl_thermostat_schedule_num_trans,
513 { "Number of Transitions for Sequence", "zbee_zcl_hvac.thermostat.num_trans", FT_UINT8, BASE_HEX, NULL,
514 0x0, NULL, HFILL }},
516 { &hf_zbee_zcl_thermostat_schedule_day_sequence,
517 { "Days of Week for Sequence", "zbee_zcl_hvac.thermostat.day_sequence", FT_UINT8, BASE_HEX, NULL,
518 0x0, NULL, HFILL }},
520 { &hf_zbee_zcl_thermostat_schedule_day_sunday,
521 { "Sunday", "zbee_zcl_hvac.thermostat.day.sunday", FT_BOOLEAN, 8, NULL, 0x01, NULL,
522 HFILL }},
524 { &hf_zbee_zcl_thermostat_schedule_day_monday,
525 { "Monday", "zbee_zcl_hvac.thermostat.day.monday", FT_BOOLEAN, 8, NULL, 0x02, NULL,
526 HFILL }},
528 { &hf_zbee_zcl_thermostat_schedule_day_tuesday,
529 { "Tuesday", "zbee_zcl_hvac.thermostat.day.tuesday", FT_BOOLEAN, 8, NULL, 0x04, NULL,
530 HFILL }},
532 { &hf_zbee_zcl_thermostat_schedule_day_wednesday,
533 { "Wednesday", "zbee_zcl_hvac.thermostat.day.wednesday", FT_BOOLEAN, 8, NULL, 0x08, NULL,
534 HFILL }},
536 { &hf_zbee_zcl_thermostat_schedule_day_thursday,
537 { "Thursday", "zbee_zcl_hvac.thermostat.day.thursday", FT_BOOLEAN, 8, NULL, 0x10, NULL,
538 HFILL }},
540 { &hf_zbee_zcl_thermostat_schedule_day_friday,
541 { "Friday", "zbee_zcl_hvac.thermostat.day.friday", FT_BOOLEAN, 8, NULL, 0x20, NULL,
542 HFILL }},
544 { &hf_zbee_zcl_thermostat_schedule_day_saturday,
545 { "Saturday", "zbee_zcl_hvac.thermostat.day.saturday", FT_BOOLEAN, 8, NULL, 0x40, NULL,
546 HFILL }},
548 { &hf_zbee_zcl_thermostat_schedule_day_vacation,
549 { "Away/Vacation", "zbee_zcl_hvac.thermostat.day.vacation", FT_BOOLEAN, 8, NULL, 0x80, NULL,
550 HFILL }},
552 { &hf_zbee_zcl_thermostat_schedule_mode_sequence,
553 { "Mode for Sequence", "zbee_zcl_hvac.thermostat.mode_sequence", FT_UINT8, BASE_HEX, NULL,
554 0x0, NULL, HFILL }},
556 { &hf_zbee_zcl_thermostat_schedule_mode_heat,
557 { "Heating", "zbee_zcl_hvac.thermostat.mode.heat", FT_BOOLEAN, 8, NULL, 0x01, NULL, HFILL }},
559 { &hf_zbee_zcl_thermostat_schedule_mode_cool,
560 { "Cooling", "zbee_zcl_hvac.thermostat.mode.cool", FT_BOOLEAN, 8, NULL, 0x02, NULL, HFILL }},
562 { &hf_zbee_zcl_thermostat_schedule_time,
563 { "Transition Time", "zbee_zcl_hvac.thermostat.time", FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0,
564 "Setpoint transition time relative to midnight of the scheduled day", HFILL }},
566 { &hf_zbee_zcl_thermostat_schedule_heat,
567 { "Heating Setpoint", "zbee_zcl_hvac.thermostat.heat", FT_FLOAT, BASE_NONE, NULL, 0x0,
568 "Heating setpoint in degrees Celsius", HFILL }},
570 { &hf_zbee_zcl_thermostat_schedule_cool,
571 { "Cooling Setpoint", "zbee_zcl_hvac.thermostat.cool", FT_FLOAT, BASE_NONE, NULL, 0x0,
572 "Cooling setpoint in degrees Celsius", HFILL }}
575 /* ZCL IAS Zone subtrees */
576 static int *ett[ZBEE_ZCL_THERMOSTAT_NUM_ETT];
578 ett[0] = &ett_zbee_zcl_thermostat;
579 ett[1] = &ett_zbee_zcl_thermostat_schedule_days;
580 ett[2] = &ett_zbee_zcl_thermostat_schedule_mode;
582 /* Register the ZigBee ZCL IAS Zoben cluster protocol name and description */
583 proto_zbee_zcl_thermostat = proto_register_protocol("ZigBee ZCL Thermostat", "ZCL Thermostat", ZBEE_PROTOABBREV_ZCL_THERMOSTAT);
584 proto_register_field_array(proto_zbee_zcl_thermostat, hf, array_length(hf));
585 proto_register_subtree_array(ett, array_length(ett));
587 /* Register the ZigBee ZCL IAS Zone dissector. */
588 register_dissector(ZBEE_PROTOABBREV_ZCL_THERMOSTAT, dissect_zbee_zcl_thermostat, proto_zbee_zcl_thermostat);
589 } /*proto_register_zbee_zcl_thermostat*/
592 *Hands off the ZCL Thermostat dissector.
595 void
596 proto_reg_handoff_zbee_zcl_thermostat(void)
598 zbee_zcl_init_cluster( ZBEE_PROTOABBREV_ZCL_THERMOSTAT,
599 proto_zbee_zcl_thermostat,
600 ett_zbee_zcl_thermostat,
601 ZBEE_ZCL_CID_THERMOSTAT,
602 ZBEE_MFG_CODE_NONE,
603 hf_zbee_zcl_thermostat_attr_id,
604 hf_zbee_zcl_thermostat_attr_id,
605 hf_zbee_zcl_thermostat_srv_rx_cmd_id,
606 hf_zbee_zcl_thermostat_srv_tx_cmd_id,
607 (zbee_zcl_fn_attr_data)dissect_zcl_thermostat_attr_data
609 } /*proto_reg_handoff_zbee_zcl_thermostat*/
611 /* ########################################################################## */
612 /* #### (0x0500) IAS ZONE CLUSTER ########################################### */
613 /* ########################################################################## */
615 #define ZBEE_ZCL_IAS_ZONE_NUM_ETT 2
617 /* IAS Zone Server Attributes */
618 #define ZBEE_ZCL_ATTR_ID_IAS_ZONE_STATE 0x0000
619 #define ZBEE_ZCL_ATTR_ID_IAS_ZONE_TYPE 0x0001
620 #define ZBEE_ZCL_ATTR_ID_IAS_ZONE_STATUS 0x0002
621 #define ZBEE_ZCL_ATTR_ID_IAS_CIE_ADDRESS 0x0010
623 static const value_string zbee_zcl_ias_zone_attr_names[] = {
624 { ZBEE_ZCL_ATTR_ID_IAS_ZONE_STATE, "ZoneState" },
625 { ZBEE_ZCL_ATTR_ID_IAS_ZONE_TYPE, "ZoneType" },
626 { ZBEE_ZCL_ATTR_ID_IAS_ZONE_STATUS, "ZoneStatus" },
627 { ZBEE_ZCL_ATTR_ID_IAS_CIE_ADDRESS, "IAS_CIE_Address" },
628 { 0, NULL }
631 /* IAS Zone States */
632 #define ZBEE_IAS_ZONE_STATE_NOT_ENROLLED 0x00
633 #define ZBEE_IAS_ZONE_STATE_ENROLLED 0x01
634 static const value_string zbee_ias_state_names[] = {
635 { ZBEE_IAS_ZONE_STATE_NOT_ENROLLED, "Not Enrolled" },
636 { ZBEE_IAS_ZONE_STATE_ENROLLED, "Enrolled" },
637 { 0, NULL }
640 /* IAS Zone Type values. */
641 #define ZBEE_IAS_ZONE_TYPE_STANDARD_CIE 0x0000
642 #define ZBEE_IAS_ZONE_TYPE_MOTION_SENSOR 0x000D
643 #define ZBEE_IAS_ZONE_TYPE_CONTACT_SWITCH 0x0015
644 #define ZBEE_IAS_ZONE_TYPE_FIRE_SENSOR 0x0028
645 #define ZBEE_IAS_ZONE_TYPE_WATER_SENSOR 0x002A
646 #define ZBEE_IAS_ZONE_TYPE_GAS_SENSOR 0x002B
647 #define ZBEE_IAS_ZONE_TYPE_PERSONAL_EMERGENCY 0x002C
648 #define ZBEE_IAS_ZONE_TYPE_VIBRATION_SENSOR 0x002D
649 #define ZBEE_IAS_ZONE_TYPE_REMOTE_CONTROL 0x010F
650 #define ZBEE_IAS_ZONE_TYPE_KEY_FOB 0x0115
651 #define ZBEE_IAS_ZONE_TYPE_KEYPAD 0x021D
652 #define ZBEE_IAS_ZONE_TYPE_STANDARD_WARNING 0x0225
653 #define ZBEE_IAS_ZONE_TYPE_INVALID_ZONE_TYPE 0xFFFF
655 #define ZBEE_IAS_ZONE_STATUS_ALARM1 0x0001
656 #define ZBEE_IAS_ZONE_STATUS_ALARM2 0x0002
657 #define ZBEE_IAS_ZONE_STATUS_TAMPER 0x0004
658 #define ZBEE_IAS_ZONE_STATUS_BATTERY 0x0008
659 #define ZBEE_IAS_ZONE_STATUS_SUPERVISION 0x0010
660 #define ZBEE_IAS_ZONE_STATUS_RESTORE 0x0020
661 #define ZBEE_IAS_ZONE_STATUS_TROUBLE 0x0040
662 #define ZBEE_IAS_ZONE_STATUS_AC_MAINS 0x0080
664 static const value_string zbee_ias_type_names[] = {
665 { ZBEE_IAS_ZONE_TYPE_STANDARD_CIE, "Standard CIE" },
666 { ZBEE_IAS_ZONE_TYPE_MOTION_SENSOR, "Motion sensor" },
667 { ZBEE_IAS_ZONE_TYPE_CONTACT_SWITCH, "Contact switch" },
668 { ZBEE_IAS_ZONE_TYPE_FIRE_SENSOR, "Fire sensor" },
669 { ZBEE_IAS_ZONE_TYPE_WATER_SENSOR, "Water sensor" },
670 { ZBEE_IAS_ZONE_TYPE_GAS_SENSOR, "Gas sensor" },
671 { ZBEE_IAS_ZONE_TYPE_PERSONAL_EMERGENCY, "Personal emergency device" },
672 { ZBEE_IAS_ZONE_TYPE_VIBRATION_SENSOR, "Vibration/movement sensor" },
673 { ZBEE_IAS_ZONE_TYPE_REMOTE_CONTROL, "Remote control" },
674 { ZBEE_IAS_ZONE_TYPE_KEY_FOB, "Key fob" },
675 { ZBEE_IAS_ZONE_TYPE_KEYPAD, "Keypad" },
676 { ZBEE_IAS_ZONE_TYPE_STANDARD_WARNING, "Standard warning device" },
677 { ZBEE_IAS_ZONE_TYPE_INVALID_ZONE_TYPE, "Invalid zone type" },
678 { 0, NULL }
681 /* Server-to-client command IDs. */
682 #define ZBEE_ZCL_CMD_ID_IAS_ZONE_ENROLL_NOTIFY 0x00
683 #define ZBEE_ZCL_CMD_ID_IAS_ZONE_ENROLL_REQUEST 0x01
684 static const value_string zbee_zcl_ias_zone_srv_tx_cmd_names[] = {
685 { ZBEE_ZCL_CMD_ID_IAS_ZONE_ENROLL_REQUEST, "Zone Enroll Request" },
686 { ZBEE_ZCL_CMD_ID_IAS_ZONE_ENROLL_NOTIFY, "Zone Status Change Notification" },
687 { 0, NULL }
690 /* Client-to-server command IDs. */
691 #define ZBEE_ZCL_CMD_ID_IAS_ZONE_ENROLL_RESPONSE 0x00
692 static const value_string zbee_zcl_ias_zone_srv_rx_cmd_names[] = {
693 { ZBEE_ZCL_CMD_ID_IAS_ZONE_ENROLL_RESPONSE, "Zone Enroll Response" },
694 { 0, NULL }
698 static const value_string zbee_zcl_ias_zone_enroll_code_names[] = {
699 { 0, "Success" },
700 { 1, "Not Supported" },
701 { 2, "No enroll permit" },
702 { 3, "Too many zones" },
703 { 0, NULL }
706 /*************************/
707 /* Global Variables */
708 /*************************/
709 /* Initialize the protocol and registered fields */
710 static int proto_zbee_zcl_ias_zone;
712 static int hf_zbee_zcl_ias_zone_attr_id;
713 static int hf_zbee_zcl_ias_zone_srv_rx_cmd_id;
714 static int hf_zbee_zcl_ias_zone_srv_tx_cmd_id;
715 static int hf_zbee_zcl_ias_zone_enroll_code;
716 static int hf_zbee_zcl_ias_zone_zone_id;
717 static int hf_zbee_zcl_ias_zone_state;
718 static int hf_zbee_zcl_ias_zone_type;
719 static int hf_zbee_zcl_ias_zone_status;
720 static int hf_zbee_zcl_ias_zone_delay;
721 static int hf_zbee_zcl_ias_zone_ext_status;
722 static int hf_zbee_zcl_ias_zone_manufacturer_code;
723 static int hf_zbee_zcl_ias_zone_status_ac_mains;
724 static int hf_zbee_zcl_ias_zone_status_alarm1;
725 static int hf_zbee_zcl_ias_zone_status_alarm2;
726 static int hf_zbee_zcl_ias_zone_status_battery;
727 static int hf_zbee_zcl_ias_zone_status_restore_reports;
728 static int hf_zbee_zcl_ias_zone_status_supervision_reports;
729 static int hf_zbee_zcl_ias_zone_status_tamper;
730 static int hf_zbee_zcl_ias_zone_status_trouble;
732 static const true_false_string tfs_ac_mains = {
733 "AC/Mains fault",
734 "AC/Mains OK"
737 static const true_false_string tfs_alarmed_or_not = {
738 "Opened or alarmed",
739 "Closed or not alarmed"
742 static const true_false_string tfs_battery = {
743 "Low battery",
744 "Battery OK"
747 static const true_false_string tfs_reports_or_not = {
748 "Reports",
749 "Does not report"
752 static const true_false_string tfs_reports_restore = {
753 "Reports restore",
754 "Does not report restore"
757 static const true_false_string tfs_tampered_or_not = {
758 "Tampered",
759 "Not tampered"
762 static const true_false_string tfs_trouble_failure = {
763 "Trouble/Failure",
764 "OK"
767 static int ett_zbee_zcl_ias_zone;
768 static int ett_zbee_zcl_ias_zone_status;
770 /*************************/
771 /* Function Declarations */
772 /*************************/
773 void proto_register_zbee_zcl_ias_zone(void);
774 void proto_reg_handoff_zbee_zcl_ias_zone(void);
776 /* Command Dissector Helpers. */
777 static int dissect_zbee_zcl_ias_zone (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data);
779 /* Attribute Dissector Helpers */
780 static void dissect_zcl_ias_zone_attr_data (proto_tree *tree, tvbuff_t *tvb, unsigned *offset, uint16_t attr_id, unsigned data_type, bool client_attr);
782 /* ZoneStatus bitmask helper */
783 static void dissect_zcl_ias_zone_status (proto_tree *tree, tvbuff_t *tvb, unsigned offset);
786 *Helper function to dissect the IAS ZoneStatus bitmask.
788 *@param tree pointer to data tree Wireshark uses to display packet.
789 *@param tvb pointer to buffer containing raw packet.
790 *@param offset payload offset of the ZoneStatus value.
792 static void
793 dissect_zcl_ias_zone_status(proto_tree *tree, tvbuff_t *tvb, unsigned offset)
795 static int * const ias_zone_statuses[] = {
796 &hf_zbee_zcl_ias_zone_status_alarm1,
797 &hf_zbee_zcl_ias_zone_status_alarm2,
798 &hf_zbee_zcl_ias_zone_status_tamper,
799 &hf_zbee_zcl_ias_zone_status_battery,
800 &hf_zbee_zcl_ias_zone_status_supervision_reports,
801 &hf_zbee_zcl_ias_zone_status_restore_reports,
802 &hf_zbee_zcl_ias_zone_status_trouble,
803 &hf_zbee_zcl_ias_zone_status_ac_mains,
804 NULL
807 proto_tree_add_bitmask(tree, tvb, offset, hf_zbee_zcl_ias_zone_status, ett_zbee_zcl_ias_zone_status, ias_zone_statuses, ENC_LITTLE_ENDIAN);
809 } /* dissect_zcl_ias_zone_status */
812 *ZigBee ZCL IAS Zone cluster dissector for wireshark.
814 *@param tvb pointer to buffer containing raw packet.
815 *@param pinfo pointer to packet information fields
816 *@param tree pointer to data tree Wireshark uses to display packet.
817 *@param data pointer to ZCL packet structure.
818 *@return length of parsed data.
820 static int
821 dissect_zbee_zcl_ias_zone(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
823 zbee_zcl_packet *zcl;
824 unsigned offset = 0;
825 uint8_t cmd_id;
827 /* Reject the packet if data is NULL */
828 if (data == NULL)
829 return 0;
830 zcl = (zbee_zcl_packet *)data;
831 cmd_id = zcl->cmd_id;
833 if (zcl->direction == ZBEE_ZCL_FCF_TO_SERVER) {
834 /* Append the command name to the info column. */
835 col_append_fstr(pinfo->cinfo, COL_INFO, "%s, Seq: %u",
836 val_to_str_const(cmd_id, zbee_zcl_ias_zone_srv_rx_cmd_names, "Unknown Command"),
837 zcl->tran_seqno);
839 /* Add the command ID. */
840 proto_tree_add_item(tree, hf_zbee_zcl_ias_zone_srv_rx_cmd_id, tvb, offset, 1, ENC_LITTLE_ENDIAN);
841 offset++;
843 /* Handle the command dissection. */
844 switch (cmd_id) {
845 case ZBEE_ZCL_CMD_ID_IAS_ZONE_ENROLL_RESPONSE:
846 proto_tree_add_item(tree, hf_zbee_zcl_ias_zone_enroll_code, tvb, offset, 1, ENC_NA);
847 offset++;
848 proto_tree_add_item(tree, hf_zbee_zcl_ias_zone_zone_id, tvb, offset, 1, ENC_NA);
849 offset++;
850 break;
852 default:
853 break;
854 } /* switch */
855 } else {
856 /* Append the command name to the info column. */
857 col_append_fstr(pinfo->cinfo, COL_INFO, "%s, Seq: %u",
858 val_to_str_const(cmd_id, zbee_zcl_ias_zone_srv_tx_cmd_names, "Unknown Command"),
859 zcl->tran_seqno);
861 /* Add the command ID. */
862 proto_tree_add_item(tree, hf_zbee_zcl_ias_zone_srv_tx_cmd_id, tvb, offset, 1, ENC_LITTLE_ENDIAN);
863 offset++;
865 /* Handle the command dissection. */
866 switch (cmd_id) {
867 case ZBEE_ZCL_CMD_ID_IAS_ZONE_ENROLL_NOTIFY:
868 dissect_zcl_ias_zone_status(tree, tvb, offset);
869 offset += 2;
870 proto_tree_add_item(tree, hf_zbee_zcl_ias_zone_ext_status, tvb, offset,
871 1, ENC_NA);
872 offset += 1;
873 proto_tree_add_item(tree, hf_zbee_zcl_ias_zone_zone_id, tvb, offset, 1,
874 ENC_NA);
875 offset += 1;
876 proto_tree_add_item(tree, hf_zbee_zcl_ias_zone_delay, tvb, offset, 2,
877 ENC_LITTLE_ENDIAN);
878 break;
880 case ZBEE_ZCL_CMD_ID_IAS_ZONE_ENROLL_REQUEST:
881 proto_tree_add_item(tree, hf_zbee_zcl_ias_zone_type, tvb, offset, 2,
882 ENC_LITTLE_ENDIAN);
883 offset += 2;
884 proto_tree_add_item(tree, hf_zbee_zcl_ias_zone_manufacturer_code,
885 tvb, offset, 2, ENC_LITTLE_ENDIAN);
886 break;
888 default:
889 break;
890 } /* switch */
893 return tvb_reported_length(tvb);
894 } /* dissect_zbee_zcl_ias_zone */
897 *This function is called by ZCL foundation dissector in order to decode
899 *@param tree pointer to data tree Wireshark uses to display packet.
900 *@param tvb pointer to buffer containing raw packet.
901 *@param offset pointer to buffer offset
902 *@param attr_id attribute identifier
903 *@param data_type attribute data type
904 *@param client_attr ZCL client
906 static void
907 dissect_zcl_ias_zone_attr_data(proto_tree *tree, tvbuff_t *tvb, unsigned *offset, uint16_t attr_id, unsigned data_type, bool client_attr)
909 /* Dissect attribute data type and data */
910 switch (attr_id) {
911 case ZBEE_ZCL_ATTR_ID_IAS_ZONE_STATE:
912 proto_tree_add_item(tree, hf_zbee_zcl_ias_zone_state, tvb, *offset, 1, ENC_NA);
913 *offset += 1;
914 break;
916 case ZBEE_ZCL_ATTR_ID_IAS_ZONE_TYPE:
917 proto_tree_add_item(tree, hf_zbee_zcl_ias_zone_type, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
918 *offset += 2;
919 break;
921 case ZBEE_ZCL_ATTR_ID_IAS_ZONE_STATUS:
922 dissect_zcl_ias_zone_status(tree, tvb, *offset);
923 *offset += 2;
924 break;
926 case ZBEE_ZCL_ATTR_ID_IAS_CIE_ADDRESS:
927 default:
928 dissect_zcl_attr_data(tvb, tree, offset, data_type, client_attr);
929 break;
931 } /*dissect_zcl_ias_zone_attr_data*/
934 *Hands off the ZCL IAS Zone dissector.
937 void
938 proto_reg_handoff_zbee_zcl_ias_zone(void)
940 zbee_zcl_init_cluster( ZBEE_PROTOABBREV_ZCL_IAS_ZONE,
941 proto_zbee_zcl_ias_zone,
942 ett_zbee_zcl_ias_zone,
943 ZBEE_ZCL_CID_IAS_ZONE,
944 ZBEE_MFG_CODE_NONE,
945 hf_zbee_zcl_ias_zone_attr_id,
946 hf_zbee_zcl_ias_zone_attr_id,
947 hf_zbee_zcl_ias_zone_srv_rx_cmd_id,
948 hf_zbee_zcl_ias_zone_srv_tx_cmd_id,
949 (zbee_zcl_fn_attr_data)dissect_zcl_ias_zone_attr_data
951 } /*proto_reg_handoff_zbee_zcl_ias_zone*/
954 *ZigBee ZCL IAS Zone cluste protocol registration.
957 void
958 proto_register_zbee_zcl_ias_zone(void)
960 /* Setup list of header fields */
961 static hf_register_info hf[] = {
963 { &hf_zbee_zcl_ias_zone_attr_id,
964 { "Attribute", "zbee_zcl_ias.zone.attr_id", FT_UINT16, BASE_HEX, VALS(zbee_zcl_ias_zone_attr_names),
965 0x0, NULL, HFILL } },
967 { &hf_zbee_zcl_ias_zone_srv_rx_cmd_id,
968 { "Command", "zbee_zcl_ias.zone.cmd.srv_rx.id", FT_UINT8, BASE_HEX,
969 VALS(zbee_zcl_ias_zone_srv_rx_cmd_names), 0x0, NULL, HFILL }},
971 { &hf_zbee_zcl_ias_zone_srv_tx_cmd_id,
972 { "Command", "zbee_zcl_ias.zone.cmd.srv_tx.id", FT_UINT8, BASE_HEX,
973 VALS(zbee_zcl_ias_zone_srv_tx_cmd_names), 0x0, NULL, HFILL }},
975 { &hf_zbee_zcl_ias_zone_enroll_code,
976 { "Enroll response code", "zbee_zcl_ias.zone.enroll_code", FT_UINT8, BASE_HEX,
977 VALS(zbee_zcl_ias_zone_enroll_code_names), 0x0, NULL, HFILL }},
979 { &hf_zbee_zcl_ias_zone_zone_id,
980 { "Zone ID", "zbee_zcl_ias.zone.zone_id", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
982 { &hf_zbee_zcl_ias_zone_state,
983 { "ZoneState", "zbee_zcl_ias.zone.state", FT_UINT16, BASE_HEX, VALS(zbee_ias_state_names), 0x0, NULL, HFILL }},
985 { &hf_zbee_zcl_ias_zone_type,
986 { "ZoneType", "zbee_zcl_ias.zone.type", FT_UINT16, BASE_HEX, VALS(zbee_ias_type_names), 0x0, NULL, HFILL }},
988 { &hf_zbee_zcl_ias_zone_manufacturer_code,
989 { "ManufacturerCode", "zbee_zcl_ias.zone.manufacturer_code", FT_UINT16, BASE_HEX, VALS(zbee_mfr_code_names),
990 0x0, NULL, HFILL } },
992 { &hf_zbee_zcl_ias_zone_status,
993 { "ZoneStatus", "zbee_zcl_ias.zone.status", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
995 { &hf_zbee_zcl_ias_zone_delay,
996 { "Delay (in quarterseconds)", "zbee_zcl_ias.zone.delay", FT_UINT16, BASE_DEC, NULL, 0x0, NULL,
997 HFILL }},
999 { &hf_zbee_zcl_ias_zone_ext_status,
1000 { "Extended Status", "zbee_zcl_ias.zone.ext_status", FT_UINT8, BASE_HEX, NULL, 0x0, NULL,
1001 HFILL }},
1003 { &hf_zbee_zcl_ias_zone_status_alarm1,
1004 { "Alarm 1", "zbee_zcl_ias.zone.status.alarm_1", FT_BOOLEAN, 16, TFS(&tfs_alarmed_or_not), ZBEE_IAS_ZONE_STATUS_ALARM1, NULL,
1005 HFILL }},
1007 { &hf_zbee_zcl_ias_zone_status_alarm2,
1008 { "Alarm 2", "zbee_zcl_ias.zone.status.alarm_2", FT_BOOLEAN, 16, TFS(&tfs_alarmed_or_not), ZBEE_IAS_ZONE_STATUS_ALARM2, NULL,
1009 HFILL }},
1011 { &hf_zbee_zcl_ias_zone_status_battery,
1012 { "Battery", "zbee_zcl_ias.zone.status.battery", FT_BOOLEAN, 16, TFS(&tfs_battery), ZBEE_IAS_ZONE_STATUS_BATTERY, NULL,
1013 HFILL }},
1015 { &hf_zbee_zcl_ias_zone_status_tamper,
1016 { "Tamper", "zbee_zcl_ias.zone.status.tamper", FT_BOOLEAN, 16, TFS(&tfs_tampered_or_not), ZBEE_IAS_ZONE_STATUS_TAMPER, NULL,
1017 HFILL }},
1019 { &hf_zbee_zcl_ias_zone_status_supervision_reports,
1020 { "Supervision Reports", "zbee_zcl_ias.zone.status.supervision_reports", FT_BOOLEAN, 16,
1021 TFS(&tfs_reports_or_not), ZBEE_IAS_ZONE_STATUS_SUPERVISION, NULL, HFILL }},
1023 { &hf_zbee_zcl_ias_zone_status_restore_reports,
1024 { "Restore Reports", "zbee_zcl_ias.zone.status.restore_reports", FT_BOOLEAN, 16,
1025 TFS(&tfs_reports_restore), ZBEE_IAS_ZONE_STATUS_RESTORE, NULL, HFILL }},
1027 { &hf_zbee_zcl_ias_zone_status_trouble,
1028 { "Trouble", "zbee_zcl_ias.zone.status.trouble", FT_BOOLEAN, 16, TFS(&tfs_trouble_failure), ZBEE_IAS_ZONE_STATUS_TROUBLE, NULL,
1029 HFILL }},
1031 { &hf_zbee_zcl_ias_zone_status_ac_mains,
1032 { "AC (mains)", "zbee_zcl_ias.zone.status.ac_mains", FT_BOOLEAN, 16, TFS(&tfs_ac_mains), ZBEE_IAS_ZONE_STATUS_AC_MAINS, NULL,
1033 HFILL }}
1036 /* ZCL IAS Zone subtrees */
1037 static int *ett[ZBEE_ZCL_IAS_ZONE_NUM_ETT];
1039 ett[0] = &ett_zbee_zcl_ias_zone;
1040 ett[1] = &ett_zbee_zcl_ias_zone_status;
1042 /* Register the ZigBee ZCL IAS Zoben cluster protocol name and description */
1043 proto_zbee_zcl_ias_zone = proto_register_protocol("ZigBee ZCL IAS Zone", "ZCL IAS Zone", ZBEE_PROTOABBREV_ZCL_IAS_ZONE);
1044 proto_register_field_array(proto_zbee_zcl_ias_zone, hf, array_length(hf));
1045 proto_register_subtree_array(ett, array_length(ett));
1047 /* Register the ZigBee ZCL IAS Zone dissector. */
1048 register_dissector(ZBEE_PROTOABBREV_ZCL_IAS_ZONE, dissect_zbee_zcl_ias_zone, proto_zbee_zcl_ias_zone);
1049 } /*proto_register_zbee_zcl_ias_zone*/
1052 * Editor modelines - https://www.wireshark.org/tools/modelines.html
1054 * Local variables:
1055 * c-basic-offset: 4
1056 * tab-width: 8
1057 * indent-tabs-mode: nil
1058 * End:
1060 * vi: set shiftwidth=4 tabstop=8 expandtab:
1061 * :indentSize=4:tabSize=8:noTabs=true: