summaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-zbee-zcl-sas.c
blob: f8e41790ff2293930f9e503cfce3f9798d9083a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
/* packet-zbee-zcl-sas.c
 * Dissector routines for the ZigBee ZCL Security and Safety Interfaces clusters
 * By Aditya Jain <aditya.jain@samsung.com>
 *
 * Wireshark - Network traffic analyzer
 * By Gerald Combs <gerald@wireshark.org>
 * Copyright 1998 Gerald Combs
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 *
 * https://zigbeealliance.org/wp-content/uploads/2021/10/07-5123-08-Zigbee-Cluster-Library.pdf
 */

/*  Include Files */
#include "config.h"

#include <epan/packet.h>
#include <epan/to_str.h>

#include "packet-zbee.h"
#include "packet-zbee-aps.h"
#include "packet-zbee-zcl.h"


/* ########################################################################## */
/* #### (0x0501) IAS ACE CLUSTER ############################################ */
/* ########################################################################## */

/*************************/
/* Defines               */
/*************************/
#define ZBEE_ZCL_IAS_ACE_NUM_ETT                               7

/* Attributes - none */

/* Server Commands Received */
#define ZBEE_ZCL_CMD_ID_IAS_ACE_ARM                     0x00  /* Arm */
#define ZBEE_ZCL_CMD_ID_IAS_ACE_BYPASS                  0x01  /* Bypass */
#define ZBEE_ZCL_CMD_ID_IAS_ACE_EMERGENCY               0x02  /* Emergency */
#define ZBEE_ZCL_CMD_ID_IAS_ACE_FIRE                    0x03  /* Fire */
#define ZBEE_ZCL_CMD_ID_IAS_ACE_PANIC                   0x04  /* Panic */
#define ZBEE_ZCL_CMD_ID_IAS_ACE_GET_ZONE_ID_MAP         0x05  /* Get Zone ID Map */
#define ZBEE_ZCL_CMD_ID_IAS_ACE_GET_ZONE_INFO           0x06  /* Get Zone Information */
#define ZBEE_ZCL_CMD_ID_IAS_ACE_GET_PANEL_STATUS        0x07  /* Get Panel Status */
#define ZBEE_ZCL_CMD_ID_IAS_ACE_GET_BYPASSED_ZONE_LIST  0x08  /* Get Bypassed Zone List */
#define ZBEE_ZCL_CMD_ID_IAS_ACE_GET_ZONE_STATUS         0x09  /* Get Zone Status */

/* Server Commands Generated */
#define ZBEE_ZCL_CMD_ID_IAS_ACE_ARM_RES                 0x00  /* Arm Response */
#define ZBEE_ZCL_CMD_ID_IAS_ACE_GET_ZONE_ID_MAP_RES     0x01  /* Get Zone ID Map Response */
#define ZBEE_ZCL_CMD_ID_IAS_ACE_GET_ZONE_INFO_RES       0x02  /* Get Zone Information Response */
#define ZBEE_ZCL_CMD_ID_IAS_ACE_ZONE_STATUS_CHANGED     0x03  /* Zone Status Changed */
#define ZBEE_ZCL_CMD_ID_IAS_ACE_PANEL_STATUS_CHANGED    0x04  /* Panel Status Changed */
#define ZBEE_ZCL_CMD_ID_IAS_ACE_GET_PANEL_STATUS_RES    0x05  /* Get Panel Status Response */
#define ZBEE_ZCL_CMD_ID_IAS_ACE_SET_BYPASSED_ZONE_LIST  0x06  /* Set Bypassed Zone List */
#define ZBEE_ZCL_CMD_ID_IAS_ACE_BYPASS_RES              0x07  /* Bypass Response */
#define ZBEE_ZCL_CMD_ID_IAS_ACE_GET_ZONE_STATUS_RES     0x08  /* Get Zone Status Response */


/*************************/
/* Function Declarations */
/*************************/

void proto_register_zbee_zcl_ias_ace(void);
void proto_reg_handoff_zbee_zcl_ias_ace(void);

/* Command Dissector Helpers */
static void dissect_zcl_ias_ace_arm                     (tvbuff_t *tvb, proto_tree *tree, unsigned *offset);
static void dissect_zcl_ias_ace_bypass                  (tvbuff_t *tvb, proto_tree *tree, unsigned *offset);
static void dissect_zcl_ias_ace_get_zone_info           (tvbuff_t *tvb, proto_tree *tree, unsigned *offset);
static void dissect_zcl_ias_ace_get_zone_status         (tvbuff_t *tvb, proto_tree *tree, unsigned *offset);
static void dissect_zcl_ias_ace_arm_res                 (tvbuff_t *tvb, proto_tree *tree, unsigned *offset);
static void dissect_zcl_ias_ace_get_zone_id_map_res     (tvbuff_t *tvb, proto_tree *tree, unsigned *offset);
static void dissect_zcl_ias_ace_get_zone_info_res       (tvbuff_t *tvb, proto_tree *tree, unsigned *offset);
static void dissect_zcl_ias_ace_zone_status_changed     (tvbuff_t *tvb, proto_tree *tree, unsigned *offset);
static void dissect_zcl_ias_ace_panel_status_changed    (tvbuff_t *tvb, proto_tree *tree, unsigned *offset);
static void dissect_zcl_ias_ace_get_panel_status_res    (tvbuff_t *tvb, proto_tree *tree, unsigned *offset);
static void dissect_zcl_ias_ace_set_bypassed_zone_list  (tvbuff_t *tvb, proto_tree *tree, unsigned *offset);
static void dissect_zcl_ias_ace_bypassed_res            (tvbuff_t *tvb, proto_tree *tree, unsigned *offset);
static void dissect_zcl_ias_ace_get_zone_status_res     (tvbuff_t *tvb, proto_tree *tree, unsigned *offset);

/* Private functions prototype */

/*************************/
/* Global Variables      */
/*************************/
/* Initialize the protocol and registered fields */
static int proto_zbee_zcl_ias_ace;

static int hf_zbee_zcl_ias_ace_arm_mode;
static int hf_zbee_zcl_ias_ace_no_of_zones;
static int hf_zbee_zcl_ias_ace_zone_id;
static int hf_zbee_zcl_ias_ace_zone_id_list;
static int hf_zbee_zcl_ias_ace_arm_notif;
static int hf_zbee_zcl_ias_ace_zone_id_map_section;
static int hf_zbee_zcl_ias_ace_zone_type;
static int hf_zbee_zcl_ias_ace_ieee_add;
static int hf_zbee_zcl_ias_ace_srv_rx_cmd_id;
static int hf_zbee_zcl_ias_ace_srv_tx_cmd_id;
static int hf_zbee_zcl_ias_ace_starting_zone_id;
static int hf_zbee_zcl_ias_ace_max_number_of_zone_ids;
static int hf_zbee_zcl_ias_ace_zone_status_mask_flag;
static int hf_zbee_zcl_ias_ace_zone_status_mask;
static int hf_zbee_zcl_ias_ace_zone_status;
static int hf_zbee_zcl_ias_ace_zone_audible_notif;
static int hf_zbee_zcl_ias_ace_zone_label;
static int hf_zbee_zcl_ias_ace_panel_status;
static int hf_zbee_zcl_ias_ace_seconds_remaining;
static int hf_zbee_zcl_ias_ace_alarm_status;
static int hf_zbee_zcl_ias_ace_number_of_zones;
static int hf_zbee_zcl_ias_ace_zone_status_complete;

