Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-zbee-zcl-closures.c
blobc4b9b881e06ce1206eae9b0ea4fe42f9081e8bff
1 /* packet-zbee-zcl-closures.c
2 * Dissector routines for the ZigBee ZCL Closures clusters
3 * Shade configuration, Door Lock
4 * By <aditya.jain@samsung.com>
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * SPDX-License-Identifier: GPL-2.0-or-later
13 /* Include Files */
14 #include "config.h"
16 #include <epan/packet.h>
17 #include <epan/tfs.h>
18 #include <wsutil/array.h>
20 #include "packet-zbee.h"
21 #include "packet-zbee-aps.h"
22 #include "packet-zbee-zcl.h"
25 /* ########################################################################## */
26 /* #### (0x0100) SHADE CONFIGURATION CLUSTER ################################ */
27 /* ########################################################################## */
29 /*************************/
30 /* Defines */
31 /*************************/
33 /*Attributes*/
34 #define ZBEE_ZCL_ATTR_ID_SHADE_CONFIGURATION_PHYSICAL_CLOSED_LIMIT 0x0000 /* Physical Closed Limit */
35 #define ZBEE_ZCL_ATTR_ID_SHADE_CONFIGURATION_MOTOR_STEP_SIZE 0x0001 /* Motor Step Size */
36 #define ZBEE_ZCL_ATTR_ID_SHADE_CONFIGURATION_STATUS 0x0002 /* Status */
37 #define ZBEE_ZCL_ATTR_ID_SHADE_CONFIGURATION_CLOSED_LIMIT 0x0010 /* Closed Limit */
38 #define ZBEE_ZCL_ATTR_ID_SHADE_CONFIGURATION_MODE 0x0011 /* Mode */
40 /*Server commands received - none*/
42 /*Server commands generated - none*/
44 /*Status Mask Value*/
45 #define ZBEE_ZCL_SHADE_CONFIGURATION_STATUS_SHADE_OPERATIONAL 0x01 /* Shade Operational */
46 #define ZBEE_ZCL_SHADE_CONFIGURATION_STATUS_SHADE_ADJUSTING 0x02 /* Shade Adjusting */
47 #define ZBEE_ZCL_SHADE_CONFIGURATION_STATUS_SHADE_DIRECTION 0x04 /* Shade Direction */
48 #define ZBEE_ZCL_SHADE_CONFIGURATION_STATUS_MOTOR_FORWARD_DIRECTION 0x08 /* Motor Forward Direction */
50 /*************************/
51 /* Function Declarations */
52 /*************************/
54 void proto_register_zbee_zcl_shade_configuration(void);
55 void proto_reg_handoff_zbee_zcl_shade_configuration(void);
57 /* Command Dissector Helpers */
58 static void dissect_zcl_shade_configuration_attr_data (proto_tree *tree, tvbuff_t *tvb, unsigned *offset, uint16_t attr_id, unsigned data_type, bool client_attr);
60 /* Private functions prototype */
62 /*************************/
63 /* Global Variables */
64 /*************************/
65 /* Initialize the protocol and registered fields */
66 static int proto_zbee_zcl_shade_configuration;
68 static int hf_zbee_zcl_shade_configuration_attr_id;
69 static int hf_zbee_zcl_shade_configuration_status;
70 static int hf_zbee_zcl_shade_configuration_status_shade_operational;
71 static int hf_zbee_zcl_shade_configuration_status_shade_adjusting;
72 static int hf_zbee_zcl_shade_configuration_status_shade_direction;
73 static int hf_zbee_zcl_shade_configuration_status_motor_forward_direction;
74 static int hf_zbee_zcl_shade_configuration_mode;
76 /* Initialize the subtree pointers */
77 static int ett_zbee_zcl_shade_configuration;
78 static int ett_zbee_zcl_shade_configuration_status;
80 /* Attributes */
81 static const value_string zbee_zcl_shade_configuration_attr_names[] = {
82 { ZBEE_ZCL_ATTR_ID_SHADE_CONFIGURATION_PHYSICAL_CLOSED_LIMIT, "Physical Closed Limit" },
83 { ZBEE_ZCL_ATTR_ID_SHADE_CONFIGURATION_MOTOR_STEP_SIZE, "Motor Step Size" },
84 { ZBEE_ZCL_ATTR_ID_SHADE_CONFIGURATION_STATUS, "Status" },
85 { ZBEE_ZCL_ATTR_ID_SHADE_CONFIGURATION_CLOSED_LIMIT, "Closed Limit" },
86 { ZBEE_ZCL_ATTR_ID_SHADE_CONFIGURATION_MODE, "Mode" },
87 { 0, NULL }
90 /*Shade and motor direction values*/
91 static const value_string zbee_zcl_shade_configuration_shade_motor_direction_names[] = {
92 {0, "Closing"},
93 {1, "Opening"},
94 {0, NULL}
97 /*Mode Values*/
98 static const value_string zbee_zcl_shade_configuration_mode_names[] = {
99 {0, "Normal"},
100 {1, "Configure"},
101 {0, NULL}
105 /*************************/
106 /* Function Bodies */
107 /*************************/
110 *ZigBee ZCL Shade Configuration cluster dissector for wireshark.
112 *@param tvb pointer to buffer containing raw packet.
113 *@param pinfo pointer to packet information fields
114 *@param tree pointer to data tree Wireshark uses to display packet.
117 static int
118 dissect_zbee_zcl_shade_configuration(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void* data _U_)
120 return tvb_captured_length(tvb);
121 } /*dissect_zbee_zcl_shade_configuration*/
125 *This function is called by ZCL foundation dissector in order to decode
127 *@param tree pointer to data tree Wireshark uses to display packet.
128 *@param tvb pointer to buffer containing raw packet.
129 *@param offset pointer to buffer offset
130 *@param attr_id attribute identifier
131 *@param data_type attribute data type
132 *@param client_attr ZCL client
134 void
135 dissect_zcl_shade_configuration_attr_data(proto_tree *tree, tvbuff_t *tvb, unsigned *offset, uint16_t attr_id, unsigned data_type, bool client_attr)
137 static int * const shade_config_status[] = {
138 &hf_zbee_zcl_shade_configuration_status_shade_operational,
139 &hf_zbee_zcl_shade_configuration_status_shade_adjusting,
140 &hf_zbee_zcl_shade_configuration_status_shade_direction,
141 &hf_zbee_zcl_shade_configuration_status_motor_forward_direction,
142 NULL
145 /* Dissect attribute data type and data */
146 switch (attr_id) {
148 case ZBEE_ZCL_ATTR_ID_SHADE_CONFIGURATION_STATUS:
149 proto_tree_add_bitmask(tree, tvb, *offset, hf_zbee_zcl_shade_configuration_status, ett_zbee_zcl_shade_configuration_status, shade_config_status, ENC_LITTLE_ENDIAN);
150 *offset += 1;
151 break;
153 case ZBEE_ZCL_ATTR_ID_SHADE_CONFIGURATION_MODE:
154 proto_tree_add_item(tree, hf_zbee_zcl_shade_configuration_mode, tvb, *offset, 1, ENC_NA);
155 *offset += 1;
156 break;
158 case ZBEE_ZCL_ATTR_ID_SHADE_CONFIGURATION_PHYSICAL_CLOSED_LIMIT:
159 case ZBEE_ZCL_ATTR_ID_SHADE_CONFIGURATION_MOTOR_STEP_SIZE:
160 case ZBEE_ZCL_ATTR_ID_SHADE_CONFIGURATION_CLOSED_LIMIT:
161 default:
162 dissect_zcl_attr_data(tvb, tree, offset, data_type, client_attr);
163 break;
166 } /*dissect_zcl_shade_configuration_attr_data*/
170 *ZigBee ZCL Shade Configuration cluster protocol registration routine.
173 void
174 proto_register_zbee_zcl_shade_configuration(void)
176 /* Setup list of header fields */
177 static hf_register_info hf[] = {
179 { &hf_zbee_zcl_shade_configuration_attr_id,
180 { "Attribute", "zbee_zcl_closures.shade_configuration.attr_id", FT_UINT16, BASE_HEX, VALS(zbee_zcl_shade_configuration_attr_names),
181 0x00, NULL, HFILL } },
183 /* start Shade Configuration Status fields */
184 { &hf_zbee_zcl_shade_configuration_status,
185 { "Shade Configuration Status", "zbee_zcl_closures.shade_configuration.attr.status", FT_UINT8, BASE_HEX, NULL,
186 0x00, NULL, HFILL } },
188 { &hf_zbee_zcl_shade_configuration_status_shade_operational,
189 { "Shade Operational", "zbee_zcl_closures.shade_configuration.attr.status.shade_operational", FT_BOOLEAN, 8, TFS(&tfs_no_yes),
190 ZBEE_ZCL_SHADE_CONFIGURATION_STATUS_SHADE_OPERATIONAL, NULL, HFILL } },
192 { &hf_zbee_zcl_shade_configuration_status_shade_adjusting,
193 { "Shade Adjusting", "zbee_zcl_closures.shade_configuration.attr.status.shade_adjusting", FT_BOOLEAN, 8, TFS(&tfs_no_yes),
194 ZBEE_ZCL_SHADE_CONFIGURATION_STATUS_SHADE_ADJUSTING, NULL, HFILL } },
196 { &hf_zbee_zcl_shade_configuration_status_shade_direction,
197 { "Shade Direction", "zbee_zcl_closures.shade_configuration.attr.status.shade_direction", FT_UINT8, BASE_DEC, VALS(zbee_zcl_shade_configuration_shade_motor_direction_names),
198 ZBEE_ZCL_SHADE_CONFIGURATION_STATUS_SHADE_DIRECTION, NULL, HFILL } },
200 { &hf_zbee_zcl_shade_configuration_status_motor_forward_direction,
201 { "Motor Forward Direction", "zbee_zcl_closures.shade_configuration.attr.status.motor_forward_direction", FT_UINT8, BASE_DEC, VALS(zbee_zcl_shade_configuration_shade_motor_direction_names),
202 ZBEE_ZCL_SHADE_CONFIGURATION_STATUS_MOTOR_FORWARD_DIRECTION, NULL, HFILL } },
203 /* end Shade Configuration Status fields */
205 { &hf_zbee_zcl_shade_configuration_mode,
206 { "Mode", "zbee_zcl_closures.shade_configuration.attr.mode", FT_UINT8, BASE_HEX, VALS(zbee_zcl_shade_configuration_mode_names),
207 0x00, NULL, HFILL } }
210 /* ZCL Shade Configuration subtrees */
211 static int *ett[] = {
212 &ett_zbee_zcl_shade_configuration,
213 &ett_zbee_zcl_shade_configuration_status
216 /* Register the ZigBee ZCL Shade Configuration cluster protocol name and description */
217 proto_zbee_zcl_shade_configuration = proto_register_protocol("ZigBee ZCL Shade Configuration", "ZCL Shade Configuration", ZBEE_PROTOABBREV_ZCL_SHADE_CONFIG);
218 proto_register_field_array(proto_zbee_zcl_shade_configuration, hf, array_length(hf));
219 proto_register_subtree_array(ett, array_length(ett));
221 /* Register the ZigBee ZCL Shade Configuration dissector. */
222 register_dissector(ZBEE_PROTOABBREV_ZCL_SHADE_CONFIG, dissect_zbee_zcl_shade_configuration, proto_zbee_zcl_shade_configuration);
223 } /*proto_register_zbee_zcl_shade_configuration*/
226 *Hands off the ZCL Shade Configuration dissector.
229 void
230 proto_reg_handoff_zbee_zcl_shade_configuration(void)
232 zbee_zcl_init_cluster( ZBEE_PROTOABBREV_ZCL_SHADE_CONFIG,
233 proto_zbee_zcl_shade_configuration,
234 ett_zbee_zcl_shade_configuration,
235 ZBEE_ZCL_CID_SHADE_CONFIG,
236 ZBEE_MFG_CODE_NONE,
237 hf_zbee_zcl_shade_configuration_attr_id,
238 hf_zbee_zcl_shade_configuration_attr_id,
239 -1, -1,
240 (zbee_zcl_fn_attr_data)dissect_zcl_shade_configuration_attr_data
242 } /*proto_reg_handoff_zbee_zcl_shade_configuration*/
245 /* ########################################################################## */
246 /* #### (0x0101) DOOR LOCK CLUSTER ########################################## */
247 /* ########################################################################## */
249 /*************************/
250 /* Defines */
251 /*************************/
253 /* Attributes */
254 #define ZBEE_ZCL_ATTR_ID_DOOR_LOCK_LOCK_STATE 0x0000 /* Lock State */
255 #define ZBEE_ZCL_ATTR_ID_DOOR_LOCK_LOCK_TYPE 0x0001 /* Lock Type */
256 #define ZBEE_ZCL_ATTR_ID_DOOR_LOCK_ACTUATOR_ENABLED 0x0002 /* Actuator Enabled */
257 #define ZBEE_ZCL_ATTR_ID_DOOR_LOCK_DOOR_STATE 0x0003 /* Door State */
258 #define ZBEE_ZCL_ATTR_ID_DOOR_LOCK_DOOR_OPEN_EVENTS 0x0004 /* Door Open Events */
259 #define ZBEE_ZCL_ATTR_ID_DOOR_LOCK_DOOR_CLOSED_EVENTS 0x0005 /* Door Closed Events */
260 #define ZBEE_ZCL_ATTR_ID_DOOR_LOCK_OPEN_PERIOD 0x0006 /* Open Period */
262 /* Server Commands Received */
263 #define ZBEE_ZCL_CMD_ID_DOOR_LOCK_LOCK_DOOR 0x00 /* Lock Door */
264 #define ZBEE_ZCL_CMD_ID_DOOR_LOCK_UNLOCK_DOOR 0x01 /* Unlock Door */
266 /* Server Commands Generated */
267 #define ZBEE_ZCL_CMD_ID_DOOR_LOCK_LOCK_DOOR_RESPONSE 0x00 /* Lock Door Response */
268 #define ZBEE_ZCL_CMD_ID_DOOR_LOCK_UNLOCK_DOOR_RESPONSE 0x01 /* Unlock Door Response */
271 /*************************/
272 /* Function Declarations */
273 /*************************/
275 void proto_register_zbee_zcl_door_lock(void);
276 void proto_reg_handoff_zbee_zcl_door_lock(void);
278 /* Command Dissector Helpers */
279 static void dissect_zcl_door_lock_lock_unlock_door_response (tvbuff_t *tvb, proto_tree *tree, unsigned *offset);
281 static void dissect_zcl_door_lock_attr_data (proto_tree *tree, tvbuff_t *tvb, unsigned *offset, uint16_t attr_id, unsigned data_type, bool client_attr);
283 /* Private functions prototype */
285 /*************************/
286 /* Global Variables */
287 /*************************/
288 /* Initialize the protocol and registered fields */
289 static int proto_zbee_zcl_door_lock;
291 static int hf_zbee_zcl_door_lock_attr_id;
292 static int hf_zbee_zcl_door_lock_lock_state;
293 static int hf_zbee_zcl_door_lock_lock_type;
294 static int hf_zbee_zcl_door_lock_door_state;
295 static int hf_zbee_zcl_door_lock_actuator_enabled;
296 static int hf_zbee_zcl_door_lock_status;
297 static int hf_zbee_zcl_door_lock_srv_rx_cmd_id;
298 static int hf_zbee_zcl_door_lock_srv_tx_cmd_id;
300 /* Initialize the subtree pointers */
301 static int ett_zbee_zcl_door_lock;
303 /* Attributes */
304 static const value_string zbee_zcl_door_lock_attr_names[] = {
305 { ZBEE_ZCL_ATTR_ID_DOOR_LOCK_LOCK_STATE, "Lock State" },
306 { ZBEE_ZCL_ATTR_ID_DOOR_LOCK_LOCK_TYPE, "Lock Type" },
307 { ZBEE_ZCL_ATTR_ID_DOOR_LOCK_ACTUATOR_ENABLED, "Actuator Enabled" },
308 { ZBEE_ZCL_ATTR_ID_DOOR_LOCK_DOOR_STATE, "Door State" },
309 { ZBEE_ZCL_ATTR_ID_DOOR_LOCK_DOOR_OPEN_EVENTS, "Door Open Events" },
310 { ZBEE_ZCL_ATTR_ID_DOOR_LOCK_DOOR_CLOSED_EVENTS, "Door Closed Events" },
311 { ZBEE_ZCL_ATTR_ID_DOOR_LOCK_OPEN_PERIOD, "Open Period" },
312 { 0, NULL }
315 /* Server Commands Received */
316 static const value_string zbee_zcl_door_lock_srv_rx_cmd_names[] = {
317 { ZBEE_ZCL_CMD_ID_DOOR_LOCK_LOCK_DOOR, "Lock Door" },
318 { ZBEE_ZCL_CMD_ID_DOOR_LOCK_UNLOCK_DOOR, "Unlock Door" },
319 { 0, NULL }
322 /* Server Commands Generated */
323 static const value_string zbee_zcl_door_lock_srv_tx_cmd_names[] = {
324 { ZBEE_ZCL_CMD_ID_DOOR_LOCK_LOCK_DOOR_RESPONSE, "Lock Door Response" },
325 { ZBEE_ZCL_CMD_ID_DOOR_LOCK_UNLOCK_DOOR_RESPONSE, "Unlock Door Response" },
326 { 0, NULL }
329 /* Lock State Values */
330 static const value_string zbee_zcl_door_lock_lock_state_values[] = {
331 { 0x00, "Not Fully Locked" },
332 { 0x01, "Locked" },
333 { 0x02, "Unlocked" },
334 { 0, NULL }
337 /* Lock Type Values */
338 static const value_string zbee_zcl_door_lock_lock_type_values[] = {
339 { 0x00, "Deadbolt" },
340 { 0x01, "Magnetic" },
341 { 0x02, "Other" },
342 { 0, NULL }
345 /* Door State Values */
346 static const value_string zbee_zcl_door_lock_door_state_values[] = {
347 { 0x00, "Open" },
348 { 0x01, "Closed" },
349 { 0x02, "Error (Jammed)" },
350 { 0x03, "Error (Forced Open)" },
351 { 0x04, "Error (Unspecified)" },
352 { 0, NULL }
356 /*************************/
357 /* Function Bodies */
358 /*************************/
361 *ZigBee ZCL Door Lock cluster dissector for wireshark.
363 *@param tvb pointer to buffer containing raw packet.
364 *@param pinfo pointer to packet information fields
365 *@param tree pointer to data tree Wireshark uses to display packet.
367 static int
368 dissect_zbee_zcl_door_lock(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
370 proto_tree *payload_tree;
371 zbee_zcl_packet *zcl;
372 unsigned offset = 0;
373 uint8_t cmd_id;
374 int rem_len;
376 /* Reject the packet if data is NULL */
377 if (data == NULL)
378 return 0;
379 zcl = (zbee_zcl_packet *)data;
380 cmd_id = zcl->cmd_id;
382 /* Create a subtree for the ZCL Command frame, and add the command ID to it. */
383 if (zcl->direction == ZBEE_ZCL_FCF_TO_SERVER) {
384 /* Append the command name to the info column. */
385 col_append_fstr(pinfo->cinfo, COL_INFO, "%s, Seq: %u",
386 val_to_str_const(cmd_id, zbee_zcl_door_lock_srv_rx_cmd_names, "Unknown Command"),
387 zcl->tran_seqno);
389 /* Add the command ID. */
390 proto_tree_add_item(tree, hf_zbee_zcl_door_lock_srv_rx_cmd_id, tvb, offset, 1, ENC_LITTLE_ENDIAN);
392 /* Check if this command has a payload, then add the payload tree */
393 rem_len = tvb_reported_length_remaining(tvb, ++offset);
394 if (rem_len > 0) {
395 /*payload_tree =*/ proto_tree_add_subtree(tree, tvb, offset, rem_len, ett_zbee_zcl_door_lock, NULL, "Payload");
397 /* Call the appropriate command dissector */
398 switch (cmd_id) {
399 case ZBEE_ZCL_CMD_ID_DOOR_LOCK_LOCK_DOOR:
400 case ZBEE_ZCL_CMD_ID_DOOR_LOCK_UNLOCK_DOOR:
401 /* No Payload */
402 default:
403 break;
407 else { /* ZBEE_ZCL_FCF_TO_CLIENT */
408 /* Append the command name to the info column. */
409 col_append_fstr(pinfo->cinfo, COL_INFO, "%s, Seq: %u",
410 val_to_str_const(cmd_id, zbee_zcl_door_lock_srv_tx_cmd_names, "Unknown Command"),
411 zcl->tran_seqno);
413 /* Add the command ID. */
414 proto_tree_add_item(tree, hf_zbee_zcl_door_lock_srv_tx_cmd_id, tvb, offset, 1, ENC_LITTLE_ENDIAN);
416 /* Check if this command has a payload, then add the payload tree */
417 rem_len = tvb_reported_length_remaining(tvb, ++offset);
418 if (rem_len > 0) {
419 payload_tree = proto_tree_add_subtree(tree, tvb, offset, rem_len, ett_zbee_zcl_door_lock, NULL, "Payload");
421 /* Call the appropriate command dissector */
422 switch (cmd_id) {
423 case ZBEE_ZCL_CMD_ID_DOOR_LOCK_LOCK_DOOR_RESPONSE:
424 case ZBEE_ZCL_CMD_ID_DOOR_LOCK_UNLOCK_DOOR_RESPONSE:
425 dissect_zcl_door_lock_lock_unlock_door_response(tvb, payload_tree, &offset);
426 break;
428 default:
429 break;
434 return tvb_captured_length(tvb);
435 } /*dissect_zbee_zcl_door_lock*/
439 *This function decodes the lock and unlock door response
441 *@param tvb the tv buffer of the current data_type
442 *@param tree the tree to append this item to
443 *@param offset offset of data in tvb
445 static void
446 dissect_zcl_door_lock_lock_unlock_door_response(tvbuff_t *tvb, proto_tree *tree, unsigned *offset)
448 /* Retrieve "Status" field */
449 proto_tree_add_item(tree, hf_zbee_zcl_door_lock_status, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
450 *offset += 1;
452 } /*dissect_zcl_door_lock_lock_unlock_door_response*/
456 *This function is called by ZCL foundation dissector in order to decode
458 *@param tree pointer to data tree Wireshark uses to display packet.
459 *@param tvb pointer to buffer containing raw packet.
460 *@param offset pointer to buffer offset
461 *@param attr_id attribute identifier
462 *@param data_type attribute data type
463 *@param client_attr ZCL client
465 void
466 dissect_zcl_door_lock_attr_data(proto_tree *tree, tvbuff_t *tvb, unsigned *offset, uint16_t attr_id, unsigned data_type, bool client_attr)
468 /* Dissect attribute data type and data */
469 switch ( attr_id ) {
471 case ZBEE_ZCL_ATTR_ID_DOOR_LOCK_LOCK_STATE:
472 proto_tree_add_item(tree, hf_zbee_zcl_door_lock_lock_state, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
473 *offset += 1;
474 break;
476 case ZBEE_ZCL_ATTR_ID_DOOR_LOCK_LOCK_TYPE:
477 proto_tree_add_item(tree, hf_zbee_zcl_door_lock_lock_type, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
478 *offset += 1;
479 break;
481 case ZBEE_ZCL_ATTR_ID_DOOR_LOCK_ACTUATOR_ENABLED:
482 proto_tree_add_item(tree, hf_zbee_zcl_door_lock_actuator_enabled, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
483 *offset += 1;
484 break;
486 case ZBEE_ZCL_ATTR_ID_DOOR_LOCK_DOOR_STATE:
487 proto_tree_add_item(tree, hf_zbee_zcl_door_lock_door_state, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
488 *offset += 1;
489 break;
491 case ZBEE_ZCL_ATTR_ID_DOOR_LOCK_DOOR_OPEN_EVENTS:
492 case ZBEE_ZCL_ATTR_ID_DOOR_LOCK_DOOR_CLOSED_EVENTS:
493 case ZBEE_ZCL_ATTR_ID_DOOR_LOCK_OPEN_PERIOD:
494 default:
495 dissect_zcl_attr_data(tvb, tree, offset, data_type, client_attr);
496 break;
499 } /*dissect_zcl_door_lock_attr_data*/
503 *ZigBee ZCL Door Lock cluster protocol registration routine.
506 void
507 proto_register_zbee_zcl_door_lock(void)
509 /* Setup list of header fields */
510 static hf_register_info hf[] = {
512 { &hf_zbee_zcl_door_lock_attr_id,
513 { "Attribute", "zbee_zcl_closures.door_lock.attr_id", FT_UINT16, BASE_HEX, VALS(zbee_zcl_door_lock_attr_names),
514 0x00, NULL, HFILL } },
516 { &hf_zbee_zcl_door_lock_lock_state,
517 { "Lock State", "zbee_zcl_closures.door_lock.attr.lock_state", FT_UINT8, BASE_HEX, VALS(zbee_zcl_door_lock_lock_state_values),
518 0x00, NULL, HFILL } },
520 { &hf_zbee_zcl_door_lock_lock_type,
521 { "Lock Type", "zbee_zcl_closures.door_lock.attr.lock_type", FT_UINT8, BASE_HEX, VALS(zbee_zcl_door_lock_lock_type_values),
522 0x00, NULL, HFILL } },
524 { &hf_zbee_zcl_door_lock_door_state,
525 { "Door State", "zbee_zcl_closures.door_lock.attr.door_state", FT_UINT8, BASE_HEX, VALS(zbee_zcl_door_lock_door_state_values),
526 0x00, NULL, HFILL } },
528 { &hf_zbee_zcl_door_lock_actuator_enabled,
529 { "Actuator enabled", "zbee_zcl_closures.door_lock.attr.actuator_enabled", FT_BOOLEAN, 8, TFS(&tfs_disabled_enabled),
530 0x01, NULL, HFILL } },
532 { &hf_zbee_zcl_door_lock_status,
533 { "Lock Status", "zbee_zcl_closures.door_lock.status", FT_UINT8, BASE_HEX, VALS(zbee_zcl_status_names),
534 0x00, NULL, HFILL } },
536 { &hf_zbee_zcl_door_lock_srv_rx_cmd_id,
537 { "Command", "zbee_zcl_closures.door_lock.cmd.srv_rx.id", FT_UINT8, BASE_HEX, VALS(zbee_zcl_door_lock_srv_rx_cmd_names),
538 0x00, NULL, HFILL } },
540 { &hf_zbee_zcl_door_lock_srv_tx_cmd_id,
541 { "Command", "zbee_zcl_closures.door_lock.cmd.srv_tx.id", FT_UINT8, BASE_HEX, VALS(zbee_zcl_door_lock_srv_tx_cmd_names),
542 0x00, NULL, HFILL } }
546 /* ZCL Door Lock subtrees */
547 static int *ett[] = {
548 &ett_zbee_zcl_door_lock
551 /* Register the ZigBee ZCL Door Lock cluster protocol name and description */
552 proto_zbee_zcl_door_lock = proto_register_protocol("ZigBee ZCL Door Lock", "ZCL Door Lock", ZBEE_PROTOABBREV_ZCL_DOOR_LOCK);
553 proto_register_field_array(proto_zbee_zcl_door_lock, hf, array_length(hf));
554 proto_register_subtree_array(ett, array_length(ett));
556 /* Register the ZigBee ZCL Door Lock dissector. */
557 register_dissector(ZBEE_PROTOABBREV_ZCL_DOOR_LOCK, dissect_zbee_zcl_door_lock, proto_zbee_zcl_door_lock);
559 } /*proto_register_zbee_zcl_door_lock*/
563 *Hands off the ZCL Door Lock dissector.
566 void
567 proto_reg_handoff_zbee_zcl_door_lock(void)
569 zbee_zcl_init_cluster( ZBEE_PROTOABBREV_ZCL_DOOR_LOCK,
570 proto_zbee_zcl_door_lock,
571 ett_zbee_zcl_door_lock,
572 ZBEE_ZCL_CID_DOOR_LOCK,
573 ZBEE_MFG_CODE_NONE,
574 hf_zbee_zcl_door_lock_attr_id,
575 hf_zbee_zcl_door_lock_attr_id,
576 hf_zbee_zcl_door_lock_srv_rx_cmd_id,
577 hf_zbee_zcl_door_lock_srv_tx_cmd_id,
578 (zbee_zcl_fn_attr_data)dissect_zcl_door_lock_attr_data
580 } /*proto_reg_handoff_zbee_zcl_door_lock*/
582 /* ########################################################################## */
583 /* #### (0x0100) WINDOW COVERING CLUSTER ################################ */
584 /* ########################################################################## */
586 /*************************/
587 /* Defines */
588 /*************************/
590 /*Attributes*/
591 #define ZBEE_ZCL_ATTR_ID_WINDOW_COVERING_TYPE 0x0000 /* Type of shutter */
592 #define ZBEE_ZCL_ATTR_ID_WINDOW_COVERING_CURRENT_POSITION_LIFT_PERCENTAGE 0x0008 /* Current position lift */
593 #define ZBEE_ZCL_ATTR_ID_WINDOW_COVERING_CURRENT_POSITION_TILT_PERCENTAGE 0x0009 /* Current position tilt */
595 /* Server commands received */
596 #define ZBEE_ZCL_CMD_ID_WINDOW_COVERING_UP_OPEN 0x00 /* Open the shutter */
597 #define ZBEE_ZCL_CMD_ID_WINDOW_COVERING_DOWN_CLOSE 0x01 /* Close the shutter */
598 #define ZBEE_ZCL_CMD_ID_WINDOW_COVERING_STOP 0x02 /* Stop the shutter */
599 #define ZBEE_ZCL_CMD_ID_WINDOW_COVERING_GO_TO_LIFT_PERCENTAGE 0x05 /* Go to lift percentage */
600 #define ZBEE_ZCL_CMD_ID_WINDOW_COVERING_GO_TO_TILT_PERCENTAGE 0x08 /* Go to tilt percentage */
603 /*Server commands generated - none*/
605 /*Status Mask Value - none */
607 /*************************/
608 /* Function Declarations */
609 /*************************/
611 void proto_register_zbee_zcl_window_covering(void);
613 /* Command Dissector Helpers */
614 static void dissect_zcl_window_covering_go_to_percentage(tvbuff_t *tvb, proto_tree *tree, unsigned *offset);
616 /* Private functions prototype */
618 /*************************/
619 /* Global Variables */
620 /*************************/
621 /* Initialize the protocol and registered fields */
622 static int proto_zbee_zcl_window_covering;
624 static int hf_zbee_zcl_window_covering_attr_id;
625 static int hf_zbee_zcl_window_covering_type;
626 static int hf_zbee_zcl_window_covering_current_position_lift_percentage;
627 static int hf_zbee_zcl_window_covering_current_position_tilt_percentage;
629 static int hf_zbee_zcl_window_covering_go_to_percentage;
630 static int hf_zbee_zcl_window_covering_srv_rx_cmd_id;
632 /* Initialize the subtree pointers */
633 static int ett_zbee_zcl_window_covering;
635 /* Attributes */
636 static const value_string zbee_zcl_window_covering_attr_names[] = {
637 { ZBEE_ZCL_ATTR_ID_WINDOW_COVERING_TYPE, "Window covering type" },
638 { ZBEE_ZCL_ATTR_ID_WINDOW_COVERING_CURRENT_POSITION_LIFT_PERCENTAGE, "Current position lift percentage" },
639 { ZBEE_ZCL_ATTR_ID_WINDOW_COVERING_CURRENT_POSITION_TILT_PERCENTAGE, "Current position tilt percentage" },
640 { 0, NULL }
643 /* Server Commands Received */
644 static const value_string zbee_zcl_window_covering_srv_rx_cmd_names[] = {
645 { ZBEE_ZCL_CMD_ID_WINDOW_COVERING_UP_OPEN, "Up / Open" },
646 { ZBEE_ZCL_CMD_ID_WINDOW_COVERING_DOWN_CLOSE, "Down / Close" },
647 { ZBEE_ZCL_CMD_ID_WINDOW_COVERING_STOP, "Stop" },
648 { ZBEE_ZCL_CMD_ID_WINDOW_COVERING_GO_TO_LIFT_PERCENTAGE, "Go to lift closed percentage" },
649 { ZBEE_ZCL_CMD_ID_WINDOW_COVERING_GO_TO_TILT_PERCENTAGE, "Go to tilt percentage" },
650 { 0, NULL }
653 /*************************/
654 /* Function Bodies */
655 /*************************/
658 *ZigBee ZCL Window Covering cluster dissector for wireshark.
660 *@param tvb pointer to buffer containing raw packet.
661 *@param pinfo pointer to packet information fields
662 *@param tree pointer to data tree Wireshark uses to display packet.
664 static int
665 dissect_zbee_zcl_window_covering(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
667 proto_tree *payload_tree;
668 zbee_zcl_packet *zcl;
669 unsigned offset = 0;
670 uint8_t cmd_id;
671 int rem_len;
673 /* Reject the packet if data is NULL */
674 if (data == NULL)
675 return 0;
676 zcl = (zbee_zcl_packet *)data;
677 cmd_id = zcl->cmd_id;
679 /* Create a subtree for the ZCL Command frame, and add the command ID to it. */
680 if (zcl->direction == ZBEE_ZCL_FCF_TO_SERVER) {
681 /* Append the command name to the info column. */
682 col_append_fstr(pinfo->cinfo, COL_INFO, "%s, Seq: %u",
683 val_to_str_const(cmd_id, zbee_zcl_window_covering_srv_rx_cmd_names, "Unknown Command"),
684 zcl->tran_seqno);
686 /* Add the command ID. */
687 proto_tree_add_item(tree, hf_zbee_zcl_window_covering_srv_rx_cmd_id, tvb, offset, 1, ENC_LITTLE_ENDIAN);
689 /* Check if this command has a payload, then add the payload tree */
690 rem_len = tvb_reported_length_remaining(tvb, ++offset);
691 if (rem_len > 0) {
692 payload_tree = proto_tree_add_subtree(tree, tvb, offset, rem_len, ett_zbee_zcl_window_covering, NULL, "Payload");
694 /* Call the appropriate command dissector */
695 switch (cmd_id) {
696 case ZBEE_ZCL_CMD_ID_WINDOW_COVERING_GO_TO_LIFT_PERCENTAGE:
697 case ZBEE_ZCL_CMD_ID_WINDOW_COVERING_GO_TO_TILT_PERCENTAGE:
698 dissect_zcl_window_covering_go_to_percentage(tvb, payload_tree, &offset);
699 break;
701 case ZBEE_ZCL_CMD_ID_WINDOW_COVERING_UP_OPEN:
702 case ZBEE_ZCL_CMD_ID_WINDOW_COVERING_DOWN_CLOSE:
703 case ZBEE_ZCL_CMD_ID_WINDOW_COVERING_STOP:
704 /* No Payload */
705 default:
706 break;
711 return tvb_captured_length(tvb);
712 } /*dissect_zbee_zcl_window_covering */
715 *This function decodes the go to lift/tilt percentage
717 *@param tvb the tv buffer of the current data_type
718 *@param tree the tree to append this item to
719 *@param offset offset of data in tvb
721 static void
722 dissect_zcl_window_covering_go_to_percentage(tvbuff_t *tvb, proto_tree *tree, unsigned *offset)
724 /* Retrieve "go to lift/tilt percentage" field */
725 proto_tree_add_item(tree, hf_zbee_zcl_window_covering_go_to_percentage, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
726 *offset += 1;
728 } /*dissect_zcl_window_covering_go_to_percentage*/
731 *This function is called by ZCL foundation dissector in order to decode
733 *@param tree pointer to data tree Wireshark uses to display packet.
734 *@param tvb pointer to buffer containing raw packet.
735 *@param offset pointer to buffer offset
736 *@param attr_id attribute identifier
737 *@param data_type attribute data type
738 *@param client_attr ZCL client
740 static void
741 dissect_zcl_window_covering_attr_data(proto_tree *tree, tvbuff_t *tvb, unsigned *offset, uint16_t attr_id, unsigned data_type, bool client_attr)
743 /* Dissect attribute data type and data */
744 switch ( attr_id ) {
746 case ZBEE_ZCL_ATTR_ID_WINDOW_COVERING_TYPE:
747 proto_tree_add_item(tree, hf_zbee_zcl_window_covering_type, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
748 *offset += 1;
749 break;
751 case ZBEE_ZCL_ATTR_ID_WINDOW_COVERING_CURRENT_POSITION_LIFT_PERCENTAGE:
752 proto_tree_add_item(tree, hf_zbee_zcl_window_covering_current_position_lift_percentage, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
753 *offset += 1;
754 break;
756 case ZBEE_ZCL_ATTR_ID_WINDOW_COVERING_CURRENT_POSITION_TILT_PERCENTAGE:
757 proto_tree_add_item(tree, hf_zbee_zcl_window_covering_current_position_tilt_percentage, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
758 *offset += 1;
759 break;
761 default:
762 dissect_zcl_attr_data(tvb, tree, offset, data_type, client_attr);
763 break;
766 } /*dissect_zcl_window_covering_attr_data*/
769 *ZigBee ZCL Window Covering cluster protocol registration routine.
772 void
773 proto_register_zbee_zcl_window_covering(void)
775 /* Setup list of header fields */
776 static hf_register_info hf[] = {
778 { &hf_zbee_zcl_window_covering_attr_id,
779 { "Attribute", "zbee_zcl_closures.window_covering.attr_id", FT_UINT16, BASE_HEX, VALS(zbee_zcl_window_covering_attr_names),
780 0x00, NULL, HFILL } },
782 { &hf_zbee_zcl_window_covering_type,
783 { "Type", "zbee_zcl_closures.window_covering.attr.type", FT_UINT8, BASE_HEX, NULL,
784 0x00, NULL, HFILL } },
786 { &hf_zbee_zcl_window_covering_current_position_lift_percentage,
787 { "Current position lift percentage", "zbee_zcl_closures.window_covering.attr.current_position_lift_percentage", FT_UINT8, BASE_DEC, NULL,
788 0x00, NULL, HFILL } },
790 { &hf_zbee_zcl_window_covering_current_position_tilt_percentage,
791 { "Current position tilt percentage", "zbee_zcl_closures.window_covering.attr.current_position_tilt_percentage", FT_UINT8, BASE_DEC, NULL,
792 0x00, NULL, HFILL } },
794 { &hf_zbee_zcl_window_covering_go_to_percentage,
795 { "Go to", "zbee_zcl_closures.window_covering.go_to", FT_UINT8, BASE_DEC, NULL,
796 0x00, NULL, HFILL } },
798 { &hf_zbee_zcl_window_covering_srv_rx_cmd_id,
799 { "Command", "zbee_zcl_closures.window_covering.cmd.srv_rx.id", FT_UINT8, BASE_HEX, VALS(zbee_zcl_window_covering_srv_rx_cmd_names),
800 0x00, NULL, HFILL } },
803 /* ZCL Window Covering subtrees */
804 static int *ett[] = {
805 &ett_zbee_zcl_window_covering
808 /* Register the ZigBee ZCL Window Covering cluster protocol name and description */
809 proto_zbee_zcl_window_covering = proto_register_protocol("ZigBee ZCL Window Covering", "ZCL Window Covering", ZBEE_PROTOABBREV_ZCL_WINDOW_COVERING);
810 proto_register_field_array(proto_zbee_zcl_window_covering, hf, array_length(hf));
811 proto_register_subtree_array(ett, array_length(ett));
813 /* Register the ZigBee ZCL Window Covering dissector. */
814 register_dissector(ZBEE_PROTOABBREV_ZCL_WINDOW_COVERING, dissect_zbee_zcl_window_covering, proto_zbee_zcl_window_covering);
816 } /*proto_register_zbee_zcl_window_covering*/
820 *Hands off the ZCL Window Covering dissector.
823 void
824 proto_reg_handoff_zbee_zcl_window_covering(void)
826 zbee_zcl_init_cluster( ZBEE_PROTOABBREV_ZCL_WINDOW_COVERING,
827 proto_zbee_zcl_window_covering,
828 ett_zbee_zcl_window_covering,
829 ZBEE_ZCL_CID_WINDOW_COVERING,
830 ZBEE_MFG_CODE_NONE,
831 hf_zbee_zcl_window_covering_attr_id,
832 hf_zbee_zcl_window_covering_attr_id,
833 hf_zbee_zcl_window_covering_srv_rx_cmd_id,
835 (zbee_zcl_fn_attr_data)dissect_zcl_window_covering_attr_data
837 } /*proto_reg_handoff_zbee_zcl_window_covering*/
840 * Editor modelines - https://www.wireshark.org/tools/modelines.html
842 * Local variables:
843 * c-basic-offset: 4
844 * tab-width: 8
845 * indent-tabs-mode: nil
846 * End:
848 * vi: set shiftwidth=4 tabstop=8 expandtab:
849 * :indentSize=4:tabSize=8:noTabs=true: