1 /* packet-zbee-zcl-se.c
2 * Dissector routines for the ZigBee ZCL SE clusters like
4 * By Fabio Tarabelloni <fabio.tarabelloni@reloc.it>
5 * Copyright 2013 RELOC s.r.l.
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30 #include <epan/packet.h>
31 #include <epan/prefs.h>
32 #include <epan/expert.h>
33 #include <epan/to_str.h>
35 #include "packet-zbee.h"
36 #include "packet-zbee-aps.h"
37 #include "packet-zbee-zcl.h"
38 #include "packet-zbee-security.h"
40 /* ########################################################################## */
41 /* #### common to all SE clusters ########################################### */
42 /* ########################################################################## */
44 #define ZBEE_ZCL_ATTR_ID_SE_ATTR_REPORT_STATUS 0xFFFE
45 #define ZBEE_ZCL_SE_ATTR_REPORT_PENDING 0x00
46 #define ZBEE_ZCL_SE_ATTR_REPORT_COMPLETE 0x01
48 static const value_string zbee_zcl_se_reporting_status_names[] = {
49 { ZBEE_ZCL_SE_ATTR_REPORT_PENDING, "Pending" },
50 { ZBEE_ZCL_SE_ATTR_REPORT_COMPLETE, "Complete" },
54 #define ZBEE_ZCL_SE_ATTR_NAMES \
55 { ZBEE_ZCL_ATTR_ID_SE_ATTR_REPORT_STATUS, "Attribute Reporting Status" }
57 /*************************/
58 /* Global Variables */
59 /*************************/
61 /* ########################################################################## */
62 /* #### (0x0703) MESSAGING CLUSTER ########################################## */
63 /* ########################################################################## */
65 /* Attributes - None (other than Attribute Reporting Status) */
66 static const value_string zbee_zcl_msg_attr_names[] = {
67 ZBEE_ZCL_SE_ATTR_NAMES,
71 /* Server Commands Received */
72 #define ZBEE_ZCL_CMD_ID_MSG_GET_LAST_MSG 0x00 /* Get Last Message */
73 #define ZBEE_ZCL_CMD_ID_MSG_MSG_CONFIRM 0x01 /* Message Confirmation */
74 #define ZBEE_ZCL_CMD_ID_MSG_GET_MESSAGE_CANCEL 0x02 /* Get Message Cancellation */
76 /* Server Commands Generated */
77 #define ZBEE_ZCL_CMD_ID_MSG_DISPLAY_MSG 0x00 /* Display Message */
78 #define ZBEE_ZCL_CMD_ID_MSG_CANCEL_MSG 0x01 /* Cancel Message */
79 #define ZBEE_ZCL_CMD_ID_MSG_DISPLAY_PROTECTED_MSG 0x02 /* Display Protected Message */
80 #define ZBEE_ZCL_CMD_ID_MSG_CANCEL_ALL_MSG 0x03 /* Cancel All Messages */
82 /* Message Control Field Bit Map */
83 #define ZBEE_ZCL_MSG_CTRL_TX_MASK 0x03
84 #define ZBEE_ZCL_MSG_CTRL_IMPORTANCE_MASK 0x0C
85 #define ZBEE_ZCL_MSG_CTRL_RESERVED_MASK 0x50
86 #define ZBEE_ZCL_MSG_CTRL_ENHANCED_CONFIRM_MASK 0x20
87 #define ZBEE_ZCL_MSG_CTRL_CONFIRM_MASK 0x80
89 #define ZBEE_ZCL_MSG_CTRL_TX_NORMAL_ONLY 0x00 /* Normal Transmission Only */
90 #define ZBEE_ZCL_MSG_CTRL_TX_NORMAL_ANON_INTERPAN 0x01 /* Normal and Anonymous Inter-PAN Transmission Only */
91 #define ZBEE_ZCL_MSG_CTRL_TX_ANON_INTERPAN_ONLY 0x02 /* Anonymous Inter-PAN Transmission Only */
93 #define ZBEE_ZCL_MSG_CTRL_IMPORTANCE_LOW 0x00 /* Low */
94 #define ZBEE_ZCL_MSG_CTRL_IMPORTANCE_MEDIUM 0x01 /* Medium */
95 #define ZBEE_ZCL_MSG_CTRL_IMPORTANCE_HIGH 0x02 /* High */
96 #define ZBEE_ZCL_MSG_CTRL_IMPORTANCE_CRITICAL 0x03 /* Critical */
98 #define ZBEE_ZCL_MSG_EXT_CTRL_STATUS_MASK 0x01
100 #define ZBEE_ZCL_MSG_CONFIRM_CTRL_MASK 0x01
102 #define ZBEE_ZCL_MSG_START_TIME_NOW 0x00000000 /* Now */
104 /*************************/
105 /* Function Declarations */
106 /*************************/
107 void proto_register_zbee_zcl_msg(void);
108 void proto_reg_handoff_zbee_zcl_msg(void);
110 /* Attribute Dissector Helpers */
111 static void dissect_zcl_msg_attr_data (proto_tree *tree, tvbuff_t *tvb, guint *offset, guint16 attr_id, guint data_type);
113 /* Command Dissector Helpers */
114 static void dissect_zcl_msg_display (tvbuff_t *tvb, proto_tree *tree, guint *offset);
115 static void dissect_zcl_msg_cancel (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint *offset);
116 static void dissect_zcl_msg_confirm (tvbuff_t *tvb, proto_tree *tree, guint *offset);
117 static void dissect_zcl_msg_cancel_all (tvbuff_t *tvb, proto_tree *tree, guint *offset);
118 static void dissect_zcl_msg_get_cancel (tvbuff_t *tvb, proto_tree *tree, guint *offset);
120 /* Private functions prototype */
121 static void decode_zcl_msg_duration (gchar *s, guint16 value);
123 /*************************/
124 /* Global Variables */
125 /*************************/
127 /* Initialize the protocol and registered fields */
128 static int proto_zbee_zcl_msg = -1;
130 static int hf_zbee_zcl_msg_srv_tx_cmd_id = -1;
131 static int hf_zbee_zcl_msg_srv_rx_cmd_id = -1;
132 static int hf_zbee_zcl_msg_attr_id = -1;
133 static int hf_zbee_zcl_msg_attr_reporting_status = -1;
134 static int hf_zbee_zcl_msg_message_id = -1;
135 static int hf_zbee_zcl_msg_ctrl = -1;
136 static int hf_zbee_zcl_msg_ctrl_tx = -1;
137 static int hf_zbee_zcl_msg_ctrl_importance = -1;
138 static int hf_zbee_zcl_msg_ctrl_enh_confirm = -1;
139 static int hf_zbee_zcl_msg_ctrl_reserved = -1;
140 static int hf_zbee_zcl_msg_ctrl_confirm = -1;
141 static int hf_zbee_zcl_msg_ext_ctrl = -1;
142 static int hf_zbee_zcl_msg_ext_ctrl_status = -1;
143 static int hf_zbee_zcl_msg_start_time = -1;
144 static int hf_zbee_zcl_msg_duration = -1;
145 static int hf_zbee_zcl_msg_message_length = - 1;
146 static int hf_zbee_zcl_msg_message = -1;
147 static int hf_zbee_zcl_msg_confirm_time = -1;
148 static int hf_zbee_zcl_msg_confirm_ctrl = -1;
149 static int hf_zbee_zcl_msg_confirm_response = -1;
150 static int hf_zbee_zcl_msg_confirm_response_length = - 1;
151 static int hf_zbee_zcl_msg_implementation_time = -1;
152 static int hf_zbee_zcl_msg_earliest_time = -1;
154 /* Initialize the subtree pointers */
155 static gint ett_zbee_zcl_msg = -1;
156 static gint ett_zbee_zcl_msg_message_control = -1;
157 static gint ett_zbee_zcl_msg_ext_message_control = -1;
159 static expert_field ei_zbee_zcl_msg_msg_ctrl_depreciated = EI_INIT;
161 /* Server Commands Received */
162 static const value_string zbee_zcl_msg_srv_rx_cmd_names[] = {
163 { ZBEE_ZCL_CMD_ID_MSG_GET_LAST_MSG, "Get Last Message" },
164 { ZBEE_ZCL_CMD_ID_MSG_MSG_CONFIRM, "Message Confirmation" },
165 { ZBEE_ZCL_CMD_ID_MSG_GET_MESSAGE_CANCEL, "Get Message Cancellation" },
169 /* Server Commands Generated */
170 static const value_string zbee_zcl_msg_srv_tx_cmd_names[] = {
171 { ZBEE_ZCL_CMD_ID_MSG_DISPLAY_MSG, "Display Message" },
172 { ZBEE_ZCL_CMD_ID_MSG_CANCEL_MSG, "Cancel Message" },
173 { ZBEE_ZCL_CMD_ID_MSG_DISPLAY_PROTECTED_MSG, "Display Protected Message"},
174 { ZBEE_ZCL_CMD_ID_MSG_CANCEL_ALL_MSG, "Cancel All Messages" },
178 /* Message Control Transmission */
179 static const value_string zbee_zcl_msg_ctrl_tx_names[] = {
180 { ZBEE_ZCL_MSG_CTRL_TX_NORMAL_ONLY, "Normal Transmission Only" },
181 { ZBEE_ZCL_MSG_CTRL_TX_NORMAL_ANON_INTERPAN, "Normal and Anonymous Inter-PAN Transmission Only" },
182 { ZBEE_ZCL_MSG_CTRL_TX_ANON_INTERPAN_ONLY, "Anonymous Inter-PAN Transmission Only" },
186 /* Message Control Importance */
187 static const value_string zbee_zcl_msg_ctrl_importance_names[] = {
188 { ZBEE_ZCL_MSG_CTRL_IMPORTANCE_LOW, "Low" },
189 { ZBEE_ZCL_MSG_CTRL_IMPORTANCE_MEDIUM, "Medium" },
190 { ZBEE_ZCL_MSG_CTRL_IMPORTANCE_HIGH, "High" },
191 { ZBEE_ZCL_MSG_CTRL_IMPORTANCE_CRITICAL, "Critical" },
195 /*************************/
196 /* Function Bodies */
197 /*************************/
199 /*FUNCTION:------------------------------------------------------
201 * dissect_zcl_msg_attr_data
203 * this function is called by ZCL foundation dissector in order to decode
204 * specific cluster attributes data.
206 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
207 * tvbuff_t *tvb - pointer to buffer containing raw packet.
208 * guint *offset - pointer to buffer offset
209 * guint16 attr_id - attribute identifier
210 * guint data_type - attribute data type
213 *---------------------------------------------------------------
216 dissect_zcl_msg_attr_data(proto_tree *tree, tvbuff_t *tvb, guint *offset, guint16 attr_id, guint data_type)
219 /* no cluster specific attributes */
221 /* applies to all SE clusters */
222 case ZBEE_ZCL_ATTR_ID_SE_ATTR_REPORT_STATUS:
223 proto_tree_add_item(tree, hf_zbee_zcl_msg_attr_reporting_status, tvb, *offset, 1, ENC_NA);
227 default: /* Catch all */
228 dissect_zcl_attr_data(tvb, tree, offset, data_type);
231 } /*dissect_zcl_ias_zone_attr_data*/
233 /*FUNCTION:------------------------------------------------------
235 * dissect_zbee_zcl_msg
237 * ZigBee ZCL Messaging cluster dissector for wireshark.
239 * tvbuff_t *tvb - pointer to buffer containing raw packet.
240 * packet_info *pinfo - pointer to packet information fields
241 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
244 *---------------------------------------------------------------
247 dissect_zbee_zcl_msg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
249 proto_tree *payload_tree;
250 zbee_zcl_packet *zcl;
255 /* Reject the packet if data is NULL */
258 zcl = (zbee_zcl_packet *)data;
259 cmd_id = zcl->cmd_id;
261 /* Create a subtree for the ZCL Command frame, and add the command ID to it. */
262 if (zcl->direction == ZBEE_ZCL_FCF_TO_SERVER) {
263 /* Append the command name to the info column. */
264 col_append_fstr(pinfo->cinfo, COL_INFO, "%s, Seq: %u",
265 val_to_str_const(cmd_id, zbee_zcl_msg_srv_rx_cmd_names, "Unknown Command"),
268 /* Add the command ID. */
269 proto_tree_add_item(tree, hf_zbee_zcl_msg_srv_rx_cmd_id, tvb, offset, 1, cmd_id);
271 /* Check is this command has a payload, than add the payload tree */
272 rem_len = tvb_reported_length_remaining(tvb, ++offset);
274 payload_tree = proto_tree_add_subtree(tree, tvb, offset, rem_len, ett_zbee_zcl_msg, NULL, "Payload");
276 /* Call the appropriate command dissector */
279 case ZBEE_ZCL_CMD_ID_MSG_GET_LAST_MSG:
283 case ZBEE_ZCL_CMD_ID_MSG_MSG_CONFIRM:
284 dissect_zcl_msg_confirm(tvb, payload_tree, &offset);
287 case ZBEE_ZCL_CMD_ID_MSG_GET_MESSAGE_CANCEL:
288 dissect_zcl_msg_get_cancel(tvb, payload_tree, &offset);
296 else { /* ZBEE_ZCL_FCF_TO_CLIENT */
297 /* Append the command name to the info column. */
298 col_append_fstr(pinfo->cinfo, COL_INFO, "%s, Seq: %u",
299 val_to_str_const(cmd_id, zbee_zcl_msg_srv_tx_cmd_names, "Unknown Command"),
302 /* Add the command ID. */
303 proto_tree_add_item(tree, hf_zbee_zcl_msg_srv_tx_cmd_id, tvb, offset, 1, cmd_id);
305 /* Check is this command has a payload, than add the payload tree */
306 rem_len = tvb_reported_length_remaining(tvb, ++offset);
308 payload_tree = proto_tree_add_subtree(tree, tvb, offset, rem_len, ett_zbee_zcl_msg, NULL, "Payload");
310 /* Call the appropriate command dissector */
313 case ZBEE_ZCL_CMD_ID_MSG_DISPLAY_MSG:
314 dissect_zcl_msg_display(tvb, payload_tree, &offset);
317 case ZBEE_ZCL_CMD_ID_MSG_CANCEL_MSG:
318 dissect_zcl_msg_cancel(tvb, pinfo, payload_tree, &offset);
321 case ZBEE_ZCL_CMD_ID_MSG_DISPLAY_PROTECTED_MSG:
322 dissect_zcl_msg_display(tvb, payload_tree, &offset);
325 case ZBEE_ZCL_CMD_ID_MSG_CANCEL_ALL_MSG:
326 dissect_zcl_msg_cancel_all(tvb, payload_tree, &offset);
335 return tvb_captured_length(tvb);
336 } /*dissect_zbee_zcl_msg*/
338 /*FUNCTION:------------------------------------------------------
340 * dissect_zcl_msg_display
342 * This function manages the Display Message payload
344 * tvbuff_t *tvb - pointer to buffer containing raw packet.
345 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
349 *---------------------------------------------------------------
352 dissect_zcl_msg_display(tvbuff_t *tvb, proto_tree *tree, guint *offset)
357 static const int * message_ctrl_flags[] = {
358 &hf_zbee_zcl_msg_ctrl_tx,
359 &hf_zbee_zcl_msg_ctrl_importance,
360 &hf_zbee_zcl_msg_ctrl_enh_confirm,
361 &hf_zbee_zcl_msg_ctrl_reserved,
362 &hf_zbee_zcl_msg_ctrl_confirm,
366 static const int * message_ext_ctrl_flags[] = {
367 &hf_zbee_zcl_msg_ext_ctrl_status,
372 proto_tree_add_item(tree, hf_zbee_zcl_msg_message_id, tvb, *offset, 4, ENC_LITTLE_ENDIAN);
375 /* Message Control */
376 proto_tree_add_bitmask(tree, tvb, *offset, hf_zbee_zcl_msg_ctrl, ett_zbee_zcl_msg_message_control, message_ctrl_flags, ENC_NA);
380 proto_tree_add_item(tree, hf_zbee_zcl_msg_start_time, tvb, *offset, 4, ENC_LITTLE_ENDIAN);
383 /* Duration In Minutes*/
384 proto_tree_add_item(tree, hf_zbee_zcl_msg_duration, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
388 msg_len = tvb_get_guint8(tvb, *offset); /* string length */
389 proto_tree_add_item(tree, hf_zbee_zcl_msg_message_length, tvb, *offset, 1, ENC_NA);
393 msg_data = tvb_get_string_enc(wmem_packet_scope(), tvb, *offset, msg_len, ENC_LITTLE_ENDIAN);
394 proto_tree_add_string(tree, hf_zbee_zcl_msg_message, tvb, *offset, msg_len, msg_data);
397 /* (Optional) Extended Message Control */
398 if (tvb_reported_length_remaining(tvb, *offset) > 0) {
399 proto_tree_add_bitmask(tree, tvb, *offset, hf_zbee_zcl_msg_ext_ctrl, ett_zbee_zcl_msg_ext_message_control, message_ext_ctrl_flags, ENC_NA);
403 } /*dissect_zcl_msg_display*/
405 /*FUNCTION:------------------------------------------------------
407 * dissect_zcl_msg_cancel
409 * This function manages the Cancel Message payload
411 * tvbuff_t *tvb - pointer to buffer containing raw packet.
412 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
416 *---------------------------------------------------------------
419 dissect_zcl_msg_cancel(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint *offset)
424 proto_tree_add_item(tree, hf_zbee_zcl_msg_message_id, tvb, *offset, 4, ENC_LITTLE_ENDIAN);
427 /* Message Control */
428 msg_ctrl = tvb_get_guint8(tvb, *offset);
429 proto_tree_add_item(tree, hf_zbee_zcl_msg_ctrl, tvb, *offset, 1, ENC_NA);
432 if (msg_ctrl != 0x00) {
433 expert_add_info(pinfo, tree, &ei_zbee_zcl_msg_msg_ctrl_depreciated);
436 } /* dissect_zcl_msg_cancel */
439 /*FUNCTION:------------------------------------------------------
441 * dissect_zcl_msg_cancel_all
443 * Send Cancel All command
445 * tvbuff_t *tvb - pointer to buffer containing raw packet.
446 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
450 *---------------------------------------------------------------
453 dissect_zcl_msg_cancel_all(tvbuff_t *tvb, proto_tree *tree, guint *offset)
457 /* Retrieve "Confirmation Time" field */
458 impl_time.secs = tvb_get_letohl(tvb, *offset) + ZBEE_ZCL_NSTIME_UTC_OFFSET;
460 proto_tree_add_time(tree, hf_zbee_zcl_msg_implementation_time, tvb, *offset, 4, &impl_time);
463 } /* dissect_zcl_msg_cancel_all */
465 /*FUNCTION:------------------------------------------------------
467 * dissect_zcl_msg_get_cancel
469 * Send Cancel All command
471 * tvbuff_t *tvb - pointer to buffer containing raw packet.
472 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
476 *---------------------------------------------------------------
479 dissect_zcl_msg_get_cancel(tvbuff_t *tvb, proto_tree *tree, guint *offset)
483 /* Earliest Implementation Time */
484 impl_time.secs = tvb_get_letohl(tvb, *offset) + ZBEE_ZCL_NSTIME_UTC_OFFSET;
486 proto_tree_add_time(tree, hf_zbee_zcl_msg_earliest_time, tvb, *offset, 4, &impl_time);
489 } /* dissect_zcl_msg_get_cancel */
492 /*FUNCTION:------------------------------------------------------
494 * dissect_zcl_msg_confirm
496 * This function manages the Message Confirmation payload
498 * tvbuff_t *tvb - pointer to buffer containing raw packet.
499 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
503 *---------------------------------------------------------------
506 dissect_zcl_msg_confirm(tvbuff_t *tvb, proto_tree *tree, guint *offset)
510 nstime_t confirm_time;
512 /* Retrieve "Message ID" field */
513 proto_tree_add_item(tree, hf_zbee_zcl_msg_message_id, tvb, *offset, 4, ENC_LITTLE_ENDIAN);
516 /* Retrieve "Confirmation Time" field */
517 confirm_time.secs = tvb_get_letohl(tvb, *offset) + ZBEE_ZCL_NSTIME_UTC_OFFSET;
518 confirm_time.nsecs = 0;
519 proto_tree_add_time(tree, hf_zbee_zcl_msg_confirm_time, tvb, *offset, 4, &confirm_time);
522 /* (Optional) Confirm Control */
523 if ( tvb_reported_length_remaining(tvb, *offset) <= 0 ) return;
524 proto_tree_add_item(tree, hf_zbee_zcl_msg_confirm_ctrl, tvb, *offset, 1, ENC_NA);
527 /* (Optional) Response Text Length */
528 if ( tvb_reported_length_remaining(tvb, *offset) <= 0 ) return;
529 msg_len = tvb_get_guint8(tvb, *offset); /* string length */
530 proto_tree_add_item(tree, hf_zbee_zcl_msg_confirm_response_length, tvb, *offset, 1, ENC_NA);
533 /* (Optional) Response Text, but is we have a length we expect to find the subsequent string */
535 msg_data = tvb_get_string_enc(wmem_packet_scope(), tvb, *offset, msg_len, ENC_LITTLE_ENDIAN);
536 proto_tree_add_string(tree, hf_zbee_zcl_msg_confirm_response, tvb, *offset, msg_len, msg_data);
540 } /* dissect_zcl_msg_confirm */
542 /*FUNCTION:------------------------------------------------------
544 * decode_zcl_msg_duration
546 * this function decodes duration in minute type variable
550 *---------------------------------------------------------------
553 decode_zcl_msg_duration(gchar *s, guint16 value)
556 g_snprintf(s, ITEM_LABEL_LENGTH, "Until changed");
558 g_snprintf(s, ITEM_LABEL_LENGTH, "%d minutes", value);
560 } /*decode_zcl_msg_duration*/
562 /*FUNCTION:------------------------------------------------------
564 * decode_zcl_msg_start_time
566 * this function decodes start time, with peculiarity case for
567 * messaging specifications.
569 * guint *s - string to display
570 * guint32 value - value to decode
573 *---------------------------------------------------------------
576 decode_zcl_msg_start_time(gchar *s, guint32 value)
578 if (value == ZBEE_ZCL_MSG_START_TIME_NOW)
579 g_snprintf(s, ITEM_LABEL_LENGTH, "Now");
582 value += ZBEE_ZCL_NSTIME_UTC_OFFSET;
583 start_time = abs_time_secs_to_str (NULL, value, ABSOLUTE_TIME_LOCAL, TRUE);
584 g_snprintf(s, ITEM_LABEL_LENGTH, "%s", start_time);
585 wmem_free(NULL, start_time);
587 } /* decode_zcl_msg_start_time */
589 /*FUNCTION:------------------------------------------------------
591 * proto_register_zbee_zcl_msg
593 * this function registers the ZCL Messaging dissector
594 * and all its information.
599 *---------------------------------------------------------------
602 proto_register_zbee_zcl_msg(void)
604 static hf_register_info hf[] = {
606 { &hf_zbee_zcl_msg_attr_id,
607 { "Attribute", "zbee_zcl_se.msg.attr_id", FT_UINT16, BASE_HEX, VALS(zbee_zcl_msg_attr_names),
608 0x0, NULL, HFILL } },
610 { &hf_zbee_zcl_msg_attr_reporting_status, /* common to all SE clusters */
611 { "Attribute Reporting Status", "zbee_zcl_se.msg.attr.attr_reporting_status",
612 FT_UINT8, BASE_HEX, VALS(zbee_zcl_se_reporting_status_names), 0x00, NULL, HFILL } },
614 { &hf_zbee_zcl_msg_srv_tx_cmd_id,
615 { "Command", "zbee_zcl_se.msg.cmd.srv_tx.id", FT_UINT8, BASE_HEX, VALS(zbee_zcl_msg_srv_tx_cmd_names),
616 0x00, NULL, HFILL } },
618 { &hf_zbee_zcl_msg_srv_rx_cmd_id,
619 { "Command", "zbee_zcl_se.msg.cmd.srv_rx.id", FT_UINT8, BASE_HEX, VALS(zbee_zcl_msg_srv_rx_cmd_names),
620 0x00, NULL, HFILL } },
622 { &hf_zbee_zcl_msg_message_id,
623 { "Message ID", "zbee_zcl_se.msg.message.id", FT_UINT32, BASE_HEX, NULL,
624 0x00, NULL, HFILL } },
626 /* Start of 'Message Control' fields */
627 { &hf_zbee_zcl_msg_ctrl,
628 { "Message Control", "zbee_zcl_se.msg.message.ctrl", FT_UINT8, BASE_HEX, NULL,
629 0x0, NULL, HFILL } },
631 { &hf_zbee_zcl_msg_ctrl_tx,
632 { "Transmission", "zbee_zcl_se.msg.message.ctrl.tx", FT_UINT8, BASE_HEX, VALS(zbee_zcl_msg_ctrl_tx_names),
633 ZBEE_ZCL_MSG_CTRL_TX_MASK, NULL, HFILL } },
635 { &hf_zbee_zcl_msg_ctrl_importance,
636 { "Importance", "zbee_zcl_se.msg.message.ctrl.importance", FT_UINT8, BASE_HEX, VALS(zbee_zcl_msg_ctrl_importance_names),
637 ZBEE_ZCL_MSG_CTRL_IMPORTANCE_MASK, NULL, HFILL } },
639 { &hf_zbee_zcl_msg_ctrl_enh_confirm,
640 { "Confirmation", "zbee_zcl_se.msg.message.ctrl.enhconfirm", FT_BOOLEAN, 8, TFS(&tfs_required_not_required),
641 ZBEE_ZCL_MSG_CTRL_ENHANCED_CONFIRM_MASK, NULL, HFILL } },
643 { &hf_zbee_zcl_msg_ctrl_reserved,
644 { "Reserved", "zbee_zcl_se.msg.message.ctrl.reserved", FT_UINT8, BASE_HEX, NULL,
645 ZBEE_ZCL_MSG_CTRL_RESERVED_MASK, NULL, HFILL } },
647 { &hf_zbee_zcl_msg_ctrl_confirm,
648 { "Confirmation", "zbee_zcl_se.msg.message.ctrl.confirm", FT_BOOLEAN, 8, TFS(&tfs_required_not_required),
649 ZBEE_ZCL_MSG_CTRL_CONFIRM_MASK, NULL, HFILL } },
650 /* End of 'Message Control' fields */
652 /* Start of 'Extended Message Control' fields */
653 { &hf_zbee_zcl_msg_ext_ctrl,
654 { "Extended Message Control", "zbee_zcl_se.msg.message.ext.ctrl", FT_UINT8, BASE_HEX, NULL,
655 0x0, NULL, HFILL } },
657 { &hf_zbee_zcl_msg_ext_ctrl_status,
658 { "Message Confirmation Satus", "zbee_zcl_se.msg.message.ext.ctrl.status", FT_BOOLEAN, 8, TFS(&tfs_confirmed_unconfirmed),
659 ZBEE_ZCL_MSG_EXT_CTRL_STATUS_MASK, NULL, HFILL } },
660 /* End of 'Extended Message Control' fields */
662 { &hf_zbee_zcl_msg_start_time,
663 { "Start Time", "zbee_zcl_se.msg.message.start_time", FT_UINT32, BASE_CUSTOM, CF_FUNC(decode_zcl_msg_start_time),
664 0x00, NULL, HFILL } },
666 { &hf_zbee_zcl_msg_duration,
667 { "Duration", "zbee_zcl_se.msg.message.duration", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_zcl_msg_duration),
668 0x00, NULL, HFILL } },
670 { &hf_zbee_zcl_msg_message_length,
671 { "Message Length", "zbee_zcl_se.msg.message.length", FT_UINT8, BASE_DEC, NULL,
672 0x00, NULL, HFILL } },
674 { &hf_zbee_zcl_msg_message,
675 { "Message", "zbee_zcl_se.msg.message", FT_STRING, BASE_NONE, NULL,
676 0x00, NULL, HFILL } },
678 { &hf_zbee_zcl_msg_confirm_time,
679 { "Confirmation Time", "zbee_zcl_se.msg.message.confirm_time", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL,
680 0x0, NULL, HFILL } },
682 { &hf_zbee_zcl_msg_confirm_ctrl,
683 { "Confirmation Control", "zbee_zcl_se.msg.message.confirm.ctrl", FT_BOOLEAN, 8, TFS(&tfs_no_yes),
684 ZBEE_ZCL_MSG_CONFIRM_CTRL_MASK, NULL, HFILL } },
686 { &hf_zbee_zcl_msg_confirm_response_length,
687 { "Response Length", "zbee_zcl_se.msg.message.length", FT_UINT8, BASE_DEC, NULL,
688 0x00, NULL, HFILL } },
690 { &hf_zbee_zcl_msg_confirm_response,
691 { "Response", "zbee_zcl_se.msg.message", FT_STRING, BASE_NONE, NULL,
692 0x00, NULL, HFILL } },
694 { &hf_zbee_zcl_msg_implementation_time,
695 { "Implementation Time", "zbee_zcl_se.msg.impl_time", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_UTC, NULL,
698 { &hf_zbee_zcl_msg_earliest_time,
699 { "Earliest Implementation Time", "zbee_zcl_se.msg.earliest_impl_time", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_UTC, NULL,
704 /* ZCL Messaging subtrees */
707 &ett_zbee_zcl_msg_message_control,
708 &ett_zbee_zcl_msg_ext_message_control,
712 expert_module_t* expert_zbee_zcl_msg;
713 static ei_register_info ei[] = {
714 { &ei_zbee_zcl_msg_msg_ctrl_depreciated, { "zbee_zcl_se.msg.msg_ctrl.depreciated", PI_PROTOCOL, PI_WARN, "Message Control depreciated in this message, should be 0x00", EXPFILL }},
717 /* Register the ZigBee ZCL Messaging cluster protocol name and description */
718 proto_zbee_zcl_msg = proto_register_protocol("ZigBee ZCL Messaging", "ZCL Messaging", ZBEE_PROTOABBREV_ZCL_MSG);
719 proto_register_field_array(proto_zbee_zcl_msg, hf, array_length(hf));
720 proto_register_subtree_array(ett, array_length(ett));
722 expert_zbee_zcl_msg = expert_register_protocol(proto_zbee_zcl_msg);
723 expert_register_field_array(expert_zbee_zcl_msg, ei, array_length(ei));
725 /* Register the ZigBee ZCL Messaging dissector. */
726 new_register_dissector(ZBEE_PROTOABBREV_ZCL_MSG, dissect_zbee_zcl_msg, proto_zbee_zcl_msg);
727 } /*proto_register_zbee_zcl_msg*/
729 /*FUNCTION:------------------------------------------------------
731 * proto_reg_handoff_zbee_zcl_msg
733 * Hands off the Zcl Messaging dissector.
738 *---------------------------------------------------------------
741 proto_reg_handoff_zbee_zcl_msg(void)
743 dissector_handle_t msg_handle;
745 /* Register our dissector with the ZigBee application dissectors. */
746 msg_handle = find_dissector(ZBEE_PROTOABBREV_ZCL_MSG);
747 dissector_add_uint("zbee.zcl.cluster", ZBEE_ZCL_CID_MESSAGE, msg_handle);
749 zbee_zcl_init_cluster( proto_zbee_zcl_msg,
751 ZBEE_ZCL_CID_MESSAGE,
752 hf_zbee_zcl_msg_attr_id,
753 hf_zbee_zcl_msg_srv_rx_cmd_id,
754 hf_zbee_zcl_msg_srv_tx_cmd_id,
755 (zbee_zcl_fn_attr_data)dissect_zcl_msg_attr_data
757 } /*proto_reg_handoff_zbee_zcl_msg*/
759 /* ########################################################################## */
760 /* #### (0x0704) TUNNELING CLUSTER ########################################### */
761 /* ########################################################################## */
764 #define ZBEE_ZCL_ATTR_ID_TUN_CLOSE_TIMEOUT 0x0000 /* Close Tunnel Timeout */
766 static const value_string zbee_zcl_tun_attr_names[] = {
767 { ZBEE_ZCL_ATTR_ID_TUN_CLOSE_TIMEOUT, "Close Tunnel Timeout" },
768 ZBEE_ZCL_SE_ATTR_NAMES,
772 /* Server Commands Received */
773 #define ZBEE_ZCL_CMD_ID_TUN_REQUEST_TUNNEL 0x00 /* Request Tunnel */
774 #define ZBEE_ZCL_CMD_ID_TUN_CLOSE_TUNNEL 0x01 /* Close Tunnel */
775 #define ZBEE_ZCL_CMD_ID_TUN_TRANSFER_DATA 0x02 /* Transfer Data */
776 #define ZBEE_ZCL_CMD_ID_TUN_TRANSFER_DATA_ERROR 0x03 /* Transfer Data Error */
777 #define ZBEE_ZCL_CMD_ID_TUN_ACK_TRANSFER_DATA 0x04 /* Ack Transfer Data */
778 #define ZBEE_ZCL_CMD_ID_TUN_READY_DATA 0x05 /* Ready Data */
779 #define ZBEE_ZCL_CMD_ID_TUN_GET_SUPPORTED_PROTOCOLS 0x06 /* Get Supported Tunnel Protocols */
781 /* Server Commands Generated */
782 #define ZBEE_ZCL_CMD_ID_TUN_REQUEST_TUNNEL_RSP 0x00 /* Request Tunnel Response*/
783 #define ZBEE_ZCL_CMD_ID_TUN_TRANSFER_DATA_TX 0x01 /* Transfer Data */
784 #define ZBEE_ZCL_CMD_ID_TUN_TRANSFER_DATA_ERROR_TX 0x02 /* Transfer Data Error */
785 #define ZBEE_ZCL_CMD_ID_TUN_ACK_TRANSFER_DATA_TX 0x03 /* Ack Transfer Data */
786 #define ZBEE_ZCL_CMD_ID_TUN_READY_DATA_TX 0x04 /* Ready Data */
787 #define ZBEE_ZCL_CMD_ID_TUN_GET_SUPPORTED_PROTOCOLS_RSP 0x05 /* Get Supported Tunnel Protocols */
788 #define ZBEE_ZCL_CMD_ID_TUN_CLOSURE_NOTIFY 0x06 /* Tunnel Closure Notification */
790 /*************************/
791 /* Function Declarations */
792 /*************************/
793 void proto_register_zbee_zcl_tun(void);
794 void proto_reg_handoff_zbee_zcl_tun(void);
796 /* Attribute Dissector Helpers */
797 static void dissect_zcl_tun_attr_data (proto_tree *tree, tvbuff_t *tvb, guint *offset, guint16 attr_id, guint data_type);
799 /* Private functions prototype */
801 /*************************/
802 /* Global Variables */
803 /*************************/
805 /* Initialize the protocol and registered fields */
806 static int proto_zbee_zcl_tun = -1;
808 static int hf_zbee_zcl_tun_srv_tx_cmd_id = -1;
809 static int hf_zbee_zcl_tun_srv_rx_cmd_id = -1;
810 static int hf_zbee_zcl_tun_attr_id = -1;
811 static int hf_zbee_zcl_tun_attr_reporting_status = -1;
812 static int hf_zbee_zcl_tun_attr_close_timeout = -1;
813 static int hf_zbee_zcl_tun_protocol_id = -1;
814 static int hf_zbee_zcl_tun_manufacturer_code = -1;
815 static int hf_zbee_zcl_tun_flow_control_support = -1;
816 static int hf_zbee_zcl_tun_max_in_size = -1;
817 static int hf_zbee_zcl_tun_tunnel_id = -1;
818 static int hf_zbee_zcl_tun_num_octets_left = -1;
819 static int hf_zbee_zcl_tun_protocol_offset = -1;
820 static int hf_zbee_zcl_tun_protocol_list_complete = -1;
821 static int hf_zbee_zcl_tun_protocol_count = -1;
822 static int hf_zbee_zcl_tun_transfer_status = -1;
823 static int hf_zbee_zcl_tun_transfer_data = -1;
824 static int hf_zbee_zcl_tun_transfer_data_status = -1;
826 /* Initialize the subtree pointers */
827 static gint ett_zbee_zcl_tun = -1;
829 /* Subdissector handles. */
830 static dissector_handle_t ipv4_handle;
831 static dissector_handle_t ipv6_handle;
833 /* Server Commands Received */
834 static const value_string zbee_zcl_tun_srv_rx_cmd_names[] = {
835 { ZBEE_ZCL_CMD_ID_TUN_REQUEST_TUNNEL, "Request Tunnel" },
836 { ZBEE_ZCL_CMD_ID_TUN_CLOSE_TUNNEL, "Close Tunnel" },
837 { ZBEE_ZCL_CMD_ID_TUN_TRANSFER_DATA, "Transfer Data" },
838 { ZBEE_ZCL_CMD_ID_TUN_TRANSFER_DATA_ERROR, "Transfer Data Error" },
839 { ZBEE_ZCL_CMD_ID_TUN_ACK_TRANSFER_DATA, "Ack Transfer Data" },
840 { ZBEE_ZCL_CMD_ID_TUN_READY_DATA, "Ready Data" },
841 { ZBEE_ZCL_CMD_ID_TUN_GET_SUPPORTED_PROTOCOLS, "Get Supported Protocols" },
845 /* Server Commands Generated */
846 static const value_string zbee_zcl_tun_srv_tx_cmd_names[] = {
847 { ZBEE_ZCL_CMD_ID_TUN_REQUEST_TUNNEL_RSP, "Request Tunnel Response" },
848 { ZBEE_ZCL_CMD_ID_TUN_TRANSFER_DATA_TX, "Transfer Data" },
849 { ZBEE_ZCL_CMD_ID_TUN_TRANSFER_DATA_ERROR_TX, "Transfer Data Error" },
850 { ZBEE_ZCL_CMD_ID_TUN_ACK_TRANSFER_DATA_TX, "Ack Transfer Data" },
851 { ZBEE_ZCL_CMD_ID_TUN_READY_DATA_TX, "Ready Data" },
852 { ZBEE_ZCL_CMD_ID_TUN_GET_SUPPORTED_PROTOCOLS_RSP, "Get Supported Tunnel Protocols" },
853 { ZBEE_ZCL_CMD_ID_TUN_CLOSURE_NOTIFY, "Tunnel Closure Notification" },
857 #define ZBEE_ZCL_TUN_PROTO_DLMS 0x00
858 #define ZBEE_ZCL_TUN_PROTO_IEC_61107 0x01
859 #define ZBEE_ZCL_TUN_PROTO_ANSI_C12 0x02
860 #define ZBEE_ZCL_TUN_PROTO_M_BUS 0x03
861 #define ZBEE_ZCL_TUN_PROTO_SML 0x04
862 #define ZBEE_ZCL_TUN_PROTO_CLIMATE_TALK 0x05
863 #define ZBEE_ZCL_TUN_PROTO_GB_HRGP 0x06
864 #define ZBEE_ZCL_TUN_PROTO_IPV6 0x07
865 #define ZBEE_ZCL_TUN_PROTO_IPV4 0x08
866 #define ZBEE_ZCL_TUN_PROTO_NULL 0x09
867 #define ZBEE_ZCL_TUN_PROTO_TEST 199
868 #define ZBEE_ZCL_TUN_PROTO_MANUFACTURER 200
869 #define ZBEE_ZCL_TUN_PROTO_RESERVED 0xFF
871 static const value_string zbee_zcl_tun_protocol_names[] = {
872 { ZBEE_ZCL_TUN_PROTO_DLMS, "DLMS/COSEM (IEC 62056)" },
873 { ZBEE_ZCL_TUN_PROTO_IEC_61107, "IEC 61107" },
874 { ZBEE_ZCL_TUN_PROTO_ANSI_C12, "ANSI C12" },
875 { ZBEE_ZCL_TUN_PROTO_M_BUS, "M-BUS" },
876 { ZBEE_ZCL_TUN_PROTO_SML, "SML" },
877 { ZBEE_ZCL_TUN_PROTO_CLIMATE_TALK, "ClimateTalk" },
878 { ZBEE_ZCL_TUN_PROTO_GB_HRGP, "GB-HRGP" },
879 { ZBEE_ZCL_TUN_PROTO_IPV6, "IPv6" },
880 { ZBEE_ZCL_TUN_PROTO_IPV4, "IPv4" },
881 { ZBEE_ZCL_TUN_PROTO_NULL, "null" },
882 { ZBEE_ZCL_TUN_PROTO_TEST, "test" },
883 { ZBEE_ZCL_TUN_PROTO_MANUFACTURER, "Manufacturer Specific" },
884 { ZBEE_ZCL_TUN_PROTO_RESERVED, "Reserved" },
888 #define ZBEE_ZCL_TUN_TRANS_STATUS_NO_TUNNEL 0x00
889 #define ZBEE_ZCL_TUN_TRANS_STATUS_WRONG_DEV 0x01
890 #define ZBEE_ZCL_TUN_TRANS_STATUS_OVERFLOW 0x02
892 static const value_string zbee_zcl_tun_trans_data_status_names[] = {
893 { ZBEE_ZCL_TUN_TRANS_STATUS_NO_TUNNEL, "Tunnel ID Does Not Exist" },
894 { ZBEE_ZCL_TUN_TRANS_STATUS_WRONG_DEV, "Wrong Device" },
895 { ZBEE_ZCL_TUN_TRANS_STATUS_OVERFLOW, "Data Overflow" },
899 #define ZBEE_ZCL_TUN_STATUS_SUCCESS 0x00
900 #define ZBEE_ZCL_TUN_STATUS_BUSY 0x01
901 #define ZBEE_ZCL_TUN_STATUS_NO_MORE_IDS 0x02
902 #define ZBEE_ZCL_TUN_STATUS_PROTO_NOT_SUPP 0x03
903 #define ZBEE_ZCL_TUN_STATUS_FLOW_CONTROL_NOT_SUPP 0x04
905 static const value_string zbee_zcl_tun_status_names[] = {
906 { ZBEE_ZCL_TUN_STATUS_SUCCESS, "Success" },
907 { ZBEE_ZCL_TUN_STATUS_BUSY, "Busy" },
908 { ZBEE_ZCL_TUN_STATUS_NO_MORE_IDS, "No More Tunnel IDs" },
909 { ZBEE_ZCL_TUN_STATUS_PROTO_NOT_SUPP, "Protocol Not Supported" },
910 { ZBEE_ZCL_TUN_STATUS_FLOW_CONTROL_NOT_SUPP, "Flow Control Not Supported" },
914 /*************************/
915 /* Function Bodies */
916 /*************************/
918 /*FUNCTION:------------------------------------------------------
920 * dissect_zcl_tun_attr_data
922 * this function is called by ZCL foundation dissector in order to decode
923 * specific cluster attributes data.
925 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
926 * tvbuff_t *tvb - pointer to buffer containing raw packet.
927 * guint *offset - pointer to buffer offset
928 * guint16 attr_id - attribute identifier
929 * guint data_type - attribute data type
932 *---------------------------------------------------------------
935 dissect_zcl_tun_attr_data(proto_tree *tree, tvbuff_t *tvb, guint *offset, guint16 attr_id, guint data_type)
938 /* cluster specific attributes */
939 case ZBEE_ZCL_ATTR_ID_TUN_CLOSE_TIMEOUT:
940 proto_tree_add_item(tree, hf_zbee_zcl_tun_attr_close_timeout, tvb, *offset, 2, ENC_NA);
944 /* applies to all SE clusters */
945 case ZBEE_ZCL_ATTR_ID_SE_ATTR_REPORT_STATUS:
946 proto_tree_add_item(tree, hf_zbee_zcl_tun_attr_reporting_status, tvb, *offset, 1, ENC_NA);
950 default: /* Catch all */
951 dissect_zcl_attr_data(tvb, tree, offset, data_type);
954 } /*dissect_zcl_ias_zone_attr_data*/
956 /*FUNCTION:------------------------------------------------------
958 * dissect_zcl_tun_request_tunnel
960 * This function manages the Display Message payload
962 * tvbuff_t *tvb - pointer to buffer containing raw packet.
963 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
967 *---------------------------------------------------------------
970 dissect_zcl_tun_request_tunnel(tvbuff_t *tvb, proto_tree *tree, guint *offset)
972 proto_tree_add_item(tree, hf_zbee_zcl_tun_protocol_id, tvb, *offset, 1, ENC_NA);
975 proto_tree_add_item(tree, hf_zbee_zcl_tun_manufacturer_code, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
978 proto_tree_add_item(tree, hf_zbee_zcl_tun_flow_control_support, tvb, *offset, 1, ENC_NA);
981 proto_tree_add_item(tree, hf_zbee_zcl_tun_max_in_size, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
985 /*FUNCTION:------------------------------------------------------
987 * dissect_zcl_tun_close_tunnel
989 * This function manages the Display Message payload
991 * tvbuff_t *tvb - pointer to buffer containing raw packet.
992 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
996 *---------------------------------------------------------------
999 dissect_zcl_tun_close_tunnel(tvbuff_t *tvb, proto_tree *tree, guint *offset)
1001 proto_tree_add_item(tree, hf_zbee_zcl_tun_tunnel_id, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
1005 /*FUNCTION:------------------------------------------------------
1007 * dissect_zcl_tun_transfer_data
1009 * This function manages the Display Message payload
1011 * tvbuff_t *tvb - pointer to buffer containing raw packet.
1012 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
1016 *---------------------------------------------------------------
1019 dissect_zcl_tun_transfer_data(tvbuff_t *tvb, proto_tree *tree, guint *offset)
1023 proto_tree_add_item(tree, hf_zbee_zcl_tun_tunnel_id, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
1026 length = tvb_reported_length_remaining(tvb, *offset);
1027 proto_tree_add_item(tree, hf_zbee_zcl_tun_transfer_data, tvb, *offset, length, ENC_NA);
1031 /*FUNCTION:------------------------------------------------------
1033 * dissect_zcl_tun_transfer_data_error
1035 * This function manages the Display Message payload
1037 * tvbuff_t *tvb - pointer to buffer containing raw packet.
1038 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
1042 *---------------------------------------------------------------
1045 dissect_zcl_tun_transfer_data_error(tvbuff_t *tvb, proto_tree *tree, guint *offset)
1047 proto_tree_add_item(tree, hf_zbee_zcl_tun_tunnel_id, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
1050 proto_tree_add_item(tree, hf_zbee_zcl_tun_transfer_data_status, tvb, *offset, 1, ENC_NA);
1054 /*FUNCTION:------------------------------------------------------
1056 * dissect_zcl_tun_ack_transfer_data
1058 * This function manages the Display Message payload
1060 * tvbuff_t *tvb - pointer to buffer containing raw packet.
1061 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
1065 *---------------------------------------------------------------
1068 dissect_zcl_tun_ack_transfer_data(tvbuff_t *tvb, proto_tree *tree, guint *offset)
1070 proto_tree_add_item(tree, hf_zbee_zcl_tun_tunnel_id, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
1073 proto_tree_add_item(tree, hf_zbee_zcl_tun_num_octets_left, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
1077 /*FUNCTION:------------------------------------------------------
1079 * dissect_zcl_tun_ready_data
1081 * This function manages the Display Message payload
1083 * tvbuff_t *tvb - pointer to buffer containing raw packet.
1084 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
1088 *---------------------------------------------------------------
1091 dissect_zcl_tun_ready_data(tvbuff_t *tvb, proto_tree *tree, guint *offset)
1093 proto_tree_add_item(tree, hf_zbee_zcl_tun_tunnel_id, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
1096 proto_tree_add_item(tree, hf_zbee_zcl_tun_num_octets_left, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
1100 /*FUNCTION:------------------------------------------------------
1102 * dissect_zcl_tun_get_supported
1104 * This function manages the Display Message payload
1106 * tvbuff_t *tvb - pointer to buffer containing raw packet.
1107 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
1111 *---------------------------------------------------------------
1114 dissect_zcl_tun_get_supported(tvbuff_t *tvb, proto_tree *tree, guint *offset)
1116 proto_tree_add_item(tree, hf_zbee_zcl_tun_protocol_offset, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
1120 /*FUNCTION:------------------------------------------------------
1122 * dissect_zcl_tun_request_tunnel_rsp
1124 * This function manages the Display Message payload
1126 * tvbuff_t *tvb - pointer to buffer containing raw packet.
1127 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
1131 *---------------------------------------------------------------
1134 dissect_zcl_tun_request_tunnel_rsp(tvbuff_t *tvb, proto_tree *tree, guint *offset)
1136 proto_tree_add_item(tree, hf_zbee_zcl_tun_tunnel_id, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
1139 proto_tree_add_item(tree, hf_zbee_zcl_tun_transfer_status, tvb, *offset, 1, ENC_NA);
1142 proto_tree_add_item(tree, hf_zbee_zcl_tun_max_in_size, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
1146 /*FUNCTION:------------------------------------------------------
1148 * dissect_zcl_tun_get_supported_rsp
1150 * This function manages the Display Message payload
1152 * tvbuff_t *tvb - pointer to buffer containing raw packet.
1153 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
1157 *---------------------------------------------------------------
1160 dissect_zcl_tun_get_supported_rsp(tvbuff_t *tvb, proto_tree *tree, guint *offset)
1164 proto_tree_add_item(tree, hf_zbee_zcl_tun_protocol_list_complete, tvb, *offset, 1, ENC_NA);
1167 proto_tree_add_item(tree, hf_zbee_zcl_tun_protocol_count, tvb, *offset, 1, ENC_NA);
1170 while (tvb_reported_length_remaining(tvb, *offset) > 0) {
1171 mfg_code = tvb_get_letohs(tvb, *offset);
1172 if (mfg_code == 0xFFFF) {
1173 proto_tree_add_string(tree, hf_zbee_zcl_tun_manufacturer_code, tvb, *offset, 2, "Standard Protocol (Mfg Code 0xFFFF)");
1176 proto_tree_add_item(tree, hf_zbee_zcl_tun_manufacturer_code, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
1180 proto_tree_add_item(tree, hf_zbee_zcl_tun_protocol_id, tvb, *offset, 1, ENC_NA);
1185 /*FUNCTION:------------------------------------------------------
1187 * dissect_zcl_tun_closure_notify
1189 * This function manages the Display Message payload
1191 * tvbuff_t *tvb - pointer to buffer containing raw packet.
1192 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
1196 *---------------------------------------------------------------
1199 dissect_zcl_tun_closure_notify(tvbuff_t *tvb, proto_tree *tree, guint *offset)
1201 proto_tree_add_item(tree, hf_zbee_zcl_tun_tunnel_id, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
1205 /*FUNCTION:------------------------------------------------------
1207 * dissect_zbee_zcl_tun
1209 * ZigBee ZCL Messaging cluster dissector for wireshark.
1211 * tvbuff_t *tvb - pointer to buffer containing raw packet.
1212 * packet_info *pinfo - pointer to packet information fields
1213 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
1216 *---------------------------------------------------------------
1219 dissect_zbee_zcl_tun(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
1221 proto_tree *payload_tree;
1222 zbee_zcl_packet *zcl;
1227 /* Reject the packet if data is NULL */
1230 zcl = (zbee_zcl_packet *)data;
1231 cmd_id = zcl->cmd_id;
1233 /* Create a subtree for the ZCL Command frame, and add the command ID to it. */
1234 if (zcl->direction == ZBEE_ZCL_FCF_TO_SERVER) {
1235 /* Append the command name to the info column. */
1236 col_append_fstr(pinfo->cinfo, COL_INFO, "%s, Seq: %u",
1237 val_to_str_const(cmd_id, zbee_zcl_tun_srv_rx_cmd_names, "Unknown Command"),
1240 /* Add the command ID. */
1241 proto_tree_add_item(tree, hf_zbee_zcl_tun_srv_rx_cmd_id, tvb, offset, 1, cmd_id);
1243 /* Check is this command has a payload, than add the payload tree */
1244 rem_len = tvb_reported_length_remaining(tvb, ++offset);
1246 payload_tree = proto_tree_add_subtree(tree, tvb, offset, rem_len, ett_zbee_zcl_tun, NULL, "Payload");
1248 /* Call the appropriate command dissector */
1251 case ZBEE_ZCL_CMD_ID_TUN_REQUEST_TUNNEL:
1252 dissect_zcl_tun_request_tunnel(tvb, payload_tree, &offset);
1255 case ZBEE_ZCL_CMD_ID_TUN_CLOSE_TUNNEL:
1256 dissect_zcl_tun_close_tunnel(tvb, payload_tree, &offset);
1259 case ZBEE_ZCL_CMD_ID_TUN_TRANSFER_DATA:
1260 dissect_zcl_tun_transfer_data(tvb, payload_tree, &offset);
1263 case ZBEE_ZCL_CMD_ID_TUN_TRANSFER_DATA_ERROR:
1264 dissect_zcl_tun_transfer_data_error(tvb, payload_tree, &offset);
1267 case ZBEE_ZCL_CMD_ID_TUN_ACK_TRANSFER_DATA:
1268 dissect_zcl_tun_ack_transfer_data(tvb, payload_tree, &offset);
1271 case ZBEE_ZCL_CMD_ID_TUN_READY_DATA:
1272 dissect_zcl_tun_ready_data(tvb, payload_tree, &offset);
1275 case ZBEE_ZCL_CMD_ID_TUN_GET_SUPPORTED_PROTOCOLS:
1276 dissect_zcl_tun_get_supported(tvb, payload_tree, &offset);
1284 else { /* ZBEE_ZCL_FCF_TO_CLIENT */
1285 /* Append the command name to the info column. */
1286 col_append_fstr(pinfo->cinfo, COL_INFO, "%s, Seq: %u",
1287 val_to_str_const(cmd_id, zbee_zcl_tun_srv_tx_cmd_names, "Unknown Command"),
1290 /* Add the command ID. */
1291 proto_tree_add_item(tree, hf_zbee_zcl_tun_srv_tx_cmd_id, tvb, offset, 1, cmd_id);
1293 /* Check is this command has a payload, than add the payload tree */
1294 rem_len = tvb_reported_length_remaining(tvb, ++offset);
1296 payload_tree = proto_tree_add_subtree(tree, tvb, offset, rem_len, ett_zbee_zcl_tun, NULL, "Payload");
1298 /* Call the appropriate command dissector */
1301 case ZBEE_ZCL_CMD_ID_TUN_REQUEST_TUNNEL_RSP:
1302 dissect_zcl_tun_request_tunnel_rsp(tvb, payload_tree, &offset);
1305 case ZBEE_ZCL_CMD_ID_TUN_TRANSFER_DATA_TX:
1306 dissect_zcl_tun_transfer_data(tvb, payload_tree, &offset);
1309 case ZBEE_ZCL_CMD_ID_TUN_TRANSFER_DATA_ERROR_TX:
1310 dissect_zcl_tun_transfer_data_error(tvb, payload_tree, &offset);
1313 case ZBEE_ZCL_CMD_ID_TUN_ACK_TRANSFER_DATA_TX:
1314 dissect_zcl_tun_ack_transfer_data(tvb, payload_tree, &offset);
1317 case ZBEE_ZCL_CMD_ID_TUN_READY_DATA_TX:
1318 dissect_zcl_tun_ready_data(tvb, payload_tree, &offset);
1321 case ZBEE_ZCL_CMD_ID_TUN_GET_SUPPORTED_PROTOCOLS_RSP:
1322 dissect_zcl_tun_get_supported_rsp(tvb, payload_tree, &offset);
1325 case ZBEE_ZCL_CMD_ID_TUN_CLOSURE_NOTIFY:
1326 dissect_zcl_tun_closure_notify(tvb, payload_tree, &offset);
1335 return tvb_captured_length(tvb);
1336 } /*dissect_zbee_zcl_tun*/
1338 /*FUNCTION:------------------------------------------------------
1340 * proto_register_zbee_zcl_tun
1342 * this function registers the ZCL Messaging dissector
1343 * and all its information.
1348 *---------------------------------------------------------------
1351 proto_register_zbee_zcl_tun(void)
1353 static hf_register_info hf[] = {
1355 { &hf_zbee_zcl_tun_attr_id,
1356 { "Attribute", "zbee_zcl_se.tun.attr_id", FT_UINT16, BASE_HEX, VALS(zbee_zcl_tun_attr_names),
1357 0x0, NULL, HFILL } },
1359 { &hf_zbee_zcl_tun_attr_reporting_status, /* common to all SE clusters */
1360 { "Attribute Reporting Status", "zbee_zcl_se.tun.attr.attr_reporting_status",
1361 FT_UINT8, BASE_HEX, VALS(zbee_zcl_se_reporting_status_names), 0x00, NULL, HFILL } },
1363 { &hf_zbee_zcl_tun_attr_close_timeout,
1364 { "Close Tunnel Timeout", "zbee_zcl_se.tun.attr.close_tunnel", FT_UINT16, BASE_DEC, NULL,
1365 0x0, NULL, HFILL } },
1367 { &hf_zbee_zcl_tun_srv_tx_cmd_id,
1368 { "Command", "zbee_zcl_se.tun.cmd.srv_tx.id", FT_UINT8, BASE_HEX, VALS(zbee_zcl_tun_srv_tx_cmd_names),
1369 0x00, NULL, HFILL } },
1371 { &hf_zbee_zcl_tun_srv_rx_cmd_id,
1372 { "Command", "zbee_zcl_se.tun.cmd.srv_rx.id", FT_UINT8, BASE_HEX, VALS(zbee_zcl_tun_srv_rx_cmd_names),
1373 0x00, NULL, HFILL } },
1375 { &hf_zbee_zcl_tun_protocol_id,
1376 { "Protocol ID", "zbee_zcl_se.tun.protocol_id", FT_UINT8, BASE_HEX, VALS(zbee_zcl_tun_protocol_names),
1377 0x00, NULL, HFILL } },
1379 { &hf_zbee_zcl_tun_manufacturer_code,
1380 { "Manufacturer Code", "zbee_zcl_se.tun.manufacturer_code", FT_UINT16, BASE_HEX, VALS(zbee_mfr_code_names),
1381 0x00, NULL, HFILL } },
1383 { &hf_zbee_zcl_tun_flow_control_support,
1384 { "Flow Control Supported", "zbee_zcl_se.tun.flow_control_supported", FT_BOOLEAN, 8, TFS(&tfs_true_false),
1385 0x00, NULL, HFILL } },
1387 { &hf_zbee_zcl_tun_max_in_size,
1388 { "Max Incoming Transfer Size", "zbee_zcl_se.tun.max_in_transfer_size", FT_UINT16, BASE_HEX, NULL,
1389 0x00, NULL, HFILL } },
1391 { &hf_zbee_zcl_tun_tunnel_id,
1392 { "Tunnel Id", "zbee_zcl_se.tun.tunnel_id", FT_UINT16, BASE_HEX, NULL,
1393 0x00, NULL, HFILL } },
1395 { &hf_zbee_zcl_tun_num_octets_left,
1396 { "Num Octets Left", "zbee_zcl_se.tun.octets_left", FT_UINT16, BASE_HEX, NULL,
1397 0x00, NULL, HFILL } },
1399 { &hf_zbee_zcl_tun_protocol_offset,
1400 { "Protocol Offset", "zbee_zcl_se.tun.protocol_offset", FT_UINT8, BASE_HEX, NULL,
1401 0x00, NULL, HFILL } },
1403 { &hf_zbee_zcl_tun_transfer_status,
1404 { "Transfer Status", "zbee_zcl_se.tun.transfer_status", FT_UINT8, BASE_HEX, VALS(zbee_zcl_tun_status_names),
1405 0x00, NULL, HFILL } },
1407 { &hf_zbee_zcl_tun_transfer_data,
1408 { "Transfer Data", "zbee_zcl_se.tun.transfer_data", FT_BYTES, BASE_NONE, NULL,
1411 { &hf_zbee_zcl_tun_transfer_data_status,
1412 { "Transfer Data Status", "zbee_zcl_se.tun.transfer_data_status", FT_UINT8, BASE_HEX, VALS(zbee_zcl_tun_trans_data_status_names),
1413 0x00, NULL, HFILL } },
1415 { &hf_zbee_zcl_tun_protocol_count,
1416 { "Protocol Count", "zbee_zcl_se.tun.protocol_count", FT_UINT8, BASE_HEX, NULL,
1417 0x00, NULL, HFILL } },
1419 { &hf_zbee_zcl_tun_protocol_list_complete,
1420 { "List Complete", "zbee_zcl_se.tun.protocol_list_complete", FT_BOOLEAN, 8, TFS(&tfs_true_false),
1421 0x00, NULL, HFILL } },
1425 /* ZCL Messaging subtrees */
1430 /* Register the ZigBee ZCL Messaging cluster protocol name and description */
1431 proto_zbee_zcl_tun = proto_register_protocol("ZigBee ZCL Tunneling", "ZCL Tunneling", ZBEE_PROTOABBREV_ZCL_TUN);
1432 proto_register_field_array(proto_zbee_zcl_tun, hf, array_length(hf));
1433 proto_register_subtree_array(ett, array_length(ett));
1435 /* Register the ZigBee ZCL Messaging dissector. */
1436 new_register_dissector(ZBEE_PROTOABBREV_ZCL_TUN, dissect_zbee_zcl_tun, proto_zbee_zcl_tun);
1438 } /* proto_register_zbee_zcl_tun */
1440 /*FUNCTION:------------------------------------------------------
1442 * proto_reg_handoff_zbee_zcl_tun
1444 * Hands off the Zcl Messaging dissector.
1449 *---------------------------------------------------------------
1452 proto_reg_handoff_zbee_zcl_tun(void)
1454 dissector_handle_t msg_handle;
1456 ipv4_handle = find_dissector("ipv4");
1457 ipv6_handle = find_dissector("ipv6");
1459 /* Register our dissector with the ZigBee application dissectors. */
1460 msg_handle = find_dissector(ZBEE_PROTOABBREV_ZCL_TUN);
1461 dissector_add_uint("zbee.zcl.cluster", ZBEE_ZCL_CID_TUNNELING, msg_handle);
1463 zbee_zcl_init_cluster( proto_zbee_zcl_tun,
1465 ZBEE_ZCL_CID_TUNNELING,
1466 hf_zbee_zcl_tun_attr_id,
1467 hf_zbee_zcl_tun_srv_rx_cmd_id,
1468 hf_zbee_zcl_tun_srv_tx_cmd_id,
1469 (zbee_zcl_fn_attr_data)dissect_zcl_tun_attr_data
1471 } /* proto_reg_handoff_zbee_zcl_tun */
1473 /* ########################################################################## */
1474 /* #### (0x0800) KEY ESTABLISHMENT ########################################## */
1475 /* ########################################################################## */
1477 /*************************/
1479 /*************************/
1481 /* Initialize the subtree pointers */
1482 static gint ett_zbee_zcl_ke = -1;
1483 static gint ett_zbee_zcl_ke_cert = -1;
1484 static gint ett_zbee_zcl_ke_key_usage = -1;
1487 #define ZBEE_ZCL_ATTR_ID_KE_SUITE 0x0000 /* Key Establishment Suite */
1489 /*************************/
1490 /* Function Declarations */
1491 /*************************/
1493 void proto_register_zbee_zcl_ke(void);
1494 void proto_reg_handoff_zbee_zcl_ke(void);
1496 /* Private functions prototype */
1498 /*************************/
1499 /* Global Variables */
1500 /*************************/
1502 /* Initialize the protocol and registered fields */
1503 static int proto_zbee_zcl_ke = -1;
1504 static int hf_zbee_zcl_ke_srv_tx_cmd_id = -1;
1505 static int hf_zbee_zcl_ke_srv_rx_cmd_id = -1;
1506 static int hf_zbee_zcl_ke_attr_id = -1;
1507 static int hf_zbee_zcl_ke_suite = -1;
1508 static int hf_zbee_zcl_ke_ephemeral_time = -1;
1509 static int hf_zbee_zcl_ke_confirm_time = -1;
1510 static int hf_zbee_zcl_ke_status = -1;
1511 static int hf_zbee_zcl_ke_wait_time = -1;
1512 static int hf_zbee_zcl_ke_cert_reconstr = -1;
1513 static int hf_zbee_zcl_ke_cert_subject = -1;
1514 static int hf_zbee_zcl_ke_cert_issuer = -1;
1515 static int hf_zbee_zcl_ke_cert_profile_attr = -1;
1516 static int hf_zbee_zcl_ke_cert_type = -1;
1517 static int hf_zbee_zcl_ke_cert_serialno = -1;
1518 static int hf_zbee_zcl_ke_cert_curve = -1;
1519 static int hf_zbee_zcl_ke_cert_hash = -1;
1520 static int hf_zbee_zcl_ke_cert_valid_from = -1;
1521 static int hf_zbee_zcl_ke_cert_valid_to = -1;
1522 static int hf_zbee_zcl_ke_cert_key_usage_agreement = -1;
1523 static int hf_zbee_zcl_ke_cert_key_usage_signature = -1;
1524 static int hf_zbee_zcl_ke_ephemeral_qeu = -1;
1525 static int hf_zbee_zcl_ke_ephemeral_qev = -1;
1526 static int hf_zbee_zcl_ke_macu = -1;
1527 static int hf_zbee_zcl_ke_macv = -1;
1529 /* Server Commands Received and Generates (symmetrical) */
1530 #define ZBEE_ZCL_CMD_ID_KE_INITIATE 0x00 /* Initiate Key Establishment */
1531 #define ZBEE_ZCL_CMD_ID_KE_EPHEMERAL 0x01 /* Ephemeral Data Request */
1532 #define ZBEE_ZCL_CMD_ID_KE_CONFIRM 0x02 /* Confirm Key Data Request */
1533 #define ZBEE_ZCL_CMD_ID_KE_TERMINATE 0x03 /* Terminate Key Establishment */
1535 #define ZBEE_ZCL_KE_SUITE_1 0x0001
1536 #define ZBEE_ZCL_KE_SUITE_2 0x0002
1538 #define ZBEE_ZCL_KE_TYPE_NO_EXT 0x00 /* no extensions were used */
1540 #define ZBEE_ZCL_KE_CURVE_SECT283K1 0x0D
1542 #define ZBEE_ZCL_KE_HASH_AES_MMO 0x08
1544 #define ZBEE_ZCL_KE_USAGE_KEY_AGREEMENT 0x08
1545 #define ZBEE_ZCL_KE_USAGE_DIGITAL_SIGNATURE 0x80
1548 static const value_string zbee_zcl_ke_attr_names[] = {
1549 { ZBEE_ZCL_ATTR_ID_KE_SUITE, "Supported Key Establishment Suites" },
1553 /* Server Commands Received and Generated */
1554 static const value_string zbee_zcl_ke_srv_cmd_names[] = {
1555 { ZBEE_ZCL_CMD_ID_KE_INITIATE, "Initiate Key Establishment" },
1556 { ZBEE_ZCL_CMD_ID_KE_EPHEMERAL, "Ephemeral Data" },
1557 { ZBEE_ZCL_CMD_ID_KE_CONFIRM, "Confirm Key Data" },
1558 { ZBEE_ZCL_CMD_ID_KE_TERMINATE, "Terminate Key Establishment" },
1563 static const value_string zbee_zcl_ke_suite_names[] = {
1564 { ZBEE_ZCL_KE_SUITE_1, "Crypto Suite 1 (CBKE K163)" },
1565 { ZBEE_ZCL_KE_SUITE_2, "Crypto Suite 2 (CBKE K283)" },
1569 /* Crypto Suite 2 Type Names */
1570 static const value_string zbee_zcl_ke_type_names[] = {
1571 { ZBEE_ZCL_KE_TYPE_NO_EXT, "No Extensions" },
1575 /* Crypto Suite 2 Curve Names */
1576 static const value_string zbee_zcl_ke_curve_names[] = {
1577 { ZBEE_ZCL_KE_CURVE_SECT283K1, "sect283k1" },
1581 /* Crypto Suite 2 Hash Names */
1582 static const value_string zbee_zcl_ke_hash_names[] = {
1583 { ZBEE_ZCL_KE_HASH_AES_MMO, "AES MMO" },
1587 #define ZBEE_ZCL_KE_STATUS_RESERVED 0x00
1588 #define ZBEE_ZCL_KE_STATUS_UNKNOWN_ISSUER 0x01
1589 #define ZBEE_ZCL_KE_STATUS_BAD_KEY_CONFIRM 0x02
1590 #define ZBEE_ZCL_KE_STATUS_BAD_MESSAGE 0x03
1591 #define ZBEE_ZCL_KE_STATUS_NO_RESOURCES 0x04
1592 #define ZBEE_ZCL_KE_STATUS_UNSUPPORTED_SUITE 0x05
1593 #define ZBEE_ZCL_KE_STATUS_INVALID_CERTIFICATE 0x06
1595 static const value_string zbee_zcl_ke_status_names[] = {
1596 { ZBEE_ZCL_KE_STATUS_RESERVED, "Reserved" },
1597 { ZBEE_ZCL_KE_STATUS_UNKNOWN_ISSUER, "Unknown Issuer"},
1598 { ZBEE_ZCL_KE_STATUS_BAD_KEY_CONFIRM, "Bad Key Confirm"},
1599 { ZBEE_ZCL_KE_STATUS_BAD_MESSAGE, "Bad Message"},
1600 { ZBEE_ZCL_KE_STATUS_NO_RESOURCES, "No Resources"},
1601 { ZBEE_ZCL_KE_STATUS_UNSUPPORTED_SUITE, "Unsupported Suite"},
1602 { ZBEE_ZCL_KE_STATUS_INVALID_CERTIFICATE, "Invalid Certificate"},
1606 /*************************/
1607 /* Function Bodies */
1608 /*************************/
1611 /*FUNCTION:------------------------------------------------------
1613 * dissect_zcl_ke_suite1_certificate
1615 * This function dissects the Suite 1 Certificate
1617 * tvbuff_t *tvb - pointer to buffer containing raw packet.
1618 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
1622 *---------------------------------------------------------------
1625 dissect_zcl_ke_suite1_certificate(tvbuff_t *tvb, proto_tree *tree, guint *offset)
1627 proto_tree_add_item(tree, hf_zbee_zcl_ke_cert_reconstr, tvb, *offset, 22, ENC_NA);
1630 proto_tree_add_item(tree, hf_zbee_zcl_ke_cert_subject, tvb, *offset, 8, ENC_NA);
1633 proto_tree_add_item(tree, hf_zbee_zcl_ke_cert_issuer, tvb, *offset, 8, ENC_NA);
1636 proto_tree_add_item(tree, hf_zbee_zcl_ke_cert_profile_attr, tvb, *offset, 10, ENC_NA);
1639 } /*dissect_zcl_ke_suite1_certificate*/
1641 /*FUNCTION:------------------------------------------------------
1643 * dissect_zcl_ke_suite2_certificate
1645 * This function dissects the Suite 2 Certificate
1647 * tvbuff_t *tvb - pointer to buffer containing raw packet.
1648 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
1652 *---------------------------------------------------------------
1655 dissect_zcl_ke_suite2_certificate(tvbuff_t *tvb, proto_tree *tree, guint *offset)
1657 nstime_t valid_from_time;
1658 nstime_t valid_to_time;
1661 proto_tree *usage_tree;
1663 proto_tree_add_item(tree, hf_zbee_zcl_ke_cert_type, tvb, *offset, 1, ENC_NA);
1666 proto_tree_add_item(tree, hf_zbee_zcl_ke_cert_serialno, tvb, *offset, 8, ENC_NA);
1669 proto_tree_add_item(tree, hf_zbee_zcl_ke_cert_curve, tvb, *offset, 1, ENC_NA);
1672 proto_tree_add_item(tree, hf_zbee_zcl_ke_cert_hash, tvb, *offset, 1, ENC_NA);
1675 proto_tree_add_item(tree, hf_zbee_zcl_ke_cert_issuer, tvb, *offset, 8, ENC_NA);
1678 valid_from_time.secs = (time_t)tvb_get_ntoh40(tvb, *offset);
1679 valid_from_time.nsecs = 0;
1680 proto_tree_add_time(tree, hf_zbee_zcl_ke_cert_valid_from, tvb, *offset, 5, &valid_from_time);
1683 valid_to = tvb_get_ntohl(tvb, *offset);
1684 if (valid_to == 0xFFFFFFFF) {
1685 proto_tree_add_time_format(tree, hf_zbee_zcl_ke_cert_valid_to, tvb, *offset, 4, &valid_to_time, "Valid To: does not expire (0xFFFFFFFF)");
1688 valid_to_time.secs = valid_from_time.secs + valid_to;
1689 valid_to_time.nsecs = 0;
1690 proto_tree_add_time(tree, hf_zbee_zcl_ke_cert_valid_to, tvb, *offset, 4, &valid_to_time);
1694 proto_tree_add_item(tree, hf_zbee_zcl_ke_cert_subject, tvb, *offset, 8, ENC_NA);
1697 key_usage = tvb_get_guint8(tvb, *offset);
1698 usage_tree = proto_tree_add_subtree_format(tree, tvb, *offset, 1, ett_zbee_zcl_ke_key_usage, NULL, "Key Usage (0x%02x)", key_usage);
1700 proto_tree_add_item(usage_tree, hf_zbee_zcl_ke_cert_key_usage_agreement, tvb, *offset, 1, ENC_NA);
1701 proto_tree_add_item(usage_tree, hf_zbee_zcl_ke_cert_key_usage_signature, tvb, *offset, 1, ENC_NA);
1704 proto_tree_add_item(tree, hf_zbee_zcl_ke_cert_reconstr, tvb, *offset, 37, ENC_NA);
1707 } /*dissect_zcl_ke_suite2_certificate*/
1709 /*FUNCTION:------------------------------------------------------
1711 * dissect_zcl_ke_initiate_req
1713 * This function manages the Initiate Key Establishment message
1715 * tvbuff_t *tvb - pointer to buffer containing raw packet.
1716 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
1720 *---------------------------------------------------------------
1723 dissect_zcl_ke_initiate(tvbuff_t *tvb, proto_tree *tree, guint *offset)
1726 proto_tree *subtree;
1729 suite = tvb_get_letohs(tvb, *offset);
1731 proto_tree_add_item(tree, hf_zbee_zcl_ke_suite, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
1734 proto_tree_add_item(tree, hf_zbee_zcl_ke_ephemeral_time, tvb, *offset, 1, ENC_NA);
1737 proto_tree_add_item(tree, hf_zbee_zcl_ke_confirm_time, tvb, *offset, 1, ENC_NA);
1740 rem_len = tvb_reported_length_remaining(tvb, *offset);
1741 subtree = proto_tree_add_subtree(tree, tvb, *offset, rem_len, ett_zbee_zcl_ke_cert, NULL, "Implicit Certificate");
1744 case ZBEE_ZCL_KE_SUITE_1:
1745 dissect_zcl_ke_suite1_certificate(tvb, subtree, offset);
1748 case ZBEE_ZCL_KE_SUITE_2:
1749 dissect_zcl_ke_suite2_certificate(tvb, subtree, offset);
1755 } /* dissect_zcl_ke_initiate */
1757 /*FUNCTION:------------------------------------------------------
1759 * dissect_zcl_ke_ephemeral_qeu
1761 * This function dissects the Ephemeral Data QEU
1763 * tvbuff_t *tvb - pointer to buffer containing raw packet.
1764 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
1768 *---------------------------------------------------------------
1771 dissect_zcl_ke_ephemeral_qeu(tvbuff_t *tvb, proto_tree *tree, guint *offset)
1775 /* size depends on suite but without a session we don't know that here */
1776 /* so just report what we have */
1777 length = tvb_reported_length_remaining(tvb, *offset);
1778 proto_tree_add_item(tree, hf_zbee_zcl_ke_ephemeral_qeu, tvb, *offset, length, ENC_NA);
1780 return tvb_captured_length(tvb);
1783 /*FUNCTION:------------------------------------------------------
1785 * dissect_zcl_ke_ephemeral_qev
1787 * This function dissects the Ephemeral Data QEV
1789 * tvbuff_t *tvb - pointer to buffer containing raw packet.
1790 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
1794 *---------------------------------------------------------------
1797 dissect_zcl_ke_ephemeral_qev(tvbuff_t *tvb, proto_tree *tree, guint *offset)
1801 /* size depends on suite but without a session we don't know that here */
1802 /* so just report what we have */
1803 length = tvb_reported_length_remaining(tvb, *offset);
1804 proto_tree_add_item(tree, hf_zbee_zcl_ke_ephemeral_qev, tvb, *offset, length, ENC_NA);
1806 return tvb_captured_length(tvb);
1809 /*FUNCTION:------------------------------------------------------
1811 * dissect_zcl_ke_confirm_macu
1813 * This function dissects the Confirm MACU
1815 * tvbuff_t *tvb - pointer to buffer containing raw packet.
1816 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
1820 *---------------------------------------------------------------
1823 dissect_zcl_ke_confirm_macu(tvbuff_t *tvb, proto_tree *tree, guint *offset)
1825 proto_tree_add_item(tree, hf_zbee_zcl_ke_macu, tvb, *offset, ZBEE_SEC_CONST_BLOCKSIZE, ENC_NA);
1826 *offset += ZBEE_SEC_CONST_BLOCKSIZE;
1827 return tvb_captured_length(tvb);
1830 /*FUNCTION:------------------------------------------------------
1832 * dissect_zcl_ke_confirm_macv
1834 * This function dissects the Confirm MACV
1836 * tvbuff_t *tvb - pointer to buffer containing raw packet.
1837 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
1841 *---------------------------------------------------------------
1844 dissect_zcl_ke_confirm_macv(tvbuff_t *tvb, proto_tree *tree, guint *offset)
1846 proto_tree_add_item(tree, hf_zbee_zcl_ke_macv, tvb, *offset, ZBEE_SEC_CONST_BLOCKSIZE, ENC_NA);
1847 *offset += ZBEE_SEC_CONST_BLOCKSIZE;
1848 return tvb_captured_length(tvb);
1851 /*FUNCTION:------------------------------------------------------
1853 * dissect_zcl_ke_terminate
1855 * This function dissects the Terminate Key Establishment message
1857 * tvbuff_t *tvb - pointer to buffer containing raw packet.
1858 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
1862 *---------------------------------------------------------------
1865 dissect_zcl_ke_terminate(tvbuff_t *tvb, proto_tree *tree, guint *offset)
1867 proto_tree_add_item(tree, hf_zbee_zcl_ke_status, tvb, *offset, 1, ENC_NA);
1870 proto_tree_add_item(tree, hf_zbee_zcl_ke_wait_time, tvb, *offset, 1, ENC_NA);
1873 proto_tree_add_item(tree, hf_zbee_zcl_ke_suite, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
1877 /*FUNCTION:------------------------------------------------------
1879 * dissect_zbee_zcl_ke
1881 * ZigBee ZCL Key Establishment cluster dissector for wireshark.
1883 * tvbuff_t *tvb - pointer to buffer containing raw packet.
1884 * packet_info *pinfo - pointer to packet information fields
1885 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
1888 *---------------------------------------------------------------
1891 dissect_zbee_zcl_ke(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
1893 zbee_zcl_packet *zcl;
1898 /* Reject the packet if data is NULL */
1901 zcl = (zbee_zcl_packet *)data;
1902 cmd_id = zcl->cmd_id;
1904 /* Create a subtree for the ZCL Command frame, and add the command ID to it. */
1905 if (zcl->direction == ZBEE_ZCL_FCF_TO_SERVER) {
1906 /* Append the command name to the info column. */
1907 col_append_fstr(pinfo->cinfo, COL_INFO, "%s, Seq: %u",
1908 val_to_str_const(cmd_id, zbee_zcl_ke_srv_cmd_names, "Unknown Command"),
1911 /* Add the command ID. */
1912 proto_tree_add_item(tree, hf_zbee_zcl_ke_srv_rx_cmd_id, tvb, offset, 1, cmd_id);
1914 /* Check is this command has a payload, than add the payload tree */
1915 rem_len = tvb_reported_length_remaining(tvb, offset);
1916 offset += 1; /* delay from last add_item */
1919 /* Call the appropriate command dissector */
1921 case ZBEE_ZCL_CMD_ID_KE_INITIATE:
1922 dissect_zcl_ke_initiate(tvb, tree, &offset);
1925 case ZBEE_ZCL_CMD_ID_KE_EPHEMERAL:
1926 return dissect_zcl_ke_ephemeral_qeu(tvb, tree, &offset);
1928 case ZBEE_ZCL_CMD_ID_KE_CONFIRM:
1929 return dissect_zcl_ke_confirm_macu(tvb, tree, &offset);
1931 case ZBEE_ZCL_CMD_ID_KE_TERMINATE:
1932 dissect_zcl_ke_terminate(tvb, tree, &offset);
1940 else { /* ZBEE_ZCL_FCF_TO_CLIENT */
1941 /* Append the command name to the info column. */
1942 col_append_fstr(pinfo->cinfo, COL_INFO, "%s, Seq: %u",
1943 val_to_str_const(cmd_id, zbee_zcl_ke_srv_cmd_names, "Unknown Command"),
1946 /* Add the command ID. */
1947 proto_tree_add_item(tree, hf_zbee_zcl_ke_srv_tx_cmd_id, tvb, offset, 1, cmd_id);
1949 /* Check is this command has a payload, than add the payload tree */
1950 rem_len = tvb_reported_length_remaining(tvb, ++offset);
1952 /* Call the appropriate command dissector */
1954 case ZBEE_ZCL_CMD_ID_KE_INITIATE:
1955 dissect_zcl_ke_initiate(tvb, tree, &offset);
1958 case ZBEE_ZCL_CMD_ID_KE_EPHEMERAL:
1959 return dissect_zcl_ke_ephemeral_qev(tvb, tree, &offset);
1961 case ZBEE_ZCL_CMD_ID_KE_CONFIRM:
1962 return dissect_zcl_ke_confirm_macv(tvb, tree, &offset);
1964 case ZBEE_ZCL_CMD_ID_KE_TERMINATE:
1965 dissect_zcl_ke_terminate(tvb, tree, &offset);
1974 return tvb_captured_length(tvb);
1975 } /*dissect_zbee_zcl_ke*/
1978 /*FUNCTION:------------------------------------------------------
1980 * proto_register_zbee_zcl_ke
1982 * this function registers the ZCL Messaging dissector
1983 * and all its information.
1988 *---------------------------------------------------------------
1991 proto_register_zbee_zcl_ke(void)
1993 static hf_register_info hf[] = {
1995 { &hf_zbee_zcl_ke_attr_id,
1996 { "Attribute", "zbee_zcl_se.ke.attr_id", FT_UINT16, BASE_HEX, VALS(zbee_zcl_ke_attr_names),
1997 0x00, NULL, HFILL } },
1999 { &hf_zbee_zcl_ke_srv_tx_cmd_id,
2000 { "Command", "zbee_zcl_se.ke.cmd.srv_tx.id", FT_UINT8, BASE_HEX, VALS(zbee_zcl_ke_srv_cmd_names),
2001 0x00, NULL, HFILL } },
2003 { &hf_zbee_zcl_ke_srv_rx_cmd_id,
2004 { "Command", "zbee_zcl_se.ke.cmd.srv_rx.id", FT_UINT8, BASE_HEX, VALS(zbee_zcl_ke_srv_cmd_names),
2005 0x00, NULL, HFILL } },
2007 { &hf_zbee_zcl_ke_suite,
2008 { "Key Establishment Suite", "zbee_zcl_se.ke.attr.suite", FT_UINT16, BASE_HEX, VALS(zbee_zcl_ke_suite_names),
2009 0x00, NULL, HFILL } },
2011 { &hf_zbee_zcl_ke_ephemeral_time,
2012 { "Ephemeral Data Generate Time", "zbee_zcl_se.ke.init.ephemeral.time", FT_UINT8, BASE_DEC, NULL,
2015 { &hf_zbee_zcl_ke_confirm_time,
2016 { "Confirm Key Generate Time", "zbee_zcl_se.ke.init.confirm.time", FT_UINT8, BASE_DEC, NULL,
2019 { &hf_zbee_zcl_ke_status,
2020 { "Status", "zbee_zcl_se.ke.terminate.status", FT_UINT8, BASE_HEX, VALS(zbee_zcl_ke_status_names),
2021 0x00, NULL, HFILL } },
2023 { &hf_zbee_zcl_ke_wait_time,
2024 { "Wait Time", "zbee_zcl_se.ke.terminate.wait.time", FT_UINT8, BASE_DEC, NULL,
2027 { &hf_zbee_zcl_ke_cert_reconstr,
2028 { "Public Key", "zbee_zcl_se.ke.cert.reconst", FT_BYTES, BASE_NONE, NULL,
2031 { &hf_zbee_zcl_ke_cert_subject,
2032 { "Subject", "zbee_zcl_se.ke.cert.subject", FT_BYTES, BASE_NONE, NULL,
2035 { &hf_zbee_zcl_ke_cert_issuer,
2036 { "Issuer", "zbee_zcl_se.ke.cert.issuer", FT_BYTES, BASE_NONE, NULL,
2039 { &hf_zbee_zcl_ke_cert_profile_attr,
2040 { "Profile Attribute Data", "zbee_zcl_se.ke.cert.profile", FT_BYTES, BASE_NONE, NULL,
2043 { &hf_zbee_zcl_ke_cert_type,
2044 { "Type", "zbee_zcl_se.ke.cert.type", FT_UINT8, BASE_HEX, VALS(zbee_zcl_ke_type_names),
2047 { &hf_zbee_zcl_ke_cert_serialno,
2048 { "Serial No", "zbee_zcl_se.ke.cert.type", FT_UINT64, BASE_HEX, NULL,
2051 { &hf_zbee_zcl_ke_cert_curve,
2052 { "Curve", "zbee_zcl_se.ke.cert.curve", FT_UINT8, BASE_HEX, VALS(zbee_zcl_ke_curve_names),
2055 { &hf_zbee_zcl_ke_cert_hash,
2056 { "Hash", "zbee_zcl_se.ke.cert.hash", FT_UINT8, BASE_HEX, VALS(zbee_zcl_ke_hash_names),
2059 { &hf_zbee_zcl_ke_cert_valid_from,
2060 { "Valid From", "zbee_zcl_se.ke.cert.valid.from", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_UTC, NULL,
2063 { &hf_zbee_zcl_ke_cert_valid_to,
2064 { "Valid To", "zbee_zcl_se.ke.cert.valid.to", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_UTC, NULL,
2067 { &hf_zbee_zcl_ke_cert_key_usage_agreement,
2068 { "Key Agreement", "zbee_zcl_se.ke.cert.key.usage.agreement", FT_BOOLEAN, 8, TFS(&tfs_enabled_disabled),
2069 ZBEE_ZCL_KE_USAGE_KEY_AGREEMENT, NULL, HFILL }},
2071 { &hf_zbee_zcl_ke_cert_key_usage_signature,
2072 { "Digital Signature", "zbee_zcl_se.ke.cert.key.usage.signature", FT_BOOLEAN, 8, TFS(&tfs_enabled_disabled),
2073 ZBEE_ZCL_KE_USAGE_DIGITAL_SIGNATURE, NULL, HFILL }},
2075 { &hf_zbee_zcl_ke_ephemeral_qeu,
2076 { "Ephemeral Data (QEU)", "zbee_zcl_se.ke.qeu", FT_BYTES, BASE_NONE, NULL,
2079 { &hf_zbee_zcl_ke_ephemeral_qev,
2080 { "Ephemeral Data (QEV)", "zbee_zcl_se.ke.qev", FT_BYTES, BASE_NONE, NULL,
2083 { &hf_zbee_zcl_ke_macu,
2084 { "Message Authentication Code (MACU)", "zbee_zcl_se.ke.macu", FT_BYTES, BASE_NONE, NULL,
2087 { &hf_zbee_zcl_ke_macv,
2088 { "Message Authentication Code (MACV)", "zbee_zcl_se.ke.macv", FT_BYTES, BASE_NONE, NULL,
2095 &ett_zbee_zcl_ke_cert,
2096 &ett_zbee_zcl_ke_key_usage,
2099 /* Register the ZigBee ZCL Messaging cluster protocol name and description */
2100 proto_zbee_zcl_ke = proto_register_protocol("ZigBee ZCL Key Establishment", "ZCL Key Establishment", ZBEE_PROTOABBREV_ZCL_KE);
2101 proto_register_field_array(proto_zbee_zcl_ke, hf, array_length(hf));
2102 proto_register_subtree_array(ett, array_length(ett));
2104 /* Register the ZigBee ZCL Messaging dissector. */
2105 new_register_dissector(ZBEE_PROTOABBREV_ZCL_KE, dissect_zbee_zcl_ke, proto_zbee_zcl_ke);
2106 } /*proto_register_zbee_zcl_ke*/
2108 /*FUNCTION:------------------------------------------------------
2110 * proto_reg_handoff_zbee_zcl_ke
2112 * Hands off the Zcl Key Establishment dissector.
2117 *---------------------------------------------------------------
2120 proto_reg_handoff_zbee_zcl_ke(void)
2122 dissector_handle_t ke_handle;
2124 /* Register our dissector with the ZigBee application dissectors. */
2125 ke_handle = find_dissector(ZBEE_PROTOABBREV_ZCL_KE);
2126 dissector_add_uint("zbee.zcl.cluster", ZBEE_ZCL_CID_KE, ke_handle);
2128 zbee_zcl_init_cluster( proto_zbee_zcl_ke,
2131 hf_zbee_zcl_ke_attr_id,
2132 hf_zbee_zcl_ke_srv_rx_cmd_id,
2133 hf_zbee_zcl_ke_srv_tx_cmd_id,
2136 } /*proto_reg_handoff_zbee_zcl_ke*/
2139 * Editor modelines - http://www.wireshark.org/tools/modelines.html
2144 * indent-tabs-mode: nil
2147 * vi: set shiftwidth=4 tabstop=8 expandtab:
2148 * :indentSize=4:tabSize=8:noTabs=true: