Warning fixes: function declaration isn’t a prototype
[obnox/wireshark/wip.git] / plugins / wimax / msg_ulmap.c
1 /* msg_ulmap.c
2  * WiMax MAC Management UL-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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
27  */
28
29 /* Include files */
30
31 #ifdef HAVE_CONFIG_H
32 #include "config.h"
33 #endif
34
35 #include "moduleinfo.h"
36
37 #include <glib.h>
38 #include <epan/packet.h>
39 #include <epan/prefs.h>
40 #include "crc.h"
41 #include "wimax_bits.h"
42
43 extern gint proto_mac_mgmt_msg_dlmap_decoder;
44 extern  gboolean include_cor2_changes;
45
46 #define MAC_MGMT_MSG_ULMAP 3
47
48 #define XBIT(var, bits, desc) \
49     do { \
50     var = BIT_BITS(bit, bufptr, bits); \
51     proto_tree_add_text(tree, tvb, BITHI(bit, bits), desc ": %d", var); \
52     bit += bits; \
53     } while(0)
54
55 #define XNIB(var, nibs, desc) \
56     do { \
57     var = NIB_NIBS(nib, bufptr, nibs); \
58     proto_tree_add_text(tree, tvb, NIBHI(nib, nibs), desc ": %d", var); \
59     nib += nibs; \
60     } while(0)
61
62 extern gint man_ofdma;
63
64 /* from msg_ucd.c */
65 extern guint cqich_id_size;             /* Set for CQICH_Alloc_IE */
66
67 /* from msg_dlmap.c */
68 extern gint harq;
69 extern gint ir_type;
70 extern gint N_layer;
71 extern gint RCID_Type;
72 extern gint RCID_IE(proto_tree *diuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb, gint RCID_Type);
73
74
75 /* forward reference */
76 void dissect_mac_mgmt_msg_ulmap_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
77
78 static gint proto_mac_mgmt_msg_ulmap_decoder = -1;
79
80 static gint ett_ulmap = -1;
81 static gint ett_ulmap_ie = -1;
82 static gint ett_ulmap_ffb = -1;
83 static gint ett_ulmap_c = -1;
84 static gint ett_ulmap_c_ie = -1;
85 static gint ett_ulmap_s = -1;
86 static gint ett_ulmap_s_ie = -1;
87 static gint ett_287_1 = -1;
88 static gint ett_287_2 = -1;
89 static gint ett_289 = -1;
90 static gint ett_290 = -1;
91 static gint ett_290b = -1;
92 static gint ett_291 = -1;
93 static gint ett_292 = -1;
94 static gint ett_293 = -1;
95 static gint ett_294 = -1;
96 static gint ett_295 = -1;
97 static gint ett_299 = -1;
98 static gint ett_300 = -1;
99 static gint ett_302 = -1;
100 static gint ett_302a = -1;
101 static gint ett_302b = -1;
102 static gint ett_302c = -1;
103 static gint ett_302d = -1;
104 static gint ett_302e = -1;
105 static gint ett_302f = -1;
106 static gint ett_302g = -1;
107 static gint ett_302h = -1;
108 static gint ett_302i = -1;
109 static gint ett_302j = -1;
110 static gint ett_302k = -1;
111 static gint ett_302l = -1;
112 static gint ett_302m = -1;
113 static gint ett_302n = -1;
114 static gint ett_302o = -1;
115 static gint ett_302p = -1;
116 static gint ett_302q = -1;
117 static gint ett_302r = -1;
118 static gint ett_302s = -1;
119 static gint ett_302t = -1;
120 static gint ett_302u = -1;
121 static gint ett_302v = -1;
122 static gint ett_306 = -1;
123 static gint ett_306_ul = -1;
124 static gint ett_308b = -1;
125 static gint ett_315d = -1;
126
127 /* Setup protocol subtree array */
128 static gint *ett[] =
129 {
130     &ett_ulmap,
131     &ett_ulmap_ie,
132     &ett_ulmap_ffb,
133     &ett_ulmap_c,
134     &ett_ulmap_c_ie,
135     &ett_ulmap_s,
136     &ett_ulmap_s_ie,
137     &ett_287_1,
138     &ett_287_2,
139     &ett_289,
140     &ett_290,
141     &ett_290b,
142     &ett_291,
143     &ett_292,
144     &ett_293,
145     &ett_294,
146     &ett_295,
147     &ett_299,
148     &ett_300,
149     &ett_302,
150     &ett_302a,
151     &ett_302b,
152     &ett_302c,
153     &ett_302d,
154     &ett_302e,
155     &ett_302f,
156     &ett_302h,
157     &ett_302g,
158     &ett_302i,
159     &ett_302j,
160     &ett_302k,
161     &ett_302l,
162     &ett_302m,
163     &ett_302n,
164     &ett_302o,
165     &ett_302p,
166     &ett_302q,
167     &ett_302r,
168     &ett_302s,
169     &ett_302t,
170     &ett_302u,
171     &ett_302v,
172     &ett_306,
173     &ett_306_ul,
174     &ett_308b,
175     &ett_315d,
176 };
177
178 #define DCD_DOWNLINK_BURST_PROFILE        1
179 #define DCD_BS_EIRP                       2
180 #define DCD_FRAME_DURATION                3
181 #define DCD_PHY_TYPE                      4
182 #define DCD_POWER_ADJUSTMENT              5
183 #define DCD_CHANNEL_NR                    6
184 #define DCD_TTG                           7
185 #define DCD_RTG                           8
186 #define DCD_RSS                           9
187 #define DCD_CHANNEL_SWITCH_FRAME_NR      10
188 #define DCD_FREQUENCY                    12
189 #define DCD_BS_ID                        13
190 #define DCD_FRAME_DURATION_CODE          14
191 #define DCD_FRAME_NR                     15
192 #define DCD_SIZE_CQICH_ID                16
193 #define DCD_H_ARQ_ACK_DELAY              17
194 #define DCD_MAC_VERSION                 148
195 #define DCD_RESTART_COUNT               154
196
197 #define DCD_BURST_FREQUENCY               1
198 #define DCD_BURST_FEC_CODE_TYPE         150
199 #define DCD_BURST_DIUC_EXIT_THRESHOLD   151
200 #define DCD_BURST_DIUC_ENTRY_THRESHOLD  152
201 #define DCD_BURST_TCS_ENABLE            153
202
203 #define DCD_TLV_T_541_TYPE_FUNCTION_ACTION                                1
204 #define DCD_TLV_T542_TRIGGER_VALUE                                        2
205 #define DCD_TLV_T_543_TRIGGER_AVERAGING_DURATION                          3
206 #define DCD_TLV_T_19_PERMUTATION_TYPE_FOR_BROADCAST_REGION_IN_HARQ_ZONE  19
207 #define DCD_TLV_T_20_MAXIMUM_RETRANSMISSION                              20
208 #define DCD_TLV_T_21_DEFAULT_RSSI_AND_CINR_AVERAGING_PARAMETER           21
209 #define DCD_TLV_T_22_DL_AMC_ALLOCATED_PHYSICAL_BANDS_BITMAP              22
210 #define DCD_TLV_T_31_H_ADD_THRESHOLD                                     31
211 #define DCD_TLV_T_32_H_DELETE_THRESHOLD                                  32
212 #define DCD_TLV_T_33_ASR                                                 33
213 #define DCD_TLV_T_34_DL_REGION_DEFINITION                                34
214 #define DCD_TLV_T_35_PAGING_GROUP_ID                                     35
215 #define DCD_TLV_T_36_TUSC1_PERMUTATION_ACTIVE_SUBCHANNELS_BITMAP         36
216 #define DCD_TLV_T_37_TUSC2_PERMUTATION_ACTIVE_SUBCHANNELS_BITMAP         37
217 #define DCD_TLV_T_45_PAGING_INTERVAL_LENGTH                              45
218 #define DCD_TLV_T_50_HO_TYPE_SUPPORT                                     50
219 #define DCD_TLV_T_51_HYSTERSIS_MARGIN                                    51
220 #define DCD_TLV_T_52_TIME_TO_TRIGGER_DURATION                            52
221 #define DCD_TLV_T_54_TRIGGER                                             54
222 #define DCD_TLV_T_153_DOWNLINK_BURST_PROFILE_FOR_MULTIPLE_FEC_TYPES     153
223
224 #define UL_MAP_NCT_PMP  0
225 #define UL_MAP_NCT_DM   1
226 #define UL_MAP_NCT_PTP  2
227
228 /* NCT messages */
229 static const value_string nct_msgs[] =
230 {
231     { UL_MAP_NCT_PMP, "PMP" },
232     { UL_MAP_NCT_PMP, "DM" },
233     { UL_MAP_NCT_PMP, "PTP" },
234     { 0,  NULL }
235 };
236
237 /* Repetition Coding Indications */
238 static const value_string rep_msgs[] =
239 {
240     { 0, "No Repetition Coding" },
241     { 1, "Repetition Coding of 2 Used" },
242     { 2, "Repetition Coding of 4 Used" },
243     { 3, "Repetition Coding of 6 Used" },
244     { 0,  NULL }
245 };
246
247 /* DL Frame Prefix Coding Indications */
248 static const value_string boost_msgs[] =
249 {
250     { 0, "Normal (not boosted)" },
251     { 1, "+6dB" },
252     { 2, "-6dB" },
253     { 3, "+9dB" },
254     { 4, "+3dB" },
255     { 5, "-3dB" },
256     { 6, "-9dB" },
257     { 7, "-12dB" },
258     { 0,  NULL }
259 };
260
261 /* ul-map fields */
262 static gint hf_ulmap_message_type = -1;
263 static gint hf_ulmap_reserved = -1;
264 static gint hf_ulmap_ucd_count = -1;
265 static gint hf_ulmap_alloc_start_time = -1;
266 static gint hf_ulmap_ofdma_sym = -1;
267 static gint hf_ulmap_fch_expected = -1;
268
269 static gint hf_ulmap_ie = -1;
270
271 static gint hf_ulmap_ie_cid      = -1;
272 static gint hf_ulmap_ie_uiuc     = -1;
273 static gint hf_ulmap_uiuc12_symofs = -1;
274 static gint hf_ulmap_uiuc12_subofs = -1;
275 static gint hf_ulmap_uiuc12_numsym = -1;
276 static gint hf_ulmap_uiuc12_numsub = -1;
277 static gint hf_ulmap_uiuc12_method = -1;
278 static gint hf_ulmap_uiuc12_dri    = -1;
279 static gint hf_ulmap_uiuc10_dur    = -1;
280 static gint hf_ulmap_uiuc10_rep    = -1;
281
282 static gint hf_ulmap_uiuc14_dur  = -1;
283 static gint hf_ulmap_uiuc14_uiuc = -1;
284 static gint hf_ulmap_uiuc14_rep  = -1;
285 static gint hf_ulmap_uiuc14_idx  = -1;
286 static gint hf_ulmap_uiuc14_code = -1;
287 static gint hf_ulmap_uiuc14_sym  = -1;
288 static gint hf_ulmap_uiuc14_sub  = -1;
289 static gint hf_ulmap_uiuc14_bwr  = -1;
290
291 static gint hf_ulmap_uiuc11_ext = -1;
292 static gint hf_ulmap_uiuc11_len = -1;
293 static gint hf_ulmap_uiuc11_data = -1;
294 static gint hf_ulmap_uiuc15_ext = -1;
295 static gint hf_ulmap_uiuc15_len = -1;
296 static gint hf_ulmap_uiuc15_data = -1;
297
298 static gint hf_ulmap_uiuc0_symofs = -1;
299 static gint hf_ulmap_uiuc0_subofs = -1;
300 static gint hf_ulmap_uiuc0_numsym = -1;
301 static gint hf_ulmap_uiuc0_numsub = -1;
302 static gint hf_ulmap_uiuc0_rsv    = -1;
303
304 static gint hf_ulmap_uiuc13_symofs = -1;
305 static gint hf_ulmap_uiuc13_subofs = -1;
306 static gint hf_ulmap_uiuc13_numsym = -1;
307 static gint hf_ulmap_uiuc13_numsub = -1;
308 static gint hf_ulmap_uiuc13_papr   = -1;
309 static gint hf_ulmap_uiuc13_zone   = -1;
310 static gint hf_ulmap_uiuc13_rsv    = -1;
311
312 /* UL-MAP fields display */
313 static hf_register_info hf[] =
314 {
315     {
316             &hf_ulmap_message_type,
317             {
318                     "MAC Management Message Type", "wmx.macmgtmsgtype.ulmap",
319                     FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL
320             }
321     },
322     {
323             &hf_ulmap_fch_expected,
324             {
325                     "FCH Expected", "wmx.ulmap.fch.expected",
326                     FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL
327             }
328     },
329     {
330             &hf_ulmap_ie,
331             {
332                     "UL-MAP IE", "wmx.ulmap.ie",
333                     FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL
334             }
335     },
336     {
337             &hf_ulmap_ie_cid,
338             {
339                     "CID", "wmx.ulmap.ie.cid",
340                     FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL
341             }
342     },
343     {
344             &hf_ulmap_ie_uiuc,
345             {
346                     "UIUC", "wmx.ulmap.ie.uiuc",
347                     FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL
348             }
349     },
350     {
351             &hf_ulmap_ofdma_sym,
352             {
353                     "Num OFDMA Symbols", "wmx.ulmap.ofdma.sym",
354                     FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL
355             }
356     },
357     {
358             &hf_ulmap_reserved,
359             {
360                     "Reserved", "wmx.ulmap.rsv",
361                     FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL
362             }
363     },
364     {
365             &hf_ulmap_alloc_start_time,
366             {
367                     "Uplink Channel ID", "wmx.ulmap.start",
368                     FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL
369             }
370     },
371     {
372             &hf_ulmap_ucd_count,
373             {
374                     "UCD Count", "wmx.ulmap.ucd",
375                     FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL
376             }
377     },
378     {
379             &hf_ulmap_uiuc0_numsub,
380             {
381                     "No. subchannels", "wmx.ulmap.uiuc0.numsub",
382                     FT_UINT32,  BASE_DEC, NULL, 0x000003f8, "", HFILL
383             }
384     },
385     {
386             &hf_ulmap_uiuc0_numsym,
387             {
388                     "No. OFDMA symbols", "wmx.ulmap.uiuc0.numsym",
389                     FT_UINT32,  BASE_DEC, NULL, 0x0001fc00, "", HFILL
390             }
391     },
392     {
393             &hf_ulmap_uiuc0_rsv,
394             {
395                     "Reserved", "wmx.ulmap.uiuc0.rsv",
396                     FT_UINT32,  BASE_DEC, NULL, 0x00000007, "", HFILL
397             }
398     },
399     {
400             &hf_ulmap_uiuc0_subofs,
401             {
402                     "Subchannel offset", "wmx.ulmap.uiuc0.subofs",
403                     FT_UINT32,  BASE_DEC, NULL, 0x00fe0000, "", HFILL
404             }
405     },
406     {
407             &hf_ulmap_uiuc0_symofs,
408             {
409                     "OFDMA symbol offset", "wmx.ulmap.uiuc0.symofs",
410                     FT_UINT32,  BASE_DEC, NULL, 0xff000000, "", HFILL
411             }
412     },
413     {
414             &hf_ulmap_uiuc11_data,
415             {
416                     "Data", "wmx.ulmap.uiuc11.data",
417                     FT_BYTES,  BASE_HEX, NULL, 0x0, "", HFILL
418             }
419     },
420     {
421             &hf_ulmap_uiuc11_ext,
422             {
423                     "Extended 2 UIUC", "wmx.ulmap.uiuc11.ext",
424                     FT_UINT8,  BASE_DEC, NULL, 0x0, "", HFILL
425             }
426     },
427     {
428             &hf_ulmap_uiuc11_len,
429             {
430                     "Length", "wmx.ulmap.uiuc11.len",
431                     FT_UINT8,  BASE_DEC, NULL, 0x0, "", HFILL
432             }
433     },
434     {
435             &hf_ulmap_uiuc12_dri,
436             {
437                     "Dedicated ranging indicator", "wmx.ulmap.uiuc12.dri",
438                     FT_UINT32, BASE_DEC, NULL, 0x00000001, "", HFILL
439             }
440     },
441     {
442             &hf_ulmap_uiuc10_dur,
443             {
444                     "Duration", "wmx.ulmap.uiuc12.dur",
445                     FT_UINT16, BASE_DEC, NULL, 0xFFc0, "", HFILL
446             }
447     },
448     {
449             &hf_ulmap_uiuc12_method,
450             {
451                     "Ranging Method", "wmx.ulmap.uiuc12.method",
452                     FT_UINT32, BASE_DEC, NULL, 0x00000006, "", HFILL
453             }
454     },
455     {
456             &hf_ulmap_uiuc12_numsub,
457             {
458                     "No. Subchannels", "wmx.ulmap.uiuc12.numsub",
459                     FT_UINT32, BASE_DEC, NULL, 0x000003F8, "", HFILL
460             }
461     },
462     {
463             &hf_ulmap_uiuc12_numsym,
464             {
465                     "No. OFDMA Symbols", "wmx.ulmap.uiuc12.numsym",
466                     FT_UINT32, BASE_DEC, NULL, 0x0001Fc00, "", HFILL
467             }
468     },
469     {
470             &hf_ulmap_uiuc10_rep,
471             {
472                     "Repetition Coding indication", "wmx.ulmap.uiuc12.rep",
473                     FT_UINT16, BASE_DEC, NULL, 0x0030, "", HFILL
474             }
475     },
476     {
477             &hf_ulmap_uiuc12_subofs,
478             {
479                     "Subchannel Offset", "wmx.ulmap.uiuc12.subofs",
480                     FT_UINT32, BASE_DEC, NULL, 0x00Fe0000, "", HFILL
481             }
482     },
483     {
484             &hf_ulmap_uiuc12_symofs,
485             {
486                     "OFDMA Symbol Offset", "wmx.ulmap.uiuc12.symofs",
487                     FT_UINT32, BASE_DEC, NULL, 0xFF000000, "", HFILL
488             }
489     },
490     {
491             &hf_ulmap_uiuc13_numsub,
492             {
493                     "No. Subchannels/SZ Shift Value", "wmx.ulmap.uiuc13.numsub",
494                     FT_UINT32,  BASE_DEC, NULL, 0x000003f8, "", HFILL
495             }
496     },
497     {
498             &hf_ulmap_uiuc13_numsym,
499             {
500                     "No. OFDMA symbols", "wmx.ulmap.uiuc13.numsym",
501                     FT_UINT32,  BASE_DEC, NULL, 0x0001fc00, "", HFILL
502             }
503     },
504     {
505             &hf_ulmap_uiuc13_papr,
506             {
507                     "PAPR Reduction/Safety Zone", "wmx.ulmap.uiuc13.papr",
508                     FT_UINT32,  BASE_DEC, NULL, 0x00000004, "", HFILL
509             }
510     },
511     {
512             &hf_ulmap_uiuc13_rsv,
513             {
514                     "Reserved", "wmx.ulmap.uiuc13.rsv",
515                     FT_UINT32,  BASE_DEC, NULL, 0x00000001, "", HFILL
516             }
517     },
518     {
519             &hf_ulmap_uiuc13_subofs,
520             {
521                     "Subchannel offset", "wmx.ulmap.uiuc13.subofs",
522                     FT_UINT32,  BASE_DEC, NULL, 0x00fe0000, "", HFILL
523             }
524     },
525     {
526             &hf_ulmap_uiuc13_symofs,
527             {
528                     "OFDMA symbol offset", "wmx.ulmap.uiuc13.symofs",
529                     FT_UINT32,  BASE_DEC, NULL, 0xff000000, "", HFILL
530             }
531     },
532     {
533             &hf_ulmap_uiuc13_zone,
534             {
535                     "Sounding Zone", "wmx.ulmap.uiuc13.zone",
536                     FT_UINT32,  BASE_DEC, NULL, 0x00000002, "", HFILL
537             }
538     },
539     {
540             &hf_ulmap_uiuc14_bwr,
541             {
542                     "BW request mandatory", "wmx.ulmap.uiuc14.bwr",
543                     FT_UINT8,  BASE_DEC, NULL, 0x01, "", HFILL
544             }
545     },
546     {
547             &hf_ulmap_uiuc14_code,
548             {
549                     "Ranging code", "wmx.ulmap.uiuc14.code",
550                     FT_UINT8,  BASE_DEC, NULL, 0x0, "", HFILL
551             }
552     },
553     {
554             &hf_ulmap_uiuc14_dur,
555             {
556                     "Duration", "wmx.ulmap.uiuc14.dur",
557                     FT_UINT16, BASE_DEC, NULL, 0xfc00, "", HFILL
558             }
559     },
560     {
561             &hf_ulmap_uiuc14_idx,
562             {
563                     "Frame Number Index", "wmx.ulmap.uiuc14.idx",
564                     FT_UINT16, BASE_DEC, NULL, 0x000F, "", HFILL
565             }
566     },
567     {
568             &hf_ulmap_uiuc14_rep,
569             {
570                     "Repetition Coding Indication", "wmx.ulmap.uiuc14.rep",
571                     FT_UINT16, BASE_DEC, NULL, 0x0030, "", HFILL
572             }
573     },
574     {
575             &hf_ulmap_uiuc14_sub,
576             {
577                     "Ranging subchannel", "wmx.ulmap.uiuc14.sub",
578                     FT_UINT8,  BASE_DEC, NULL, 0xfe, "", HFILL
579             }
580     },
581     {
582             &hf_ulmap_uiuc14_sym,
583             {
584                     "Ranging symbol", "wmx.ulmap.uiuc14.sym",
585                     FT_UINT8,  BASE_DEC, NULL, 0x0, "", HFILL
586             }
587     },
588     {
589             &hf_ulmap_uiuc14_uiuc,
590             {
591                     "UIUC", "wmx.ulmap.uiuc14.uiuc",
592                     FT_UINT16, BASE_DEC, NULL, 0x03c0, "", HFILL
593             }
594     },
595     {
596             &hf_ulmap_uiuc15_data,
597             {
598                     "Data", "wmx.ulmap.uiuc15.data",
599                     FT_BYTES,  BASE_HEX, NULL, 0x0, "", HFILL
600             }
601     },
602     {
603             &hf_ulmap_uiuc15_ext,
604             {
605                     "Extended UIUC", "wmx.ulmap.uiuc15.ext",
606                     FT_UINT8,  BASE_DEC, NULL, 0x0, "", HFILL
607             }
608     },
609     {
610             &hf_ulmap_uiuc15_len,
611             {
612                     "Length", "wmx.ulmap.uiuc15.len",
613                     FT_UINT8,  BASE_DEC, NULL, 0x0, "", HFILL
614             }
615     }
616 };
617
618 /*  This gets called each time a capture file is loaded. */
619 void init_wimax_globals(void)
620 {
621     cqich_id_size = 0;
622     harq = 0;
623     ir_type = 0;
624     N_layer = 0;
625     RCID_Type = 0;
626 }
627
628 /********************************************************************
629  * UL-MAP HARQ Sub-Burst IEs
630  * 8.4.5.4.24 table 302j
631  * these functions take offset/length in bits
632  *******************************************************************/
633
634 gint Dedicated_UL_Control_IE(proto_tree *uiuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
635 {
636     /* 8.4.5.4.24.1 Dedicated_UL_Control_IE -- table 302r */
637     /* UL-MAP HARQ Sub-Burst IE * offset/length are in bits */
638     gint bit;
639     gint data;
640     proto_item *ti = NULL;
641     proto_item *tree = NULL;
642     gint sdma;
643
644     bit = offset;
645
646     ti = proto_tree_add_text(uiuc_tree, tvb, NIBHI(offset, length), "Dedicated_UL_Control_IE");
647     tree = proto_item_add_subtree(ti, ett_302r);
648
649     XBIT(data, 4, "Length");
650     XBIT(sdma, 4, "Control Header");
651     if ((sdma & 1) == 1) {
652         XBIT(data, 2, "Num SDMA layers");
653         XBIT(data, 2, "Pilot Pattern");
654     }
655     return (bit - offset); /* length in bits */
656 }
657
658 gint Dedicated_MIMO_UL_Control_IE(proto_tree *uiuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
659 {
660     /* 8.4.5.4.24.2 Dedicated_MIMO_UL_Control_IE -- table 302s */
661     /* UL-MAP HARQ Sub-Burst IE * offset/length are in bits */
662     gint bit;
663     gint data;
664     proto_item *ti = NULL;
665     proto_item *tree = NULL;
666
667     bit = offset;
668
669     ti = proto_tree_add_text(uiuc_tree, tvb, NIBHI(offset, length), "Dedicated_MIMO_UL_Control_IE");
670     tree = proto_item_add_subtree(ti, ett_302s);
671
672     XBIT(data, 2, "Matrix");
673     XBIT(N_layer, 2, "N_layer");
674
675     return (bit - offset); /* length in bits */
676 }
677
678 /* begin Sub-Burst IEs */
679
680 gint UL_HARQ_Chase_Sub_Burst_IE(proto_tree *uiuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
681 {
682     /* 8.4.5.4.24 UL_HARQ_Chase_sub_burst_IE -- table 302k */
683     /* UL-MAP HARQ Sub-Burst IE * offset/length are in bits */
684     gint bit;
685     gint data;
686     proto_item *ti = NULL;
687     proto_item *tree = NULL;
688     proto_item *generic_item = NULL;
689     gint duci;
690     guint16 calculated_crc;
691
692     bit = offset;
693
694     ti = proto_tree_add_text(uiuc_tree, tvb, BITHI(offset,length), "UL_HARQ_Chase_Sub_Burst_IE");
695     tree = proto_item_add_subtree(ti, ett_302k);
696
697     bit += RCID_IE(tree, bufptr, bit, length, tvb, RCID_Type);
698     XBIT(duci, 1, "Dedicated UL Control Indicator");
699     if (duci == 1) {
700         bit += Dedicated_UL_Control_IE(tree, bufptr, bit, length, tvb);
701     }
702     XBIT(data, 4, "UIUC");
703     XBIT(data, 2, "Repetition Coding Indication");
704     XBIT(data,10, "Duration");
705     XBIT(data, 4, "ACID");
706     XBIT(data, 1, "AI_SN");
707     XBIT(data, 1, "ACK_disable");
708     XBIT(data, 1, "Reserved");
709
710     if (include_cor2_changes)
711     {
712         /* CRC-16 is always appended */
713         data = BIT_BITS(bit, bufptr, 16);
714         generic_item = proto_tree_add_text(tree, tvb, BITHI(bit,16), "CRC-16: 0x%04x",data);
715         /* calculate the CRC */
716         calculated_crc = wimax_mac_calc_crc16((guint8 *)tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
717         if (data != calculated_crc)
718         {
719                 proto_item_append_text(generic_item, " - incorrect! (should be: 0x%x)", calculated_crc);
720         }
721         bit += 16;
722     }
723
724     return (bit - offset); /* length in bits */
725 }
726
727 gint UL_HARQ_IR_CTC_Sub_Burst_IE(proto_tree *uiuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
728 {
729     /* 8.4.5.4.24 UL_HARQ_IR_CTC_sub_burst_IE -- table 302l */
730     /* UL-MAP HARQ Sub-Burst IE * offset/length are in bits */
731     gint bit;
732     gint data;
733     proto_item *ti = NULL;
734     proto_item *tree = NULL;
735     proto_item *generic_item = NULL;
736     gint duci;
737     guint16 calculated_crc;
738
739     bit = offset;
740
741     ti = proto_tree_add_text(uiuc_tree, tvb, NIBHI(offset, length), "UL_HARQ_IR_CTC_Sub_Burst_IE");
742     tree = proto_item_add_subtree(ti, ett_302l);
743
744     bit += RCID_IE(tree, bufptr, bit, length, tvb, RCID_Type);
745     XBIT(duci, 1, "Dedicated UL Control Indicator");
746     if (duci == 1) {
747         bit += Dedicated_UL_Control_IE(tree, bufptr, bit, length, tvb);
748     }
749     XBIT(data, 4, "N(EP)");
750     XBIT(data, 4, "N(SCH)");
751     XBIT(data, 2, "SPID");
752     XBIT(data, 4, "ACIN");
753     XBIT(data, 1, "AI_SN");
754     XBIT(data, 1, "ACK_disable");
755     XBIT(data, 3, "Reserved");
756
757     if (include_cor2_changes)
758     {
759         /* CRC-16 is always appended */
760         data = BIT_BITS(bit, bufptr, 16);
761         generic_item = proto_tree_add_text(tree, tvb, BITHI(bit,16), "CRC-16: 0x%04x",data);
762         /* calculate the CRC */
763         calculated_crc = wimax_mac_calc_crc16((guint8 *)tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
764         if (data != calculated_crc)
765         {
766                 proto_item_append_text(generic_item, " - incorrect! (should be: 0x%x)", calculated_crc);
767         }
768         bit += 16;
769     }
770
771     return (bit - offset); /* length in bits */
772 }
773
774 gint UL_HARQ_IR_CC_Sub_Burst_IE(proto_tree *uiuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
775 {
776     /* 8.4.5.4.24 UL_HARQ_IR_CC_sub_burst_IE -- table 302m */
777     /* UL-MAP HARQ Sub-Burst IE * offset/length are in bits */
778     gint bit;
779     gint data;
780     proto_item *ti = NULL;
781     proto_item *tree = NULL;
782     proto_item *generic_item = NULL;
783     gint duci;
784     guint16 calculated_crc;
785
786     bit = offset;
787
788     ti = proto_tree_add_text(uiuc_tree, tvb, NIBHI(offset, length), "UL_HARQ_IR_CC_Sub_Burst_IE");
789     tree = proto_item_add_subtree(ti, ett_302m);
790
791     bit += RCID_IE(tree, bufptr, bit, length, tvb, RCID_Type);
792     XBIT(duci, 1, "Dedicated UL Control Indicator");
793     if (duci == 1) {
794         bit += Dedicated_UL_Control_IE(tree, bufptr, bit, length, tvb);
795     }
796     XBIT(data, 4, "UIUC");
797     XBIT(data, 2, "Repetition Coding Indication");
798     XBIT(data,10, "Duration");
799     XBIT(data, 2, "SPID");
800     XBIT(data, 4, "ACID");
801     XBIT(data, 1, "AI_SN");
802     XBIT(data, 1, "ACK_disable");
803     XBIT(data, 3, "Reserved");
804
805     if (include_cor2_changes)
806     {
807         /* CRC-16 is always appended */
808         data = BIT_BITS(bit, bufptr, 16);
809         generic_item = proto_tree_add_text(tree, tvb, BITHI(bit,16), "CRC-16: 0x%04x",data);
810         /* calculate the CRC */
811         calculated_crc = wimax_mac_calc_crc16((guint8 *)tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
812         if (data != calculated_crc)
813         {
814                 proto_item_append_text(generic_item, " - incorrect! (should be: 0x%x)", calculated_crc);
815         }
816         bit += 16;
817     }
818
819     return (bit - offset); /* length in bits */
820 }
821
822 gint MIMO_UL_Chase_HARQ_Sub_Burst_IE(proto_tree *uiuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
823 {
824     /* 8.4.5.4.24 MIMO_UL_Chase_HARQ_Sub_Burst_IE -- table 302n */
825     /* UL-MAP HARQ Sub-Burst IE * offset/length are in bits */
826     gint bit;
827     gint data;
828     proto_item *ti = NULL;
829     proto_item *tree = NULL;
830     proto_item *generic_item = NULL;
831     gint muin,dmci,ackd,i;
832     guint16 calculated_crc;
833
834     bit = offset;
835
836     ti = proto_tree_add_text(uiuc_tree, tvb, NIBHI(offset, length), "MIMO_UL_Chase_HARQ_Sub_Burst_IE");
837     tree = proto_item_add_subtree(ti, ett_302n);
838
839     XBIT(muin, 1, "MU indicator");
840     XBIT(dmci, 1, "Dedicated MIMO ULControl Indicator");
841     XBIT(ackd, 1, "ACK Disable");
842     if (muin == 0) {
843         bit += RCID_IE(tree, bufptr, bit, length, tvb, RCID_Type);
844         if (dmci) {
845             bit += Dedicated_MIMO_UL_Control_IE(tree, bufptr, bit, length, tvb);
846         }
847     } else {
848         XBIT(data, 1, "Matrix");
849     }
850     XBIT(data, 10, "Duration");
851     for (i = 0; i < N_layer; i++) {
852         if (muin == 1) {
853             bit += RCID_IE(tree, bufptr, bit, length, tvb, RCID_Type);
854         }
855         XBIT(data, 4, "UIUC");
856         XBIT(data, 2, "Repetition Coding Indication");
857         if (ackd == 0) {
858             XBIT(data, 4, "ACID");
859             XBIT(data, 1, "AI_SN");
860         }
861     }
862
863     if (include_cor2_changes)
864     {
865         /* CRC-16 is always appended */
866         data = BIT_BITS(bit, bufptr, 16);
867         generic_item = proto_tree_add_text(tree, tvb, BITHI(bit,16), "CRC-16: 0x%04x",data);
868         /* calculate the CRC */
869         calculated_crc = wimax_mac_calc_crc16((guint8 *)tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
870         if (data != calculated_crc)
871         {
872                 proto_item_append_text(generic_item, " - incorrect! (should be: 0x%x)", calculated_crc);
873         }
874         bit += 16;
875     }
876
877     return (bit - offset); /* length in bits */
878 }
879
880 gint MIMO_UL_IR_HARQ__Sub_Burst_IE(proto_tree *uiuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
881 {
882     /* 8.4.5.4.24 MIMO_UL_IR_HARQ__Sub_Burst_IE -- table 302o */
883     /* UL-MAP HARQ Sub-Burst IE * offset/length are in bits */
884     gint bit;
885     gint data;
886     proto_item *ti = NULL;
887     proto_item *tree = NULL;
888     proto_item *generic_item = NULL;
889     gint muin,dmci,ackd,i;
890     guint16 calculated_crc;
891
892     bit = offset;
893
894     ti = proto_tree_add_text(uiuc_tree, tvb, NIBHI(offset, length), "MIMO_UL_IR_HARQ__Sub_Burst_IE");
895     tree = proto_item_add_subtree(ti, ett_302o);
896
897     XBIT(muin, 1, "MU indicator");
898     XBIT(dmci, 1, "Dedicated MIMO UL Control Indicator");
899     XBIT(ackd, 1, "ACK Disable");
900     if (muin == 0) {
901         bit += RCID_IE(tree, bufptr, bit, length, tvb, RCID_Type);
902         if (dmci) {
903             bit += Dedicated_MIMO_UL_Control_IE(tree, bufptr, bit, length, tvb);
904         }
905     } else {
906         XBIT(data, 1, "Matrix");
907     }
908     XBIT(data, 4, "N(SCH)");
909     for (i = 0; i < N_layer; i++) {
910         if (muin == 1) {
911             bit += RCID_IE(tree, bufptr, bit, length, tvb, RCID_Type);
912         }
913         XBIT(data, 4, "N(EP)");
914         if (ackd == 0) {
915             XBIT(data, 2, "SPID");
916             XBIT(data, 4, "ACID");
917             XBIT(data, 1, "AI_SN");
918         }
919     }
920
921     if (include_cor2_changes)
922     {
923         /* CRC-16 is always appended */
924         data = BIT_BITS(bit, bufptr, 16);
925         generic_item = proto_tree_add_text(tree, tvb, BITHI(bit,16), "CRC-16: 0x%04x",data);
926         /* calculate the CRC */
927         calculated_crc = wimax_mac_calc_crc16((guint8 *)tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
928         if (data != calculated_crc)
929         {
930                 proto_item_append_text(generic_item, " - incorrect! (should be: 0x%x)", calculated_crc);
931         }
932         bit += 16;
933     }
934
935     return (bit - offset); /* length in bits */
936 }
937
938 gint MIMO_UL_IR_HARQ_for_CC_Sub_Burst_UIE(proto_tree *uiuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
939 {
940     /* 8.4.5.4.24 MIMO_UL_IR_HARQ_for_CC_Sub_Burst_UIE -- table 302p */
941     /* UL-MAP HARQ Sub-Burst IE * offset/length are in bits */
942     gint bit;
943     gint data;
944     proto_item *ti = NULL;
945     proto_item *tree = NULL;
946     proto_item *generic_item = NULL;
947     gint muin,dmci,ackd,i;
948     guint16 calculated_crc;
949
950     bit = offset;
951
952     ti = proto_tree_add_text(uiuc_tree, tvb, NIBHI(offset, length), "MIMO_UL_IR_HARQ_for_CC_Sub_Burst_UIE");
953     tree = proto_item_add_subtree(ti, ett_302p);
954
955     XBIT(muin, 1, "MU indicator");
956     XBIT(dmci, 1, "Dedicated MIMO UL Control Indicator");
957     XBIT(ackd, 1, "ACK Disable");
958     if (muin == 0) {
959         bit += RCID_IE(tree, bufptr, bit, length, tvb, RCID_Type);
960         if (dmci) {
961             bit += Dedicated_MIMO_UL_Control_IE(tree, bufptr, bit, length, tvb);
962         }
963     } else {
964         XBIT(data, 1, "Matrix");
965     }
966     XBIT(data, 10, "Duration");
967     for (i = 0; i < N_layer; i++) {
968         if (muin == 1) {
969             bit += RCID_IE(tree, bufptr, bit, length, tvb, RCID_Type);
970         }
971         XBIT(data, 4, "UIUC");
972         XBIT(data, 2, "Repetition Coding Indication");
973         if (ackd == 0) {
974             XBIT(data, 4, "ACID");
975             XBIT(data, 1, "AI_SN");
976             XBIT(data, 2, "SPID");
977         }
978     }
979
980     if (include_cor2_changes)
981     {
982         /* CRC-16 is always appended */
983         data = BIT_BITS(bit, bufptr, 16);
984         generic_item = proto_tree_add_text(tree, tvb, BITHI(bit,16), "CRC-16: 0x%04x",data);
985         /* calculate the CRC */
986         calculated_crc = wimax_mac_calc_crc16((guint8 *)tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
987         if (data != calculated_crc)
988         {
989                 proto_item_append_text(generic_item, " - incorrect! (should be: 0x%x)", calculated_crc);
990         }
991         bit += 16;
992     }
993
994     return (bit - offset); /* length in bits */
995 }
996
997 gint MIMO_UL_STC_HARQ_Sub_Burst_IE(proto_tree *uiuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
998 {
999     /* 8.4.5.4.24 MIMO_UL_STC_HARQ_Sub_Burst_IE -- table 302q */
1000     /* UL-MAP HARQ Sub-Burst IE * offset/length are in bits */
1001     gint bit;
1002     gint data;
1003     proto_item *ti = NULL;
1004     proto_item *tree = NULL;
1005     proto_item *generic_item = NULL;
1006     gint ackd,txct,sboi;
1007     guint16 calculated_crc;
1008
1009     bit = offset;
1010
1011     ti = proto_tree_add_text(uiuc_tree, tvb, NIBHI(offset, length), "MIMO_UL_STC_HARQ_Sub_Burst_IE");
1012     tree = proto_item_add_subtree(ti, ett_302q);
1013
1014     XBIT(txct, 2, "Tx count");
1015     XBIT(data, 10, "Duration");
1016     XBIT(sboi, 1, "Sub-burst offset indication");
1017     /*XBIT(muin, 1, "Reserved");*/
1018     if (sboi == 1) {
1019         XBIT(data, 8, "Sub-burst offset");
1020     }
1021     bit += RCID_IE(tree, bufptr, bit, length, tvb, RCID_Type);
1022     XBIT(ackd, 1, "ACK Disable");
1023     if (txct == 0) {
1024         XBIT(data, 4, "UIUC");
1025         XBIT(data, 2, "Repetition Coding Indication");
1026     }
1027     if (ackd == 0) {
1028         XBIT(data, 4, "ACID");
1029     }
1030
1031     if (include_cor2_changes)
1032     {
1033         /* CRC-16 is always appended */
1034         data = BIT_BITS(bit, bufptr, 16);
1035         generic_item = proto_tree_add_text(tree, tvb, BITHI(bit,16), "CRC-16: 0x%04x",data);
1036         /* calculate the CRC */
1037         calculated_crc = wimax_mac_calc_crc16((guint8 *)tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
1038         if (data != calculated_crc)
1039         {
1040                 proto_item_append_text(generic_item, " - incorrect! (should be: 0x%x)", calculated_crc);
1041         }
1042         bit += 16;
1043     }
1044
1045     return (bit - offset); /* length in bits */
1046 }
1047
1048 /********************************************************************
1049  * UL-MAP Extended IEs
1050  * table 290a
1051  *******************************************************************/
1052
1053 gint Power_Control_IE(proto_tree *uiuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
1054 {
1055     /* UL-MAP Extended IE = 0 */
1056     /* 8.4.5.4.5 Power_Control_IE */
1057     /* offset of TLV in nibbles, length of TLV in nibbles */
1058     gint nib;
1059     gint data;
1060     proto_item *ti = NULL;
1061     proto_item *tree = NULL;
1062
1063     nib = offset;
1064
1065     ti = proto_tree_add_text(uiuc_tree, tvb, NIBHI(offset, length), "Power_Control_IE");
1066     tree = proto_item_add_subtree(ti, ett_292);
1067
1068     XNIB(data, 1, "Extended UIUC");
1069     XNIB(data, 1, "Length");
1070
1071     XNIB(data, 2, "Power Control");
1072     XNIB(data, 2, "Power measurement frame");
1073     return nib;
1074 }
1075
1076 gint Mini_Subchannel_allocation_IE(proto_tree *uiuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
1077 {
1078     /* UL-MAP Extended IE = 1 */
1079     /* 8.4.5.4.8 [2] Mini-Subchannel_allocation_IE */
1080     /* offset of TLV in nibbles, length of TLV in nibbles */
1081     gint bit;
1082     gint data;
1083     proto_item *ti = NULL;
1084     proto_item *tree = NULL;
1085     gint j, M;
1086     const gint m_table[4] = { 2, 2, 3, 6 };
1087
1088     bit = NIB_TO_BIT(offset);
1089
1090     ti = proto_tree_add_text(uiuc_tree, tvb, NIBHI(offset, length), "Mini_subchannel_allocation_IE");
1091     tree = proto_item_add_subtree(ti, ett_295);
1092
1093     XBIT(data, 4, "Extended-2 UIUC");
1094     XBIT(data, 8, "Length");
1095
1096     XBIT(data, 2, "Ctype");
1097     M = m_table[data];
1098     XBIT(data, 6, "Duration");
1099
1100     for (j = 0; j < M; j++) {
1101         data = BIT_BITS(bit, bufptr, 16);
1102         proto_tree_add_text(tree, tvb, BITHI(bit, 16), "CID(%d): %d", j, data);
1103         bit += 16;
1104         data = BIT_BITS(bit, bufptr, 4);
1105         proto_tree_add_text(tree, tvb, BITHI(bit, 4), "UIUC(%d): %d", j, data);
1106         bit += 4;
1107         data = BIT_BITS(bit, bufptr, 2);
1108         proto_tree_add_text(tree, tvb, BITHI(bit, 2), "Repetition(%d): %d", j, data);
1109         bit += 2;
1110     }
1111     if (M == 3) {
1112         XBIT(data, 4, "Padding");
1113     }
1114     return BIT_TO_NIB(bit);
1115 }
1116
1117 gint AAS_UL_IE(proto_tree *uiuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
1118 {
1119     /* UL-MAP Extended IE = 2 */
1120     /* 8.4.5.4.6 [2] AAS_UL_IE*/
1121     /* offset of TLV in nibbles, length of TLV in nibbles */
1122     gint bit;
1123     gint data;
1124     proto_item *ti = NULL;
1125     proto_item *tree = NULL;
1126
1127     bit = NIB_TO_BIT(offset);
1128
1129     ti = proto_tree_add_text(uiuc_tree, tvb, NIBHI(offset, length), "AAS_UL_IE");
1130     tree = proto_item_add_subtree(ti, ett_293);
1131
1132     XBIT(data, 4, "Extended UIUC");
1133     XBIT(data, 4, "Length");
1134
1135     XBIT(data, 2, "Permutation");
1136     XBIT(data, 7, "UL_PermBase");
1137     XBIT(data, 8, "OFDMA symbol offset");
1138     XBIT(data, 8, "AAS zone length");
1139     XBIT(data, 2, "Uplink peramble config");
1140     XBIT(data, 1, "Preamble type");
1141     XBIT(data, 4, "Reserved");
1142     return BIT_TO_NIB(bit);
1143 }
1144
1145 gint CQICH_Alloc_IE(proto_tree *uiuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
1146 {
1147     /* UL-MAP Extended IE = 3 */
1148     /* 8.4.5.4.12 [2] CQICH_Alloc_IE */
1149     /* offset of TLV in nibbles, length of TLV in nibbles */
1150     gint bit;
1151     gint data;
1152     proto_item *ti = NULL;
1153     proto_item *tree = NULL;
1154     gint rci, rtype, ftype, zperm, mgi, api, pad;
1155
1156     bit = NIB_TO_BIT(offset);
1157
1158     ti = proto_tree_add_text(uiuc_tree, tvb, NIBHI(offset, length), "UL_ZONE_IE");
1159     tree = proto_item_add_subtree(ti, ett_300);
1160
1161     XBIT(data, 4, "Extended UIUC");
1162     XBIT(data, 4, "Length");
1163
1164     if (cqich_id_size == 0) {
1165         proto_tree_add_text(tree, tvb, BITHI(bit, 1), "CQICH_ID: n/a (size == 0 bits)");
1166     } else {
1167         /* variable from 0-9 bits */
1168         data = BIT_BITS16(bit, bufptr, cqich_id_size);
1169         proto_tree_add_text(tree, tvb, BITHI(bit, cqich_id_size), "CQICH_ID: %d (%d bits)", data, cqich_id_size);
1170         bit += cqich_id_size;
1171     }
1172
1173     XBIT(data, 6, "Allocation offset");
1174     XBIT(data, 2, "Period (p)");
1175     XBIT(data, 3, "Frame offset");
1176     XBIT(data, 3, "Duration (d)");
1177     XBIT(rci,  1, "Report configuration included");
1178     if (rci)
1179     {
1180         XBIT(ftype, 2, "Feedback Type");
1181         XBIT(rtype, 1, "Report type");
1182         if (rtype == 0) {
1183             XBIT(data, 1, "CINR preamble report type");
1184         }
1185         else {
1186             XBIT(zperm, 3, "Zone permutation");
1187             XBIT(data, 2, "Zone type");
1188             XBIT(data, 2, "Zone PRBS_ID");
1189             if (zperm == 0 || zperm == 1) {
1190                 XBIT(mgi, 1, "Major group indicatioon");
1191                 if (mgi == 1) {
1192                     /* PUSC major group bitmap*/
1193                     XBIT(data, 6, "PUSC Major group bitmap");
1194                 }
1195             }
1196             XBIT(data, 1, "CINR zone measurement type");
1197         }
1198         if (ftype == 0) {
1199             XBIT(api, 1, "Averaging parameter included");
1200             if (api == 1) {
1201                 XBIT(data, 4, "Averaging parameter");
1202             }
1203         }
1204     }
1205     XBIT(data, 2, "MIMO_permutation_feedback_cycle");
1206
1207     pad = BIT_PADDING(bit,8);
1208     if (pad) {
1209         proto_tree_add_text(tree, tvb, BITHI(bit, pad), "Padding: %d bits", pad);
1210         bit += pad;
1211     }
1212     return BIT_TO_NIB(bit);     /* Return position in nibbles. */
1213 }
1214
1215 gint UL_Zone_IE(proto_tree *uiuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
1216 {
1217     /* UL-MAP Extended IE = 4 */
1218     /* 8.4.5.4.7 [2] UL_Zone_IE */
1219     /* offset of TLV in nibbles, length of TLV in nibbles */
1220     gint bit;
1221     gint data;
1222     proto_item *ti = NULL;
1223     proto_item *tree = NULL;
1224
1225     bit = NIB_TO_BIT(offset);
1226
1227     ti = proto_tree_add_text(uiuc_tree, tvb, NIBHI(offset, length), "UL_ZONE_IE");
1228     tree = proto_item_add_subtree(ti, ett_294);
1229
1230     XBIT(data, 4, "Extended UIUC");
1231     XBIT(data, 4, "Length");
1232
1233     XBIT(data, 7, "OFDMA symbol offset");
1234     XBIT(data, 2, "Permutation");
1235     XBIT(data, 7, "UL_PermBase");
1236     XBIT(data, 2, "AMC type");
1237     XBIT(data, 1, "Use All SC indicator");
1238     XBIT(data, 1, "Disable subchannel rotation");
1239     XBIT(data, 4, "Reserved");
1240     return BIT_TO_NIB(bit);
1241 }
1242
1243 gint PHYMOD_UL_IE(proto_tree *uiuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
1244 {
1245     /* UL-MAP Extended IE = 5 */
1246     /* 8.4.5.4.14 [2] PHYMOD_UL_IE */
1247     /* offset of TLV in nibbles, length of TLV in nibbles */
1248     gint bit;
1249     gint data;
1250     proto_item *ti = NULL;
1251     proto_item *tree = NULL;
1252     gint pmt;
1253
1254     bit = NIB_TO_BIT(offset);
1255
1256     ti = proto_tree_add_text(uiuc_tree, tvb, NIBHI(offset, length), "PHYMOD_UL_IE");
1257     tree = proto_item_add_subtree(ti, ett_302);
1258
1259     XBIT(data, 4, "Extended UIUC");
1260     XBIT(data, 4, "Length");
1261
1262     XBIT(pmt, 1, "Preamble Modifier Type");
1263     if (pmt == 0) {
1264         XBIT(data, 4, "Preamble frequency shift index");
1265     } else {
1266         XBIT(data, 4, "Preamble Time Shift index");
1267     }
1268     XBIT(data, 1, "Pilot Pattern Modifier");
1269     XBIT(data, 2, "Pilot Pattern Index");
1270     return BIT_TO_NIB(bit);
1271 }
1272
1273 gint MIMO_UL_IE(proto_tree *uiuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
1274 {
1275     /* UL-MAP Extended IE = 6 */
1276     /* 8.4.5.4.11 MIMO_UL_Basic_IE (not implemented) */
1277     /* offset of TLV in nibbles, length of TLV in nibbles */
1278     gint nib;
1279     gint data;
1280     proto_item *ti = NULL;
1281     proto_item *tree = NULL;
1282
1283     nib = offset;
1284
1285     ti = proto_tree_add_text(uiuc_tree, tvb, NIBHI(offset, length), "MIMO_UL_Basic_IE");
1286     tree = proto_item_add_subtree(ti, ett_299);
1287
1288     XNIB(data, 1, "Extended UIUC");
1289     XNIB(data, 1, "Length");
1290     proto_tree_add_text(tree, tvb, NIBHI(nib,length-2), "(not implemented)");
1291     return nib;
1292 }
1293
1294 gint ULMAP_Fast_Tracking_IE(proto_tree *uiuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
1295 {
1296     /* UL-MAP Extended IE = 7 */
1297     /* 8.4.5.4.22 [2] ULMAP_Fast_Tracking_IE */
1298     /* offset of TLV in nibbles, length of TLV in nibbles */
1299     gint bit;
1300     gint data;
1301     proto_item *ti = NULL;
1302     proto_item *tree = NULL;
1303
1304     bit = NIB_TO_BIT(offset);
1305
1306     ti = proto_tree_add_text(uiuc_tree, tvb, NIBHI(offset, length), "Fast_Tracking_IE");
1307     tree = proto_item_add_subtree(ti, ett_302h);
1308
1309     length = NIB_TO_BIT(length);
1310
1311     XBIT(data, 4, "Extended UIUC");
1312     XBIT(data, 4, "Length");
1313
1314     XBIT(data, 2, "Map Index");
1315     XBIT(data, 6, "Reserved");
1316     while (bit < (length-7)) {
1317         XBIT(data, 3, "Power correction");
1318         XBIT(data, 3, "Frequency correction");
1319         XBIT(data, 2, "Time correction");
1320     }
1321     return BIT_TO_NIB(bit);
1322 }
1323
1324 gint UL_PUSC_Burst_Allocation_in_other_segment_IE(proto_tree *uiuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
1325 {
1326     /* UL-MAP Extended IE = 8 */
1327     /* 8.4.5.4.17 [2] UL_PUSC_Burst_Allocation_in_other_segment_IE */
1328     /* offset of TLV in nibbles, length of TLV in nibbles */
1329     gint bit;
1330     gint data;
1331     proto_item *ti = NULL;
1332     proto_item *tree = NULL;
1333
1334     bit = NIB_TO_BIT(offset);
1335
1336     ti = proto_tree_add_text(uiuc_tree, tvb, NIBHI(offset, length), "UL_PUSC_Burst_Allocation_in_Other_Segment_IE");
1337     tree = proto_item_add_subtree(ti, ett_302c);
1338
1339     XBIT(data, 4, "Extended UIUC");
1340     XBIT(data, 4, "Length");
1341
1342     XBIT(data, 4, "UIUC");
1343     XBIT(data, 2, "Segment");
1344     XBIT(data, 7, "UL_PermBase");
1345     XBIT(data, 8, "OFDMA symbol offset");
1346     XBIT(data, 6, "Subchannel offset");
1347     XBIT(data,10, "Duration");
1348     XBIT(data, 2, "Repetition coding indication");
1349     XBIT(data, 1, "Reserved");
1350     return BIT_TO_NIB(bit);
1351 }
1352
1353 gint Fast_Ranging_IE(proto_tree *uiuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
1354 {
1355     /* UL-MAP Extended IE = 9 */
1356     /* 8.4.5.4.21 [2] Fast_Ranging_IE */
1357     /* offset of TLV in nibbles, length of TLV in nibbles */
1358     gint bit;
1359     gint data;
1360     proto_item *ti = NULL;
1361     proto_item *tree = NULL;
1362     gint hidi;
1363
1364     bit = NIB_TO_BIT(offset);
1365
1366     ti = proto_tree_add_text(uiuc_tree, tvb, NIBHI(offset, length), "Fast_Ranging_IE");
1367     tree = proto_item_add_subtree(ti, ett_302g);
1368
1369     XBIT(data, 4, "Extended UIUC");
1370     XBIT(data, 4, "Length");
1371
1372     XBIT(hidi, 1, "HO_ID indicator");
1373     XBIT(data, 7, "Reserved");
1374     if (hidi == 1) {
1375         XBIT(data,  8, "HO_ID");
1376         /* XBIT(data, 40, "Reserved"); TODO */
1377     } else {
1378         /* XBIT(data, 48, "MAC address"); TODO */
1379         proto_tree_add_text(tree, tvb, BITHI(bit, 48), "MAC address");
1380         bit += 48;
1381     }
1382     XBIT(data, 4, "UIUC");
1383     XBIT(data,10, "Duration");
1384     XBIT(data, 2, "Repetition coding indication");
1385     return BIT_TO_NIB(bit);
1386 }
1387
1388 gint UL_Allocation_Start_IE(proto_tree *uiuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
1389 {
1390     /* UL-MAP Extended IE = 0xA */
1391     /* 8.4.5.4.15 [2] UL_Allocation_Start_IE */
1392     /* offset of TLV in nibbles, length of TLV in nibbles */
1393     gint bit;
1394     gint data;
1395     proto_item *ti = NULL;
1396     proto_item *tree = NULL;
1397
1398     bit = NIB_TO_BIT(offset);
1399
1400     ti = proto_tree_add_text(uiuc_tree, tvb, NIBHI(offset, length), "UL_Allocation_start_IE");
1401     tree = proto_item_add_subtree(ti, ett_302a);
1402
1403     XBIT(data, 4, "Extended UIUC");
1404     XBIT(data, 4, "Length");
1405
1406     XBIT(data, 8, "OFDMA symbol offset");
1407     XBIT(data, 7, "Subchannel offset");
1408     XBIT(data, 1, "Reserved");
1409     return BIT_TO_NIB(bit);
1410 }
1411
1412
1413 /********************************************************************
1414  * UL-MAP Extended-2 IEs
1415  * table 290c
1416  *******************************************************************/
1417
1418 gint CQICH_Enhanced_Allocation_IE(proto_tree *uiuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
1419 {
1420     /* UL-MAP Extended-2 IE = 0 */
1421     /* 8.4.5.4.16 [2] CQICH_Enhanced_Allocation_IE */
1422     /* offset of TLV in nibbles, length of TLV in nibbles */
1423     gint bit;
1424     gint data;
1425     proto_item *ti = NULL;
1426     proto_item *tree = NULL;
1427     gint i, cnum, bapm;
1428     guint pad;
1429
1430     bit = NIB_TO_BIT(offset);
1431
1432     ti = proto_tree_add_text(uiuc_tree, tvb, NIBHI(offset, length), "CQICH_Enhanced_Alloc_IE");
1433     tree = proto_item_add_subtree(ti, ett_302b);
1434
1435     XBIT(data, 4, "Extended-2 UIUC");
1436     XBIT(data, 8, "Length");
1437
1438     if (cqich_id_size == 0) {
1439         proto_tree_add_text(tree, tvb, BITHI(bit, 1), "CQICH_ID: n/a (size == 0 bits)");
1440     } else {
1441         /* variable from 0-9 bits */
1442         data = BIT_BITS16(bit, bufptr, cqich_id_size);
1443         proto_tree_add_text(tree, tvb, BITHI(bit, cqich_id_size), "CQICH_ID: %d (%d bits)", data, cqich_id_size);
1444         bit += cqich_id_size;
1445     }
1446
1447     XBIT(data, 3, "Period (p)");
1448     XBIT(data, 3, "Frame offset");
1449     XBIT(data, 3, "Duration (d)");
1450     XBIT(cnum, 4, "CQICH_Num");
1451     cnum += 1;
1452     for (i = 0; i < cnum; i++) {
1453         XBIT(data, 3, "Feedback Type");
1454         XBIT(data, 6, "Allocation Index");
1455         XBIT(data, 3, "CQICH Type");
1456         XBIT(data, 1, "STTD indication");
1457     }
1458     XBIT(bapm, 1, "Band_AMC_Precoding_Mode");
1459     if (bapm == 1) {
1460         XBIT(data, 3, "Nr_Precoders_Feedback (=N)");
1461     }
1462
1463     pad = BIT_PADDING(bit,8);
1464     if (pad) {
1465         proto_tree_add_text(tree, tvb, BITHI(bit, pad), "Padding: %d bits", pad);
1466         bit += pad;
1467     }
1468     return BIT_TO_NIB(bit);
1469 }
1470
1471 gint HO_Anchor_Active_UL_MAP_IE(proto_tree *uiuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
1472 {
1473     /* UL-MAP Extended-2 IE = 1 */
1474     /* 8.4.5.4.18 [2] HO_Anchor_Active_UL_MAP_IE (not implemented) */
1475     /* offset of TLV in nibbles, length of TLV in nibbles */
1476     gint nib;
1477     gint data;
1478     proto_item *ti = NULL;
1479     proto_item *tree = NULL;
1480
1481     nib = offset;
1482
1483     ti = proto_tree_add_text(uiuc_tree, tvb, NIBHI(offset, length), "HO_Anchor_Active_UL_MAP_IE");
1484     tree = proto_item_add_subtree(ti, ett_302d);
1485
1486     XNIB(data, 1, "Extended-2 UIUC");
1487     XNIB(data, 2, "Length");
1488     proto_tree_add_text(tree, tvb, NIBHI(nib,length-3), "(not implemented)");
1489     return nib;
1490 }
1491
1492 gint HO_Active_Anchor_UL_MAP_IE(proto_tree *uiuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
1493 {
1494     /* UL-MAP Extended-2 IE = 2 */
1495     /* 8.4.5.4.19 [2] HO_Active_Anchor_UL_MAP_IE (not implemented) */
1496     /* offset of TLV in nibbles, length of TLV in nibbles */
1497     gint nib;
1498     gint data;
1499     proto_item *ti = NULL;
1500     proto_item *tree = NULL;
1501
1502     nib = offset;
1503
1504     ti = proto_tree_add_text(uiuc_tree, tvb, NIBHI(offset, length), "HO_Active_Anchor_UL_MAP_IE");
1505     tree = proto_item_add_subtree(ti, ett_302e);
1506
1507     XNIB(data, 1, "Extended-2 UIUC");
1508     XNIB(data, 2, "Length");
1509     proto_tree_add_text(tree, tvb, NIBHI(nib,length-3), "(not implemented)");
1510     return nib;
1511 }
1512
1513 gint Anchor_BS_switch_IE(proto_tree *uiuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
1514 {
1515     /* UL-MAP Extended-2 IE = 3 */
1516     /* 8.4.5.4.23 [2] Anchor_BS_switch_IE */
1517     /* offset of TLV in nibbles, length of TLV in nibbles */
1518     gint bit;
1519     gint data;
1520     proto_item *ti = NULL;
1521     proto_item *tree = NULL;
1522     gint nbss, acod, cqai, pad;
1523     gint i;
1524
1525     bit = NIB_TO_BIT(offset);
1526
1527     ti = proto_tree_add_text(uiuc_tree, tvb, NIBHI(offset, length), "Anchor_BS_switch_IE");
1528     tree = proto_item_add_subtree(ti, ett_302i);
1529
1530     XBIT(data, 4, "Extended-2 UIUC");
1531     XBIT(data, 8, "Length");
1532
1533     XBIT(nbss, 4, "N_Anchor_BS_switch");
1534     for (i = 0; i < nbss; i++) {
1535         XBIT(data,12, "Reduced CID");
1536         XBIT(acod, 2, "Action Code");
1537         if (acod == 1) {
1538             XBIT(data, 3, "Action Time (A)");
1539             XBIT(data, 3, "TEMP_BS_ID");
1540             XBIT(data, 2, "Reserved");
1541         }
1542         if (acod == 0 || acod == 1) {
1543             XBIT(data, 1, "AK Change Indicator");
1544             XBIT(cqai, 1, "CQICH Allocation Indicator");
1545             if (cqai == 1) {
1546                 /* variable bits from 0-9 */
1547                 if (cqich_id_size == 0) {
1548                     proto_tree_add_text(tree, tvb, BITHI(bit, 1), "CQICH_ID: n/a (size == 0 bits)");
1549                 } else {
1550                     data = BIT_BITS16(bit, bufptr, cqich_id_size);
1551                     proto_tree_add_text(tree, tvb, BITHI(bit, cqich_id_size),
1552                         "CQICH_ID: %d (%d bits)", data, cqich_id_size);
1553                     bit += cqich_id_size;
1554                 }
1555                 XBIT(data, 6, "Feedback channel offset");
1556                 XBIT(data, 2, "Period (=p)");
1557                 XBIT(data, 3, "Frame offset");
1558                 XBIT(data, 3, "Duration (=d)");
1559                 XBIT(data, 2, "MIMO_permutation_feedback_code");
1560                 pad = BIT_PADDING(bit,8);
1561                 if (pad) {
1562                     proto_tree_add_text(tree, tvb, BITHI(bit,pad), "Reserved: %d bits", pad);
1563                 }
1564             }
1565         } else {
1566             XBIT(data, 2, "Reserved");
1567         }
1568     }
1569     XBIT(data, 4, "Reserved");
1570     return BIT_TO_NIB(bit);
1571 }
1572
1573 gint UL_sounding_command_IE(proto_tree *uiuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
1574 {
1575     /* UL-MAP Extended-2 IE = 4 */
1576     /* 8.4.5.4.26 [2] UL_sounding_command_IE */
1577     /* see 8.4.6.2.7.1 */
1578     /* offset of TLV in nibbles, length of TLV in nibbles */
1579     gint bit;
1580     gint data;
1581     proto_item *ti = NULL;
1582     proto_item *tree = NULL;
1583     gint stype, ssrf, srlf, iafb, pad, sept, nssym, ncid, amod;
1584     gint i, j;
1585
1586     bit = NIB_TO_BIT(offset);
1587
1588     ti = proto_tree_add_text(uiuc_tree, tvb, NIBHI(offset, length), "UL_Sounding_Command_IE");
1589     tree = proto_item_add_subtree(ti, ett_315d);
1590
1591     XBIT(data, 4, "Extended-2 UIUC");
1592     XBIT(data, 8, "Length");
1593
1594     XBIT(stype, 1, "Sounding_Type");
1595     XBIT(ssrf, 1, "Send Sounding Report Flag");
1596     XBIT(srlf, 1, "Sounding Relevance Flag");
1597     if (srlf == 0) {
1598         XBIT(data, 1, "Sounding_Relevance");
1599         XBIT(data, 2, "Reserved");
1600     } else {
1601         XBIT(data, 3, "Reserved");
1602     }
1603     XBIT(iafb, 2, "Include additional feedback");
1604     if (stype == 0) {
1605         XBIT(nssym, 3, "Num_Sounding_Symbols");
1606         XBIT(data, 1, "Reserved");
1607         for (i = 0; i < nssym; i++) {
1608             XBIT(sept, 1, "Separability Type");
1609             if (sept == 0) {
1610                 XBIT(data, 3, "Max Cyclic Shift Index P");
1611                 XBIT(data, 1, "Reserved");
1612             } else {
1613                 XBIT(data, 3, "Decimation Value D");
1614                 XBIT(data, 1, "Decimation offset randomization");
1615             }
1616             XBIT(data, 3, "Sounding symbol index");
1617             XBIT(ncid, 7, "Number of CIDs");
1618             XBIT(data, 1, "Reserved");
1619             for (j = 0; j < ncid; j++) {
1620                 XBIT(data,12, "Shorted Basic CID");
1621                 XBIT(data, 2, "Power Assignment Method");
1622                 XBIT(data, 1, "Power boost");
1623                 XBIT(data, 1, "Multi-Antenna Flag");
1624                 XBIT(amod, 1, "Allocation Mode");
1625                 if (amod == 1) {
1626                     XBIT(data,12, "Band bit map");
1627                     XBIT(data, 2, "Reserved");
1628                 } else {
1629                     XBIT(data, 7, "Starting frequency band");
1630                     XBIT(data, 7, "Number of frequency bands");
1631                 }
1632                 if (srlf == 1) {
1633                     XBIT(data, 1, "Sounding_Relevance");
1634                 } else {
1635                     XBIT(data, 1, "Reserved");
1636                 }
1637                 if (sept == 0) {
1638                     XBIT(data, 5, "Cyclic time shift index m");
1639                 } else {
1640                     XBIT(data, 6, "Decimation offset d");
1641                     if (iafb == 1) {
1642                         XBIT(data, 1, "Use same symbol for additional feedback");
1643                         XBIT(data, 2, "Reserved");
1644                     } else {
1645                         XBIT(data, 3, "Reserved");
1646                     }
1647                 }
1648                 XBIT(data, 3, "Periodicity");
1649             }
1650         }
1651     } else {
1652         XBIT(data, 3, "Permutation");
1653         XBIT(data, 6, "DL_PermBase");
1654         XBIT(nssym, 3, "Num_Sounding_symbols");
1655         for (i = 0; i < nssym; i++) {
1656             XBIT(ncid, 7, "Number of CIDs");
1657             XBIT(data, 1, "Reserved");
1658             for (j = 0; j < ncid; j++) {
1659                 XBIT(data, 12, "Shortened basic CID");
1660                 if (srlf) {
1661                     XBIT(data, 1, "Sounding_Relevance");
1662                     XBIT(data, 3, "Reserved");
1663                 }
1664                 XBIT(data, 7, "Subchannel offset");
1665                 XBIT(data, 1, "Power boost");
1666                 XBIT(data, 3, "Number of subchannels");
1667                 XBIT(data, 3, "Periodicity");
1668                 XBIT(data, 2, "Power assignment method");
1669             }
1670         }
1671     }
1672     pad = BIT_PADDING(bit,8);
1673     if (pad) {
1674         proto_tree_add_text(tree, tvb, BITHI(bit,pad), "Padding: %d bits",pad);
1675         bit += pad;
1676     }
1677     return BIT_TO_NIB(bit);
1678 }
1679
1680 gint MIMO_UL_Enhanced_IE(proto_tree *uiuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
1681 {
1682     /* UL-MAP Extended-2 IE = 6 */
1683     /* 8.4.5.4.20 [2] MIMO_UL_Enhanced_IE (not implemented) */
1684     /* offset of TLV in nibbles, length of TLV in nibbles */
1685     gint nib;
1686     gint data;
1687     proto_item *ti = NULL;
1688     proto_item *tree = NULL;
1689
1690     nib = offset;
1691
1692     ti = proto_tree_add_text(uiuc_tree, tvb, NIBHI(offset, length), "MIMO_UL_Enhanced_IE");
1693     tree = proto_item_add_subtree(ti, ett_302f);
1694
1695     XNIB(data, 1, "Extended-2 UIUC");
1696     XNIB(data, 2, "Length");
1697     proto_tree_add_text(tree, tvb, NIBHI(nib,length-3), "(not implemented)");
1698     return nib;
1699 }
1700
1701 gint HARQ_ULMAP_IE(proto_tree *uiuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
1702 {
1703     /* UL-MAP Extended-2 IE = 7 */
1704     /* 8.4.5.4.24 HARQ_ULMAP_IE */
1705     /* offset of TLV in nibbles, length of TLV in nibbles */
1706     gint bit;
1707     gint data;
1708     proto_item *ti = NULL;
1709     proto_item *tree = NULL;
1710     gint bitlength;
1711     gint lastbit;
1712     gint pad, mode, alsi, nsub;
1713     gint i;
1714
1715     bit = NIB_TO_BIT(offset);
1716     bitlength = NIB_TO_BIT(length);
1717
1718     ti = proto_tree_add_text(uiuc_tree, tvb, NIBHI(offset, length), "HARQ_ULMAP_IE");
1719     tree = proto_item_add_subtree(ti, ett_302j);
1720
1721     XBIT(data, 4, "Extended-2 UIUC");
1722     XBIT(data, 8, "Length");
1723
1724     XBIT(RCID_Type, 2, "RCID_Type");
1725     XBIT(data, 2, "Reserved");
1726     lastbit = bit + bitlength -16 - 4;
1727     while (bit < lastbit) {
1728         XBIT(mode, 3, "Mode");
1729         XBIT(alsi, 1, "Allocation Start Indication");
1730         if (alsi == 1) {
1731             XBIT(data, 8, "OFDMA Symbol offset");
1732             XBIT(data, 7, "Subchannel offset");
1733             XBIT(data, 1, "Reserved");
1734         }
1735         XBIT(nsub, 4, "N sub Burst");
1736         for (i = 0; i < nsub; i++) {
1737             if (mode == 0) {
1738                 bit += UL_HARQ_Chase_Sub_Burst_IE(tree, bufptr, bit, bitlength, tvb);
1739             } else if (mode == 1) {
1740                bit +=  UL_HARQ_IR_CTC_Sub_Burst_IE(tree, bufptr, bit, bitlength, tvb);
1741             } else if (mode == 2) {
1742                 bit += UL_HARQ_IR_CC_Sub_Burst_IE(tree, bufptr, bit, bitlength, tvb);
1743             } else if (mode == 3) {
1744                 bit += MIMO_UL_Chase_HARQ_Sub_Burst_IE(tree, bufptr, bit, bitlength, tvb);
1745             } else if (mode == 4) {
1746                 bit += MIMO_UL_IR_HARQ__Sub_Burst_IE(tree, bufptr, bit, bitlength, tvb);
1747             } else if (mode == 5) {
1748                 bit += MIMO_UL_IR_HARQ_for_CC_Sub_Burst_UIE(tree, bufptr, bit, bitlength, tvb);
1749             } else if (mode == 6) {
1750                 bit += MIMO_UL_STC_HARQ_Sub_Burst_IE(tree, bufptr, bit, bitlength, tvb);
1751             }
1752         }
1753     }
1754
1755     pad = NIB_TO_BIT(offset) + bitlength - bit;
1756     if (pad) {
1757         proto_tree_add_text(tree, tvb, BITHI(bit,pad), "Padding: %d bits",pad);
1758         bit += pad;
1759     }
1760     return BIT_TO_NIB(bit);
1761 }
1762
1763 gint HARQ_ACKCH_Region_Allocation_IE(proto_tree *uiuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
1764 {
1765     /* UL-MAP Extended-2 IE = 8 */
1766     /* 8.4.5.4.25 [2] HARQ_ACKCH_Region_Allocation_IE */
1767     /* offset of TLV in nibbles, length of TLV in nibbles */
1768     gint bit;
1769     gint data;
1770     proto_item *ti = NULL;
1771     proto_item *tree = NULL;
1772
1773     bit = NIB_TO_BIT(offset);
1774
1775     ti = proto_tree_add_text(uiuc_tree, tvb, NIBHI(offset, length), "HARQ_ACKCH_Region_IE");
1776     tree = proto_item_add_subtree(ti, ett_302t);
1777
1778     XBIT(data, 4, "Extended-2 UIUC");
1779     XBIT(data, 8, "Length");
1780
1781     XBIT(data, 8, "OFDMA Symbol Offset");
1782     XBIT(data, 7, "Subchannel Offset");
1783     XBIT(data, 5, "No. OFDMA Symbols");
1784     XBIT(data, 4, "No. Subchannels");
1785     return BIT_TO_NIB(bit);
1786 }
1787
1788 gint AAS_SDMA_UL_IE(proto_tree *uiuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
1789 {
1790     /* UL-MAP Extended-2 IE = 0xE */
1791     /* 8.4.5.4.27 [2] AAS_SDMA_UL_IE  */
1792     /* offset of TLV in nibbles, length of TLV in nibbles */
1793     gint bit;
1794     gint data;
1795     proto_item *ti = NULL;
1796     proto_item *tree = NULL;
1797     gint nreg, pad, user, encm, ppmd, padj;
1798     gint aasp = 0; /* TODO AAS UL preamble used */
1799     gint ii, jj;
1800
1801     bit = NIB_TO_BIT(offset);
1802
1803     ti = proto_tree_add_text(uiuc_tree, tvb, NIBHI(offset, length), "AAS_SDMA_UL_IE");
1804     tree = proto_item_add_subtree(ti, ett_302u);
1805
1806     XBIT(data, 4, "Extended-2 UIUC");
1807     XBIT(data, 8, "Length");
1808
1809     XBIT(RCID_Type, 2, "RCID_Type");
1810     XBIT(nreg, 4, "Num Burst Region");
1811     XBIT(data, 2, "Reserved");
1812     for (ii = 0; ii < nreg; ii++) {
1813         XBIT(data,12, "Slot offset");
1814         XBIT(data,10, "Slot duration");
1815         XBIT(user, 3, "Number of users");
1816         XBIT(data, 3, "Reserved");
1817         for (jj = 0; jj < user; jj++) {
1818             bit += RCID_IE(tree, bufptr, bit, length, tvb, RCID_Type);
1819             XBIT(encm, 2, "Encoding Mode");
1820             XBIT(padj, 1, "Power Adjust");
1821             XBIT(ppmd, 1, "Pilot Pattern Modifier");
1822             if (aasp) {
1823                 XBIT(data, 4, "Preamble Modifier Index");
1824             }
1825             if (ppmd) {
1826                 XBIT(data, 2, "Pilot Pattern");
1827                 XBIT(data, 2, "Reserved");
1828             }
1829             if (encm == 0) {
1830                 XBIT(data, 4, "DIUC");
1831                 XBIT(data, 2, "Repetition Coding Indication");
1832                 XBIT(data, 2, "Reserved");
1833             }
1834             if (encm == 1) {
1835                 XBIT(data, 4, "DIUC");
1836                 XBIT(data, 2, "Repetition Coding Indication");
1837                 XBIT(data, 4, "ACID");
1838                 XBIT(data, 1, "AI_SN");
1839                 XBIT(data, 1, "Reserved");
1840             }
1841             if (encm == 2) {
1842                 XBIT(data, 4, "N(EP)");
1843                 XBIT(data, 4, "N(SCH)");
1844                 XBIT(data, 2, "SPID");
1845                 XBIT(data, 4, "ACID");
1846                 XBIT(data, 1, "AI_SN");
1847                 XBIT(data, 1, "Reserved");
1848             }
1849             if (encm == 3) {
1850                 XBIT(data, 4, "DIUC");
1851                 XBIT(data, 2, "Repetition Coding Indication");
1852                 XBIT(data, 2, "SPID");
1853                 XBIT(data, 4, "ACID");
1854                 XBIT(data, 1, "AI_SN");
1855                 XBIT(data, 3, "Reserved");
1856             }
1857             if (padj) {
1858                 XBIT(data, 8, "Power Adjustment");
1859
1860             }
1861         }
1862     }
1863
1864     pad = BIT_PADDING(bit,8);
1865     if (pad) {
1866         proto_tree_add_text(tree, tvb, BITHI(bit, pad), "Padding: %d bits", pad);
1867         bit += pad;
1868     }
1869     return BIT_TO_NIB(bit);
1870 }
1871
1872 gint Feedback_Polling_IE(proto_tree *uiuc_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
1873 {
1874     /* UL-MAP Extended-2 IE = 0xF */
1875     /* 8.4.5.4.28 [2] Feedback_Polling_IE */
1876     /* offset of TLV in nibbles, length of TLV in nibbles */
1877     gint bit;
1878     gint data;
1879     proto_item *ti = NULL;
1880     proto_item *tree = NULL;
1881     gint nalloc, dula, pad, adur;
1882     gint i;
1883
1884     bit = NIB_TO_BIT(offset);
1885
1886     ti = proto_tree_add_text(uiuc_tree, tvb, NIBHI(offset, length), "Feedback_Polling_IE");
1887     tree = proto_item_add_subtree(ti, ett_302v);
1888
1889     XBIT(data, 4, "Extended-2 UIUC");
1890     XBIT(data, 8, "Length");
1891
1892     XBIT(nalloc, 4, "Num_Allocation");
1893     XBIT(dula, 1, "Dedicated UL Allocation included");
1894     XBIT(data, 3, "Reserved");
1895     for (i = 0; i < nalloc; i++) {
1896         XBIT(data,16, "Basic CID");
1897         XBIT(adur, 3, "Allocation Duration (d)");
1898         if (adur != 0) {
1899             XBIT(data, 4, "Feedback type");
1900             XBIT(data, 3, "Frame Offset");
1901             XBIT(data, 2, "Period (p)");
1902             if (dula == 1) {
1903                 XBIT(data, 4, "UIUC");
1904                 XBIT(data, 8, "OFDMA Symbol Offset");
1905                 XBIT(data, 7, "Subchannel offset");
1906                 XBIT(data, 3, "Duration");
1907                 XBIT(data, 2, "Repetition coding indication");
1908             }
1909         }
1910     }
1911     pad = BIT_PADDING(bit,8);
1912     if (pad) {
1913         proto_tree_add_text(tree, tvb, BITHI(bit, pad), "Padding: %d bits", pad);
1914         bit += pad;
1915     }
1916     return BIT_TO_NIB(bit);
1917 }
1918
1919
1920 /********************************************************************
1921  * UL-MAP Miscellany
1922  *******************************************************************/
1923
1924
1925 void lshift_bits(guint8 *buffer, gint bytes, gint bits)
1926 {
1927     /* left shift a buffer by specified number of bits */
1928     /* used for ULMAP ExtIE CQICH alloc IE */
1929     gint i;
1930     gint xbits;
1931
1932     while (bits >= 8) {
1933         for (i=1; i<bytes; i++)
1934             buffer[i-1] = buffer[i];
1935         bits -= 8;
1936         bytes--;
1937     }
1938     if (bits > 0)
1939     {
1940         xbits = 8 - bits;
1941         for (i = 0; i < (bytes-1); i++) {
1942             buffer[i] <<= bits;
1943             buffer[i] |= (buffer[i+1] >> xbits);
1944         }
1945         buffer[bytes-1] <<= bits;
1946     }
1947 }
1948
1949
1950 /* Register Wimax Mac Payload Protocol and Dissector */
1951 void proto_register_mac_mgmt_msg_ulmap(void)
1952 {
1953     if (proto_mac_mgmt_msg_ulmap_decoder == -1)
1954     {
1955         proto_mac_mgmt_msg_ulmap_decoder = proto_mac_mgmt_msg_dlmap_decoder;
1956
1957         proto_register_field_array(proto_mac_mgmt_msg_ulmap_decoder, hf, array_length(hf));
1958         proto_register_subtree_array(ett, array_length(ett));
1959     }
1960 }
1961
1962
1963 gint dissect_ulmap_ie( proto_tree *ie_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
1964 {
1965     /* decode a single UL-MAP IE and return the
1966      * length of the IE in nibbles
1967      * offset = start of IE (nibbles)
1968      * length = total length of bufptr (nibbles) */
1969     proto_item *ti = NULL;
1970     proto_tree *tree = NULL;
1971     gint nibble;
1972     gint uiuc, ext_uiuc, ext2_uiuc, len, aas_or_amc;
1973     guint cid;
1974     guint data;
1975     guint32 data32;
1976
1977     nibble = offset;
1978
1979     UNREFERENCED_PARAMETER(length);
1980
1981     /* 8.4.5.4 UL-MAP IE format - table 287 */
1982     cid = NIB_WORD(nibble, bufptr);
1983     uiuc = NIB_NIBBLE(nibble + 4, bufptr);
1984
1985     if (uiuc == 0)
1986     {
1987         /* 8.4.5.4.9 FAST-FEEDBACK channel */
1988         ti = proto_tree_add_text(ie_tree, tvb, NIBHI(nibble, 5+8), "FAST FEEDBACK Allocation IE");
1989         tree = proto_item_add_subtree(ti, ett_ulmap_ffb);
1990
1991         proto_tree_add_uint(tree, hf_ulmap_ie_cid, tvb, NIBHI(nibble, 4), cid);
1992         nibble += 4;
1993         proto_tree_add_uint(tree, hf_ulmap_ie_uiuc, tvb, NIBHI(nibble, 1), uiuc);
1994         nibble += 1;
1995
1996         data = NIB_LONG(nibble, bufptr);
1997         proto_tree_add_uint(tree, hf_ulmap_uiuc0_symofs, tvb, NIBHI(nibble, 8), data);
1998         proto_tree_add_uint(tree, hf_ulmap_uiuc0_subofs, tvb, NIBHI(nibble, 8), data);
1999         proto_tree_add_uint(tree, hf_ulmap_uiuc0_numsym, tvb, NIBHI(nibble, 8), data);
2000         proto_tree_add_uint(tree, hf_ulmap_uiuc0_numsub, tvb, NIBHI(nibble, 8), data);
2001         proto_tree_add_uint(tree, hf_ulmap_uiuc0_rsv,    tvb, NIBHI(nibble, 8), data);
2002         nibble += 8;
2003     }
2004     else if (uiuc == 11)
2005     {
2006         /* 8.4.5.4.4.2 [2] extended-2 UIUC IE table 290b */
2007         ext2_uiuc = NIB_NIBBLE(5+nibble, bufptr);
2008         len = NIB_BYTE(5+nibble+1, bufptr);
2009
2010         ti = proto_tree_add_text(ie_tree, tvb, NIBHI(nibble, 5+3+len*2), "UIUC: %d (Extended-2 IE)", uiuc);
2011         tree = proto_item_add_subtree(ti, ett_290b);
2012
2013         proto_tree_add_uint(tree, hf_ulmap_ie_cid, tvb, NIBHI(nibble, 4), cid);
2014         nibble += 4;
2015         proto_tree_add_uint(tree, hf_ulmap_ie_uiuc, tvb, NIBHI(nibble, 1), uiuc);
2016         nibble += 1;
2017
2018         /*
2019         proto_tree_add_uint(tree, hf_ulmap_uiuc11_ext, tvb, NIBHI(nibble, 1), ext2_uiuc);
2020         nibble += 1;
2021         proto_tree_add_uint(tree, hf_ulmap_uiuc11_len, tvb, NIBHI(nibble, 2), len);
2022         nibble += 2;
2023         */
2024
2025         len = 4 + BYTE_TO_NIB(len); /* length in nibbles */
2026
2027         /* data table 290c 8.4.5.4.4.2 */
2028         switch (ext2_uiuc) {
2029             case 0x00:
2030                 /* 8.4.5.4.16 CQICH_Enhanced_Allocation_IE */
2031                 nibble = CQICH_Enhanced_Allocation_IE(tree, bufptr, nibble, len, tvb);
2032                 break;
2033             case 0x01:
2034                 /* 8.4.5.4.18 HO_Anchor_Active_UL_MAP_IE */
2035                 nibble = HO_Anchor_Active_UL_MAP_IE(tree, bufptr, nibble, len, tvb);
2036                 break;
2037             case 0x02:
2038                 /* 8.4.5.4.19 HO_Active_Anchor_UL_MAP_IE */
2039                 nibble = HO_Active_Anchor_UL_MAP_IE(tree, bufptr, nibble, len, tvb);
2040                 break;
2041             case 0x03:
2042                 /* 8.4.5.4.23 Anchor_BS_switch_IE */
2043                 nibble = Anchor_BS_switch_IE(tree, bufptr, nibble, len, tvb);
2044                 break;
2045             case 0x04:
2046                 /* 8.4.5.4.26 UL_sounding_command_IE */
2047                 nibble = UL_sounding_command_IE(tree, bufptr, nibble, len, tvb);
2048                 break;
2049             case 0x06:
2050                 /* 8.4.5.4.20 MIMO_UL_Enhanced_IE */
2051                 nibble = MIMO_UL_Enhanced_IE(tree, bufptr, nibble, len, tvb);
2052                 break;
2053             case 0x07:
2054                 /* 8.4.5.4.24 HARQ_ULMAP_IE */
2055                 nibble = HARQ_ULMAP_IE(tree, bufptr, nibble, len, tvb);
2056                 break;
2057             case 0x08:
2058                 /* 8.4.5.4.25 HARQ_ACKCH_Region_Allocation_IE */
2059                 nibble = HARQ_ACKCH_Region_Allocation_IE(tree, bufptr, nibble, len, tvb);
2060                 break;
2061             case 0x0e:
2062                 /* 8.4.5.4.27 AAS_SDMA_UL_IE */
2063                 nibble = AAS_SDMA_UL_IE(tree, bufptr, nibble, len, tvb);
2064                 break;
2065             case 0x0f:
2066                 /* 8.4.5.4.28 Feedback_Polling_IE */
2067                 nibble = Feedback_Polling_IE(tree, bufptr, nibble, len, tvb);
2068                 break;
2069
2070             default:
2071                 proto_tree_add_text(tree, tvb, NIBHI(nibble, len), "(reserved Extended-2 UIUC: %d)", ext2_uiuc);
2072                 nibble += len;
2073                 break;
2074
2075         }
2076     }
2077     else if (uiuc == 12)
2078     {
2079         /* 8.4.5.4 [2] CDMA bandwidth request, CDMA ranging */
2080         ti = proto_tree_add_text(ie_tree, tvb, NIBHI(nibble, 5+8), "CDMA Bandwidth/Ranging Request IE");
2081         tree = proto_item_add_subtree(ti, ett_287_1);
2082
2083         proto_tree_add_uint(tree, hf_ulmap_ie_cid, tvb, NIBHI(nibble, 4), cid);
2084         nibble += 4;
2085         proto_tree_add_uint(tree, hf_ulmap_ie_uiuc, tvb, NIBHI(nibble, 1), uiuc);
2086         nibble += 1;
2087
2088         data32 = NIB_LONG(nibble, bufptr);
2089         proto_tree_add_uint(tree, hf_ulmap_uiuc12_symofs, tvb, NIBHI(nibble,8), data32);
2090         proto_tree_add_uint(tree, hf_ulmap_uiuc12_subofs, tvb, NIBHI(nibble,8), data32);
2091         proto_tree_add_uint(tree, hf_ulmap_uiuc12_numsym, tvb, NIBHI(nibble,8), data32);
2092         proto_tree_add_uint(tree, hf_ulmap_uiuc12_numsub, tvb, NIBHI(nibble,8), data32);
2093         proto_tree_add_uint(tree, hf_ulmap_uiuc12_method, tvb, NIBHI(nibble,8), data32);
2094         proto_tree_add_uint(tree, hf_ulmap_uiuc12_dri,    tvb, NIBHI(nibble,8), data32);
2095         nibble += 8;
2096     }
2097     else if (uiuc == 13)
2098     {
2099         /* 8.4.5.4.2 [2] PAPR reduction allocation, safety zone - table 289 */
2100         ti = proto_tree_add_text(ie_tree, tvb, NIBHI(nibble,5+8), "PAPR/Safety/Sounding Zone IE");
2101         tree = proto_item_add_subtree(ti, ett_289);
2102
2103
2104         proto_tree_add_uint(tree, hf_ulmap_ie_cid, tvb, NIBHI(nibble, 4), cid);
2105         nibble += 4;
2106         proto_tree_add_uint(tree, hf_ulmap_ie_uiuc, tvb, NIBHI(nibble, 1), uiuc);
2107         nibble += 1;
2108
2109         data = NIB_LONG(nibble, bufptr);
2110         proto_tree_add_uint(tree, hf_ulmap_uiuc13_symofs, tvb, NIBHI(nibble,8), data);
2111         proto_tree_add_uint(tree, hf_ulmap_uiuc13_subofs, tvb, NIBHI(nibble,8), data);
2112         proto_tree_add_uint(tree, hf_ulmap_uiuc13_numsym, tvb, NIBHI(nibble,8), data);
2113         proto_tree_add_uint(tree, hf_ulmap_uiuc13_numsub, tvb, NIBHI(nibble,8), data);
2114         proto_tree_add_uint(tree, hf_ulmap_uiuc13_papr,   tvb, NIBHI(nibble,8), data);
2115         proto_tree_add_uint(tree, hf_ulmap_uiuc13_zone,   tvb, NIBHI(nibble,8), data);
2116         proto_tree_add_uint(tree, hf_ulmap_uiuc13_rsv,    tvb, NIBHI(nibble,8), data);
2117         nibble += 8;
2118     }
2119     else if (uiuc == 14)
2120     {
2121         /* 8.4.5.4.3 [2] CDMA allocation IE */
2122         ti = proto_tree_add_text(ie_tree, tvb, NIBHI(nibble,5+10), "CDMA allocation IE");
2123         tree = proto_item_add_subtree(ti, ett_290);
2124
2125         proto_tree_add_uint(tree, hf_ulmap_ie_cid, tvb, NIBHI(nibble, 4), cid);
2126         nibble += 4;
2127         proto_tree_add_uint(tree, hf_ulmap_ie_uiuc, tvb, NIBHI(nibble, 1), uiuc);
2128         nibble += 1;
2129
2130         data = NIB_WORD(nibble, bufptr);
2131         proto_tree_add_uint(tree, hf_ulmap_uiuc14_dur,  tvb, NIBHI(nibble,2), data);
2132         proto_tree_add_uint(tree, hf_ulmap_uiuc14_uiuc, tvb, NIBHI(nibble+1,2), data);
2133         proto_tree_add_uint(tree, hf_ulmap_uiuc14_rep,  tvb, NIBHI(nibble+2,1), data);
2134         proto_tree_add_uint(tree, hf_ulmap_uiuc14_idx,  tvb, NIBHI(nibble+3,1), data);
2135         nibble += 4;
2136
2137         data = NIB_BYTE(nibble, bufptr);
2138         proto_tree_add_uint(tree, hf_ulmap_uiuc14_code, tvb, NIBHI(nibble,2), data);
2139         proto_item_append_text(ti, " (0x%02x)", data);
2140         nibble += 2;
2141
2142         data = NIB_BYTE(nibble, bufptr);
2143         proto_tree_add_uint(tree, hf_ulmap_uiuc14_sym,  tvb, NIBHI(nibble,2), data);
2144         proto_item_append_text(ti, " (0x%02x)", data);
2145         nibble += 2;
2146
2147         data = NIB_BYTE(nibble, bufptr);
2148         proto_tree_add_uint(tree, hf_ulmap_uiuc14_sub,  tvb, NIBHI(nibble,2), data);
2149         proto_item_append_text(ti, " (0x%02x)", data >> 1);
2150         proto_tree_add_uint(tree, hf_ulmap_uiuc14_bwr,  tvb, NIBHI(nibble+1,1), data);
2151         nibble += 2;
2152     }
2153     else if (uiuc == 15)
2154     {
2155         /* 8.4.5.4.4 [1] Extended UIUC dependent IE table 291 */
2156         ext_uiuc = NIB_NIBBLE(5+nibble, bufptr);
2157         len = NIB_NIBBLE(5+nibble+1, bufptr);
2158
2159         ti = proto_tree_add_text(ie_tree, tvb, NIBHI(nibble, 5+2+len*2), "UIUC: %d (Extended IE)", uiuc);
2160         tree = proto_item_add_subtree(ti, ett_291);
2161
2162         proto_tree_add_uint(tree, hf_ulmap_ie_cid, tvb, NIBHI(nibble,4), cid);
2163         nibble += 4;
2164         proto_tree_add_uint(tree, hf_ulmap_ie_uiuc, tvb, NIBHI(nibble,1), uiuc);
2165         nibble += 1;
2166
2167         /*
2168         ti = proto_tree_add_uint(tree, hf_ulmap_uiuc11_ext, tvb, NIBHI(nibble,1), ext_uiuc);
2169         nibble += 1;
2170         proto_tree_add_uint(tree, hf_ulmap_uiuc11_len, tvb, NIBHI(nibble,1), len);
2171         nibble += 1;
2172         */
2173
2174         len = 2 + BYTE_TO_NIB(len); /* length in nibbles */
2175
2176         /* data table 290a 8.4.5.4.4.1 */
2177         switch (ext_uiuc) {
2178             case 0x00:
2179                 /* 8.4.5.4.5 Power_Control_IE */
2180                 nibble = Power_Control_IE(tree, bufptr, nibble, len, tvb);
2181                 break;
2182             case 0x01:
2183                 /* 8.4.5.4.8 Mini-Subchannel_allocation_IE*/
2184                 nibble = Mini_Subchannel_allocation_IE(tree, bufptr, nibble, len, tvb);
2185                 break;
2186             case 0x02:
2187                 /* 8.4.5.4.6 AAS_UL_IE*/
2188                 nibble = AAS_UL_IE(tree, bufptr, nibble, len, tvb);
2189                 break;
2190             case 0x03:
2191                 /* 8.4.5.4.12 CQICH_Alloc_IE */
2192                 nibble = CQICH_Alloc_IE(tree, bufptr, nibble, len, tvb);
2193                 break;
2194             case 0x04:
2195                 /* 8.4.5.4.7 UL_Zone_IE */
2196                 nibble = UL_Zone_IE(tree, bufptr, nibble, len, tvb);
2197                 break;
2198             case 0x05:
2199                 /* 8.4.5.4.14 PHYMOD_UL_IE */
2200                 nibble = PHYMOD_UL_IE(tree, bufptr, nibble, len, tvb);
2201                 break;
2202             case 0x06:
2203                 /* 8.4.5.4.11 MIMO_UL_IE */
2204                 nibble = MIMO_UL_IE(tree, bufptr, nibble, len, tvb);
2205                 break;
2206             case 0x07:
2207                 /* 8.4.5.4.22 ULMAP_Fast_Tracking_IE */
2208                 nibble = ULMAP_Fast_Tracking_IE(tree, bufptr, nibble, len, tvb);
2209                 break;
2210             case 0x08:
2211                 /* 8.4.5.4.17 UL_PUSC_Burst_Allocation_in_other_segment_IE */
2212                 nibble = UL_PUSC_Burst_Allocation_in_other_segment_IE(tree, bufptr, nibble, len, tvb);
2213                 break;
2214             case 0x09:
2215                 /* 8.4.5.4.21 Fast_Ranging_IE */
2216                 nibble = Fast_Ranging_IE(tree, bufptr, nibble, len, tvb);
2217                 break;
2218             case 0x0a:
2219                 /* 8.4.5.4.15 UL_Allocation_Start_IE */
2220                 nibble = UL_Allocation_Start_IE(tree, bufptr, nibble, len, tvb);
2221                 break;
2222             default:
2223                 proto_tree_add_text(tree, tvb, NIBHI(nibble,len), "(reserved Extended UIUC: %d)", ext_uiuc);
2224                 nibble += len;
2225                 break;
2226         }
2227     }
2228     else
2229     {
2230         /* 8.4.5.4 [2] regular IE 1-10, data grant burst type */
2231         aas_or_amc = 0; /* TODO */
2232         len = 3;
2233
2234         if (aas_or_amc) len += 3;
2235
2236         ti = proto_tree_add_text(ie_tree, tvb, NIBHI(nibble, 5+len), "Data Grant Burst Profile");
2237         tree = proto_item_add_subtree(ti, ett_287_2);
2238
2239         proto_tree_add_uint(tree, hf_ulmap_ie_cid, tvb, NIBHI(nibble, 4), cid);
2240         nibble += 4;
2241         proto_tree_add_uint(tree, hf_ulmap_ie_uiuc, tvb, NIBHI(nibble, 1), uiuc);
2242         nibble += 1;
2243
2244         data = NIB_WORD(nibble, bufptr);
2245         proto_tree_add_uint(tree, hf_ulmap_uiuc10_dur, tvb, NIBHI(nibble,3), data);
2246         proto_tree_add_uint(tree, hf_ulmap_uiuc10_rep, tvb, NIBHI(nibble+2,1), data);
2247         nibble += 3;
2248
2249         if (aas_or_amc) {
2250             data = NIB_BITS12(nibble, bufptr);
2251             proto_tree_add_text(tree, tvb, NIBHI(nibble,3), "Slot offset: %d", data);
2252             nibble += 3;
2253         }
2254     }
2255
2256     /* length in nibbles */
2257     return (nibble - offset);
2258 }
2259
2260 void dissect_mac_mgmt_msg_ulmap_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2261 {
2262     /* 6.3.2.3.4 [2] UL-MAP table 18 */
2263     guint offset = 0;
2264     guint length;
2265     guint nib, pad;
2266     proto_item *ti         = NULL;
2267     proto_tree *ulmap_tree = NULL;
2268     proto_tree *ie_tree    = NULL;
2269     guint tvb_len;
2270     const guint8 *bufptr;
2271
2272     tvb_len = tvb_reported_length(tvb);
2273     /* XXX This should be removed, and regular tvb accessors should be used instead. */
2274     bufptr = tvb_get_ptr(tvb, offset, tvb_len);
2275
2276     UNREFERENCED_PARAMETER(pinfo);
2277
2278     /* display MAC UL-MAP */
2279     ti = proto_tree_add_protocol_format(tree, proto_mac_mgmt_msg_ulmap_decoder, tvb, offset, tvb_len, "UL-MAP (%u bytes)", tvb_len);
2280     ulmap_tree = proto_item_add_subtree(ti, ett_ulmap);
2281
2282     /* Decode and display the UL-MAP */
2283     proto_tree_add_item(ulmap_tree, hf_ulmap_message_type, tvb, offset, 1, FALSE);
2284     offset++;
2285
2286     proto_tree_add_item(ulmap_tree, hf_ulmap_reserved, tvb, offset, 1, FALSE);
2287     offset++;
2288     proto_tree_add_item(ulmap_tree, hf_ulmap_ucd_count, tvb, offset, 1, FALSE);
2289     offset++;
2290     proto_tree_add_item(ulmap_tree, hf_ulmap_alloc_start_time, tvb, offset, 4, FALSE);
2291     offset += 4;
2292     proto_tree_add_item(ulmap_tree, hf_ulmap_ofdma_sym, tvb, offset, 1, FALSE);
2293     offset++;
2294
2295     /* UL-MAP IEs */
2296     length = tvb_len - offset; /* remaining length in bytes */
2297     ti = proto_tree_add_text(ulmap_tree, tvb, offset, length, "UL-MAP IEs (%u bytes)", length);
2298     ie_tree = proto_item_add_subtree(ti, ett_ulmap_ie);
2299
2300     length = BYTE_TO_NIB(length); /* convert length to nibbles */
2301     nib = BYTE_TO_NIB(offset);
2302     while (nib < ((tvb_len*2)-1)) {
2303         nib += dissect_ulmap_ie(ie_tree, bufptr, nib, tvb_len*2, tvb);
2304     }
2305     pad = NIB_PADDING(nib);
2306     if (pad) {
2307         proto_tree_add_text(ulmap_tree, tvb, NIBHI(nib,1), "Padding nibble");
2308         nib++;
2309     }
2310 }
2311
2312 /*gint wimax_decode_ulmapc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)*/
2313 gint wimax_decode_ulmapc(proto_tree *base_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
2314 {
2315     /* 8.4.5.6.2 [2] Compressed UL-MAP */
2316     /* returns length in nibbles */
2317     gint nib;
2318     guint data;
2319     proto_item *ti = NULL;
2320     proto_tree *tree = NULL;
2321     proto_tree *ie_tree = NULL;
2322
2323     nib = offset;
2324
2325     /* display MAC UL-MAP */
2326     ti = proto_tree_add_protocol_format(base_tree, proto_mac_mgmt_msg_ulmap_decoder, tvb, NIBHI(offset,length), "Compressed UL-MAP");
2327     tree = proto_item_add_subtree(ti, ett_306);
2328
2329     /* Decode and display the UL-MAP */
2330     data = NIB_BYTE(nib, bufptr);
2331     proto_tree_add_uint(tree, hf_ulmap_ucd_count, tvb, NIBHI(nib,2), data);
2332     nib += 2;
2333     data = NIB_LONG(nib, bufptr);
2334     proto_tree_add_uint(tree, hf_ulmap_alloc_start_time, tvb, NIBHI(nib,8), data);
2335     nib += 8;
2336     data = NIB_BYTE(nib, bufptr);
2337     proto_tree_add_uint(tree, hf_ulmap_ofdma_sym, tvb, NIBHI(nib,2), data); /* added 2005 */
2338     nib += 2;
2339
2340     ti = proto_tree_add_text(tree, tvb, NIBHI(nib,length-nib), "UL-MAP IEs");
2341     ie_tree = proto_item_add_subtree(ti, ett_306_ul);
2342     while (nib < length-1) {
2343         nib += dissect_ulmap_ie(ie_tree, bufptr, nib, length-nib, tvb);
2344     }
2345
2346     /* padding */
2347     if (nib & 1) {
2348         proto_tree_add_text(tree, tvb, NIBHI(nib,1), "Padding Nibble");
2349         nib++;
2350     }
2351
2352
2353     return length;
2354 }
2355
2356
2357 gint wimax_decode_ulmap_reduced_aas(proto_tree *base_tree, const guint8 *bufptr, gint offset, gint length, tvbuff_t *tvb)
2358 {
2359     /* 8.4.5.8.2 Reduced AAS private UL-MAP */
2360     /* offset and length are in bits since this is called from within
2361      * the Reduced AAS private DL-MAP
2362      * return length in bits */
2363     gint bit;
2364     guint data;
2365     proto_item *ti = NULL;
2366     proto_tree *tree = NULL;
2367     gint azci, azpi, umii, phmi, powi, fbck;
2368
2369     bit = offset;
2370
2371     ti = proto_tree_add_text(base_tree, tvb, BITHI(bit,length), "Reduced_AAS_Private_UL_MAP");
2372     tree = proto_item_add_subtree(ti, ett_308b);
2373
2374     /* Decode and display the Reduced AAS private UL-MAP */
2375     XBIT(azci, 1, "AAS zone configuration included");
2376     XBIT(azpi, 1, "AAS zone position included");
2377     XBIT(umii, 1, "UL-MAP information included");
2378     XBIT(phmi, 1, "PHY modification included");
2379     XBIT(powi, 1, "Power Control included");
2380     XBIT(fbck, 2, "Include Feedback Header");
2381     XBIT(data, 2, "Encoding Mode");
2382
2383     if (azci) {
2384         XBIT(data, 2, "Permutation");
2385         XBIT(data, 7, "UL_PermBase");
2386         XBIT(data, 2, "Preamble Indication");
2387         XBIT(data, 5, "Padding");
2388     }
2389     if (azpi) {
2390         XBIT(data, 8, "Zone Symbol Offset");
2391         XBIT(data, 8, "Zone Length");
2392     }
2393     if (umii) {
2394         XBIT(data, 8, "UCD Count");
2395         data = BIT_BITS64(bit,bufptr,32);
2396         proto_tree_add_text(tree, tvb, BITHI(bit,32), "Private Map Allocation Start Time: %u",data);
2397         bit += 32;
2398     }
2399     if (phmi) {
2400         XBIT(data, 1, "Preamble Select");
2401         XBIT(data, 4, "Preamble Shift Index");
2402         XBIT(data, 1, "Pilot Pattern Modifier");
2403         data = BIT_BITS32(bit,bufptr,22);
2404         proto_tree_add_text(tree, tvb, BITHI(bit,22), "Pilot Pattern Index: %u",data);
2405         bit += 22;
2406     }
2407     if (powi) {
2408         XBIT(data, 8, "Power Control");
2409     }
2410     XBIT(data, 3, "UL Frame Offset");
2411     XBIT(data,12, "Slot Offset");
2412     XBIT(data,10, "Slot Duration");
2413     XBIT(data, 4, "UIUC / N(EP)");
2414     if (harq) {
2415         XBIT(data, 4, "ACID");
2416         XBIT(data, 1, "AI_SN");
2417         XBIT(data, 3, "Reserved");
2418         if (ir_type) {
2419             XBIT(data, 4, "N(SCH)");
2420             XBIT(data, 2, "SPID");
2421             XBIT(data, 2, "Reserved");
2422         }
2423     }
2424     XBIT(data, 2, "Repetition Coding Indication");
2425
2426     return (bit - offset); /* length in bits */
2427 }
2428