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