HTTPS (almost) everywhere.
[metze/wireshark/wip.git] / epan / dissectors / packet-zbee-zcl-lighting.c
1 /* packet-zbee-zcl-lighting.c
2  * Dissector routines for the ZigBee ZCL Lighting clusters
3  * Color Control, Ballast Configuration
4  * By Aditya Jain <aditya.jain@samsung.com>
5  *
6  * Wireshark - Network traffic analyzer
7  * By Gerald Combs <gerald@wireshark.org>
8  * Copyright 1998 Gerald Combs
9  *
10  * SPDX-License-Identifier: GPL-2.0-or-later
11  */
12
13 /*  Include Files */
14 #include "config.h"
15
16 #include <epan/packet.h>
17 #include <epan/to_str.h>
18
19 #include "packet-zbee.h"
20 #include "packet-zbee-aps.h"
21 #include "packet-zbee-zcl.h"
22
23 /* ########################################################################## */
24 /* #### (0x0300) COLOR CONTROL CLUSTER ###################################### */
25 /* ########################################################################## */
26
27 /*************************/
28 /* Defines               */
29 /*************************/
30
31 #define ZBEE_ZCL_COLOR_CONTROL_NUM_ETT                                              3
32
33 #define ZBEE_ZCL_COLOR_CAPABILITIES_SUPPORT_HS_MASK                                 0x0001  /* bit 0 */
34 #define ZBEE_ZCL_COLOR_CAPABILITIES_SUPPORT_EHS_MASK                                0x0002  /* bit 1 */
35 #define ZBEE_ZCL_COLOR_CAPABILITIES_SUPPORT_LOOP_MASK                               0x0004  /* bit 2 */
36 #define ZBEE_ZCL_COLOR_CAPABILITIES_SUPPORT_XY_MASK                                 0x0008  /* bit 3 */
37 #define ZBEE_ZCL_COLOR_CAPABILITIES_SUPPORT_CT_MASK                                 0x0010  /* bit 4 */
38 #define ZBEE_ZCL_COLOR_LOOP_UPDATE_ACTION_MASK                                      0x01    /* bit 0 */
39 #define ZBEE_ZCL_COLOR_LOOP_UPDATE_DIRECTION_MASK                                   0x02    /* bit 1 */
40 #define ZBEE_ZCL_COLOR_LOOP_UPDATE_TIME_MASK                                        0x04    /* bit 2 */
41 #define ZBEE_ZCL_COLOR_LOOP_UPDATE_START_HUE_MASK                                   0x08    /* bit 3 */
42
43 /* Attributes */
44 #define ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_CURRENT_HUE                                  0x0000  /* Current Hue */
45 #define ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_CURRENT_SATURATION                           0x0001  /* Current Saturation */
46 #define ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_REMAINING_TIME                               0x0002  /* Remaining Time */
47 #define ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_CURRENT_X                                    0x0003  /* Current X */
48 #define ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_CURRENT_Y                                    0x0004  /* Current Y */
49 #define ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_DRIFT_COMPENSATION                           0x0005  /* Drift Compensation */
50 #define ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COMPENSATION_TEXT                            0x0006  /* Compensation Text */
51 #define ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_TEMP                                   0x0007  /* Color Temperature */
52 #define ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_MODE                                   0x0008  /* Color Mode */
53 #define ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_NO_OF_PRIMARIES                              0x0010  /* Number of Primaries */
54 #define ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_1_X                                  0x0011  /* Primary 1X */
55 #define ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_1_Y                                  0x0012  /* Primary 1Y */
56 #define ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_1_INTENSITY                          0x0013  /* Primary 1intensity */
57 #define ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_2_X                                  0x0015  /* Primary 2X */
58 #define ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_2_Y                                  0x0016  /* Primary 2Y */
59 #define ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_2_INTENSITY                          0x0017  /* Primary 2intensity */
60 #define ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_3_X                                  0x0019  /* Primary 3X */
61 #define ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_3_Y                                  0x001a  /* Primary 3Y */
62 #define ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_3_INTENSITY                          0x001b  /* Primary 3intensity */
63 #define ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_4_X                                  0x0020  /* Primary 4X */
64 #define ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_4_Y                                  0x0021  /* Primary 4Y */
65 #define ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_4_INTENSITY                          0x0022  /* Primary 4intensity */
66 #define ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_5_X                                  0x0024  /* Primary 5X */
67 #define ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_5_Y                                  0x0025  /* Primary 5Y */
68 #define ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_5_INTENSITY                          0x0026  /* Primary 5intensity */
69 #define ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_6_X                                  0x0028  /* Primary 6X */
70 #define ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_6_Y                                  0x0029  /* Primary 6Y */
71 #define ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_6_INTENSITY                          0x002a  /* Primary 6intensity */
72 #define ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_WHITE_POINT_X                                0x0030  /* White Point X */
73 #define ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_WHITE_POINT_Y                                0x0031  /* White Point Y */
74 #define ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_POINT_R_X                              0x0032  /* Color Point RX */
75 #define ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_POINT_R_Y                              0x0033  /* Color Point RY */
76 #define ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_POINT_R_INTENSITY                      0x0034  /* Color Point Rintensity */
77 #define ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_POINT_G_X                              0x0036  /* Color Point GX */
78 #define ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_POINT_G_Y                              0x0037  /* Color Point GY */
79 #define ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_POINT_G_INTENSITY                      0x0038  /* Color Point Gintensity */
80 #define ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_POINT_B_X                              0x003a  /* Color Point BX */
81 #define ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_POINT_B_Y                              0x003b  /* Color Point BY */
82 #define ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_POINT_B_INTENSITY                      0x003c  /* Color Point Bintensity */
83 #define ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_ENHANCED_CURRENT_HUE                         0x4000  /* Enhanced Current Hue */
84 #define ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_ENHANCED_COLOR_MODE                          0x4001  /* Enhanced Color Mode */
85 #define ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_LOOP_ACTIVE                            0x4002  /* Color Loop Active */
86 #define ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_LOOP_DIRECTION                         0x4003  /* Color Loop Direction */
87 #define ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_LOOP_TIME                              0x4004  /* Color Loop Time */
88 #define ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_LOOP_START_ENH_HUE                     0x4005  /* Color Loop Start Enhanced Hue */
89 #define ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_LOOP_STORED_ENH_HUE                    0x4006  /* Color Loop Stored Enhanced Hue */
90 #define ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_CAPABILITIES                           0x400a  /* Color Capabilities */
91 #define ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_TEMPERATURE_PHYS_MIN                   0x400b  /* Color Temperature Physical Min */
92 #define ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_TEMPERATURE_PHYS_MAX                   0x400c  /* Color Temperature Physical Max */
93 #define ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_STARTUP_COLOR_TEMPERATURE                    0x4010  /* Startup Color Temperature */
94
95 /* Server Commands Received */
96 #define ZBEE_ZCL_CMD_ID_COLOR_CONTROL_MOVE_TO_HUE                                   0x00  /* Move to Hue */
97 #define ZBEE_ZCL_CMD_ID_COLOR_CONTROL_MOVE_HUE                                      0x01  /* Move Hue */
98 #define ZBEE_ZCL_CMD_ID_COLOR_CONTROL_STEP_HUE                                      0x02  /* Step Hue */
99 #define ZBEE_ZCL_CMD_ID_COLOR_CONTROL_MOVE_TO_SATURATION                            0x03  /* Move to Saturation */
100 #define ZBEE_ZCL_CMD_ID_COLOR_CONTROL_MOVE_SATURATION                               0x04  /* Move Saturation */
101 #define ZBEE_ZCL_CMD_ID_COLOR_CONTROL_STEP_SATURATION                               0x05  /* Step Saturation */
102 #define ZBEE_ZCL_CMD_ID_COLOR_CONTROL_MOVE_TO_HUE_AND_SATURATION                    0x06  /* Move to Hue and Saturation */
103 #define ZBEE_ZCL_CMD_ID_COLOR_CONTROL_MOVE_TO_COLOR                                 0x07  /* Move to Color */
104 #define ZBEE_ZCL_CMD_ID_COLOR_CONTROL_MOVE_COLOR                                    0x08  /* Move Color */
105 #define ZBEE_ZCL_CMD_ID_COLOR_CONTROL_STEP_COLOR                                    0x09  /* Step Color */
106 #define ZBEE_ZCL_CMD_ID_COLOR_CONTROL_MOVE_TO_COLOR_TEMP                            0x0a  /* Move to Color Temperature */
107 #define ZBEE_ZCL_CMD_ID_COLOR_CONTROL_ENHANCED_MOVE_TO_HUE                          0x40  /* Enhanced Move to Hue */
108 #define ZBEE_ZCL_CMD_ID_COLOR_CONTROL_ENHANCED_MOVE_HUE                             0x41  /* Enhanced Move Hue */
109 #define ZBEE_ZCL_CMD_ID_COLOR_CONTROL_ENHANCED_STEP_HUE                             0x42  /* Enhanced Step Hue */
110 #define ZBEE_ZCL_CMD_ID_COLOR_CONTROL_ENHANCED_MOVE_TO_HUE_AND_SATURATION           0x43  /* Enhanced Move to Hue and Saturation */
111 #define ZBEE_ZCL_CMD_ID_COLOR_CONTROL_COLOR_LOOP_SET                                0x44  /* Color Loop Set */
112 #define ZBEE_ZCL_CMD_ID_COLOR_CONTROL_STOP_MOVE_STEP                                0x47  /* Stop Move Step */
113 #define ZBEE_ZCL_CMD_ID_COLOR_CONTROL_MOVE_COLOR_TEMP                               0x4b  /* Move Color Temperature */
114 #define ZBEE_ZCL_CMD_ID_COLOR_CONTROL_STEP_COLOR_TEMP                               0x4c  /* Step Color Temperature */
115
116 #define ZBEE_ZCL_NORMAL_HUE                                                         FALSE
117 #define ZBEE_ZCL_ENHANCED_HUE                                                       TRUE
118
119 /* Server Commands Generated - None */
120
121 /*************************/
122 /* Function Declarations */
123 /*************************/
124
125 void proto_register_zbee_zcl_color_control(void);
126 void proto_reg_handoff_zbee_zcl_color_control(void);
127
128 /* Command Dissector Helpers */
129 static void dissect_zcl_color_control_move_to_hue                               (tvbuff_t *tvb, proto_tree *tree, guint *offset, gboolean enhanced);
130 static void dissect_zcl_color_control_move_hue_saturation                       (tvbuff_t *tvb, proto_tree *tree, guint *offset, gboolean enhanced);
131 static void dissect_zcl_color_control_step_hue_saturation                       (tvbuff_t *tvb, proto_tree *tree, guint *offset, gboolean enhanced);
132 static void dissect_zcl_color_control_move_to_saturation                        (tvbuff_t *tvb, proto_tree *tree, guint *offset);
133 static void dissect_zcl_color_control_move_to_hue_and_saturation                (tvbuff_t *tvb, proto_tree *tree, guint *offset, gboolean enhanced);
134 static void dissect_zcl_color_control_move_to_color                             (tvbuff_t *tvb, proto_tree *tree, guint *offset);
135 static void dissect_zcl_color_control_move_color                                (tvbuff_t *tvb, proto_tree *tree, guint *offset);
136 static void dissect_zcl_color_control_step_color                                (tvbuff_t *tvb, proto_tree *tree, guint *offset);
137 static void dissect_zcl_color_control_move_to_color_temp                        (tvbuff_t *tvb, proto_tree *tree, guint *offset);
138 static void dissect_zcl_color_control_color_loop_set                            (tvbuff_t *tvb, proto_tree *tree, guint *offset);
139 static void dissect_zcl_color_control_move_color_temp                           (tvbuff_t *tvb, proto_tree *tree, guint *offset);
140 static void dissect_zcl_color_control_step_color_temp                           (tvbuff_t *tvb, proto_tree *tree, guint *offset);
141
142 static void dissect_zcl_color_control_attr_data                                 (proto_tree *tree, tvbuff_t *tvb, guint *offset, guint16 attr_id, guint data_type, gboolean client_attr);
143
144 /* Private functions prototype */
145
146 /*************************/
147 /* Global Variables      */
148 /*************************/
149 /* Initialize the protocol and registered fields */
150 static int proto_zbee_zcl_color_control = -1;
151
152 static int hf_zbee_zcl_color_control_attr_id = -1;
153 static int hf_zbee_zcl_color_control_attr_current_hue = -1;
154 static int hf_zbee_zcl_color_control_attr_current_saturation = -1;
155 static int hf_zbee_zcl_color_control_attr_remaining_time = -1;
156 static int hf_zbee_zcl_color_control_attr_color_x = -1;
157 static int hf_zbee_zcl_color_control_attr_color_y = -1;
158 static int hf_zbee_zcl_color_control_attr_drift_compensation = -1;
159 static int hf_zbee_zcl_color_control_attr_color_temperature = -1;
160 static int hf_zbee_zcl_color_control_attr_color_mode = -1;
161 static int hf_zbee_zcl_color_control_attr_nr_of_primaries = -1;
162 static int hf_zbee_zcl_color_control_attr_primary_1_x = -1;
163 static int hf_zbee_zcl_color_control_attr_primary_1_y = -1;
164 static int hf_zbee_zcl_color_control_attr_primary_1_intensity = -1;
165 static int hf_zbee_zcl_color_control_attr_primary_2_x = -1;
166 static int hf_zbee_zcl_color_control_attr_primary_2_y = -1;
167 static int hf_zbee_zcl_color_control_attr_primary_2_intensity = -1;
168 static int hf_zbee_zcl_color_control_attr_primary_3_x = -1;
169 static int hf_zbee_zcl_color_control_attr_primary_3_y = -1;
170 static int hf_zbee_zcl_color_control_attr_primary_3_intensity = -1;
171 static int hf_zbee_zcl_color_control_attr_primary_4_x = -1;
172 static int hf_zbee_zcl_color_control_attr_primary_4_y = -1;
173 static int hf_zbee_zcl_color_control_attr_primary_4_intensity = -1;
174 static int hf_zbee_zcl_color_control_attr_primary_5_x = -1;
175 static int hf_zbee_zcl_color_control_attr_primary_5_y = -1;
176 static int hf_zbee_zcl_color_control_attr_primary_5_intensity = -1;
177 static int hf_zbee_zcl_color_control_attr_primary_6_x = -1;
178 static int hf_zbee_zcl_color_control_attr_primary_6_y = -1;
179 static int hf_zbee_zcl_color_control_attr_primary_6_intensity = -1;
180 static int hf_zbee_zcl_color_control_attr_white_point_x = -1;
181 static int hf_zbee_zcl_color_control_attr_white_point_y = -1;
182 static int hf_zbee_zcl_color_control_attr_red_x = -1;
183 static int hf_zbee_zcl_color_control_attr_red_y = -1;
184 static int hf_zbee_zcl_color_control_attr_red_intensity = -1;
185 static int hf_zbee_zcl_color_control_attr_green_x = -1;
186 static int hf_zbee_zcl_color_control_attr_green_y = -1;
187 static int hf_zbee_zcl_color_control_attr_green_intensity = -1;
188 static int hf_zbee_zcl_color_control_attr_blue_x = -1;
189 static int hf_zbee_zcl_color_control_attr_blue_y = -1;
190 static int hf_zbee_zcl_color_control_attr_blue_intensity = -1;
191 static int hf_zbee_zcl_color_control_attr_enhanced_current_hue = -1;
192 static int hf_zbee_zcl_color_control_attr_enhanced_color_mode = -1;
193 static int hf_zbee_zcl_color_control_attr_color_loop_active = -1;
194 static int hf_zbee_zcl_color_control_attr_color_loop_direction = -1;
195 static int hf_zbee_zcl_color_control_attr_color_loop_time = -1;
196 static int hf_zbee_zcl_color_control_attr_color_loop_start_enhanced_hue = -1;
197 static int hf_zbee_zcl_color_control_attr_color_loop_stored_enhanced_hue = -1;
198 static int hf_zbee_zcl_color_control_attr_color_capabilities = -1;
199 static int hf_zbee_zcl_color_control_attr_color_capabilities_hs = -1;
200 static int hf_zbee_zcl_color_control_attr_color_capabilities_ehs = -1;
201 static int hf_zbee_zcl_color_control_attr_color_capabilities_loop = -1;
202 static int hf_zbee_zcl_color_control_attr_color_capabilities_xy = -1;
203 static int hf_zbee_zcl_color_control_attr_color_capabilities_ct = -1;
204 static int hf_zbee_zcl_color_control_attr_color_temperature_phys_min = -1;
205 static int hf_zbee_zcl_color_control_attr_color_temperature_phys_max = -1;
206 static int hf_zbee_zcl_color_control_attr_startup_color_temperature = -1;
207 static int hf_zbee_zcl_color_control_hue = -1;
208 static int hf_zbee_zcl_color_control_direction = -1;
209 static int hf_zbee_zcl_color_control_transit_time = -1;
210 static int hf_zbee_zcl_color_control_move_mode = -1;
211 static int hf_zbee_zcl_color_control_rate = -1;
212 static int hf_zbee_zcl_color_control_step_mode = -1;
213 static int hf_zbee_zcl_color_control_step_size = -1;
214 static int hf_zbee_zcl_color_control_transit_time_8bit = -1;
215 static int hf_zbee_zcl_color_control_saturation = -1;
216 static int hf_zbee_zcl_color_control_color_X = -1;
217 static int hf_zbee_zcl_color_control_color_Y = -1;
218 static int hf_zbee_zcl_color_control_rate_X = -1;
219 static int hf_zbee_zcl_color_control_rate_Y = -1;
220 static int hf_zbee_zcl_color_control_step_X = -1;
221 static int hf_zbee_zcl_color_control_step_Y = -1;
222 static int hf_zbee_zcl_color_control_color_temp = -1;
223 static int hf_zbee_zcl_color_control_enhanced_hue = -1;
224 static int hf_zbee_zcl_color_control_enhanced_rate = -1;
225 static int hf_zbee_zcl_color_control_enhanced_step_size = -1;
226 static int hf_zbee_zcl_color_control_color_loop_update_flags = -1;
227 static int hf_zbee_zcl_color_control_color_loop_update_action = -1;
228 static int hf_zbee_zcl_color_control_color_loop_update_direction = -1;
229 static int hf_zbee_zcl_color_control_color_loop_update_time = -1;
230 static int hf_zbee_zcl_color_control_color_loop_update_start_hue = -1;
231 static int hf_zbee_zcl_color_control_color_loop_action = -1;
232 static int hf_zbee_zcl_color_control_color_loop_direction = -1;
233 static int hf_zbee_zcl_color_control_color_loop_time = -1;
234 static int hf_zbee_zcl_color_control_color_loop_start_hue = -1;
235 static int hf_zbee_zcl_color_control_color_temp_min = -1;
236 static int hf_zbee_zcl_color_control_color_temp_max = -1;
237 static int hf_zbee_zcl_color_control_srv_rx_cmd_id = -1;
238
239 /* Initialize the subtree pointers */
240 static gint ett_zbee_zcl_color_control = -1;
241 static gint ett_zbee_zcl_color_control_color_capabilities = -1;
242 static gint ett_zbee_zcl_color_control_color_loop_settings = -1;
243
244 /* Attributes */
245 static const value_string zbee_zcl_color_control_attr_names[] = {
246     { ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_CURRENT_HUE,                   "Current Hue" },
247     { ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_CURRENT_SATURATION,            "Current Saturation" },
248     { ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_REMAINING_TIME,                "Remaining Time" },
249     { ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_CURRENT_X,                     "Current X" },
250     { ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_CURRENT_Y,                     "Current Y" },
251     { ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_DRIFT_COMPENSATION,            "Drift Compensation" },
252     { ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COMPENSATION_TEXT,             "Compensation Text" },
253     { ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_TEMP,                    "Color Temperature" },
254     { ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_MODE,                    "Color Mode" },
255     { ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_NO_OF_PRIMARIES,               "Number of Primaries" },
256     { ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_1_X,                   "Primary 1 X" },
257     { ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_1_Y,                   "Primary 1 Y" },
258     { ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_1_INTENSITY,           "Primary 1 Intensity" },
259     { ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_2_X,                   "Primary 2 X" },
260     { ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_2_Y,                   "Primary 2 Y" },
261     { ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_2_INTENSITY,           "Primary 2 Intensity" },
262     { ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_3_X,                   "Primary 3 X" },
263     { ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_3_Y,                   "Primary 3 Y" },
264     { ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_3_INTENSITY,           "Primary 3 Intensity" },
265     { ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_4_X,                   "Primary 4 X" },
266     { ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_4_Y,                   "Primary 4 Y" },
267     { ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_4_INTENSITY,           "Primary 4 Intensity" },
268     { ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_5_X,                   "Primary 5 X" },
269     { ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_5_Y,                   "Primary 5 Y" },
270     { ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_5_INTENSITY,           "Primary 5 Intensity" },
271     { ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_6_X,                   "Primary 6 X" },
272     { ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_6_Y,                   "Primary 6 Y" },
273     { ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_6_INTENSITY,           "Primary 6 Intensity" },
274     { ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_WHITE_POINT_X,                 "White Point X" },
275     { ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_WHITE_POINT_Y,                 "White Point Y" },
276     { ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_POINT_R_X,               "Color Point Red X" },
277     { ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_POINT_R_Y,               "Color Point Red Y" },
278     { ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_POINT_R_INTENSITY,       "Color Point Red Intensity" },
279     { ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_POINT_G_X,               "Color Point Green X" },
280     { ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_POINT_G_Y,               "Color Point Green Y" },
281     { ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_POINT_G_INTENSITY,       "Color Point Green Intensity" },
282     { ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_POINT_B_X,               "Color Point Blue X" },
283     { ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_POINT_B_Y,               "Color Point Blue Y" },
284     { ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_POINT_B_INTENSITY,       "Color Point Blue Intensity" },
285     { ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_ENHANCED_CURRENT_HUE,          "Enhanced Current Hue" },
286     { ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_ENHANCED_COLOR_MODE,           "Enhanced Color Mode" },
287     { ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_LOOP_ACTIVE,             "Color Loop Active" },
288     { ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_LOOP_DIRECTION,          "Color Loop Direction" },
289     { ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_LOOP_TIME,               "Color Loop Time" },
290     { ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_LOOP_START_ENH_HUE,      "Color Loop Start Enhanced Hue" },
291     { ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_LOOP_STORED_ENH_HUE,     "Color Loop Stored Enhanced Hue" },
292     { ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_CAPABILITIES,            "Color Capabilities" },
293     { ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_TEMPERATURE_PHYS_MIN,    "Color Temperature Physical Min" },
294     { ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_TEMPERATURE_PHYS_MAX,    "Color Temperature Physical Max" },
295     { ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_STARTUP_COLOR_TEMPERATURE,     "Startup Color Temperature" },
296     { 0, NULL }
297 };
298
299 /* Server Commands Received */
300 static const value_string zbee_zcl_color_control_srv_rx_cmd_names[] = {
301     { ZBEE_ZCL_CMD_ID_COLOR_CONTROL_MOVE_TO_HUE,                            "Move to Hue" },
302     { ZBEE_ZCL_CMD_ID_COLOR_CONTROL_MOVE_HUE,                               "Move Hue" },
303     { ZBEE_ZCL_CMD_ID_COLOR_CONTROL_STEP_HUE,                               "Step Hue" },
304     { ZBEE_ZCL_CMD_ID_COLOR_CONTROL_MOVE_TO_SATURATION,                     "Move to Saturation" },
305     { ZBEE_ZCL_CMD_ID_COLOR_CONTROL_MOVE_SATURATION,                        "Move Saturation" },
306     { ZBEE_ZCL_CMD_ID_COLOR_CONTROL_STEP_SATURATION,                        "Step Saturation" },
307     { ZBEE_ZCL_CMD_ID_COLOR_CONTROL_MOVE_TO_HUE_AND_SATURATION,             "Move to Hue and Saturation" },
308     { ZBEE_ZCL_CMD_ID_COLOR_CONTROL_MOVE_TO_COLOR,                          "Move to Color" },
309     { ZBEE_ZCL_CMD_ID_COLOR_CONTROL_MOVE_COLOR,                             "Move Color" },
310     { ZBEE_ZCL_CMD_ID_COLOR_CONTROL_STEP_COLOR,                             "Step Color" },
311     { ZBEE_ZCL_CMD_ID_COLOR_CONTROL_MOVE_TO_COLOR_TEMP,                     "Move to Color Temperature" },
312     { ZBEE_ZCL_CMD_ID_COLOR_CONTROL_ENHANCED_MOVE_TO_HUE,                   "Enhanced Move to Hue" },
313     { ZBEE_ZCL_CMD_ID_COLOR_CONTROL_ENHANCED_MOVE_HUE,                      "Enhanced Move Hue" },
314     { ZBEE_ZCL_CMD_ID_COLOR_CONTROL_ENHANCED_STEP_HUE,                      "Enhanced Step Hue" },
315     { ZBEE_ZCL_CMD_ID_COLOR_CONTROL_ENHANCED_MOVE_TO_HUE_AND_SATURATION,    "Enhanced Move to Hue and Saturation" },
316     { ZBEE_ZCL_CMD_ID_COLOR_CONTROL_COLOR_LOOP_SET,                         "Color Loop Set" },
317     { ZBEE_ZCL_CMD_ID_COLOR_CONTROL_STOP_MOVE_STEP,                         "Stop Move Step" },
318     { ZBEE_ZCL_CMD_ID_COLOR_CONTROL_MOVE_COLOR_TEMP,                        "Move Color Temperature" },
319     { ZBEE_ZCL_CMD_ID_COLOR_CONTROL_STEP_COLOR_TEMP,                        "Step Color Temperature" },
320     { 0, NULL }
321 };
322
323 /* Drift Compensation Values */
324 static const value_string zbee_zcl_color_control_drift_compensation_values[] = {
325     { 0x00,   "None" },
326     { 0x01,   "Other/Unknown" },
327     { 0x02,   "Temperature monitoring" },
328     { 0x03,   "Optical Luminance Monitoring and Feedback" },
329     { 0x04,   "Optical Color Monitoring and Feedback" },
330     { 0, NULL }
331 };
332
333 /* Color Mode Values */
334 static const value_string zbee_zcl_color_control_color_mode_values[] = {
335     { 0x00,   "Hue and Saturation" },
336     { 0x01,   "Color X and Y" },
337     { 0x02,   "Color Temperature" },
338     { 0x03,   "Enhanced Hue and Saturation" },
339     { 0, NULL }
340 };
341
342 /* Color Loop Directions */
343 static const value_string zbee_zcl_color_control_color_loop_direction_values[] = {
344     { 0x00,   "Hue is Decrementing" },
345     { 0x01,   "Hue is Incrementing" },
346     { 0, NULL }
347 };
348
349 /* Direction Values */
350 static const value_string zbee_zcl_color_control_direction_values[] = {
351     { 0x00,   "Shortest Distance" },
352     { 0x01,   "Longest Distance" },
353     { 0x02,   "Up" },
354     { 0x03,   "Down" },
355     { 0, NULL }
356 };
357
358 /* Move Mode Values */
359 static const value_string zbee_zcl_color_control_move_mode[] = {
360     { 0x00,   "Stop" },
361     { 0x01,   "Up" },
362     { 0x02,   "Reserved" },
363     { 0x03,   "Down" },
364     { 0, NULL }
365 };
366
367 /* Step Mode Values */
368 static const value_string zbee_zcl_color_control_step_mode[] = {
369     { 0x00,   "Reserved" },
370     { 0x01,   "Up" },
371     { 0x02,   "Reserved" },
372     { 0x03,   "Down" },
373     { 0, NULL }
374 };
375
376 /* Move Mode Values */
377 static const value_string zbee_zcl_color_control_action[] = {
378     { 0x00,   "De-activate" },
379     { 0x01,   "Activate from the value in the ColorLoopStartEnhancedHue field" },
380     { 0x02,   "Activate from the value of the EnhancedCurrentHue attribute" },
381     { 0, NULL }
382 };
383
384 /*************************/
385 /* Function Bodies       */
386 /*************************/
387
388 /**
389  *ZigBee ZCL Color Control cluster dissector for wireshark.
390  *
391  *@param tvb pointer to buffer containing raw packet.
392  *@param pinfo pointer to packet information fields
393  *@param tree pointer to data tree Wireshark uses to display packet.
394 */
395 static int
396 dissect_zbee_zcl_color_control(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
397 {
398     proto_tree        *payload_tree;
399     zbee_zcl_packet   *zcl;
400     guint             offset = 0;
401     guint8            cmd_id;
402     gint              rem_len;
403
404     /* Reject the packet if data is NULL */
405     if (data == NULL)
406         return 0;
407     zcl = (zbee_zcl_packet *)data;
408     cmd_id = zcl->cmd_id;
409
410     /*  Create a subtree for the ZCL Command frame, and add the command ID to it. */
411     if (zcl->direction == ZBEE_ZCL_FCF_TO_SERVER) {
412         /* Append the command name to the info column. */
413         col_append_fstr(pinfo->cinfo, COL_INFO, "%s, Seq: %u",
414             val_to_str_const(cmd_id, zbee_zcl_color_control_srv_rx_cmd_names, "Unknown Command"),
415             zcl->tran_seqno);
416
417         /* Add the command ID. */
418         proto_tree_add_item(tree, hf_zbee_zcl_color_control_srv_rx_cmd_id, tvb, offset, 1, ENC_LITTLE_ENDIAN);
419
420         /* Check if this command has a payload, then add the payload tree */
421         rem_len = tvb_reported_length_remaining(tvb, ++offset);
422         if (rem_len > 0) {
423             payload_tree = proto_tree_add_subtree(tree, tvb, offset, rem_len, ett_zbee_zcl_color_control, NULL, "Payload");
424
425             /* Call the appropriate command dissector */
426             switch (cmd_id) {
427                 case ZBEE_ZCL_CMD_ID_COLOR_CONTROL_MOVE_TO_HUE:
428                     dissect_zcl_color_control_move_to_hue(tvb, payload_tree, &offset, ZBEE_ZCL_NORMAL_HUE);
429                     break;
430
431                 case ZBEE_ZCL_CMD_ID_COLOR_CONTROL_MOVE_HUE:
432                     dissect_zcl_color_control_move_hue_saturation(tvb, payload_tree, &offset, ZBEE_ZCL_NORMAL_HUE);
433                     break;
434
435                 case ZBEE_ZCL_CMD_ID_COLOR_CONTROL_STEP_HUE:
436                     dissect_zcl_color_control_step_hue_saturation(tvb, payload_tree, &offset, ZBEE_ZCL_NORMAL_HUE);
437                     break;
438
439                 case ZBEE_ZCL_CMD_ID_COLOR_CONTROL_MOVE_TO_SATURATION:
440                     dissect_zcl_color_control_move_to_saturation(tvb, payload_tree, &offset);
441                     break;
442
443                 case ZBEE_ZCL_CMD_ID_COLOR_CONTROL_MOVE_SATURATION:
444                     dissect_zcl_color_control_move_hue_saturation(tvb, payload_tree, &offset, ZBEE_ZCL_NORMAL_HUE);
445                     break;
446
447                 case ZBEE_ZCL_CMD_ID_COLOR_CONTROL_STEP_SATURATION:
448                     dissect_zcl_color_control_step_hue_saturation(tvb, payload_tree, &offset, ZBEE_ZCL_NORMAL_HUE);
449                     break;
450
451                 case ZBEE_ZCL_CMD_ID_COLOR_CONTROL_MOVE_TO_HUE_AND_SATURATION:
452                     dissect_zcl_color_control_move_to_hue_and_saturation(tvb, payload_tree, &offset, ZBEE_ZCL_NORMAL_HUE);
453                     break;
454
455                 case ZBEE_ZCL_CMD_ID_COLOR_CONTROL_MOVE_TO_COLOR:
456                     dissect_zcl_color_control_move_to_color(tvb, payload_tree, &offset);
457                     break;
458
459                 case ZBEE_ZCL_CMD_ID_COLOR_CONTROL_MOVE_COLOR:
460                     dissect_zcl_color_control_move_color(tvb, payload_tree, &offset);
461                     break;
462
463                 case ZBEE_ZCL_CMD_ID_COLOR_CONTROL_STEP_COLOR:
464                     dissect_zcl_color_control_step_color(tvb, payload_tree, &offset);
465                     break;
466
467                 case ZBEE_ZCL_CMD_ID_COLOR_CONTROL_MOVE_TO_COLOR_TEMP:
468                     dissect_zcl_color_control_move_to_color_temp(tvb, payload_tree, &offset);
469                     break;
470
471                 case ZBEE_ZCL_CMD_ID_COLOR_CONTROL_ENHANCED_MOVE_TO_HUE:
472                     dissect_zcl_color_control_move_to_hue(tvb, payload_tree, &offset, ZBEE_ZCL_ENHANCED_HUE);
473                     break;
474
475                 case ZBEE_ZCL_CMD_ID_COLOR_CONTROL_ENHANCED_MOVE_HUE:
476                     dissect_zcl_color_control_move_hue_saturation(tvb, payload_tree, &offset, ZBEE_ZCL_ENHANCED_HUE);
477                     break;
478
479                 case ZBEE_ZCL_CMD_ID_COLOR_CONTROL_ENHANCED_STEP_HUE:
480                     dissect_zcl_color_control_step_hue_saturation(tvb, payload_tree, &offset, ZBEE_ZCL_ENHANCED_HUE);
481                     break;
482
483                 case ZBEE_ZCL_CMD_ID_COLOR_CONTROL_ENHANCED_MOVE_TO_HUE_AND_SATURATION:
484                     dissect_zcl_color_control_move_to_hue_and_saturation(tvb, payload_tree, &offset, ZBEE_ZCL_ENHANCED_HUE);
485                     break;
486
487                 case ZBEE_ZCL_CMD_ID_COLOR_CONTROL_COLOR_LOOP_SET:
488                     dissect_zcl_color_control_color_loop_set(tvb, payload_tree, &offset);
489                     break;
490
491                 case ZBEE_ZCL_CMD_ID_COLOR_CONTROL_MOVE_COLOR_TEMP:
492                     dissect_zcl_color_control_move_color_temp(tvb, payload_tree, &offset);
493                     break;
494
495                 case ZBEE_ZCL_CMD_ID_COLOR_CONTROL_STEP_COLOR_TEMP:
496                     dissect_zcl_color_control_step_color_temp(tvb, payload_tree, &offset);
497                     break;
498
499                 case ZBEE_ZCL_CMD_ID_COLOR_CONTROL_STOP_MOVE_STEP:
500                 default:
501                     break;
502             }
503         }
504     }
505
506     return tvb_captured_length(tvb);
507 } /*dissect_zbee_zcl_color_control*/
508
509
510 /**
511  *This function decodes the Add Group or Add Group If
512  *
513  *@param  tvb the tv buffer of the current data_type
514  *@param  tree the tree to append this item to
515  *@param  offset offset of data in tvb
516 */
517 static void
518 dissect_zcl_color_control_move_to_hue(tvbuff_t *tvb, proto_tree *tree, guint *offset, gboolean enhanced)
519 {
520     /* Retrieve "Hue" field */
521     if (enhanced)
522     {
523         proto_tree_add_item(tree, hf_zbee_zcl_color_control_enhanced_hue, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
524         *offset += 2;
525     }
526     else
527     {
528         proto_tree_add_item(tree, hf_zbee_zcl_color_control_hue, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
529         *offset += 1;
530     }
531
532     /* Retrieve "Direction" field */
533     proto_tree_add_item(tree, hf_zbee_zcl_color_control_direction, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
534     *offset += 1;
535
536     /* Retrieve "Transition Time" field */
537     proto_tree_add_item(tree, hf_zbee_zcl_color_control_transit_time, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
538     *offset += 2;
539
540 } /*dissect_zcl_color_control_move_to_hue*/
541
542
543 /**
544  *This function decodes the Move Hue and Move Saturation payload.
545  *
546  *@param  tvb the tv buffer of the current data_type
547  *@param  tree the tree to append this item to
548  *@param  offset offset of data in tvb
549 */
550 static void
551 dissect_zcl_color_control_move_hue_saturation(tvbuff_t *tvb, proto_tree *tree, guint *offset, gboolean enhanced)
552 {
553     /* Retrieve "Move Mode" field */
554     proto_tree_add_item(tree, hf_zbee_zcl_color_control_move_mode, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
555     *offset += 1;
556
557     /* Retrieve "Rate" field */
558     if (enhanced)
559     {
560         proto_tree_add_item(tree, hf_zbee_zcl_color_control_enhanced_rate, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
561         *offset += 2;
562     }
563     else
564     {
565         proto_tree_add_item(tree, hf_zbee_zcl_color_control_rate, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
566         *offset += 1;
567     }
568
569 } /*dissect_zcl_color_control_move_hue_saturation*/
570
571
572 /**
573  *This function decodes the Step Hue and Step Saturation payload
574  *
575  *@param  tvb the tv buffer of the current data_type
576  *@param  tree the tree to append this item to
577  *@param  offset offset of data in tvb
578 */
579 static void
580 dissect_zcl_color_control_step_hue_saturation(tvbuff_t *tvb, proto_tree *tree, guint *offset, gboolean enhanced)
581 {
582     /* Retrieve "Step Mode" field */
583     proto_tree_add_item(tree, hf_zbee_zcl_color_control_step_mode, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
584     *offset += 1;
585
586     /* Retrieve "Step Size" field */
587     if (enhanced)
588     {
589         proto_tree_add_item(tree, hf_zbee_zcl_color_control_enhanced_step_size, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
590         *offset += 2;
591     }
592     else
593     {
594         proto_tree_add_item(tree, hf_zbee_zcl_color_control_step_size, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
595         *offset += 1;
596     }
597
598     /* Retrieve "Transition Time" field */
599     proto_tree_add_item(tree, hf_zbee_zcl_color_control_transit_time_8bit, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
600     *offset += 1;
601
602 } /*dissect_zcl_color_control_step_hue_saturation*/
603
604
605 /**
606  *This function decodes the Move to Saturation payload.
607  *
608  *@param  tvb the tv buffer of the current data_type
609  *@param  tree the tree to append this item to
610  *@param  offset offset of data in tvb
611 */
612 static void
613 dissect_zcl_color_control_move_to_saturation(tvbuff_t *tvb, proto_tree *tree, guint *offset)
614 {
615     /* Retrieve "Saturation" field */
616     proto_tree_add_item(tree, hf_zbee_zcl_color_control_saturation, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
617     *offset += 1;
618
619     /* Retrieve "Transition Time" field */
620     proto_tree_add_item(tree, hf_zbee_zcl_color_control_transit_time, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
621     *offset += 2;
622
623 } /*dissect_zcl_color_control_move_to_saturation*/
624
625
626 /**
627  *This function decodes the Move to Hue and Saturation payload.
628  *
629  *@param  tvb the tv buffer of the current data_type
630  *@param  tree the tree to append this item to
631  *@param  offset offset of data in tvb
632 */
633 static void
634 dissect_zcl_color_control_move_to_hue_and_saturation(tvbuff_t *tvb, proto_tree *tree, guint *offset, gboolean enhanced)
635 {
636     /* Retrieve "Hue" field */
637     if (enhanced)
638     {
639         proto_tree_add_item(tree, hf_zbee_zcl_color_control_enhanced_hue, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
640         *offset += 2;
641     }
642     else
643     {
644         proto_tree_add_item(tree, hf_zbee_zcl_color_control_hue, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
645         *offset += 1;
646     }
647
648     /* Retrieve "Saturation" field */
649     proto_tree_add_item(tree, hf_zbee_zcl_color_control_saturation, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
650     *offset += 1;
651
652     /* Retrieve "Transition Time" field */
653     proto_tree_add_item(tree, hf_zbee_zcl_color_control_transit_time, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
654     *offset += 2;
655
656 } /*dissect_zcl_color_control_move_to_hue_and_saturation*/
657
658
659 /**
660  *This function decodes the Move to Color payload.
661  *
662  *@param  tvb the tv buffer of the current data_type
663  *@param  tree the tree to append this item to
664  *@param  offset offset of data in tvb
665 */
666 static void
667 dissect_zcl_color_control_move_to_color(tvbuff_t *tvb, proto_tree *tree, guint *offset)
668 {
669    /* Retrieve "Color X" field */
670    proto_tree_add_item(tree, hf_zbee_zcl_color_control_color_X, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
671    *offset += 2;
672
673    /* Retrieve "Color Y" field */
674    proto_tree_add_item(tree, hf_zbee_zcl_color_control_color_Y, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
675    *offset += 2;
676
677    /* Retrieve "Transition Time" field */
678    proto_tree_add_item(tree, hf_zbee_zcl_color_control_transit_time, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
679    *offset += 2;
680
681 } /*dissect_zcl_color_control_move_to_color*/
682
683 /**
684  *This function decodes the Move Color payload.
685  *
686  *@param  tvb the tv buffer of the current data_type
687  *@param  tree the tree to append this item to
688  *@param  offset offset of data in tvb
689 */
690 static void
691 dissect_zcl_color_control_move_color(tvbuff_t *tvb, proto_tree *tree, guint *offset)
692 {
693    /* Retrieve "Rate X" field */
694    proto_tree_add_item(tree, hf_zbee_zcl_color_control_rate_X, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
695    *offset += 2;
696
697    /* Retrieve "Rate Y" field */
698    proto_tree_add_item(tree, hf_zbee_zcl_color_control_rate_Y, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
699    *offset += 2;
700
701 } /*dissect_zcl_color_control_move_color*/
702
703
704 /**
705  *This function decodes the Step Color payload.
706  *
707  *@param  tvb the tv buffer of the current data_type
708  *@param  tree the tree to append this item to
709  *@param  offset offset of data in tvb
710 */
711 static void
712 dissect_zcl_color_control_step_color(tvbuff_t *tvb, proto_tree *tree, guint *offset)
713 {
714    /* Retrieve "Step X" field */
715    proto_tree_add_item(tree, hf_zbee_zcl_color_control_step_X, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
716    *offset += 2;
717
718    /* Retrieve "Step Y" field */
719    proto_tree_add_item(tree, hf_zbee_zcl_color_control_step_Y, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
720    *offset += 2;
721
722    /* Retrieve "Transition Time" field */
723    proto_tree_add_item(tree, hf_zbee_zcl_color_control_transit_time, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
724    *offset += 2;
725
726 } /*dissect_zcl_color_control_step_color*/
727
728 /**
729  *This function decodes the Move to Color Temperature payload.
730  *
731  *@param  tvb the tv buffer of the current data_type
732  *@param  tree the tree to append this item to
733  *@param  offset offset of data in tvb
734 */
735 static void
736 dissect_zcl_color_control_move_to_color_temp(tvbuff_t *tvb, proto_tree *tree, guint *offset)
737 {
738    /* Retrieve "Color Temperature" field */
739    proto_tree_add_item(tree, hf_zbee_zcl_color_control_color_temp, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
740    *offset += 2;
741
742    /* Retrieve "Transition Time" field */
743    proto_tree_add_item(tree, hf_zbee_zcl_color_control_transit_time, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
744    *offset += 2;
745
746 } /*dissect_zcl_color_control_move_to_color_temp*/
747
748 /**
749  *This function decodes the Color Loop Set payload.
750  *
751  *@param  tvb the tv buffer of the current data_type
752  *@param  tree the tree to append this item to
753  *@param  offset offset of data in tvb
754 */
755 static void
756 dissect_zcl_color_control_color_loop_set(tvbuff_t *tvb, proto_tree *tree, guint *offset)
757 {
758     static const int *color_loop_update_fields[] = {
759         &hf_zbee_zcl_color_control_color_loop_update_action,
760         &hf_zbee_zcl_color_control_color_loop_update_direction,
761         &hf_zbee_zcl_color_control_color_loop_update_time,
762         &hf_zbee_zcl_color_control_color_loop_update_start_hue,
763         NULL
764     };
765
766     /* Retrieve "Update Flags" field */
767     proto_tree_add_bitmask(tree, tvb, *offset, hf_zbee_zcl_color_control_color_loop_update_flags, ett_zbee_zcl_color_control_color_loop_settings, color_loop_update_fields, ENC_LITTLE_ENDIAN);
768     *offset += 1;
769
770     /* Retrieve "Action" field */
771     proto_tree_add_item(tree, hf_zbee_zcl_color_control_color_loop_action, tvb, *offset, 1, ENC_NA);
772     *offset += 1;
773
774     /* Retrieve "Direction" field */
775     proto_tree_add_item(tree, hf_zbee_zcl_color_control_color_loop_direction, tvb, *offset, 1, ENC_NA);
776     *offset += 1;
777
778     /* Retrieve "Time" field */
779     proto_tree_add_item(tree, hf_zbee_zcl_color_control_color_loop_time, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
780     *offset += 2;
781
782     /* Retrieve "Start Hue" field */
783     proto_tree_add_item(tree, hf_zbee_zcl_color_control_color_loop_start_hue, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
784     *offset += 2;
785
786 } /*dissect_zcl_color_control_color_loop_set*/
787
788   /**
789   *This function decodes the Move Color Temperature payload.
790   *
791   *@param  tvb the tv buffer of the current data_type
792   *@param  tree the tree to append this item to
793   *@param  offset offset of data in tvb
794   */
795 static void
796 dissect_zcl_color_control_move_color_temp(tvbuff_t *tvb, proto_tree *tree, guint *offset)
797 {
798     /* Retrieve "Move Mode" field */
799     proto_tree_add_item(tree, hf_zbee_zcl_color_control_move_mode, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
800     *offset += 1;
801
802     /* Retrieve "Rate" field */
803     proto_tree_add_item(tree, hf_zbee_zcl_color_control_enhanced_rate, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
804     *offset += 2;
805
806     /* Retrieve "Color Temperature Min" field */
807     proto_tree_add_item(tree, hf_zbee_zcl_color_control_color_temp_min, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
808     *offset += 2;
809
810     /* Retrieve "Color Temperature Max" field */
811     proto_tree_add_item(tree, hf_zbee_zcl_color_control_color_temp_max, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
812     *offset += 2;
813
814 } /*dissect_zcl_color_control_move_color_temp*/
815
816   /**
817   *This function decodes the Step Color Temperature payload.
818   *
819   *@param  tvb the tv buffer of the current data_type
820   *@param  tree the tree to append this item to
821   *@param  offset offset of data in tvb
822   */
823 static void
824 dissect_zcl_color_control_step_color_temp(tvbuff_t *tvb, proto_tree *tree, guint *offset)
825 {
826     /* Retrieve "Step Mode" field */
827     proto_tree_add_item(tree, hf_zbee_zcl_color_control_step_mode, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
828     *offset += 1;
829
830     /* Retrieve "Step" field */
831     proto_tree_add_item(tree, hf_zbee_zcl_color_control_enhanced_step_size, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
832     *offset += 2;
833
834     /* Retrieve "Time" field */
835     proto_tree_add_item(tree, hf_zbee_zcl_color_control_transit_time, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
836     *offset += 2;
837
838     /* Retrieve "Color Temperature Min" field */
839     proto_tree_add_item(tree, hf_zbee_zcl_color_control_color_temp_min, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
840     *offset += 2;
841
842     /* Retrieve "Color Temperature Max" field */
843     proto_tree_add_item(tree, hf_zbee_zcl_color_control_color_temp_max, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
844     *offset += 2;
845
846 } /*dissect_zcl_color_control_step_color_temp*/
847
848 /*FUNCTION:------------------------------------------------------
849  *  NAME
850  *    decode_color_xy
851  *  DESCRIPTION
852  *    this function decodes color xy values
853  *  PARAMETERS
854  *      guint *s        - string to display
855  *      guint16 value   - value to decode
856  *  RETURNS
857  *    none
858  *---------------------------------------------------------------
859  */
860 static void
861 decode_color_xy(gchar *s, guint16 value)
862 {
863     g_snprintf(s, ITEM_LABEL_LENGTH, "%.4lf", value/65535.0);
864     return;
865 } /*decode_power_conf_voltage*/
866
867   /*FUNCTION:------------------------------------------------------
868   *  NAME
869   *    decode_color_temperature
870   *  DESCRIPTION
871   *    this function decodes color temperature values
872   *  PARAMETERS
873   *      guint *s        - string to display
874   *      guint16 value   - value to decode
875   *  RETURNS
876   *    none
877   *---------------------------------------------------------------
878   */
879 static void
880 decode_color_temperature(gchar *s, guint16 value)
881 {
882     if (value == 0) {
883         g_snprintf(s, ITEM_LABEL_LENGTH, "%u [Mired]", value);
884     } else {
885         g_snprintf(s, ITEM_LABEL_LENGTH, "%u [Mired] (%u [K])", value, 1000000/value);
886     }
887     return;
888 } /*decode_color_temperature*/
889
890   /*FUNCTION:------------------------------------------------------
891   *  NAME
892   *    decode_startup_color_temperature
893   *  DESCRIPTION
894   *    this function decodes color temperature values
895   *  PARAMETERS
896   *      guint *s        - string to display
897   *      guint16 value   - value to decode
898   *  RETURNS
899   *    none
900   *---------------------------------------------------------------
901   */
902 static void
903 decode_startup_color_temperature(gchar *s, guint16 value)
904 {
905     if (value == 0xffff)
906     {
907         g_snprintf(s, ITEM_LABEL_LENGTH, "Set the Color Temperature attribute to its previous value");
908     }
909     else
910     {
911         decode_color_temperature(s, value);
912     }
913     return;
914 } /*decode_startup_color_temperature*/
915
916   /**
917  *This function is called by ZCL foundation dissector in order to decode
918  *
919  *@param tree pointer to data tree Wireshark uses to display packet.
920  *@param tvb pointer to buffer containing raw packet.
921  *@param offset pointer to buffer offset
922  *@param attr_id attribute identifier
923  *@param data_type attribute data type
924  *@param client_attr ZCL client
925 */
926 void
927 dissect_zcl_color_control_attr_data(proto_tree *tree, tvbuff_t *tvb, guint *offset, guint16 attr_id, guint data_type, gboolean client_attr)
928 {
929     static const int *capabilities_fields[] = {
930         &hf_zbee_zcl_color_control_attr_color_capabilities_hs,
931         &hf_zbee_zcl_color_control_attr_color_capabilities_ehs,
932         &hf_zbee_zcl_color_control_attr_color_capabilities_loop,
933         &hf_zbee_zcl_color_control_attr_color_capabilities_xy,
934         &hf_zbee_zcl_color_control_attr_color_capabilities_ct,
935         NULL
936     };
937
938     /* Dissect attribute data type and data */
939     switch ( attr_id ) {
940
941         case ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_CURRENT_HUE:
942             proto_tree_add_item(tree, hf_zbee_zcl_color_control_attr_current_hue, tvb, *offset, 1, ENC_NA);
943             *offset += 1;
944             break;
945
946         case ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_CURRENT_SATURATION:
947             proto_tree_add_item(tree, hf_zbee_zcl_color_control_attr_current_saturation, tvb, *offset, 1, ENC_NA);
948             *offset += 1;
949             break;
950
951         case ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_REMAINING_TIME:
952             proto_tree_add_item(tree, hf_zbee_zcl_color_control_attr_remaining_time, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
953             *offset += 2;
954             break;
955
956         case ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_CURRENT_X:
957             proto_tree_add_item(tree, hf_zbee_zcl_color_control_attr_color_x, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
958             *offset += 2;
959             break;
960
961         case ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_CURRENT_Y:
962             proto_tree_add_item(tree, hf_zbee_zcl_color_control_attr_color_y, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
963             *offset += 2;
964             break;
965
966         case ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_DRIFT_COMPENSATION:
967             proto_tree_add_item(tree, hf_zbee_zcl_color_control_attr_drift_compensation, tvb, *offset, 1, ENC_NA);
968             *offset += 1;
969             break;
970
971         case ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_TEMP:
972             proto_tree_add_item(tree, hf_zbee_zcl_color_control_attr_color_temperature, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
973             *offset += 2;
974             break;
975
976         case ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_MODE:
977             proto_tree_add_item(tree, hf_zbee_zcl_color_control_attr_color_mode, tvb, *offset, 1, ENC_NA);
978             *offset += 1;
979             break;
980
981         case ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_NO_OF_PRIMARIES:
982             proto_tree_add_item(tree, hf_zbee_zcl_color_control_attr_nr_of_primaries, tvb, *offset, 1, ENC_NA);
983             *offset += 1;
984             break;
985
986         case ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_1_X:
987             proto_tree_add_item(tree, hf_zbee_zcl_color_control_attr_primary_1_x, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
988             *offset += 2;
989             break;
990
991         case ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_1_Y:
992             proto_tree_add_item(tree, hf_zbee_zcl_color_control_attr_primary_1_y, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
993             *offset += 2;
994             break;
995
996         case ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_1_INTENSITY:
997             proto_tree_add_item(tree, hf_zbee_zcl_color_control_attr_primary_1_intensity, tvb, *offset, 1, ENC_NA);
998             *offset += 1;
999             break;
1000
1001         case ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_2_X:
1002             proto_tree_add_item(tree, hf_zbee_zcl_color_control_attr_primary_2_x, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
1003             *offset += 2;
1004             break;
1005
1006         case ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_2_Y:
1007             proto_tree_add_item(tree, hf_zbee_zcl_color_control_attr_primary_2_y, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
1008             *offset += 2;
1009             break;
1010
1011         case ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_2_INTENSITY:
1012             proto_tree_add_item(tree, hf_zbee_zcl_color_control_attr_primary_2_intensity, tvb, *offset, 1, ENC_NA);
1013             *offset += 1;
1014             break;
1015
1016         case ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_3_X:
1017             proto_tree_add_item(tree, hf_zbee_zcl_color_control_attr_primary_3_x, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
1018             *offset += 2;
1019             break;
1020
1021         case ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_3_Y:
1022             proto_tree_add_item(tree, hf_zbee_zcl_color_control_attr_primary_3_y, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
1023             *offset += 2;
1024             break;
1025
1026         case ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_3_INTENSITY:
1027             proto_tree_add_item(tree, hf_zbee_zcl_color_control_attr_primary_3_intensity, tvb, *offset, 1, ENC_NA);
1028             *offset += 1;
1029             break;
1030
1031         case ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_4_X:
1032             proto_tree_add_item(tree, hf_zbee_zcl_color_control_attr_primary_4_x, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
1033             *offset += 2;
1034             break;
1035
1036         case ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_4_Y:
1037             proto_tree_add_item(tree, hf_zbee_zcl_color_control_attr_primary_4_y, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
1038             *offset += 2;
1039             break;
1040
1041         case ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_4_INTENSITY:
1042             proto_tree_add_item(tree, hf_zbee_zcl_color_control_attr_primary_4_intensity, tvb, *offset, 1, ENC_NA);
1043             *offset += 1;
1044             break;
1045
1046         case ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_5_X:
1047             proto_tree_add_item(tree, hf_zbee_zcl_color_control_attr_primary_5_x, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
1048             *offset += 2;
1049             break;
1050
1051         case ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_5_Y:
1052             proto_tree_add_item(tree, hf_zbee_zcl_color_control_attr_primary_5_y, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
1053             *offset += 2;
1054             break;
1055
1056         case ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_5_INTENSITY:
1057             proto_tree_add_item(tree, hf_zbee_zcl_color_control_attr_primary_5_intensity, tvb, *offset, 1, ENC_NA);
1058             *offset += 1;
1059             break;
1060
1061         case ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_6_X:
1062             proto_tree_add_item(tree, hf_zbee_zcl_color_control_attr_primary_6_x, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
1063             *offset += 2;
1064             break;
1065
1066         case ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_6_Y:
1067             proto_tree_add_item(tree, hf_zbee_zcl_color_control_attr_primary_6_y, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
1068             *offset += 2;
1069             break;
1070
1071         case ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_PRIMARY_6_INTENSITY:
1072             proto_tree_add_item(tree, hf_zbee_zcl_color_control_attr_primary_6_intensity, tvb, *offset, 1, ENC_NA);
1073             *offset += 1;
1074             break;
1075
1076         case ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_WHITE_POINT_X:
1077             proto_tree_add_item(tree, hf_zbee_zcl_color_control_attr_white_point_x, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
1078             *offset += 2;
1079             break;
1080
1081         case ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_WHITE_POINT_Y:
1082             proto_tree_add_item(tree, hf_zbee_zcl_color_control_attr_white_point_y, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
1083             *offset += 2;
1084             break;
1085
1086         case ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_POINT_R_X:
1087             proto_tree_add_item(tree, hf_zbee_zcl_color_control_attr_red_x, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
1088             *offset += 2;
1089             break;
1090
1091         case ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_POINT_R_Y:
1092             proto_tree_add_item(tree, hf_zbee_zcl_color_control_attr_red_y, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
1093             *offset += 2;
1094             break;
1095
1096         case ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_POINT_R_INTENSITY:
1097             proto_tree_add_item(tree,hf_zbee_zcl_color_control_attr_red_intensity, tvb, *offset, 1, ENC_NA);
1098             *offset += 1;
1099             break;
1100
1101         case ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_POINT_G_X:
1102             proto_tree_add_item(tree, hf_zbee_zcl_color_control_attr_green_x, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
1103             *offset += 2;
1104             break;
1105
1106         case ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_POINT_G_Y:
1107             proto_tree_add_item(tree, hf_zbee_zcl_color_control_attr_green_y, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
1108             *offset += 2;
1109             break;
1110
1111         case ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_POINT_G_INTENSITY:
1112             proto_tree_add_item(tree,hf_zbee_zcl_color_control_attr_green_intensity, tvb, *offset, 1, ENC_NA);
1113             *offset += 1;
1114             break;
1115
1116         case ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_POINT_B_X:
1117             proto_tree_add_item(tree, hf_zbee_zcl_color_control_attr_blue_x, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
1118             *offset += 2;
1119             break;
1120
1121         case ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_POINT_B_Y:
1122             proto_tree_add_item(tree, hf_zbee_zcl_color_control_attr_blue_y, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
1123             *offset += 2;
1124             break;
1125
1126         case ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_POINT_B_INTENSITY:
1127             proto_tree_add_item(tree,hf_zbee_zcl_color_control_attr_blue_intensity, tvb, *offset, 1, ENC_NA);
1128             *offset += 1;
1129             break;
1130
1131         case ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_ENHANCED_CURRENT_HUE:
1132             proto_tree_add_item(tree, hf_zbee_zcl_color_control_attr_enhanced_current_hue, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
1133             *offset += 2;
1134             break;
1135
1136         case ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_ENHANCED_COLOR_MODE:
1137             proto_tree_add_item(tree, hf_zbee_zcl_color_control_attr_enhanced_color_mode, tvb, *offset, 1, ENC_NA);
1138             *offset += 1;
1139             break;
1140
1141         case ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_LOOP_ACTIVE:
1142             proto_tree_add_item(tree, hf_zbee_zcl_color_control_attr_color_loop_active, tvb, *offset, 1, ENC_NA);
1143             *offset += 1;
1144             break;
1145
1146         case ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_LOOP_DIRECTION:
1147             proto_tree_add_item(tree, hf_zbee_zcl_color_control_attr_color_loop_direction, tvb, *offset, 1, ENC_NA);
1148             *offset += 1;
1149             break;
1150
1151         case ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_LOOP_TIME:
1152             proto_tree_add_item(tree, hf_zbee_zcl_color_control_attr_color_loop_time, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
1153             *offset += 2;
1154             break;
1155
1156         case ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_LOOP_START_ENH_HUE:
1157             proto_tree_add_item(tree, hf_zbee_zcl_color_control_attr_color_loop_start_enhanced_hue, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
1158             *offset += 2;
1159             break;
1160
1161         case ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_LOOP_STORED_ENH_HUE:
1162             proto_tree_add_item(tree, hf_zbee_zcl_color_control_attr_color_loop_stored_enhanced_hue, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
1163             *offset += 2;
1164             break;
1165
1166         case ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_CAPABILITIES:
1167             proto_tree_add_bitmask(tree, tvb, *offset, hf_zbee_zcl_color_control_attr_color_capabilities, ett_zbee_zcl_color_control_color_capabilities, capabilities_fields, ENC_LITTLE_ENDIAN);
1168             *offset += 2;
1169             break;
1170
1171         case ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_TEMPERATURE_PHYS_MIN:
1172             proto_tree_add_item(tree, hf_zbee_zcl_color_control_attr_color_temperature_phys_min, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
1173             *offset += 2;
1174             break;
1175
1176         case ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COLOR_TEMPERATURE_PHYS_MAX:
1177             proto_tree_add_item(tree, hf_zbee_zcl_color_control_attr_color_temperature_phys_max, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
1178             *offset += 2;
1179             break;
1180
1181         case ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_STARTUP_COLOR_TEMPERATURE:
1182             proto_tree_add_item(tree, hf_zbee_zcl_color_control_attr_startup_color_temperature, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
1183             *offset += 2;
1184             break;
1185
1186         case ZBEE_ZCL_ATTR_ID_COLOR_CONTROL_COMPENSATION_TEXT:
1187         default:
1188             dissect_zcl_attr_data(tvb, tree, offset, data_type, client_attr);
1189             break;
1190     }
1191
1192 } /*dissect_zcl_color_control_attr_data*/
1193
1194
1195 /**
1196  *ZigBee ZCL Color Control cluster protocol registration routine.
1197  *
1198 */
1199 void
1200 proto_register_zbee_zcl_color_control(void)
1201 {
1202     /* Setup list of header fields */
1203     static hf_register_info hf[] = {
1204
1205         { &hf_zbee_zcl_color_control_attr_id,
1206             { "Attribute", "zbee_zcl_lighting.color_control.attr_id", FT_UINT16, BASE_HEX, VALS(zbee_zcl_color_control_attr_names),
1207             0x00, NULL, HFILL } },
1208
1209         { &hf_zbee_zcl_color_control_attr_current_hue,
1210             { "Hue", "zbee_zcl_lighting.color_control.attr.current_hue", FT_UINT8, BASE_DEC, NULL,
1211             0x00, NULL, HFILL } },
1212
1213         { &hf_zbee_zcl_color_control_attr_current_saturation,
1214             { "Saturation", "zbee_zcl_lighting.color_control.attr.current_satuaration", FT_UINT8, BASE_DEC, NULL,
1215             0x00, NULL, HFILL } },
1216
1217         { &hf_zbee_zcl_color_control_attr_remaining_time,
1218             { "Time", "zbee_zcl_lighting.color_control.attr.remaining_time", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_zcl_time_in_100ms),
1219             0x00, NULL, HFILL } },
1220
1221         { &hf_zbee_zcl_color_control_attr_color_x,
1222             { "X", "zbee_zcl_lighting.color_control.attr.color_x", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_color_xy),
1223             0x00, NULL, HFILL } },
1224
1225         { &hf_zbee_zcl_color_control_attr_color_y,
1226             { "Y", "zbee_zcl_lighting.color_control.attr.color_y", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_color_xy),
1227             0x00, NULL, HFILL } },
1228
1229         { &hf_zbee_zcl_color_control_attr_drift_compensation,
1230             { "Drift Compensation", "zbee_zcl_lighting.color_control.attr.drift_compensation", FT_UINT8, BASE_HEX, VALS(zbee_zcl_color_control_drift_compensation_values),
1231             0x00, NULL, HFILL } },
1232
1233         { &hf_zbee_zcl_color_control_attr_color_temperature,
1234             { "Color Temperature", "zbee_zcl_lighting.color_control.attr.color_temperature", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_color_temperature),
1235             0x00, NULL, HFILL } },
1236
1237         { &hf_zbee_zcl_color_control_attr_color_mode,
1238             { "Color Mode", "zbee_zcl_lighting.color_control.attr.color_mode", FT_UINT8, BASE_HEX, VALS(zbee_zcl_color_control_color_mode_values),
1239             0x00, NULL, HFILL } },
1240
1241         { &hf_zbee_zcl_color_control_attr_nr_of_primaries,
1242             { "Number", "zbee_zcl_lighting.color_control.attr.nr_of_primaries", FT_UINT8, BASE_DEC, NULL,
1243             0x00, NULL, HFILL } },
1244
1245         { &hf_zbee_zcl_color_control_attr_primary_1_x,
1246             { "X", "zbee_zcl_lighting.color_control.attr.primary_1_x", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_color_xy),
1247             0x00, NULL, HFILL } },
1248
1249         { &hf_zbee_zcl_color_control_attr_primary_1_y,
1250             { "Y", "zbee_zcl_lighting.color_control.attr.primary_1_y", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_color_xy),
1251             0x00, NULL, HFILL } },
1252
1253         { &hf_zbee_zcl_color_control_attr_primary_1_intensity,
1254             { "Intensity", "zbee_zcl_lighting.color_control.attr.primary_1_intensity", FT_UINT8, BASE_DEC, NULL,
1255             0x00, NULL, HFILL } },
1256
1257         { &hf_zbee_zcl_color_control_attr_primary_2_x,
1258             { "X", "zbee_zcl_lighting.color_control.attr.primary_2_x", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_color_xy),
1259             0x00, NULL, HFILL } },
1260
1261         { &hf_zbee_zcl_color_control_attr_primary_2_y,
1262             { "Y", "zbee_zcl_lighting.color_control.attr.primary_2_y", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_color_xy),
1263             0x00, NULL, HFILL } },
1264
1265         { &hf_zbee_zcl_color_control_attr_primary_2_intensity,
1266             { "Intensity", "zbee_zcl_lighting.color_control.attr.primary_2_intensity", FT_UINT8, BASE_DEC, NULL,
1267             0x00, NULL, HFILL } },
1268
1269         { &hf_zbee_zcl_color_control_attr_primary_3_x,
1270             { "X", "zbee_zcl_lighting.color_control.attr.primary_3_x", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_color_xy),
1271             0x00, NULL, HFILL } },
1272
1273         { &hf_zbee_zcl_color_control_attr_primary_3_y,
1274             { "Y", "zbee_zcl_lighting.color_control.attr.primary_3_y", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_color_xy),
1275             0x00, NULL, HFILL } },
1276
1277         { &hf_zbee_zcl_color_control_attr_primary_3_intensity,
1278             { "Intensity", "zbee_zcl_lighting.color_control.attr.primary_3_intensity", FT_UINT8, BASE_DEC, NULL,
1279             0x00, NULL, HFILL } },
1280
1281         { &hf_zbee_zcl_color_control_attr_primary_4_x,
1282             { "X", "zbee_zcl_lighting.color_control.attr.primary_4_x", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_color_xy),
1283             0x00, NULL, HFILL } },
1284
1285         { &hf_zbee_zcl_color_control_attr_primary_4_y,
1286             { "Y", "zbee_zcl_lighting.color_control.attr.primary_4_y", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_color_xy),
1287             0x00, NULL, HFILL } },
1288
1289         { &hf_zbee_zcl_color_control_attr_primary_4_intensity,
1290             { "Intensity", "zbee_zcl_lighting.color_control.attr.primary_4_intensity", FT_UINT8, BASE_DEC, NULL,
1291             0x00, NULL, HFILL } },
1292
1293         { &hf_zbee_zcl_color_control_attr_primary_5_x,
1294             { "X", "zbee_zcl_lighting.color_control.attr.primary_5_x", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_color_xy),
1295             0x00, NULL, HFILL } },
1296
1297         { &hf_zbee_zcl_color_control_attr_primary_5_y,
1298             { "Y", "zbee_zcl_lighting.color_control.attr.primary_5_y", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_color_xy),
1299             0x00, NULL, HFILL } },
1300
1301         { &hf_zbee_zcl_color_control_attr_primary_5_intensity,
1302             { "Intensity", "zbee_zcl_lighting.color_control.attr.primary_5_intensity", FT_UINT8, BASE_DEC, NULL,
1303             0x00, NULL, HFILL } },
1304
1305         { &hf_zbee_zcl_color_control_attr_primary_6_x,
1306             { "X", "zbee_zcl_lighting.color_control.attr.primary_6_x", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_color_xy),
1307             0x00, NULL, HFILL } },
1308
1309         { &hf_zbee_zcl_color_control_attr_primary_6_y,
1310             { "Y", "zbee_zcl_lighting.color_control.attr.primary_6_y", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_color_xy),
1311             0x00, NULL, HFILL } },
1312
1313         { &hf_zbee_zcl_color_control_attr_primary_6_intensity,
1314             { "Intensity", "zbee_zcl_lighting.color_control.attr.primary_6_intensity", FT_UINT8, BASE_DEC, NULL,
1315             0x00, NULL, HFILL } },
1316
1317         { &hf_zbee_zcl_color_control_attr_white_point_x,
1318             { "X", "zbee_zcl_lighting.color_control.attr.white_point_x", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_color_xy),
1319             0x00, NULL, HFILL } },
1320
1321         { &hf_zbee_zcl_color_control_attr_white_point_y,
1322             { "Y", "zbee_zcl_lighting.color_control.attr.white_point_y", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_color_xy),
1323             0x00, NULL, HFILL } },
1324
1325         { &hf_zbee_zcl_color_control_attr_red_x,
1326             { "X", "zbee_zcl_lighting.color_control.attr.red_x", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_color_xy),
1327             0x00, NULL, HFILL } },
1328
1329         { &hf_zbee_zcl_color_control_attr_red_y,
1330             { "Y", "zbee_zcl_lighting.color_control.attr.red_y", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_color_xy),
1331             0x00, NULL, HFILL } },
1332
1333         { &hf_zbee_zcl_color_control_attr_red_intensity,
1334             { "Intensity", "zbee_zcl_lighting.color_control.attr.red_intensity", FT_UINT8, BASE_DEC, NULL,
1335             0x00, NULL, HFILL } },
1336
1337         { &hf_zbee_zcl_color_control_attr_green_x,
1338             { "X", "zbee_zcl_lighting.color_control.attr.green_x", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_color_xy),
1339             0x00, NULL, HFILL } },
1340
1341         { &hf_zbee_zcl_color_control_attr_green_y,
1342             { "Y", "zbee_zcl_lighting.color_control.attr.green_y", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_color_xy),
1343             0x00, NULL, HFILL } },
1344
1345         { &hf_zbee_zcl_color_control_attr_green_intensity,
1346             { "Intensity", "zbee_zcl_lighting.color_control.attr.green_intensity", FT_UINT8, BASE_DEC, NULL,
1347             0x00, NULL, HFILL } },
1348
1349         { &hf_zbee_zcl_color_control_attr_blue_x,
1350             { "X", "zbee_zcl_lighting.color_control.attr.blue_x", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_color_xy),
1351             0x00, NULL, HFILL } },
1352
1353         { &hf_zbee_zcl_color_control_attr_blue_y,
1354             { "Y", "zbee_zcl_lighting.color_control.attr.blue_y", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_color_xy),
1355             0x00, NULL, HFILL } },
1356
1357         { &hf_zbee_zcl_color_control_attr_blue_intensity,
1358             { "Intensity", "zbee_zcl_lighting.color_control.attr.blue_intensity", FT_UINT8, BASE_DEC, NULL,
1359             0x00, NULL, HFILL } },
1360
1361         { &hf_zbee_zcl_color_control_attr_enhanced_current_hue,
1362             { "Enhanced Hue", "zbee_zcl_lighting.color_control.attr.enhanced_current_hue", FT_UINT16, BASE_DEC, NULL,
1363             0x00, NULL, HFILL } },
1364
1365         { &hf_zbee_zcl_color_control_attr_enhanced_color_mode,
1366             { "Enhanced Color Mode", "zbee_zcl_lighting.color_control.attr.enhanced_color_mode", FT_UINT8, BASE_DEC, VALS(zbee_zcl_color_control_color_mode_values),
1367             0x00, NULL, HFILL } },
1368
1369         { &hf_zbee_zcl_color_control_attr_color_loop_active,
1370             { "Active", "zbee_zcl_lighting.color_control.attr.color_loop_active", FT_BOOLEAN, 8, TFS(&tfs_true_false),
1371                 0x00, NULL, HFILL } },
1372
1373         { &hf_zbee_zcl_color_control_attr_color_loop_direction,
1374             { "Direction", "zbee_zcl_lighting.color_control.attr.color_loop_direction", FT_UINT8, BASE_DEC, VALS(zbee_zcl_color_control_color_loop_direction_values),
1375             0x00, NULL, HFILL } },
1376
1377         { &hf_zbee_zcl_color_control_attr_color_loop_time,
1378             { "Time", "zbee_zcl_lighting.color_control.attr.color_loop_time", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_zcl_time_in_seconds),
1379             0x00, NULL, HFILL } },
1380
1381         { &hf_zbee_zcl_color_control_attr_color_loop_start_enhanced_hue,
1382             { "Enhanced Hue", "zbee_zcl_lighting.color_control.attr.color_loop_start_enhanced_hue", FT_UINT16, BASE_DEC, NULL,
1383             0x00, NULL, HFILL } },
1384
1385         { &hf_zbee_zcl_color_control_attr_color_loop_stored_enhanced_hue,
1386             { "Enhanced Hue", "zbee_zcl_lighting.color_control.attr.color_loop_stored_enhanced_hue", FT_UINT16, BASE_DEC, NULL,
1387             0x00, NULL, HFILL } },
1388
1389         { &hf_zbee_zcl_color_control_attr_color_capabilities,
1390             { "Capabilities", "zbee_zcl_lighting.color_control.attr.color_capabilities", FT_UINT16, BASE_HEX, NULL,
1391             0x00, NULL, HFILL } },
1392
1393         { &hf_zbee_zcl_color_control_attr_color_capabilities_hs,
1394             { "Support Hue and Saturation", "zbee_zcl_lighting.color_control.attr.color_capabilities.hue_saturation", FT_UINT16, BASE_DEC, NULL,
1395                 ZBEE_ZCL_COLOR_CAPABILITIES_SUPPORT_HS_MASK, NULL, HFILL } },
1396
1397         { &hf_zbee_zcl_color_control_attr_color_capabilities_ehs,
1398             { "Support Enhanced Hue and Saturation", "zbee_zcl_lighting.color_control.attr.color_capabilities.enhanced_hue_saturation", FT_UINT16, BASE_DEC, NULL,
1399                 ZBEE_ZCL_COLOR_CAPABILITIES_SUPPORT_EHS_MASK, NULL, HFILL } },
1400
1401         { &hf_zbee_zcl_color_control_attr_color_capabilities_loop,
1402             { "Support Color Loop", "zbee_zcl_lighting.color_control.attr.color_capabilities.color_loop", FT_UINT16, BASE_DEC, NULL,
1403                 ZBEE_ZCL_COLOR_CAPABILITIES_SUPPORT_LOOP_MASK, NULL, HFILL } },
1404
1405         { &hf_zbee_zcl_color_control_attr_color_capabilities_xy,
1406             { "Support Color XY", "zbee_zcl_lighting.color_control.attr.color_capabilities.color_xy", FT_UINT16, BASE_DEC, NULL,
1407                 ZBEE_ZCL_COLOR_CAPABILITIES_SUPPORT_XY_MASK, NULL, HFILL } },
1408
1409         { &hf_zbee_zcl_color_control_attr_color_capabilities_ct,
1410             { "Support Color Temperature", "zbee_zcl_lighting.color_control.attr.color_capabilities.color_temperature", FT_UINT16, BASE_DEC, NULL,
1411                 ZBEE_ZCL_COLOR_CAPABILITIES_SUPPORT_CT_MASK, NULL, HFILL } },
1412
1413         { &hf_zbee_zcl_color_control_attr_color_temperature_phys_min,
1414             { "Color Temperature", "zbee_zcl_lighting.color_control.attr.color_temperature_physical_min", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_color_temperature),
1415             0x00, NULL, HFILL } },
1416
1417         { &hf_zbee_zcl_color_control_attr_color_temperature_phys_max,
1418             { "Color Temperature", "zbee_zcl_lighting.color_control.attr.color_temperature_physical_max", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_color_temperature),
1419             0x00, NULL, HFILL } },
1420
1421         { &hf_zbee_zcl_color_control_attr_startup_color_temperature,
1422             { "Startup Color Temparature", "zbee_zcl_lighting.color_control.attr.startup_color_temperature", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_startup_color_temperature),
1423             0x00, NULL, HFILL } },
1424
1425         { &hf_zbee_zcl_color_control_hue,
1426             { "Hue", "zbee_zcl_lighting.color_control.hue", FT_UINT8, BASE_DEC, NULL,
1427             0x00, NULL, HFILL } },
1428
1429         { &hf_zbee_zcl_color_control_direction,
1430             { "Direction", "zbee_zcl_lighting.color_control.direction", FT_UINT8, BASE_DEC, VALS(zbee_zcl_color_control_direction_values),
1431             0x00, NULL, HFILL } },
1432
1433         { &hf_zbee_zcl_color_control_transit_time,
1434             { "Transition Time", "zbee_zcl_lighting.color_control.transit_time", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_zcl_time_in_100ms),
1435             0x00, NULL, HFILL } },
1436
1437         { &hf_zbee_zcl_color_control_move_mode,
1438             { "Move Mode", "zbee_zcl_lighting.color_control.move_mode", FT_UINT8, BASE_DEC, VALS(zbee_zcl_color_control_move_mode),
1439             0x00, NULL, HFILL } },
1440
1441         { &hf_zbee_zcl_color_control_rate,
1442             { "Rate", "zbee_zcl_lighting.color_control.rate", FT_UINT8, BASE_DEC, NULL,
1443             0x00, NULL, HFILL }},
1444
1445         { &hf_zbee_zcl_color_control_step_mode,
1446             { "Step Mode", "zbee_zcl_lighting.color_control.step_mode", FT_UINT8, BASE_DEC, VALS(zbee_zcl_color_control_step_mode),
1447             0x00, NULL, HFILL }},
1448
1449         { &hf_zbee_zcl_color_control_step_size,
1450             { "Step Size", "zbee_zcl_lighting.color_control.step_size", FT_UINT8, BASE_DEC, NULL,
1451             0x00, NULL, HFILL }},
1452
1453         { &hf_zbee_zcl_color_control_transit_time_8bit,
1454             { "Transition Time", "zbee_zcl_lighting.color_control.transition_time_8bit", FT_UINT8, BASE_CUSTOM, CF_FUNC(decode_zcl_time_in_100ms),
1455             0x00, NULL, HFILL }},
1456
1457         { &hf_zbee_zcl_color_control_saturation,
1458             { "Saturation", "zbee_zcl_lighting.color_control.saturation", FT_UINT8, BASE_DEC, NULL,
1459             0x00, NULL, HFILL }},
1460
1461         { &hf_zbee_zcl_color_control_color_X,
1462             { "Color X", "zbee_zcl_lighting.color_control.color_x", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_color_xy),
1463             0x00, NULL, HFILL }},
1464
1465         { &hf_zbee_zcl_color_control_color_Y,
1466             { "Color Y", "zbee_zcl_lighting.color_control.color_y", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_color_xy),
1467             0x00, NULL, HFILL }},
1468
1469         { &hf_zbee_zcl_color_control_rate_X,
1470             { "Rate X", "zbee_zcl_lighting.color_control.rate_x", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_color_xy),
1471             0x00, NULL, HFILL }},
1472
1473         { &hf_zbee_zcl_color_control_rate_Y,
1474             { "Rate Y", "zbee_zcl_lighting.color_control.rate_y", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_color_xy),
1475             0x00, NULL, HFILL }},
1476
1477         { &hf_zbee_zcl_color_control_step_X,
1478             { "Step X", "zbee_zcl_lighting.color_control.step_x", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_color_xy),
1479             0x00, NULL, HFILL }},
1480
1481         { &hf_zbee_zcl_color_control_step_Y,
1482             { "Step Y", "zbee_zcl_lighting.color_control.step_y", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_color_xy),
1483             0x00, NULL, HFILL }},
1484
1485         { &hf_zbee_zcl_color_control_color_temp,
1486             { "Color temperature", "zbee_zcl_lighting.color_control.color_temp", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_color_temperature),
1487             0x00, NULL, HFILL }},
1488
1489         { &hf_zbee_zcl_color_control_enhanced_hue,
1490             { "Enhanced Hue", "zbee_zcl_lighting.color_control.enhanced_hue", FT_UINT16, BASE_DEC, NULL,
1491             0x00, NULL, HFILL } },
1492
1493         { &hf_zbee_zcl_color_control_enhanced_rate,
1494             { "Enhanced Rate", "zbee_zcl_lighting.color_control.enhanced_rate", FT_UINT16, BASE_DEC, NULL,
1495             0x00, NULL, HFILL }},
1496
1497         { &hf_zbee_zcl_color_control_enhanced_step_size,
1498             { "Enhanced Step Size", "zbee_zcl_lighting.color_control.enhanced_step_size", FT_UINT16, BASE_DEC, NULL,
1499             0x00, NULL, HFILL }},
1500
1501         { &hf_zbee_zcl_color_control_color_loop_update_flags,
1502             { "Update Flags", "zbee_zcl_lighting.color_control.color_loop_update", FT_UINT8, BASE_HEX, NULL,
1503             0x00, NULL, HFILL } },
1504
1505         { &hf_zbee_zcl_color_control_color_loop_update_action,
1506             { "Update Action", "zbee_zcl_lighting.color_control.color_loop_update.action", FT_UINT8, BASE_DEC, NULL,
1507             ZBEE_ZCL_COLOR_LOOP_UPDATE_ACTION_MASK, NULL, HFILL } },
1508
1509         { &hf_zbee_zcl_color_control_color_loop_update_direction,
1510             { "Update Direction", "zbee_zcl_lighting.color_control.color_loop_update.direction", FT_UINT8, BASE_DEC, NULL,
1511             ZBEE_ZCL_COLOR_LOOP_UPDATE_DIRECTION_MASK, NULL, HFILL } },
1512
1513         { &hf_zbee_zcl_color_control_color_loop_update_time,
1514             { "Update Time", "zbee_zcl_lighting.color_control.color_loop_update.time", FT_UINT8, BASE_DEC, NULL,
1515             ZBEE_ZCL_COLOR_LOOP_UPDATE_TIME_MASK, NULL, HFILL } },
1516
1517         { &hf_zbee_zcl_color_control_color_loop_update_start_hue,
1518             { "Update Start Hue", "zbee_zcl_lighting.color_control.color_loop_update.start_hue", FT_UINT8, BASE_DEC, NULL,
1519             ZBEE_ZCL_COLOR_LOOP_UPDATE_START_HUE_MASK, NULL, HFILL } },
1520
1521         { &hf_zbee_zcl_color_control_color_loop_action,
1522             { "Action", "zbee_zcl_lighting.color_control.color_loop_action", FT_UINT8, BASE_DEC, VALS(zbee_zcl_color_control_action),
1523             0x00, NULL, HFILL }},
1524
1525         { &hf_zbee_zcl_color_control_color_loop_direction,
1526             { "Direction", "zbee_zcl_lighting.color_control.color_loop_direction", FT_UINT8, BASE_DEC, VALS(zbee_zcl_color_control_color_loop_direction_values),
1527             0x00, NULL, HFILL }},
1528
1529         { &hf_zbee_zcl_color_control_color_loop_time,
1530             { "Time", "zbee_zcl_lighting.color_control.color_loop_time", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_zcl_time_in_seconds),
1531             0x00, NULL, HFILL } },
1532
1533         { &hf_zbee_zcl_color_control_color_loop_start_hue,
1534             { "Enhanced Hue", "zbee_zcl_lighting.color_control.color_loop_start_hue", FT_UINT16, BASE_DEC, NULL,
1535             0x00, NULL, HFILL } },
1536
1537         { &hf_zbee_zcl_color_control_color_temp_min,
1538             { "Color Temperature Minimum Mired", "zbee_zcl_lighting.color_control.color_temp_min", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_color_temperature),
1539             0x00, NULL, HFILL }},
1540
1541         { &hf_zbee_zcl_color_control_color_temp_max,
1542             { "Color Temperature Maximum Mired", "zbee_zcl_lighting.color_control.color_temp_max", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_color_temperature),
1543             0x00, NULL, HFILL }},
1544
1545         { &hf_zbee_zcl_color_control_srv_rx_cmd_id,
1546           { "Command", "zbee_zcl_lighting.color_control.cmd.srv_rx.id", FT_UINT8, BASE_HEX, VALS(zbee_zcl_color_control_srv_rx_cmd_names),
1547             0x00, NULL, HFILL } }
1548     };
1549
1550     /* ZCL Color Control subtrees */
1551     static gint *ett[ZBEE_ZCL_COLOR_CONTROL_NUM_ETT];
1552     ett[0] = &ett_zbee_zcl_color_control;
1553     ett[1] = &ett_zbee_zcl_color_control_color_capabilities;
1554     ett[2] = &ett_zbee_zcl_color_control_color_loop_settings;
1555
1556     /* Register the ZigBee ZCL Color Control cluster protocol name and description */
1557     proto_zbee_zcl_color_control = proto_register_protocol("ZigBee ZCL Color Control", "ZCL Color Control", ZBEE_PROTOABBREV_ZCL_COLOR_CONTROL);
1558     proto_register_field_array(proto_zbee_zcl_color_control, hf, array_length(hf));
1559     proto_register_subtree_array(ett, array_length(ett));
1560
1561     /* Register the ZigBee ZCL Color Control dissector. */
1562     register_dissector(ZBEE_PROTOABBREV_ZCL_COLOR_CONTROL, dissect_zbee_zcl_color_control, proto_zbee_zcl_color_control);
1563
1564 } /*proto_register_zbee_zcl_color_control*/
1565
1566
1567 /**
1568  *Hands off the ZCL Color Control dissector.
1569  *
1570 */
1571 void
1572 proto_reg_handoff_zbee_zcl_color_control(void)
1573 {
1574     zbee_zcl_init_cluster(  ZBEE_PROTOABBREV_ZCL_COLOR_CONTROL,
1575                             proto_zbee_zcl_color_control,
1576                             ett_zbee_zcl_color_control,
1577                             ZBEE_ZCL_CID_COLOR_CONTROL,
1578                             ZBEE_MFG_CODE_NONE,
1579                             hf_zbee_zcl_color_control_attr_id,
1580                             hf_zbee_zcl_color_control_attr_id,
1581                             hf_zbee_zcl_color_control_srv_rx_cmd_id,
1582                             -1,
1583                             (zbee_zcl_fn_attr_data)dissect_zcl_color_control_attr_data
1584                          );
1585 } /*proto_reg_handoff_zbee_zcl_color_control*/
1586
1587
1588 /* ########################################################################## */
1589 /* #### (0x0300) BALLAST CONFIGURATION CLUSTER ############################## */
1590 /* ########################################################################## */
1591
1592 /*************************/
1593 /* Defines               */
1594 /*************************/
1595
1596 #define ZBEE_ZCL_BALLAST_CONFIGURATION_NUM_ETT                                    3
1597
1598 /*Attributes*/
1599 #define ZBEE_ZCL_ATTR_ID_BALLAST_CONFIGURATION_PHYSICAL_MIN_LEVEL                 0x0000  /* Physical Min Level */
1600 #define ZBEE_ZCL_ATTR_ID_BALLAST_CONFIGURATION_PHYSICAL_MAX_LEVEL                 0x0001  /* Physical Max Level */
1601 #define ZBEE_ZCL_ATTR_ID_BALLAST_CONFIGURATION_BALLAST_STATUS                     0x0002  /* Ballast Status */
1602 #define ZBEE_ZCL_ATTR_ID_BALLAST_CONFIGURATION_MIN_LEVEL                          0x0010  /* Min Level */
1603 #define ZBEE_ZCL_ATTR_ID_BALLAST_CONFIGURATION_MAX_LEVEL                          0x0011  /* Max Level */
1604 #define ZBEE_ZCL_ATTR_ID_BALLAST_CONFIGURATION_POWER_ON_LEVEL                     0x0012  /* Power On Level */
1605 #define ZBEE_ZCL_ATTR_ID_BALLAST_CONFIGURATION_POWER_ON_FADE_TIME                 0x0013  /* Power On Fade Time */
1606 #define ZBEE_ZCL_ATTR_ID_BALLAST_CONFIGURATION_INTRINSIC_BALLAST_FACTOR           0x0014  /* Intrinsic Ballast Factor */
1607 #define ZBEE_ZCL_ATTR_ID_BALLAST_CONFIGURATION_BALLAST_FACT_ADJ                   0x0015  /* Ballast Factor Adjustment */
1608 #define ZBEE_ZCL_ATTR_ID_BALLAST_CONFIGURATION_LAMP_QUANTITY                      0x0020  /* Lamp Quantity */
1609 #define ZBEE_ZCL_ATTR_ID_BALLAST_CONFIGURATION_LAMP_TYPE                          0x0030  /* Lamp Type */
1610 #define ZBEE_ZCL_ATTR_ID_BALLAST_CONFIGURATION_LAMP_MANUFACTURER                  0x0031  /* Lamp Manufacturer */
1611 #define ZBEE_ZCL_ATTR_ID_BALLAST_CONFIGURATION_LAMP_RATED_HOURS                   0x0032  /* Lamp Rated Hours */
1612 #define ZBEE_ZCL_ATTR_ID_BALLAST_CONFIGURATION_LAMP_BURN_HOURS                    0x0033  /* Lamp Burn Hours */
1613 #define ZBEE_ZCL_ATTR_ID_BALLAST_CONFIGURATION_LAMP_ALARM_MODE                    0x0034  /* Lamp Alarm Mode */
1614 #define ZBEE_ZCL_ATTR_ID_BALLAST_CONFIGURATION_LAMP_BURN_HOURS_TRIP_POINT         0x0035  /* Lamp Burn Hours Trip Point */
1615
1616 /*Server commands received - none*/
1617
1618 /*Server commands generated - none*/
1619
1620 /*Ballast Status Mask Values*/
1621 #define ZBEE_ZCL_BALLAST_CONFIGURATION_STATUS_NON_OPERATIONAL                     0x01    /* Non-operational */
1622 #define ZBEE_ZCL_BALLAST_CONFIGURATION_STATUS_LAMP_NOT_IN_SOCKET                  0x02    /* Lamp Not in Socket */
1623
1624 /*Lamp Alarm Mode Mask Value*/
1625 #define ZBEE_ZCL_BALLAST_CONFIGURATION_LAMP_ALARM_MODE_LAMP_BURN_HOURS            0x01    /* Lamp Burn Hours */
1626
1627 /*************************/
1628 /* Function Declarations */
1629 /*************************/
1630
1631 void proto_register_zbee_zcl_ballast_configuration(void);
1632 void proto_reg_handoff_zbee_zcl_ballast_configuration(void);
1633
1634 /* Command Dissector Helpers */
1635 static void dissect_zcl_ballast_configuration_attr_data      (proto_tree *tree, tvbuff_t *tvb, guint *offset, guint16 attr_id, guint data_type, gboolean client_attr);
1636
1637 /* Private functions prototype */
1638
1639 /*************************/
1640 /* Global Variables      */
1641 /*************************/
1642 /* Initialize the protocol and registered fields */
1643 static int proto_zbee_zcl_ballast_configuration = -1;
1644
1645 static int hf_zbee_zcl_ballast_configuration_attr_id = -1;
1646 static int hf_zbee_zcl_ballast_configuration_status = -1;
1647 static int hf_zbee_zcl_ballast_configuration_status_non_operational = -1;
1648 static int hf_zbee_zcl_ballast_configuration_status_lamp_not_in_socket = -1;
1649 static int hf_zbee_zcl_ballast_configuration_lamp_alarm_mode = -1;
1650 static int hf_zbee_zcl_ballast_configuration_lamp_alarm_mode_lamp_burn_hours = -1;
1651
1652 /* Initialize the subtree pointers */
1653 static gint ett_zbee_zcl_ballast_configuration = -1;
1654 static gint ett_zbee_zcl_ballast_configuration_status = -1;
1655 static gint ett_zbee_zcl_ballast_configuration_lamp_alarm_mode = -1;
1656
1657 /* Attributes */
1658 static const value_string zbee_zcl_ballast_configuration_attr_names[] = {
1659     { ZBEE_ZCL_ATTR_ID_BALLAST_CONFIGURATION_PHYSICAL_MIN_LEVEL,                "Physical Min Level" },
1660     { ZBEE_ZCL_ATTR_ID_BALLAST_CONFIGURATION_PHYSICAL_MAX_LEVEL,                "Physical Max Level" },
1661     { ZBEE_ZCL_ATTR_ID_BALLAST_CONFIGURATION_BALLAST_STATUS,                    "Ballast Status" },
1662     { ZBEE_ZCL_ATTR_ID_BALLAST_CONFIGURATION_MIN_LEVEL,                         "Min Level" },
1663     { ZBEE_ZCL_ATTR_ID_BALLAST_CONFIGURATION_MAX_LEVEL,                         "Max Level" },
1664     { ZBEE_ZCL_ATTR_ID_BALLAST_CONFIGURATION_POWER_ON_LEVEL,                    "Power On Level" },
1665     { ZBEE_ZCL_ATTR_ID_BALLAST_CONFIGURATION_POWER_ON_FADE_TIME,                "Power On Fade Time" },
1666     { ZBEE_ZCL_ATTR_ID_BALLAST_CONFIGURATION_INTRINSIC_BALLAST_FACTOR,          "Intrinsic Ballast Factor" },
1667     { ZBEE_ZCL_ATTR_ID_BALLAST_CONFIGURATION_BALLAST_FACT_ADJ,                  "Ballast Factor Adjustment" },
1668     { ZBEE_ZCL_ATTR_ID_BALLAST_CONFIGURATION_LAMP_QUANTITY,                     "Lamp Quantity" },
1669     { ZBEE_ZCL_ATTR_ID_BALLAST_CONFIGURATION_LAMP_TYPE,                         "Lamp Type" },
1670     { ZBEE_ZCL_ATTR_ID_BALLAST_CONFIGURATION_LAMP_MANUFACTURER,                 "Lamp Manufacturer" },
1671     { ZBEE_ZCL_ATTR_ID_BALLAST_CONFIGURATION_LAMP_RATED_HOURS,                  "Lamp Rated Hours" },
1672     { ZBEE_ZCL_ATTR_ID_BALLAST_CONFIGURATION_LAMP_BURN_HOURS,                   "Lamp Burn Hours" },
1673     { ZBEE_ZCL_ATTR_ID_BALLAST_CONFIGURATION_LAMP_ALARM_MODE,                   "Lamp Alarm Mode" },
1674     { ZBEE_ZCL_ATTR_ID_BALLAST_CONFIGURATION_LAMP_BURN_HOURS_TRIP_POINT,        "Lamp Burn Hours Trip Point" },
1675     { 0, NULL }
1676 };
1677
1678 /*Non-operational Values*/
1679 static const value_string zbee_zcl_ballast_configuration_status_non_operational_names[] = {
1680     {0, "Fully Operational"},
1681     {1, "Not Fully Operational"},
1682     {0, NULL}
1683 };
1684
1685 /*Not in Socket Values*/
1686 static const value_string zbee_zcl_ballast_configuration_status_lamp_not_in_socket_names[] = {
1687     {0, "All lamps in Socket"},
1688     {1, "Atleast one lamp not in Socket"},
1689     {0, NULL}
1690 };
1691
1692
1693 /*************************/
1694 /* Function Bodies       */
1695 /*************************/
1696
1697 /**
1698  *ZigBee ZCL Ballast Configuration cluster dissector for wireshark.
1699  *
1700  *@param tvb pointer to buffer containing raw packet.
1701  *@param pinfo pointer to packet information fields
1702  *@param tree pointer to data tree Wireshark uses to display packet.
1703 */
1704
1705 static int
1706 dissect_zbee_zcl_ballast_configuration(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void* data _U_)
1707 {
1708     return tvb_captured_length(tvb);
1709 } /*dissect_zbee_zcl_ballast_configuration*/
1710
1711
1712 /**
1713  *This function is called by ZCL foundation dissector in order to decode
1714  *
1715  *@param tree pointer to data tree Wireshark uses to display packet.
1716  *@param tvb pointer to buffer containing raw packet.
1717  *@param offset pointer to buffer offset
1718  *@param attr_id attribute identifier
1719  *@param data_type attribute data type
1720  *@param client_attr ZCL client
1721 */
1722 void
1723 dissect_zcl_ballast_configuration_attr_data(proto_tree *tree, tvbuff_t *tvb, guint *offset, guint16 attr_id, guint data_type, gboolean client_attr)
1724 {
1725     static const int * ballast_status[] = {
1726         &hf_zbee_zcl_ballast_configuration_status_non_operational,
1727         &hf_zbee_zcl_ballast_configuration_status_lamp_not_in_socket,
1728         NULL
1729     };
1730
1731     static const int * lamp_alarm_mode[] = {
1732         &hf_zbee_zcl_ballast_configuration_lamp_alarm_mode_lamp_burn_hours,
1733         NULL
1734     };
1735
1736     /* Dissect attribute data type and data */
1737     switch (attr_id) {
1738
1739         case ZBEE_ZCL_ATTR_ID_BALLAST_CONFIGURATION_BALLAST_STATUS:
1740             proto_tree_add_bitmask(tree, tvb, *offset, hf_zbee_zcl_ballast_configuration_status, ett_zbee_zcl_ballast_configuration_status, ballast_status, ENC_LITTLE_ENDIAN);
1741             *offset += 1;
1742             break;
1743
1744         case ZBEE_ZCL_ATTR_ID_BALLAST_CONFIGURATION_LAMP_ALARM_MODE:
1745             proto_tree_add_bitmask(tree, tvb, *offset, hf_zbee_zcl_ballast_configuration_lamp_alarm_mode, ett_zbee_zcl_ballast_configuration_lamp_alarm_mode, lamp_alarm_mode, ENC_LITTLE_ENDIAN);
1746             *offset += 1;
1747             break;
1748
1749         case ZBEE_ZCL_ATTR_ID_BALLAST_CONFIGURATION_PHYSICAL_MIN_LEVEL:
1750         case ZBEE_ZCL_ATTR_ID_BALLAST_CONFIGURATION_PHYSICAL_MAX_LEVEL:
1751         case ZBEE_ZCL_ATTR_ID_BALLAST_CONFIGURATION_MIN_LEVEL:
1752         case ZBEE_ZCL_ATTR_ID_BALLAST_CONFIGURATION_MAX_LEVEL:
1753         case ZBEE_ZCL_ATTR_ID_BALLAST_CONFIGURATION_POWER_ON_LEVEL:
1754         case ZBEE_ZCL_ATTR_ID_BALLAST_CONFIGURATION_POWER_ON_FADE_TIME:
1755         case ZBEE_ZCL_ATTR_ID_BALLAST_CONFIGURATION_INTRINSIC_BALLAST_FACTOR:
1756         case ZBEE_ZCL_ATTR_ID_BALLAST_CONFIGURATION_BALLAST_FACT_ADJ:
1757         case ZBEE_ZCL_ATTR_ID_BALLAST_CONFIGURATION_LAMP_QUANTITY:
1758         case ZBEE_ZCL_ATTR_ID_BALLAST_CONFIGURATION_LAMP_TYPE:
1759         case ZBEE_ZCL_ATTR_ID_BALLAST_CONFIGURATION_LAMP_MANUFACTURER:
1760         case ZBEE_ZCL_ATTR_ID_BALLAST_CONFIGURATION_LAMP_RATED_HOURS:
1761         case ZBEE_ZCL_ATTR_ID_BALLAST_CONFIGURATION_LAMP_BURN_HOURS:
1762         case ZBEE_ZCL_ATTR_ID_BALLAST_CONFIGURATION_LAMP_BURN_HOURS_TRIP_POINT:
1763         default:
1764             dissect_zcl_attr_data(tvb, tree, offset, data_type, client_attr);
1765             break;
1766     }
1767
1768 } /*dissect_zcl_ballast_configuration_attr_data*/
1769
1770
1771 /**
1772  *ZigBee ZCL Ballast Configuration cluster protocol registration routine.
1773  *
1774 */
1775 void
1776 proto_register_zbee_zcl_ballast_configuration(void)
1777 {
1778     /* Setup list of header fields */
1779     static hf_register_info hf[] = {
1780
1781         { &hf_zbee_zcl_ballast_configuration_attr_id,
1782             { "Attribute", "zbee_zcl_lighting.ballast_configuration.attr_id", FT_UINT16, BASE_HEX, VALS(zbee_zcl_ballast_configuration_attr_names),
1783             0x00, NULL, HFILL } },
1784
1785         /* start Ballast Status fields */
1786         { &hf_zbee_zcl_ballast_configuration_status,
1787             { "Status", "zbee_zcl_lighting.ballast_configuration.attr.status", FT_UINT8, BASE_HEX, NULL,
1788             0x00, NULL, HFILL } },
1789
1790         { &hf_zbee_zcl_ballast_configuration_status_non_operational,
1791             { "Non-operational", "zbee_zcl_lighting.ballast_configuration.attr.status.non_operational", FT_UINT8, BASE_HEX, VALS(zbee_zcl_ballast_configuration_status_non_operational_names),
1792             ZBEE_ZCL_BALLAST_CONFIGURATION_STATUS_NON_OPERATIONAL, NULL, HFILL } },
1793
1794         { &hf_zbee_zcl_ballast_configuration_status_lamp_not_in_socket,
1795             { "Not in Socket", "zbee_zcl_lighting.ballast_configuration.attr.status.not_in_socket", FT_UINT8, BASE_HEX, VALS(zbee_zcl_ballast_configuration_status_lamp_not_in_socket_names),
1796             ZBEE_ZCL_BALLAST_CONFIGURATION_STATUS_LAMP_NOT_IN_SOCKET, NULL, HFILL } },
1797         /* end Ballast Status fields */
1798
1799         /*stat Lamp Alarm Mode fields*/
1800         { &hf_zbee_zcl_ballast_configuration_lamp_alarm_mode,
1801             { "Lamp Alarm Mode", "zbee_zcl_lighting.ballast_configuration.attr.lamp_alarm_mode", FT_UINT8, BASE_HEX, NULL,
1802             0x00, NULL, HFILL } },
1803
1804         { &hf_zbee_zcl_ballast_configuration_lamp_alarm_mode_lamp_burn_hours,
1805             { "Lamp Burn Hours", "zbee_zcl_lighting.ballast_configuration.attr.lamp_alarm_mode.lamp_burn_hours", FT_BOOLEAN, 8, NULL,
1806             ZBEE_ZCL_BALLAST_CONFIGURATION_LAMP_ALARM_MODE_LAMP_BURN_HOURS, NULL, HFILL } }
1807         /* end Lamp Alarm Mode fields */
1808     };
1809
1810     /* ZCL Ballast Configuration subtrees */
1811     static gint *ett[ZBEE_ZCL_BALLAST_CONFIGURATION_NUM_ETT];
1812
1813     ett[0] = &ett_zbee_zcl_ballast_configuration;
1814     ett[1] = &ett_zbee_zcl_ballast_configuration_status;
1815     ett[2] = &ett_zbee_zcl_ballast_configuration_lamp_alarm_mode;
1816
1817     /* Register the ZigBee ZCL Ballast Configuration cluster protocol name and description */
1818     proto_zbee_zcl_ballast_configuration = proto_register_protocol("ZigBee ZCL Ballast Configuration", "ZCL Ballast Configuration", ZBEE_PROTOABBREV_ZCL_BALLAST_CONFIG);
1819     proto_register_field_array(proto_zbee_zcl_ballast_configuration, hf, array_length(hf));
1820     proto_register_subtree_array(ett, array_length(ett));
1821
1822     /* Register the ZigBee ZCL Ballast Configuration dissector. */
1823     register_dissector(ZBEE_PROTOABBREV_ZCL_BALLAST_CONFIG, dissect_zbee_zcl_ballast_configuration, proto_zbee_zcl_ballast_configuration);
1824 } /*proto_register_zbee_zcl_ballast_configuration*/
1825
1826 /**
1827  *Hands off the ZCL Ballast Configuration dissector.
1828  *
1829 */
1830 void
1831 proto_reg_handoff_zbee_zcl_ballast_configuration(void)
1832 {
1833     zbee_zcl_init_cluster(  ZBEE_PROTOABBREV_ZCL_BALLAST_CONFIG,
1834                             proto_zbee_zcl_ballast_configuration,
1835                             ett_zbee_zcl_ballast_configuration,
1836                             ZBEE_ZCL_CID_BALLAST_CONFIG,
1837                             ZBEE_MFG_CODE_NONE,
1838                             hf_zbee_zcl_ballast_configuration_attr_id,
1839                             hf_zbee_zcl_ballast_configuration_attr_id,
1840                             -1, -1,
1841                             (zbee_zcl_fn_attr_data)dissect_zcl_ballast_configuration_attr_data
1842                          );
1843 } /*proto_reg_handoff_zbee_zcl_ballast_configuration*/
1844
1845 /*
1846  * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
1847  *
1848  * Local variables:
1849  * c-basic-offset: 4
1850  * tab-width: 8
1851  * indent-tabs-mode: nil
1852  * End:
1853  *
1854  * vi: set shiftwidth=4 tabstop=8 expandtab:
1855  * :indentSize=4:tabSize=8:noTabs=true:
1856  */