Revert "Fixup: tvb_* -> tvb_captured"
[metze/wireshark/wip.git] / epan / dissectors / packet-zbee-zcl-se.c
1 /* packet-zbee-zcl-ha.c
2  * Dissector routines for the ZigBee ZCL SE clusters like
3  * Messaging
4  * By Fabio Tarabelloni <fabio.tarabelloni@reloc.it>
5  * Copyright 2013 RELOC s.r.l.
6  *
7  * Wireshark - Network traffic analyzer
8  * By Gerald Combs <gerald@wireshark.org>
9  * Copyright 1998 Gerald Combs
10  *
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.
15  *
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.
20  *
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.
24  */
25
26 /*  Include Files */
27 #include "config.h"
28
29 #include <string.h>
30 #include <glib.h>
31 #include <epan/packet.h>
32 #include <epan/to_str.h>
33
34 #include "packet-zbee.h"
35 #include "packet-zbee-aps.h"
36 #include "packet-zbee-zcl.h"
37
38 /* ########################################################################## */
39 /* #### (0x0703) MESSAGING CLUSTER ########################################## */
40 /* ########################################################################## */
41
42 /*************************/
43 /* Defines               */
44 /*************************/
45
46 #define ZBEE_ZCL_MSG_NUM_GENERIC_ETT                   2
47 #define ZBEE_ZCL_MSG_NUM_ETT                           (ZBEE_ZCL_MSG_NUM_GENERIC_ETT)
48
49 /* Attributes - None */
50
51 /* Server Commands Received */
52 #define ZBEE_ZCL_CMD_ID_MSG_GET_LAST_MSG                0x00  /* Get Last Message */
53 #define ZBEE_ZCL_CMD_ID_MSG_MSG_CONFIRM                 0x01  /* Message Confirmation */
54
55 /* Server Commands Generated */
56 #define ZBEE_ZCL_CMD_ID_MSG_DISPLAY_MSG                 0x00  /* Display Message */
57 #define ZBEE_ZCL_CMD_ID_MSG_CANCEL_MSG                  0x01  /* Cancel Message */
58
59 /* Message Control Field Bit Map */
60 #define ZBEE_ZCL_MSG_CTRL_TX_MASK                       0x03
61 #define ZBEE_ZCL_MSG_CTRL_IMPORTANCE_MASK               0x0C
62 #define ZBEE_ZCL_MSG_CTRL_RESERVED_MASK                 0x70
63 #define ZBEE_ZCL_MSG_CTRL_CONFIRM_MASK                  0x80
64
65 #define ZBEE_ZCL_MSG_CTRL_TX_NORMAL_ONLY                0x00 /* Normal Transmission Only */
66 #define ZBEE_ZCL_MSG_CTRL_TX_NORMAL_ANON_INTERPAN       0x01 /* Normal and Anonymous Inter-PAN Transmission Only */
67 #define ZBEE_ZCL_MSG_CTRL_TX_ANON_INTERPAN_ONLY         0x02 /* Anonymous Inter-PAN Transmission Only */
68
69 #define ZBEE_ZCL_MSG_CTRL_IMPORTANCE_LOW                0x00 /* Low */
70 #define ZBEE_ZCL_MSG_CTRL_IMPORTANCE_MEDIUM             0x01 /* Medium */
71 #define ZBEE_ZCL_MSG_CTRL_IMPORTANCE_HIGH               0x02 /* High */
72 #define ZBEE_ZCL_MSG_CTRL_IMPORTANCE_CRITICAL           0x03 /* Critical */
73
74 #define ZBEE_ZCL_MSG_START_TIME_NOW                     0x00000000 /* Now */
75
76 /*************************/
77 /* Function Declarations */
78 /*************************/
79 void proto_register_zbee_zcl_msg(void);
80 void proto_reg_handoff_zbee_zcl_msg(void);
81
82 /* Command Dissector Helpers */
83 static void dissect_zcl_msg_display             (tvbuff_t *tvb, proto_tree *tree, guint *offset);
84 static void dissect_zcl_msg_cancel              (tvbuff_t *tvb, proto_tree *tree, guint *offset);
85 static void dissect_zcl_msg_confirm             (tvbuff_t *tvb, proto_tree *tree, guint *offset);
86 static void dissect_zcl_msg_cmd_id              (proto_tree *tree, tvbuff_t *tvb, guint *offset, guint8 cmd_dir);
87
88 /* Private functions prototype */
89 static void decode_zcl_msg_duration             (gchar *s, guint16 value);
90
91 /*************************/
92 /* Global Variables      */
93 /*************************/
94
95 /* Initialize the protocol and registered fields */
96 static int proto_zbee_zcl_msg = -1;
97
98 static int hf_zbee_zcl_msg_srv_tx_cmd_id = -1;
99 static int hf_zbee_zcl_msg_srv_rx_cmd_id = -1;
100 static int hf_zbee_zcl_msg_message_id = -1;
101 static int hf_zbee_zcl_msg_ctrl_tx = -1;
102 static int hf_zbee_zcl_msg_ctrl_importance = -1;
103 static int hf_zbee_zcl_msg_ctrl_reserved = -1;
104 static int hf_zbee_zcl_msg_ctrl_confirm = -1;
105 static int hf_zbee_zcl_msg_start_time = -1;
106 static int hf_zbee_zcl_msg_duration = -1;
107 static int hf_zbee_zcl_msg_message_length =- 1;
108 static int hf_zbee_zcl_msg_message = -1;
109 static int hf_zbee_zcl_msg_confirm_time = -1;
110
111 /* Initialize the subtree pointers */
112 static gint ett_zbee_zcl_msg = -1;
113 static gint ett_zbee_zcl_msg_message_control = -1;
114
115 /* Server Commands Received */
116 static const value_string zbee_zcl_msg_srv_rx_cmd_names[] = {
117     { ZBEE_ZCL_CMD_ID_MSG_GET_LAST_MSG,                 "Get Last Message" },
118     { ZBEE_ZCL_CMD_ID_MSG_MSG_CONFIRM,                  "Message Confirmation" },
119     { 0, NULL }
120 };
121
122 /* Server Commands Generated */
123 static const value_string zbee_zcl_msg_srv_tx_cmd_names[] = {
124     { ZBEE_ZCL_CMD_ID_MSG_DISPLAY_MSG,                  "Display Message" },
125     { ZBEE_ZCL_CMD_ID_MSG_CANCEL_MSG,                   "Cancel Message" },
126     { 0, NULL }
127 };
128
129 /* Message Control Transmission */
130 static const value_string zbee_zcl_msg_ctrl_tx_names[] = {
131     { ZBEE_ZCL_MSG_CTRL_TX_NORMAL_ONLY,                 "Normal Transmission Only" },
132     { ZBEE_ZCL_MSG_CTRL_TX_NORMAL_ANON_INTERPAN,        "Normal and Anonymous Inter-PAN Transmission Only" },
133     { ZBEE_ZCL_MSG_CTRL_TX_ANON_INTERPAN_ONLY,          "Anonymous Inter-PAN Transmission Only" },
134     { 0, NULL }
135 };
136
137 /* Message Control Importance */
138 static const value_string zbee_zcl_msg_ctrl_importance_names[] = {
139     { ZBEE_ZCL_MSG_CTRL_IMPORTANCE_LOW,                 "Low" },
140     { ZBEE_ZCL_MSG_CTRL_IMPORTANCE_MEDIUM,              "Medium" },
141     { ZBEE_ZCL_MSG_CTRL_IMPORTANCE_HIGH,                "High" },
142     { ZBEE_ZCL_MSG_CTRL_IMPORTANCE_CRITICAL,            "Critical" },
143     { 0, NULL }
144 };
145
146
147 /*************************/
148 /* Function Bodies       */
149 /*************************/
150
151 /*FUNCTION:------------------------------------------------------
152  *  NAME
153  *      dissect_zbee_zcl_msg
154  *  DESCRIPTION
155  *      ZigBee ZCL Messaging cluster dissector for wireshark.
156  *  PARAMETERS
157  *      tvbuff_t *tvb       - pointer to buffer containing raw packet.
158  *      packet_info *pinfo  - pointer to packet information fields
159  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
160  *  RETURNS
161  *      none
162  *---------------------------------------------------------------
163  */
164 static int
165 dissect_zbee_zcl_msg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
166 {
167     proto_item        *payload_root;
168     proto_tree        *payload_tree;
169     zbee_zcl_packet   *zcl;
170     guint             offset = 0;
171     guint8            cmd_id;
172     gint              rem_len;
173
174     /* Reject the packet if data is NULL */
175     if (data == NULL)
176         return 0;
177     zcl = (zbee_zcl_packet *)data;
178     cmd_id = zcl->cmd_id;
179
180     /*  Create a subtree for the ZCL Command frame, and add the command ID to it. */
181     if (zcl->direction == ZBEE_ZCL_FCF_TO_SERVER) {
182         /* Append the command name to the info column. */
183         col_append_fstr(pinfo->cinfo, COL_INFO, "%s, Seq: %u",
184             val_to_str_const(cmd_id, zbee_zcl_msg_srv_rx_cmd_names, "Unknown Command"),
185             zcl->tran_seqno);
186
187         /* Add the command ID. */
188         proto_tree_add_item(tree, hf_zbee_zcl_msg_srv_rx_cmd_id, tvb, offset, 1, cmd_id);
189
190         /* Check is this command has a payload, than add the payload tree */
191         rem_len = tvb_reported_length_remaining(tvb, ++offset);
192         if (rem_len > 0) {
193             payload_root = proto_tree_add_text(tree, tvb, offset, rem_len, "Payload");
194             payload_tree = proto_item_add_subtree(payload_root, ett_zbee_zcl_msg);
195
196             /* Call the appropriate command dissector */
197             switch (cmd_id) {
198
199                 case ZBEE_ZCL_CMD_ID_MSG_GET_LAST_MSG:
200                     /* No payload */
201                     break;
202
203                 case ZBEE_ZCL_CMD_ID_MSG_MSG_CONFIRM:
204                     dissect_zcl_msg_confirm(tvb, payload_tree, &offset);
205                     break;
206
207                 default:
208                     break;
209             }
210         }
211     }
212     else { /* ZBEE_ZCL_FCF_TO_CLIENT */
213         /* Append the command name to the info column. */
214         col_append_fstr(pinfo->cinfo, COL_INFO, "%s, Seq: %u",
215             val_to_str_const(cmd_id, zbee_zcl_msg_srv_tx_cmd_names, "Unknown Command"),
216             zcl->tran_seqno);
217
218         /* Add the command ID. */
219         proto_tree_add_item(tree, hf_zbee_zcl_msg_srv_tx_cmd_id, tvb, offset, 1, cmd_id);
220
221         /* Check is this command has a payload, than add the payload tree */
222         rem_len = tvb_reported_length_remaining(tvb, ++offset);
223         if (rem_len > 0) {
224             payload_root = proto_tree_add_text(tree, tvb, offset, rem_len, "Payload");
225             payload_tree = proto_item_add_subtree(payload_root, ett_zbee_zcl_msg);
226
227             /* Call the appropriate command dissector */
228             switch (cmd_id) {
229
230                 case ZBEE_ZCL_CMD_ID_MSG_DISPLAY_MSG:
231                     dissect_zcl_msg_display(tvb, payload_tree, &offset);
232                     break;
233
234                 case ZBEE_ZCL_CMD_ID_MSG_CANCEL_MSG:
235                     dissect_zcl_msg_cancel(tvb, payload_tree, &offset);
236                     break;
237
238                 default:
239                     break;
240             }
241         }
242     }
243
244     return tvb_length(tvb);
245 } /*dissect_zbee_zcl_msg*/
246
247  /*FUNCTION:------------------------------------------------------
248  *  NAME
249  *      dissect_zcl_msg_display
250  *  DESCRIPTION
251  *      This function manages the Display Message payload
252  *  PARAMETERS
253  *      tvbuff_t *tvb       - pointer to buffer containing raw packet.
254  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
255  *      offset              - offset
256  *  RETURNS
257  *      none
258  *---------------------------------------------------------------
259  */
260 static void
261 dissect_zcl_msg_display(tvbuff_t *tvb, proto_tree *tree, guint *offset)
262 {
263     proto_tree *sub_tree = NULL;
264     proto_item *ti;
265     guint8 control;
266     guint  msg_len;
267     guint8 *msg_data;
268
269     /* Retrieve "Message ID" field */
270     proto_tree_add_item(tree, hf_zbee_zcl_msg_message_id, tvb, *offset, 4, ENC_LITTLE_ENDIAN);
271     *offset += 4;
272
273     /* Retrieve "Message Control" field */
274     control = tvb_get_guint8(tvb, *offset);
275     ti = proto_tree_add_text(tree, tvb, *offset, 1, "Message Control: 0x%02x", control);
276     sub_tree = proto_item_add_subtree(ti, ett_zbee_zcl_msg_message_control);
277     proto_tree_add_item(sub_tree, hf_zbee_zcl_msg_ctrl_tx, tvb, *offset, 1, ENC_NA);
278     proto_tree_add_item(sub_tree, hf_zbee_zcl_msg_ctrl_importance, tvb, *offset, 1, ENC_NA);
279     proto_tree_add_item(sub_tree, hf_zbee_zcl_msg_ctrl_reserved, tvb, *offset, 1, ENC_NA);
280     proto_tree_add_item(sub_tree, hf_zbee_zcl_msg_ctrl_confirm, tvb, *offset, 1, ENC_NA);
281     *offset += 1;
282
283     /* Retrieve "Start Time" field */
284     proto_tree_add_item(tree, hf_zbee_zcl_msg_start_time, tvb, *offset, 4, ENC_LITTLE_ENDIAN);
285     *offset += 4;
286
287     /* Retrieve "Duration In Minutes" field */
288     proto_tree_add_item(tree, hf_zbee_zcl_msg_duration, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
289     *offset += 2;
290
291     /* Retrieve "Message Length" field */
292     msg_len = tvb_get_guint8(tvb, *offset); /* string length */
293     proto_tree_add_item(tree, hf_zbee_zcl_msg_message_length, tvb, *offset, 1, ENC_NA);
294     *offset += 1;
295
296     /* Retrieve "Message" field */
297     msg_data = tvb_get_string_enc(wmem_packet_scope(), tvb, *offset, msg_len, ENC_LITTLE_ENDIAN);
298     proto_tree_add_string(tree, hf_zbee_zcl_msg_message, tvb, *offset, msg_len, msg_data);
299     *offset += msg_len;
300
301 } /*dissect_zcl_msg_display*/
302
303  /*FUNCTION:------------------------------------------------------
304  *  NAME
305  *      dissect_zcl_msg_cancel
306  *  DESCRIPTION
307  *      This function manages the Cancel Message payload
308  *  PARAMETERS
309  *      tvbuff_t *tvb       - pointer to buffer containing raw packet.
310  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
311  *      offset              - offset
312  *  RETURNS
313  *      none
314  *---------------------------------------------------------------
315  */
316 static void
317 dissect_zcl_msg_cancel(tvbuff_t *tvb, proto_tree *tree, guint *offset)
318 {
319     proto_tree *sub_tree = NULL;
320     proto_item *ti;
321     guint8 control;
322
323     /* Retrieve "Message ID" field */
324     proto_tree_add_item(tree, hf_zbee_zcl_msg_message_id, tvb, *offset, 4, ENC_LITTLE_ENDIAN);
325     *offset += 4;
326
327     /* Retrieve "Message Control" field */
328     control = tvb_get_guint8(tvb, *offset);
329     ti = proto_tree_add_text(tree, tvb, *offset, 1, "Message Control: 0x%02x", control);
330     sub_tree = proto_item_add_subtree(ti, ett_zbee_zcl_msg_message_control);
331     proto_tree_add_item(sub_tree, hf_zbee_zcl_msg_ctrl_tx, tvb, *offset, 1, ENC_NA);
332     proto_tree_add_item(sub_tree, hf_zbee_zcl_msg_ctrl_importance, tvb, *offset, 1, ENC_NA);
333     proto_tree_add_item(sub_tree, hf_zbee_zcl_msg_ctrl_reserved, tvb, *offset, 1, ENC_NA);
334     proto_tree_add_item(sub_tree, hf_zbee_zcl_msg_ctrl_confirm, tvb, *offset, 1, ENC_NA);
335     *offset += 1;
336 }
337
338  /*FUNCTION:------------------------------------------------------
339  *  NAME
340  *      dissect_zcl_msg_confirm
341  *  DESCRIPTION
342  *      This function manages the Message Confirmation payload
343  *  PARAMETERS
344  *      tvbuff_t *tvb       - pointer to buffer containing raw packet.
345  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
346  *      offset              - offset
347  *  RETURNS
348  *      none
349  *---------------------------------------------------------------
350  */
351 static void
352 dissect_zcl_msg_confirm(tvbuff_t *tvb, proto_tree *tree, guint *offset)
353 {
354     nstime_t confirm_time;
355
356     /* Retrieve "Message ID" field */
357     proto_tree_add_item(tree, hf_zbee_zcl_msg_message_id, tvb, *offset, 4, ENC_LITTLE_ENDIAN);
358     *offset += 4;
359
360     /* Retrieve "Confirmation Time" field */
361     confirm_time.secs = tvb_get_letohl(tvb, *offset) + ZBEE_ZCL_NSTIME_UTC_OFFSET;
362     confirm_time.nsecs = 0;
363     proto_tree_add_time(tree, hf_zbee_zcl_msg_confirm_time, tvb, *offset, 4, &confirm_time);
364     *offset += 4;
365 }
366
367 /*FUNCTION:------------------------------------------------------
368  *  NAME
369  *      decode_zcl_msg_duration
370  *  DESCRIPTION
371  *    this function decodes duration in minute type variable
372  *  PARAMETERS
373  *  RETURNS
374  *      none
375  *---------------------------------------------------------------
376  */
377 static void
378 decode_zcl_msg_duration(gchar *s, guint16 value)
379 {
380     if (value == 0xffff)
381         g_snprintf(s, ITEM_LABEL_LENGTH, "Until changed");
382     else
383         g_snprintf(s, ITEM_LABEL_LENGTH, "%d minutes", value);
384     return;
385 } /*decode_zcl_msg_duration*/
386
387 /*FUNCTION:------------------------------------------------------
388  *  NAME
389  *      decode_zcl_msg_start_time
390  *  DESCRIPTION
391  *      this function decodes start time, with peculiarity case for
392  *      messaging specifications.
393  *  PARAMETERS
394  *      guint *s        - string to display
395  *      guint32 value   - value to decode
396  *  RETURNS
397  *      none
398  *---------------------------------------------------------------
399  */
400 static void
401 decode_zcl_msg_start_time(gchar *s, guint32 value)
402 {
403     if (value == ZBEE_ZCL_MSG_START_TIME_NOW)
404         g_snprintf(s, ITEM_LABEL_LENGTH, "Now");
405     else {
406         value += ZBEE_ZCL_NSTIME_UTC_OFFSET;
407         g_snprintf(s, ITEM_LABEL_LENGTH, "%s", abs_time_secs_to_str (wmem_packet_scope(), value, ABSOLUTE_TIME_LOCAL, TRUE));
408     }
409 } /* decode_zcl_msg_start_time */
410
411 /*FUNCTION:------------------------------------------------------
412  *  NAME
413  *      dissect_zcl_msg_cmd_id
414  *  DESCRIPTION
415  *      this function is called by ZCL foundation dissector in order to decode
416  *      specific cluster command identifier.
417  *  PARAMETERS
418  *      proto_tree *tree    - pointer to data tree Wireshark uses to display packet.
419  *      tvbuff_t *tvb       - pointer to buffer containing raw packet.
420  *      guint *offset       - pointer to buffer offset
421  *      guint8 cmd_dir      - command direction
422  *
423  *  RETURNS
424  *      none
425  *---------------------------------------------------------------
426  */
427 static void
428 dissect_zcl_msg_cmd_id(proto_tree *tree, tvbuff_t *tvb, guint *offset, guint8 cmd_dir)
429 {
430     if (cmd_dir == ZBEE_ZCL_FCF_TO_CLIENT)
431         proto_tree_add_item(tree, hf_zbee_zcl_msg_srv_rx_cmd_id, tvb, *offset, 1, ENC_NA);
432     else
433         proto_tree_add_item(tree, hf_zbee_zcl_msg_srv_tx_cmd_id, tvb, *offset, 1, ENC_NA);
434
435 } /*dissect_zcl_msg_cmd_id*/
436
437 /*FUNCTION:------------------------------------------------------
438  *  NAME
439  *      proto_register_zbee_zcl_msg
440  *  DESCRIPTION
441  *      this function registers the ZCL Messaging dissector
442  *      and all its information.
443  *  PARAMETERS
444  *      none
445  *  RETURNS
446  *      none
447  *---------------------------------------------------------------
448  */
449 void
450 proto_register_zbee_zcl_msg(void)
451 {
452     static hf_register_info hf[] = {
453
454         { &hf_zbee_zcl_msg_srv_tx_cmd_id,
455             { "Command", "zbee_zcl_se.msg.cmd.srv_tx.id", FT_UINT8, BASE_HEX, VALS(zbee_zcl_msg_srv_tx_cmd_names),
456             0x00, NULL, HFILL } },
457
458         { &hf_zbee_zcl_msg_srv_rx_cmd_id,
459             { "Command", "zbee_zcl_se.msg.cmd.srv_rx.id", FT_UINT8, BASE_HEX, VALS(zbee_zcl_msg_srv_rx_cmd_names),
460             0x00, NULL, HFILL } },
461
462         { &hf_zbee_zcl_msg_message_id,
463             { "Message ID", "zbee_zcl_se.msg.message.id", FT_UINT32, BASE_HEX, NULL,
464             0x00, NULL, HFILL } },
465
466 /* Start of 'Message Control' fields */
467         { &hf_zbee_zcl_msg_ctrl_tx,
468             { "Transmission", "zbee_zcl_se.msg.message.ctrl.tx", FT_UINT8, BASE_HEX, VALS(zbee_zcl_msg_ctrl_tx_names),
469             ZBEE_ZCL_MSG_CTRL_TX_MASK, NULL, HFILL } },
470
471         { &hf_zbee_zcl_msg_ctrl_importance,
472             { "Importance", "zbee_zcl_se.msg.message.ctrl.importance", FT_UINT8, BASE_HEX, VALS(zbee_zcl_msg_ctrl_importance_names),
473             ZBEE_ZCL_MSG_CTRL_IMPORTANCE_MASK, NULL, HFILL } },
474
475         { &hf_zbee_zcl_msg_ctrl_reserved,
476             { "Reserved", "zbee_zcl_se.msg.message.ctrl.reserved", FT_UINT8, BASE_HEX, NULL,
477             ZBEE_ZCL_MSG_CTRL_RESERVED_MASK, NULL, HFILL } },
478
479         { &hf_zbee_zcl_msg_ctrl_confirm,
480             { "Confirmation", "zbee_zcl_se.msg.message.ctrl.confirm", FT_BOOLEAN, 8, TFS(&tfs_requested_not_requested),
481             ZBEE_ZCL_MSG_CTRL_CONFIRM_MASK, NULL, HFILL } },
482 /* End of 'Message Control' fields */
483
484         { &hf_zbee_zcl_msg_start_time,
485             { "Start Time", "zbee_zcl_se.msg.message.start_time", FT_UINT32, BASE_CUSTOM, decode_zcl_msg_start_time,
486             0x00, NULL, HFILL } },
487
488         { &hf_zbee_zcl_msg_duration,
489             { "Duration", "zbee_zcl_se.msg.message.duration", FT_UINT16, BASE_CUSTOM, decode_zcl_msg_duration,
490             0x00, NULL, HFILL } },
491
492         { &hf_zbee_zcl_msg_message_length,
493             { "Message Length", "zbee_zcl_se.msg.message.length", FT_UINT8, BASE_DEC, NULL,
494             0x00, NULL, HFILL } },
495
496         { &hf_zbee_zcl_msg_message,
497             { "Message", "zbee_zcl_se.msg.message", FT_STRING, BASE_NONE, NULL,
498             0x00, NULL, HFILL } },
499
500         { &hf_zbee_zcl_msg_confirm_time,
501             { "Confirmation Time", "zbee_zcl_se.msg.message.confirm_time",  FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL,
502             0x0, NULL, HFILL }}
503
504     };
505
506     /* ZCL Messaging subtrees */
507     gint *ett[ZBEE_ZCL_MSG_NUM_ETT];
508
509     ett[0] = &ett_zbee_zcl_msg;
510     ett[1] = &ett_zbee_zcl_msg_message_control;
511
512     /* Register the ZigBee ZCL Messaging cluster protocol name and description */
513     proto_zbee_zcl_msg = proto_register_protocol("ZigBee ZCL Messaging", "ZCL Messaging", ZBEE_PROTOABBREV_ZCL_MSG);
514     proto_register_field_array(proto_zbee_zcl_msg, hf, array_length(hf));
515     proto_register_subtree_array(ett, array_length(ett));
516
517     /* Register the ZigBee ZCL Messaging dissector. */
518     new_register_dissector(ZBEE_PROTOABBREV_ZCL_MSG, dissect_zbee_zcl_msg, proto_zbee_zcl_msg);
519
520 } /*proto_register_zbee_zcl_msg*/
521
522
523 /*FUNCTION:------------------------------------------------------
524  *  NAME
525  *      proto_reg_handoff_zbee_zcl_msg
526  *  DESCRIPTION
527  *      Hands off the Zcl Messaging dissector.
528  *  PARAMETERS
529  *      none
530  *  RETURNS
531  *      void
532  *---------------------------------------------------------------
533  */
534 void
535 proto_reg_handoff_zbee_zcl_msg(void)
536 {
537     dissector_handle_t msg_handle;
538
539     /* Register our dissector with the ZigBee application dissectors. */
540     msg_handle = find_dissector(ZBEE_PROTOABBREV_ZCL_MSG);
541     dissector_add_uint("zbee.zcl.cluster", ZBEE_ZCL_CID_MESSAGE, msg_handle);
542
543     zbee_zcl_init_cluster(  proto_zbee_zcl_msg,
544                             ett_zbee_zcl_msg,
545                             ZBEE_ZCL_CID_MESSAGE,
546                             NULL,
547                             NULL,
548                             (zbee_zcl_fn_cmd_id)dissect_zcl_msg_cmd_id
549                          );
550 } /*proto_reg_handoff_zbee_zcl_msg*/
551