Change each filter prefix to match the protocol name ("wmx"). Add a
[obnox/wireshark/wip.git] / plugins / wimax / msg_rng_rsp.c
1 /* msg_rng_rsp.c
2  * WiMax MAC Management RNG-RSP Message decoder
3  *
4  * Copyright (c) 2007 by Intel Corporation.
5  *
6  * Author: John R. Underwood <junderx@yahoo.com>
7  *
8  * $Id$
9  *
10  * Wireshark - Network traffic analyzer
11  * By Gerald Combs <gerald@wireshark.org>
12  * Copyright 1999 Gerald Combs
13  *
14  * This program is free software; you can redistribute it and/or
15  * modify it under the terms of the GNU General Public License
16  * as published by the Free Software Foundation; either version 2
17  * of the License, or (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with this program; if not, write to the Free Software
26  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
27  */
28
29 /* Include files */
30
31 #ifdef HAVE_CONFIG_H
32 #include "config.h"
33 #endif
34
35 #include "moduleinfo.h"
36
37 #include <glib.h>
38 #include <epan/packet.h>
39 #include <epan/prefs.h>
40 #include "crc.h"
41 #include "wimax_tlv.h"
42 #include "wimax_mac.h"
43 #include "wimax_utils.h"
44
45 extern gint proto_mac_mgmt_msg_rng_req_decoder;
46 extern gboolean include_cor2_changes;
47
48 /* forward reference */
49 void dissect_mac_mgmt_msg_rng_rsp_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
50
51 /* external reference */
52 extern void dissect_power_saving_class(proto_tree *rng_req_tree, gint tlv_type, tvbuff_t *tvb, guint compound_tlv_len, packet_info *pinfo, guint offset);
53 extern void dissect_mac_mgmt_msg_sbc_rsp_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
54 extern void dissect_mac_mgmt_msg_reg_rsp_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
55
56 static gint proto_mac_mgmt_msg_rng_rsp_decoder = -1;
57 static gint ett_mac_mgmt_msg_rng_rsp_decoder   = -1;
58 static gint ett_rng_rsp_message_tree           = -1;
59
60 /* Setup protocol subtree array */
61 static gint *ett[] =
62 {
63         &ett_mac_mgmt_msg_rng_rsp_decoder,
64         &ett_rng_rsp_message_tree
65 };
66
67 /* RNG-RSP fields */
68 static gint hf_rng_rsp_message_type                             = -1;
69 static gint hf_rng_req_reserved                                 = -1;
70 static gint hf_rng_rsp_ul_channel_id                            = -1;
71 static gint hf_rng_rsp_timing_adjust                            = -1;
72 static gint hf_rng_rsp_power_level_adjust                       = -1;
73 static gint hf_rng_rsp_offset_freq_adjust                       = -1;
74 static gint hf_rng_rsp_ranging_status                           = -1;
75 static gint hf_rng_rsp_dl_freq_override                         = -1;
76 static gint hf_rng_rsp_ul_chan_id_override                      = -1;
77 static gint hf_rng_rsp_dl_operational_burst_profile             = -1;
78 static gint hf_rng_rsp_dl_operational_burst_profile_diuc        = -1;
79 static gint hf_rng_rsp_dl_operational_burst_profile_ccc         = -1;
80 static gint hf_rng_rsp_ss_mac_address                           = -1;
81 static gint hf_rng_rsp_basic_cid                                = -1;
82 static gint hf_rng_rsp_primary_mgmt_cid                         = -1;
83 static gint hf_rng_rsp_broadcast                                = -1;
84 static gint hf_rng_rsp_frame_number                             = -1;
85 static gint hf_rng_rsp_opportunity_number                       = -1;
86 static gint hf_rng_rsp_service_level_prediction                 = -1;
87 static gint hf_rng_rsp_resource_retain_flag                     = -1;
88 static gint hf_rng_rsp_ho_process_optimization                  = -1;
89 static gint hf_rng_rsp_ho_process_optimization_0                = -1;
90 static gint hf_rng_rsp_ho_process_optimization_1_2              = -1;
91 static gint hf_rng_rsp_ho_process_optimization_3                = -1;
92 static gint hf_rng_rsp_ho_process_optimization_4                = -1;
93 static gint hf_rng_rsp_ho_process_optimization_5                = -1;
94 static gint hf_rng_rsp_ho_process_optimization_6                = -1;
95 static gint hf_rng_rsp_ho_process_optimization_7                = -1;
96 static gint hf_rng_rsp_ho_process_optimization_8                = -1;
97 static gint hf_rng_rsp_ho_process_optimization_9                = -1;
98 static gint hf_rng_rsp_ho_process_optimization_10               = -1;
99 static gint hf_rng_rsp_ho_process_optimization_11               = -1;
100 static gint hf_rng_rsp_ho_process_optimization_12               = -1;
101 static gint hf_rng_rsp_ho_process_optimization_13               = -1;
102 static gint hf_rng_rsp_ho_process_optimization_14               = -1;
103 static gint hf_rng_rsp_ho_process_optimization_15               = -1;
104 /* Added the following to help implement RNG-RSP message encoding 33 (Table 367 in IEEE 802.16e-2007) */
105 static gint hf_rng_rsp_dl_op_burst_profile_ofdma                = -1;
106 static gint hf_rng_rsp_least_robust_diuc                        = -1;
107 static gint hf_rng_rsp_repetition_coding_indication             = -1;
108 static gint hf_rng_rsp_config_change_count_of_dcd               = -1;
109 /* Added the following to help implement RNG-RSP message encoding 22 (Table 367 in IEEE 802.16e-2007) */
110 static gint hf_rng_rsp_ho_id                                    = -1;
111 static gint hf_rng_rsp_location_update_response                 = -1;
112 /* Added the following to help implement RNG-RSP message encoding 24 (Table 367 in IEEE 802.16e-2007) */
113 static gint hf_rng_rsp_paging_information                       = -1;
114 static gint hf_rng_rsp_paging_cycle                             = -1;
115 static gint hf_rng_rsp_paging_offset                            = -1;
116 static gint hf_rng_rsp_paging_group_id                          = -1;
117 static gint hf_rng_rsp_bs_random                                = -1;
118 static gint hf_rng_rsp_akid                                     = -1;
119 static gint hf_rng_rsp_ranging_subchan                          = -1;
120 static gint hf_rng_rsp_time_symbol_reference                    = -1;
121 static gint hf_rng_rsp_subchannel_reference                     = -1;
122 static gint hf_rng_rsp_ranging_code_index                       = -1;
123 static gint hf_rng_rsp_frame_number2                            = -1;
124 static gint hf_tlv_type                                         = -1;
125 static gint hf_tlv_value                                        = -1;
126 static gint hf_rng_invalid_tlv                                  = -1;
127
128 /* STRING RESOURCES */
129
130 static const true_false_string tfs_rng_rsp_aas_broadcast = {
131     "SS shall not issue contention-based Bandwidth Request",
132     "SS may issue contention-based Bandwidth Request"
133 };
134
135 static const true_false_string tfs_rng_rsp_resource_retain_flag = {
136         "Retained by the BS",
137         "Deleted by the BS"
138 };
139
140 static const value_string vals_rng_rsp_ranging_status[] = {
141     {1,                                 "continue"},
142     {2,                                 "abort"},
143     {3,                                 "success"},
144     {4,                                 "rerange"},
145     {0,                                 NULL}
146 };
147
148 static const value_string vals_rng_rsp_level_of_service[] = {
149         {0,             "No service possible for this MS"},
150         {1,             "Some service is available for one or"
151                         " several service flows authorized for the MS"},
152         {2,             "For each authorized service flow, a MAC"
153                         " connection can be established with QoS"
154                         " specified by the AuthorizedQoSParamSet"},
155         {3,             "No service level prediction available"},
156         {0,             NULL}
157 };
158
159 static const value_string vals_rng_rsp_ho_process_optimization_0[] = {
160         {0,             "SBC-REQ management messages during current re-entry"
161                         " processing required"},
162         {1,             "Omit SBC-REQ management messages during current"
163                         " re-entry processing"},
164         {0,             NULL},
165 };
166
167 static const value_string vals_rng_rsp_ho_process_optimization_1_2[] = {
168         {0,             "Perform re-authentication and SA-TEK 3-way handshake."
169                         " BS should include SA-TEK-Update TLV in the"
170                         " SA-TEK-Response message. In addition, the RNG-RSP"
171                         " message does not include SA-TEK-Update TLV or SA"
172                         " Challenge Tuple TLV."},
173         {1,             "SA-TEK-Update TLV is included in the RNG-RSP message."
174                         " In this case, SA-TEK 3-way handshake is avoided and"
175                         " SA Challenge Tuple TLV shall not be included in the"
176                         " RNG-RSP message."},
177         {2,             "Reserved"},
178         {3,             "Re-authentication and SA-TEK 3-way handshake is not"
179                         " performed. The RNG-RSP message does not include"
180                         " SA-TEK-Update TLV nor SA Challenge Tuple TLV. All the"
181                         " TEKs received from the serving BS are reused"},
182         {0,             NULL}
183 };
184
185 static const value_string vals_rng_rsp_ho_process_optimization_3[] = {
186         {0,             "Network Address Acquisition management messages during"
187                         " current reentry processing required"},
188         {1,             "Omit Network Address Acquisition management messages"
189                         " during current reentry processing"},
190         {0,             NULL}
191 };
192
193 static const value_string vals_rng_rsp_ho_process_optimization_4[] = {
194         {0,             "Time of Day Acquisition management messages during"
195                         " current reentry processing required"},
196         {1,             "Omit Time of Day Acquisition management messages"
197                         " during current reentry processing"},
198         {0,             NULL}
199 };
200
201 static const value_string vals_rng_rsp_ho_process_optimization_5[] = {
202         {0,             "TFTP management messages during current re-entry"
203                         " processing required"},
204         {1,             "Omit TFTP management messages during current re-entry"
205                         " processing"},
206         {0,             NULL}
207 };
208
209 static const value_string vals_rng_rsp_ho_process_optimization_6[] = {
210         {0,             "Full service and operational state transfer or sharing"
211                         " between Serving BS and Target BS required"},
212         {1,             "Omit Full service and operational state transfer or"
213                         " sharing between Serving BS and Target BS"},
214         {0,             NULL}
215 };
216
217 static const value_string vals_rng_rsp_ho_process_optimization_7[] = {
218         {0,             "REG-REQ management message during current re-entry"
219                         " processing required"},
220         {1,             "Omit REG-REQ management message during current re-entry"
221                         " processing"},
222         {0,             NULL}
223 };
224
225 static const value_string vals_rng_rsp_ho_process_optimization_8[] = {
226         {0,             "BS shall send not send an unsolicited SBC-RSP"
227                         " management message"},
228         {1,             "BS shall send an unsolicited SBC-RSP management message"},
229         {0,             NULL}
230 };
231
232 static const value_string vals_rng_rsp_ho_process_optimization_9[] = {
233         {0,             "No post-HO re-entry MS DL data pending at target BS"},
234         {1,             "post-HO re-entry MS DL data pending at target BS"},
235         {0,             NULL}
236 };
237
238 static const value_string vals_rng_rsp_ho_process_optimization_10[] = {
239         {0,             "BS shall not send an unsolicited REG-RSP management"
240                         " message"},
241         {1,             "BS shall send an unsolicited REG-RSP management message"},
242         {0,             NULL}
243 };
244
245 static const value_string vals_rng_rsp_ho_process_optimization_11[] = {
246         {0,             "(Target) BS does not support virtual SDU SN"},
247         {1,             "(Target} BS supports virtual SDU SN"},
248         {0,             NULL}
249 };
250
251 static const value_string vals_rng_rsp_ho_process_optimization_12[] = {
252         {0,             "MS shall not send a notification of MS's successful"
253                         " re-entry registration"},
254         {1,             "MS shall send a notification of MS's successful"
255                         " re-entry registration"},
256         {0,             NULL}
257 };
258
259 static const value_string vals_rng_rsp_ho_process_optimization_13[] = {
260         {0,             "MS shall not trigger a higher layer protocol required"
261                         " to refresh its traffic IP address"},
262         {1,             "MS shall trigger a higher layer protocol required to"
263                         " refresh its traffic IP address"},
264         {0,             NULL}
265 };
266
267 static const value_string vals_rng_rsp_repetition_coding_indication[] = {
268         {0,             "No repetition coding"},
269         {1,             "Repetition coding of 2"},
270         {2,             "Repetition coding of 4"},
271         {3,             "Repetition coding of 6"},
272         {0,             NULL}
273 };
274
275 static const value_string vals_rng_rsp_location_update_response[] = {
276         {0,             "Success of Location Update"},
277         {1,             "Failure of Location Update"},
278         {3,             "Success of location update and DL traffic pending"},
279         {4,             "Reserved"},
280         {0,             NULL}
281 };
282
283 /* RNG-RSP fields display */
284 static hf_register_info hf[] =
285 {
286         {
287                 &hf_rng_rsp_message_type,
288                 {
289                         "MAC Management Message Type", "wmx.macmgtmsgtype.rng_rsp",
290                         FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL
291                 }
292         },
293         {
294                 &hf_rng_rsp_broadcast,
295                 {
296                         "AAS broadcast permission", "wmx.rng_rsp.aas_broadcast",
297                         FT_BOOLEAN, 8, TFS(&tfs_rng_rsp_aas_broadcast), 0x00, "", HFILL
298                 }
299         },
300         {
301                 &hf_rng_rsp_akid,
302                 {
303                         "AKId", "wmx.rng_rsp.akid",
304                         FT_BYTES, BASE_NONE, NULL, 0x00, "", HFILL
305                 }
306         },
307         {
308                 &hf_rng_rsp_basic_cid,
309                 {
310                         "Basic CID", "wmx.rng_rsp.basic_cid",
311                         FT_UINT16, BASE_DEC, NULL, 0x00, "", HFILL
312                 }
313         },
314         {
315                 &hf_rng_rsp_bs_random,
316                 {
317                         "BS_Random", "wmx.rng_rsp.bs_random",
318                         FT_BYTES, BASE_NONE, NULL, 0x00, "", HFILL
319                 }
320         },
321         {
322                 &hf_rng_rsp_config_change_count_of_dcd,
323                 {
324                         "Configuration Change Count value of DCD defining DIUC associated burst profile", "wmx.rng_rsp.config_change_count_of_dcd",
325                         FT_UINT16, BASE_HEX, NULL, 0xFF00, "", HFILL
326                 }
327         },
328         {
329                 &hf_rng_rsp_dl_freq_override,
330                 {
331                         "Downlink Frequency Override", "wmx.rng_rsp.dl_freq_override",
332                         FT_UINT32, BASE_DEC, NULL, 0x00, "", HFILL
333                 }
334         },
335         {
336                 &hf_rng_rsp_dl_operational_burst_profile_ccc,
337                 {
338                         "CCC value of DCD defining the burst profile associated with DIUC", "wmx.rng_rsp.dl_op_burst_prof.ccc",
339                         FT_UINT16, BASE_DEC, NULL, 0x00FF, "", HFILL
340                 }
341         },
342         {
343                 &hf_rng_rsp_dl_operational_burst_profile_diuc,
344                 {
345                         "The least robust DIUC that may be used by the BS for transmissions to the SS", "wmx.rng_rsp.dl_op_burst_prof.diuc",
346                         FT_UINT16, BASE_DEC, NULL, 0xFF00, "", HFILL
347                 }
348         },
349         {
350                 &hf_rng_rsp_dl_operational_burst_profile,
351                 {
352                         "Downlink Operational Burst Profile", "wmx.rng_rsp.dl_op_burst_profile",
353                         FT_UINT16, BASE_HEX, NULL, 0x00, "", HFILL
354                 }
355         },
356         /* Added the following to help implement RNG-RSP message encoding 33 (Table 367 in IEEE 802.16e-2007) */
357         {
358                 &hf_rng_rsp_dl_op_burst_profile_ofdma,
359                 {
360                         "Downlink Operational Burst Profile for OFDMA", "wmx.rng_rsp.dl_op_burst_profile_ofdma",
361                         FT_UINT16, BASE_HEX, NULL, 0x00, "", HFILL
362                 }
363         },
364         {
365                 &hf_rng_rsp_frame_number2,
366                 {
367                         "The 8 least significant bits of the frame number of the OFDMA frame where the SS sent the ranging code", "wmx.rng_rsp.eight_bit_frame_num",
368                         FT_UINT32, BASE_DEC, NULL, 0x000000FF, "", HFILL
369                 }
370         },
371         {
372                 &hf_rng_rsp_frame_number,
373                 {
374                         "Frame number", "wmx.rng_rsp.frame_number",
375                         FT_UINT24, BASE_DEC, NULL, 0x00, "", HFILL
376                 }
377         },
378         /* Added the following to help implement RNG-RSP message encoding 22 (IEEE 802.16e-2007) */
379         {
380                 &hf_rng_rsp_ho_id,
381                 {
382                         "HO ID", "wmx.rng_rsp.ho_id",
383                         FT_UINT8, BASE_HEX, NULL, 0x00, "", HFILL
384                 }
385         },
386         {
387                 &hf_rng_rsp_ho_process_optimization,
388                 {
389                         "HO Process Optimization", "wmx.rng_rsp.ho_process_optimization",
390                         FT_UINT16, BASE_HEX, NULL, 0x0000, "", HFILL
391                 }
392         },
393         {
394                 &hf_rng_rsp_ho_process_optimization_0,
395                 {
396                         "Bit #0", "wmx.rng_rsp.ho_process_optimization.omit_sbc_req",
397                         FT_UINT16, BASE_HEX, VALS(vals_rng_rsp_ho_process_optimization_0), 0x0001, "", HFILL
398                 }
399         },
400         {
401                 &hf_rng_rsp_ho_process_optimization_1_2,
402                 {
403                         "Bits #1-2", "wmx.rng_rsp.ho_process_optimization.perform_reauthentication",
404                         FT_UINT16, BASE_HEX, VALS(vals_rng_rsp_ho_process_optimization_1_2), 0x0006, "", HFILL
405                 }
406         },
407         {
408                 &hf_rng_rsp_ho_process_optimization_3,
409                 {
410                         "Bit #3", "wmx.rng_rsp.ho_process_optimization.omit_network_address",
411                         FT_UINT16, BASE_HEX, VALS(vals_rng_rsp_ho_process_optimization_3), 0x0008, "", HFILL
412                 }
413         },
414         {
415                 &hf_rng_rsp_ho_process_optimization_4,
416                 {
417                         "Bit #4", "wmx.rng_rsp.ho_process_optimization.omit_time_of_day",
418                         FT_UINT16, BASE_HEX, VALS(vals_rng_rsp_ho_process_optimization_4), 0x0010, "", HFILL
419                 }
420         },
421         {
422                 &hf_rng_rsp_ho_process_optimization_5,
423                 {
424                         "Bit #5", "wmx.rng_rsp.ho_process_optimization.omit_tftp",
425                         FT_UINT16, BASE_HEX, VALS(vals_rng_rsp_ho_process_optimization_5), 0x0020, "", HFILL
426                 }
427         },
428         {
429                 &hf_rng_rsp_ho_process_optimization_6,
430                 {
431                         "Bit #6", "wmx.rng_rsp.ho_process_optimization.transfer_or_sharing",
432                         FT_UINT16, BASE_HEX, VALS(vals_rng_rsp_ho_process_optimization_6), 0x0040, "", HFILL
433                 }
434         },
435         {
436                 &hf_rng_rsp_ho_process_optimization_7,
437                 {
438                         "Bit #7", "wmx.rng_rsp.ho_process_optimization.omit_reg_req",
439                         FT_UINT16, BASE_HEX, VALS(vals_rng_rsp_ho_process_optimization_7), 0x0080, "", HFILL
440                 }
441         },
442         {
443                 &hf_rng_rsp_ho_process_optimization_8,
444                 {
445                         "Bit #8", "wmx.rng_rsp.ho_process_optimization.unsolicited_sbc_rsp",
446                         FT_UINT16, BASE_HEX, VALS(vals_rng_rsp_ho_process_optimization_8), 0x0100, "", HFILL
447                 }
448         },
449         {
450                 &hf_rng_rsp_ho_process_optimization_9,
451                 {
452                         "Bit #9", "wmx.rng_rsp.ho_process_optimization.post_ho_reentry",
453                         FT_UINT16, BASE_HEX, VALS(vals_rng_rsp_ho_process_optimization_9), 0x0200, "", HFILL
454                 }
455         },
456         {
457                 &hf_rng_rsp_ho_process_optimization_10,
458                 {
459                         "Bit #10", "wmx.rng_rsp.ho_process_optimization.unsolicited_reg_rsp",
460                         FT_UINT16, BASE_HEX, VALS(vals_rng_rsp_ho_process_optimization_10), 0x0400, "", HFILL
461                 }
462         },
463         {
464                 &hf_rng_rsp_ho_process_optimization_11,
465                 {
466                         "Bit #11", "wmx.rng_rsp.ho_process_optimization.virtual_sdu_sn",
467                         FT_UINT16, BASE_HEX, VALS(vals_rng_rsp_ho_process_optimization_11), 0x0800, "", HFILL
468                 }
469         },
470         {
471                 &hf_rng_rsp_ho_process_optimization_12,
472                 {
473                         "Bit #12", "wmx.rng_rsp.ho_process_optimization.send_notification",
474                         FT_UINT16, BASE_HEX, VALS(vals_rng_rsp_ho_process_optimization_12), 0x1000, "", HFILL
475                 }
476         },
477         {
478                 &hf_rng_rsp_ho_process_optimization_13,
479                 {
480                         "Bit #13", "wmx.rng_rsp.ho_process_optimization.trigger_higher_layer_protocol",
481                         FT_UINT16, BASE_HEX, VALS(vals_rng_rsp_ho_process_optimization_13), 0x2000, "", HFILL
482                 }
483         },
484         {
485                 &hf_rng_rsp_ho_process_optimization_14,
486                 {
487                         "Bit #14: Reserved", "wmx.rng_rsp.ho_process_optimization.reserved",
488                         FT_UINT16, BASE_HEX, NULL, 0x4000, "", HFILL
489                 }
490         },
491         {
492                 &hf_rng_rsp_ho_process_optimization_15,
493                 {
494                         "Bit #15: Reserved", "wmx.rng_rsp.ho_process_optimization.reserved",
495                         FT_UINT16, BASE_HEX, NULL, 0x8000, "", HFILL
496                 }
497         },
498         {
499                 &hf_rng_invalid_tlv,
500                 {
501                         "Invalid TLV", "wmx.rng_rsp.invalid_tlv", 
502                         FT_BYTES, BASE_HEX, NULL, 0, "", HFILL
503                 }
504         },
505         {
506                 &hf_rng_rsp_least_robust_diuc,
507                 {
508                         "Least Robust DIUC that may be used by the BS for transmissions to the MS", "wmx.rng_rsp.least_robust_diuc",
509                         FT_UINT16, BASE_HEX, NULL, 0x000F, "", HFILL
510                 }
511         },
512         {
513                 &hf_rng_rsp_location_update_response,
514                 {
515                         "Location Update Response", "wmx.rng_rsp.location_update_response",
516                         FT_UINT8, BASE_DEC, VALS(vals_rng_rsp_location_update_response), 0xFF, "", HFILL
517                 }
518         },
519         {
520                 &hf_rng_rsp_offset_freq_adjust,
521                 {
522                         "Offset Frequency Adjust", "wmx.rng_rsp.offset_freq_adjust",
523                         FT_INT32, BASE_DEC, NULL, 0x00, "", HFILL
524                 }
525         },
526         {
527                 &hf_rng_rsp_opportunity_number,
528                 {
529                         "Initial ranging opportunity number", "wmx.rng_rsp.opportunity_number",
530                         FT_UINT8, BASE_DEC, NULL, 0x00, "", HFILL
531                 }
532         },
533         {
534                 &hf_rng_rsp_paging_cycle,
535                 {
536                         "Paging Cycle", "wmx.rng_rsp.paging_cycle",
537                         FT_UINT16, BASE_DEC, NULL, 0x00, "", HFILL
538                 }
539         },
540         {
541                 &hf_rng_rsp_paging_group_id,
542                 {
543                         "Paging Group ID", "wmx.rng_rsp.paging_group_id",
544                         FT_UINT16, BASE_DEC, NULL, 0x00, "", HFILL
545                 }
546         },
547         {
548                 &hf_rng_rsp_paging_information,
549                 {
550                         "Paging Information", "wmx.rng_rsp.paging_information",
551                         FT_BYTES, BASE_DEC, NULL, 0x00, "", HFILL
552                 }
553         },
554         {
555                 &hf_rng_rsp_paging_offset,
556                 {
557                         "Paging Offset", "wmx.rng_rsp.paging_offset",
558                         FT_UINT8, BASE_DEC, NULL, 0x00, "", HFILL
559                 }
560         },
561         {
562                 &hf_rng_rsp_power_level_adjust,
563                 {
564                         "Power Level Adjust", "wmx.rng_rsp.power_level_adjust",
565                         FT_FLOAT, BASE_DEC, NULL, 0x00, "", HFILL
566                 }
567         },
568         {
569                 &hf_rng_rsp_primary_mgmt_cid,
570                 {
571                         "Primary Management CID", "wmx.rng_rsp.primary_mgmt_cid",
572                         FT_UINT16, BASE_DEC, NULL, 0x00, "", HFILL
573                 }
574         },
575         {
576                 &hf_rng_rsp_ranging_code_index,
577                 {
578                         "The ranging code index that was sent by the SS", "wmx.rng_rsp.ranging_code_index",
579                         FT_UINT32, BASE_DEC, NULL, 0x0000FF00, "", HFILL
580                 }
581         },
582         {
583                 &hf_rng_rsp_ranging_status,
584                 {
585                         "Ranging status", "wmx.rng_rsp.ranging_status",
586                         FT_UINT8, BASE_DEC, VALS(vals_rng_rsp_ranging_status), 0x00, "", HFILL
587                 }
588         },
589         {
590                 &hf_rng_rsp_ranging_subchan,
591                 {
592                         "Ranging code attributes", "wmx.rng_rsp.ranging_subchannel",
593                         FT_UINT32, BASE_HEX, NULL, 0x00, "", HFILL
594                 }
595         },
596         {
597                 &hf_rng_rsp_repetition_coding_indication,
598                 {
599                         "Repetition Coding Indication", "wmx.rng_rsp.repetition_coding_indication",
600                         FT_UINT16, BASE_HEX, VALS(vals_rng_rsp_repetition_coding_indication), 0x00F0, "", HFILL
601                 }
602         },
603         {
604                 &hf_rng_req_reserved,
605                 {
606                         "Reserved", "wmx.rng_rsp.reserved",
607                         FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL
608                 }
609         },
610         {
611                 &hf_rng_rsp_resource_retain_flag,
612                 {
613                         "The connection information for the MS is", "wmx.rng_rsp.resource_retain_flag",
614                         FT_BOOLEAN, 8, TFS(&tfs_rng_rsp_resource_retain_flag), 0x00, "", HFILL
615                 }
616         },
617         {
618                 &hf_rng_rsp_service_level_prediction,
619                 {
620                         "Service Level Prediction", "wmx.rng_rsp.service_level_prediction",
621                         FT_UINT8, BASE_DEC, VALS(vals_rng_rsp_level_of_service), 0x00, "", HFILL
622                 }
623         },
624         {
625                 &hf_rng_rsp_ss_mac_address,
626                 {
627                         "SS MAC Address", "wmx.rng_rsp.ss_mac_address",
628                         FT_ETHER, BASE_HEX, NULL, 0x00, "", HFILL
629                 }
630         },
631         {
632                 &hf_rng_rsp_subchannel_reference,
633                 {
634                         "OFDMA subchannel reference used to transmit the ranging code", "wmx.rng_rsp.subchannel_reference",
635                         FT_UINT32, BASE_DEC, NULL, 0x003f0000, "", HFILL
636                 }
637         },
638         {
639                 &hf_rng_rsp_time_symbol_reference,
640                 {
641                         "OFDM time symbol reference used to transmit the ranging code", "wmx.rng_rsp.time_symbol_reference",
642                         FT_UINT32, BASE_DEC, NULL, 0xFFC00000, "", HFILL
643                 }
644         },
645         {
646                 &hf_rng_rsp_timing_adjust,
647                 {
648                         "Timing Adjust", "wmx.rng_rsp.timing_adjust",
649                         FT_FLOAT, BASE_DEC, NULL, 0x00, "", HFILL
650                 }
651         },
652         {
653                 &hf_rng_rsp_ul_channel_id,
654                 {
655                         "Uplink Channel ID", "wmx.rng_rsp.ul_chan_id",
656                         FT_UINT8, BASE_DEC, NULL, 0x00, "", HFILL
657                 }
658         },
659         {
660                 &hf_rng_rsp_ul_chan_id_override,
661                 {
662                         "Uplink channel ID Override", "wmx.rng_rsp.ul_chan_id_override",
663                         FT_UINT8, BASE_DEC, NULL, 0x00, "", HFILL
664                 }
665         },
666         {
667                 &hf_tlv_type,
668                 {
669                         "Unknown TLV Type", "wmx.rng_rsp.unknown_tlv_type",
670                         FT_BYTES, BASE_NONE, NULL, 0x00, "", HFILL
671                 }
672         },
673         {
674                 &hf_tlv_value,
675                 {
676                         "Value", "wmx.rng_rsp.tlv_value",
677                         FT_BYTES, BASE_NONE, NULL, 0x00, "", HFILL
678                 }
679         }
680 };
681
682 /* Register Wimax Mac Payload Protocol and Dissector */
683 void proto_register_mac_mgmt_msg_rng_rsp(void)
684 {
685         if (proto_mac_mgmt_msg_rng_rsp_decoder == -1)
686         {
687                 proto_mac_mgmt_msg_rng_rsp_decoder = proto_mac_mgmt_msg_rng_req_decoder;
688
689                 proto_register_field_array(proto_mac_mgmt_msg_rng_rsp_decoder, hf, array_length(hf));
690                 proto_register_subtree_array(ett, array_length(ett));
691         }
692 }
693
694 /* Decode RNG-RSP messages. */
695 void dissect_mac_mgmt_msg_rng_rsp_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
696 {
697         proto_item *ranging_status_item = NULL;
698         proto_item *dl_freq_override_item = NULL;
699         proto_item *ss_mac_address_item = NULL;
700         proto_item *frame_number_item = NULL;
701         proto_item *opportunity_number_item = NULL;
702
703         guint offset = 0;
704         guint tlv_offset;
705         guint tvb_len, payload_type;
706         proto_item *rng_rsp_item = NULL;
707         proto_item *tlv_item = NULL;
708         proto_tree *rng_rsp_tree = NULL;
709         proto_tree *sub_tree = NULL;
710         proto_tree *tlv_tree = NULL;
711         tlv_info_t tlv_info;
712         gint tlv_type;
713         guint tlv_len;
714         guint this_offset = 0;
715         tlv_info_t sub_tlv_info;
716         gint sub_tlv_type;
717         gint sub_tlv_len;
718         guint sub_tlv_offset;
719         float timing_adjust;
720         float power_level_adjust;
721         gint offset_freq_adjust;
722
723         /* Ensure the right payload type */
724         payload_type = tvb_get_guint8(tvb, offset);
725         if(payload_type != MAC_MGMT_MSG_RNG_RSP)
726         {
727                 return;
728         }
729
730         if (tree)
731         {       /* we are being asked for details */
732
733                 /* Get the tvb reported length */
734                 tvb_len =  tvb_reported_length(tvb);
735                 /* display MAC payload type RNG-RSP */
736                 rng_rsp_item = proto_tree_add_protocol_format(tree, proto_mac_mgmt_msg_rng_rsp_decoder, tvb, offset, tvb_len, "MAC Management Message, RNG-RSP (5)");
737                 /* add MAC RNG-RSP subtree */
738                 rng_rsp_tree = proto_item_add_subtree(rng_rsp_item, ett_mac_mgmt_msg_rng_rsp_decoder);
739                 /* display the Message Type */
740                 proto_tree_add_item(rng_rsp_tree, hf_rng_rsp_message_type, tvb, offset, 1, FALSE);
741                 proto_tree_add_item(rng_rsp_tree, hf_rng_req_reserved, tvb, 1, 1, FALSE);
742                 offset += 2;
743
744                 while(offset < tvb_len)
745                 {
746                         /* Get the TLV data. */
747                         init_tlv_info(&tlv_info, tvb, offset);
748                         /* get the TLV type */
749                         tlv_type = get_tlv_type(&tlv_info);
750                         /* get the TLV length */
751                         tlv_len = get_tlv_length(&tlv_info);
752                         if(tlv_type == -1 || tlv_len > MAX_TLV_LEN || tlv_len < 1)
753                         {       /* invalid tlv info */
754                                 if(pinfo->cinfo)
755                                 {
756                                         col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "RNG-RSP TLV error");
757                                 }
758                                 proto_tree_add_item(rng_rsp_tree, hf_rng_invalid_tlv, tvb, offset, (tvb_len - offset), FALSE);
759                                 break;
760                         }
761                         /* get the offset to the TLV data */
762                         tlv_offset = offset + get_tlv_value_offset(&tlv_info);
763
764                         switch (tlv_type) {
765                                 case RNG_RSP_TIMING_ADJUST: {
766                                         sub_tree = add_protocol_subtree(&tlv_info, ett_rng_rsp_message_tree, rng_rsp_tree, proto_mac_mgmt_msg_rng_rsp_decoder, tvb, tlv_offset, tlv_len, "Timing Adjust (%u byte(s))", tlv_len);
767                                         timing_adjust = (float)(gint32)tvb_get_ntohl(tvb, tlv_offset) / 4;
768                                         tlv_item = proto_tree_add_float_format_value(sub_tree, hf_rng_rsp_timing_adjust, tvb,
769                                                 tlv_offset, 4, timing_adjust, " %.2f modulation symbols", timing_adjust);
770                                         if ((timing_adjust < -2) || (timing_adjust > 2))
771                                                 proto_item_append_text(tlv_item, " (during periodic ranging shall not exceed +- 2)");
772                                         break;
773                                 }
774                                 case RNG_RSP_POWER_LEVEL_ADJUST: {
775                                         sub_tree = add_protocol_subtree(&tlv_info, ett_rng_rsp_message_tree, rng_rsp_tree, proto_mac_mgmt_msg_rng_rsp_decoder, tvb, tlv_offset, tlv_len, "Power Level Adjust (%u byte(s))", tlv_len);
776                                         power_level_adjust = (float)(gint8)tvb_get_guint8(tvb, tlv_offset) / 4;
777                                         proto_tree_add_float_format_value(sub_tree, hf_rng_rsp_power_level_adjust, tvb, tlv_offset, 1,
778                                                                 power_level_adjust, " %.2f dB", power_level_adjust);
779                                         break;
780                                 }
781                                 case RNG_RSP_OFFSET_FREQ_ADJUST: {
782                                         sub_tree = add_protocol_subtree(&tlv_info, ett_rng_rsp_message_tree, rng_rsp_tree, proto_mac_mgmt_msg_rng_rsp_decoder, tvb, tlv_offset, tlv_len, "Offset Frequency Adjust (%u byte(s))", tlv_len);
783                                         offset_freq_adjust = tvb_get_ntohl(tvb, tlv_offset);
784                                         proto_tree_add_int_format_value(sub_tree, hf_rng_rsp_offset_freq_adjust, tvb, tlv_offset, 4,
785                                                 offset_freq_adjust, " %d Hz", offset_freq_adjust);
786                                         break;
787                                 }
788                                 case RNG_RSP_RANGING_STATUS:
789                                         sub_tree = add_tlv_subtree(&tlv_info, ett_rng_rsp_message_tree, rng_rsp_tree, hf_rng_rsp_ranging_status, tvb, tlv_offset, 1, FALSE);
790                                         ranging_status_item = proto_tree_add_item(sub_tree, hf_rng_rsp_ranging_status, tvb, tlv_offset, 1, FALSE);
791                                         break;
792                                 case RNG_RSP_DL_FREQ_OVERRIDE: {
793                                         sub_tree = add_tlv_subtree(&tlv_info, ett_rng_rsp_message_tree, rng_rsp_tree, hf_rng_rsp_dl_freq_override, tvb, tlv_offset, 4, FALSE);
794                                         dl_freq_override_item = proto_tree_add_item(sub_tree, hf_rng_rsp_dl_freq_override, tvb, tlv_offset, 4, FALSE);
795                                         proto_item_append_text(dl_freq_override_item, " kHz");
796                                         break;
797                                 }
798                                 case RNG_RSP_UL_CHANNEL_ID_OVERRIDE:
799                                         sub_tree = add_tlv_subtree(&tlv_info, ett_rng_rsp_message_tree, rng_rsp_tree, hf_rng_rsp_ul_chan_id_override, tvb, tlv_offset, 1, FALSE);
800                                         proto_tree_add_item(sub_tree, hf_rng_rsp_ul_chan_id_override, tvb, tlv_offset, 1, FALSE);
801                                         break;
802                                 case RNG_RSP_DL_OPERATIONAL_BURST_PROFILE:
803                                         sub_tree = add_tlv_subtree(&tlv_info, ett_rng_rsp_message_tree, rng_rsp_tree, hf_rng_rsp_dl_operational_burst_profile, tvb, tlv_offset, 2, FALSE);
804                                         proto_tree_add_item(sub_tree, hf_rng_rsp_dl_operational_burst_profile_diuc, tvb, tlv_offset, 2, FALSE);
805                                         proto_tree_add_item(sub_tree, hf_rng_rsp_dl_operational_burst_profile_ccc, tvb, tlv_offset, 2, FALSE);
806                                         break;
807                                 case RNG_RSP_SS_MAC_ADDRESS:
808                                         if (tlv_len == 6)
809                                         {
810                                                 sub_tree = add_tlv_subtree(&tlv_info, ett_rng_rsp_message_tree, rng_rsp_tree, hf_rng_rsp_ss_mac_address, tvb, tlv_offset, 6, FALSE);
811                                                 ss_mac_address_item = proto_tree_add_item(sub_tree, hf_rng_rsp_ss_mac_address, tvb, tlv_offset, 6, FALSE);
812                                         } else {
813                                                 sub_tree = add_tlv_subtree(&tlv_info, ett_rng_rsp_message_tree, rng_rsp_tree, hf_rng_invalid_tlv, tvb, tlv_offset, tlv_len, FALSE);
814                                                 proto_tree_add_item(sub_tree, hf_rng_rsp_ss_mac_address, tvb, tlv_offset, 6, FALSE);
815                                         }
816                                         break;
817                                 case RNG_RSP_BASIC_CID:
818                                         sub_tree = add_tlv_subtree(&tlv_info, ett_rng_rsp_message_tree, rng_rsp_tree, hf_rng_rsp_basic_cid, tvb, tlv_offset, 1, FALSE);
819                                         proto_tree_add_item(sub_tree, hf_rng_rsp_basic_cid, tvb, tlv_offset, 2, FALSE);
820                                         break;
821                                 case RNG_RSP_PRIMARY_MGMT_CID:
822                                         sub_tree = add_tlv_subtree(&tlv_info, ett_rng_rsp_message_tree, rng_rsp_tree, hf_rng_rsp_primary_mgmt_cid, tvb, tlv_offset, 1, FALSE);
823                                         proto_tree_add_item(sub_tree, hf_rng_rsp_primary_mgmt_cid, tvb, tlv_offset, 2, FALSE);
824                                         break;
825                                 case RNG_RSP_AAS_BROADCAST_PERMISSION:
826                                         sub_tree = add_tlv_subtree(&tlv_info, ett_rng_rsp_message_tree, rng_rsp_tree, hf_rng_rsp_broadcast, tvb, tlv_offset, 1, FALSE);
827                                         proto_tree_add_item(sub_tree, hf_rng_rsp_broadcast, tvb, tlv_offset, 1, FALSE);
828                                         break;
829                                 case RNG_RSP_FRAME_NUMBER:
830                                         sub_tree = add_tlv_subtree(&tlv_info, ett_rng_rsp_message_tree, rng_rsp_tree, hf_rng_rsp_frame_number, tvb, tlv_offset, 3, FALSE);
831                                         frame_number_item = proto_tree_add_item(sub_tree, hf_rng_rsp_frame_number, tvb, tlv_offset, 3, FALSE);
832                                         break;
833                                 case RNG_RSP_OPPORTUNITY_NUMBER:
834                                         sub_tree = add_tlv_subtree(&tlv_info, ett_rng_rsp_message_tree, rng_rsp_tree, hf_rng_rsp_opportunity_number, tvb, tlv_offset, 1, FALSE);
835                                         opportunity_number_item = proto_tree_add_item(sub_tree, hf_rng_rsp_opportunity_number, tvb, tlv_offset, 1, FALSE);
836                                         if (tvb_get_ntohl(tvb, tlv_offset) == 0)
837                                                 proto_item_append_text(opportunity_number_item, " (may not be 0!)");
838                                         break;
839                                 case RNG_RSP_SERVICE_LEVEL_PREDICTION:
840                                         sub_tree = add_tlv_subtree(&tlv_info, ett_rng_rsp_message_tree, rng_rsp_tree, hf_rng_rsp_service_level_prediction, tvb, tlv_offset, 1, FALSE);
841                                         proto_tree_add_item(sub_tree, hf_rng_rsp_service_level_prediction, tvb, tlv_offset, 1, FALSE);
842                                         break;
843                                 case RNG_RSP_RESOURCE_RETAIN_FLAG:
844                                         sub_tree = add_tlv_subtree(&tlv_info, ett_rng_rsp_message_tree, rng_rsp_tree, hf_rng_rsp_resource_retain_flag, tvb, tlv_offset, 1, FALSE);
845                                         proto_tree_add_item(sub_tree, hf_rng_rsp_resource_retain_flag, tvb, tlv_offset, 1, FALSE);
846                                         break;
847                                 case RNG_RSP_HO_PROCESS_OPTIMIZATION:
848                                         sub_tree = add_tlv_subtree(&tlv_info, ett_rng_rsp_message_tree, rng_rsp_tree, hf_rng_rsp_ho_process_optimization, tvb, tlv_offset, 2, FALSE);
849                                         proto_tree_add_item(sub_tree, hf_rng_rsp_ho_process_optimization_0, tvb, tlv_offset, 2, FALSE);
850                                         proto_tree_add_item(sub_tree, hf_rng_rsp_ho_process_optimization_1_2, tvb, tlv_offset, 2, FALSE);
851                                         proto_tree_add_item(sub_tree, hf_rng_rsp_ho_process_optimization_3, tvb, tlv_offset, 2, FALSE);
852                                         proto_tree_add_item(sub_tree, hf_rng_rsp_ho_process_optimization_4, tvb, tlv_offset, 2, FALSE);
853                                         proto_tree_add_item(sub_tree, hf_rng_rsp_ho_process_optimization_5, tvb, tlv_offset, 2, FALSE);
854                                         proto_tree_add_item(sub_tree, hf_rng_rsp_ho_process_optimization_6, tvb, tlv_offset, 2, FALSE);
855                                         proto_tree_add_item(sub_tree, hf_rng_rsp_ho_process_optimization_7, tvb, tlv_offset, 2, FALSE);
856                                         proto_tree_add_item(sub_tree, hf_rng_rsp_ho_process_optimization_8, tvb, tlv_offset, 2, FALSE);
857                                         proto_tree_add_item(sub_tree, hf_rng_rsp_ho_process_optimization_9, tvb, tlv_offset, 2, FALSE);
858                                         proto_tree_add_item(sub_tree, hf_rng_rsp_ho_process_optimization_10, tvb, tlv_offset, 2, FALSE);
859                                         proto_tree_add_item(sub_tree, hf_rng_rsp_ho_process_optimization_11, tvb, tlv_offset, 2, FALSE);
860                                         proto_tree_add_item(sub_tree, hf_rng_rsp_ho_process_optimization_12, tvb, tlv_offset, 2, FALSE);
861                                         proto_tree_add_item(sub_tree, hf_rng_rsp_ho_process_optimization_13, tvb, tlv_offset, 2, FALSE);
862                                         proto_tree_add_item(sub_tree, hf_rng_rsp_ho_process_optimization_14, tvb, tlv_offset, 2, FALSE);
863                                         proto_tree_add_item(sub_tree, hf_rng_rsp_ho_process_optimization_15, tvb, tlv_offset, 2, FALSE);
864                                         break;
865                                 case RNG_RSP_SBC_RSP_ENCODINGS:
866                                         sub_tree = add_protocol_subtree(&tlv_info, ett_rng_rsp_message_tree, rng_rsp_tree, proto_mac_mgmt_msg_rng_rsp_decoder, tvb, tlv_offset, tlv_len, "SBC-RSP Encodings (%u byte(s))", tlv_len);
867                                         dissect_mac_mgmt_msg_sbc_rsp_decoder(tvb_new_subset(tvb, tlv_offset, tlv_len, tlv_len), pinfo, sub_tree);
868                                         break;
869                                 case RNG_RSP_REG_RSP_ENCODINGS:
870                                         sub_tree = add_protocol_subtree(&tlv_info, ett_rng_rsp_message_tree, rng_rsp_tree, proto_mac_mgmt_msg_rng_rsp_decoder, tvb, tlv_offset, tlv_len, "REG-RSP Encodings (%u byte(s))", tlv_len);
871                                         dissect_mac_mgmt_msg_reg_rsp_decoder(tvb_new_subset(tvb, tlv_offset, tlv_len, tlv_len), pinfo, sub_tree);
872                                         break;
873                                 /* Implemented message encoding 33 (Table 367 in IEEE 802.16e-2007) */
874                                 case RNG_RSP_DL_OP_BURST_PROFILE_OFDMA:
875                                         sub_tree = add_tlv_subtree(&tlv_info, ett_rng_rsp_message_tree, rng_rsp_tree, hf_rng_rsp_dl_op_burst_profile_ofdma, tvb, tlv_offset, 2, FALSE);
876                                         proto_tree_add_item(sub_tree, hf_rng_rsp_least_robust_diuc, tvb, tlv_offset, 2, FALSE);
877                                         proto_tree_add_item(sub_tree, hf_rng_rsp_repetition_coding_indication, tvb, tlv_offset, 2, FALSE);
878                                         proto_tree_add_item(sub_tree, hf_rng_rsp_config_change_count_of_dcd, tvb, tlv_offset, 2, FALSE);
879                                         break;
880                                 case RNG_RSP_HO_ID:
881                                         sub_tree = add_tlv_subtree(&tlv_info, ett_rng_rsp_message_tree, rng_rsp_tree, hf_rng_rsp_ho_id, tvb, tlv_offset, 1, FALSE);
882                                         proto_tree_add_item(sub_tree, hf_rng_rsp_ho_id, tvb, tlv_offset, 1, FALSE);
883                                         break;
884                                 case RNG_RSP_LOCATION_UPDATE_RESPONSE:
885                                         sub_tree = add_tlv_subtree(&tlv_info, ett_rng_rsp_message_tree, rng_rsp_tree, hf_rng_rsp_location_update_response, tvb, tlv_offset, 1, FALSE);
886                                         proto_tree_add_item(sub_tree, hf_rng_rsp_location_update_response, tvb, tlv_offset, 1, FALSE);
887                                         break;
888                                 case RNG_RSP_PAGING_INFORMATION:
889                                         sub_tree = add_tlv_subtree(&tlv_info, ett_rng_rsp_message_tree, rng_rsp_tree, hf_rng_rsp_paging_information, tvb, tlv_offset, 5, FALSE);
890                                         proto_tree_add_item(sub_tree, hf_rng_rsp_paging_cycle, tvb, tlv_offset, 2, FALSE);
891                                         proto_tree_add_item(sub_tree, hf_rng_rsp_paging_offset, tvb, tlv_offset+2, 1, FALSE);
892                                         proto_tree_add_item(sub_tree, hf_rng_rsp_paging_group_id, tvb, tlv_offset+3, 2, FALSE);
893                                         break;
894                                 case RNG_RSP_POWER_SAVING_CLASS_PARAMETERS:
895                                         sub_tree = add_protocol_subtree(&tlv_info, ett_rng_rsp_message_tree, rng_rsp_tree, proto_mac_mgmt_msg_rng_rsp_decoder, tvb, tlv_offset, tlv_len, "Power Saving Class Parameters (%u byte(s))", tlv_len);
896                                         dissect_power_saving_class(sub_tree, tlv_type, tvb, tlv_len, pinfo, tlv_offset);
897                                         break;
898                                 case RNG_RSP_SA_CHALLENGE_TUPLE:
899                                         /* Display SA Challenge Tuple header */
900                                         sub_tree = add_protocol_subtree(&tlv_info, ett_rng_rsp_message_tree, rng_rsp_tree, proto_mac_mgmt_msg_rng_rsp_decoder, tvb, tlv_offset, tlv_len, "SA Challenge Tuple (%u byte(s))", tlv_len);
901                                         /* add subtree */
902                                         /* Use a local copy of tlv_offset */
903                                         this_offset = tlv_offset;
904                                         while(this_offset < tlv_len) {
905                                                 /* Get the sub TLV data. */
906                                                 init_tlv_info(&sub_tlv_info, tvb, this_offset);
907                                                 /* get the sub TLV type */
908                                                 sub_tlv_type = get_tlv_type(&sub_tlv_info);
909                                                 /* get the TLV length */
910                                                 sub_tlv_len = get_tlv_length(&sub_tlv_info);
911                                                 if(tlv_type == -1 || sub_tlv_len > MAX_TLV_LEN || sub_tlv_len < 1)
912                                                 {       /* invalid tlv info */
913                                                         if(pinfo->cinfo)
914                                                         {
915                                                                 col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "RNG-RSP TLV error");
916                                                         }
917                                                         proto_tree_add_item(rng_rsp_tree, hf_rng_invalid_tlv, tvb, tlv_offset, (tvb_len - offset), FALSE);
918                                                         break;
919                                                 }
920                                                 /* get the offset to the sub TLV data */
921                                                 sub_tlv_offset = this_offset + get_tlv_value_offset(&sub_tlv_info);
922                                                 switch (sub_tlv_type) {
923                                                         case RNG_RSP_SA_CHALLENGE_BS_RANDOM:
924                                                                 tlv_tree = add_tlv_subtree(&sub_tlv_info, ett_rng_rsp_message_tree, sub_tree, hf_rng_rsp_bs_random, tvb, sub_tlv_offset, sub_tlv_len, FALSE);
925                                                                 proto_tree_add_item(tlv_tree, hf_rng_rsp_bs_random, tvb, sub_tlv_offset, sub_tlv_len, FALSE);
926                                                                 break;
927                                                         case RNG_RSP_SA_CHALLENGE_AKID:
928                                                                 tlv_tree = add_tlv_subtree(&sub_tlv_info, ett_rng_rsp_message_tree, sub_tree, hf_rng_rsp_akid, tvb, sub_tlv_offset, sub_tlv_len, FALSE);
929                                                                 proto_tree_add_item(tlv_tree, hf_rng_rsp_akid, tvb, sub_tlv_offset, sub_tlv_len, FALSE);
930                                                                 break;
931                                                         default:
932                                                                 tlv_tree = add_tlv_subtree(&sub_tlv_info, ett_rng_rsp_message_tree, sub_tree, hf_tlv_type, tvb, sub_tlv_offset, sub_tlv_len, FALSE);
933                                                                 proto_tree_add_item(tlv_tree, hf_tlv_type, tvb, sub_tlv_offset, sub_tlv_len, FALSE);
934                                                                 break;
935                                                 }
936                                                 this_offset = sub_tlv_len + sub_tlv_offset;
937                                         }
938                                         break;
939                                 case DSx_UPLINK_FLOW:
940                                         /* display Uplink Service Flow Encodings info */
941                                         /* add subtree */
942                                         sub_tree = add_protocol_subtree(&tlv_info, ett_mac_mgmt_msg_rng_rsp_decoder, rng_rsp_tree, proto_mac_mgmt_msg_rng_rsp_decoder, tvb, tlv_offset, tlv_len, "Uplink QOS Parameters (%u bytes)", tlv_len);
943                                         /* decode and display the DL Service Flow Encodings */
944                                         wimax_service_flow_encodings_decoder(tvb_new_subset(tvb, tlv_offset, tlv_len, tlv_len), pinfo, sub_tree);
945                                         break;
946                                 case DSx_DOWNLINK_FLOW:
947                                         /* display Downlink Service Flow Encodings info */
948                                         /* add subtree */
949                                         sub_tree = add_protocol_subtree(&tlv_info, ett_mac_mgmt_msg_rng_rsp_decoder, rng_rsp_tree, proto_mac_mgmt_msg_rng_rsp_decoder, tvb, tlv_offset, tlv_len, "Downlink QOS Parameters (%u bytes)", tlv_len);
950                                         /* decode and display the DL Service Flow Encodings */
951                                         wimax_service_flow_encodings_decoder(tvb_new_subset(tvb, tlv_offset, tlv_len, tlv_len), pinfo, sub_tree);
952                                         break;
953                                 case RNG_RSP_RANGING_CODE_ATTRIBUTES:
954                                 /* case SHORT_HMAC_TUPLE: */
955                                         sub_tree = add_tlv_subtree(&tlv_info, ett_rng_rsp_message_tree, rng_rsp_tree, hf_rng_rsp_ranging_subchan, tvb, tlv_offset, 4, FALSE);
956                                         proto_tree_add_item(sub_tree, hf_rng_rsp_time_symbol_reference, tvb, tlv_offset, 4, FALSE);
957                                         proto_tree_add_item(sub_tree, hf_rng_rsp_subchannel_reference, tvb, tlv_offset, 4, FALSE);
958                                         proto_tree_add_item(sub_tree, hf_rng_rsp_ranging_code_index, tvb, tlv_offset, 4, FALSE);
959                                         proto_tree_add_item(sub_tree, hf_rng_rsp_frame_number2, tvb, tlv_offset, 4, FALSE);
960                                         break;
961                                 case SHORT_HMAC_TUPLE_COR2:
962                                         if (include_cor2_changes) {
963                                                 sub_tree = add_protocol_subtree(&tlv_info, ett_rng_rsp_message_tree, rng_rsp_tree, proto_mac_mgmt_msg_rng_rsp_decoder, tvb, tlv_offset, tlv_len, "Short HMAC Tuple (%u byte(s))", tlv_len);
964                                                 wimax_short_hmac_tuple_decoder(sub_tree, tvb, tlv_offset, tvb_len - offset);
965                                         } else {
966                                                 /* Unknown TLV type */
967                                                 sub_tree = add_tlv_subtree(&tlv_info, ett_rng_rsp_message_tree, rng_rsp_tree, hf_tlv_type, tvb, tlv_offset, 1, FALSE);
968                                                 proto_tree_add_item(sub_tree, hf_tlv_type, tvb, tlv_offset, tlv_len, FALSE);
969                                         }
970                                         break;
971                         
972                                 default:
973                                         sub_tree = add_tlv_subtree(&tlv_info, ett_rng_rsp_message_tree, rng_rsp_tree, hf_tlv_type, tvb, tlv_offset, 1, FALSE);
974                                         proto_tree_add_item(sub_tree, hf_tlv_type, tvb, tlv_offset, tlv_len, FALSE);
975                                         break;
976                                         
977                         }
978                         offset = tlv_len + tlv_offset;
979                 }       /* end of TLV process while loop */
980                 if (ranging_status_item && dl_freq_override_item)
981                         proto_item_append_text(ranging_status_item, " (shall be set to 2 because Downlink Frequency Override is present)");
982                 if (ss_mac_address_item && frame_number_item) {
983                         proto_item_append_text(frame_number_item, " (mutually exclusive with SS MAC Address!)");
984                         proto_item_append_text(ss_mac_address_item, " (mutually exclusive with Frame Number!)");
985                 }
986                 if (ss_mac_address_item && opportunity_number_item) {
987                         proto_item_append_text(opportunity_number_item, " (mutually exclusive with SS MAC Address!)");
988                         proto_item_append_text(ss_mac_address_item, " (mutually exclusive with Initial Ranging Opportunity Number!)");
989                 }
990                 if (!ranging_status_item)
991                         proto_item_append_text(rng_rsp_tree, " (Ranging status is missing!)");
992
993         }
994 }
995