We always HAVE_CONFIG_H so don't bother checking whether we have it or not.
[metze/wireshark/wip.git] / plugins / wimax / msg_dlmap.c
1 /* msg_dlmap.c
2  * WiMax MAC Management DL-MAP Message decoder
3  *
4  * Copyright (c) 2007 by Intel Corporation.
5  *
6  * Author: Mike Harvey <michael.harvey@intel.com>
7  *
8  * $Id$
9  *
10  * Wireshark - Network traffic analyzer
11  * By Gerald Combs <gerald@wireshark.org>
12  * Copyright 1999 Gerald Combs
13  *
14  * This program is free software; you can redistribute it and/or
15  * modify it under the terms of the GNU General Public License
16  * as published by the Free Software Foundation; either version 2
17  * of the License, or (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with this program; if not, write to the Free Software
26  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27  */
28
29 /* Include files */
30
31 #include "config.h"
32
33 #include <glib.h>
34 #include <epan/packet.h>
35 #include "crc.h"
36 #include "wimax_bits.h"
37
38 extern gint proto_wimax;
39 extern  gboolean include_cor2_changes;
40
41 #define MAC_MGMT_MSG_DLMAP 2
42
43 #define XBIT(var, bits, desc) \
44     do { \
45     var = BIT_BITS(bit, bufptr, bits); \
46     proto_tree_add_text(tree, tvb, BITHI(bit, bits), desc ": %d", var); \
47     bit += bits; \
48     } while(0)
49
50 #define VBIT(var, bits, hf) \
51     do { \
52     var = BIT_BITS(bit, bufptr, bits); \
53     proto_tree_add_uint(tree, hf, tvb, BITHI(bit,bits), var); \
54     bit += bits; \
55     } while(0)
56
57 #define XNIB(var, nibs, desc) \
58     do { \
59     var = NIB_NIBS(nib, bufptr, nibs); \
60     proto_tree_add_text(tree, tvb, NIBHI(nib, nibs), desc ": %d", var); \
61     nib += nibs; \
62     } while(0)
63
64 gint harq = 0; /* 1 if HARQ enabled (TODO) */
65 gint fusc = 0; /* 1 if current zone permutation is FUSC or optional FUSC (TODO) */
66 gint tusc = 0; /* 1 if current zone permutation is AMC, TUSC1 or TUSC2 (TODO) */
67 gint ir_type = 0; /* reduced AAS map (TODO) */
68 gint RCID_Type = 0;
69 gint N_layer = 0;
70 gint STC_Zone_Dedicated_Pilots = 0;
71 gint STC_Zone_Matrix = 0;
72 gint INC_CID = 0;
73 gint sub_dl_ul_map = 0;
74
75
76 extern gint man_ofdma;
77
78 gint proto_mac_mgmt_msg_dlmap_decoder = -1;
79
80 static gint ett_dlmap = -1;
81 static gint ett_dlmap_ie = -1;
82 /* static gint ett_dlmap_c_ie = -1; */
83 static gint ett_109x = -1; /* SUB-DL-UL-MAP */
84 static gint ett_109x_dl = -1;
85 static gint ett_109x_ul = -1;
86 static gint ett_275_phy = -1;
87 static gint ett_275_1 = -1;
88 static gint ett_277 = -1;
89 static gint ett_277b = -1;
90 static gint ett_278 = -1;
91 static gint ett_279 = -1;
92 static gint ett_280 = -1;
93 static gint ett_281 = -1;
94 static gint ett_282 = -1;
95 static gint ett_283 = -1;
96 static gint ett_284 = -1;
97 static gint ett_285 = -1;
98 static gint ett_286 = -1;
99 static gint ett_286a = -1;
100 static gint ett_286b = -1;
101 static gint ett_286c = -1;
102 static gint ett_286d = -1;
103 static gint ett_286e = -1;
104 static gint ett_286f = -1;
105 static gint ett_286g = -1;
106 static gint ett_286h = -1;
107 static gint ett_286i = -1;
108 static gint ett_286j = -1;
109 static gint ett_286k = -1;
110 static gint ett_286l = -1;
111 static gint ett_286m = -1;
112 static gint ett_286n = -1;
113 static gint ett_286o = -1;
114 static gint ett_286p = -1;
115 static gint ett_286q = -1;
116 static gint ett_286r = -1;
117 static gint ett_286s = -1;
118 static gint ett_286t = -1;
119 static gint ett_286u = -1;
120 static gint ett_286v = -1;
121 static gint ett_286w = -1;
122 static gint ett_286x = -1;
123 static gint ett_286y = -1;
124 static gint ett_286z = -1;
125 static gint ett_305  = -1;
126 /* static gint ett_305_dl = -1; */
127 static gint ett_308a = -1;
128
129 #define DCD_DOWNLINK_BURST_PROFILE     1
130 #define DCD_BS_EIRP                    2
131 #define DCD_FRAME_DURATION             3
132 #define DCD_PHY_TYPE                   4
133 #define DCD_POWER_ADJUSTMENT           5
134 #define DCD_CHANNEL_NR                 6
135 #define DCD_TTG                        7
136 #define DCD_RTG                        8
137 #define DCD_RSS                        9
138 #define DCD_CHANNEL_SWITCH_FRAME_NR    10
139 #define DCD_FREQUENCY                  12
140 #define DCD_BS_ID                      13
141 #define DCD_FRAME_DURATION_CODE        14
142 #define DCD_FRAME_NR                   15
143 #define DCD_SIZE_CQICH_ID              16
144 #define DCD_H_ARQ_ACK_DELAY            17
145 #define DCD_MAC_VERSION                148
146 #define DCD_RESTART_COUNT              154
147
148 #define DCD_BURST_FREQUENCY            1
149 #define DCD_BURST_FEC_CODE_TYPE        150
150 #define DCD_BURST_DIUC_EXIT_THRESHOLD  151
151 #define DCD_BURST_DIUC_ENTRY_THRESHOLD 152
152 #define DCD_BURST_TCS_ENABLE           153
153
154 #define DCD_TLV_T_541_TYPE_FUNCTION_ACTION                              1
155 #define DCD_TLV_T542_TRIGGER_VALUE                                      2
156 #define DCD_TLV_T_543_TRIGGER_AVERAGING_DURATION                        3
157 #define DCD_TLV_T_19_PERMUTATION_TYPE_FOR_BROADCAST_REGION_IN_HARQ_ZONE 19
158 #define DCD_TLV_T_20_MAXIMUM_RETRANSMISSION                             20
159 #define DCD_TLV_T_21_DEFAULT_RSSI_AND_CINR_AVERAGING_PARAMETER          21
160 #define DCD_TLV_T_22_DL_AMC_ALLOCATED_PHYSICAL_BANDS_BITMAP             22
161 #define DCD_TLV_T_31_H_ADD_THRESHOLD                                    31
162 #define DCD_TLV_T_32_H_DELETE_THRESHOLD                                 32
163 #define DCD_TLV_T_33_ASR                                                33
164 #define DCD_TLV_T_34_DL_REGION_DEFINITION                               34
165 #define DCD_TLV_T_35_PAGING_GROUP_ID                                    35
166 #define DCD_TLV_T_36_TUSC1_PERMUTATION_ACTIVE_SUBCHANNELS_BITMAP        36
167 #define DCD_TLV_T_37_TUSC2_PERMUTATION_ACTIVE_SUBCHANNELS_BITMAP        37
168 #define DCD_TLV_T_45_PAGING_INTERVAL_LENGTH                             45
169 #define DCD_TLV_T_50_HO_TYPE_SUPPORT                                    50
170 #define DCD_TLV_T_51_HYSTERSIS_MARGIN                                   51
171 #define DCD_TLV_T_52_TIME_TO_TRIGGER_DURATION                           52
172 #define DCD_TLV_T_54_TRIGGER                                            54
173 #define DCD_TLV_T_153_DOWNLINK_BURST_PROFILE_FOR_MULTIPLE_FEC_TYPES     153
174
175 #define DL_MAP_NCT_PMP  0
176 #define DL_MAP_NCT_DM   1
177 #define DL_MAP_NCT_PTP  2
178
179 /* NCT messages */
180 static const value_string nct_msgs[] =
181 {
182     { DL_MAP_NCT_PMP, "PMP" },
183     { DL_MAP_NCT_PMP, "DM" },
184     { DL_MAP_NCT_PMP, "PTP" },
185     { 0,  NULL }
186 };
187
188 /* Repetition Coding Indications */
189 static const value_string rep_msgs[] =
190 {
191     { 0, "No Repetition Coding" },
192     { 1, "Repetition Coding of 2 Used" },
193     { 2, "Repetition Coding of 4 Used" },
194     { 3, "Repetition Coding of 6 Used" },
195     { 0,  NULL }
196 };
197
198 /* DL Frame Prefix Coding Indications */
199 static const value_string boost_msgs[] =
200 {
201     { 0, "Normal (not boosted)" },
202     { 1, "+6dB" },
203     { 2, "-6dB" },
204     { 3, "+9dB" },
205     { 4, "+3dB" },
206     { 5, "-3dB" },
207     { 6, "-9dB" },
208     { 7, "-12dB" },
209     { 0,  NULL }
210 };
211
212 /* OFDMA frame duration ms (Table 320)*/
213 static const value_string frame_duration[] =
214 {
215         { 0, "reserved"},
216         { 1, "2 ms"},
217         { 2, "2.5 ms"},
218         { 3, "4 ms"},
219         { 4, "5 ms"},
220         { 5, "8 ms"},
221         { 6, "10 ms"},
222         { 7, "12.5 ms"},
223         { 8, "20 ms"},
224         { 0, NULL}
225 };
226
227 /* OFDMA frames per second (Table 320)*/
228 static const value_string frames_per_second[] =
229 {
230         { 0, "reserved"},
231         { 1, "500"},
232         { 2, "400"},
233         { 3, "250"},
234         { 4, "200"},
235         { 5, "125"},
236         { 6, "100"},
237         { 7, "80"},
238         { 8, "50"},
239         { 0, NULL}
240 };
241
242 /* dl-map fields */
243 static gint hf_dlmap_message_type = -1;
244
245 static gint hf_dlmap_phy_fdur = -1;
246 static gint hf_dlmap_phy_fdur_ms = -1;
247 static gint hf_dlmap_phy_fdur_per_sec = -1;
248 static gint hf_dlmap_phy_fnum = -1;
249 static gint hf_dlmap_fch_expected = -1;
250 static gint hf_dlmap_dcd = -1;
251 static gint hf_dlmap_bsid = -1;
252 static gint hf_dlmap_ofdma_sym = -1;
253 static gint hf_dlmap_ie = -1;
254 static gint hf_dlmap_ie_diuc = -1;
255 static gint hf_dlmap_ie_ncid = -1;
256 static gint hf_dlmap_ie_cid = -1;
257 static gint hf_dlmap_ie_offsym = -1;
258 static gint hf_dlmap_ie_offsub = -1;
259 static gint hf_dlmap_ie_boosting = -1;
260 static gint hf_dlmap_ie_numsym = -1;
261 static gint hf_dlmap_ie_numsub = -1;
262 static gint hf_dlmap_ie_rep = -1;
263 static gint hf_dlmap_ie_offsym2 = -1;
264 static gint hf_dlmap_ie_offsub2 = -1;
265 static gint hf_dlmap_ie_boosting2 = -1;
266 static gint hf_dlmap_ie_numsym2 = -1;
267 static gint hf_dlmap_ie_numsub2 = -1;
268 static gint hf_dlmap_ie_rep2 = -1;
269
270 static gint hf_dlmap_xie_diuc = -1;
271 static gint hf_dlmap_xie_len = -1;
272
273 static gint hf_dlmapc_compr = -1;
274 static gint hf_dlmapc_ulmap = -1;
275 static gint hf_dlmapc_rsv = -1;
276 static gint hf_dlmapc_len = -1;
277 static gint hf_dlmapc_sync = -1;
278 static gint hf_dlmapc_opid = -1;
279 static gint hf_dlmapc_secid = -1;
280 static gint hf_dlmapc_count = -1;
281
282 static gint hf_109x_cmi = -1;
283 static gint hf_109x_len = -1;
284 static gint hf_109x_rcid = -1;
285 static gint hf_109x_haoi = -1;
286 static gint hf_109x_dl = -1;
287 static gint hf_109x_ul = -1;
288 static gint hf_109x_dlie = -1;
289 static gint hf_109x_symofs = -1;
290 static gint hf_109x_subofs = -1;
291 static gint hf_109x_rsv = -1;
292
293 static gint hf_308a_cmi = -1;
294 static gint hf_308a_ulmap = -1;
295 static gint hf_308a_type = -1;
296 static gint hf_308a_mult = -1;
297 static gint hf_308a_rsv = -1;
298 static gint hf_mac_header_compress_dlmap_crc = -1;
299
300 /********************************************************************
301  * DL-MAP Miscellaneous IEs and TLVs
302  *******************************************************************/
303
304 gint RCID_IE(proto_tree *diuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb, gint RCID_Type_lcl)
305 {
306     /* RCID_IE 8.4.5.3 and 8.4.5.3.20.1 */
307     /* offset of IE in bits, length is variable  */
308     gint bit = offset;
309     proto_item *ti = NULL;
310     proto_tree *tree = NULL;
311     gint Prefix = 0;
312     gint cid = 0;
313
314     if (RCID_Type_lcl == 0)
315         length = 16;
316     else {
317         Prefix = BIT_BIT(bit, bufptr);
318         if (Prefix == 1) length = 12;
319         else if (RCID_Type_lcl == 1) length = 12;
320         else if (RCID_Type_lcl == 2) length = 8;
321         else if (RCID_Type_lcl == 3) length = 4;
322     }
323
324     ti = proto_tree_add_text(diuc_tree, tvb, BITHI(bit, length), "RCID_IE");
325     tree = proto_item_add_subtree(ti, ett_286j);
326
327     if (RCID_Type_lcl == 0) {
328         XBIT(cid, 16, "CID");
329     } else {
330         proto_tree_add_text(tree, tvb, BITHI(bit,1), "Prefix: %d", Prefix);
331         bit++;
332
333         if (Prefix == 1) {
334             /* RCID 11 */
335             XBIT(cid, 11, "CID11");
336         } else {
337             if (RCID_Type_lcl == 1) {
338                 /* RCID 11 */
339                 XBIT(cid, 11, "CID11");
340             } else if (RCID_Type_lcl == 2) {
341                 /* RCID 7 */
342                 XBIT(cid, 7, "CID7");
343             } else if (RCID_Type_lcl == 3) {
344                 /* RCID 3 */
345                 XBIT(cid, 3, "CID3");
346             }
347         }
348     }
349
350     proto_item_append_text(ti, " (CID = %d)", cid);
351
352     return length; /* return length in bits */
353 }
354
355 /********************************************************************
356  * DL-MAP Extended-2 HARQ sub-burst IEs (8.4.5.3.21)
357  *******************************************************************/
358
359 gint Dedicated_DL_Control_IE(proto_tree *diuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
360 {
361     /* 8.4.5.3.20 */
362     /* offset of IE in nibbles, length is variable */
363     gint nib;
364     gint nibble;
365     proto_item *ti = NULL;
366     proto_tree *tree = NULL;
367     gint len;
368
369     nib = offset;
370
371     length = NIB_NIBBLE(nib, bufptr); /* length in nibbles */
372
373     ti = proto_tree_add_text(diuc_tree, tvb, NIBHI(nib, length+1), "Dedicated_DL_Control_IE");
374     tree = proto_item_add_subtree(ti, ett_286i);
375
376     proto_tree_add_text(tree, tvb, NIBHI(nib,1), "Length: %d", length);
377     nib++;
378     nibble = NIB_NIBBLE(nib, bufptr);
379     proto_tree_add_text(tree, tvb, NIBHI(nib,1), "Control Header: %d", nibble);
380     nib++;
381     if ((nibble & 1) == 1) {
382         nibble = NIB_NIBBLE(nib, bufptr);
383         proto_tree_add_text(tree, tvb, NIBHI(nib,1), "Num SDMA Layers: %d", (nibble >> 2) & 0x3);
384         /* Bit padding */
385         if ((nib*4)+2 < (offset+length)*4) {
386             len = ((offset + length - nib) * 4) - 2;
387             proto_tree_add_text(tree, tvb, BITHI(nib*4, len), "Reserved bits");
388         }
389     } else {
390         /* Nibble padding */
391         if (nib < offset+length) {
392             len = (offset + length) - nib;
393             proto_tree_add_text(tree, tvb, NIBHI(nib,len), "Reserved bits");
394         }
395     }
396     return (length + 1);
397 }
398
399 gint Dedicated_MIMO_DL_Control_IE(proto_tree *diuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
400 {
401     /* offset of IE in bits, length is variable */
402     gint bit;
403     gint data;
404     proto_item *ti = NULL;
405     proto_tree *tree = NULL;
406     gint mci, cqi, cmi, matrix = 0, pad, CQICH_num, mimo_mode;
407     gint j;
408
409     bit = offset;
410
411     /* 8.4.5.3.21 table 286t */
412     ti = proto_tree_add_text(diuc_tree, tvb, BITHI(bit, 1), "Dedicated MIMO DL Control IE");
413     tree = proto_item_add_subtree(ti, ett_286t);
414
415     XBIT(length, 5, "Length (nibbles)");
416     XBIT(mci, 1, "Control Header (MIMO Control Info)");
417     XBIT(cqi, 1, "Control Header (CQI Control Info)");
418     XBIT(cmi, 1, "Control Header (Closed MIMO Control Info)");
419     XBIT(N_layer, 2, "N_layer");
420
421     /* MIMO Control Info */
422     if (mci == 1) {
423         XBIT(matrix, 2, "Matrix");
424         if (STC_Zone_Dedicated_Pilots == 1) {
425             XBIT(data, 2, "Num_Beamformed_Streams");
426         }
427     }
428
429     /* CQICH Control Info */
430     if (cqi == 1) {
431         XBIT(data, 3, "Period");
432         XBIT(data, 3, "Frame Offset");
433         XBIT(data, 4, "Duration");
434         for (j = 0; j < N_layer; j++) {
435             XBIT(data, 6, "Allocation Index");
436         }
437         XBIT(CQICH_num, 2, "CQICH_Num");
438         for (j = 0; j < CQICH_num; j++) {
439             XBIT(data, 3, "Feedback type");
440             XBIT(data, 6, "Allocation index");
441         }
442     }
443
444     /* Closed MIMO Control Info */
445     if (cmi == 1) {
446         if (mci == 1) {
447             mimo_mode = matrix;
448         } else {
449             mimo_mode = STC_Zone_Matrix;
450         }
451         if (mimo_mode == 0 || mimo_mode == 1) {
452             XBIT(data, 3, "Antenna Grouping Index");
453         } else if (mimo_mode == 2) {
454             XBIT(data, 2, "Num_stream");
455             XBIT(data, 3, "Antenna Selection Index");
456         } else if (mimo_mode == 3) {
457             XBIT(data, 2, "Num_stream");
458             XBIT(data, 6, "Codebook Precoding Index");
459         }
460     }
461
462     /* padding to nibble */
463     pad = BIT_PADDING(bit,4);
464     if(pad){
465         proto_tree_add_text(tree, tvb, BITHI(bit,pad), "Padding: %d bits", pad);
466         bit += pad;
467     }
468
469     return (bit - offset);
470 }
471
472 gint DL_HARQ_Chase_sub_burst_IE(proto_tree *diuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
473 {
474     /* 8.4.5.3.21 DL_HARQ_Chase_sub_burst_IE */
475     /* offset of IE in nibbles, length is variable */
476     gint bit;
477     gint data;
478     proto_item *ti = NULL;
479     proto_tree *tree = NULL;
480     gint nsub, ddci, dur, sbi, res, diuc, rci, ind, per, ofs;
481     gint j;
482
483     bit = NIB_TO_BIT(offset);
484
485     /* 8.4.5.3.21 table 286m */
486     ti = proto_tree_add_text(diuc_tree, tvb, BITHI(bit, length), "DL_HARQ_Chase_sub_burst_IE");
487     tree = proto_item_add_subtree(ti, ett_286m);
488
489     XBIT(nsub, 4, "N sub burst[ISI]");
490     XBIT(data, 4, "N ACK channel");
491
492     nsub += 1;
493     for (j = 0; j < nsub; j++) {
494         bit += RCID_IE(tree, bufptr, bit, length, tvb, RCID_Type);
495         XBIT(dur, 10, "Duration");
496         XBIT(sbi,  1, "Sub-Burst DIUC Indicator");
497         XBIT(res,  1, "Reserved");
498
499         if (sbi == 1) {
500             XBIT(diuc, 4, "DIUC");
501             XBIT(rci, 2, "Repetition Coding Indication");
502             XBIT(res, 2, "Reserved");
503         }
504
505         XBIT(data, 4, "ACID");
506         XBIT(data, 1, "AI_SN");
507         XBIT(data, 1, "ACK disable");
508         XBIT(ddci, 2, "Dedicated DL Control Indicator");
509
510         if ((ddci & 1) == 1) {
511             XBIT(dur, 4, "Duration (d)");
512             if (dur != 0) {
513                 XBIT(ind, 6, "Allocation Index");
514                 XBIT(per, 3, "Period (p)");
515                 XBIT(ofs, 3, "Frame offset");
516             }
517         }
518
519         if ((ddci & 2) == 2) {
520             bit += Dedicated_DL_Control_IE(tree, bufptr, BIT_TO_NIB(bit), length, tvb) * 4;
521         }
522     }
523
524     /* proto_tree_add_text(tree, tvb, BITHI(bit,4), "(DL HARQ Chase sub-burst IE)"); */
525     return (BIT_TO_NIB(bit) - offset);
526 }
527
528 gint DL_HARQ_IR_CTC_sub_burst_IE(proto_tree *diuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
529 {
530     /* offset of IE in nibbles, length is variable */
531     gint bit;
532     guint data;
533     proto_item *ti = NULL;
534     proto_tree *tree = NULL;
535     proto_item *generic_item = NULL;
536     gint nsub, ddci, dur, ind, per, ofs;
537     gint j;
538     guint32        calculated_crc;
539
540     bit = NIB_TO_BIT(offset);
541
542     /* 8.4.5.3.21 table 286n */
543     ti = proto_tree_add_text(diuc_tree, tvb, BITHI(bit, 4), "DL HARQ IR CTC sub-burst IE");
544     tree = proto_item_add_subtree(ti, ett_286n);
545
546     XBIT(nsub, 4, "N sub burst[ISI]");
547     XBIT(data, 4, "N ACK channel");
548
549     nsub += 1;
550     for (j = 0; j < nsub; j++) {
551         bit += RCID_IE(tree, bufptr, bit, length, tvb, RCID_Type);
552
553         XBIT(data, 4, "N(EP)");
554         XBIT(data, 4, "N(SCH)");
555         XBIT(data, 2, "SPID");
556         XBIT(data, 4, "ACID");
557         XBIT(data, 1, "AI_SN");
558         XBIT(data, 1, "ACK disable");
559         XBIT(data, 2, "Reserved");
560         XBIT(ddci, 2, "Dedicated DL Control Indicator");
561
562         if ((ddci & 1) == 1) {
563             XBIT(dur, 4, "Duration (d)");
564
565             if (dur != 0) {
566                 XBIT(ind, 6, "Allocation Index");
567                 XBIT(per, 3, "Period (p)");
568                 XBIT(ofs, 3, "Frame offset");
569             }
570         }
571         if ((ddci & 2) == 2) {
572             bit += Dedicated_DL_Control_IE(tree, bufptr, BIT_TO_NIB(bit), length, tvb);
573         }
574     }
575
576     if (include_cor2_changes)
577     {
578         /* CRC-16 is always appended */
579         data = BIT_BITS(bit, bufptr, 16);
580         generic_item = proto_tree_add_text(tree, tvb, BITHI(bit,16), "CRC-16: 0x%04x",data);
581         /* calculate the CRC */
582         calculated_crc = wimax_mac_calc_crc16(tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
583         if (data != calculated_crc)
584         {
585             proto_item_append_text(generic_item, " - incorrect! (should be: 0x%x)", calculated_crc);
586         }
587         bit += 16;
588     }
589
590     return (BIT_TO_NIB(bit) - offset);
591 }
592
593 gint DL_HARQ_IR_CC_sub_burst_IE(proto_tree *diuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
594 {
595     /* offset of IE in nibbles, length is variable */
596     gint bit;
597     gint data;
598     proto_item *ti = NULL;
599     proto_tree *tree = NULL;
600     proto_item *generic_item = NULL;
601     gint nsub, sbdi, ddci, dur, ind, per, ofs;
602     gint j;
603     guint16 calculated_crc;
604
605     bit = NIB_TO_BIT(offset);
606
607     /* 8.4.5.3.21 table 286o */
608     ti = proto_tree_add_text(diuc_tree, tvb, BITHI(bit, 4), "DL HARQ IR CC sub-burst IE");
609     tree = proto_item_add_subtree(ti, ett_286o);
610
611     XBIT(nsub, 4, "N sub burst[ISI]");
612     XBIT(data, 4, "N ACK channel");
613
614     nsub += 1;
615     for (j = 0; j < nsub; j++) {
616         bit += RCID_IE(tree, bufptr, bit, length, tvb, RCID_Type) / 4;
617
618         XBIT(data, 10, "Duration");
619         XBIT(sbdi,  1, "Sub-Burst DIUC Indicator");
620         XBIT(data,  1, "Reserved");
621
622         if (sbdi) {
623             XBIT(data, 4, "DIUC");
624             XBIT(data, 2, "Repetition Coding Indication");
625             XBIT(data, 2, "Reserved");
626         }
627
628         XBIT(data, 4, "ACID");
629         XBIT(data, 1, "AI_SN");
630         XBIT(data, 2, "SPID");
631         XBIT(data, 1, "ACK disable");
632         XBIT(ddci, 2, "Dedicated DL Control Indicator");
633         XBIT(data, 2, "Reserved");
634
635         if (ddci & 1) {
636             XBIT(dur, 4, "Duration (d)");
637
638             if (dur != 0) {
639                 XBIT(ind, 6, "Allocation Index");
640                 XBIT(per, 3, "Period (p)");
641                 XBIT(ofs, 3, "Frame offset");
642             }
643         }
644         if ((ddci & 2) == 2) {
645             bit += Dedicated_DL_Control_IE(tree, bufptr, BIT_TO_NIB(bit), length, tvb);
646         }
647     }
648
649     if (include_cor2_changes)
650     {
651         /* CRC-16 is always appended */
652         data = BIT_BITS(bit, bufptr, 16);
653         generic_item = proto_tree_add_text(tree, tvb, BITHI(bit,16), "CRC-16: 0x%04x",data);
654         /* calculate the CRC */
655         calculated_crc = wimax_mac_calc_crc16(tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
656         if (data != calculated_crc)
657         {
658             proto_item_append_text(generic_item, " - incorrect! (should be: 0x%x)", calculated_crc);
659         }
660         bit += 16;
661     }
662
663     return (BIT_TO_NIB(bit) - offset);
664 }
665
666 gint MIMO_DL_Chase_HARQ_sub_burst_IE(proto_tree *diuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
667 {
668     /* offset of IE in nibbles, length is variable */
669     gint bit;
670     gint data;
671     proto_item *ti = NULL;
672     proto_tree *tree = NULL;
673     proto_item *generic_item = NULL;
674     gint nsub, mui, dci, akd;
675     gint i, j;
676     guint16 calculated_crc;
677
678     bit = NIB_TO_BIT(offset);
679
680     /* 8.4.5.3.21 table 286p */
681     ti = proto_tree_add_text(diuc_tree, tvb, BITHI(bit, 1), "MIMO DL Chase HARQ sub-burst IE");
682     tree = proto_item_add_subtree(ti, ett_286p);
683
684     XBIT(nsub, 4, "N sub burst[ISI]");
685     XBIT(data, 6, "N ACK channel");
686
687     nsub += 1;
688     for (j = 0; j < nsub; j++) {
689         XBIT(mui, 1, "MU Indicator");
690         XBIT(dci, 1, "Dedicated MIMO DL Control Indicator");
691         XBIT(akd, 1, "ACK Disable");
692         if (mui == 0) {
693             bit += RCID_IE(tree, bufptr, bit, length, tvb, RCID_Type);
694         }
695         if (dci == 1) {
696             bit += Dedicated_MIMO_DL_Control_IE(tree, bufptr, bit, length, tvb);
697         }
698         XBIT(data, 10, "Duration");
699         for (i = 0; i < N_layer; i++) {
700             if (mui == 1) {
701                 bit += RCID_IE(tree, bufptr, bit, length, tvb, RCID_Type);
702             }
703             XBIT(data, 4, "DIUC");
704             XBIT(data, 2, "Repetition Coding Indication");
705             if (akd == 0) {
706                 XBIT(data, 4, "ACID");
707                 XBIT(data, 1, "AI_SN");
708             }
709         }
710     }
711     /* Padding to nibble */
712     data = BIT_PADDING(bit, 4);
713     if (data) {
714         proto_tree_add_text(tree, tvb, BITHI(bit,data), "Padding: %d bits", data);
715         bit += data;
716     }
717
718     if (include_cor2_changes)
719     {
720         /* CRC-16 is always appended */
721         data = BIT_BITS(bit, bufptr, 16);
722         generic_item = proto_tree_add_text(tree, tvb, BITHI(bit,16), "CRC-16: 0x%04x",data);
723         /* calculate the CRC */
724         calculated_crc = wimax_mac_calc_crc16(tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
725         if (data != calculated_crc)
726         {
727             proto_item_append_text(generic_item, " - incorrect! (should be: 0x%x)", calculated_crc);
728         }
729         bit += 16;
730     }
731
732     return (BIT_TO_NIB(bit) - offset);
733 }
734
735 gint MIMO_DL_IR_HARQ_sub_burst_IE(proto_tree *diuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
736 {
737     /* offset of IE in nibbles, length is variable */
738     gint bit;
739     gint data;
740     proto_item *ti = NULL;
741     proto_tree *tree = NULL;
742     proto_item *generic_item = NULL;
743     gint nsub, mui, dci, akd;
744     gint i, j;
745     guint16 calculated_crc;
746
747     bit = NIB_TO_BIT(offset);
748
749     /* 8.4.5.3.21 table 286q */
750     ti = proto_tree_add_text(diuc_tree, tvb, BITHI(bit, 4), "MIMO DL IR HARQ sub-burst IE");
751     tree = proto_item_add_subtree(ti, ett_286q);
752
753     XBIT(nsub, 4, "N sub burst[ISI]");
754     XBIT(data, 6, "N ACK channel");
755
756     nsub += 1;
757     for (j = 0; j < nsub; j++) {
758         XBIT(mui, 1, "MU Indicator");
759         XBIT(dci, 1, "Dedicated MIMO DL Control Indicator");
760         XBIT(akd, 1, "ACK Disable");
761         if (mui == 0) {
762             bit += RCID_IE(tree, bufptr, bit, length, tvb, RCID_Type);
763         }
764         if (dci == 1) {
765             bit += Dedicated_MIMO_DL_Control_IE(tree, bufptr, bit, length, tvb);
766         }
767         XBIT(data, 4, "N(SCH)");
768         for (i = 0; i < N_layer; i++) {
769             if (mui == 1) {
770                 bit += RCID_IE(tree, bufptr, bit, length, tvb, RCID_Type);
771             }
772             XBIT(data, 4, "N(EP)");
773             if (akd) {
774                 XBIT(data, 2, "SPID");
775                 XBIT(data, 4, "ACID");
776                 XBIT(data, 1, "AI_SN");
777             }
778         }
779     }
780
781     if (include_cor2_changes)
782     {
783         /* CRC-16 is always appended */
784         data = BIT_BITS(bit, bufptr, 16);
785         generic_item = proto_tree_add_text(tree, tvb, BITHI(bit,16), "CRC-16: 0x%04x",data);
786         /* calculate the CRC */
787         calculated_crc = wimax_mac_calc_crc16(tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
788         if (data != calculated_crc)
789         {
790             proto_item_append_text(generic_item, " - incorrect! (should be: 0x%x)", calculated_crc);
791         }
792         bit += 16;
793     }
794
795     return (BIT_TO_NIB(bit) - offset);
796 }
797
798 gint MIMO_DL_IR_HARQ_for_CC_sub_burst_IE(proto_tree *diuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
799 {
800     /* offset of IE in nibbles, length is variable */
801     gint bit;
802     gint data;
803     proto_item *ti = NULL;
804     proto_tree *tree = NULL;
805     proto_item *generic_item = NULL;
806     gint nsub, mui, dci, akd;
807     gint i, j;
808     guint16 calculated_crc;
809
810     bit = NIB_TO_BIT(offset);
811
812     /* 8.4.5.3.21 table 286r */
813     ti = proto_tree_add_text(diuc_tree, tvb, BITHI(bit, 1), "MIMO DL IR HARQ for CC sub-burst IE");
814     tree = proto_item_add_subtree(ti, ett_286r);
815
816     XBIT(nsub, 4, "N sub burst[ISI]");
817     XBIT(data, 6, "N ACK channel");
818
819     nsub += 1;
820     for (j = 0; j < nsub; j++) {
821         XBIT(mui, 1, "MU Indicator");
822         XBIT(dci, 1, "Dedicated MIMO DL Control Indicator");
823         XBIT(akd, 1, "ACK Disable");
824         if (mui == 0) {
825             bit += RCID_IE(tree, bufptr, bit, length, tvb, RCID_Type);
826         }
827         if (dci == 1) {
828             bit += Dedicated_MIMO_DL_Control_IE(tree, bufptr, bit, length, tvb);
829         }
830         XBIT(data, 10, "Duration");
831         for (i = 0; i < N_layer; i++) {
832             if (mui == 1) {
833                 bit += RCID_IE(tree, bufptr, bit, length, tvb, RCID_Type);
834             }
835             XBIT(data, 4, "DIUC");
836             XBIT(data, 2, "Repetition Coding Indication");
837             if (akd == 0) {
838                 XBIT(data, 4, "ACID");
839                 XBIT(data, 1, "AI_SN");
840                 XBIT(data, 2, "SPID");
841             }
842         }
843     }
844
845     if (include_cor2_changes)
846     {
847         /* CRC-16 is always appended */
848         data = BIT_BITS(bit, bufptr, 16);
849         generic_item = proto_tree_add_text(tree, tvb, BITHI(bit,16), "CRC-16: 0x%04x",data);
850         /* calculate the CRC */
851         calculated_crc = wimax_mac_calc_crc16(tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
852         if (data != calculated_crc)
853         {
854             proto_item_append_text(generic_item, " - incorrect! (should be: 0x%x)", calculated_crc);
855         }
856         bit += 16;
857     }
858
859     return (BIT_TO_NIB(bit) - offset);
860 }
861
862 gint MIMO_DL_STC_HARQ_sub_burst_IE(proto_tree *diuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
863 {
864     /* offset of IE in nibbles, length is variable */
865     gint bit;
866     gint data;
867     proto_item *ti = NULL;
868     proto_tree *tree = NULL;
869     proto_item *generic_item = NULL;
870     gint nsub, sbi, txc, akd, dmci;
871     gint j;
872     guint16 calculated_crc;
873
874     bit = NIB_TO_BIT(offset);
875
876     /* 8.4.5.3.21 table 286s */
877     ti = proto_tree_add_text(diuc_tree, tvb, BITHI(bit, 1), "MIMO DL STC HARQ sub-burst IE");
878     tree = proto_item_add_subtree(ti, ett_286s);
879
880     XBIT(nsub, 4, "N sub burst[ISI]");
881     XBIT(data, 6, "N ACK channel");
882
883     nsub += 1;
884     for (j = 0; j < nsub; j++) {
885         XBIT(txc, 2, "TX Count");
886         XBIT(data, 10, "Duration");
887         XBIT(sbi, 1, "Sub-burst offset indication");
888         XBIT(data, 3, "Reserved");
889         if (sbi == 1) {
890             XBIT(data, 8, "Sub-burst offset");
891         }
892         bit += RCID_IE(tree, bufptr, bit, length, tvb, RCID_Type);
893         XBIT(akd, 1, "ACK Disable");
894         if (txc == 0) {
895             XBIT(dmci, 1, "Dedicated MIMO DL Control Indicator");
896             if (dmci == 1) {
897                 bit += Dedicated_MIMO_DL_Control_IE(tree, bufptr, bit, length, tvb);
898             }
899             XBIT(data, 4, "DIUC");
900             XBIT(data, 2, "Repetition coding Indication");
901         }
902         if (akd == 0) {
903             XBIT(data, 4, "ACID");
904         }
905     }
906
907     if (include_cor2_changes)
908     {
909         /* CRC-16 is always appended */
910         data = BIT_BITS(bit, bufptr, 16);
911         generic_item = proto_tree_add_text(tree, tvb, BITHI(bit,16), "CRC-16: 0x%04x",data);
912         /* calculate the CRC */
913         calculated_crc = wimax_mac_calc_crc16(tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
914         if (data != calculated_crc)
915         {
916             proto_item_append_text(generic_item, " - incorrect! (should be: 0x%x)", calculated_crc);
917         }
918         bit += 16;
919     }
920
921     return (BIT_TO_NIB(bit) - offset);
922 }
923
924 /********************************************************************
925  * DL-MAP Extended-2 IEs
926  *******************************************************************/
927
928 gint MBS_MAP_IE(proto_tree *diuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
929 {
930     /* DL-MAP Extended-2 IE = 0 */
931     /* 8.4.5.3.12 MBS_MAP_IE */
932     /* offset of TLV in nibbles, length of TLV in nibbles */
933     gint bit;
934     gint data;
935     proto_item *ti = NULL;
936     proto_tree *tree = NULL;
937     gint mde, dci, s3i;
938
939     bit = NIB_TO_BIT(offset);
940
941     ti = proto_tree_add_text(diuc_tree, tvb, NIBHI(offset, length), "MBS_MAP_IE");
942     tree = proto_item_add_subtree(ti, ett_286a);
943
944     XBIT(data,  4, "Extended-2 DIUC");
945     XBIT(data,  8, "Length");
946
947     XBIT(data, 7, "MBS Zone identifier");
948     XBIT(mde, 1, "Macro diversity enhanced");
949     if (mde == 1)
950     {
951         XBIT(data, 2, "Permutation");
952         XBIT(data, 5, "DL_PermBase");
953         XBIT(data, 2, "PRBS_ID");
954         XBIT(data, 7, "OFDMA_Symbol_Offset");
955         XBIT(dci, 1, "DIUC_change_indication");
956         XBIT(data, 3, "Reserved");
957         if (dci == 1) {
958             XBIT(data, 3, "Reserved");
959             XBIT(data, 3, "Boosting");
960             XBIT(data, 4, "DIUC");
961             XBIT(data, 6, "No. Subchannels");
962             XBIT(data, 6, "No. OFDMA Symbols");
963             XBIT(data, 2, "Repetition Coding Indication");
964         }
965     } else {
966         XBIT(data, 4, "DIUC");
967         XBIT(data, 16, "CID");
968         XBIT(data, 8, "OFDMA Symbols Offset");
969         XBIT(data, 6, "Subchannel offset");
970         XBIT(data, 3, "Boosting");
971         XBIT(s3i, 1, "SLC_3_indication");
972         XBIT(data, 6, "No. OFDMA Symbols");
973         XBIT(data, 6, "No. Subchannels");
974         XBIT(data, 2, "Repetition Coding Indication");
975         if (s3i == 1) {
976             XBIT(data, 8, "Next MBS_MAP_IE frame offset");
977         }
978     }
979     data = BIT_PADDING(bit, 4);
980     if (data) {
981         proto_tree_add_text(tree, tvb, BITHI(bit,data), "Padding: %d bits", data);
982         bit += data;
983     }
984     return BIT_TO_NIB(bit);
985 }
986
987 gint HO_Anchor_Active_DL_MAP_IE(proto_tree *diuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
988 {
989     /* DL-MAP Extended-2 IE = 1 */
990     /* 8.4.5.3.14 [2] HO_Anchor_Active_DL-MAP_IE TODO 1.1 */
991     /* offset of TLV in nibbles, length of TLV in nibbles */
992     gint nib;
993     gint data;
994     proto_item *ti = NULL;
995     proto_tree *tree = NULL;
996
997     nib = offset;
998
999     ti = proto_tree_add_text(diuc_tree, tvb, NIBHI(offset, length), "HO_Anchor_Active_DL_MAP_IE");
1000     tree = proto_item_add_subtree(ti, ett_286c);
1001
1002     XNIB(data,  1, "Extended-2 DIUC");
1003     XNIB(data,  2, "Length");
1004     proto_tree_add_text(diuc_tree, tvb, NIBHI(nib, length-3), "(not implemented)");
1005     return nib;
1006 }
1007
1008 gint HO_Active_Anchor_DL_MAP_IE(proto_tree *diuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
1009 {
1010     /* DL-MAP Extended-2 IE = 2 */
1011     /* 8.4.5.3.15 HO_Active_Anchor_DL_MAP_IE TODO 1.1 */
1012     /* offset of TLV in nibbles, length of TLV in nibbles */
1013     gint nib;
1014     gint data;
1015     proto_item *ti = NULL;
1016     proto_tree *tree = NULL;
1017
1018     nib = offset;
1019
1020     ti = proto_tree_add_text(diuc_tree, tvb, NIBHI(offset, length), "HO_Active_Anchor_DL_MAP_IE");
1021     tree = proto_item_add_subtree(ti, ett_286d);
1022
1023     XNIB(data,  1, "Extended-2 DIUC");
1024     XNIB(data,  2, "Length");
1025     proto_tree_add_text(diuc_tree, tvb, NIBHI(nib, length-3), "(not implemented)");
1026     return nib;
1027 }
1028
1029 gint HO_CID_Translation_MAP_IE(proto_tree *diuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
1030 {
1031     /* DL-MAP Extended-2 IE = 3 */
1032     /* 8.4.5.3.16 HO_CID_Translation_MAP_IE TODO 1.1 */
1033     /* offset of TLV in nibbles, length of TLV in nibbles */
1034     gint nib;
1035     gint data;
1036     proto_item *ti = NULL;
1037     proto_tree *tree = NULL;
1038
1039     nib = offset;
1040
1041     ti = proto_tree_add_text(diuc_tree, tvb, NIBHI(offset, length), "CID_Translation_MAP_IE");
1042     tree = proto_item_add_subtree(ti, ett_286e);
1043
1044     XNIB(data,  1, "Extended-2 DIUC");
1045     XNIB(data,  2, "Length");
1046     proto_tree_add_text(diuc_tree, tvb, NIBHI(nib, length-3), "(not implemented)");
1047     return nib;
1048 }
1049
1050 gint MIMO_in_another_BS_IE(proto_tree *diuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
1051 {
1052     /* DL-MAP Extended-2 IE = 4 */
1053     /* 8.4.5.3.17 [2] MIMO_in_another_BS_IE (not implemented)*/
1054     /* offset of TLV in nibbles, length of TLV in nibbles */
1055     gint nib;
1056     gint data;
1057     proto_item *ti = NULL;
1058     proto_tree *tree = NULL;
1059
1060     nib = offset;
1061
1062     ti = proto_tree_add_text(diuc_tree, tvb, NIBHI(offset, length), "MIMO_in_another_BS_IE");
1063     tree = proto_item_add_subtree(ti, ett_286f);
1064
1065     XNIB(data,  1, "Extended-2 DIUC");
1066     XNIB(data,  2, "Length");
1067     proto_tree_add_text(diuc_tree, tvb, NIBHI(nib, length-3), "(not implemented)");
1068     return nib;
1069 }
1070
1071 gint Macro_MIMO_DL_Basic_IE(proto_tree *diuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
1072 {
1073     /* dl-map extended-2 ie = 5 */
1074     /* 8.4.5.3.18 [2] Macro-MIMO_DL_Basic_IE (not implemented) */
1075     /* offset of tlv in nibbles, length of tlv in nibbles */
1076     gint nib;
1077     gint data;
1078     proto_item *ti = NULL;
1079     proto_tree *tree = NULL;
1080
1081     nib = offset;
1082
1083     ti = proto_tree_add_text(diuc_tree, tvb, NIBHI(offset, length), "Macro_MIMO_DL_Basic_IE");
1084     tree = proto_item_add_subtree(ti, ett_286g);
1085
1086     XNIB(data,  1, "Extended-2 DIUC");
1087     XNIB(data,  2, "Length");
1088     proto_tree_add_text(diuc_tree, tvb, NIBHI(nib, length-3), "(not implemented)");
1089     return nib;
1090 }
1091
1092 gint Skip_IE(proto_tree *diuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
1093 {
1094     /* DL-MAP Extended-2 IE = 6 */
1095     /* 8.4.5.3.20.2 Skip_IE */
1096     /* offset of TLV in nibbles, length of TLV in nibbles */
1097     gint bit;
1098     gint data;
1099     proto_item *ti = NULL;
1100     proto_tree *tree = NULL;
1101
1102     bit = NIB_TO_BIT(offset);
1103
1104     ti = proto_tree_add_text(diuc_tree, tvb, NIBHI(offset, length), "Skip_IE");
1105     tree = proto_item_add_subtree(ti, ett_286k);
1106
1107     XBIT(data,  4, "Extended-2 DIUC");
1108     XBIT(data,  8, "Length");
1109
1110     XBIT(data,  1, "Mode");
1111     XBIT(data,  7, "Reserved");
1112
1113     return BIT_TO_NIB(bit);
1114 }
1115
1116 gint HARQ_DL_MAP_IE(proto_tree *diuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
1117 {
1118     /* DL-MAP Extended-2 IE = 7 */
1119     /* 8.4.5.3.21 [2] HARQ_DL_MAP_IE */
1120     /* offset of TLV in nibbles, length of TLV in nibbles */
1121     gint bit;
1122     gint data;
1123     proto_item *ti = NULL;
1124     proto_tree *tree = NULL;
1125     gint len, lastbit, rui, mode, sub_len, pad;
1126
1127     bit = NIB_TO_BIT(offset);
1128
1129     ti = proto_tree_add_text(diuc_tree, tvb, NIBHI(offset, length), "HARQ_DL_MAP_IE");
1130     tree = proto_item_add_subtree(ti, ett_286l);
1131
1132     XBIT(data,  4, "Extended-2 DIUC");
1133     XBIT(len,  8, "Length");
1134
1135     XBIT(RCID_Type,  2, "RCID_Type");
1136     XBIT(data,  2, "Reserved");
1137
1138     /* while data remains */
1139     length = NIB_TO_BIT(length);
1140     /* Subtract extra nibble to be sure to stop in time. */
1141     lastbit = bit + BYTE_TO_BIT(len) - 14 - 4;
1142     while (bit < lastbit) {
1143         XBIT(data,  3, "Boosting");
1144         XBIT(rui,  1, "Region_ID use indicator");
1145
1146         if (rui == 0) {
1147             XBIT(data,  8, "OFDMA symbol offset");
1148             XBIT(data,  7, "Subchannel offset");
1149             XBIT(data,  7, "Number of OFDMA symbols");
1150             XBIT(data,  7, "Number of subchannels");
1151             if (include_cor2_changes)
1152             {
1153                 XBIT(data,  1, "Rectangular Sub-Burst Indicator"); /* Implemented: "Rectangular Sub-Burst Indicator" field added */
1154                 XBIT(data,  2, "Reserved");   /* and "Reserved" field resized from 3 bits to 2 bits         */
1155             }
1156             else
1157             {
1158                 XBIT(data,  3, "Reserved");
1159             }
1160         } else {
1161             XBIT(data,  8, "Region_ID");
1162         }
1163         XBIT(mode,  4, "Mode");
1164         XBIT(sub_len,  8, "Sub-burst IE Length");
1165
1166         /* 8.4.5.3.21 */
1167         /* length of these are variable, each returns length in nibbles */
1168         if (mode == 0) {
1169             DL_HARQ_Chase_sub_burst_IE(tree, bufptr, BIT_TO_NIB(bit), length, tvb);
1170         } else if (mode == 1) {
1171             DL_HARQ_IR_CTC_sub_burst_IE(tree, bufptr, BIT_TO_NIB(bit), length, tvb);
1172         } else if (mode == 2) {
1173             DL_HARQ_IR_CC_sub_burst_IE(tree, bufptr, BIT_TO_NIB(bit), length, tvb);
1174         } else if (mode == 3) {
1175             MIMO_DL_Chase_HARQ_sub_burst_IE(tree, bufptr, BIT_TO_NIB(bit), length, tvb);
1176         } else if (mode == 4) {
1177             MIMO_DL_IR_HARQ_sub_burst_IE(tree, bufptr, BIT_TO_NIB(bit), length, tvb);
1178         } else if (mode == 5) {
1179             MIMO_DL_IR_HARQ_for_CC_sub_burst_IE(tree, bufptr, BIT_TO_NIB(bit), length, tvb);
1180         } else if (mode == 6) {
1181             MIMO_DL_STC_HARQ_sub_burst_IE(tree, bufptr, BIT_TO_NIB(bit), length, tvb);
1182         } else {
1183             proto_tree_add_text(tree, tvb, BITHI(bit,1), "(reserved Mode)");
1184             break; /* cannot continue */
1185         }
1186         bit += NIB_TO_BIT(sub_len);
1187     }
1188
1189     pad = NIB_TO_BIT(offset) + length - bit;
1190     if (pad) {
1191         proto_tree_add_text(tree, tvb, BITHI(bit,pad), "Padding: %d bits",pad);
1192         bit += pad;
1193     }
1194
1195     return BIT_TO_NIB(bit);
1196 }
1197
1198 gint HARQ_ACK_IE(proto_tree *diuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
1199 {
1200     /* DL-MAP Extended-2 IE = 8 */
1201     /* 8.4.5.3.22 HARQ_ACK IE */
1202     /* offset of TLV in nibbles, length of TLV in nibbles */
1203     gint data;
1204     gint nib;
1205     proto_item *ti = NULL;
1206     proto_tree *tree = NULL;
1207
1208     nib = offset;
1209
1210     ti = proto_tree_add_text(diuc_tree, tvb, NIBHI(offset, length), "HARQ_ACK_IE");
1211     tree = proto_item_add_subtree(ti, ett_286u);
1212
1213     XNIB(data,  1, "Extended-2 DIUC");
1214     XNIB(data,  2, "Length");
1215
1216     proto_tree_add_text(diuc_tree, tvb, NIBHI(nib,length-3), "(bitmap data)");
1217
1218     return nib;
1219 }
1220
1221 gint Enhanced_DL_MAP_IE(proto_tree *diuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
1222 {
1223     /* DL-MAP Extended-2 IE = 9 */
1224     /* 8.4.5.3.23 Enhanced DL MAP IE */
1225     /* offset of TLV in nibbles, length of TLV in nibbles */
1226     gint bit;
1227     gint data;
1228     proto_item *ti = NULL;
1229     proto_tree *tree = NULL;
1230     gint numass, n_cid;
1231     gint i, n;
1232
1233     bit = NIB_TO_BIT(offset);
1234
1235     ti = proto_tree_add_text(diuc_tree, tvb, NIBHI(offset, length), "Enhanced_DL-MAP_IE");
1236     tree = proto_item_add_subtree(ti, ett_286v);
1237
1238     XBIT(data,  4, "Extended-2 DIUC");
1239     XBIT(data,  8, "Length");
1240
1241     XBIT(numass, 4, "Num_Assignment");
1242     for (i = 0; i < numass; i++) {
1243         if (INC_CID == 1) {
1244             XBIT(n_cid, 8, "N_CID");
1245             for (n = 0; n < n_cid; n++) {
1246                 XBIT(data, 16, "CID");
1247             }
1248         }
1249         XBIT(data, 4, "DIUC");
1250         XBIT(data, 3, "Boosting");
1251         XBIT(data, 2, "Repetition Coding Indication");
1252         XBIT(data, 8, "Region_ID");
1253         XBIT(data, 3, "Reserved");
1254     }
1255     return BIT_TO_NIB(bit);
1256 }
1257
1258 gint Closed_loop_MIMO_DL_Enhanced_IE(proto_tree *diuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
1259 {
1260     /* DL-MAP Extended-2 IE = 0xA */
1261     /* 8.4.5.3.24 Closed-loop MIMO DL Enhanced IE (not implemented) */
1262     /* offset of TLV in nibbles, length of TLV in nibbles */
1263     gint nib;
1264     gint data;
1265     proto_item *ti = NULL;
1266     proto_tree *tree = NULL;
1267
1268     nib = offset;
1269
1270     ti = proto_tree_add_text(diuc_tree, tvb, NIBHI(offset, length), "CL_MIMO_DL_Enhanced_IE");
1271     tree = proto_item_add_subtree(ti, ett_286w);
1272
1273     XNIB(data,  1, "Extended-2 DIUC");
1274     XNIB(data,  2, "Length");
1275     proto_tree_add_text(diuc_tree, tvb, NIBHI(nib, length-3), "(not implemented)");
1276     return nib;
1277 }
1278
1279 gint AAS_SDMA_DL_IE(proto_tree *diuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
1280 {
1281     /* DL-MAP Extended-2 IE = 0xE */
1282     /* 8.4.5.3.26 AAS_SDMA_DL_IE */
1283     /* offset of TLV in nibbles, length of TLV in nibbles */
1284     gint bit;
1285     gint data;
1286     proto_item *ti = NULL;
1287     proto_tree *tree = NULL;
1288     gint num_region, num_users, pilot_pattern, encoding_mode, ackch_alloc, cqich_alloc;
1289     gint aas_preamble = 1;
1290     gint zone_permut = 0; /* TODO */
1291     gint i, j;
1292
1293     bit = NIB_TO_BIT(offset);
1294
1295     ti = proto_tree_add_text(diuc_tree, tvb, NIBHI(offset, length), "AAS_SDMA_DL_IE");
1296     tree = proto_item_add_subtree(ti, ett_286y);
1297
1298     XBIT(data,  4, "Extended-2 DIUC");
1299     XBIT(data,  8, "Length");
1300
1301     XBIT(RCID_Type,  2, "RCID_Type");
1302     XBIT(num_region,  4, "Num_Burst_Region");
1303     XBIT(data,  2, "Reserved");
1304     for (i = 0; i < num_region; i++) {
1305         XBIT(data,  8, "OFDMA Symbol Offset");
1306         if (zone_permut == 0) {
1307             XBIT(data,  8, "Subchannel offset");
1308             XBIT(data,  5, "No. OFDMA triple symbols");
1309             XBIT(data,  6, "No. subchannels");
1310         } else {
1311             XBIT(data,  6, "Subchannel offset");
1312             XBIT(data,  7, "No. OFDMA triple symbols");
1313             XBIT(data,  6, "No. subchannels");
1314         }
1315         XBIT(num_users,  3, "Number of Users");
1316         XBIT(data,  2, "Reserved");
1317         for (j = 0; j < num_users; j++) {
1318             bit += RCID_IE(tree, bufptr, bit, length, tvb, RCID_Type);
1319             XBIT(encoding_mode,  2, "Encoding Mode");
1320             XBIT(cqich_alloc,  1, "CQICH Allocation");
1321             XBIT(ackch_alloc,  1, "ACKCH Allocation");
1322             XBIT(pilot_pattern,  1, "Pilot Pattern Modifier");
1323             if (aas_preamble) {
1324                 XBIT(data,  4, "Preamble Modifier Index");
1325             }
1326             if (pilot_pattern) {
1327                 XBIT(data,  2, "Pilot Pattern");
1328                 XBIT(data,  1, "Reserved");
1329             } else {
1330                 XBIT(data,  3, "Reserved");
1331             }
1332             if (encoding_mode == 0x0) {
1333                 XBIT(data,  4, "DIUC");
1334                 XBIT(data,  2, "Repetition Coding Indication");
1335                 XBIT(data,  2, "Reserved");
1336             }
1337             if (encoding_mode == 0x1) {
1338                 if (ackch_alloc) {
1339                     XBIT(data,  5, "ACK CH Index");
1340                 } else {
1341                     XBIT(data,  1, "Reserved");
1342                 }
1343                 XBIT(data,  4, "DIUC");
1344                 XBIT(data,  2, "Repetition Coding Indication");
1345                 XBIT(data,  4, "ACID");
1346                 XBIT(data,  1, "AI_SN");
1347             }
1348             if (encoding_mode == 0x2) {
1349                 if (ackch_alloc) {
1350                     XBIT(data,  5, "ACK CH Index");
1351                 } else {
1352                     XBIT(data,  1, "Reserved");
1353                 }
1354                 XBIT(data,  4, "N(EP)");
1355                 XBIT(data,  4, "N(SCH)");
1356                 XBIT(data,  2, "SPID");
1357                 XBIT(data,  4, "ACID");
1358                 XBIT(data,  1, "AI_SN");
1359             }
1360             if (encoding_mode == 0x3) {
1361                 if (ackch_alloc) {
1362                     XBIT(data,  5, "ACK CH Index");
1363                     XBIT(data,  2, "Reserved");
1364                 } else {
1365                     XBIT(data,  3, "Reserved");
1366                 }
1367                 XBIT(data,  4, "DIUC");
1368                 XBIT(data,  2, "Repetition Coding Indication");
1369                 XBIT(data,  2, "SPID");
1370                 XBIT(data,  4, "ACID");
1371                 XBIT(data,  1, "AI_SN");
1372             }
1373             if (cqich_alloc) {
1374                 XBIT(data,  6, "Allocation Index");
1375                 XBIT(data,  3, "Period (p)");
1376                 XBIT(data,  3, "Frame offset");
1377                 XBIT(data,  4, "Duration (d)");
1378             }
1379         }
1380     }
1381     data = BIT_PADDING(bit,4);
1382     /* Should this be an optional field? Or do we want it, even if it has a length of zero? */
1383     proto_tree_add_text(tree, tvb, BITHI(bit,data), "Padding: %d bits", data);
1384     bit += data;
1385
1386     return BIT_TO_NIB(bit);
1387 }
1388
1389
1390
1391 /********************************************************************
1392  * DL-MAP Extended IEs
1393  *******************************************************************/
1394
1395 gint Channel_Measurement_IE(proto_tree *diuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
1396 {
1397     /* DL-MAP Extended IE = 0 */
1398     /* 8.4.5.3.5 [1] Channel_Measurement_IE */
1399     /* offset of TLV in nibbles, length of TLV in nibbles */
1400     gint nib;
1401     gint data;
1402     proto_item *ti = NULL;
1403     proto_tree *tree = NULL;
1404
1405     nib = offset;
1406
1407     ti = proto_tree_add_text(diuc_tree, tvb, NIBHI(offset, length), "Channel_Measurement_IE");
1408     tree = proto_item_add_subtree(ti, ett_280);
1409
1410     XNIB(data,  1, "Extended DIUC");
1411     XNIB(data,  1, "Length");
1412
1413     XNIB(data, 2, "Channel Nr");
1414     XNIB(data, 2, "OFDMA Symbol Offset");
1415     data = NIB_WORD(nib, bufptr);
1416     proto_tree_add_text(tree, tvb, NIBHI(nib,4), "CID: %d", data);
1417     nib += 4;
1418     return nib;
1419 }
1420
1421 gint STC_Zone_IE(proto_tree *diuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
1422 {
1423     /* DL-MAP Extended IE = 1 */
1424     /* 8.4.5.3.4 STC_Zone_IE */
1425     /* offset of TLV in nibbles, length of TLV in nibbles */
1426     /* set globals: STC_Zone_Dedicated_Pilots, STC_Zone_Matrix
1427      * used in 8.4.5.3.21.1 Dedicated MIMO Control IE 286t */
1428     gint bit;
1429     gint data;
1430     proto_item *ti = NULL;
1431     proto_tree *tree = NULL;
1432
1433     bit = NIB_TO_BIT(offset);
1434
1435     ti = proto_tree_add_text(diuc_tree, tvb, NIBHI(offset, length), "STC_Zone_IE");
1436     tree = proto_item_add_subtree(ti, ett_279);
1437
1438     XBIT(data,  4, "Extended DIUC");
1439     XBIT(data,  4, "Length");
1440
1441     XBIT(data, 8, "OFDMA Symbol Offset");
1442     XBIT(data, 2, "Permutations");
1443     XBIT(data, 1, "Use All SC indicator");
1444     XBIT(data, 2, "STC");
1445     XBIT(STC_Zone_Matrix, 2, "Matrix indicator");
1446     XBIT(data, 5, "DL_PermBase");
1447     XBIT(data, 2, "PRBS_ID");
1448     XBIT(data, 2, "AMC type");
1449     XBIT(data, 1, "Midamble Presence");
1450     XBIT(data, 1, "Midamble Boosting");
1451     XBIT(data, 1, "2/3 antenna select");
1452     XBIT(STC_Zone_Dedicated_Pilots, 1, "Dedicated Pilots");
1453     XBIT(data, 4, "Reserved");
1454
1455     return BIT_TO_NIB(bit);
1456 }
1457
1458 gint AAS_DL_IE(proto_tree *diuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
1459 {
1460     /* DL-MAP Extended IE = 2 */
1461     /* 8.4.5.3.3 AAS_DL_IE */
1462     /* offset of TLV in nibbles, length of TLV in nibbles */
1463     gint bit;
1464     gint data;
1465     proto_item *ti = NULL;
1466     proto_tree *tree = NULL;
1467
1468     bit = NIB_TO_BIT(offset);
1469
1470     ti = proto_tree_add_text(diuc_tree, tvb, NIBHI(offset, length), "AAS_DL_IE");
1471     tree = proto_item_add_subtree(ti, ett_278);
1472
1473     XBIT(data,  4, "Extended DIUC");
1474     XBIT(data,  4, "Length");
1475
1476     XBIT(data, 8, "OFDMA Symbol Offset");
1477     XBIT(data, 3, "Permutation");
1478     XBIT(data, 6, "DL_PermBase");
1479     XBIT(data, 2, "Downlink_preamble_config");
1480     XBIT(data, 1, "Preamble type");
1481     XBIT(data, 2, "PRBS_ID");
1482     XBIT(data, 1, "Diversity Map");
1483     XBIT(data, 1, "Reserved");
1484
1485     return BIT_TO_NIB(bit);
1486 }
1487
1488 gint Data_location_in_another_BS_IE(proto_tree *diuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
1489 {
1490     /* DL-MAP Extended IE = 3 */
1491     /* 8.4.5.3.6 Data_location_in_another_BS_IE */
1492     /* offset of TLV in nibbles, length of TLV in nibbles */
1493     gint bit;
1494     gint data;
1495     proto_item *ti = NULL;
1496     proto_tree *tree = NULL;
1497
1498     bit = NIB_TO_BIT(offset);
1499
1500     ti = proto_tree_add_text(diuc_tree, tvb, NIBHI(offset, length), "Data location in another BS IE");
1501     tree = proto_item_add_subtree(ti, ett_281);
1502
1503     XBIT(data,  4, "Extended DIUC");
1504     XBIT(data,  4, "Length");
1505
1506     XBIT(data, 2, "Segment");
1507     XBIT(data, 6, "Used subchannels");
1508     XBIT(data, 4, "DIUC");
1509     XBIT(data, 3, "Frame Advance");
1510     XBIT(data, 1, "Reserved");
1511     XBIT(data, 8, "OFDMA Symbol Offset");
1512     XBIT(data, 6, "Subchannel Offset");
1513     XBIT(data, 3, "Boosting");
1514     XBIT(data, 7, "Preamble Index");
1515     XBIT(data, 8, "No. OFDMA Symbols");
1516     XBIT(data, 6, "No. Subchannels");
1517     XBIT(data, 2, "Repetition Coding Indication");
1518     XBIT(data, 16, "CID");
1519
1520     return BIT_TO_NIB(bit);
1521 }
1522
1523 gint CID_Switch_IE(proto_tree *diuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
1524 {
1525     /* DL-MAP Extended IE = 4 */
1526     /* 8.4.5.3.7 [1] CID_Switch_IE */
1527     /* offset of TLV in nibbles, length of TLV in nibbles */
1528     gint nib;
1529     gint data;
1530     proto_item *ti = NULL;
1531     proto_tree *tree = NULL;
1532
1533     nib = offset;
1534
1535     INC_CID = INC_CID ? 0 : 1;
1536
1537     ti = proto_tree_add_text(diuc_tree, tvb, NIBHI(offset, length), "CID_Switch_IE");
1538     proto_item_append_text(ti, " (INC_CID = %d)",INC_CID);
1539     tree = proto_item_add_subtree(ti, ett_282);
1540
1541     XNIB(data,  1, "Extended DIUC");
1542     XNIB(data,  1, "Length");
1543
1544     return nib;
1545 }
1546
1547 gint MIMO_DL_Basic_IE(proto_tree *diuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
1548 {
1549     /* DL-MAP Extended IE = 5 */
1550     /* 8.4.5.3.8 MIMO_DL_Basic_IE (not implemented) */
1551     /* offset of TLV in nibbles, length of TLV in nibbles */
1552     gint nib;
1553     gint data;
1554     proto_item *ti = NULL;
1555     proto_tree *tree = NULL;
1556
1557     nib = offset;
1558
1559     ti = proto_tree_add_text(diuc_tree, tvb, NIBHI(offset, length), "MIMO_DL_Basic_IE");
1560     tree = proto_item_add_subtree(ti, ett_283);
1561
1562     XNIB(data,  1, "Extended-2 DIUC");
1563     XNIB(data,  2, "Length");
1564     proto_tree_add_text(diuc_tree, tvb, NIBHI(nib, length-2), "(not implemented)");
1565     return nib;
1566 }
1567
1568 gint MIMO_DL_Enhanced_IE(proto_tree *diuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
1569 {
1570     /* DL-MAP Extended IE = 6 */
1571     /* 8.4.5.3.9 MIMO_DL_Enhanced_IE (not implemented) */
1572     /* offset of TLV in nibbles, length of TLV in nibbles */
1573     gint nib;
1574     gint data;
1575     proto_item *ti = NULL;
1576     proto_tree *tree = NULL;
1577
1578     nib = offset;
1579
1580     ti = proto_tree_add_text(diuc_tree, tvb, NIBHI(offset, length), "MIMO_DL_Enhanced_IE");
1581     tree = proto_item_add_subtree(ti, ett_284);
1582
1583     XNIB(data,  1, "Extended-2 DIUC");
1584     XNIB(data,  2, "Length");
1585     proto_tree_add_text(diuc_tree, tvb, NIBHI(nib, length-2), "(not implemented)");
1586     return nib;
1587 }
1588
1589 gint HARQ_Map_Pointer_IE(proto_tree *diuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
1590 {
1591     /* DL-MAP Extended IE = 7 */
1592     /* 8.4.5.3.10 [2] HARQ_Map_Pointer_IE */
1593     /* offset of TLV in nibbles, length of TLV in nibbles */
1594     gint bit;
1595     gint data;
1596     proto_item *ti = NULL;
1597     proto_tree *tree = NULL;
1598     gint length_in_bits, rep, map, diuc, slots, idle, sleep, mask_len;
1599
1600     bit = NIB_TO_BIT(offset);
1601
1602     ti = proto_tree_add_text(diuc_tree, tvb, NIBHI(offset, length), "HARQ_Map_Pointer_IE");
1603     tree = proto_item_add_subtree(ti, ett_285);
1604
1605     XBIT(data,  4, "Extended DIUC");
1606     XBIT(data,  4, "Length");
1607
1608     length_in_bits = NIB_TO_BIT(length-1);
1609     while (bit < length_in_bits) {
1610         XBIT(diuc, 4, "DIUC");
1611         XBIT(slots, 8, "No. Slots");
1612         XBIT(rep, 2, "Repetition Coding Indication");
1613         XBIT(map, 2, "Map Version");
1614         if (map == 2) {
1615             XBIT(idle, 1, "Idle users");
1616             XBIT(sleep, 1, "Sleep users");
1617             XBIT(mask_len, 2, "CID Mask Length");
1618             if (mask_len == 0) {
1619                 /* 12 bits */
1620                 proto_tree_add_text(diuc_tree, tvb, BITHI(bit,12), "CID Mask: 12 bits");
1621                 bit += 12;
1622             } else if (mask_len == 1) {
1623                 /* 20 bits */
1624                 proto_tree_add_text(diuc_tree, tvb, BITHI(bit,20), "CID Mask: 20 bits");
1625                 bit += 20;
1626             } else if (mask_len == 2) {
1627                 /* 36 bits */
1628                 proto_tree_add_text(diuc_tree, tvb, BITHI(bit,36), "CID Mask: 36 bits");
1629                 bit += 36;
1630             } else if (mask_len == 3) {
1631                 /* 52 bits */
1632                 proto_tree_add_text(diuc_tree, tvb, BITHI(bit,52), "CID Mask: 52 bits");
1633                 bit += 52;
1634             }
1635         }
1636     }
1637     return BIT_TO_NIB(bit);
1638 }
1639
1640 gint PHYMOD_DL_IE(proto_tree *diuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
1641 {
1642     /* DL-MAP Extended IE = 8 */
1643     /* 8.4.5.3.11 PHYMOD_DL_IE */
1644     /* offset of TLV in nibbles, length of TLV in nibbles */
1645     gint bit;
1646     gint data;
1647     proto_item *ti = NULL;
1648     proto_tree *tree = NULL;
1649     gint pmt;
1650
1651     bit = NIB_TO_BIT(offset);
1652
1653     ti = proto_tree_add_text(diuc_tree, tvb, NIBHI(offset, length), "PHYMOD_DL_IE");
1654     tree = proto_item_add_subtree(ti, ett_286);
1655
1656     XBIT(data,  4, "Extended DIUC");
1657     XBIT(data,  4, "Length");
1658
1659     XBIT(pmt, 1, "Preamble Modifier Type");
1660     if (pmt == 0) {
1661         XBIT(data, 4, "Preamble frequency shift index");
1662     } else {
1663         XBIT(data, 4, "Preamble Time Shift Index");
1664     }
1665     XBIT(data, 1, "Pilot Pattern Modifier");
1666     XBIT(data, 2, "Pilot Pattern Index");
1667
1668     return BIT_TO_NIB(bit);
1669 }
1670
1671 gint Broadcast_Control_Pointer_IE(proto_tree *diuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
1672 {
1673     /* DL-MAP Extended IE = 0xA */
1674     /* 8.4.5.3.25 Broadcast Control Pointer IE */
1675     /* offset of TLV in nibbles, length of TLV in nibbles */
1676     gint bit;
1677     gint data;
1678     proto_item *ti = NULL;
1679     proto_tree *tree = NULL;
1680     gint skip;
1681
1682     bit = NIB_TO_BIT(offset);
1683
1684     ti = proto_tree_add_text(diuc_tree, tvb, NIBHI(offset, length), "Broadcast Control Pointer IE");
1685     tree = proto_item_add_subtree(ti, ett_286x);
1686
1687     XBIT(data,  4, "Extended DIUC");
1688     XBIT(data,  4, "Length");
1689
1690     XBIT(data,  7, "DCD_UCD Transmission Frame");
1691     XBIT(skip,  1, "Skip Broadcast_System_Update");
1692     if (skip == 0) {
1693         XBIT(data,  1, "Broadcast_System_Update_Type");
1694         XBIT(data,  7, "Broadcast_System_Update_Transmission_Frame");
1695     }
1696     return BIT_TO_NIB(bit);
1697 }
1698
1699 gint DL_PUSC_Burst_Allocation_in_Other_Segment_IE(proto_tree *diuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
1700 {
1701     /* DL-MAP Extended IE = 0xB */
1702     /* 8.4.5.3.13 DL PUSC Burst Allocation in Other Segment IE */
1703     /* offset of TLV in nibbles, length of TLV in nibbles */
1704     gint bit;
1705     gint data;
1706     proto_item *ti = NULL;
1707     proto_tree *tree = NULL;
1708
1709     bit = NIB_TO_BIT(offset);
1710
1711     ti = proto_tree_add_text(diuc_tree, tvb, NIBHI(offset, length), "DL_PUSC_Burst_Allocation_in_Other_Segment_IE");
1712     tree = proto_item_add_subtree(ti, ett_286b);
1713
1714     XBIT(data,  4, "Extended DIUC");
1715     XBIT(data,  4, "Length");
1716
1717     XBIT(data, 16, "CID");
1718     XBIT(data,  4, "DIUC");
1719     XBIT(data,  2, "Segment");
1720     XBIT(data,  3, "Boosting");
1721     XBIT(data,  5, "IDcell");
1722     XBIT(data,  5, "DL_PermBase");
1723     XBIT(data,  2, "PRBS_ID");
1724     XBIT(data,  2, "Repetition coding indication");
1725     XBIT(data,  6, "Used Subchannels");
1726     XBIT(data,  8, "OFDMA symbol offset");
1727     XBIT(data,  1, "Reserved");
1728     XBIT(data,  7, "# OFDMA symbols");
1729     XBIT(data,  6, "Subchannel offset");
1730     XBIT(data,  6, "# subchannels");
1731     XBIT(data,  7, "Reserved");
1732     return BIT_TO_NIB(bit);
1733 }
1734
1735 gint PUSC_ASCA_Alloc_IE(proto_tree *diuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
1736 {
1737     /* DL-MAP Extended IE = 0xC */
1738     /* 8.4.5.3.27 PUSC_ASCA_Alloc_IE */
1739     /* offset of TLV in nibbles, length of TLV in nibbles */
1740     gint bit;
1741     gint data;
1742     proto_item *ti = NULL;
1743     proto_tree *tree = NULL;
1744
1745     bit = NIB_TO_BIT(offset);
1746
1747     ti = proto_tree_add_text(diuc_tree, tvb, NIBHI(offset, length), "PUSC_ASCA_Alloc_IE");
1748     tree = proto_item_add_subtree(ti, ett_286z);
1749
1750     XBIT(data,  4, "Extended DIUC");
1751     XBIT(data,  4, "Length");
1752     XBIT(data,  4, "DIUC");
1753     XBIT(data, 12, "Short Basic CID");
1754     XBIT(data,  8, "OFDMA Symbol offset");
1755     XBIT(data,  6, "Subchannel offset");
1756     XBIT(data,  7, "# OFDMA Symbols");
1757     XBIT(data,  6, "# Symbols");
1758     XBIT(data,  2, "Repetition Coding Information");
1759     XBIT(data,  4, "Permutation ID");
1760     XBIT(data,  7, "Reserved");
1761
1762     return BIT_TO_NIB(bit);
1763 }
1764
1765 gint UL_interference_and_noise_level_IE(proto_tree *diuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
1766 {
1767     /* DL-MAP Extended IE = 0xF */
1768     /* 8.4.5.3.19 UL_interference_and_noise_level_IE */
1769     /* offset of TLV in nibbles, length of TLV in nibbles */
1770     gint nib;
1771     gint data;
1772     proto_item *ti = NULL;
1773     proto_tree *tree = NULL;
1774     gint bitmap;
1775
1776     nib = offset;
1777
1778     ti = proto_tree_add_text(diuc_tree, tvb, NIBHI(offset, length), "UL_interference_and_noise_level_IE");
1779     tree = proto_item_add_subtree(ti, ett_286h);
1780
1781     XNIB(data,  1, "Extended DIUC");
1782     XNIB(data,  1, "Length");
1783
1784     XNIB(bitmap,  2, "Bitmap");
1785
1786     if (bitmap & 0x01) {
1787         XNIB(data, 2, "CQI/ACK/Periodic Ranging region NI");
1788     }
1789     if (bitmap & 0x02) {
1790         XNIB(data, 2, "PUSC region NI");
1791     }
1792     if (bitmap & 0x04) {
1793         XNIB(data, 2, "Optional PUSC region NI");
1794     }
1795     if (bitmap & 0x08) {
1796         XNIB(data, 2, "AMC region NI");
1797     }
1798     if (bitmap & 0x10) {
1799         XNIB(data, 2, "AAS region NI");
1800     }
1801     if (bitmap & 0x20) {
1802         XNIB(data, 2, "Periodic Ranging region NI");
1803     }
1804     if (bitmap & 0x40) {
1805         XNIB(data, 2, "Sounding region NI");
1806     }
1807     if (bitmap & 0x80) {
1808         XNIB(data, 2, "MIMO region NI");
1809     }
1810
1811     return nib;
1812 }
1813
1814 /********************************************************************
1815  * DL-MAP Plugin
1816  *******************************************************************/
1817
1818 extern gint wimax_decode_ulmapc(proto_tree *base_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb);
1819
1820
1821 gint dissect_dlmap_ie(proto_tree *ie_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
1822 {
1823     /* decode a single DL-MAP IE and return the
1824      * length of the IE in nibbles
1825      * offset = start of IE (nibbles)
1826      * length = total length of bufptr (nibbles) */
1827     proto_item *ti = NULL;
1828     proto_tree *tree = NULL;
1829
1830     gint nibble = offset;
1831     gint diuc;
1832     gint ext2_diuc;
1833     gint len;
1834     gint ext_diuc;
1835
1836     gint alt_format = 0;
1837     guint data = 0;
1838     gint i;
1839     /*gint papr = 0;*/
1840     gint ie_len = 9;
1841
1842     gint n_cid;
1843
1844     /* 8.4.5.3 DL-MAP IE format - table 275 */
1845     diuc = NIB_NIBBLE(nibble, bufptr);
1846     if (diuc == 14)
1847     {
1848         /* 8.4.5.3.2.2 [2] Extended-2 DIUC dependent IE table 277b */
1849         ext2_diuc = NIB_NIBBLE(1+nibble, bufptr);
1850         len = NIB_BYTE(1+nibble+1, bufptr);
1851
1852         ti = proto_tree_add_uint(ie_tree, hf_dlmap_ie_diuc, tvb, NIBHI(nibble, 1+3+len*2), diuc);
1853         proto_item_append_text(ti, " (Extended-2)");
1854         tree = proto_item_add_subtree(ti, ett_277b);
1855         nibble++;
1856
1857         len = 3 + BYTE_TO_NIB(len);
1858
1859         /* table 277c [2] */
1860         switch (ext2_diuc)
1861         {
1862             case 0x00:
1863                 /* 8.4.5.3.12 MBS_MAP_IE */
1864                 nibble = MBS_MAP_IE(tree, bufptr, nibble, len, tvb);
1865                 break;
1866             case 0x01:
1867                 /* 8.4.5.3.14 HO_Anchor_Active_DL-MAP_IE */
1868                 nibble = HO_Anchor_Active_DL_MAP_IE(tree, bufptr, nibble, len, tvb);
1869                 break;
1870             case 0x02:
1871                 /* 8.4.5.3.15 HO_Active_Anchor_DL_MAP_IE */
1872                 nibble = HO_Active_Anchor_DL_MAP_IE(tree, bufptr, nibble, len, tvb);
1873                 break;
1874             case 0x03:
1875                 /* 8.4.5.3.16 HO_CID_Translation_MAP_IE */
1876                 nibble = HO_CID_Translation_MAP_IE(tree, bufptr, nibble, len, tvb);
1877                 break;
1878             case 0x04:
1879                 /* 8.4.5.3.17 MIMO_in_another_BS_IE */
1880                 nibble = MIMO_in_another_BS_IE(tree, bufptr, nibble, len, tvb);
1881                 break;
1882             case 0x05:
1883                 /* 8.4.5.3.18 Macro-MIMO_DL_Basic_IE */
1884                 nibble = Macro_MIMO_DL_Basic_IE(tree, bufptr, nibble, len, tvb);
1885                 break;
1886             case 0x06:
1887                 /* 8.4.5.3.20.2 Skip_IE */
1888                 nibble = Skip_IE(tree, bufptr, nibble, len, tvb);
1889                 break;
1890             case 0x07:
1891                 /* 8.4.5.3.21 HARQ_DL_MAP_IE */
1892                 nibble = HARQ_DL_MAP_IE(tree, bufptr, nibble, len, tvb);
1893                 break;
1894             case 0x08:
1895                 /* 8.4.5.3.22 HARQ_ACK IE */
1896                 nibble = HARQ_ACK_IE(tree, bufptr, nibble, len, tvb);
1897                 break;
1898             case 0x09:
1899                 /* 8.4.5.3.23 Enhanced DL MAP IE */
1900                 nibble = Enhanced_DL_MAP_IE(tree, bufptr, nibble, len, tvb);
1901                 break;
1902             case 0x0a:
1903                 /* 8.4.5.3.24 Closed-loop MIMO DL Enhanced IE */
1904                 nibble = Closed_loop_MIMO_DL_Enhanced_IE(tree, bufptr, nibble, len, tvb);
1905                 break;
1906             case 0x0b:
1907                 nibble = MIMO_DL_Basic_IE(tree, bufptr, nibble, len, tvb);
1908                 break;
1909             case 0x0c:
1910                 nibble = MIMO_DL_Enhanced_IE(tree, bufptr, nibble, len, tvb);
1911                 break;
1912
1913             case 0x0e:
1914                 nibble = AAS_SDMA_DL_IE(tree, bufptr, nibble, len, tvb);
1915                 break;
1916
1917             default:
1918                 proto_tree_add_text(tree, tvb, NIBHI(nibble,len), "(reserved Extended-2 DIUC: %d)", ext2_diuc);
1919                 nibble += len;
1920                 break;
1921
1922         }
1923     }
1924     else if (diuc == 15)
1925     {
1926         /* 8.4.5.3.2.1 [1] Extended DIUC dependent IE - table 277 */
1927         ext_diuc = NIB_NIBBLE(1+nibble, bufptr);
1928         len = NIB_NIBBLE(1+nibble+1, bufptr);
1929
1930         ti = proto_tree_add_uint(ie_tree, hf_dlmap_ie_diuc,  tvb, NIBHI(nibble, 1+2+len*2), diuc);
1931         proto_item_append_text(ti, " (Extended)");
1932         tree = proto_item_add_subtree(ti, ett_277);
1933         nibble++;
1934
1935         len = 2 + BYTE_TO_NIB(len);
1936
1937         /* TODO 8.4.5.3.27 PUSC_ASCA_IE -- unspecified ExtDIUC? */
1938
1939         /* 8.4.5.3.2.1 table 277a */
1940         switch (ext_diuc)
1941         {
1942             case 0x00:
1943                 /* 8.4.5.3.? Channel_Measurement_IE */
1944                 nibble = Channel_Measurement_IE(tree, bufptr, nibble, len, tvb);
1945                 break;
1946             case 0x01:
1947                 /* 8.4.5.3.4 STC_Zone_IE */
1948                 nibble = STC_Zone_IE(tree, bufptr, nibble, len, tvb);
1949                 break;
1950             case 0x02:
1951                 /* 8.4.5.3.3 AAS_DL_IE */
1952                 nibble = AAS_DL_IE(tree, bufptr, nibble, len, tvb);
1953                 break;
1954             case 0x03:
1955                 /* 8.4.5.3.6 Data_location_in_another_BS_IE */
1956                 nibble = Data_location_in_another_BS_IE(tree, bufptr, nibble, len, tvb);
1957                 break;
1958             case 0x04:
1959                 /* 8.4.5.3.7 CID_Switch_IE */
1960                 nibble = CID_Switch_IE(tree, bufptr, nibble, len, tvb);
1961                 break;
1962             case 0x07:
1963                 /* 8.4.5.3.10 HARQ_Map_Pointer_IE */
1964                 nibble = HARQ_Map_Pointer_IE(tree, bufptr, nibble, len, tvb);
1965                 break;
1966             case 0x08:
1967                 /* 8.4.5.3.11 PHYMOD_DL_IE */
1968                 nibble = PHYMOD_DL_IE(tree, bufptr, nibble, len, tvb);
1969                 break;
1970
1971             case 0x0b:
1972                 /* 8.4.5.3.13 DL PUSC Burst Allocation in Other Segment IE */
1973                 nibble = DL_PUSC_Burst_Allocation_in_Other_Segment_IE(tree, bufptr, nibble, len, tvb);
1974                 break;
1975             case 0x0c:
1976                 nibble = PUSC_ASCA_Alloc_IE(tree, bufptr, nibble, len, tvb);
1977                 break;
1978
1979             case 0x0f:
1980                 /* 8.4.5.3.19 UL_interference_and_noise_level_IE */
1981                 nibble = UL_interference_and_noise_level_IE(tree, bufptr, nibble, len, tvb);
1982                 break;
1983
1984             default:
1985                 proto_tree_add_text(tree, tvb, NIBHI(nibble,len), "(reserved Extended DIUC: %d)", ext_diuc);
1986                 nibble += len;
1987                 break;
1988         }
1989     }
1990     else
1991     {
1992         /* Downlink IE */
1993         alt_format = 0;
1994         /*papr = 0; XX: not used ? */
1995         ie_len = 9;
1996
1997         /* TODO: alt_format = 1 if (Permutation == 0x11) and (AMC type is 2x3 or 1x6) */
1998
1999         /* precalculate IE len for correct highlighting */
2000         if (INC_CID && !sub_dl_ul_map) {
2001             ie_len += 2 + (NIB_BYTE(nibble+1, bufptr) * 4);
2002         }
2003
2004         /* DL-MAP_IE */
2005         ti = proto_tree_add_uint(ie_tree, hf_dlmap_ie_diuc,  tvb, NIBHI(nibble, ie_len), diuc);
2006         tree = proto_item_add_subtree(ti, ett_275_1);
2007         nibble += 1;
2008
2009         if (diuc == 13) {
2010             /* 8.4.5.3.1 [1] Gap/PAPR Reduction */
2011             /*papr = 1; XX: not used ? */
2012             proto_item_append_text(ti, " (Gap/PAPR Reduction)");
2013         }
2014
2015
2016         if (INC_CID)
2017         {
2018             n_cid = NIB_BYTE(nibble, bufptr);
2019             proto_tree_add_uint(tree, hf_dlmap_ie_ncid, tvb, NIBHI(nibble, 2), n_cid);
2020             nibble += 2;
2021
2022             for (i = 0; i < n_cid; i++)
2023             {
2024                 if (sub_dl_ul_map) {
2025                     /* RCID_IE 8.4.5.3 and 8.4.5.3.20.1, only part of SUB-DL-UL-MAP */
2026                     /* RCID_Type comes from 6.3.2.3.43.2 [2] Format_configuration_IE in Compact_DL-MAP_IE */
2027                     nibble += RCID_IE(tree, bufptr, nibble*4, length, tvb, RCID_Type) / 4;
2028                 } else {
2029                     data = NIB_WORD(nibble, bufptr);
2030                     proto_tree_add_uint(tree, hf_dlmap_ie_cid, tvb, NIBHI(nibble, 4), data);
2031                     nibble += 4;
2032                 }
2033             }
2034         }
2035
2036         data = NIB_LONG(nibble, bufptr);
2037         if (alt_format) {
2038             proto_tree_add_uint(tree, hf_dlmap_ie_offsym2,   tvb, NIBHI(nibble, 8), data);
2039             proto_tree_add_uint(tree, hf_dlmap_ie_offsub2,   tvb, NIBHI(nibble, 8), data);
2040             proto_tree_add_uint(tree, hf_dlmap_ie_boosting2, tvb, NIBHI(nibble, 8), data);
2041             proto_tree_add_uint(tree, hf_dlmap_ie_numsym2,   tvb, NIBHI(nibble, 8), data);
2042             proto_tree_add_uint(tree, hf_dlmap_ie_numsub2,   tvb, NIBHI(nibble, 8), data);
2043             proto_tree_add_uint(tree, hf_dlmap_ie_rep2,      tvb, NIBHI(nibble, 8), data);
2044         } else {
2045             proto_tree_add_uint(tree, hf_dlmap_ie_offsym,    tvb, NIBHI(nibble, 8), data);
2046             proto_tree_add_uint(tree, hf_dlmap_ie_offsub,    tvb, NIBHI(nibble, 8), data);
2047             proto_tree_add_uint(tree, hf_dlmap_ie_boosting,  tvb, NIBHI(nibble, 8), data);
2048             proto_tree_add_uint(tree, hf_dlmap_ie_numsym,    tvb, NIBHI(nibble, 8), data);
2049             proto_tree_add_uint(tree, hf_dlmap_ie_numsub,    tvb, NIBHI(nibble, 8), data);
2050             proto_tree_add_uint(tree, hf_dlmap_ie_rep,       tvb, NIBHI(nibble, 8), data);
2051         }
2052         nibble += 8;
2053     }
2054
2055     /* length in nibbles */
2056     return (nibble - offset);
2057 }
2058
2059
2060 void dissect_mac_mgmt_msg_dlmap_decoder(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *base_tree)
2061 {
2062     /* 6.3.2.3.2 [2] DL-MAP table 16 */
2063     guint offset = 0;
2064     gint length, nib, pad;
2065     proto_item *ti         = NULL;
2066     proto_tree *dlmap_tree = NULL;
2067     proto_tree *ie_tree    = NULL;
2068     proto_tree *phy_tree   = NULL;
2069     gint tvb_len           = tvb_reported_length(tvb);
2070     /* XXX This should be removed, and regular tvb accessors should be used instead. */
2071     const guint8 *bufptr   = tvb_get_ptr(tvb, offset, tvb_len);
2072
2073     INC_CID = 0;
2074
2075     /* add protocol */
2076     ti = proto_tree_add_protocol_format(base_tree, proto_mac_mgmt_msg_dlmap_decoder, tvb, offset, tvb_len, "DL-MAP (%u bytes)", tvb_len);
2077     dlmap_tree = proto_item_add_subtree(ti, ett_dlmap);
2078
2079     /* Decode and display the DL-MAP */
2080     proto_tree_add_item(dlmap_tree, hf_dlmap_message_type, tvb, offset, 1, ENC_BIG_ENDIAN);
2081     offset++;
2082     /* PHY Synchronization Field 8.4.5.1 */
2083     {
2084         ti = proto_tree_add_text(dlmap_tree, tvb, offset, 4, "Phy Synchronization Field");
2085         phy_tree = proto_item_add_subtree(ti, ett_275_phy);
2086         proto_tree_add_item(phy_tree, hf_dlmap_phy_fdur_ms, tvb, offset, 1, ENC_BIG_ENDIAN);
2087         proto_tree_add_item(phy_tree, hf_dlmap_phy_fdur_per_sec, tvb, offset, 1, ENC_BIG_ENDIAN);
2088         proto_tree_add_item(phy_tree, hf_dlmap_phy_fdur, tvb, offset, 1, ENC_BIG_ENDIAN);
2089         offset++;
2090         proto_tree_add_item(phy_tree, hf_dlmap_phy_fnum, tvb, offset, 3, ENC_BIG_ENDIAN);
2091         offset += 3;
2092     }
2093     proto_tree_add_item(dlmap_tree, hf_dlmap_dcd, tvb, offset, 1, ENC_BIG_ENDIAN);
2094     offset++;
2095     proto_tree_add_item(dlmap_tree, hf_dlmap_bsid, tvb, offset, 6, ENC_NA);
2096     offset += 6;
2097     proto_tree_add_item(dlmap_tree, hf_dlmap_ofdma_sym, tvb, offset, 1, ENC_BIG_ENDIAN);
2098     offset++;
2099
2100     /* DL-MAP IEs */
2101     length = tvb_len - offset; /* remaining length in bytes */
2102     ti = proto_tree_add_text(dlmap_tree, tvb, offset, length, "DL-MAP IEs (%d bytes)", length);
2103     ie_tree = proto_item_add_subtree(ti, ett_dlmap_ie);
2104
2105     /* length = BYTE_TO_NIB(length); */ /* convert length to nibbles */
2106
2107     nib = BYTE_TO_NIB(offset);
2108     while (nib < ((tvb_len*2)-1)) {
2109         nib += dissect_dlmap_ie(ie_tree, bufptr, nib, tvb_len * 2, tvb);
2110     }
2111     pad = NIB_PADDING(nib);
2112     if (pad) {
2113         proto_tree_add_text(dlmap_tree, tvb, NIBHI(nib,1), "Padding nibble");
2114         nib++;
2115     }
2116 }
2117
2118 gint wimax_decode_dlmapc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *base_tree)
2119 {
2120     /* 8.4.5.6.1 [2] Compressed DL-MAP */
2121     /* decode a compressed dl-map and return the length in bytes; */
2122     /* if there is a compressed ul-map, also decode that and include in the length */
2123     guint offset = 0;
2124     proto_item *ti = NULL;
2125     proto_item *ti_phy = NULL;
2126     proto_item *ti_dlmap_ies = NULL;
2127     proto_item *generic_item = NULL;
2128     proto_tree *tree = NULL;
2129     proto_tree *ie_tree = NULL;
2130     proto_tree *phy_tree = NULL;
2131     gint ulmap_appended;
2132     guint length, lennib, pad;
2133     guint mac_len, dl_ie_count;
2134     guint           tvb_len = tvb_reported_length(tvb);
2135     /* XXX This should be removed, and regular tvb accessors should be used instead. */
2136     const guint8 * bufptr  = tvb_get_ptr(tvb, offset, tvb_len);
2137     guint          nib     = 0;
2138     guint32        mac_crc, calculated_crc;
2139
2140     /* update the info column */
2141     col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "Compressed DL-MAP");
2142
2143     INC_CID = 0;
2144
2145     length = tvb_get_ntohs(tvb, offset) & 0x07FF; /* compressed map length is 11 bits */
2146     mac_len = length;
2147     lennib = BYTE_TO_NIB(length);
2148
2149     ulmap_appended = (tvb_get_guint8(tvb, offset) >> 4) & 1; /* UL MAP appended? */
2150
2151     /* display MAC Compressed DL-MAP and create subtree */
2152     ti = proto_tree_add_protocol_format(base_tree, proto_mac_mgmt_msg_dlmap_decoder, tvb, offset, length, "Compressed DL-MAP (%u bytes)", length);
2153     tree = proto_item_add_subtree(ti, ett_305);
2154
2155     /* decode dlmap fields */
2156     proto_tree_add_item(tree, hf_dlmapc_compr,    tvb, offset,   2, ENC_BIG_ENDIAN);
2157     proto_tree_add_item(tree, hf_dlmapc_ulmap,    tvb, offset,   2, ENC_BIG_ENDIAN);
2158     proto_tree_add_item(tree, hf_dlmapc_rsv,      tvb, offset,   2, ENC_BIG_ENDIAN);
2159     proto_tree_add_item(tree, hf_dlmapc_len,      tvb, offset,   2, ENC_BIG_ENDIAN);
2160     /* PHY Synchronization Field 8.4.5.1 */
2161     {
2162         ti_phy = proto_tree_add_text(tree, tvb, offset+2, 4, "Phy Synchronization Field");
2163         phy_tree = proto_item_add_subtree(ti_phy, ett_275_phy);
2164         proto_tree_add_item(phy_tree, hf_dlmap_phy_fdur_ms, tvb, offset+2, 1, ENC_BIG_ENDIAN);
2165         proto_tree_add_item(phy_tree, hf_dlmap_phy_fdur_per_sec, tvb, offset+2, 1, ENC_BIG_ENDIAN);
2166         proto_tree_add_item(phy_tree, hf_dlmap_phy_fnum, tvb, offset+3, 3, ENC_BIG_ENDIAN);
2167     }
2168     proto_tree_add_item(tree, hf_dlmap_dcd,       tvb, offset+6, 1, ENC_BIG_ENDIAN);
2169     proto_tree_add_item(tree, hf_dlmapc_opid,     tvb, offset+7, 1, ENC_BIG_ENDIAN);
2170     proto_tree_add_item(tree, hf_dlmapc_secid,    tvb, offset+8, 1, ENC_BIG_ENDIAN);
2171     proto_tree_add_item(tree, hf_dlmap_ofdma_sym, tvb, offset+9, 1, ENC_BIG_ENDIAN); /* 2005 */
2172     proto_tree_add_item(tree, hf_dlmapc_count,    tvb, offset+10,1, ENC_BIG_ENDIAN);
2173     dl_ie_count = tvb_get_guint8(tvb, offset + 10);
2174     offset += 11;
2175     nib = BYTE_TO_NIB(offset);
2176
2177     /* DL-MAP IEs */
2178     length -= 15; /* remaining length in bytes (11 bytes above + CRC at end) */
2179     if (dl_ie_count) {
2180         ti_dlmap_ies = proto_tree_add_text(tree, tvb, offset, length, "DL-MAP IEs (%d bytes)", length);
2181         ie_tree = proto_item_add_subtree(ti_dlmap_ies, ett_dlmap_ie);
2182
2183         /* length = BYTE_TO_NIB(mac_len - sizeof(mac_crc) - 1); */ /* convert length to nibbles */
2184
2185         while (dl_ie_count--) {
2186             nib += dissect_dlmap_ie(ie_tree, bufptr, nib, tvb_len * 2, tvb);
2187         }
2188         pad = NIB_PADDING(nib);
2189         if (pad) {
2190             proto_tree_add_text(tree, tvb, NIBHI(nib,1), "Padding nibble");
2191             nib++;
2192         }
2193     }
2194
2195     if (ulmap_appended) {
2196         /* Replace the text of items to set the correct length in bytes.*/
2197         proto_item_set_text(ti, "Compressed DL-MAP (%u bytes)", NIB_ADDR(nib));
2198         proto_item_set_text(ti_dlmap_ies, "DL-MAP IEs (%u bytes)",NIB_ADDR(nib)- offset);
2199
2200         /* set the length of items */
2201         proto_item_set_end(ti_dlmap_ies, tvb, NIB_ADDR(nib));
2202         proto_item_set_end(ti, tvb, NIB_ADDR(nib));
2203
2204         /* update the info column */
2205         col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "Compressed UL-MAP");
2206
2207         /* subtract 8 from lennib (CRC) */
2208         wimax_decode_ulmapc(base_tree, bufptr, nib, lennib - 8, tvb);
2209     }
2210
2211     /* CRC is always appended */
2212     /* check the length */
2213     if (MIN(tvb_len, tvb_reported_length(tvb)) >= mac_len)
2214     {   /* get the CRC */
2215         mac_crc = tvb_get_ntohl(tvb, mac_len - sizeof(mac_crc));
2216         /* calculate the CRC */
2217         calculated_crc = wimax_mac_calc_crc32(tvb_get_ptr(tvb, 0, mac_len - sizeof(mac_crc)), mac_len - sizeof(mac_crc));
2218         /* display the CRC */
2219         generic_item = proto_tree_add_item(base_tree, hf_mac_header_compress_dlmap_crc, tvb, mac_len - sizeof(mac_crc), sizeof(mac_crc), ENC_BIG_ENDIAN);
2220         if (mac_crc != calculated_crc)
2221         {
2222             proto_item_append_text(generic_item, " - incorrect! (should be: 0x%x)", calculated_crc);
2223         }
2224     }
2225     else
2226     {   /* display error message */
2227         proto_tree_add_protocol_format(base_tree, proto_mac_mgmt_msg_dlmap_decoder, tvb, 0, tvb_len, "CRC missing - the frame is too short (%u bytes)", tvb_len);
2228     }
2229
2230     return mac_len;
2231 }
2232
2233 extern gint dissect_ulmap_ie(proto_tree *ie_tree,
2234     const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb);
2235 extern gint wimax_decode_ulmap_reduced_aas(proto_tree *ie_tree,
2236     const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb);
2237
2238 gint wimax_decode_sub_dl_ul_map(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *base_tree)
2239 {
2240     /* decode a SUB-DL-UL-MAP message 6.3.2.3.60 and return the length in bytes */
2241     /* first three bits are 0x7, which following a compressed DL map indicates this message */
2242     guint offset = 0;
2243     proto_item *ti = NULL;
2244     proto_tree *tree = NULL;
2245     proto_tree *ie_tree = NULL;
2246     proto_item *generic_item = NULL;
2247     gint data;
2248     gint i, numie;
2249     guint16 calculated_crc;
2250
2251     gint           length = tvb_reported_length(tvb);
2252     /* XXX This should be removed, and regular tvb accessors should be used instead. */
2253     const guint8 * bufptr = tvb_get_ptr(tvb, offset, length);
2254     gint           nib = 0;
2255     gint           lennib = BYTE_TO_NIB(length);
2256
2257     sub_dl_ul_map = 1; /* set flag */
2258
2259     ti = proto_tree_add_text(base_tree, tvb, NIBHI(nib,lennib-nib), "SUB-DL-UL-MAP");
2260     tree = proto_item_add_subtree(ti, ett_109x);
2261
2262     data = NIB_WORD(nib,bufptr);
2263     proto_tree_add_uint(tree, hf_109x_cmi,  tvb, NIBHI(nib,4), data);
2264     proto_tree_add_uint(tree, hf_109x_len,  tvb, NIBHI(nib,4), data);
2265     proto_tree_add_uint(tree, hf_109x_rcid, tvb, NIBHI(nib,4), data);
2266     proto_tree_add_uint(tree, hf_109x_haoi, tvb, NIBHI(nib,4), data);
2267     nib += 4;
2268
2269     /* HARQ ACK offset indicator */
2270     if (data & 1) {
2271         data = NIB_BYTE(nib,bufptr);
2272         proto_tree_add_uint(tree, hf_109x_dl,  tvb, NIBHI(nib,2), data);
2273         nib += 2;
2274         data = NIB_BYTE(nib,bufptr);
2275         proto_tree_add_uint(tree, hf_109x_ul, tvb, NIBHI(nib,2), data);
2276         nib += 2;
2277     }
2278
2279     numie = NIB_BYTE(nib,bufptr);
2280     proto_tree_add_uint(tree, hf_109x_dlie,  tvb, NIBHI(nib,2), numie);
2281     nib += 2;
2282
2283     /* DL-MAP IEs */
2284     ti = proto_tree_add_text(tree, tvb, NIBHI(nib,1), "DL-MAP IEs");
2285     ie_tree = proto_item_add_subtree(ti, ett_109x_dl);
2286     for (i = 0; i < numie; i++) {
2287         nib += dissect_dlmap_ie(ie_tree, bufptr, nib, lennib - nib, tvb);
2288     }
2289
2290     data = NIB_BYTE(nib,bufptr);
2291     proto_tree_add_uint(tree, hf_109x_symofs,  tvb, NIBHI(nib,2), data);
2292     nib += 2;
2293     data = NIB_BYTE(nib,bufptr);
2294     proto_tree_add_uint(tree, hf_109x_subofs,  tvb, NIBHI(nib,2), data);
2295     proto_tree_add_uint(tree, hf_109x_rsv, tvb, NIBHI(nib,2), data);
2296     nib += 2;
2297
2298     /* UL-MAP IEs */
2299     ti = proto_tree_add_text(tree, tvb, NIBHI(nib,lennib-nib), "UL-MAP IEs");
2300     ie_tree = proto_item_add_subtree(ti, ett_109x_ul);
2301     for ( ; nib < lennib - 1; ) {
2302         nib += dissect_ulmap_ie(ie_tree, bufptr, nib, lennib - nib, tvb);
2303     }
2304
2305     /* padding */
2306     if (nib & 1) {
2307         proto_tree_add_text(tree, tvb, NIBHI(nib,1), "Padding Nibble");
2308         nib++;
2309     }
2310
2311     /* CRC-16 is always appended */
2312     data = NIB_WORD(nib, bufptr);
2313     generic_item = proto_tree_add_text(tree, tvb, NIBHI(nib,4), "CRC-16: 0x%04x",data);
2314     /* calculate the CRC */
2315     calculated_crc = wimax_mac_calc_crc16(tvb_get_ptr(tvb, 0, NIB_TO_BYTE(nib)), NIB_TO_BYTE(nib));
2316     if (data != calculated_crc)
2317     {
2318         proto_item_append_text(generic_item, " - incorrect! (should be: 0x%x)", calculated_crc);
2319     }
2320     /* nib += 4; */
2321
2322     sub_dl_ul_map = 0; /* clear flag */
2323     /* return length */
2324     return length;
2325 }
2326
2327 gint wimax_decode_dlmap_reduced_aas(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *base_tree)
2328 {
2329     /* 8.4.5.8.1 [2] Reduced AAS private DL-MAP */
2330     /* if there is an appended UL-MAP, also decode that */
2331     guint offset = 0;
2332     proto_item *ti = NULL;
2333     proto_tree *tree = NULL;
2334     proto_item *generic_item = NULL;
2335     gint ulmap_appended;
2336     gint length;
2337     gint           tvb_len = tvb_reported_length(tvb);
2338     /* XXX This should be removed, and regular tvb accessors should be used instead. */
2339     const guint8 * bufptr  = tvb_get_ptr(tvb, offset, tvb_len);
2340     gint           bit     = 0;
2341     guint data, pad, mult;
2342     gint numie = 1;
2343     gint i;
2344     guint16 calculated_crc;
2345     gint smcs,cidi,dcdi,phyi,cqci;
2346
2347     length = tvb_len;
2348
2349     /* display MAC Reduced_AAS_Private_DL-MAP and create subtree */
2350     ti = proto_tree_add_protocol_format(base_tree, proto_mac_mgmt_msg_dlmap_decoder, tvb, offset, length, "Reduced_AAS_Private_DL-MAP");
2351     tree = proto_item_add_subtree(ti, ett_308a);
2352
2353     VBIT(data, 3, hf_308a_cmi);
2354     VBIT(ulmap_appended, 1, hf_308a_ulmap);
2355     VBIT(data, 2, hf_308a_type);
2356     VBIT(mult, 1, hf_308a_mult);
2357     VBIT(data, 1, hf_308a_rsv);
2358
2359     if (mult) {
2360         XBIT(numie, 8, "NUM IE");
2361     }
2362
2363     for (i = 0; i < numie; i++) {
2364         XBIT(data, 2, "Periodicity");
2365         XBIT(cidi, 1, "CID Included");
2366         XBIT(dcdi, 1, "DCD Count Included");
2367         XBIT(phyi, 1, "PHY modification included");
2368         XBIT(cqci, 1, "CQICH control indicator");
2369         XBIT(data, 2, "Encoding Mode");
2370         XBIT(smcs, 1, "Separate MCS Enabled");
2371
2372         if (smcs) {
2373             XBIT(data,10, "Duration");
2374             XBIT(data, 4, "DIUC");
2375             XBIT(data, 2, "Repetition Coding Indication");
2376         }
2377         if (cidi) {
2378             XBIT(data,16, "CID");
2379         }
2380         if (cqci) {
2381             XBIT(data, 6, "Allocation Index");
2382             XBIT(data, 3, "Report Period");
2383             XBIT(data, 3, "Frame Offset");
2384             XBIT(data, 4, "Report Duration");
2385             XBIT(data, 2, "CQI Measurement Type");
2386             XBIT(data, 2, "Reserved");
2387         }
2388         if (dcdi) {
2389             XBIT(data, 8, "DCD Count");
2390         }
2391         if (phyi) {
2392             XBIT(data, 1, "Preamble Select");
2393             XBIT(data, 4, "Preamble Shift Index");
2394             XBIT(data, 1, "Pilot Pattern Modifier");
2395             XBIT(data, 2, "Pilot Pattern Index");
2396         }
2397         XBIT(data, 3, "DL Frame Offset");
2398         if (fusc) {
2399             XBIT(data, 8, "Zone Symbol Offset");
2400         }
2401         XBIT(data, 8, "OFDMA Symbol Offset");
2402         if (tusc) {
2403             XBIT(data, 8, "Subchannel Offset");
2404             XBIT(data, 5, "No. OFDMA triple symbol");
2405             XBIT(data, 6, "No. subchannels");
2406         } else {
2407             XBIT(data, 6, "Subchannel Offset");
2408             XBIT(data, 7, "No. OFDMA symbols");
2409             XBIT(data, 6, "No. subchannels");
2410         }
2411         XBIT(data, 4, "DIUC/N(EP)");
2412         if (harq) {
2413             XBIT(data, 1, "DL HARQ ACK bitmap");
2414             XBIT(data, 6, "ACK Allocation Index");
2415             XBIT(data, 4, "ACID");
2416             XBIT(data, 1, "AI_SN");
2417             if (ir_type) {
2418                 XBIT(data, 4, "N(SCH)");
2419                 XBIT(data, 2, "SPID");
2420                 XBIT(data, 2, "Reserved");
2421             }
2422         }
2423         XBIT(data, 2, "Repetition Coding Indication");
2424         if (ulmap_appended) {
2425             /* offset and length are in bits */
2426             bit += wimax_decode_ulmap_reduced_aas(tree, bufptr, offset, length*8, tvb);
2427         }
2428         XBIT(data, 3, "Reserved");
2429     }
2430
2431     /* padding */
2432     pad = BIT_PADDING(bit,8);
2433     if (pad) {
2434         proto_tree_add_text(tree, tvb, BITHI(bit,pad), "Padding: %d bits",pad);
2435         bit += pad;
2436     }
2437
2438     /* CRC-16 is always appended */
2439     data = BIT_BITS(bit, bufptr, 16);
2440     generic_item = proto_tree_add_text(tree, tvb, BITHI(bit,16), "CRC-16: 0x%04x",data);
2441     /* calculate the CRC */
2442     calculated_crc = wimax_mac_calc_crc16(tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
2443     if (data != calculated_crc)
2444     {
2445         proto_item_append_text(generic_item, " - incorrect! (should be: 0x%x)", calculated_crc);
2446     }
2447     bit += 16;
2448
2449     return BIT_TO_BYTE(bit) - offset;
2450 }
2451
2452 /* Register Wimax Mac Payload Protocol and Dissector */
2453 void proto_register_mac_mgmt_msg_dlmap(void)
2454 {
2455         /* DL-MAP fields display */
2456         static hf_register_info hf[] =
2457         {
2458                 {
2459                         &hf_dlmap_message_type,
2460                         {
2461                                 "MAC Management Message Type", "wmx.macmgtmsgtype.dlmap",
2462                                 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL
2463                         }
2464                 },
2465                 {
2466                         &hf_dlmap_bsid,
2467                         {
2468                                 "Base Station ID", "wmx.dlmap.bsid",
2469                                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL
2470                         }
2471                 },
2472                 {
2473                         &hf_dlmap_dcd,
2474                         {
2475                                 "DCD Count", "wmx.dlmap.dcd",
2476                                 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL
2477                         }
2478                 },
2479                 {
2480                         &hf_dlmap_fch_expected,
2481                         {
2482                                 "FCH Expected", "wmx.dlmap.fch_expected",
2483                                 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL
2484                         }
2485                 },
2486                 {
2487                         &hf_dlmap_ie,
2488                         {
2489                                 "DL-MAP IE", "wmx.dlmap.ie",
2490                                 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL
2491                         }
2492                 },
2493                 {
2494                         &hf_dlmap_ie_boosting,
2495                         {
2496                                 "Boosting", "wmx.dlmap.ie.boosting",
2497                                 FT_UINT32, BASE_DEC, VALS(boost_msgs), 0x00038000, NULL, HFILL
2498                         }
2499                 },
2500                 {
2501                         &hf_dlmap_ie_boosting2,
2502                         {
2503                                 "Boosting", "wmx.dlmap.ie.boosting",
2504                                 FT_UINT32, BASE_DEC, VALS(boost_msgs), 0x0000E000, NULL, HFILL
2505                         }
2506                 },
2507                 {
2508                         &hf_dlmap_ie_cid,
2509                         {
2510                                 "CID", "wmx.dlmap.ie.cid",
2511                                 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL
2512                         }
2513                 },
2514                 {
2515                         &hf_dlmap_ie_diuc,
2516                         {
2517                                 "DIUC", "wmx.dlmap.ie.diuc",
2518                                 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL
2519                         }
2520                 },
2521                 {
2522                         &hf_dlmap_ie_ncid,
2523                         {
2524                                 "N_CID", "wmx.dlmap.ie.ncid",
2525                                 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL
2526                         }
2527                 },
2528                 {
2529                         &hf_dlmap_ie_numsub,
2530                         {
2531                                 "Number of Subchannels", "wmx.dlmap.ie.numsub",
2532                                 FT_UINT32, BASE_DEC, NULL, 0x000000FC, NULL, HFILL
2533                         }
2534                 },
2535                 {
2536                         &hf_dlmap_ie_numsym,
2537                         {
2538                                 "Number of OFDMA Symbols", "wmx.dlmap.ie.numsym",
2539                                 FT_UINT32, BASE_DEC, NULL, 0x00007F00, NULL, HFILL
2540                         }
2541                 },
2542                 {
2543                         &hf_dlmap_ie_numsub2,
2544                         {
2545                                 "Number of Subchannels", "wmx.dlmap.ie.numsub",
2546                                 FT_UINT32, BASE_DEC, NULL, 0x000000FC, NULL, HFILL
2547                         }
2548                 },
2549                 {
2550                         &hf_dlmap_ie_numsym2,
2551                         {
2552                                 "Number of OFDMA Symbols", "wmx.dlmap.ie.numsym",
2553                                 FT_UINT32, BASE_DEC, NULL, 0x00001F00, NULL, HFILL
2554                         }
2555                 },
2556                 {
2557                         &hf_dlmap_ie_offsub,
2558                         {
2559                                 "Subchannel Offset", "wmx.dlmap.ie.offsub",
2560                                 FT_UINT32, BASE_DEC, NULL, 0x00FC0000, NULL, HFILL
2561                         }
2562                 },
2563                 {
2564                         &hf_dlmap_ie_offsym,
2565                         {
2566                                 "OFDMA Symbol Offset", "wmx.dlmap.ie.offsym",
2567                                 FT_UINT32, BASE_DEC, NULL, 0xFF000000, NULL, HFILL
2568                         }
2569                 },
2570                 /* alt ie format */
2571                 {
2572                         &hf_dlmap_ie_offsub2,
2573                         {
2574                                 "Subchannel Offset", "wmx.dlmap.ie.offsub",
2575                                 FT_UINT32, BASE_DEC, NULL, 0x00FF0000, NULL, HFILL
2576                         }
2577                 },
2578                 {
2579                         &hf_dlmap_ie_offsym2,
2580                         {
2581                                 "OFDMA Symbol Offset", "wmx.dlmap.ie.offsym",
2582                                 FT_UINT32, BASE_DEC, NULL, 0xFF000000, NULL, HFILL
2583                         }
2584                 },
2585                 {
2586                         &hf_dlmap_ie_rep,
2587                         {
2588                                 "Repetition Coding Indication", "wmx.dlmap.ie.rep",
2589                                 FT_UINT32, BASE_DEC, VALS(rep_msgs), 0x00000003, NULL, HFILL
2590                         }
2591                 },
2592                 {
2593                         &hf_dlmap_ie_rep2,
2594                         {
2595                                 "Repetition Coding Indication", "wmx.dlmap.ie.rep",
2596                                 FT_UINT32, BASE_DEC, VALS(rep_msgs), 0x00000003, NULL, HFILL
2597                         }
2598                 },
2599                 {
2600                         &hf_dlmap_ofdma_sym,
2601                         {
2602                                 "Num OFDMA Symbols", "wmx.dlmap.ofdma_sym",
2603                                 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL
2604                         }
2605                 },
2606                 {
2607                         &hf_dlmap_phy_fdur,
2608                         {
2609                                 "Frame Duration Code", "wmx.dlmap.phy_fdur",
2610                                 FT_UINT8, BASE_HEX, NULL, 0x00, NULL, HFILL
2611                         }
2612                 },
2613                 {
2614                         &hf_dlmap_phy_fdur_ms,
2615                         {
2616                                 "Frame Duration", "wmx.dlmap.phy_fdur",
2617                                 FT_UINT8, BASE_HEX, VALS(frame_duration), 0x00, NULL, HFILL
2618                         }
2619                 },
2620                 {
2621                         &hf_dlmap_phy_fdur_per_sec,
2622                         {
2623                                 "Frames per second", "wmx.dlmap.phy_fdur",
2624                                 FT_UINT8, BASE_HEX, VALS(frames_per_second), 0x00, NULL, HFILL
2625                         }
2626                 },
2627                 {
2628                         &hf_dlmap_phy_fnum,
2629                         {
2630                                 "Frame Number", "wmx.dlmap.phy_fnum",
2631                                 FT_UINT24, BASE_DEC, NULL, 0x0, NULL, HFILL
2632                         }
2633                 },
2634                 {
2635                         &hf_dlmapc_compr,
2636                         {
2637                                 "Compressed map indicator", "wmx.dlmapc.compr",
2638                                 FT_UINT16, BASE_DEC, NULL, 0xe000, NULL, HFILL
2639                         }
2640                 },
2641                 {
2642                         &hf_dlmapc_count,
2643                         {
2644                                 "DL IE Count", "wmx.dlmapc.count",
2645                                 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL
2646                         }
2647                 },
2648                 {
2649                         &hf_dlmapc_len,
2650                         {
2651                                 "Map message length", "wmx.dlmapc.len",
2652                                 FT_UINT16, BASE_DEC, NULL, 0x07FF, NULL, HFILL
2653                         }
2654                 },
2655                 {
2656                         &hf_dlmapc_opid,
2657                         {
2658                                 "Operator ID", "wmx.dlmapc.opid",
2659                                 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL
2660                         }
2661                 },
2662                 {
2663                         &hf_dlmapc_rsv,
2664                         {
2665                                 "Reserved", "wmx.dlmapc.rsv",
2666                                 FT_UINT16, BASE_DEC, NULL, 0x0800, NULL, HFILL
2667                         }
2668                 },
2669                 {
2670                         &hf_dlmapc_secid,
2671                         {
2672                                 "Sector ID", "wmx.dlmapc.secid",
2673                                 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL
2674                         }
2675                 },
2676                 {
2677                         &hf_dlmapc_sync,
2678                         {
2679                                 "PHY Synchronization Field", "wmx.dlmapc.sync",
2680                                 FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL
2681                         }
2682                 },
2683                 {
2684                         &hf_dlmapc_ulmap,
2685                         {
2686                                 "UL-MAP appended", "wmx.dlmapc.ulmap",
2687                                 FT_UINT16, BASE_DEC, NULL, 0x1000, NULL, HFILL
2688                         }
2689                 },
2690                 {
2691                         &hf_dlmap_xie_diuc,
2692                         {
2693                                 "Extended DIUC", "wmx.dlmapc.xie_diuc",
2694                                 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL
2695                         }
2696                 },
2697                 {
2698                         &hf_dlmap_xie_len,
2699                         {
2700                                 "Length", "wmx.dlmapc.xie_len",
2701                                 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL
2702                         }
2703                 },
2704                 {
2705                         &hf_109x_cmi,
2706                         {
2707                                 "SUB-DL-UL-MAP map indicator", "wmx.dlul.cmi",
2708                                 FT_UINT16, BASE_DEC, NULL, 0xE000, NULL, HFILL
2709                         }
2710                 },
2711                 {
2712                         &hf_109x_dl,
2713                         {
2714                                 "DL HARQ ACK offset", "wmx.dlul.dl",
2715                                 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL
2716                         }
2717                 },
2718                 {
2719                         &hf_109x_dlie,
2720                         {
2721                                 "DL IE Count", "wmx.dlul.dlie",
2722                                 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL
2723                         }
2724                 },
2725                 {
2726                         &hf_109x_haoi,
2727                         {
2728                                 "HARQ ACK offset indicator", "wmx.dlul.haoi",
2729                                 FT_UINT16, BASE_DEC, NULL, 0x0001, NULL, HFILL
2730                         }
2731                 },
2732                 {
2733                         &hf_109x_len,
2734                         {
2735                                 "Map message length - The length is limited to 735 bytes at most", "wmx.dlul.len",
2736                                 FT_UINT16, BASE_DEC, NULL, 0x1FF8, NULL, HFILL
2737                         }
2738                 },
2739                 {
2740                         &hf_109x_rcid,
2741                         {
2742                                 "RCID_Type", "wmx.dlul.rcid",
2743                                 FT_UINT16, BASE_DEC, NULL, 0x0006, NULL, HFILL
2744                         }
2745                 },
2746                 {
2747                         &hf_109x_subofs,
2748                         {
2749                                 "Subchannel offset", "wmx.dlul.subofs",
2750                                 FT_UINT8, BASE_DEC, NULL, 0xFE, NULL, HFILL
2751                         }
2752                 },
2753                 {
2754                         &hf_109x_symofs,
2755                         {
2756                                 "OFDMA Symbol offset of subsequent sub-bursts "
2757                                 "in this Sub-DL-UL-MAP message with reference to "
2758                                 "the start of UL sub-frame.", "wmx.dlul.symofs",
2759                                 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL
2760                         }
2761                 },
2762                 {
2763                         &hf_109x_rsv,
2764                         {
2765                                 "Reserved", "wmx.dlul.rsv",
2766                                 FT_UINT8, BASE_DEC, NULL, 0x01, NULL, HFILL
2767                         }
2768                 },
2769                 {
2770                         &hf_109x_ul,
2771                         {
2772                                 "UL HARQ ACK offset", "wmx.dlul.ul",
2773                                 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL
2774                         }
2775                 },
2776                 {
2777                         &hf_308a_cmi,
2778                         {
2779                                 "Compressed map indicator", "wmx.dlmap.reduced_aas_private.cmi",
2780                                 FT_UINT8, BASE_DEC, NULL, 0xe0, NULL, HFILL
2781                         }
2782                 },
2783                 {
2784                         &hf_308a_mult,
2785                         {
2786                                 "Multiple IE", "wmx.dlmap.reduced_aas_private.mult",
2787                                 FT_UINT8, BASE_DEC, NULL, 0x02, NULL, HFILL
2788                         }
2789                 },
2790                 {
2791                         &hf_308a_rsv,
2792                         {
2793                                 "Reserved", "wmx.dlmap.reduced_aas_private.rsv",
2794                                 FT_UINT8, BASE_DEC, NULL, 0x01, NULL, HFILL
2795                         }
2796                 },
2797                 {
2798                         &hf_308a_type,
2799                         {
2800                                 "Compressed Map Type", "wmx.dlmap.reduced_aas_private.type",
2801                                 FT_UINT8, BASE_DEC, NULL, 0x0d, NULL, HFILL
2802                         }
2803                 },
2804                 {
2805                         &hf_308a_ulmap,
2806                         {
2807                                 "UL-MAP appended", "wmx.dlmap.reduced_aas_private.ulmap",
2808                                 FT_UINT8, BASE_DEC, NULL, 0x10, NULL, HFILL
2809                         }
2810                 },
2811                 {
2812                         &hf_mac_header_compress_dlmap_crc,
2813                         {
2814                                 "CRC", "wmx.compress_dlmap_crc",
2815                                 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL
2816                         }
2817                 }
2818         };
2819
2820         /* Setup protocol subtree array */
2821         static gint *ett[] =
2822                 {
2823                         &ett_dlmap,
2824                         &ett_dlmap_ie,
2825                         /* &ett_dlmap_c_ie, */
2826                         &ett_109x,
2827                         &ett_109x_dl,
2828                         &ett_109x_ul,
2829                         &ett_275_phy,
2830                         &ett_275_1,
2831                         &ett_277,
2832                         &ett_277b,
2833                         &ett_278,
2834                         &ett_279,
2835                         &ett_280,
2836                         &ett_281,
2837                         &ett_282,
2838                         &ett_283,
2839                         &ett_284,
2840                         &ett_285,
2841                         &ett_286,
2842                         &ett_286a,
2843                         &ett_286b,
2844                         &ett_286c,
2845                         &ett_286d,
2846                         &ett_286e,
2847                         &ett_286f,
2848                         &ett_286g,
2849                         &ett_286h,
2850                         &ett_286i,
2851                         &ett_286j,
2852                         &ett_286k,
2853                         &ett_286l,
2854                         &ett_286m,
2855                         &ett_286n,
2856                         &ett_286o,
2857                         &ett_286p,
2858                         &ett_286q,
2859                         &ett_286r,
2860                         &ett_286s,
2861                         &ett_286t,
2862                         &ett_286u,
2863                         &ett_286v,
2864                         &ett_286w,
2865                         &ett_286x,
2866                         &ett_286y,
2867                         &ett_286z,
2868                         &ett_305,
2869                         /* &ett_305_dl, */
2870                         &ett_308a,
2871                 };
2872
2873         proto_mac_mgmt_msg_dlmap_decoder = proto_register_protocol (
2874                 "WiMax DLMAP/ULMAP Messages", /* name       */
2875                 "WiMax DLMAP/ULMAP (map)",    /* short name */
2876                 "wmx.map"                     /* abbrev     */
2877                 );
2878
2879         proto_register_field_array(proto_mac_mgmt_msg_dlmap_decoder, hf, array_length(hf));
2880         proto_register_subtree_array(ett, array_length(ett));
2881 }