MSWSP: fix dissect_mswsp_smb()
[wireshark-wip.git] / plugins / wimax / msg_rng_rsp.c
blob9508900aea95ad8d386e312cd3ee55d93134cc40
1 /* msg_rng_rsp.c
2 * WiMax MAC Management RNG-RSP Message decoder
4 * Copyright (c) 2007 by Intel Corporation.
6 * Author: John R. Underwood <junderx@yahoo.com>
8 * $Id$
10 * Wireshark - Network traffic analyzer
11 * By Gerald Combs <gerald@wireshark.org>
12 * Copyright 1999 Gerald Combs
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.
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.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 /* Include files */
31 #include "config.h"
33 #include <glib.h>
34 #include <epan/packet.h>
35 #include "crc.h"
36 #include "wimax_tlv.h"
37 #include "wimax_mac.h"
38 #include "wimax_utils.h"
40 extern gboolean include_cor2_changes;
42 /* external reference */
43 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);
45 static dissector_handle_t sbc_rsp_handle = NULL;
46 static dissector_handle_t reg_rsp_handle = NULL;
48 static gint proto_mac_mgmt_msg_rng_rsp_decoder = -1;
49 static gint ett_mac_mgmt_msg_rng_rsp_decoder = -1;
50 static gint ett_rng_rsp_message_tree = -1;
52 /* RNG-RSP fields */
53 static gint hf_rng_req_reserved = -1;
54 /* static gint hf_rng_rsp_ul_channel_id = -1; */
55 static gint hf_rng_rsp_timing_adjust = -1;
56 static gint hf_rng_rsp_power_level_adjust = -1;
57 static gint hf_rng_rsp_offset_freq_adjust = -1;
58 static gint hf_rng_rsp_ranging_status = -1;
59 static gint hf_rng_rsp_dl_freq_override = -1;
60 static gint hf_rng_rsp_ul_chan_id_override = -1;
61 static gint hf_rng_rsp_dl_operational_burst_profile = -1;
62 static gint hf_rng_rsp_dl_operational_burst_profile_diuc = -1;
63 static gint hf_rng_rsp_dl_operational_burst_profile_ccc = -1;
64 static gint hf_rng_rsp_ss_mac_address = -1;
65 static gint hf_rng_rsp_basic_cid = -1;
66 static gint hf_rng_rsp_primary_mgmt_cid = -1;
67 static gint hf_rng_rsp_broadcast = -1;
68 static gint hf_rng_rsp_frame_number = -1;
69 static gint hf_rng_rsp_opportunity_number = -1;
70 static gint hf_rng_rsp_service_level_prediction = -1;
71 static gint hf_rng_rsp_resource_retain_flag = -1;
72 static gint hf_rng_rsp_ho_process_optimization = -1;
73 static gint hf_rng_rsp_ho_process_optimization_0 = -1;
74 static gint hf_rng_rsp_ho_process_optimization_1_2 = -1;
75 static gint hf_rng_rsp_ho_process_optimization_3 = -1;
76 static gint hf_rng_rsp_ho_process_optimization_4 = -1;
77 static gint hf_rng_rsp_ho_process_optimization_5 = -1;
78 static gint hf_rng_rsp_ho_process_optimization_6 = -1;
79 static gint hf_rng_rsp_ho_process_optimization_7 = -1;
80 static gint hf_rng_rsp_ho_process_optimization_8 = -1;
81 static gint hf_rng_rsp_ho_process_optimization_9 = -1;
82 static gint hf_rng_rsp_ho_process_optimization_10 = -1;
83 static gint hf_rng_rsp_ho_process_optimization_11 = -1;
84 static gint hf_rng_rsp_ho_process_optimization_12 = -1;
85 static gint hf_rng_rsp_ho_process_optimization_13 = -1;
86 static gint hf_rng_rsp_ho_process_optimization_14 = -1;
87 static gint hf_rng_rsp_ho_process_optimization_15 = -1;
88 /* Added the following to help implement RNG-RSP message encoding 33 (Table 367 in IEEE 802.16e-2007) */
89 static gint hf_rng_rsp_dl_op_burst_profile_ofdma = -1;
90 static gint hf_rng_rsp_least_robust_diuc = -1;
91 static gint hf_rng_rsp_repetition_coding_indication = -1;
92 static gint hf_rng_rsp_config_change_count_of_dcd = -1;
93 /* Added the following to help implement RNG-RSP message encoding 22 (Table 367 in IEEE 802.16e-2007) */
94 static gint hf_rng_rsp_ho_id = -1;
95 static gint hf_rng_rsp_location_update_response = -1;
96 /* Added the following to help implement RNG-RSP message encoding 24 (Table 367 in IEEE 802.16e-2007) */
97 static gint hf_rng_rsp_paging_information = -1;
98 static gint hf_rng_rsp_paging_cycle = -1;
99 static gint hf_rng_rsp_paging_offset = -1;
100 static gint hf_rng_rsp_paging_group_id = -1;
101 static gint hf_rng_rsp_bs_random = -1;
102 static gint hf_rng_rsp_akid = -1;
103 static gint hf_rng_rsp_ranging_subchan = -1;
104 static gint hf_rng_rsp_time_symbol_reference = -1;
105 static gint hf_rng_rsp_subchannel_reference = -1;
106 static gint hf_rng_rsp_ranging_code_index = -1;
107 static gint hf_rng_rsp_frame_number2 = -1;
108 static gint hf_tlv_type = -1;
109 /* static gint hf_tlv_value = -1; */
110 static gint hf_rng_invalid_tlv = -1;
112 /* STRING RESOURCES */
114 static const true_false_string tfs_rng_rsp_aas_broadcast = {
115 "SS shall not issue contention-based Bandwidth Request",
116 "SS may issue contention-based Bandwidth Request"
119 static const true_false_string tfs_rng_rsp_resource_retain_flag = {
120 "Retained by the BS",
121 "Deleted by the BS"
124 static const value_string vals_rng_rsp_ranging_status[] = {
125 {1, "continue"},
126 {2, "abort"},
127 {3, "success"},
128 {4, "rerange"},
129 {0, NULL}
132 static const value_string vals_rng_rsp_level_of_service[] = {
133 {0, "No service possible for this MS"},
134 {1, "Some service is available for one or"
135 " several service flows authorized for the MS"},
136 {2, "For each authorized service flow, a MAC"
137 " connection can be established with QoS"
138 " specified by the AuthorizedQoSParamSet"},
139 {3, "No service level prediction available"},
140 {0, NULL}
143 static const value_string vals_rng_rsp_ho_process_optimization_0[] = {
144 {0, "SBC-REQ management messages during current re-entry"
145 " processing required"},
146 {1, "Omit SBC-REQ management messages during current"
147 " re-entry processing"},
148 {0, NULL},
151 static const value_string vals_rng_rsp_ho_process_optimization_1_2[] = {
152 {0, "Perform re-authentication and SA-TEK 3-way handshake."
153 " BS should include SA-TEK-Update TLV in the"
154 " SA-TEK-Response message. In addition, the RNG-RSP"
155 " message does not include SA-TEK-Update TLV or SA"
156 " Challenge Tuple TLV."},
157 {1, "SA-TEK-Update TLV is included in the RNG-RSP message."
158 " In this case, SA-TEK 3-way handshake is avoided and"
159 " SA Challenge Tuple TLV shall not be included in the"
160 " RNG-RSP message."},
161 {2, "Reserved"},
162 {3, "Re-authentication and SA-TEK 3-way handshake is not"
163 " performed. The RNG-RSP message does not include"
164 " SA-TEK-Update TLV nor SA Challenge Tuple TLV. All the"
165 " TEKs received from the serving BS are reused"},
166 {0, NULL}
169 static const value_string vals_rng_rsp_ho_process_optimization_3[] = {
170 {0, "Network Address Acquisition management messages during"
171 " current reentry processing required"},
172 {1, "Omit Network Address Acquisition management messages"
173 " during current reentry processing"},
174 {0, NULL}
177 static const value_string vals_rng_rsp_ho_process_optimization_4[] = {
178 {0, "Time of Day Acquisition management messages during"
179 " current reentry processing required"},
180 {1, "Omit Time of Day Acquisition management messages"
181 " during current reentry processing"},
182 {0, NULL}
185 static const value_string vals_rng_rsp_ho_process_optimization_5[] = {
186 {0, "TFTP management messages during current re-entry"
187 " processing required"},
188 {1, "Omit TFTP management messages during current re-entry"
189 " processing"},
190 {0, NULL}
193 static const value_string vals_rng_rsp_ho_process_optimization_6[] = {
194 {0, "Full service and operational state transfer or sharing"
195 " between Serving BS and Target BS required"},
196 {1, "Omit Full service and operational state transfer or"
197 " sharing between Serving BS and Target BS"},
198 {0, NULL}
201 static const value_string vals_rng_rsp_ho_process_optimization_7[] = {
202 {0, "REG-REQ management message during current re-entry"
203 " processing required"},
204 {1, "Omit REG-REQ management message during current re-entry"
205 " processing"},
206 {0, NULL}
209 static const value_string vals_rng_rsp_ho_process_optimization_8[] = {
210 {0, "BS shall send not send an unsolicited SBC-RSP"
211 " management message"},
212 {1, "BS shall send an unsolicited SBC-RSP management message"},
213 {0, NULL}
216 static const value_string vals_rng_rsp_ho_process_optimization_9[] = {
217 {0, "No post-HO re-entry MS DL data pending at target BS"},
218 {1, "post-HO re-entry MS DL data pending at target BS"},
219 {0, NULL}
222 static const value_string vals_rng_rsp_ho_process_optimization_10[] = {
223 {0, "BS shall not send an unsolicited REG-RSP management"
224 " message"},
225 {1, "BS shall send an unsolicited REG-RSP management message"},
226 {0, NULL}
229 static const value_string vals_rng_rsp_ho_process_optimization_11[] = {
230 {0, "(Target) BS does not support virtual SDU SN"},
231 {1, "(Target} BS supports virtual SDU SN"},
232 {0, NULL}
235 static const value_string vals_rng_rsp_ho_process_optimization_12[] = {
236 {0, "MS shall not send a notification of MS's successful"
237 " re-entry registration"},
238 {1, "MS shall send a notification of MS's successful"
239 " re-entry registration"},
240 {0, NULL}
243 static const value_string vals_rng_rsp_ho_process_optimization_13[] = {
244 {0, "MS shall not trigger a higher layer protocol required"
245 " to refresh its traffic IP address"},
246 {1, "MS shall trigger a higher layer protocol required to"
247 " refresh its traffic IP address"},
248 {0, NULL}
251 static const value_string vals_rng_rsp_repetition_coding_indication[] = {
252 {0, "No repetition coding"},
253 {1, "Repetition coding of 2"},
254 {2, "Repetition coding of 4"},
255 {3, "Repetition coding of 6"},
256 {0, NULL}
259 static const value_string vals_rng_rsp_location_update_response[] = {
260 {0, "Success of Location Update"},
261 {1, "Failure of Location Update"},
262 {3, "Success of location update and DL traffic pending"},
263 {4, "Reserved"},
264 {0, NULL}
268 /* Decode RNG-RSP messages. */
269 static void dissect_mac_mgmt_msg_rng_rsp_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
271 proto_item *ranging_status_item = NULL;
272 proto_item *dl_freq_override_item = NULL;
273 proto_item *ss_mac_address_item = NULL;
274 proto_item *frame_number_item = NULL;
275 proto_item *opportunity_number_item = NULL;
277 guint offset = 0;
278 guint tlv_offset;
279 guint tvb_len;
280 proto_item *rng_rsp_item, *sub_item;
281 proto_item *tlv_item = NULL;
282 proto_tree *rng_rsp_tree;
283 proto_tree *sub_tree = NULL;
284 tlv_info_t tlv_info;
285 gint tlv_type;
286 guint tlv_len;
287 guint this_offset = 0;
288 tlv_info_t sub_tlv_info;
289 gint sub_tlv_type;
290 gint sub_tlv_len;
291 guint sub_tlv_offset;
292 float timing_adjust;
293 float power_level_adjust;
295 { /* we are being asked for details */
297 /* Get the tvb reported length */
298 tvb_len = tvb_reported_length(tvb);
299 /* display MAC payload type RNG-RSP */
300 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");
301 /* add MAC RNG-RSP subtree */
302 rng_rsp_tree = proto_item_add_subtree(rng_rsp_item, ett_mac_mgmt_msg_rng_rsp_decoder);
304 proto_tree_add_item(rng_rsp_tree, hf_rng_req_reserved, tvb, offset, 1, ENC_BIG_ENDIAN);
305 offset += 1;
307 while(offset < tvb_len)
309 /* Get the TLV data. */
310 init_tlv_info(&tlv_info, tvb, offset);
311 /* get the TLV type */
312 tlv_type = get_tlv_type(&tlv_info);
313 /* get the TLV length */
314 tlv_len = get_tlv_length(&tlv_info);
315 if(tlv_type == -1 || tlv_len > MAX_TLV_LEN || tlv_len < 1)
316 { /* invalid tlv info */
317 col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "RNG-RSP TLV error");
318 proto_tree_add_item(rng_rsp_tree, hf_rng_invalid_tlv, tvb, offset, (tvb_len - offset), ENC_NA);
319 break;
321 /* get the offset to the TLV data */
322 tlv_offset = offset + get_tlv_value_offset(&tlv_info);
324 switch (tlv_type) {
325 case RNG_RSP_TIMING_ADJUST: {
326 sub_tree = add_tlv_subtree_no_item(&tlv_info, rng_rsp_tree, hf_rng_rsp_timing_adjust, tvb, offset);
327 timing_adjust = (float)(tvb_get_ntohl(tvb, tlv_offset) / 4.0);
328 tlv_item = proto_tree_add_float_format_value(sub_tree, hf_rng_rsp_timing_adjust, tvb,
329 tlv_offset, 4, timing_adjust, " %.2f modulation symbols", timing_adjust);
330 if ((timing_adjust < -2) || (timing_adjust > 2))
331 proto_item_append_text(tlv_item, " (during periodic ranging shall not exceed +- 2)");
332 break;
334 case RNG_RSP_POWER_LEVEL_ADJUST: {
335 sub_tree = add_tlv_subtree_no_item(&tlv_info, rng_rsp_tree, hf_rng_rsp_power_level_adjust, tvb, offset);
336 power_level_adjust = (float)(tvb_get_guint8(tvb, tlv_offset) / 4.0);
337 proto_tree_add_float_format_value(sub_tree, hf_rng_rsp_power_level_adjust, tvb, tlv_offset, 1,
338 power_level_adjust, " %.2f dB", power_level_adjust);
339 break;
341 case RNG_RSP_OFFSET_FREQ_ADJUST: {
342 tlv_item = add_tlv_subtree(&tlv_info, rng_rsp_tree, hf_rng_rsp_offset_freq_adjust, tvb, offset, ENC_BIG_ENDIAN);
343 proto_item_append_text(tlv_item, " Hz");
344 break;
346 case RNG_RSP_RANGING_STATUS:
347 ranging_status_item = add_tlv_subtree(&tlv_info, rng_rsp_tree, hf_rng_rsp_ranging_status, tvb, offset, ENC_BIG_ENDIAN);
348 break;
349 case RNG_RSP_DL_FREQ_OVERRIDE: {
350 dl_freq_override_item = add_tlv_subtree(&tlv_info, rng_rsp_tree, hf_rng_rsp_dl_freq_override, tvb, offset, ENC_BIG_ENDIAN);
351 proto_item_append_text(dl_freq_override_item, " kHz");
352 break;
354 case RNG_RSP_UL_CHANNEL_ID_OVERRIDE:
355 add_tlv_subtree(&tlv_info, rng_rsp_tree, hf_rng_rsp_ul_chan_id_override, tvb, offset, ENC_BIG_ENDIAN);
356 break;
357 case RNG_RSP_DL_OPERATIONAL_BURST_PROFILE:
358 sub_item = add_tlv_subtree(&tlv_info, rng_rsp_tree, hf_rng_rsp_dl_operational_burst_profile, tvb, offset, ENC_BIG_ENDIAN);
359 sub_tree = proto_item_add_subtree(sub_item, ett_rng_rsp_message_tree);
360 proto_tree_add_item(sub_tree, hf_rng_rsp_dl_operational_burst_profile_diuc, tvb, tlv_offset, 2, ENC_BIG_ENDIAN);
361 proto_tree_add_item(sub_tree, hf_rng_rsp_dl_operational_burst_profile_ccc, tvb, tlv_offset, 2, ENC_BIG_ENDIAN);
362 break;
363 case RNG_RSP_SS_MAC_ADDRESS:
364 if (tlv_len == 6)
366 add_tlv_subtree(&tlv_info, rng_rsp_tree, hf_rng_rsp_ss_mac_address, tvb, offset, ENC_NA);
367 } else {
368 add_tlv_subtree(&tlv_info, rng_rsp_tree, hf_rng_invalid_tlv, tvb, offset, ENC_NA);
370 break;
371 case RNG_RSP_BASIC_CID:
372 add_tlv_subtree(&tlv_info, rng_rsp_tree, hf_rng_rsp_basic_cid, tvb, offset, ENC_BIG_ENDIAN);
373 break;
374 case RNG_RSP_PRIMARY_MGMT_CID:
375 add_tlv_subtree(&tlv_info, rng_rsp_tree, hf_rng_rsp_primary_mgmt_cid, tvb, offset, ENC_BIG_ENDIAN);
376 break;
377 case RNG_RSP_AAS_BROADCAST_PERMISSION:
378 add_tlv_subtree(&tlv_info, rng_rsp_tree, hf_rng_rsp_broadcast, tvb, offset, ENC_BIG_ENDIAN);
379 break;
380 case RNG_RSP_FRAME_NUMBER:
381 frame_number_item = add_tlv_subtree(&tlv_info, rng_rsp_tree, hf_rng_rsp_frame_number, tvb, offset, ENC_BIG_ENDIAN);
382 break;
383 case RNG_RSP_OPPORTUNITY_NUMBER:
384 opportunity_number_item = add_tlv_subtree(&tlv_info, rng_rsp_tree, hf_rng_rsp_opportunity_number, tvb, offset, ENC_BIG_ENDIAN);
385 if (tvb_get_ntohl(tvb, tlv_offset) == 0)
386 proto_item_append_text(opportunity_number_item, " (may not be 0!)");
387 break;
388 case RNG_RSP_SERVICE_LEVEL_PREDICTION:
389 add_tlv_subtree(&tlv_info, rng_rsp_tree, hf_rng_rsp_service_level_prediction, tvb, offset, ENC_BIG_ENDIAN);
390 break;
391 case RNG_RSP_RESOURCE_RETAIN_FLAG:
392 add_tlv_subtree(&tlv_info, rng_rsp_tree, hf_rng_rsp_resource_retain_flag, tvb, offset, ENC_BIG_ENDIAN);
393 break;
394 case RNG_RSP_HO_PROCESS_OPTIMIZATION:
395 sub_item = add_tlv_subtree(&tlv_info, rng_rsp_tree, hf_rng_rsp_ho_process_optimization, tvb, offset, ENC_BIG_ENDIAN);
396 sub_tree = proto_item_add_subtree(sub_item, ett_rng_rsp_message_tree);
397 proto_tree_add_item(sub_tree, hf_rng_rsp_ho_process_optimization_0, tvb, tlv_offset, 2, ENC_BIG_ENDIAN);
398 proto_tree_add_item(sub_tree, hf_rng_rsp_ho_process_optimization_1_2, tvb, tlv_offset, 2, ENC_BIG_ENDIAN);
399 proto_tree_add_item(sub_tree, hf_rng_rsp_ho_process_optimization_3, tvb, tlv_offset, 2, ENC_BIG_ENDIAN);
400 proto_tree_add_item(sub_tree, hf_rng_rsp_ho_process_optimization_4, tvb, tlv_offset, 2, ENC_BIG_ENDIAN);
401 proto_tree_add_item(sub_tree, hf_rng_rsp_ho_process_optimization_5, tvb, tlv_offset, 2, ENC_BIG_ENDIAN);
402 proto_tree_add_item(sub_tree, hf_rng_rsp_ho_process_optimization_6, tvb, tlv_offset, 2, ENC_BIG_ENDIAN);
403 proto_tree_add_item(sub_tree, hf_rng_rsp_ho_process_optimization_7, tvb, tlv_offset, 2, ENC_BIG_ENDIAN);
404 proto_tree_add_item(sub_tree, hf_rng_rsp_ho_process_optimization_8, tvb, tlv_offset, 2, ENC_BIG_ENDIAN);
405 proto_tree_add_item(sub_tree, hf_rng_rsp_ho_process_optimization_9, tvb, tlv_offset, 2, ENC_BIG_ENDIAN);
406 proto_tree_add_item(sub_tree, hf_rng_rsp_ho_process_optimization_10, tvb, tlv_offset, 2, ENC_BIG_ENDIAN);
407 proto_tree_add_item(sub_tree, hf_rng_rsp_ho_process_optimization_11, tvb, tlv_offset, 2, ENC_BIG_ENDIAN);
408 proto_tree_add_item(sub_tree, hf_rng_rsp_ho_process_optimization_12, tvb, tlv_offset, 2, ENC_BIG_ENDIAN);
409 proto_tree_add_item(sub_tree, hf_rng_rsp_ho_process_optimization_13, tvb, tlv_offset, 2, ENC_BIG_ENDIAN);
410 proto_tree_add_item(sub_tree, hf_rng_rsp_ho_process_optimization_14, tvb, tlv_offset, 2, ENC_BIG_ENDIAN);
411 proto_tree_add_item(sub_tree, hf_rng_rsp_ho_process_optimization_15, tvb, tlv_offset, 2, ENC_BIG_ENDIAN);
412 break;
413 case RNG_RSP_SBC_RSP_ENCODINGS:
414 sub_tree = add_protocol_subtree(&tlv_info, ett_rng_rsp_message_tree, rng_rsp_tree, proto_mac_mgmt_msg_rng_rsp_decoder, tvb, offset, tlv_len, "SBC-RSP Encodings");
415 call_dissector(sbc_rsp_handle, tvb_new_subset_length(tvb, tlv_offset, tlv_len), pinfo, sub_tree);
416 break;
417 case RNG_RSP_REG_RSP_ENCODINGS:
418 sub_tree = add_protocol_subtree(&tlv_info, ett_rng_rsp_message_tree, rng_rsp_tree, proto_mac_mgmt_msg_rng_rsp_decoder, tvb, offset, tlv_len, "REG-RSP Encodings");
419 call_dissector(reg_rsp_handle, tvb_new_subset_length(tvb, tlv_offset, tlv_len), pinfo, sub_tree);
420 break;
421 /* Implemented message encoding 33 (Table 367 in IEEE 802.16e-2007) */
422 case RNG_RSP_DL_OP_BURST_PROFILE_OFDMA:
423 sub_item = add_tlv_subtree(&tlv_info, rng_rsp_tree, hf_rng_rsp_dl_op_burst_profile_ofdma, tvb, offset, ENC_BIG_ENDIAN);
424 sub_tree = proto_item_add_subtree(sub_item, ett_rng_rsp_message_tree);
425 proto_tree_add_item(sub_tree, hf_rng_rsp_least_robust_diuc, tvb, tlv_offset, 2, ENC_BIG_ENDIAN);
426 proto_tree_add_item(sub_tree, hf_rng_rsp_repetition_coding_indication, tvb, tlv_offset, 2, ENC_BIG_ENDIAN);
427 proto_tree_add_item(sub_tree, hf_rng_rsp_config_change_count_of_dcd, tvb, tlv_offset, 2, ENC_BIG_ENDIAN);
428 break;
429 case RNG_RSP_HO_ID:
430 add_tlv_subtree(&tlv_info, rng_rsp_tree, hf_rng_rsp_ho_id, tvb, offset, ENC_BIG_ENDIAN);
431 break;
432 case RNG_RSP_LOCATION_UPDATE_RESPONSE:
433 add_tlv_subtree(&tlv_info, rng_rsp_tree, hf_rng_rsp_location_update_response, tvb, offset, ENC_BIG_ENDIAN);
434 break;
435 case RNG_RSP_PAGING_INFORMATION:
436 sub_item = add_tlv_subtree(&tlv_info, rng_rsp_tree, hf_rng_rsp_paging_information, tvb, offset, ENC_NA);
437 sub_tree = proto_item_add_subtree(sub_item, ett_rng_rsp_message_tree);
438 proto_tree_add_item(sub_tree, hf_rng_rsp_paging_cycle, tvb, tlv_offset, 2, ENC_BIG_ENDIAN);
439 proto_tree_add_item(sub_tree, hf_rng_rsp_paging_offset, tvb, tlv_offset+2, 1, ENC_BIG_ENDIAN);
440 proto_tree_add_item(sub_tree, hf_rng_rsp_paging_group_id, tvb, tlv_offset+3, 2, ENC_BIG_ENDIAN);
441 break;
442 case RNG_RSP_POWER_SAVING_CLASS_PARAMETERS:
443 sub_tree = add_protocol_subtree(&tlv_info, ett_rng_rsp_message_tree, rng_rsp_tree, proto_mac_mgmt_msg_rng_rsp_decoder, tvb, offset, tlv_len, "Power Saving Class Parameters");
444 dissect_power_saving_class(sub_tree, tlv_type, tvb, tlv_len, pinfo, tlv_offset);
445 break;
446 case RNG_RSP_SA_CHALLENGE_TUPLE:
447 /* Display SA Challenge Tuple header */
448 sub_tree = add_protocol_subtree(&tlv_info, ett_rng_rsp_message_tree, rng_rsp_tree, proto_mac_mgmt_msg_rng_rsp_decoder, tvb, offset, tlv_len, "SA Challenge Tuple");
449 /* add subtree */
450 /* Use a local copy of tlv_offset */
451 this_offset = tlv_offset;
452 while(this_offset < tlv_len) {
453 /* Get the sub TLV data. */
454 init_tlv_info(&sub_tlv_info, tvb, this_offset);
455 /* get the sub TLV type */
456 sub_tlv_type = get_tlv_type(&sub_tlv_info);
457 /* get the TLV length */
458 sub_tlv_len = get_tlv_length(&sub_tlv_info);
459 if(tlv_type == -1 || sub_tlv_len > MAX_TLV_LEN || sub_tlv_len < 1)
460 { /* invalid tlv info */
461 col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "RNG-RSP TLV error");
462 proto_tree_add_item(rng_rsp_tree, hf_rng_invalid_tlv, tvb, tlv_offset, (tvb_len - offset), ENC_NA);
463 break;
465 /* get the offset to the sub TLV data */
466 sub_tlv_offset = this_offset + get_tlv_value_offset(&sub_tlv_info);
467 switch (sub_tlv_type) {
468 case RNG_RSP_SA_CHALLENGE_BS_RANDOM:
469 add_tlv_subtree(&sub_tlv_info, sub_tree, hf_rng_rsp_bs_random, tvb, this_offset, ENC_NA);
470 break;
471 case RNG_RSP_SA_CHALLENGE_AKID:
472 add_tlv_subtree(&sub_tlv_info, sub_tree, hf_rng_rsp_akid, tvb, this_offset, ENC_NA);
473 break;
474 default:
475 add_tlv_subtree(&sub_tlv_info, sub_tree, hf_tlv_type, tvb, this_offset, ENC_NA);
476 break;
478 this_offset = sub_tlv_len + sub_tlv_offset;
480 break;
481 case DSx_UPLINK_FLOW:
482 /* display Uplink Service Flow Encodings info */
483 /* add subtree */
484 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, offset, tlv_len, "Uplink QOS Parameters");
485 /* decode and display the DL Service Flow Encodings */
486 wimax_service_flow_encodings_decoder(tvb_new_subset_length(tvb, tlv_offset, tlv_len), pinfo, sub_tree);
487 break;
488 case DSx_DOWNLINK_FLOW:
489 /* display Downlink Service Flow Encodings info */
490 /* add subtree */
491 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, offset, tlv_len, "Downlink QOS Parameters");
492 /* decode and display the DL Service Flow Encodings */
493 wimax_service_flow_encodings_decoder(tvb_new_subset_length(tvb, tlv_offset, tlv_len), pinfo, sub_tree);
494 break;
495 case RNG_RSP_RANGING_CODE_ATTRIBUTES:
496 /* case SHORT_HMAC_TUPLE: */
497 sub_item = add_tlv_subtree(&tlv_info, rng_rsp_tree, hf_rng_rsp_ranging_subchan, tvb, offset, ENC_BIG_ENDIAN);
498 sub_tree = proto_item_add_subtree(sub_item, ett_rng_rsp_message_tree);
499 proto_tree_add_item(sub_tree, hf_rng_rsp_time_symbol_reference, tvb, tlv_offset, 4, ENC_BIG_ENDIAN);
500 proto_tree_add_item(sub_tree, hf_rng_rsp_subchannel_reference, tvb, tlv_offset, 4, ENC_BIG_ENDIAN);
501 proto_tree_add_item(sub_tree, hf_rng_rsp_ranging_code_index, tvb, tlv_offset, 4, ENC_BIG_ENDIAN);
502 proto_tree_add_item(sub_tree, hf_rng_rsp_frame_number2, tvb, tlv_offset, 4, ENC_BIG_ENDIAN);
503 break;
504 case SHORT_HMAC_TUPLE_COR2:
505 if (include_cor2_changes) {
506 sub_tree = add_protocol_subtree(&tlv_info, ett_rng_rsp_message_tree, rng_rsp_tree, proto_mac_mgmt_msg_rng_rsp_decoder, tvb, offset, tlv_len, "Short HMAC Tuple");
507 wimax_short_hmac_tuple_decoder(sub_tree, tvb, tlv_offset, tvb_len - offset);
508 } else {
509 /* Unknown TLV type */
510 add_tlv_subtree(&tlv_info, rng_rsp_tree, hf_tlv_type, tvb, offset, ENC_NA);
512 break;
514 default:
515 add_tlv_subtree(&tlv_info, rng_rsp_tree, hf_tlv_type, tvb, offset, ENC_NA);
516 break;
519 offset = tlv_len + tlv_offset;
520 } /* end of TLV process while loop */
521 if (ranging_status_item && dl_freq_override_item)
522 proto_item_append_text(ranging_status_item, " (shall be set to 2 because Downlink Frequency Override is present)");
523 if (ss_mac_address_item && frame_number_item) {
524 proto_item_append_text(frame_number_item, " (mutually exclusive with SS MAC Address!)");
525 proto_item_append_text(ss_mac_address_item, " (mutually exclusive with Frame Number!)");
527 if (ss_mac_address_item && opportunity_number_item) {
528 proto_item_append_text(opportunity_number_item, " (mutually exclusive with SS MAC Address!)");
529 proto_item_append_text(ss_mac_address_item, " (mutually exclusive with Initial Ranging Opportunity Number!)");
531 if (!ranging_status_item)
532 proto_item_append_text(rng_rsp_tree, " (Ranging status is missing!)");
538 /* Register Wimax Mac Payload Protocol and Dissector */
539 void proto_register_mac_mgmt_msg_rng_rsp(void)
541 /* RNG-RSP fields display */
542 static hf_register_info hf[] =
545 &hf_rng_rsp_broadcast,
547 "AAS broadcast permission", "wmx.rng_rsp.aas_broadcast",
548 FT_BOOLEAN, BASE_NONE, TFS(&tfs_rng_rsp_aas_broadcast), 0x0, NULL, HFILL
552 &hf_rng_rsp_akid,
554 "AKId", "wmx.rng_rsp.akid",
555 FT_BYTES, BASE_NONE, NULL, 0x00, NULL, HFILL
559 &hf_rng_rsp_basic_cid,
561 "Basic CID", "wmx.rng_rsp.basic_cid",
562 FT_UINT16, BASE_DEC, NULL, 0x00, NULL, HFILL
566 &hf_rng_rsp_bs_random,
568 "BS_Random", "wmx.rng_rsp.bs_random",
569 FT_BYTES, BASE_NONE, NULL, 0x00, NULL, HFILL
573 &hf_rng_rsp_config_change_count_of_dcd,
575 "Configuration Change Count value of DCD defining DIUC associated burst profile", "wmx.rng_rsp.config_change_count_of_dcd",
576 FT_UINT16, BASE_HEX, NULL, 0xFF00, NULL, HFILL
580 &hf_rng_rsp_dl_freq_override,
582 "Downlink Frequency Override", "wmx.rng_rsp.dl_freq_override",
583 FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL
587 &hf_rng_rsp_dl_operational_burst_profile_ccc,
589 "CCC value of DCD defining the burst profile associated with DIUC", "wmx.rng_rsp.dl_op_burst_prof.ccc",
590 FT_UINT16, BASE_DEC, NULL, 0x00FF, NULL, HFILL
594 &hf_rng_rsp_dl_operational_burst_profile_diuc,
596 "The least robust DIUC that may be used by the BS for transmissions to the SS", "wmx.rng_rsp.dl_op_burst_prof.diuc",
597 FT_UINT16, BASE_DEC, NULL, 0xFF00, NULL, HFILL
601 &hf_rng_rsp_dl_operational_burst_profile,
603 "Downlink Operational Burst Profile", "wmx.rng_rsp.dl_op_burst_profile",
604 FT_UINT16, BASE_HEX, NULL, 0x00, NULL, HFILL
607 /* Added the following to help implement RNG-RSP message encoding 33 (Table 367 in IEEE 802.16e-2007) */
609 &hf_rng_rsp_dl_op_burst_profile_ofdma,
611 "Downlink Operational Burst Profile for OFDMA", "wmx.rng_rsp.dl_op_burst_profile_ofdma",
612 FT_UINT16, BASE_HEX, NULL, 0x00, NULL, HFILL
616 &hf_rng_rsp_frame_number2,
618 "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",
619 FT_UINT32, BASE_DEC, NULL, 0x000000FF, NULL, HFILL
623 &hf_rng_rsp_frame_number,
625 "Frame number", "wmx.rng_rsp.frame_number",
626 FT_UINT24, BASE_DEC, NULL, 0x00, NULL, HFILL
629 /* Added the following to help implement RNG-RSP message encoding 22 (IEEE 802.16e-2007) */
631 &hf_rng_rsp_ho_id,
633 "HO ID", "wmx.rng_rsp.ho_id",
634 FT_UINT8, BASE_HEX, NULL, 0x00, NULL, HFILL
638 &hf_rng_rsp_ho_process_optimization,
640 "HO Process Optimization", "wmx.rng_rsp.ho_process_optimization",
641 FT_UINT16, BASE_HEX, NULL, 0x0000, NULL, HFILL
645 &hf_rng_rsp_ho_process_optimization_0,
647 "Bit #0", "wmx.rng_rsp.ho_process_optimization.omit_sbc_req",
648 FT_UINT16, BASE_HEX, VALS(vals_rng_rsp_ho_process_optimization_0), 0x0001, NULL, HFILL
652 &hf_rng_rsp_ho_process_optimization_1_2,
654 "Bits #1-2", "wmx.rng_rsp.ho_process_optimization.perform_reauthentication",
655 FT_UINT16, BASE_HEX, VALS(vals_rng_rsp_ho_process_optimization_1_2), 0x0006, NULL, HFILL
659 &hf_rng_rsp_ho_process_optimization_3,
661 "Bit #3", "wmx.rng_rsp.ho_process_optimization.omit_network_address",
662 FT_UINT16, BASE_HEX, VALS(vals_rng_rsp_ho_process_optimization_3), 0x0008, NULL, HFILL
666 &hf_rng_rsp_ho_process_optimization_4,
668 "Bit #4", "wmx.rng_rsp.ho_process_optimization.omit_time_of_day",
669 FT_UINT16, BASE_HEX, VALS(vals_rng_rsp_ho_process_optimization_4), 0x0010, NULL, HFILL
673 &hf_rng_rsp_ho_process_optimization_5,
675 "Bit #5", "wmx.rng_rsp.ho_process_optimization.omit_tftp",
676 FT_UINT16, BASE_HEX, VALS(vals_rng_rsp_ho_process_optimization_5), 0x0020, NULL, HFILL
680 &hf_rng_rsp_ho_process_optimization_6,
682 "Bit #6", "wmx.rng_rsp.ho_process_optimization.transfer_or_sharing",
683 FT_UINT16, BASE_HEX, VALS(vals_rng_rsp_ho_process_optimization_6), 0x0040, NULL, HFILL
687 &hf_rng_rsp_ho_process_optimization_7,
689 "Bit #7", "wmx.rng_rsp.ho_process_optimization.omit_reg_req",
690 FT_UINT16, BASE_HEX, VALS(vals_rng_rsp_ho_process_optimization_7), 0x0080, NULL, HFILL
694 &hf_rng_rsp_ho_process_optimization_8,
696 "Bit #8", "wmx.rng_rsp.ho_process_optimization.unsolicited_sbc_rsp",
697 FT_UINT16, BASE_HEX, VALS(vals_rng_rsp_ho_process_optimization_8), 0x0100, NULL, HFILL
701 &hf_rng_rsp_ho_process_optimization_9,
703 "Bit #9", "wmx.rng_rsp.ho_process_optimization.post_ho_reentry",
704 FT_UINT16, BASE_HEX, VALS(vals_rng_rsp_ho_process_optimization_9), 0x0200, NULL, HFILL
708 &hf_rng_rsp_ho_process_optimization_10,
710 "Bit #10", "wmx.rng_rsp.ho_process_optimization.unsolicited_reg_rsp",
711 FT_UINT16, BASE_HEX, VALS(vals_rng_rsp_ho_process_optimization_10), 0x0400, NULL, HFILL
715 &hf_rng_rsp_ho_process_optimization_11,
717 "Bit #11", "wmx.rng_rsp.ho_process_optimization.virtual_sdu_sn",
718 FT_UINT16, BASE_HEX, VALS(vals_rng_rsp_ho_process_optimization_11), 0x0800, NULL, HFILL
722 &hf_rng_rsp_ho_process_optimization_12,
724 "Bit #12", "wmx.rng_rsp.ho_process_optimization.send_notification",
725 FT_UINT16, BASE_HEX, VALS(vals_rng_rsp_ho_process_optimization_12), 0x1000, NULL, HFILL
729 &hf_rng_rsp_ho_process_optimization_13,
731 "Bit #13", "wmx.rng_rsp.ho_process_optimization.trigger_higher_layer_protocol",
732 FT_UINT16, BASE_HEX, VALS(vals_rng_rsp_ho_process_optimization_13), 0x2000, NULL, HFILL
736 &hf_rng_rsp_ho_process_optimization_14,
738 "Bit #14: Reserved", "wmx.rng_rsp.ho_process_optimization.reserved",
739 FT_UINT16, BASE_HEX, NULL, 0x4000, NULL, HFILL
743 &hf_rng_rsp_ho_process_optimization_15,
745 "Bit #15: Reserved", "wmx.rng_rsp.ho_process_optimization.reserved",
746 FT_UINT16, BASE_HEX, NULL, 0x8000, NULL, HFILL
750 &hf_rng_invalid_tlv,
752 "Invalid TLV", "wmx.rng_rsp.invalid_tlv",
753 FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL
757 &hf_rng_rsp_least_robust_diuc,
759 "Least Robust DIUC that may be used by the BS for transmissions to the MS", "wmx.rng_rsp.least_robust_diuc",
760 FT_UINT16, BASE_HEX, NULL, 0x000F, NULL, HFILL
764 &hf_rng_rsp_location_update_response,
766 "Location Update Response", "wmx.rng_rsp.location_update_response",
767 FT_UINT8, BASE_DEC, VALS(vals_rng_rsp_location_update_response), 0xFF, NULL, HFILL
771 &hf_rng_rsp_offset_freq_adjust,
773 "Offset Frequency Adjust", "wmx.rng_rsp.offset_freq_adjust",
774 FT_INT32, BASE_DEC, NULL, 0x00, NULL, HFILL
778 &hf_rng_rsp_opportunity_number,
780 "Initial ranging opportunity number", "wmx.rng_rsp.opportunity_number",
781 FT_UINT8, BASE_DEC, NULL, 0x00, NULL, HFILL
785 &hf_rng_rsp_paging_cycle,
787 "Paging Cycle", "wmx.rng_rsp.paging_cycle",
788 FT_UINT16, BASE_DEC, NULL, 0x00, NULL, HFILL
792 &hf_rng_rsp_paging_group_id,
794 "Paging Group ID", "wmx.rng_rsp.paging_group_id",
795 FT_UINT16, BASE_DEC, NULL, 0x00, NULL, HFILL
799 &hf_rng_rsp_paging_information,
801 "Paging Information", "wmx.rng_rsp.paging_information",
802 FT_BYTES, BASE_NONE, NULL, 0x00, NULL, HFILL
806 &hf_rng_rsp_paging_offset,
808 "Paging Offset", "wmx.rng_rsp.paging_offset",
809 FT_UINT8, BASE_DEC, NULL, 0x00, NULL, HFILL
813 &hf_rng_rsp_power_level_adjust,
815 "Power Level Adjust", "wmx.rng_rsp.power_level_adjust",
816 FT_FLOAT, BASE_NONE, NULL, 0x00, NULL, HFILL
820 &hf_rng_rsp_primary_mgmt_cid,
822 "Primary Management CID", "wmx.rng_rsp.primary_mgmt_cid",
823 FT_UINT16, BASE_DEC, NULL, 0x00, NULL, HFILL
827 &hf_rng_rsp_ranging_code_index,
829 "The ranging code index that was sent by the SS", "wmx.rng_rsp.ranging_code_index",
830 FT_UINT32, BASE_DEC, NULL, 0x0000FF00, NULL, HFILL
834 &hf_rng_rsp_ranging_status,
836 "Ranging status", "wmx.rng_rsp.ranging_status",
837 FT_UINT8, BASE_DEC, VALS(vals_rng_rsp_ranging_status), 0x00, NULL, HFILL
841 &hf_rng_rsp_ranging_subchan,
843 "Ranging code attributes", "wmx.rng_rsp.ranging_subchannel",
844 FT_UINT32, BASE_HEX, NULL, 0x00, NULL, HFILL
848 &hf_rng_rsp_repetition_coding_indication,
850 "Repetition Coding Indication", "wmx.rng_rsp.repetition_coding_indication",
851 FT_UINT16, BASE_HEX, VALS(vals_rng_rsp_repetition_coding_indication), 0x00F0, NULL, HFILL
855 &hf_rng_req_reserved,
857 "Reserved", "wmx.rng_rsp.reserved",
858 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL
862 &hf_rng_rsp_resource_retain_flag,
864 "The connection information for the MS is", "wmx.rng_rsp.resource_retain_flag",
865 FT_BOOLEAN, BASE_NONE, TFS(&tfs_rng_rsp_resource_retain_flag), 0x0, NULL, HFILL
869 &hf_rng_rsp_service_level_prediction,
871 "Service Level Prediction", "wmx.rng_rsp.service_level_prediction",
872 FT_UINT8, BASE_DEC, VALS(vals_rng_rsp_level_of_service), 0x00, NULL, HFILL
876 &hf_rng_rsp_ss_mac_address,
878 "SS MAC Address", "wmx.rng_rsp.ss_mac_address",
879 FT_ETHER, BASE_NONE, NULL, 0x00, NULL, HFILL
883 &hf_rng_rsp_subchannel_reference,
885 "OFDMA subchannel reference used to transmit the ranging code", "wmx.rng_rsp.subchannel_reference",
886 FT_UINT32, BASE_DEC, NULL, 0x003f0000, NULL, HFILL
890 &hf_rng_rsp_time_symbol_reference,
892 "OFDM time symbol reference used to transmit the ranging code", "wmx.rng_rsp.time_symbol_reference",
893 FT_UINT32, BASE_DEC, NULL, 0xFFC00000, NULL, HFILL
897 &hf_rng_rsp_timing_adjust,
899 "Timing Adjust", "wmx.rng_rsp.timing_adjust",
900 FT_FLOAT, BASE_NONE, NULL, 0x00, NULL, HFILL
903 #if 0
905 &hf_rng_rsp_ul_channel_id,
907 "Uplink Channel ID", "wmx.rng_rsp.ul_chan_id",
908 FT_UINT8, BASE_DEC, NULL, 0x00, NULL, HFILL
911 #endif
913 &hf_rng_rsp_ul_chan_id_override,
915 "Uplink channel ID Override", "wmx.rng_rsp.ul_chan_id_override",
916 FT_UINT8, BASE_DEC, NULL, 0x00, NULL, HFILL
920 &hf_tlv_type,
922 "Unknown TLV Type", "wmx.rng_rsp.unknown_tlv_type",
923 FT_BYTES, BASE_NONE, NULL, 0x00, NULL, HFILL
926 #if 0
928 &hf_tlv_value,
930 "Value", "wmx.rng_rsp.tlv_value",
931 FT_BYTES, BASE_NONE, NULL, 0x00, NULL, HFILL
934 #endif
937 /* Setup protocol subtree array */
938 static gint *ett[] =
940 &ett_mac_mgmt_msg_rng_rsp_decoder,
941 &ett_rng_rsp_message_tree
944 proto_mac_mgmt_msg_rng_rsp_decoder = proto_register_protocol (
945 "WiMax RNG-RSP Messages", /* name */
946 "WiMax RNG-RSP", /* short name */
947 "wmx.rng_rsp" /* abbrev */
950 proto_register_field_array(proto_mac_mgmt_msg_rng_rsp_decoder, hf, array_length(hf));
951 proto_register_subtree_array(ett, array_length(ett));
954 void proto_reg_handoff_mac_mgmt_msg_rng_rsp(void)
956 dissector_handle_t rng_rsp_handle;
958 rng_rsp_handle = create_dissector_handle(dissect_mac_mgmt_msg_rng_rsp_decoder, proto_mac_mgmt_msg_rng_rsp_decoder);
959 dissector_add_uint("wmx.mgmtmsg", MAC_MGMT_MSG_RNG_RSP, rng_rsp_handle);
961 sbc_rsp_handle = find_dissector("mac_mgmt_msg_sbc_rsp_handler");
962 reg_rsp_handle = find_dissector("mac_mgmt_msg_reg_rsp_handler");