MSWSP: add ids for another unknown Property Set
[wireshark-wip.git] / plugins / wimax / msg_pmc.c
blob47a4b4428815eb7e44cc05988aaf8ef3b7f40f27
1 /* msg_pmc.c
2 * WiMax MAC Management PMC-REQ, PMC-RSP Message decoders
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 "moduleinfo.h"
35 #include <glib.h>
36 #include <epan/packet.h>
37 #include "crc.h"
38 #include "wimax_tlv.h"
39 #include "wimax_mac.h"
40 #include "wimax_utils.h"
42 extern gboolean include_cor2_changes;
44 static gint proto_mac_mgmt_msg_pmc_req_decoder = -1;
45 static gint proto_mac_mgmt_msg_pmc_rsp_decoder = -1;
47 static gint ett_mac_mgmt_msg_pmc_decoder = -1;
49 /* Setup protocol subtree array */
50 static gint *ett[] =
52 &ett_mac_mgmt_msg_pmc_decoder,
55 /* PMC fields */
56 static gint hf_pmc_req_pwr_control_mode_change = -1;
57 static gint hf_pmc_req_pwr_control_mode_change_cor2 = -1;
58 static gint hf_pmc_req_tx_power_level = -1;
59 static gint hf_pmc_req_confirmation = -1;
60 static gint hf_pmc_req_reserved = -1;
61 static gint hf_pmc_rsp_start_frame = -1;
62 static gint hf_pmc_rsp_power_adjust = -1;
63 static gint hf_pmc_rsp_offset_BS_per_MS = -1;
65 /* STRING RESOURCES */
66 static const value_string vals_pmc_req_pwr[] = {
67 {0, "Closed loop power control mode"},
68 {1, "Reserved"},
69 {2, "Open loop power control passive mode"},
70 {3, "Open loop power control active mode"},
71 {0, NULL}
74 static const value_string vals_pmc_req_pwr_cor2[] = {
75 {0, "Closed loop power control mode"},
76 {1, "Open loop power control passive mode with Offset_SSperSS retention"},
77 {2, "Open loop power control passive mode with Offset_SSperSS reset"},
78 {3, "Open loop power control active mode"},
79 {0, NULL}
82 static const value_string vals_pmc_req_confirmation[] = {
83 {0, "MS requests to change the power control mode"},
84 {1, "MS confirms the receipt of PMC_RSP from BS"},
85 {0, NULL}
88 /* Register Wimax Mac Payload Protocol and Dissector */
89 void proto_register_mac_mgmt_msg_pmc_req(void)
91 /* PMC fields display */
92 static hf_register_info hf[] =
95 &hf_pmc_req_confirmation,
97 "Confirmation", "wmx.pmc_req.confirmation",
98 FT_UINT16, BASE_DEC, VALS(vals_pmc_req_confirmation), 0x0020, NULL, HFILL
102 &hf_pmc_req_pwr_control_mode_change,
104 "Power control mode change", "wmx.pmc_req.power_control_mode",
105 FT_UINT16, BASE_DEC, VALS(vals_pmc_req_pwr), 0xC000, NULL, HFILL
109 &hf_pmc_req_pwr_control_mode_change_cor2,
111 "Power control mode change", "wmx.pmc_req.power_control_mode",
112 FT_UINT16, BASE_DEC, VALS(vals_pmc_req_pwr_cor2), 0xC000, NULL, HFILL
116 &hf_pmc_req_reserved,
118 "Reserved", "wmx.pmc_req.reserved",
119 FT_UINT16, BASE_DEC, NULL, 0x001F, NULL, HFILL
123 &hf_pmc_req_tx_power_level,
125 "UL Tx power level for the burst that carries this header", "wmx.pmc_req.ul_tx_power_level",
126 FT_UINT16, BASE_DEC, NULL, 0x3FC0, "When the Tx power is different from slot to slot, the maximum value is reported", HFILL
130 &hf_pmc_rsp_offset_BS_per_MS,
132 "Offset_BS per MS", "wmx.pmc_rsp.offset_BS_per_MS",
133 FT_FLOAT, BASE_NONE, NULL, 0x0, "Signed change in power level (incr of 0.25 dB) that the MS shall apply to the open loop power control formula in 8.4.10.3.2", HFILL
137 &hf_pmc_rsp_power_adjust,
139 "Power adjust", "wmx.pmc_rsp.power_adjust",
140 FT_FLOAT, BASE_NONE, NULL, 0x0, "Signed change in power level (incr of 0.25 dB) that the MS shall apply to its current transmission power. When subchannelization is employed, the SS shall interpret as a required change to the Tx power density", HFILL
144 &hf_pmc_rsp_start_frame,
146 "Start frame", "wmx.pmc_rsp.start_frame",
147 FT_UINT16, BASE_HEX, NULL, 0x3F00, "Apply mode change from current frame when 6 LSBs of frame match this", HFILL
152 proto_mac_mgmt_msg_pmc_req_decoder = proto_register_protocol (
153 "WiMax PMC-REQ Messages", /* name */
154 "WiMax PMC-REQ", /* short name */
155 "wmx.pmc_req" /* abbrev */
158 proto_register_field_array(proto_mac_mgmt_msg_pmc_req_decoder, hf, array_length(hf));
159 proto_register_subtree_array(ett, array_length(ett));
162 /* Register Wimax Mac Payload Protocol and Dissector */
163 void proto_register_mac_mgmt_msg_pmc_rsp(void)
165 proto_mac_mgmt_msg_pmc_rsp_decoder = proto_register_protocol (
166 "WiMax PMC-RSP Messages", /* name */
167 "WiMax PMC-RSP", /* short name */
168 "wmx.pmc_rsp" /* abbrev */
172 /* Decode PMC-REQ messages. */
173 static void dissect_mac_mgmt_msg_pmc_req_decoder(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
175 guint offset = 0;
176 proto_item *pmc_req_item;
177 proto_tree *pmc_req_tree;
179 { /* we are being asked for details */
181 /* display MAC payload type PMC-REQ */
182 pmc_req_item = proto_tree_add_protocol_format(tree, proto_mac_mgmt_msg_pmc_req_decoder, tvb, 0, -1, "MAC Management Message, PMC-REQ");
183 /* add MAC PMC REQ subtree */
184 pmc_req_tree = proto_item_add_subtree(pmc_req_item, ett_mac_mgmt_msg_pmc_decoder);
185 /* display the Power Control Mode Change */
186 proto_tree_add_item(pmc_req_tree, hf_pmc_req_pwr_control_mode_change, tvb, offset, 2, ENC_BIG_ENDIAN);
187 /* show the Transmit Power Level */
188 proto_tree_add_item(pmc_req_tree, hf_pmc_req_tx_power_level, tvb, offset, 2, ENC_BIG_ENDIAN);
189 /* display the Confirmation/request */
190 proto_tree_add_item(pmc_req_tree, hf_pmc_req_confirmation, tvb, offset, 2, ENC_BIG_ENDIAN);
191 /* show the Reserved bits */
192 proto_tree_add_item(pmc_req_tree, hf_pmc_req_reserved, tvb, offset, 2, ENC_BIG_ENDIAN);
196 /* Decode PMC-RSP messages. */
197 static void dissect_mac_mgmt_msg_pmc_rsp_decoder(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
199 guint offset = 0;
200 proto_item *pmc_rsp_item;
201 proto_tree *pmc_rsp_tree;
202 guint8 pwr_control_mode;
203 gint8 value;
204 gfloat power_change;
206 { /* we are being asked for details */
208 /* display MAC payload type PMC-RSP */
209 pmc_rsp_item = proto_tree_add_protocol_format(tree, proto_mac_mgmt_msg_pmc_rsp_decoder, tvb, 0, -1, "MAC Management Message, PMC-RSP");
210 /* add MAC PMC RSP subtree */
211 pmc_rsp_tree = proto_item_add_subtree(pmc_rsp_item, ett_mac_mgmt_msg_pmc_decoder);
213 /* display the Power Control Mode Change */
214 if (include_cor2_changes)
215 proto_tree_add_item(pmc_rsp_tree, hf_pmc_req_pwr_control_mode_change_cor2, tvb, offset, 2, ENC_BIG_ENDIAN);
216 else
217 proto_tree_add_item(pmc_rsp_tree, hf_pmc_req_pwr_control_mode_change, tvb, offset, 2, ENC_BIG_ENDIAN);
218 /* display the Power Adjust start frame */
219 proto_tree_add_item(pmc_rsp_tree, hf_pmc_rsp_start_frame, tvb, offset, 2, ENC_BIG_ENDIAN);
220 pwr_control_mode = 0xC0 & tvb_get_guint8(tvb, offset);
221 offset++;
223 value = (gint8)tvb_get_guint8(tvb, offset);
224 power_change = (float)0.25 * value; /* 0.25dB incr */
225 /* Check if Power Control Mode is 0 */
226 if (pwr_control_mode == 0) {
227 /* display the amount of power change requested */
228 proto_tree_add_float_format_value(pmc_rsp_tree, hf_pmc_rsp_power_adjust, tvb, offset, 1, power_change, " %.2f dB", power_change);
229 } else {
230 /* display the amount of MS power change requested */
231 proto_tree_add_float_format_value(pmc_rsp_tree, hf_pmc_rsp_offset_BS_per_MS, tvb, offset, 1, power_change, " %.2f dB", power_change);
236 void
237 proto_reg_handoff_mac_mgmt_msg_pmc(void)
239 dissector_handle_t pmc_handle;
241 pmc_handle = create_dissector_handle(dissect_mac_mgmt_msg_pmc_req_decoder, proto_mac_mgmt_msg_pmc_req_decoder);
242 dissector_add_uint("wmx.mgmtmsg", MAC_MGMT_MSG_PMC_REQ, pmc_handle);
244 pmc_handle = create_dissector_handle(dissect_mac_mgmt_msg_pmc_rsp_decoder, proto_mac_mgmt_msg_pmc_rsp_decoder);
245 dissector_add_uint("wmx.mgmtmsg", MAC_MGMT_MSG_PMC_RSP, pmc_handle);