aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/epan/wimax/mac_hd_type2_decoder.c
blob: 4cb74c96b6263649435e111d05f11a4de85574d0 (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
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
/* mac_hd_type2_decoder.c
 * WiMax MAC Type II Signaling Header decoder
 *
 * Copyright (c) 2007 by Intel Corporation.
 *
 * Author: Lu Pan <lu.pan@intel.com>
 *
 * Wireshark - Network traffic analyzer
 * By Gerald Combs <gerald@wireshark.org>
 * Copyright 1999 Gerald Combs
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

/* TODO:  Add FT_UINT24 and FT_INT24 cases to gtk_widget_get_toplevel()
 * to prevent having to make all the changes from BASE_DEC to BASE_HEX
 * made to this file today: 10/20/06.
 */

/*
#define DEBUG
*/

/* Include files */

#include "config.h"

#include <epan/packet.h>
#include "wimax-int.h"

extern gint proto_mac_header_generic_decoder;

static gint proto_mac_header_type_2_decoder = -1;
static gint ett_mac_header_type_2_decoder = -1;
static gint hf_mac_header_type_2_value_bytes = -1;

#define WIMAX_MAC_HEADER_SIZE  6

/* WiMax MAC Header Type II Feedback Types */
typedef enum
{
	CQI_MIMO_FB,         /* 0 */
	DL_AVG_CINR,         /* 1 */
	MIMO_COEF_FB,        /* 2 */
	PREF_DL_CHAN_DIUC_FB,/* 3 */
	UL_TX_PWR,           /* 4 */
	PHY_CHAN_FB,         /* 5 */
	AMC_BAND_BITMAP,     /* 6 */
	SHORT_PRECODE_FB,    /* 7 */
	MULTI_TYPES_FB,      /* 8 */
	LONG_PRECODE_FB,     /* 9 */
	COMB_DL_AVG_CINR,    /* 10 */
	MIMO_CHAN_FB,        /* 11 */
	CINR_FB,             /* 12 */
	CL_MIMO_FB,          /* 13 */
	TYPE_II_FB_TYPE_MAX
} TYPE_II_FB_TYPE_e;

static const char *type2_fb_type_abbrv[TYPE_II_FB_TYPE_MAX] =
{
	"CQI and MIMO Feedback",
	"DL average CINR",
	"MIMO Coefficients Feedback",
	"Preferred DL Channel DIUC Feedback",
	"UL Transmission Power",
	"PHY Channel Feedback",
	"AMC Band Indication Bitmap",
	"Life Span of Short-term Precoding Feedback",
	"Multiple Types of Feedback",
	"Long-term Precoding Feedback",
	"Combined DL Average CINR of Active BSs",
	"MIMO Channel Feedback",
	"CINR Feedback",
	"Close-loop MIMO Feedback"
};

/* WIMAX MAC HEADER TYPE II FILEDS */
/* first byte */
#define WIMAX_MAC_HEADER_TYPE_2_HT           0x80
#define WIMAX_MAC_HEADER_TYPE_2_EC           0x40
#define WIMAX_MAC_HEADER_TYPE_2_TYPE         0x20
#define WIMAX_MAC_HEADER_TYPE_2_CII          0x10
#define WIMAX_MAC_HEADER_TYPE_2_FB_TYPE      0x0F
static int hf_mac_header_type_2_ht = -1;
static int hf_mac_header_type_2_ec = -1;
static int hf_mac_header_type_2_type = -1;
static int hf_mac_header_type_2_cii = -1;
static int hf_mac_header_type_2_fb_type = -1;

/* 2nd to 5th bytes (varies by different fb types) */
static int hf_mac_header_type_2_cid = -1;
static int hf_mac_header_type_2_no_cid = -1;
/* CQI and MIMO Feedback */
/* 2nd & 3rd bytes */
#define WIMAX_MAC_HEADER_TYPE_2_CQI_FB_TYPE  0xE000
#define WIMAX_MAC_HEADER_TYPE_2_CQI_PAYLOAD  0x1F80
#define WIMAX_MAC_HEADER_TYPE_2_CQI_RSV      0x007F
static int hf_mac_header_type_2_cqi_fb_type = -1;
static int hf_mac_header_type_2_cqi_payload = -1;
static int hf_mac_header_type_2_cqi_rsv = -1;
/* 4th & 5th without CID */
/*#define WIMAX_MAC_HEADER_TYPE_2_NO_CID       0xFFFF*/

/* DL average CINR */
/* 2nd byte */
#define WIMAX_MAC_HEADER_TYPE_2_DL_AVE_CINR  0xF800
#define WIMAX_MAC_HEADER_TYPE_2_DL_AVE_RSV   0x07FF
static int hf_mac_header_type_2_dl_ave_cinr = -1;
static int hf_mac_header_type_2_dl_ave_rsv = -1;

/* MIMO Coefficients Feedback */
/* 2nd & 3rd bytes */
#define WIMAX_MAC_HEADER_TYPE_2_MIMO_COEF_NI   0xC000
#define WIMAX_MAC_HEADER_TYPE_2_MIMO_COEF_AI   0x3000
#define WIMAX_MAC_HEADER_TYPE_2_MIMO_COEF      0x0F80
#define WIMAX_MAC_HEADER_TYPE_2_MIMO_COEF_RSV  0x007F
static int hf_mac_header_type_2_mimo_coef_ni = -1;
static int hf_mac_header_type_2_mimo_coef_ai = -1;
static int hf_mac_header_type_2_mimo_coef = -1;
static int hf_mac_header_type_2_mimo_coef_rsv = -1;

/* Preferred DL Channel DIUC Feedback */
/* 2nd byte */
#define WIMAX_MAC_HEADER_TYPE_2_DL_CHAN_DIUC  0xF000
#define WIMAX_MAC_HEADER_TYPE_2_DL_CHAN_DCD   0x0F00
#define WIMAX_MAC_HEADER_TYPE_2_DL_CHAN_RSV   0x00FF
static int hf_mac_header_type_2_dl_chan_diuc = -1;
static int hf_mac_header_type_2_dl_chan_dcd = -1;
static int hf_mac_header_type_2_dl_chan_rsv = -1;

/* UL Transmission Power */
/* 2nd byte */
#define WIMAX_MAC_HEADER_TYPE_2_UL_TX_PWR     0xFF00
#define WIMAX_MAC_HEADER_TYPE_2_UL_TX_PWR_RSV 0x00FF
static int hf_mac_header_type_2_ul_tx_pwr = -1;
static int hf_mac_header_type_2_ul_tx_pwr_rsv = -1;

/* PHY Channel Feedback */
/* 2nd to 4th bytes */
#define WIMAX_MAC_HEADER_TYPE_2_PHY_DIUC      0xF00000
#define WIMAX_MAC_HEADER_TYPE_2_PHY_UL_TX_PWR 0x0FF000
#define WIMAX_MAC_HEADER_TYPE_2_PHY_UL_HDRM   0x000FC0
#define WIMAX_MAC_HEADER_TYPE_2_PHY_RSV       0x00003F
static int hf_mac_header_type_2_phy_diuc = -1;
static int hf_mac_header_type_2_phy_ul_tx_pwr = -1;
static int hf_mac_header_type_2_phy_ul_hdrm = -1;
static int hf_mac_header_type_2_phy_rsv = -1;

/* AMC Band Indication Bitmap */
/* 2nd to 5th bytes */
#define WIMAX_MAC_HEADER_TYPE_2_AMC_BITMAP   0xFFF00000
#define WIMAX_MAC_HEADER_TYPE_2_AMC_CQI_1    0x000F8000
#define WIMAX_MAC_HEADER_TYPE_2_AMC_CQI_2    0x00007C00
#define WIMAX_MAC_HEADER_TYPE_2_AMC_CQI_3    0x000003E0
#define WIMAX_MAC_HEADER_TYPE_2_AMC_CQI_4    0x0000001F
static int hf_mac_header_type_2_amc_bitmap = -1;
static int hf_mac_header_type_2_amc_cqi_1 = -1;
static int hf_mac_header_type_2_amc_cqi_2 = -1;
static int hf_mac_header_type_2_amc_cqi_3 = -1;
static int hf_mac_header_type_2_amc_cqi_4 = -1;

/* Life Span of Short-term Precoding Feedback */
/* 2nd byte */
#define WIMAX_MAC_HEADER_TYPE_2_LIFE_SPAN  0xF000
#define WIMAX_MAC_HEADER_TYPE_2_LIFE_SPAN_RSV 0x0FFF
static int hf_mac_header_type_2_life_span = -1;
static int hf_mac_header_type_2_life_span_rsv = -1;

/* Multiple Types of Feedback */
/* 2nd to 5th bytes ??? */
#define WIMAX_MAC_HEADER_TYPE_2_MT_NUM_FB_TYPES 0xC0000000
#define WIMAX_MAC_HEADER_TYPE_2_MT_OCCU_FB_TYPE 0x3C000000
#define WIMAX_MAC_HEADER_TYPE_2_MT_FB_CONTENTS  0x03FFFFFF
static int hf_mac_header_type_2_mt_num_fb_types = -1;
static int hf_mac_header_type_2_mt_occu_fb_type = -1;
static int hf_mac_header_type_2_mt_fb_contents = -1;

/* Long-term Precoding Feedback */
/* 2nd & 3rd bytes */
#define WIMAX_MAC_HEADER_TYPE_2_LT_ID_FB     0xFC00
#define WIMAX_MAC_HEADER_TYPE_2_LT_RANK      0x0300
#define WIMAX_MAC_HEADER_TYPE_2_LT_FEC_QAM   0x00FC
#define WIMAX_MAC_HEADER_TYPE_2_LT_RSV       0x0003
static int hf_mac_header_type_2_lt_id_fb = -1;
static int hf_mac_header_type_2_lt_rank = -1;
static int hf_mac_header_type_2_lt_fec_qam = -1;
static int hf_mac_header_type_2_lt_rsv = -1;

/* Combined DL Average CINR of Active BSs */
/* 2nd & 3rd bytes */
#define WIMAX_MAC_HEADER_TYPE_2_COMB_DL_AVE  0xF800
#define WIMAX_MAC_HEADER_TYPE_2_COMB_DL_RSV  0x0EFF
static int hf_mac_header_type_2_comb_dl_ave = -1;
static int hf_mac_header_type_2_comb_dl_rsv = -1;

/* MIMO Channel Feedback */
/* 2nd byte */
#define WIMAX_MAC_HEADER_TYPE_2_DIUC         0xF0
#define WIMAX_MAC_HEADER_TYPE_2_PBWI         0x0F
/* 3rd to 5th bytes with CID */
#define WIMAX_MAC_HEADER_TYPE_2_SLPB         0xFE0000
#define WIMAX_MAC_HEADER_TYPE_2_PBRI_CID     0x010000
#define WIMAX_MAC_HEADER_TYPE_2_CID          0x00FFFF
/* 3rd to 5th bytes without CID */
#define WIMAX_MAC_HEADER_TYPE_2_PBRI         0x018000
#define WIMAX_MAC_HEADER_TYPE_2_CTI          0x007000
#define WIMAX_MAC_HEADER_TYPE_2_AI_0         0x000800
#define WIMAX_MAC_HEADER_TYPE_2_AI_1         0x000400
#define WIMAX_MAC_HEADER_TYPE_2_AI_2         0x000200
#define WIMAX_MAC_HEADER_TYPE_2_AI_3         0x000100
#define WIMAX_MAC_HEADER_TYPE_2_MI           0x0000C0
#define WIMAX_MAC_HEADER_TYPE_2_CT           0x000020
#define WIMAX_MAC_HEADER_TYPE_2_CQI          0x00001F
static int hf_mac_header_type_2_mimo_diuc = -1;
static int hf_mac_header_type_2_mimo_pbwi = -1;
static int hf_mac_header_type_2_mimo_slpb = -1;
static int hf_mac_header_type_2_mimo_bpri = -1;
static int hf_mac_header_type_2_mimo_bpri_cid = -1;
static int hf_mac_header_type_2_mimo_cid = -1;
static int hf_mac_header_type_2_mimo_cti = -1;
static int hf_mac_header_type_2_mimo_ai_0 = -1;
static int hf_mac_header_type_2_mimo_ai_1 = -1;
static int hf_mac_header_type_2_mimo_ai_2 = -1;
static int hf_mac_header_type_2_mimo_ai_3 = -1;
static int hf_mac_header_type_2_mimo_mi = -1;
static int hf_mac_header_type_2_mimo_ct = -1;
static int hf_mac_header_type_2_mimo_cqi = -1;

/* CINR Feedback */
/* 2nd byte */
/*#define WIMAX_MAC_HEADER_TYPE_2_CINR_MEAN    0xFF*/
/* 3rd byte */
/*#define WIMAX_MAC_HEADER_TYPE_2_CINR_DEVI    0xFF*/
static int hf_mac_header_type_2_cinr_mean = -1;
static int hf_mac_header_type_2_cinr_devi = -1;

/* Close-loop MIMO Feedback */
/* 2nd & 3rd bytes */
#define WIMAX_MAC_HEADER_TYPE_2_CL_MIMO_TYPE        0xC000
#define WIMAX_MAC_HEADER_TYPE_2_CL_MIMO_ANT_ID      0x3C00
#define WIMAX_MAC_HEADER_TYPE_2_CL_MIMO_CQI         0x03E0
#define WIMAX_MAC_HEADER_TYPE_2_CL_MIMO_RSV         0x008F
#define WIMAX_MAC_HEADER_TYPE_2_CL_MIMO_STREAMS     0x3000
#define WIMAX_MAC_HEADER_TYPE_2_CL_MIMO_ANT_SEL     0x0E00
#define WIMAX_MAC_HEADER_TYPE_2_CL_MIMO_CQI_1       0x01F0
#define WIMAX_MAC_HEADER_TYPE_2_CL_MIMO_RSV_1       0x000F
#define WIMAX_MAC_HEADER_TYPE_2_CL_MIMO_CODEBOOK_ID 0x3F00
#define WIMAX_MAC_HEADER_TYPE_2_CL_MIMO_CQI_2       0x00F8
#define WIMAX_MAC_HEADER_TYPE_2_CL_MIMO_RSV_2       0x000E
static int hf_mac_header_type_2_cl_mimo_type = -1;
static int hf_mac_header_type_2_cl_mimo_ant_id = -1;
static int hf_mac_header_type_2_cl_mimo_cqi = -1;
static int hf_mac_header_type_2_cl_mimo_cqi_1 = -1;
static int hf_mac_header_type_2_cl_mimo_cqi_2 = -1;
static int hf_mac_header_type_2_cl_mimo_rsv = -1;
static int hf_mac_header_type_2_cl_mimo_rsv_1 = -1;
static int hf_mac_header_type_2_cl_mimo_rsv_2 = -1;
static int hf_mac_header_type_2_cl_mimo_streams = -1;
static int hf_mac_header_type_2_cl_mimo_ant_sel = -1;
static int hf_mac_header_type_2_cl_mimo_codebook_id = -1;

/* last byte */
/*#define WIMAX_MAC_HEADER_TYPE_2_HCS          0xFF*/
static int hf_mac_header_type_2_hcs = -1;

/* CID Inclusion Indication messages */
static const value_string cii_msgs[] =
{
	{ 0, "without CID" },
	{ 1, "with CID" },
	{ 0,  NULL}
};

/* Feedback Types */
static const value_string fb_types[] =
{
	{ 0, "CQI and MIMO Feedback" },
	{ 1, "DL average CINR" },
	{ 2, "MIMO Coefficients Feedback" },
	{ 3, "Preferred DL Channel DIUC Feedback" },
	{ 4, "UL Transmission Power" },
	{ 5, "PHY Channel Feedback" },
	{ 6, "AMC Band Indication Bitmap" },
	{ 7, "Life Span of Short-term Precoding Feedback" },
	{ 8, "Multiple Types of Feedback" },
	{ 9, "Long-term Precoding Feedback" },
	{ 10, "Combined DL Average CINR of Active BSs" },
	{ 11, "MIMO Channel Feedback" },
	{ 12, "CINR Feedback" },
	{ 13, "Close-loop MIMO Feedback" },
	{ 14, "Reserved" },
	{ 15, "Reserved" },
	{ 0,  NULL}
};

/* Table of the Preferred Bandwidth Ratio of bandwidth over used channel bandwidth */
static const value_string pbwi_table[] =
{
	{ 0, "1" },
	{ 1, "3/4" },
	{ 2, "2/3" },
	{ 3, "1/2" },
	{ 4, "1/3" },
	{ 5, "1/4" },
	{ 6, "1/5" },
	{ 7, "1/6" },
	{ 8, "1/8" },
	{ 9, "1/10" },
	{ 10, "1/12" },
	{ 11, "1/16" },
	{ 12, "1/24" },
	{ 13, "1/32" },
	{ 14, "1/48" },
	{ 15, "1/64" },
	{ 0,  NULL}
};

/* Burst Profile Ranking Indicator table */
static const value_string bpri_table[] =
{
	{ 0, "1st preferred burst profile" },
	{ 1, "2nd preferred burst profile" },
	{ 2, "3rd preferred burst profile" },
	{ 3, "4th preferred burst profile" },
	{ 0,  NULL}
};

/* Coherent Time Index Table */
static const value_string cti_table[] =
{
	{ 0, "Infinite" },
	{ 1, "1 frame" },
	{ 2, "2 frames" },
	{ 3, "3 frames" },
	{ 4, "4 frames" },
	{ 5, "8 frames" },
	{ 6, "14 frames" },
	{ 7, "24 frames" },
	{ 0,  NULL}
};

/* The MS Matrix Index Table */
static const value_string mi_table[] =
{
	{ 0, "No STC" },
	{ 1, "Matrix A" },
	{ 2, "Matrix B" },
	{ 3, "Matrix C" },
	{ 0,  NULL}
};

/* CQI Feedback Types */
static const value_string ct_msgs[] =
{
	{ 0, "DL average feedback" },
	{ 1, "CQI feedback" },
	{ 0,  NULL}
};

/* Antenna Indication messages */
static const value_string ai_msgs[] =
{
	{ 0, "Not applicable" },
	{ 1, "Applicable" },
	{ 0,  NULL}
};


static int dissect_mac_header_type_2_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
	gint tvb_len, offset = 0;
	guint cii_bit, first_byte, fb_type, mimo_type;
	proto_item *parent_item = NULL;
	proto_item *ti = NULL;
	proto_tree *ti_tree = NULL;

	{	/* we are being asked for details */
		/* Get the tvb reported length */
		tvb_len =  tvb_reported_length(tvb);
		/* display the MAC Type II Header message */
		ti = proto_tree_add_protocol_format(tree, proto_mac_header_type_2_decoder, tvb, offset, tvb_len, "Mac Type II Header (6 bytes)");
		/* add subtree */
		ti_tree = proto_item_add_subtree(ti, ett_mac_header_type_2_decoder);
		if(tvb_len < WIMAX_MAC_HEADER_SIZE)
		{
			/* display the error message */
			proto_tree_add_protocol_format(ti_tree, proto_mac_header_type_2_decoder, tvb, offset, tvb_len, "Error: the size of Mac Header Type II tvb is too small! (%u bytes)", tvb_len);
			/* display the MAC Type II Header in Hex */
			proto_tree_add_item(ti_tree, hf_mac_header_type_2_value_bytes, tvb, offset, tvb_len, ENC_NA);
			return tvb_captured_length(tvb);
		}
#ifdef DEBUG
		/* update the info column */
		col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "MAC Signaling Header Type II");
#endif
		/* get the parent */
		parent_item = proto_tree_get_parent(tree);
		/* Decode and display the first byte of the header */
		/* header type */
		proto_tree_add_item(ti_tree, hf_mac_header_type_2_ht, tvb, offset, 1, ENC_BIG_ENDIAN);
		/* encryption control */
		proto_tree_add_item(ti_tree, hf_mac_header_type_2_ec, tvb, offset, 1, ENC_BIG_ENDIAN);
		/* sub-type */
		proto_tree_add_item(ti_tree, hf_mac_header_type_2_type, tvb, offset, 1, ENC_BIG_ENDIAN);
		/* CID inclusion indication */
		proto_tree_add_item(ti_tree, hf_mac_header_type_2_cii, tvb, offset, 1, ENC_BIG_ENDIAN);
		/* feedback type */
		proto_tree_add_item(ti_tree, hf_mac_header_type_2_fb_type, tvb, offset, 1, ENC_BIG_ENDIAN);
		/* Get the first byte */
		first_byte = tvb_get_guint8(tvb, offset);
		/* get the CII field */
		cii_bit = ((first_byte & WIMAX_MAC_HEADER_TYPE_2_CII)?1:0);
		/* check the Type field */
		if(!(first_byte & WIMAX_MAC_HEADER_TYPE_2_TYPE))
		{
			/* Get the feedback type */
			fb_type = (first_byte & WIMAX_MAC_HEADER_TYPE_2_FB_TYPE);
			if(fb_type < TYPE_II_FB_TYPE_MAX)
			{
				/* update the info column */
				col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, type2_fb_type_abbrv[fb_type]);
			}
			else
			{
				/* update the info column */
				col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "Unknown type 2 fb type");
				/* display the MAC Type I Header in Hex */
				proto_tree_add_item(ti_tree, hf_mac_header_type_2_value_bytes, tvb, offset, tvb_len, ENC_NA);
				return tvb_captured_length(tvb);
			}
			/* move to the second byte */
			offset++;
			/* add the MAC header info */
			proto_item_append_text(parent_item, "%s", type2_fb_type_abbrv[fb_type]);
			/* process the feedback header based on the fb type */
			switch (fb_type)
			{
			case CQI_MIMO_FB:
				/* Decode and display the CQI and MIMO feedback */
				/* CQI feedback type */
				proto_tree_add_item(ti_tree, hf_mac_header_type_2_cqi_fb_type, tvb, offset, 2, ENC_BIG_ENDIAN);
				/* CQI payload */
				proto_tree_add_item(ti_tree, hf_mac_header_type_2_cqi_payload, tvb, offset, 2, ENC_BIG_ENDIAN);
				/* reserved */
				proto_tree_add_item(ti_tree, hf_mac_header_type_2_cqi_rsv, tvb, offset, 2, ENC_BIG_ENDIAN);
				/* check the CII field */
				if(cii_bit)
				{	/* with CID */
					/* CID */
					proto_tree_add_item(ti_tree, hf_mac_header_type_2_cid, tvb, (offset+2), 2, ENC_BIG_ENDIAN);
				}
				else
				{	/* without CID */
					/* reserved */
					proto_tree_add_item(ti_tree, hf_mac_header_type_2_no_cid, tvb, (offset+2), 2, ENC_BIG_ENDIAN);
				}
			break;
			case DL_AVG_CINR:
				/* Decode and display the DL average CINR feedback */
				/* DL average CINR payload */
				proto_tree_add_item(ti_tree, hf_mac_header_type_2_dl_ave_cinr, tvb, offset, 2, ENC_BIG_ENDIAN);
				/* reserved */
				proto_tree_add_item(ti_tree, hf_mac_header_type_2_dl_ave_rsv, tvb, offset, 2, ENC_BIG_ENDIAN);
				/* check the CII field */
				if(cii_bit)
				{	/* with CID */
					/* CID */
					proto_tree_add_item(ti_tree, hf_mac_header_type_2_cid, tvb, (offset+2), 2, ENC_BIG_ENDIAN);
				}
				else
				{	/* without CID */
					/* reserved */
					proto_tree_add_item(ti_tree, hf_mac_header_type_2_no_cid, tvb, (offset+2), 2, ENC_BIG_ENDIAN);
				}
			break;
			case MIMO_COEF_FB:
				/* Decode and display the MIMO coefficients feedback */
				/* number of index */
				proto_tree_add_item(ti_tree, hf_mac_header_type_2_mimo_coef_ni, tvb, offset, 2, ENC_BIG_ENDIAN);
				/* occurrences of antenna index */
				proto_tree_add_item(ti_tree, hf_mac_header_type_2_mimo_coef_ai, tvb, offset, 2, ENC_BIG_ENDIAN);
				/* MIMO coefficients */
				proto_tree_add_item(ti_tree, hf_mac_header_type_2_mimo_coef, tvb, offset, 2, ENC_BIG_ENDIAN);
				/* reserved */
				proto_tree_add_item(ti_tree, hf_mac_header_type_2_mimo_coef_rsv, tvb, offset, 2, ENC_BIG_ENDIAN);
				/* check the CII field */
				if(cii_bit)
				{	/* with CID */
					/* Decode and display the CID */
					proto_tree_add_item(ti_tree, hf_mac_header_type_2_cid, tvb, (offset+2), 2, ENC_BIG_ENDIAN);
				}
				else
				{	/* without CID */
					proto_tree_add_item(ti_tree, hf_mac_header_type_2_no_cid, tvb, (offset+2), 2, ENC_BIG_ENDIAN);
				}
			break;
			case PREF_DL_CHAN_DIUC_FB:
				/* Decode and display the Preffed DL Channel DIUC feedback */
				/* Preferred DIUC */
				proto_tree_add_item(ti_tree, hf_mac_header_type_2_dl_chan_diuc, tvb, offset, 2, ENC_BIG_ENDIAN);
				/* DCD Change Count */
				proto_tree_add_item(ti_tree, hf_mac_header_type_2_dl_chan_dcd, tvb, offset, 2, ENC_BIG_ENDIAN);
				/* reserved */
				proto_tree_add_item(ti_tree, hf_mac_header_type_2_dl_chan_rsv, tvb, offset, 2, ENC_BIG_ENDIAN);
				/* check the CII field */
				if(cii_bit)
				{	/* with CID */
					/* CID */
					proto_tree_add_item(ti_tree, hf_mac_header_type_2_cid, tvb, (offset+2), 2, ENC_BIG_ENDIAN);
				}
				else
				{	/* without CID */
					/* reserved */
					proto_tree_add_item(ti_tree, hf_mac_header_type_2_no_cid, tvb, (offset+2), 2, ENC_BIG_ENDIAN);
				}
			break;
			case UL_TX_PWR:
				/* Decode and display the UL TX Power feedback */
				/* UL TX Power */
				proto_tree_add_item(ti_tree, hf_mac_header_type_2_ul_tx_pwr, tvb, offset, 2, ENC_BIG_ENDIAN);
				/* reserved */
				proto_tree_add_item(ti_tree, hf_mac_header_type_2_ul_tx_pwr_rsv, tvb, offset, 2, ENC_BIG_ENDIAN);
				/* check the CII field */
				if(cii_bit)
				{	/* with CID */
					/* CID */
					proto_tree_add_item(ti_tree, hf_mac_header_type_2_cid, tvb, (offset+2), 2, ENC_BIG_ENDIAN);
				}
				else
				{	/* without CID */
					/* reserved */
					proto_tree_add_item(ti_tree, hf_mac_header_type_2_no_cid, tvb, (offset+2), 2, ENC_BIG_ENDIAN);
				}
			break;
			case PHY_CHAN_FB:
				/* Decode and display the PHY Channel feedback */
				/* Preffed DIUC */
				proto_tree_add_item(ti_tree, hf_mac_header_type_2_phy_diuc, tvb, offset, 2, ENC_BIG_ENDIAN);
				/* UL TX Power */
				proto_tree_add_item(ti_tree, hf_mac_header_type_2_phy_ul_tx_pwr, tvb, offset, 2, ENC_BIG_ENDIAN);
				/* UL Headroom */
				proto_tree_add_item(ti_tree, hf_mac_header_type_2_phy_ul_hdrm, tvb, offset, 2, ENC_BIG_ENDIAN);
				/* reserved */
				proto_tree_add_item(ti_tree, hf_mac_header_type_2_phy_rsv, tvb, offset, 2, ENC_BIG_ENDIAN);
				/* check the CII field */
				if(cii_bit)
				{	/* with CID */
					/* CID */
					proto_tree_add_item(ti_tree, hf_mac_header_type_2_cid, tvb, (offset+2), 2, ENC_BIG_ENDIAN);
				}
				else
				{	/* without CID */
					/* reserved */
					proto_tree_add_item(ti_tree, hf_mac_header_type_2_no_cid, tvb, (offset+2), 2, ENC_BIG_ENDIAN);
				}
			break;
			case AMC_BAND_BITMAP:
				/* Decode and display the AMC Band CQIs feedback */
				/* AMC Band Indication Bitmap */
				proto_tree_add_item(ti_tree, hf_mac_header_type_2_amc_bitmap, tvb, offset, 2, ENC_BIG_ENDIAN);
				/* AMC CQI 1 */
				proto_tree_add_item(ti_tree, hf_mac_header_type_2_amc_cqi_1, tvb, offset, 2, ENC_BIG_ENDIAN);
				/* AMC CQI 2 */
				proto_tree_add_item(ti_tree, hf_mac_header_type_2_amc_cqi_2, tvb, offset, 2, ENC_BIG_ENDIAN);
				/* AMC CQI 3 */
				proto_tree_add_item(ti_tree, hf_mac_header_type_2_amc_cqi_3, tvb, offset, 2, ENC_BIG_ENDIAN);
				/* AMC CQI 4 */
				proto_tree_add_item(ti_tree, hf_mac_header_type_2_amc_cqi_4, tvb, offset, 2, ENC_BIG_ENDIAN);
#if 0
				/* check the CII field */
				if(cii_bit)
				{	/* with CID */
					/* CID */
					proto_tree_add_item(ti_tree, hf_mac_header_type_2_cid, tvb, (offset+2), 2, ENC_BIG_ENDIAN);
				}
				else
				{	/* without CID */
					/* reserved */
					proto_tree_add_item(ti_tree, hf_mac_header_type_2_no_cid, tvb, (offset+2), 2, ENC_BIG_ENDIAN);
				}
#endif
			break;
			case SHORT_PRECODE_FB:
				/* Decode and display the Life Span of Short-term precoding feedback */
				/* Life Span */
				proto_tree_add_item(ti_tree, hf_mac_header_type_2_life_span, tvb, offset, 2, ENC_BIG_ENDIAN);
				/* reserved */
				proto_tree_add_item(ti_tree, hf_mac_header_type_2_life_span_rsv, tvb, offset, 2, ENC_BIG_ENDIAN);
				/* check the CII field */
				if(cii_bit)
				{	/* with CID */
					/* CID */
					proto_tree_add_item(ti_tree, hf_mac_header_type_2_cid, tvb, (offset+2), 2, ENC_BIG_ENDIAN);
				}
				else
				{	/* without CID */
					/* reserved */
					proto_tree_add_item(ti_tree, hf_mac_header_type_2_no_cid, tvb, (offset+2), 2, ENC_BIG_ENDIAN);
				}
			break;
			case MULTI_TYPES_FB:
				/* Decode and display the Multi types of feedback */
				/* Number of feedback types */
				proto_tree_add_item(ti_tree, hf_mac_header_type_2_mt_num_fb_types, tvb, offset, 4, ENC_BIG_ENDIAN);
				/* Occurrences of feedback type */
				proto_tree_add_item(ti_tree, hf_mac_header_type_2_mt_occu_fb_type, tvb, offset, 4, ENC_BIG_ENDIAN);
				/* feedback contents */
				proto_tree_add_item(ti_tree, hf_mac_header_type_2_mt_fb_contents, tvb, offset, 4, ENC_BIG_ENDIAN);
#if 0
				/* check the CII field */
				if(cii_bit)
				{	/* with CID */
					/* CID */
					proto_tree_add_item(ti_tree, hf_mac_header_type_2_cid, tvb, (offset+2), 2, ENC_BIG_ENDIAN);
				}
				else
				{	/* without CID */
					/* reserved */
					proto_tree_add_item(ti_tree, hf_mac_header_type_2_no_cid, tvb, (offset+2), 2, ENC_BIG_ENDIAN);
				}
#endif
			break;
			case LONG_PRECODE_FB:
				/* Decode and display the Long-term precoding feedback */
				/* Feedback of index */
				proto_tree_add_item(ti_tree, hf_mac_header_type_2_lt_id_fb, tvb, offset, 2, ENC_BIG_ENDIAN);
				/* rank of prrecoding codebook */
				proto_tree_add_item(ti_tree, hf_mac_header_type_2_lt_rank, tvb, offset, 2, ENC_BIG_ENDIAN);
				/* EFC and QAM feedback */
				proto_tree_add_item(ti_tree, hf_mac_header_type_2_lt_fec_qam, tvb, offset, 2, ENC_BIG_ENDIAN);
				/* reserved */
				proto_tree_add_item(ti_tree, hf_mac_header_type_2_lt_rsv, tvb, offset, 2, ENC_BIG_ENDIAN);
				/* check the CII field */
				if(cii_bit)
				{	/* with CID */
					/* CID */
					proto_tree_add_item(ti_tree, hf_mac_header_type_2_cid, tvb, (offset+2), 2, ENC_BIG_ENDIAN);
				}
				else
				{	/* without CID */
					/* reserved */
					proto_tree_add_item(ti_tree, hf_mac_header_type_2_no_cid, tvb, (offset+2), 2, ENC_BIG_ENDIAN);
				}
			break;
			case COMB_DL_AVG_CINR:
				/* Decode and display the Combined DL Average CINR feedback */
				/* Combined DL average CINR of Active BSs */
				proto_tree_add_item(ti_tree, hf_mac_header_type_2_comb_dl_ave, tvb, offset, 2, ENC_BIG_ENDIAN);
				/* reserved */
				proto_tree_add_item(ti_tree, hf_mac_header_type_2_comb_dl_rsv, tvb, offset, 2, ENC_BIG_ENDIAN);
				/* check the CII field */
				if(cii_bit)
				{	/* with CID */
					/* CID */
					proto_tree_add_item(ti_tree, hf_mac_header_type_2_cid, tvb, (offset+2), 2, ENC_BIG_ENDIAN);
				}
				else
				{	/* without CID */
					/* reserved */
					proto_tree_add_item(ti_tree, hf_mac_header_type_2_no_cid, tvb, (offset+2), 2, ENC_BIG_ENDIAN);
				}
			break;
			case MIMO_CHAN_FB:
				/* Decode and display the second byte of the header */
				proto_tree_add_item(ti_tree, hf_mac_header_type_2_mimo_diuc, tvb, (offset+1), 1, ENC_BIG_ENDIAN);
				proto_tree_add_item(ti_tree, hf_mac_header_type_2_mimo_pbwi, tvb, (offset+1), 1, ENC_BIG_ENDIAN);
				/* Decode and display the 3rd to 5th bytes of the header */
				/* Decode and display the SLPB */
				proto_tree_add_item(ti_tree, hf_mac_header_type_2_mimo_slpb, tvb, offset, 3, ENC_BIG_ENDIAN);
				/* check the CII field */
				if(cii_bit)
				{	/* with CID */
					/* Decode and display the BPRI */
					proto_tree_add_item(ti_tree, hf_mac_header_type_2_mimo_bpri_cid, tvb, offset, 3, ENC_BIG_ENDIAN);
					/* Decode and display the CID */
					proto_tree_add_item(ti_tree, hf_mac_header_type_2_mimo_cid, tvb, offset, 3, ENC_BIG_ENDIAN);
				}
				else
				{	/* without CID */
					/* Decode and display the BPRI */
					proto_tree_add_item(ti_tree, hf_mac_header_type_2_mimo_bpri, tvb, offset, 3, ENC_BIG_ENDIAN);
					/* Decode and display the CTI */
					proto_tree_add_item(ti_tree, hf_mac_header_type_2_mimo_cti, tvb, offset, 3, ENC_BIG_ENDIAN);
					/* Decode and display the AI */
					proto_tree_add_item(ti_tree, hf_mac_header_type_2_mimo_ai_0, tvb, offset, 3, ENC_BIG_ENDIAN);
					proto_tree_add_item(ti_tree, hf_mac_header_type_2_mimo_ai_1, tvb, offset, 3, ENC_BIG_ENDIAN);
					proto_tree_add_item(ti_tree, hf_mac_header_type_2_mimo_ai_2, tvb, offset, 3, ENC_BIG_ENDIAN);
					proto_tree_add_item(ti_tree, hf_mac_header_type_2_mimo_ai_3, tvb, offset, 3, ENC_BIG_ENDIAN);
					/* Decode and display the MI */
					proto_tree_add_item(ti_tree, hf_mac_header_type_2_mimo_mi, tvb, offset, 3, ENC_BIG_ENDIAN);
					/* Decode and display the CT */
					proto_tree_add_item(ti_tree, hf_mac_header_type_2_mimo_ct, tvb, offset, 3, ENC_BIG_ENDIAN);
					/* Decode and display the CQI */
					proto_tree_add_item(ti_tree, hf_mac_header_type_2_mimo_cqi, tvb, offset, 3, ENC_BIG_ENDIAN);
				}
			break;
			case CINR_FB:
				/* Decode and display the CINRC feedback */
				/* CINR Mean */
				proto_tree_add_item(ti_tree, hf_mac_header_type_2_cinr_mean, tvb, offset, 2, ENC_BIG_ENDIAN);
				/* CINR Standard Deviation */
				proto_tree_add_item(ti_tree, hf_mac_header_type_2_cinr_devi, tvb, offset, 2, ENC_BIG_ENDIAN);
				/* check the CII field */
				if(cii_bit)
				{	/* with CID */
					/* Decode and display the CID */
					proto_tree_add_item(ti_tree, hf_mac_header_type_2_cid, tvb, (offset+2), 2, ENC_BIG_ENDIAN);
				}
				else
				{	/* without CID */
					/* reserved */
					proto_tree_add_item(ti_tree, hf_mac_header_type_2_no_cid, tvb, (offset+2), 2, ENC_BIG_ENDIAN);
				}
			break;
			case CL_MIMO_FB:
				/* Get the MIMO type */
				mimo_type = ((tvb_get_guint8(tvb, offset) & 0xC0) >> 6);
				/* Decode and display the MIMO type */
				proto_tree_add_item(ti_tree, hf_mac_header_type_2_cl_mimo_type, tvb, offset, 2, ENC_BIG_ENDIAN);
				if(mimo_type == 1)
				{
					/* Decode and display the umber of streams */
					proto_tree_add_item(ti_tree, hf_mac_header_type_2_cl_mimo_streams, tvb, offset, 2, ENC_BIG_ENDIAN);
					/* Decode and display the antenna selection option index */
					proto_tree_add_item(ti_tree, hf_mac_header_type_2_cl_mimo_ant_sel, tvb, offset, 2, ENC_BIG_ENDIAN);
					/* Decode and display the average CQI */
					proto_tree_add_item(ti_tree, hf_mac_header_type_2_cl_mimo_cqi_1, tvb, offset, 2, ENC_BIG_ENDIAN);
					/* reserved */
					proto_tree_add_item(ti_tree, hf_mac_header_type_2_cl_mimo_rsv_1, tvb, offset, 2, ENC_BIG_ENDIAN);
				}
				else if(mimo_type == 2)
				{
					/* Decode and display the umber of streams */
					proto_tree_add_item(ti_tree, hf_mac_header_type_2_cl_mimo_streams, tvb, offset, 2, ENC_BIG_ENDIAN);
					/* Decode and display the antenna selection option index */
					proto_tree_add_item(ti_tree, hf_mac_header_type_2_cl_mimo_codebook_id, tvb, offset, 2, ENC_BIG_ENDIAN);
					/* Decode and display the average CQI */
					proto_tree_add_item(ti_tree, hf_mac_header_type_2_cl_mimo_cqi_2, tvb, offset, 2, ENC_BIG_ENDIAN);
					/* reserved */
					proto_tree_add_item(ti_tree, hf_mac_header_type_2_cl_mimo_rsv_2, tvb, offset, 2, ENC_BIG_ENDIAN);
				}
				else
				{
					/* Decode and display the antenna grouping index */
					proto_tree_add_item(ti_tree, hf_mac_header_type_2_cl_mimo_ant_id, tvb, offset, 2, ENC_BIG_ENDIAN);
					/* Decode and display the average CQI */
					proto_tree_add_item(ti_tree, hf_mac_header_type_2_cl_mimo_cqi, tvb, offset, 2, ENC_BIG_ENDIAN);
					/* reserved */
					proto_tree_add_item(ti_tree, hf_mac_header_type_2_cl_mimo_rsv, tvb, offset, 2, ENC_BIG_ENDIAN);
				}
				/* check the CII field */
				if(cii_bit)
				{	/* with CID */
					/* Decode and display the CID */
					proto_tree_add_item(ti_tree, hf_mac_header_type_2_cid, tvb, (offset+2), 2, ENC_BIG_ENDIAN);
				}
				else
				{	/* without CID */
					/* reserved */
					proto_tree_add_item(ti_tree, hf_mac_header_type_2_no_cid, tvb, (offset+2), 2, ENC_BIG_ENDIAN);
				}
			break;
			default:
			break;
			}
			/* Decode and display the HCS */
			proto_tree_add_item(ti_tree, hf_mac_header_type_2_hcs, tvb, (offset+4), 1, ENC_BIG_ENDIAN);
		}
		else
		{
			/* update the info column */
			col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "Error - Undefined Type");
		}
	}
	return tvb_captured_length(tvb);
}