/* Initialize the subtree pointers */
static int ett_zbee_zcl_ias_ace;
static int ett_zbee_zcl_ias_ace_zone_id;
static int ett_zbee_zcl_ias_ace_zone_id_map_sec;
static int ett_zbee_zcl_ias_ace_zone_id_map_sec_elem;
static int ett_zbee_zcl_ias_ace_bypassed_zone_list;
static int ett_zbee_zcl_ias_ace_bypassed_resp_list;
static int ett_zbee_zcl_ias_ace_get_zone_status_resp_list;

/* Server Commands Received */
static const value_string zbee_zcl_ias_ace_srv_rx_cmd_names[] = {
    { ZBEE_ZCL_CMD_ID_IAS_ACE_ARM,                    "Arm" },
    { ZBEE_ZCL_CMD_ID_IAS_ACE_BYPASS,                 "Bypass" },
    { ZBEE_ZCL_CMD_ID_IAS_ACE_EMERGENCY,              "Emergency" },
    { ZBEE_ZCL_CMD_ID_IAS_ACE_FIRE,                   "Fire" },
    { ZBEE_ZCL_CMD_ID_IAS_ACE_PANIC,                  "Panic" },
    { ZBEE_ZCL_CMD_ID_IAS_ACE_GET_ZONE_ID_MAP,        "Get Zone ID Map" },
    { ZBEE_ZCL_CMD_ID_IAS_ACE_GET_ZONE_INFO,          "Get Zone Information" },
    { ZBEE_ZCL_CMD_ID_IAS_ACE_GET_PANEL_STATUS,       "Get Panel Status" },
    { ZBEE_ZCL_CMD_ID_IAS_ACE_GET_BYPASSED_ZONE_LIST, "Get Bypassed Zone List" },
    { ZBEE_ZCL_CMD_ID_IAS_ACE_GET_ZONE_STATUS,        "Get Zone Status" },
    { 0, NULL }
};

/* Server Commands Generated */
static const value_string zbee_zcl_ias_ace_srv_tx_cmd_names[] = {
    { ZBEE_ZCL_CMD_ID_IAS_ACE_ARM_RES,                "Arm Response" },
    { ZBEE_ZCL_CMD_ID_IAS_ACE_GET_ZONE_ID_MAP_RES,    "Get Zone ID Map Response" },
    { ZBEE_ZCL_CMD_ID_IAS_ACE_GET_ZONE_INFO_RES,      "Get Zone Information Response" },
    { ZBEE_ZCL_CMD_ID_IAS_ACE_ZONE_STATUS_CHANGED,    "Zone Status Changed" },
    { ZBEE_ZCL_CMD_ID_IAS_ACE_PANEL_STATUS_CHANGED,   "Panel Status Changed" },
    { ZBEE_ZCL_CMD_ID_IAS_ACE_GET_PANEL_STATUS_RES,   "Get Panel Status Response" },
    { ZBEE_ZCL_CMD_ID_IAS_ACE_SET_BYPASSED_ZONE_LIST, "Set Bypassed Zone List" },
    { ZBEE_ZCL_CMD_ID_IAS_ACE_BYPASS_RES,             "Bypass Response" },
    { ZBEE_ZCL_CMD_ID_IAS_ACE_GET_ZONE_STATUS_RES,    "Get Zone Status Response" },
    { 0, NULL }
};

/* Arm Mode Values */
static const value_string arm_mode_values[] = {
  { 0x00, "Disarm" },
  { 0x01, "Arm Day/Home Zones Only" },
  { 0x02, "Arm Night/Sleep Zones Only" },
  { 0x03, "Arm All Zones" },
  { 0, NULL }
};

/* Arm Notification Values */
static const value_string arm_notif_values[] = {
  { 0x00, "All Zones Disarmed" },
  { 0x01, "Only Day/Home Zones Armed" },
  { 0x02, "Only Night/Sleep Zones Armed" },
  { 0x03, "All Zones Armed" },
  { 0, NULL }
};

/* Audible Notification Values */
static const value_string audible_notif_values[] = {
  { 0x00, "Mute" },
  { 0x01, "Default sound" },
  { 0, NULL }
};

/* Panel Status Values */
static const value_string panel_status_values[] = {
  { 0x00, "Panel disarmed" },
  { 0x01, "Armed stay" },
  { 0x02, "Armed night" },
  { 0x03, "Armed away" },
  { 0x04, "Exit delay" },
  { 0x05, "Entry delay" },
  { 0x06, "Not ready to arm" },
  { 0x07, "In alarm" },
  { 0x08, "Arming Stay" },
  { 0x09, "Arming Night" },
  { 0x0a, "Arming Away" },
  { 0, NULL }
};

/* Panel Status Values */
static const value_string alarm_status_values[] = {
  { 0x00, "No alarm" },
  { 0x01, "Burglar" },
  { 0x02, "Fire" },
  { 0x03, "Emergency" },
  { 0x04, "Police Panic" },
  { 0x05, "Fire Panic" },
  { 0x06, "Emergency Panic" },
  { 0, NULL }
};

/*************************/
/* Function Bodies       */
/*************************/

