1 /* mac_mgmt_msg_decoder.c
2 * WiMax MAC Management Message decoder
4 * Copyright (c) 2007 by Intel Corporation.
6 * Author: Lu Pan <lu.pan@intel.com>
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.
34 #include <epan/packet.h>
35 #include <epan/expert.h>
36 #include "wimax_mac.h"
38 static gint proto_mac_mgmt_msg_decoder
= -1;
39 static gint ett_mac_mgmt_msg_decoder
= -1;
41 static gint hf_mac_mgmt_msg_type
= -1;
42 static gint hf_mac_mgmt_msg_values
= -1;
44 static expert_field ei_empty_payload
= EI_INIT
;
46 static dissector_table_t subdissector_message_table
;
48 /* WIMAX MAC Management message type info */
49 static const value_string mgt_msg_abbrv_vals
[] = {
50 { MAC_MGMT_MSG_UCD
, "UCD" },
51 { MAC_MGMT_MSG_DCD
, "DCD" },
52 { MAC_MGMT_MSG_DL_MAP
, "DL-MAP" },
53 { MAC_MGMT_MSG_UL_MAP
, "UL-MAP" },
54 { MAC_MGMT_MSG_RNG_REQ
, "RNG-REQ" },
55 { MAC_MGMT_MSG_RNG_RSP
, "RNG-RSP" },
56 { MAC_MGMT_MSG_REG_REQ
, "REG-REQ" },
57 { MAC_MGMT_MSG_REG_RSP
, "REG-RSP" },
59 { MAC_MGMT_MSG_PKM_REQ
, "PKM-REQ" },
60 { MAC_MGMT_MSG_PKM_RSP
, "PKM-RSP" },
61 { MAC_MGMT_MSG_DSA_REQ
, "DSA-REQ" },
62 { MAC_MGMT_MSG_DSA_RSP
, "DSA-RSP" },
63 { MAC_MGMT_MSG_DSA_ACK
, "DSA-ACK" },
64 { MAC_MGMT_MSG_DSC_REQ
, "DSC-REQ" },
65 { MAC_MGMT_MSG_DSC_RSP
, "DSC-RSP" },
66 { MAC_MGMT_MSG_DSC_ACK
, "DSC-ACK" },
67 { MAC_MGMT_MSG_DSD_REQ
, "DSD-REQ" },
68 { MAC_MGMT_MSG_DSD_RSP
, "DSD-RSP" },
71 { MAC_MGMT_MSG_MCA_REQ
, "MCA-REQ" },
72 { MAC_MGMT_MSG_MCA_RSP
, "MCA-RSP" },
73 { MAC_MGMT_MSG_DBPC_REQ
, "DBPC-REQ" },
74 { MAC_MGMT_MSG_DBPC_RSP
, "DBPC-RSP" },
75 { MAC_MGMT_MSG_RES_CMD
, "RES-CMD" },
76 { MAC_MGMT_MSG_SBC_REQ
, "SBC-REQ" },
77 { MAC_MGMT_MSG_SBC_RSP
, "SBC-RSP" },
78 { MAC_MGMT_MSG_CLK_CMP
, "CLK-CMP" },
79 { MAC_MGMT_MSG_DREG_CMD
, "DREG-CMD" },
80 { MAC_MGMT_MSG_DSX_RVD
, "DSX-RVD" },
81 { MAC_MGMT_MSG_TFTP_CPLT
, "TFTP-CPLT" },
82 { MAC_MGMT_MSG_TFTP_RSP
, "TFTP-RSP" },
83 { MAC_MGMT_MSG_ARQ_FEEDBACK
, "ARQ-FEEDBACK" },
84 { MAC_MGMT_MSG_ARQ_DISCARD
, "ARQ-DISCARD" },
85 { MAC_MGMT_MSG_ARQ_RESET
, "ARQ-RESET" },
86 { MAC_MGMT_MSG_REP_REQ
, "REP-REQ" },
87 { MAC_MGMT_MSG_REP_RSP
, "REP-RSP" },
88 { MAC_MGMT_MSG_FPC
, "FPC" },
89 { MAC_MGMT_MSG_MSH_NCFG
, "MSH-NCFG" },
90 { MAC_MGMT_MSG_MSH_NENT
, "MSH-NENT" },
91 { MAC_MGMT_MSG_MSH_DSCH
, "MSH-DSCH" },
92 { MAC_MGMT_MSG_MSH_CSCH
, "MSH-CSCH" },
93 { MAC_MGMT_MSG_MSH_CSCF
, "MSH-CSCF" },
94 { MAC_MGMT_MSG_AAS_FBCK_REQ
, "AAS-FBCK_REQ" },
95 { MAC_MGMT_MSG_AAS_FBCK_RSP
, "AAS-FBCK_RSP" },
96 { MAC_MGMT_MSG_AAS_BEAM_SELECT
, "AAS-BEAM_SELECT" },
97 { MAC_MGMT_MSG_AAS_BEAM_REQ
, "AAS-BEAM_REQ" },
98 { MAC_MGMT_MSG_AAS_BEAM_RSP
, "AAS-BEAM_RSP" },
99 { MAC_MGMT_MSG_DREG_REQ
, "DREG-REQ" },
100 { MAC_MGMT_MSG_MOB_SLP_REQ
, "MOB-SLP-REQ" },
101 { MAC_MGMT_MSG_MOB_SLP_RSP
, "MOB-SLP-RSP" },
102 { MAC_MGMT_MSG_MOB_TRF_IND
, "MOB-TRF-IND" },
103 { MAC_MGMT_MSG_MOB_NBR_ADV
, "MOB-NBR-ADV" },
104 { MAC_MGMT_MSG_MOB_SCN_REQ
, "MOB-SCN-REQ" },
105 { MAC_MGMT_MSG_MOB_SCN_RSP
, "MOB-SCN-RSP" },
106 { MAC_MGMT_MSG_MOB_BSHO_REQ
, "MOB-BSHO-REQ" },
107 { MAC_MGMT_MSG_MOB_MSHO_REQ
, "MOB-MSHO-REQ" },
108 { MAC_MGMT_MSG_MOB_BSHO_RSP
, "MOB-BSHO-RSP" },
109 { MAC_MGMT_MSG_MOB_HO_IND
, "MOB-HO-IND" },
110 { MAC_MGMT_MSG_MOB_SCN_REP
, "MOB-SCN-REP" },
111 { MAC_MGMT_MSG_MOB_PAG_ADV
, "MOB-PAG-ADV" },
112 { MAC_MGMT_MSG_MBS_MAP
, "MBS-MAP" },
113 { MAC_MGMT_MSG_PMC_REQ
, "PMC-REQ" },
114 { MAC_MGMT_MSG_PMC_RSP
, "PMC-RSP" },
115 { MAC_MGMT_MSG_PRC_LT_CTRL
, "PRC-LT-CTRL" },
116 { MAC_MGMT_MSG_MOB_ASC_REP
, "MOB-ASC-REP" },
121 static value_string_ext mgt_msg_abbrv_vals_ext
= VALUE_STRING_EXT_INIT(mgt_msg_abbrv_vals
);
123 static void dissect_mac_mgmt_msg_decoder(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
127 proto_item
*message_item
;
128 proto_tree
*message_tree
;
129 const char* mgt_msg_str
;
131 message_item
= proto_tree_add_protocol_format(tree
, proto_mac_mgmt_msg_decoder
, tvb
, offset
, -1,
132 "MAC Management Message Type (%u bytes)", tvb_reported_length(tvb
));
133 message_tree
= proto_item_add_subtree(message_item
, ett_mac_mgmt_msg_decoder
);
135 if (tvb_reported_length(tvb
) == 0)
137 expert_add_info(pinfo
, message_item
, &ei_empty_payload
);
141 /* Get the payload type */
142 message_type
= tvb_get_guint8(tvb
, offset
);
143 proto_tree_add_item(message_tree
, hf_mac_mgmt_msg_type
, tvb
, offset
, 1, ENC_NA
);
144 mgt_msg_str
= val_to_str_ext_const(message_type
, &mgt_msg_abbrv_vals_ext
, "Unknown");
146 /* Display message type in Info column */
147 col_append_sep_str(pinfo
->cinfo
, COL_INFO
, ", ", mgt_msg_str
);
149 /* add the payload type into the info column */
150 if (try_val_to_str_ext(message_type
, &mgt_msg_abbrv_vals_ext
) == NULL
)
152 /* display the MAC payload in Hex */
153 proto_tree_add_item(message_tree
, hf_mac_mgmt_msg_values
, tvb
, offset
, -1, ENC_NA
);
157 /* add the MAC header info to parent*/
158 proto_item_append_text(proto_tree_get_parent(tree
), ", %s", mgt_msg_str
);
160 /* Decode and display the MAC payload */
161 if (!dissector_try_uint(subdissector_message_table
, message_type
,
162 tvb_new_subset_remaining(tvb
, 1), pinfo
, tree
))
164 proto_tree_add_item(message_tree
, hf_mac_mgmt_msg_values
, tvb
, offset
, -1, ENC_NA
);
168 /* Register Wimax Mac Payload Protocol and Dissector */
169 void proto_register_mac_mgmt_msg(void)
171 /* Payload display */
172 static hf_register_info hf
[] =
175 &hf_mac_mgmt_msg_type
,
177 "MAC Management Message Type", "wmx.macmgtmsgtype",
178 FT_UINT8
, BASE_DEC
| BASE_EXT_STRING
, &mgt_msg_abbrv_vals_ext
, 0x0,
183 &hf_mac_mgmt_msg_values
,
185 "Values", "wmx.values",
186 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
192 /* Setup protocol subtree array */
195 &ett_mac_mgmt_msg_decoder
,
198 static ei_register_info ei
[] = {
199 { &ei_empty_payload
, { "wmx.empty_payload", PI_PROTOCOL
, PI_ERROR
, "Error: Mac payload tvb is empty !", EXPFILL
}},
202 expert_module_t
* expert_mac_mgmt
;
204 proto_mac_mgmt_msg_decoder
= proto_register_protocol (
205 "WiMax MAC Management Message", /* name */
206 "MGMT MSG", /* short name */
207 "wmx.mgmt" /* abbrev */
210 proto_register_field_array(proto_mac_mgmt_msg_decoder
, hf
, array_length(hf
));
211 proto_register_subtree_array(ett
, array_length(ett
));
212 expert_mac_mgmt
= expert_register_protocol(proto_mac_mgmt_msg_decoder
);
213 expert_register_field_array(expert_mac_mgmt
, ei
, array_length(ei
));
215 subdissector_message_table
= register_dissector_table("wmx.mgmtmsg",
216 "WiMax MAC Management Message", FT_UINT8
, BASE_DEC
);
218 /* Register dissector by name */
219 register_dissector("wmx_mac_mgmt_msg_decoder", dissect_mac_mgmt_msg_decoder
,
220 proto_mac_mgmt_msg_decoder
);
223 void proto_reg_handoff_mac_mgmt_msg(void)
225 dissector_handle_t mgt_msg_handle
;
227 /* Find the dissectors that appear to be supported through a third-party plugin
228 Keep here until third-party plugin can register through the new "wmx.mgmtmsg"
231 /* find the Multicast Assignment request message handler */
232 mgt_msg_handle
= find_dissector("mac_mgmt_msg_mca_req_handler");
234 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_MCA_REQ
, mgt_msg_handle
);
236 /* find the Multicast Assignment response message handler */
237 mgt_msg_handle
= find_dissector("mac_mgmt_msg_mca_rsp_handler");
239 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_MCA_RSP
, mgt_msg_handle
);
241 /* find the DL Burst Profile Change request message handler */
242 mgt_msg_handle
= find_dissector("mac_mgmt_msg_dbpc_req_handler");
244 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_DBPC_REQ
, mgt_msg_handle
);
246 /* find the DL Burst Profile Change response message handler */
247 mgt_msg_handle
= find_dissector("mac_mgmt_msg_dbpc_rsp_handler");
249 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_DBPC_RSP
, mgt_msg_handle
);
251 /* find the Config File TFTP Complete message handler */
252 mgt_msg_handle
= find_dissector("mac_mgmt_msg_tftp_cplt_handler");
254 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_TFTP_CPLT
, mgt_msg_handle
);
256 /* find the Config File TFTP Complete response message handler */
257 mgt_msg_handle
= find_dissector("mac_mgmt_msg_tftp_rsp_handler");
259 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_TFTP_RSP
, mgt_msg_handle
);
261 /* find the Mesh Network Configuration message handler */
262 mgt_msg_handle
= find_dissector("mac_mgmt_msg_ncfg_handler");
264 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_MSH_NCFG
, mgt_msg_handle
);
266 /* find the Mesh Network Entry message handler */
267 mgt_msg_handle
= find_dissector("mac_mgmt_msg_nent_handler");
269 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_MSH_NENT
, mgt_msg_handle
);
271 /* find the Mesh Distributed Schedule message handler */
272 mgt_msg_handle
= find_dissector("mac_mgmt_msg_dsch_handler");
274 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_MSH_DSCH
, mgt_msg_handle
);
276 /* find the Mesh Centralized Schedule message handler */
277 mgt_msg_handle
= find_dissector("mac_mgmt_msg_csch_handler");
279 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_MSH_CSCH
, mgt_msg_handle
);
281 /* find the Mesh Centralized Schedule Configuration message handler */
282 mgt_msg_handle
= find_dissector("mac_mgmt_msg_cscf_handler");
284 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_MSH_CSCF
, mgt_msg_handle
);
286 /* find the AAS Beam request message handler */
287 mgt_msg_handle
= find_dissector("mac_mgmt_msg_aas_beam_req_handler");
289 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_AAS_BEAM_REQ
, mgt_msg_handle
);
291 /* find the AAS Beam response message handler */
292 mgt_msg_handle
= find_dissector("mac_mgmt_msg_aas_beam_rsp_handler");
294 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_AAS_BEAM_RSP
, mgt_msg_handle
);
296 /* find the Sleep Request message handler */
297 mgt_msg_handle
= find_dissector("mac_mgmt_msg_mob_slp_req_handler");
299 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_MOB_SLP_REQ
, mgt_msg_handle
);
301 /* find the Sleep Response message handler */
302 mgt_msg_handle
= find_dissector("mac_mgmt_msg_mob_slp_rsp_handler");
304 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_MOB_SLP_RSP
, mgt_msg_handle
);
306 /* find the Traffic Indication message handler */
307 mgt_msg_handle
= find_dissector("mac_mgmt_msg_mob_trf_ind_handler");
309 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_MOB_TRF_IND
, mgt_msg_handle
);
311 /* find the Neighbor Advertisement message handler */
312 mgt_msg_handle
= find_dissector("mac_mgmt_msg_mob_nbr_adv_handler");
314 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_MOB_NBR_ADV
, mgt_msg_handle
);
316 /* find the Scanning Interval Allocation Reqest message handler */
317 mgt_msg_handle
= find_dissector("mac_mgmt_msg_mob_scn_req_handler");
319 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_MOB_SCN_REQ
, mgt_msg_handle
);
321 /* find the Scanning Interval Allocation Response message handler */
322 mgt_msg_handle
= find_dissector("mac_mgmt_msg_mob_scn_rsp_handler");
324 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_MOB_SCN_RSP
, mgt_msg_handle
);
326 /* find the BS HO Request message handler */
327 mgt_msg_handle
= find_dissector("mac_mgmt_msg_mob_bsho_req_handler");
329 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_MOB_BSHO_REQ
, mgt_msg_handle
);
331 /* find the MS HO Request message handler */
332 mgt_msg_handle
= find_dissector("mac_mgmt_msg_mob_msho_req_handler");
334 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_MOB_MSHO_REQ
, mgt_msg_handle
);
336 /* find the BS HO Response message handler */
337 mgt_msg_handle
= find_dissector("mac_mgmt_msg_mob_bsho_rsp_handler");
339 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_MOB_BSHO_RSP
, mgt_msg_handle
);
341 /* find the HO Indication message handler */
342 mgt_msg_handle
= find_dissector("mac_mgmt_msg_mob_ho_ind_handler");
344 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_MOB_HO_IND
, mgt_msg_handle
);
346 /* find the Scanning Result Report message handler */
347 mgt_msg_handle
= find_dissector("mac_mgmt_msg_mob_scn_rep_handler");
349 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_MOB_SCN_REP
, mgt_msg_handle
);
351 /* find the BS Broadcast Paging message handler */
352 mgt_msg_handle
= find_dissector("mac_mgmt_msg_mob_pag_adv_handler");
354 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_MOB_PAG_ADV
, mgt_msg_handle
);
356 /* find the MBS MAP message handler */
357 mgt_msg_handle
= find_dissector("mac_mgmt_msg_mbs_map_handler");
359 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_MBS_MAP
, mgt_msg_handle
);
361 /* find the Association Result Report message handler */
362 mgt_msg_handle
= find_dissector("mac_mgmt_msg_mob_asc_rep_handler");
364 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_MOB_ASC_REP
, mgt_msg_handle
);