/* Register Wimax Mac Header Type II Protocol and Dissector */
void wimax_proto_register_mac_header_type_2(void)
{
	/* MAC HEADER TYPE II display */
	static hf_register_info hf[] =
	{
		{
			&hf_mac_header_type_2_value_bytes,
			{
				"Values", "wmx.type2ValueBytes",
				FT_BYTES, BASE_NONE, NULL, 0x0,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_ht,
			{
				"MAC Header Type", "wmx.type2Ht",
				FT_UINT8, BASE_DEC, NULL, WIMAX_MAC_HEADER_TYPE_2_HT,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_ec,
			{
				"MAC Encryption Control", "wmx.type2Ec",
				FT_UINT8, BASE_DEC, NULL, WIMAX_MAC_HEADER_TYPE_2_EC,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_type,
			{
				"MAC Sub-Type", "wmx.type2Type",
				FT_UINT8, BASE_DEC, NULL, WIMAX_MAC_HEADER_TYPE_2_TYPE,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_cii,
			{
				"CID Inclusion Indication", "wmx.type2Cii",
				FT_UINT8, BASE_DEC, VALS(cii_msgs), WIMAX_MAC_HEADER_TYPE_2_CII,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_fb_type,
			{
				"Feedback Type", "wmx.type2FbType",
				FT_UINT8, BASE_DEC, VALS(fb_types), WIMAX_MAC_HEADER_TYPE_2_FB_TYPE,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_cqi_fb_type,
			{
				"Mimo Feedback Type", "wmx.type2MimoFbType",
				FT_UINT16, BASE_DEC, NULL, WIMAX_MAC_HEADER_TYPE_2_CQI_FB_TYPE,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_cqi_payload,
			{
				"CQI and Mimo Feedback Payload", "wmx.type2MimoFbPayload",
				FT_UINT16, BASE_DEC, NULL, WIMAX_MAC_HEADER_TYPE_2_CQI_PAYLOAD,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_cqi_rsv,
			{
				"Reserved", "wmx.type2MimoFbRsv",
				FT_UINT16, BASE_DEC, NULL, WIMAX_MAC_HEADER_TYPE_2_CQI_RSV,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_dl_ave_cinr,
			{
				"DL Average CINR", "wmx.type2DlAveCinr",
				FT_UINT16, BASE_DEC, NULL, WIMAX_MAC_HEADER_TYPE_2_DL_AVE_CINR,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_dl_ave_rsv,
			{
				"Reserved", "wmx.type2DlAveRsv",
				FT_UINT16, BASE_DEC, NULL, WIMAX_MAC_HEADER_TYPE_2_DL_AVE_RSV,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_mimo_coef_ni,
			{
				"Number of Index", "wmx.type2MimoCoefNi",
				FT_UINT16, BASE_DEC, NULL, WIMAX_MAC_HEADER_TYPE_2_MIMO_COEF_NI,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_mimo_coef_ai,
			{
				"Occurrences of Antenna Index", "wmx.type2MimoCoefAi",
				FT_UINT16, BASE_DEC, NULL, WIMAX_MAC_HEADER_TYPE_2_MIMO_COEF_AI,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_mimo_coef,
			{
				"MIMO Coefficients", "wmx.type2MimoCoef",
				FT_UINT16, BASE_DEC, NULL, WIMAX_MAC_HEADER_TYPE_2_MIMO_COEF,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_mimo_coef_rsv,
			{
				"Reserved", "wmx.type2MimoCoefRsv",
				FT_UINT16, BASE_DEC, NULL, WIMAX_MAC_HEADER_TYPE_2_MIMO_COEF_RSV,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_dl_chan_diuc,
			{
				"Preferred DIUC", "wmx.type2DlChanDiuc",
				FT_UINT16, BASE_DEC, NULL, WIMAX_MAC_HEADER_TYPE_2_DL_CHAN_DIUC,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_dl_chan_dcd,
			{
				"DCD Change Count", "wmx.type2DlChanDcd",
				FT_UINT16, BASE_DEC, NULL, WIMAX_MAC_HEADER_TYPE_2_DL_CHAN_DCD,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_dl_chan_rsv,
			{
				"Reserved", "wmx.type2DlChanRsv",
				FT_UINT16, BASE_DEC, NULL, WIMAX_MAC_HEADER_TYPE_2_DL_CHAN_RSV,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_ul_tx_pwr,
			{
				"UL TX Power", "wmx.type2UlTxPwr",
				FT_UINT16, BASE_DEC, NULL, WIMAX_MAC_HEADER_TYPE_2_UL_TX_PWR,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_ul_tx_pwr_rsv,
			{
				"Reserved", "wmx.type2UlTxPwrRsv",
				FT_UINT16, BASE_DEC, NULL, WIMAX_MAC_HEADER_TYPE_2_UL_TX_PWR_RSV,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_phy_diuc,
			{
				"Preferred DIUC Index", "wmx.type2PhyDiuc",
				FT_UINT24, BASE_DEC, NULL, WIMAX_MAC_HEADER_TYPE_2_PHY_DIUC,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_phy_ul_tx_pwr,
			{
				"UL TX Power", "wmx.type2PhyUlTxPwr",
				FT_UINT24, BASE_DEC, NULL, WIMAX_MAC_HEADER_TYPE_2_PHY_UL_TX_PWR,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_phy_ul_hdrm,
			{
				"UL Headroom", "wmx.type2PhyHdRm",
				FT_UINT24, BASE_DEC, NULL, WIMAX_MAC_HEADER_TYPE_2_PHY_UL_HDRM,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_phy_rsv,
			{
				"Reserved", "wmx.type2PhyRsv",
				FT_UINT24, BASE_DEC, NULL, WIMAX_MAC_HEADER_TYPE_2_PHY_RSV,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_amc_bitmap,
			{
				"AMC Band Indication Bitmap", "wmx.type2AmcBitmap",
				FT_UINT32, BASE_DEC, NULL, WIMAX_MAC_HEADER_TYPE_2_AMC_BITMAP,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_amc_cqi_1,
			{
				"CQI 1", "wmx.type2AmcCqi1",
				FT_UINT32, BASE_DEC, NULL, WIMAX_MAC_HEADER_TYPE_2_AMC_CQI_1,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_amc_cqi_2,
			{
				"CQI 2", "wmx.type2AmcCqi2",
				FT_UINT32, BASE_DEC, NULL, WIMAX_MAC_HEADER_TYPE_2_AMC_CQI_2,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_amc_cqi_3,
			{
				"CQI 3", "wmx.type2AmcCqi3",
				FT_UINT32, BASE_DEC, NULL, WIMAX_MAC_HEADER_TYPE_2_AMC_CQI_3,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_amc_cqi_4,
			{
				"CQI 4", "wmx.type2AmcCqi4",
				FT_UINT32, BASE_DEC, NULL, WIMAX_MAC_HEADER_TYPE_2_AMC_CQI_4,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_life_span,
			{
				"Life Span of Short-term", "wmx.type2LifeSpan",
				FT_UINT16, BASE_DEC, NULL, WIMAX_MAC_HEADER_TYPE_2_LIFE_SPAN,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_life_span_rsv,
			{
				"Reserved", "wmx.type2LifeSpanRsv",
				FT_UINT16, BASE_DEC, NULL, WIMAX_MAC_HEADER_TYPE_2_LIFE_SPAN_RSV,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_mt_num_fb_types,
			{
				"Number of Feedback Types", "wmx.type2MtNumFbTypes",
				FT_UINT32, BASE_DEC, NULL, WIMAX_MAC_HEADER_TYPE_2_MT_NUM_FB_TYPES,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_mt_occu_fb_type,
			{
				"Occurrences of Feedback Type", "wmx.type2MtOccuFbType",
				FT_UINT32, BASE_DEC, NULL, WIMAX_MAC_HEADER_TYPE_2_MT_OCCU_FB_TYPE,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_mt_fb_contents,
			{
				"Number of Feedback Types", "wmx.type2MtNumFbTypes",
				FT_UINT32, BASE_HEX, NULL, WIMAX_MAC_HEADER_TYPE_2_MT_FB_CONTENTS,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_lt_id_fb,
			{
				"Long-term Feedback Index", "wmx.type2LtFbId",
				FT_UINT16, BASE_DEC, NULL, WIMAX_MAC_HEADER_TYPE_2_LT_ID_FB,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_lt_rank,
			{
				"Rank of Precoding Codebook", "wmx.type2LtRank",
				FT_UINT16, BASE_DEC, NULL, WIMAX_MAC_HEADER_TYPE_2_LT_RANK,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_lt_fec_qam,
			{
				"FEC and QAM", "wmx.type2LtFecQam",
				FT_UINT16, BASE_DEC, NULL, WIMAX_MAC_HEADER_TYPE_2_LT_FEC_QAM,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_lt_rsv,
			{
				"Reserved", "wmx.type2LtFbId",
				FT_UINT16, BASE_DEC, NULL, WIMAX_MAC_HEADER_TYPE_2_LT_RSV,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_comb_dl_ave,
			{
				"Combined DL Average CINR of Active BSs", "wmx.type2CombDlAve",
				FT_UINT16, BASE_DEC, NULL, WIMAX_MAC_HEADER_TYPE_2_COMB_DL_AVE,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_comb_dl_rsv,
			{
				"Reserved", "wmx.type2CombDlRsv",
				FT_UINT16, BASE_DEC, NULL, WIMAX_MAC_HEADER_TYPE_2_COMB_DL_RSV,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_mimo_diuc,
			{
				"Preferred DIUC Index", "wmx.type2MimoDiuc",
				FT_UINT8, BASE_DEC, NULL, WIMAX_MAC_HEADER_TYPE_2_DIUC,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_mimo_pbwi,
			{
				"Preferred Bandwidth Index", "wmx.type2MimoPbwi",
				FT_UINT8, BASE_DEC, VALS(pbwi_table), WIMAX_MAC_HEADER_TYPE_2_PBWI,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_mimo_slpb,
			{
				"Starting Location of Preferred Bandwidth", "wmx.type2MimoSlpb",
				FT_UINT24, BASE_DEC, NULL, WIMAX_MAC_HEADER_TYPE_2_SLPB,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_mimo_bpri_cid,
			{
				"Burst Profile Ranking Indicator with CID", "wmx.type2MimoBpriCid",
				FT_UINT24, BASE_HEX, VALS(bpri_table), WIMAX_MAC_HEADER_TYPE_2_PBRI_CID,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_mimo_cid,
			{
				"Connection ID", "wmx.type2MimoCid",
				FT_UINT24, BASE_DEC, NULL, WIMAX_MAC_HEADER_TYPE_2_CID,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_mimo_bpri,
			{
				"Burst Profile Ranking Indicator without CID", "wmx.type2MimoBpri",
				FT_UINT24, BASE_HEX, VALS(bpri_table), WIMAX_MAC_HEADER_TYPE_2_PBRI,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_mimo_cti,
			{
				"Coherent Time Index", "wmx.type2MimoCti",
				FT_UINT24, BASE_HEX, VALS(cti_table), WIMAX_MAC_HEADER_TYPE_2_CTI,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_mimo_ai_0,
			{
				"Antenna 0 Indication", "wmx.type2MimoAi",
				FT_UINT24, BASE_HEX, VALS(ai_msgs), WIMAX_MAC_HEADER_TYPE_2_AI_0,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_mimo_ai_1,
			{
				"Antenna 1 Indication", "wmx.type2MimoAi",
				FT_UINT24, BASE_HEX, VALS(ai_msgs), WIMAX_MAC_HEADER_TYPE_2_AI_1,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_mimo_ai_2,
			{
				"Antenna 2 Indication", "wmx.type2MimoAi",
				FT_UINT24, BASE_HEX, VALS(ai_msgs), WIMAX_MAC_HEADER_TYPE_2_AI_2,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_mimo_ai_3,
			{
				"Antenna 3 Indication", "wmx.type2MimoAi",
				FT_UINT24, BASE_HEX, VALS(ai_msgs), WIMAX_MAC_HEADER_TYPE_2_AI_3,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_mimo_mi,
			{
				"MS Matrix Indicator", "wmx.type2MimoMi",
				FT_UINT24, BASE_HEX, VALS(mi_table), WIMAX_MAC_HEADER_TYPE_2_MI,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_mimo_ct,
			{
				"CQI Type", "wmx.type2MimoCt",
				FT_UINT24, BASE_HEX, VALS(ct_msgs), WIMAX_MAC_HEADER_TYPE_2_CT,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_mimo_cqi,
			{
				"CQI Feedback", "wmx.type2MimoCqi",
				FT_UINT24, BASE_HEX, NULL, WIMAX_MAC_HEADER_TYPE_2_CQI,
				NULL, HFILL
			}
		},
		{	&hf_mac_header_type_2_cinr_mean,
			{
				"CINR Mean", "wmx.type2CinrMean",
				FT_UINT8, BASE_HEX, NULL, 0x0,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_cinr_devi,
			{
				"CINR Standard Deviation", "wmx.type2CinrDevi",
				FT_UINT8, BASE_HEX, NULL, 0x0,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_cl_mimo_type,
			{
				"Closed-Loop MIMO Type", "wmx.type2ClMimoType",
				FT_UINT16, BASE_HEX, NULL, WIMAX_MAC_HEADER_TYPE_2_CL_MIMO_TYPE,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_cl_mimo_ant_id,
			{
				"Antenna Grouping Index", "wmx.type2ClMimoAntId",
				FT_UINT16, BASE_DEC, NULL, WIMAX_MAC_HEADER_TYPE_2_CL_MIMO_ANT_ID,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_cl_mimo_cqi,
			{
				"Average CQI", "wmx.type2ClMimoCqi",
				FT_UINT16, BASE_DEC, NULL, WIMAX_MAC_HEADER_TYPE_2_CL_MIMO_CQI,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_cl_mimo_cqi_1,
			{
				"Average CQI", "wmx.type2ClMimoCqi",
				FT_UINT16, BASE_DEC, NULL, WIMAX_MAC_HEADER_TYPE_2_CL_MIMO_CQI_1,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_cl_mimo_cqi_2,
			{
				"Average CQI", "wmx.type2ClMimoCqi",
				FT_UINT16, BASE_DEC, NULL, WIMAX_MAC_HEADER_TYPE_2_CL_MIMO_CQI_2,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_cl_mimo_rsv,
			{
				"Reserved", "wmx.type2ClMimoRsv",
				FT_UINT16, BASE_DEC, NULL, WIMAX_MAC_HEADER_TYPE_2_CL_MIMO_RSV,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_cl_mimo_rsv_1,
			{
				"Reserved", "wmx.type2ClMimoRsv",
				FT_UINT16, BASE_DEC, NULL, WIMAX_MAC_HEADER_TYPE_2_CL_MIMO_RSV_1,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_cl_mimo_rsv_2,
			{
				"Reserved", "wmx.type2ClMimoRsv",
				FT_UINT16, BASE_DEC, NULL, WIMAX_MAC_HEADER_TYPE_2_CL_MIMO_RSV_2,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_cl_mimo_streams,
			{
				"Number of Streams", "wmx.type2ClMimoStreams",
				FT_UINT16, BASE_DEC, NULL, WIMAX_MAC_HEADER_TYPE_2_CL_MIMO_STREAMS,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_cl_mimo_ant_sel,
			{
				"Antenna Selection Option Index", "wmx.type2ClMimoAntSel",
				FT_UINT16, BASE_DEC, NULL, WIMAX_MAC_HEADER_TYPE_2_CL_MIMO_ANT_SEL,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_cl_mimo_codebook_id,
			{
				"Codebook Index", "wmx.type2ClMimoCodeBkId",
				FT_UINT16, BASE_DEC, NULL, WIMAX_MAC_HEADER_TYPE_2_CL_MIMO_CODEBOOK_ID,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_cid,
			{
				"Connection ID", "wmx.type2Cid",
				FT_UINT16, BASE_DEC, NULL, 0x0,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_no_cid,
			{
				"Reserved", "wmx.type2NoCid",
				FT_UINT16, BASE_HEX, NULL, 0x0,
				NULL, HFILL
			}
		},
		{
			&hf_mac_header_type_2_hcs,
			{
				"Header Check Sequence", "wmx.type2Hcs",
				FT_UINT8, BASE_HEX, NULL, 0x0,
				NULL, HFILL
			}
		}
	};

	/* Setup protocol subtree array */
	static gint *ett[] =
		{
			&ett_mac_header_type_2_decoder,
		};

	proto_mac_header_type_2_decoder = proto_mac_header_generic_decoder;

	proto_register_field_array(proto_mac_header_type_2_decoder, hf, array_length(hf));
	proto_register_subtree_array(ett, array_length(ett));

	register_dissector("mac_header_type_2_handler", dissect_mac_header_type_2_decoder, proto_mac_header_type_2_decoder);
}

/*
 * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
 *
 * Local variables:
 * c-basic-offset: 8
 * tab-width: 8
 * indent-tabs-mode: t
 * End:
 *
 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
 * :indentSize=8:tabSize=8:noTabs=false:
 */