/**
 *ZigBee ZCL IAS ACE cluster dissector for wireshark.
 *
 *@param tvb pointer to buffer containing raw packet.
 *@param pinfo pointer to packet information fields
 *@param tree pointer to data tree Wireshark uses to display packet.
*/
static int
dissect_zbee_zcl_ias_ace(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
{
    proto_tree        *payload_tree;
    zbee_zcl_packet   *zcl;
    unsigned          offset = 0;
    uint8_t           cmd_id;
    int               rem_len;

    /* Reject the packet if data is NULL */
    if (data == NULL)
        return 0;
    zcl = (zbee_zcl_packet *)data;
    cmd_id = zcl->cmd_id;

    /*  Create a subtree for the ZCL Command frame, and add the command ID to it. */
    if (zcl->direction == ZBEE_ZCL_FCF_TO_SERVER) {
        /* Append the command name to the info column. */
        col_append_fstr(pinfo->cinfo, COL_INFO, "%s, Seq: %u",
            val_to_str_const(cmd_id, zbee_zcl_ias_ace_srv_rx_cmd_names, "Unknown Command"),
            zcl->tran_seqno);

        /* Add the command ID. */
        proto_tree_add_item(tree, hf_zbee_zcl_ias_ace_srv_rx_cmd_id, tvb, offset, 1, ENC_LITTLE_ENDIAN);

        /* Check if this command has a payload, then add the payload tree */
        rem_len = tvb_reported_length_remaining(tvb, ++offset);
        if (rem_len > 0) {
            payload_tree = proto_tree_add_subtree(tree, tvb, offset, rem_len, ett_zbee_zcl_ias_ace, NULL, "Payload");

            /* Call the appropriate command dissector */
            switch (cmd_id) {
                case ZBEE_ZCL_CMD_ID_IAS_ACE_ARM:
                    dissect_zcl_ias_ace_arm(tvb, payload_tree, &offset);
                    break;
                case ZBEE_ZCL_CMD_ID_IAS_ACE_BYPASS:
                    dissect_zcl_ias_ace_bypass(tvb, payload_tree, &offset);
                    break;
                case ZBEE_ZCL_CMD_ID_IAS_ACE_GET_ZONE_INFO:
                    dissect_zcl_ias_ace_get_zone_info(tvb, payload_tree, &offset);
                    break;
                case ZBEE_ZCL_CMD_ID_IAS_ACE_GET_ZONE_STATUS:
                    dissect_zcl_ias_ace_get_zone_status(tvb, payload_tree, &offset);
                    break;
                case ZBEE_ZCL_CMD_ID_IAS_ACE_EMERGENCY:
                case ZBEE_ZCL_CMD_ID_IAS_ACE_FIRE:
                case ZBEE_ZCL_CMD_ID_IAS_ACE_PANIC:
                case ZBEE_ZCL_CMD_ID_IAS_ACE_GET_ZONE_ID_MAP:
                case ZBEE_ZCL_CMD_ID_IAS_ACE_GET_BYPASSED_ZONE_LIST:
                case ZBEE_ZCL_CMD_ID_IAS_ACE_GET_PANEL_STATUS:
                    /* No Payload */
                default:
                    break;
            }
        }
    }
    else { /* ZBEE_ZCL_FCF_TO_CLIENT */
        /* Append the command name to the info column. */
        col_append_fstr(pinfo->cinfo, COL_INFO, "%s, Seq: %u",
            val_to_str_const(cmd_id, zbee_zcl_ias_ace_srv_tx_cmd_names, "Unknown Command"),
            zcl->tran_seqno);

        /* Add the command ID. */
        proto_tree_add_item(tree, hf_zbee_zcl_ias_ace_srv_tx_cmd_id, tvb, offset, 1, ENC_LITTLE_ENDIAN);

        /* Check if this command has a payload, then add the payload tree */
        rem_len = tvb_reported_length_remaining(tvb, ++offset);
        if (rem_len > 0) {
            payload_tree = proto_tree_add_subtree(tree, tvb, offset, rem_len, ett_zbee_zcl_ias_ace, NULL, "Payload");

            /* Call the appropriate command dissector */
            switch (cmd_id) {
                case ZBEE_ZCL_CMD_ID_IAS_ACE_ARM_RES:
                    dissect_zcl_ias_ace_arm_res(tvb, payload_tree, &offset);
                    break;

                case ZBEE_ZCL_CMD_ID_IAS_ACE_GET_ZONE_ID_MAP_RES:
                    dissect_zcl_ias_ace_get_zone_id_map_res(tvb, payload_tree, &offset);
                    break;

                case ZBEE_ZCL_CMD_ID_IAS_ACE_GET_ZONE_INFO_RES:
                    dissect_zcl_ias_ace_get_zone_info_res(tvb, payload_tree, &offset);
                    break;

                case ZBEE_ZCL_CMD_ID_IAS_ACE_ZONE_STATUS_CHANGED:
                    dissect_zcl_ias_ace_zone_status_changed(tvb, payload_tree, &offset);
                    break;

                case ZBEE_ZCL_CMD_ID_IAS_ACE_PANEL_STATUS_CHANGED:
                    dissect_zcl_ias_ace_panel_status_changed(tvb, payload_tree, &offset);
                    break;

                case ZBEE_ZCL_CMD_ID_IAS_ACE_GET_PANEL_STATUS_RES:
                    dissect_zcl_ias_ace_get_panel_status_res(tvb, payload_tree, &offset);
                    break;

                case ZBEE_ZCL_CMD_ID_IAS_ACE_SET_BYPASSED_ZONE_LIST:
                    dissect_zcl_ias_ace_set_bypassed_zone_list(tvb, payload_tree, &offset);
                    break;

                case ZBEE_ZCL_CMD_ID_IAS_ACE_BYPASS_RES:
                    dissect_zcl_ias_ace_bypassed_res(tvb, payload_tree, &offset);
                    break;

                case ZBEE_ZCL_CMD_ID_IAS_ACE_GET_ZONE_STATUS_RES:
                    dissect_zcl_ias_ace_get_zone_status_res(tvb, payload_tree, &offset);
                    break;

                default:
                    break;
            }
        }
    }

    return tvb_captured_length(tvb);
} /*dissect_zbee_zcl_ias_ace*/


/**
 *This function decodes the Arm payload.
 *
 *@param  tvb the tv buffer of the current data_type
 *@param  tree the tree to append this item to
 *@param  offset offset of data in tvb
*/
static void
dissect_zcl_ias_ace_arm(tvbuff_t *tvb, proto_tree *tree, unsigned *offset)
{
    /* Retrieve "Arm Mode" field */
    proto_tree_add_item(tree, hf_zbee_zcl_ias_ace_arm_mode, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
    *offset += 1;

} /*dissect_zcl_ias_ace_arm*/


/**
 *This function decodes the Bypass payload.
 *
 *@param  tvb the tv buffer of the current data_type
 *@param  tree the tree to append this item to
 *@param  offset offset of data in tvb
*/
static void
dissect_zcl_ias_ace_bypass(tvbuff_t *tvb, proto_tree *tree, unsigned *offset)
{
    proto_item *zone_id_list = NULL;
    proto_tree *sub_tree = NULL;
    uint8_t num, i;

    /* Retrieve "Number of Zones" field */
    num = tvb_get_uint8(tvb, *offset);
    proto_tree_add_item(tree, hf_zbee_zcl_ias_ace_no_of_zones, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
    *offset += 1;

    /* Retrieve "Zone ID" fields */
    zone_id_list = proto_tree_add_item(tree, hf_zbee_zcl_ias_ace_zone_id_list, tvb, *offset, num, ENC_NA);
    sub_tree = proto_item_add_subtree(zone_id_list, ett_zbee_zcl_ias_ace_zone_id);

    for(i = 0; i < num; i++){
        proto_tree_add_item(sub_tree, hf_zbee_zcl_ias_ace_zone_id, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
        *offset += 1;
    }
} /*dissect_zcl_ias_ace_bypass*/


/**
 *This function decodes the Get Zone Information payload.
 *
 *@param  tvb the tv buffer of the current data_type
 *@param  tree the tree to append this item to
 *@param  offset offset of data in tvb
*/
static void
dissect_zcl_ias_ace_get_zone_info(tvbuff_t *tvb, proto_tree *tree, unsigned *offset)
{
   /* Retrieve "Zone ID" field */
   proto_tree_add_item(tree, hf_zbee_zcl_ias_ace_zone_id, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
   *offset += 1;

} /*dissect_zcl_ias_ace_get_zone_info*/


/**
 *This function decodes the Get Zone Status payload.
 *
 *@param  tvb the tv buffer of the current data_type
 *@param  tree the tree to append this item to
 *@param  offset offset of data in tvb
*/
static void
dissect_zcl_ias_ace_get_zone_status(tvbuff_t *tvb, proto_tree *tree, unsigned *offset)
{
    /* Retrieve "Starting Zone ID" field */
    proto_tree_add_item(tree, hf_zbee_zcl_ias_ace_starting_zone_id, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
    *offset += 1;

    /* Retrieve "Max Number of Zone IDs" field */
    proto_tree_add_item(tree, hf_zbee_zcl_ias_ace_max_number_of_zone_ids, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
    *offset += 1;

    /* Retrieve "Zone Status Mask Flag" field */
    proto_tree_add_item(tree, hf_zbee_zcl_ias_ace_zone_status_mask_flag, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
    *offset += 1;

    /* Retrieve "Zone Status Mask" field */
    proto_tree_add_item(tree, hf_zbee_zcl_ias_ace_zone_status_mask, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
    *offset += 2;

} /*dissect_zcl_ias_ace_get_zone_status*/


/**
 *This function decodes the Zone Status Changed payload.
 *
 *@param  tvb the tv buffer of the current data_type
 *@param  tree the tree to append this item to
 *@param  offset offset of data in tvb
*/
static void
dissect_zcl_ias_ace_zone_status_changed(tvbuff_t *tvb, proto_tree *tree, unsigned *offset)
{
    int length;

    /* Retrieve "Zone ID" field */
    proto_tree_add_item(tree, hf_zbee_zcl_ias_ace_zone_id, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
    *offset += 1;

    /* Retrieve "Zone Status" field */
    proto_tree_add_item(tree, hf_zbee_zcl_ias_ace_zone_status, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
    *offset += 2;

    /* Retrieve "Audible Notification" field */
    proto_tree_add_item(tree, hf_zbee_zcl_ias_ace_zone_audible_notif, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
    *offset += 1;

    /* Rate Label */
    proto_tree_add_item_ret_length(tree, hf_zbee_zcl_ias_ace_zone_label, tvb, *offset, 1, ENC_NA | ENC_ZIGBEE, &length);
    *offset += length;

} /*dissect_zcl_ias_ace_zone_status_changed*/


/**
 *This function decodes the Panel Status Changed payload.
 *
 *@param  tvb the tv buffer of the current data_type
 *@param  tree the tree to append this item to
 *@param  offset offset of data in tvb
*/
static void
dissect_zcl_ias_ace_panel_status_changed(tvbuff_t *tvb, proto_tree *tree, unsigned *offset)
{
    /* Retrieve "Panel Status" field */
    proto_tree_add_item(tree, hf_zbee_zcl_ias_ace_panel_status, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
    *offset += 1;

    /* Retrieve "Seconds Remaining" field */
    proto_tree_add_item(tree, hf_zbee_zcl_ias_ace_seconds_remaining, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
    *offset += 1;

    /* Retrieve "Audible Notification" field */
    proto_tree_add_item(tree, hf_zbee_zcl_ias_ace_zone_audible_notif, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
    *offset += 1;

    /* Retrieve "Alarm Status" field */
    proto_tree_add_item(tree, hf_zbee_zcl_ias_ace_alarm_status, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
    *offset += 1;

} /*dissect_zcl_ias_ace_panel_status_changed*/


/**
 *This function decodes the Get Panel Status Response payload.
 *
 *@param  tvb the tv buffer of the current data_type
 *@param  tree the tree to append this item to
 *@param  offset offset of data in tvb
*/
static void
dissect_zcl_ias_ace_get_panel_status_res(tvbuff_t *tvb, proto_tree *tree, unsigned *offset)
{
    /* Retrieve "Panel Status" field */
    proto_tree_add_item(tree, hf_zbee_zcl_ias_ace_panel_status, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
    *offset += 1;

    /* Retrieve "Seconds Remaining" field */
    proto_tree_add_item(tree, hf_zbee_zcl_ias_ace_seconds_remaining, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
    *offset += 1;

    /* Retrieve "Audible Notification" field */
    proto_tree_add_item(tree, hf_zbee_zcl_ias_ace_zone_audible_notif, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
    *offset += 1;

    /* Retrieve "Alarm Status" field */
    proto_tree_add_item(tree, hf_zbee_zcl_ias_ace_alarm_status, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
    *offset += 1;

} /*dissect_zcl_ias_ace_get_panel_status_res*/


/**
 *This function decodes the Set Bypassed Zone List payload.
 *
 *@param  tvb the tv buffer of the current data_type
 *@param  tree the tree to append this item to
 *@param  offset offset of data in tvb
*/
static void
dissect_zcl_ias_ace_set_bypassed_zone_list(tvbuff_t *tvb, proto_tree *tree, unsigned *offset)
{
    size_t length = tvb_get_uint8(tvb, *offset);

    /* Retrieve "Number of Zones" field */
    proto_tree_add_item(tree, hf_zbee_zcl_ias_ace_number_of_zones, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
    *offset += 1;

    if (length > 0) {
        proto_tree *subtree;
        subtree = proto_item_add_subtree(tree, ett_zbee_zcl_ias_ace_bypassed_zone_list);

        for (size_t i = 0; i < length; i++) {
            /* Retrieve "Zone ID n" field */
            proto_tree_add_item(subtree, hf_zbee_zcl_ias_ace_zone_id, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
            *offset += 1;
        }
    }
} /*dissect_zcl_ias_ace_set_bypassed_zone_list*/


/**
 *This function decodes the Set Bypassed Zone List payload.
 *
 *@param  tvb the tv buffer of the current data_type
 *@param  tree the tree to append this item to
 *@param  offset offset of data in tvb
*/
static void
dissect_zcl_ias_ace_bypassed_res(tvbuff_t *tvb, proto_tree *tree, unsigned *offset)
{
    size_t length = tvb_get_uint8(tvb, *offset);

    /* Retrieve "Number of Zones" field */
    proto_tree_add_item(tree, hf_zbee_zcl_ias_ace_number_of_zones, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
    *offset += 1;

    if (length > 0) {
        proto_tree *subtree;
        subtree = proto_item_add_subtree(tree, ett_zbee_zcl_ias_ace_bypassed_resp_list);

        for (size_t i = 0; i < length; i++) {
            /* Retrieve "Bypass Result for Zone ID n" field */
            proto_tree_add_item(subtree, hf_zbee_zcl_ias_ace_zone_id, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
            *offset += 1;
        }
    }
} /*dissect_zcl_ias_ace_bypassed_res */



/**
 *This function decodes the Set Bypassed Zone List payload.
 *
 *@param  tvb the tv buffer of the current data_type
 *@param  tree the tree to append this item to
 *@param  offset offset of data in tvb
*/
static void
dissect_zcl_ias_ace_get_zone_status_res(tvbuff_t *tvb, proto_tree *tree, unsigned *offset)
{
    size_t length = 0;

    /* Retrieve "Zone Status Complete" field */
    proto_tree_add_item(tree, hf_zbee_zcl_ias_ace_zone_status_complete, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
    *offset += 1;

    length = tvb_get_uint8(tvb, *offset);

    /* Retrieve "Number of Zones" field */
    proto_tree_add_item(tree, hf_zbee_zcl_ias_ace_number_of_zones, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
    *offset += 1;

    if (length > 0) {
        proto_tree *subtree;
        subtree = proto_item_add_subtree(tree, ett_zbee_zcl_ias_ace_get_zone_status_resp_list);

        for (size_t i = 0; i < length; i++) {
            /* Retrieve "Bypass Result for Zone ID n" field */
            proto_tree_add_item(subtree, hf_zbee_zcl_ias_ace_zone_id, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
            *offset += 1;
        }
    }
} /*dissect_zcl_ias_ace_get_zone_status_res */

/**
 *This function decodes the Arm Response payload.
 *
 *@param  tvb the tv buffer of the current data_type
 *@param  tree the tree to append this item to
 *@param  offset offset of data in tvb
*/
static void
dissect_zcl_ias_ace_arm_res(tvbuff_t *tvb, proto_tree *tree, unsigned *offset)
{
   /* Retrieve "Arm Notification" field */
   proto_tree_add_item(tree, hf_zbee_zcl_ias_ace_arm_notif, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
   *offset += 1;

} /*dissect_zcl_ias_ace_arm_res*/


/**
 *This function decodes the Bypass payload.
 *
 *@param  tvb the tv buffer of the current data_type
 *@param  tree the tree to append this item to
 *@param  offset offset of data in tvb
*/
static void
dissect_zcl_ias_ace_get_zone_id_map_res(tvbuff_t *tvb, proto_tree *tree, unsigned *offset)
{
   uint8_t i;

   /* Retrieve "Zone ID" fields */
   for(i = 0; i < 16; i++){
       proto_tree_add_item(tree, hf_zbee_zcl_ias_ace_zone_id_map_section, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
       *offset += 2;
   }
} /*dissect_zcl_ias_ace_get_zone_id_map_res*/


/**
 *This function decodes the Get Zone Information Response payload.
 *
 *@param  tvb the tv buffer of the current data_type
 *@param  tree the tree to append this item to
 *@param  offset offset of data in tvb
*/
static void
dissect_zcl_ias_ace_get_zone_info_res(tvbuff_t *tvb, proto_tree *tree, unsigned *offset)
{
   /* Retrieve "Zone ID" field */
   proto_tree_add_item(tree, hf_zbee_zcl_ias_ace_zone_id, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
   *offset += 1;

   /* Retrieve "Zone Type" field */
   proto_tree_add_item(tree, hf_zbee_zcl_ias_ace_zone_type, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
   *offset += 2;

   /* Retrieve "IEEE Address" field */
   proto_tree_add_item(tree, hf_zbee_zcl_ias_ace_ieee_add, tvb, *offset, 8, ENC_NA);
   *offset += 8;

} /*dissect_zcl_ias_ace_get_zone_info_res*/


/**
 *ZigBee ZCL IAS ACE cluster protocol registration routine.
 *
*/
void
proto_register_zbee_zcl_ias_ace(void)
{
    /* Setup list of header fields */
    static hf_register_info hf[] = {

        { &hf_zbee_zcl_ias_ace_arm_mode,
            { "Arm Mode", "zbee_zcl_sas.ias_ace.arm_mode", FT_UINT8, BASE_DEC, VALS(arm_mode_values),
            0x0, NULL, HFILL } },

        { &hf_zbee_zcl_ias_ace_no_of_zones,
            { "Number of Zones", "zbee_zcl_sas.ias_ace.no_of_zones", FT_UINT8, BASE_DEC, NULL,
            0x0, NULL, HFILL } },

        { &hf_zbee_zcl_ias_ace_zone_id,
            { "Zone ID", "zbee_zcl_sas.ias_ace.zone_id", FT_UINT8, BASE_HEX, NULL,
            0x0, NULL, HFILL } },

        { &hf_zbee_zcl_ias_ace_zone_id_list,
            { "Zone ID List", "zbee_zcl_sas.ias_ace.zone_id_list", FT_NONE, BASE_NONE, NULL,
            0x0, NULL, HFILL } },

        { &hf_zbee_zcl_ias_ace_arm_notif,
            { "Arm Notifications", "zbee_zcl_sas.ias_ace.arm_notif", FT_UINT8, BASE_DEC, VALS(arm_notif_values),
            0x0, NULL, HFILL } },

        { &hf_zbee_zcl_ias_ace_zone_id_map_section,
            { "Zone ID Map Section", "zbee_zcl_sas.ias_ace.zone_id_map_section", FT_UINT16, BASE_HEX, NULL,
            0x0, NULL, HFILL } },

        { &hf_zbee_zcl_ias_ace_zone_type,
            { "Zone Type", "zbee_zcl_sas.ias_ace.zone_type", FT_UINT16, BASE_HEX, NULL,
            0x0, NULL, HFILL } },

        { &hf_zbee_zcl_ias_ace_ieee_add,
            { "IEEE Address", "zbee_zcl_sas.ias_ace.ieee_add", FT_BYTES, BASE_NONE, NULL,
            0x0, NULL, HFILL } },

        { &hf_zbee_zcl_ias_ace_srv_rx_cmd_id,
          { "Command", "zbee_zcl_sas.ias_ace.cmd.srv_rx.id", FT_UINT8, BASE_HEX, VALS(zbee_zcl_ias_ace_srv_rx_cmd_names),
            0x0, NULL, HFILL } },

        { &hf_zbee_zcl_ias_ace_srv_tx_cmd_id,
          { "Command", "zbee_zcl_sas.ias_ace.cmd.srv_tx.id", FT_UINT8, BASE_HEX, VALS(zbee_zcl_ias_ace_srv_tx_cmd_names),
            0x0, NULL, HFILL } },

        { &hf_zbee_zcl_ias_ace_starting_zone_id,
          { "Starting Zone ID", "zbee_zcl_sas.ias_ace.cmd.starting_zone_id", FT_UINT8, BASE_HEX, NULL,
            0x0, NULL, HFILL } },

        { &hf_zbee_zcl_ias_ace_max_number_of_zone_ids,
          { "Max Number Of Zone IDs", "zbee_zcl_sas.ias_ace.cmd.max_number_of_zone_ids", FT_UINT8, BASE_DEC, NULL,
            0x0, NULL, HFILL } },

        { &hf_zbee_zcl_ias_ace_zone_status_mask_flag,
          { "Zone Status Mask Flag", "zbee_zcl_sas.ias_ace.cmd.zone_status_mask_flag", FT_BOOLEAN, BASE_NONE, NULL,
            0x0, NULL, HFILL } },

        { &hf_zbee_zcl_ias_ace_zone_status_mask,
          { "Zone Status Mask", "zbee_zcl_sas.ias_ace.cmd.zone_status_mask", FT_UINT16, BASE_HEX, NULL,
            0x0, NULL, HFILL } },

        { &hf_zbee_zcl_ias_ace_zone_status,
          { "Zone Status", "zbee_zcl_sas.ias_ace.cmd.zone_status", FT_UINT16, BASE_HEX, NULL,
            0x0, NULL, HFILL } },

        { &hf_zbee_zcl_ias_ace_zone_audible_notif,
          { "Audible Notification", "zbee_zcl_sas.ias_ace.cmd.zone_audible_notif", FT_UINT16, BASE_HEX, VALS(audible_notif_values),
            0x0, NULL, HFILL } },

        { &hf_zbee_zcl_ias_ace_zone_label,
          { "Zone Label", "zbee_zcl_sas.ias_ace.cmd.zone_label", FT_UINT_STRING, BASE_NONE, NULL,
            0x0, NULL, HFILL } },

        { &hf_zbee_zcl_ias_ace_panel_status,
          { "Panel Status", "zbee_zcl_sas.ias_ace.cmd.panel_status", FT_UINT8, BASE_HEX, VALS(panel_status_values),
            0x0, NULL, HFILL } },

        { &hf_zbee_zcl_ias_ace_seconds_remaining,
          { "Seconds Remaining", "zbee_zcl_sas.ias_ace.cmd.seconds_remaining", FT_UINT8, BASE_DEC, NULL,
            0x0, NULL, HFILL } },

        { &hf_zbee_zcl_ias_ace_alarm_status,
          { "Alarm Status", "zbee_zcl_sas.ias_ace.cmd.alarm_status", FT_UINT8, BASE_HEX, VALS(alarm_status_values),
            0x0, NULL, HFILL } },

        { &hf_zbee_zcl_ias_ace_number_of_zones,
          { "Number of Zones", "zbee_zcl_sas.ias_ace.cmd.number_of_zones", FT_UINT8, BASE_DEC, NULL,
            0x0, NULL, HFILL } },

        { &hf_zbee_zcl_ias_ace_zone_status_complete,
          { "Zone Status Complete", "zbee_zcl_sas.ias_ace.cmd.zone_status_complete", FT_BOOLEAN, BASE_NONE, NULL,
            0x0, NULL, HFILL } },
    };

    /* ZCL IAS ACE subtrees */
    static int *ett[ZBEE_ZCL_IAS_ACE_NUM_ETT];
    ett[0] = &ett_zbee_zcl_ias_ace;
    ett[1] = &ett_zbee_zcl_ias_ace_zone_id;
    ett[2] = &ett_zbee_zcl_ias_ace_zone_id_map_sec;
    ett[3] = &ett_zbee_zcl_ias_ace_zone_id_map_sec_elem;
    ett[4] = &ett_zbee_zcl_ias_ace_bypassed_zone_list;
    ett[5] = &ett_zbee_zcl_ias_ace_bypassed_resp_list;
    ett[6] = &ett_zbee_zcl_ias_ace_get_zone_status_resp_list;

    /* Register the ZigBee ZCL IAS ACE cluster protocol name and description */
    proto_zbee_zcl_ias_ace = proto_register_protocol("ZigBee ZCL IAS ACE", "ZCL IAS ACE", ZBEE_PROTOABBREV_ZCL_IAS_ACE);
    proto_register_field_array(proto_zbee_zcl_ias_ace, hf, array_length(hf));
    proto_register_subtree_array(ett, array_length(ett));

    /* Register the ZigBee ZCL IAS ACE dissector. */
    register_dissector(ZBEE_PROTOABBREV_ZCL_IAS_ACE, dissect_zbee_zcl_ias_ace, proto_zbee_zcl_ias_ace);

} /*proto_register_zbee_zcl_ias_ace*/


/**
 *Hands off the ZCL IAS ACE dissector.
 *
*/
void
proto_reg_handoff_zbee_zcl_ias_ace(void)
{
    zbee_zcl_init_cluster(  ZBEE_PROTOABBREV_ZCL_IAS_ACE,
                            proto_zbee_zcl_ias_ace,
                            ett_zbee_zcl_ias_ace,
                            ZBEE_ZCL_CID_IAS_ACE,
                            ZBEE_MFG_CODE_NONE,
                            -1, -1,
                            hf_zbee_zcl_ias_ace_srv_rx_cmd_id,
                            hf_zbee_zcl_ias_ace_srv_tx_cmd_id,
                            NULL
                         );
} /*proto_reg_handoff_zbee_zcl_ias_ace*/


/* ########################################################################## */
/* #### (0x0502) IAS WD CLUSTER ############################################# */
/* ########################################################################## */

/*************************/
/* Defines               */
/*************************/
#define ZBEE_ZCL_IAS_WD_NUM_ETT                             1
#define ZBEE_ZCL_IAS_WD_WARNING_MODE_MASK                   0xF0
#define ZBEE_ZCL_IAS_WD_STROBE_2BIT_MASK                    0x0C
#define ZBEE_ZCL_IAS_WD_SWQUAWK_MODE_MASK                   0xF0
#define ZBEE_ZCL_IAS_WD_STROBE_1BIT_MASK                    0x08
#define ZBEE_ZCL_IAS_WD_SWQUAWK_LEVEL_MASK                  0x03

/* Attributes */
#define ZBEE_ZCL_ATTR_ID_IAS_WD_MAX_DURATION                0x0000  /* Max Duration */

/* Server Commands Received */
#define ZBEE_ZCL_CMD_ID_IAS_WD_START_WARNING                0x00  /* Start Warning */
#define ZBEE_ZCL_CMD_ID_IAS_WD_SQUAWK                       0x01  /* Squawk */

/*************************/
/* Function Declarations */
/*************************/

void proto_register_zbee_zcl_ias_wd(void);
void proto_reg_handoff_zbee_zcl_ias_wd(void);

/* Command Dissector Helpers */
static void dissect_zcl_ias_wd_attr_data                (proto_tree *tree, tvbuff_t *tvb, unsigned *offset, uint16_t attr_id, unsigned data_type, bool client_attr);
static void dissect_zcl_ias_wd_start_warning            (tvbuff_t *tvb, proto_tree *tree, unsigned *offset);
static void dissect_zcl_ias_wd_squawk                   (tvbuff_t *tvb, proto_tree *tree, unsigned *offset);

/* Private functions prototype */

/*************************/
/* Global Variables      */
/*************************/
/* Initialize the protocol and registered fields */
static int proto_zbee_zcl_ias_wd;

static int hf_zbee_zcl_ias_wd_attr_id;
static int hf_zbee_zcl_ias_wd_warning_mode;
static int hf_zbee_zcl_ias_wd_strobe_2bit;
static int hf_zbee_zcl_ias_wd_squawk_mode;
static int hf_zbee_zcl_ias_wd_strobe_1bit;
static int hf_zbee_zcl_ias_wd_warning_duration;
static int hf_zbee_zcl_ias_wd_squawk_level;
static int hf_zbee_zcl_ias_wd_srv_rx_cmd_id;

/* Initialize the subtree pointers */
static int ett_zbee_zcl_ias_wd;

/* Attributes */
static const value_string zbee_zcl_ias_wd_attr_names[] = {
    { ZBEE_ZCL_ATTR_ID_IAS_WD_MAX_DURATION,                 "Maximum Duration" },
    { 0, NULL }
};

/* Server Commands Received */
static const value_string zbee_zcl_ias_wd_srv_rx_cmd_names[] = {
    { ZBEE_ZCL_CMD_ID_IAS_WD_START_WARNING,      "Start Warning" },
    { ZBEE_ZCL_CMD_ID_IAS_WD_SQUAWK,             "Squawk" },
    { 0, NULL }
};

/* Warning Mode Values */
static const value_string warning_mode_values[] = {
  { 0, "Stop (no warning)" },
  { 1, "Burglar" },
  { 2, "Fire" },
  { 3, "Emergency" },
  { 0, NULL }
};

/* Strobe 2-bit Values */
static const value_string strobe_2bit_values[] = {
  { 0, "No Strobe" },
  { 1, "Use strobe in parallel to warning" },
  { 0, NULL }
};

/* Strobe 1-bit Values */
static const value_string strobe_1bit_values[] = {
  { 0, "No Strobe" },
  { 1, "Use strobe blink in parallel to squawk" },
  { 0, NULL }
};

/* Squawk Mode Values */
static const value_string squawk_mode_values[] = {
  { 0, "Notification sound for 'System is armed'" },
  { 1, "Notification sound for 'System is disarmed'" },
  { 0, NULL }
};

/* Squawk Level Values */
static const value_string squawk_level_values[] = {
  { 0, "Low level sound" },
  { 1, "Medium level sound" },
  { 2, "High level sound" },
  { 3, "Very high level sound" },
  { 0, NULL }
};

/*************************/
/* Function Bodies       */
/*************************/

/**
 *ZigBee ZCL IAS WD cluster dissector for wireshark.
 *
 *@param tvb pointer to buffer containing raw packet.
 *@param pinfo pointer to packet information fields
 *@param tree pointer to data tree Wireshark uses to display packet.
*/
static int
dissect_zbee_zcl_ias_wd(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
{
    proto_tree        *payload_tree;
    zbee_zcl_packet   *zcl;
    unsigned          offset = 0;
    uint8_t           cmd_id;
    int               rem_len;

    /* Reject the packet if data is NULL */
    if (data == NULL)
        return 0;
    zcl = (zbee_zcl_packet *)data;
    cmd_id = zcl->cmd_id;

    /*  Create a subtree for the ZCL Command frame, and add the command ID to it. */
    if (zcl->direction == ZBEE_ZCL_FCF_TO_SERVER) {
        /* Append the command name to the info column. */
        col_append_fstr(pinfo->cinfo, COL_INFO, "%s, Seq: %u",
            val_to_str_const(cmd_id, zbee_zcl_ias_wd_srv_rx_cmd_names, "Unknown Command"),
            zcl->tran_seqno);

        /* Add the command ID. */
        proto_tree_add_item(tree, hf_zbee_zcl_ias_wd_srv_rx_cmd_id, tvb, offset, 1, ENC_LITTLE_ENDIAN);

        /* Check if this command has a payload, then add the payload tree */
        rem_len = tvb_reported_length_remaining(tvb, ++offset);
        if (rem_len > 0) {
            payload_tree = proto_tree_add_subtree(tree, tvb, offset, rem_len, ett_zbee_zcl_ias_wd, NULL, "Payload");

            /* Call the appropriate command dissector */
            switch (cmd_id) {

                case ZBEE_ZCL_CMD_ID_IAS_WD_START_WARNING:
                    dissect_zcl_ias_wd_start_warning(tvb, payload_tree, &offset);
                    break;

                case ZBEE_ZCL_CMD_ID_IAS_WD_SQUAWK:
                    dissect_zcl_ias_wd_squawk(tvb, payload_tree, &offset);
                    break;

                default:
                    break;
            }
        }
    }

    return tvb_captured_length(tvb);
} /*dissect_zbee_zcl_ias_wd*/


/**
 *This function decodes the Start Warning payload.
 *
 *@param  tvb the tv buffer of the current data_type
 *@param  tree the tree to append this item to
 *@param  offset offset of data in tvb
*/
static void
dissect_zcl_ias_wd_start_warning(tvbuff_t *tvb, proto_tree *tree, unsigned *offset)
{
    /* Retrieve "Warning Mode" field */
    proto_tree_add_item(tree, hf_zbee_zcl_ias_wd_warning_mode, tvb, *offset, 1, ENC_LITTLE_ENDIAN);

    /* Retrieve "Strobe" field */
    proto_tree_add_item(tree, hf_zbee_zcl_ias_wd_strobe_2bit, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
    *offset += 1;

    /* Retrieve "Warning Duration" field */
    proto_tree_add_item(tree, hf_zbee_zcl_ias_wd_warning_duration, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
    *offset += 2;

} /*dissect_zcl_ias_wd_start_warning*/


/**
 *This function decodes the Squawk payload.
 *
 *@param  tvb the tv buffer of the current data_type
 *@param  tree the tree to append this item to
 *@param  offset offset of data in tvb
*/
static void
dissect_zcl_ias_wd_squawk(tvbuff_t *tvb, proto_tree *tree, unsigned *offset)
{
    /* Retrieve "Squawk Mode" field */
    proto_tree_add_item(tree, hf_zbee_zcl_ias_wd_squawk_mode, tvb, *offset, 1, ENC_LITTLE_ENDIAN);

    /* Retrieve "Strobe" field */
    proto_tree_add_item(tree, hf_zbee_zcl_ias_wd_strobe_1bit, tvb, *offset, 1, ENC_LITTLE_ENDIAN);

    /* Retrieve "Squawk Level" field */
    proto_tree_add_item(tree, hf_zbee_zcl_ias_wd_squawk_level, tvb, *offset, 1, ENC_LITTLE_ENDIAN);
    *offset += 1;

} /*dissect_zcl_ias_wd_squawk*/


/**
 *This function is called by ZCL foundation dissector in order to decode
 *
 *@param tree pointer to data tree Wireshark uses to display packet.
 *@param tvb pointer to buffer containing raw packet.
 *@param offset pointer to buffer offset
 *@param attr_id attribute identifier
 *@param data_type attribute data type
 *@param client_attr ZCL client
*/
void
dissect_zcl_ias_wd_attr_data(proto_tree *tree, tvbuff_t *tvb, unsigned *offset, uint16_t attr_id, unsigned data_type, bool client_attr)
{
    /* Dissect attribute data type and data */
    switch (attr_id) {
        case ZBEE_ZCL_ATTR_ID_IAS_WD_MAX_DURATION:
        default:
            dissect_zcl_attr_data(tvb, tree, offset, data_type, client_attr);
            break;
    }

} /*dissect_zcl_ias_wd_attr_data*/


/**
 *ZigBee ZCL IAS WD cluster protocol registration routine.
 *
*/
void
proto_register_zbee_zcl_ias_wd(void)
{
    /* Setup list of header fields */
    static hf_register_info hf[] = {

        { &hf_zbee_zcl_ias_wd_attr_id,
            { "Attribute", "zbee_zcl_sas.ias_wd.attr_id", FT_UINT16, BASE_HEX, VALS(zbee_zcl_ias_wd_attr_names),
            0x0, NULL, HFILL } },

        { &hf_zbee_zcl_ias_wd_warning_mode,
            { "Warning Mode", "zbee_zcl_sas.ias_wd.warning_mode", FT_UINT8, BASE_DEC, VALS(warning_mode_values),
            ZBEE_ZCL_IAS_WD_WARNING_MODE_MASK, NULL, HFILL } },

        { &hf_zbee_zcl_ias_wd_strobe_2bit,
            { "Strobe", "zbee_zcl_sas.ias_wd.strobe", FT_UINT8, BASE_DEC, VALS(strobe_2bit_values),
            ZBEE_ZCL_IAS_WD_STROBE_2BIT_MASK, NULL, HFILL } },

        { &hf_zbee_zcl_ias_wd_squawk_mode,
            { "Squawk Mode", "zbee_zcl_sas.ias_wd.squawk_mode", FT_UINT8, BASE_DEC, VALS(squawk_mode_values),
            ZBEE_ZCL_IAS_WD_SWQUAWK_MODE_MASK, NULL, HFILL } },

        { &hf_zbee_zcl_ias_wd_strobe_1bit,
            { "Strobe", "zbee_zcl_sas.ias_wd.strobe", FT_UINT8, BASE_DEC, VALS(strobe_1bit_values),
            ZBEE_ZCL_IAS_WD_STROBE_1BIT_MASK, NULL, HFILL } },

        { &hf_zbee_zcl_ias_wd_warning_duration,
            { "Warning Duration", "zbee_zcl_sas.ias_wd.warning_duration", FT_UINT16, BASE_HEX, NULL,
            0x0, NULL, HFILL } },

        { &hf_zbee_zcl_ias_wd_squawk_level,
            { "Squawk Level", "zbee_zcl_sas.ias_wd.squawk_level", FT_UINT8, BASE_DEC, VALS(squawk_level_values),
            ZBEE_ZCL_IAS_WD_SWQUAWK_LEVEL_MASK, NULL, HFILL } },

        { &hf_zbee_zcl_ias_wd_srv_rx_cmd_id,
          { "Command", "zbee_zcl_sas.ias_wd.cmd.srv_rx.id", FT_UINT8, BASE_HEX, VALS(zbee_zcl_ias_wd_srv_rx_cmd_names),
            0x0, NULL, HFILL } }
    };

    /* ZCL IAS WD subtrees */
    static int *ett[ZBEE_ZCL_IAS_WD_NUM_ETT];
    ett[0] = &ett_zbee_zcl_ias_wd;

    /* Register the ZigBee ZCL IAS WD cluster protocol name and description */
    proto_zbee_zcl_ias_wd = proto_register_protocol("ZigBee ZCL IAS WD", "ZCL IAS WD", ZBEE_PROTOABBREV_ZCL_IAS_WD);
    proto_register_field_array(proto_zbee_zcl_ias_wd, hf, array_length(hf));
    proto_register_subtree_array(ett, array_length(ett));

    /* Register the ZigBee ZCL IAS WD dissector. */
    register_dissector(ZBEE_PROTOABBREV_ZCL_IAS_WD, dissect_zbee_zcl_ias_wd, proto_zbee_zcl_ias_wd);

} /*proto_register_zbee_zcl_ias_wd*/


/**
 *Hands off the ZCL IAS WD dissector.
 *
*/
void
proto_reg_handoff_zbee_zcl_ias_wd(void)
{
    zbee_zcl_init_cluster(  ZBEE_PROTOABBREV_ZCL_IAS_WD,
                            proto_zbee_zcl_ias_wd,
                            ett_zbee_zcl_ias_wd,
                            ZBEE_ZCL_CID_IAS_WD,
                            ZBEE_MFG_CODE_NONE,
                            hf_zbee_zcl_ias_wd_attr_id,
                            hf_zbee_zcl_ias_wd_attr_id,
                            hf_zbee_zcl_ias_wd_srv_rx_cmd_id,
                            -1,
                            (zbee_zcl_fn_attr_data)dissect_zcl_ias_wd_attr_data
                         );
} /*proto_reg_handoff_zbee_zcl_ias_wd*/

/*
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
 *
 * Local variables:
 * c-basic-offset: 4
 * tab-width: 8
 * indent-tabs-mode: nil
 * End:
 *
 * vi: set shiftwidth=4 tabstop=8 expandtab:
 * :indentSize=4:tabSize=8:noTabs=true:
 */