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>
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1999 Gerald Combs
12 * SPDX-License-Identifier: GPL-2.0-or-later
19 #include <epan/packet.h>
20 #include <epan/expert.h>
21 #include "wimax_mac.h"
23 void proto_register_mac_mgmt_msg(void);
24 void proto_reg_handoff_mac_mgmt_msg(void);
26 static int proto_mac_mgmt_msg_decoder
;
27 static int ett_mac_mgmt_msg_decoder
;
29 static int hf_mac_mgmt_msg_type
;
30 static int hf_mac_mgmt_msg_values
;
32 static expert_field ei_empty_payload
;
34 static dissector_table_t subdissector_message_table
;
36 /* WIMAX MAC Management message type info */
37 static const value_string mgt_msg_abbrv_vals
[] = {
38 { MAC_MGMT_MSG_UCD
, "UCD" },
39 { MAC_MGMT_MSG_DCD
, "DCD" },
40 { MAC_MGMT_MSG_DL_MAP
, "DL-MAP" },
41 { MAC_MGMT_MSG_UL_MAP
, "UL-MAP" },
42 { MAC_MGMT_MSG_RNG_REQ
, "RNG-REQ" },
43 { MAC_MGMT_MSG_RNG_RSP
, "RNG-RSP" },
44 { MAC_MGMT_MSG_REG_REQ
, "REG-REQ" },
45 { MAC_MGMT_MSG_REG_RSP
, "REG-RSP" },
47 { MAC_MGMT_MSG_PKM_REQ
, "PKM-REQ" },
48 { MAC_MGMT_MSG_PKM_RSP
, "PKM-RSP" },
49 { MAC_MGMT_MSG_DSA_REQ
, "DSA-REQ" },
50 { MAC_MGMT_MSG_DSA_RSP
, "DSA-RSP" },
51 { MAC_MGMT_MSG_DSA_ACK
, "DSA-ACK" },
52 { MAC_MGMT_MSG_DSC_REQ
, "DSC-REQ" },
53 { MAC_MGMT_MSG_DSC_RSP
, "DSC-RSP" },
54 { MAC_MGMT_MSG_DSC_ACK
, "DSC-ACK" },
55 { MAC_MGMT_MSG_DSD_REQ
, "DSD-REQ" },
56 { MAC_MGMT_MSG_DSD_RSP
, "DSD-RSP" },
59 { MAC_MGMT_MSG_MCA_REQ
, "MCA-REQ" },
60 { MAC_MGMT_MSG_MCA_RSP
, "MCA-RSP" },
61 { MAC_MGMT_MSG_DBPC_REQ
, "DBPC-REQ" },
62 { MAC_MGMT_MSG_DBPC_RSP
, "DBPC-RSP" },
63 { MAC_MGMT_MSG_RES_CMD
, "RES-CMD" },
64 { MAC_MGMT_MSG_SBC_REQ
, "SBC-REQ" },
65 { MAC_MGMT_MSG_SBC_RSP
, "SBC-RSP" },
66 { MAC_MGMT_MSG_CLK_CMP
, "CLK-CMP" },
67 { MAC_MGMT_MSG_DREG_CMD
, "DREG-CMD" },
68 { MAC_MGMT_MSG_DSX_RVD
, "DSX-RVD" },
69 { MAC_MGMT_MSG_TFTP_CPLT
, "TFTP-CPLT" },
70 { MAC_MGMT_MSG_TFTP_RSP
, "TFTP-RSP" },
71 { MAC_MGMT_MSG_ARQ_FEEDBACK
, "ARQ-FEEDBACK" },
72 { MAC_MGMT_MSG_ARQ_DISCARD
, "ARQ-DISCARD" },
73 { MAC_MGMT_MSG_ARQ_RESET
, "ARQ-RESET" },
74 { MAC_MGMT_MSG_REP_REQ
, "REP-REQ" },
75 { MAC_MGMT_MSG_REP_RSP
, "REP-RSP" },
76 { MAC_MGMT_MSG_FPC
, "FPC" },
77 { MAC_MGMT_MSG_MSH_NCFG
, "MSH-NCFG" },
78 { MAC_MGMT_MSG_MSH_NENT
, "MSH-NENT" },
79 { MAC_MGMT_MSG_MSH_DSCH
, "MSH-DSCH" },
80 { MAC_MGMT_MSG_MSH_CSCH
, "MSH-CSCH" },
81 { MAC_MGMT_MSG_MSH_CSCF
, "MSH-CSCF" },
82 { MAC_MGMT_MSG_AAS_FBCK_REQ
, "AAS-FBCK_REQ" },
83 { MAC_MGMT_MSG_AAS_FBCK_RSP
, "AAS-FBCK_RSP" },
84 { MAC_MGMT_MSG_AAS_BEAM_SELECT
, "AAS-BEAM_SELECT" },
85 { MAC_MGMT_MSG_AAS_BEAM_REQ
, "AAS-BEAM_REQ" },
86 { MAC_MGMT_MSG_AAS_BEAM_RSP
, "AAS-BEAM_RSP" },
87 { MAC_MGMT_MSG_DREG_REQ
, "DREG-REQ" },
88 { MAC_MGMT_MSG_MOB_SLP_REQ
, "MOB-SLP-REQ" },
89 { MAC_MGMT_MSG_MOB_SLP_RSP
, "MOB-SLP-RSP" },
90 { MAC_MGMT_MSG_MOB_TRF_IND
, "MOB-TRF-IND" },
91 { MAC_MGMT_MSG_MOB_NBR_ADV
, "MOB-NBR-ADV" },
92 { MAC_MGMT_MSG_MOB_SCN_REQ
, "MOB-SCN-REQ" },
93 { MAC_MGMT_MSG_MOB_SCN_RSP
, "MOB-SCN-RSP" },
94 { MAC_MGMT_MSG_MOB_BSHO_REQ
, "MOB-BSHO-REQ" },
95 { MAC_MGMT_MSG_MOB_MSHO_REQ
, "MOB-MSHO-REQ" },
96 { MAC_MGMT_MSG_MOB_BSHO_RSP
, "MOB-BSHO-RSP" },
97 { MAC_MGMT_MSG_MOB_HO_IND
, "MOB-HO-IND" },
98 { MAC_MGMT_MSG_MOB_SCN_REP
, "MOB-SCN-REP" },
99 { MAC_MGMT_MSG_MOB_PAG_ADV
, "MOB-PAG-ADV" },
100 { MAC_MGMT_MSG_MBS_MAP
, "MBS-MAP" },
101 { MAC_MGMT_MSG_PMC_REQ
, "PMC-REQ" },
102 { MAC_MGMT_MSG_PMC_RSP
, "PMC-RSP" },
103 { MAC_MGMT_MSG_PRC_LT_CTRL
, "PRC-LT-CTRL" },
104 { MAC_MGMT_MSG_MOB_ASC_REP
, "MOB-ASC-REP" },
109 static value_string_ext mgt_msg_abbrv_vals_ext
= VALUE_STRING_EXT_INIT(mgt_msg_abbrv_vals
);
111 static int dissect_mac_mgmt_msg_decoder(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
114 unsigned message_type
;
115 proto_item
*message_item
;
116 proto_tree
*message_tree
;
117 const char* mgt_msg_str
;
119 message_item
= proto_tree_add_protocol_format(tree
, proto_mac_mgmt_msg_decoder
, tvb
, offset
, -1,
120 "MAC Management Message Type (%u bytes)", tvb_reported_length(tvb
));
121 message_tree
= proto_item_add_subtree(message_item
, ett_mac_mgmt_msg_decoder
);
123 if (tvb_reported_length(tvb
) == 0)
125 expert_add_info(pinfo
, message_item
, &ei_empty_payload
);
126 return tvb_captured_length(tvb
);
129 /* Get the payload type */
130 message_type
= tvb_get_uint8(tvb
, offset
);
131 proto_tree_add_item(message_tree
, hf_mac_mgmt_msg_type
, tvb
, offset
, 1, ENC_NA
);
132 mgt_msg_str
= val_to_str_ext_const(message_type
, &mgt_msg_abbrv_vals_ext
, "Unknown");
134 /* Display message type in Info column */
135 col_append_sep_str(pinfo
->cinfo
, COL_INFO
, ", ", mgt_msg_str
);
137 /* add the payload type into the info column */
138 if (try_val_to_str_ext(message_type
, &mgt_msg_abbrv_vals_ext
) == NULL
)
140 /* display the MAC payload in Hex */
141 proto_tree_add_item(message_tree
, hf_mac_mgmt_msg_values
, tvb
, offset
, -1, ENC_NA
);
145 /* add the MAC header info to parent*/
146 proto_item_append_text(proto_tree_get_parent(tree
), ", %s", mgt_msg_str
);
148 /* Decode and display the MAC payload */
149 if (!dissector_try_uint(subdissector_message_table
, message_type
,
150 tvb_new_subset_remaining(tvb
, 1), pinfo
, tree
))
152 proto_tree_add_item(message_tree
, hf_mac_mgmt_msg_values
, tvb
, offset
, -1, ENC_NA
);
154 return tvb_captured_length(tvb
);
157 /* Register Wimax Mac Payload Protocol and Dissector */
158 void proto_register_mac_mgmt_msg(void)
160 /* Payload display */
161 static hf_register_info hf
[] =
164 &hf_mac_mgmt_msg_type
,
166 "MAC Management Message Type", "wmx.macmgtmsgtype",
167 FT_UINT8
, BASE_DEC
| BASE_EXT_STRING
, &mgt_msg_abbrv_vals_ext
, 0x0,
172 &hf_mac_mgmt_msg_values
,
174 "Values", "wmx.values",
175 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
181 /* Setup protocol subtree array */
184 &ett_mac_mgmt_msg_decoder
,
187 static ei_register_info ei
[] = {
188 { &ei_empty_payload
, { "wmx.empty_payload", PI_PROTOCOL
, PI_ERROR
, "Error: Mac payload tvb is empty !", EXPFILL
}},
191 expert_module_t
* expert_mac_mgmt
;
193 proto_mac_mgmt_msg_decoder
= proto_register_protocol (
194 "WiMax MAC Management Message", /* name */
195 "MGMT MSG", /* short name */
196 "wmx.mgmt" /* abbrev */
199 proto_register_field_array(proto_mac_mgmt_msg_decoder
, hf
, array_length(hf
));
200 proto_register_subtree_array(ett
, array_length(ett
));
201 expert_mac_mgmt
= expert_register_protocol(proto_mac_mgmt_msg_decoder
);
202 expert_register_field_array(expert_mac_mgmt
, ei
, array_length(ei
));
204 subdissector_message_table
= register_dissector_table("wmx.mgmtmsg",
205 "WiMax MAC Management Message", proto_mac_mgmt_msg_decoder
, FT_UINT8
, BASE_DEC
);
207 /* Register dissector by name */
208 register_dissector("wmx_mac_mgmt_msg_decoder", dissect_mac_mgmt_msg_decoder
,
209 proto_mac_mgmt_msg_decoder
);
212 void proto_reg_handoff_mac_mgmt_msg(void)
214 dissector_handle_t mgt_msg_handle
;
216 /* Find the dissectors that appear to be supported through a third-party plugin
217 Keep here until third-party plugin can register through the new "wmx.mgmtmsg"
220 /* find the Multicast Assignment request message handler */
221 mgt_msg_handle
= find_dissector("mac_mgmt_msg_mca_req_handler");
223 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_MCA_REQ
, mgt_msg_handle
);
225 /* find the Multicast Assignment response message handler */
226 mgt_msg_handle
= find_dissector("mac_mgmt_msg_mca_rsp_handler");
228 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_MCA_RSP
, mgt_msg_handle
);
230 /* find the DL Burst Profile Change request message handler */
231 mgt_msg_handle
= find_dissector("mac_mgmt_msg_dbpc_req_handler");
233 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_DBPC_REQ
, mgt_msg_handle
);
235 /* find the DL Burst Profile Change response message handler */
236 mgt_msg_handle
= find_dissector("mac_mgmt_msg_dbpc_rsp_handler");
238 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_DBPC_RSP
, mgt_msg_handle
);
240 /* find the Config File TFTP Complete message handler */
241 mgt_msg_handle
= find_dissector("mac_mgmt_msg_tftp_cplt_handler");
243 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_TFTP_CPLT
, mgt_msg_handle
);
245 /* find the Config File TFTP Complete response message handler */
246 mgt_msg_handle
= find_dissector("mac_mgmt_msg_tftp_rsp_handler");
248 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_TFTP_RSP
, mgt_msg_handle
);
250 /* find the Mesh Network Configuration message handler */
251 mgt_msg_handle
= find_dissector("mac_mgmt_msg_ncfg_handler");
253 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_MSH_NCFG
, mgt_msg_handle
);
255 /* find the Mesh Network Entry message handler */
256 mgt_msg_handle
= find_dissector("mac_mgmt_msg_nent_handler");
258 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_MSH_NENT
, mgt_msg_handle
);
260 /* find the Mesh Distributed Schedule message handler */
261 mgt_msg_handle
= find_dissector("mac_mgmt_msg_dsch_handler");
263 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_MSH_DSCH
, mgt_msg_handle
);
265 /* find the Mesh Centralized Schedule message handler */
266 mgt_msg_handle
= find_dissector("mac_mgmt_msg_csch_handler");
268 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_MSH_CSCH
, mgt_msg_handle
);
270 /* find the Mesh Centralized Schedule Configuration message handler */
271 mgt_msg_handle
= find_dissector("mac_mgmt_msg_cscf_handler");
273 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_MSH_CSCF
, mgt_msg_handle
);
275 /* find the AAS Beam request message handler */
276 mgt_msg_handle
= find_dissector("mac_mgmt_msg_aas_beam_req_handler");
278 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_AAS_BEAM_REQ
, mgt_msg_handle
);
280 /* find the AAS Beam response message handler */
281 mgt_msg_handle
= find_dissector("mac_mgmt_msg_aas_beam_rsp_handler");
283 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_AAS_BEAM_RSP
, mgt_msg_handle
);
285 /* find the Sleep Request message handler */
286 mgt_msg_handle
= find_dissector("mac_mgmt_msg_mob_slp_req_handler");
288 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_MOB_SLP_REQ
, mgt_msg_handle
);
290 /* find the Sleep Response message handler */
291 mgt_msg_handle
= find_dissector("mac_mgmt_msg_mob_slp_rsp_handler");
293 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_MOB_SLP_RSP
, mgt_msg_handle
);
295 /* find the Traffic Indication message handler */
296 mgt_msg_handle
= find_dissector("mac_mgmt_msg_mob_trf_ind_handler");
298 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_MOB_TRF_IND
, mgt_msg_handle
);
300 /* find the Neighbor Advertisement message handler */
301 mgt_msg_handle
= find_dissector("mac_mgmt_msg_mob_nbr_adv_handler");
303 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_MOB_NBR_ADV
, mgt_msg_handle
);
305 /* find the Scanning Interval Allocation Request message handler */
306 mgt_msg_handle
= find_dissector("mac_mgmt_msg_mob_scn_req_handler");
308 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_MOB_SCN_REQ
, mgt_msg_handle
);
310 /* find the Scanning Interval Allocation Response message handler */
311 mgt_msg_handle
= find_dissector("mac_mgmt_msg_mob_scn_rsp_handler");
313 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_MOB_SCN_RSP
, mgt_msg_handle
);
315 /* find the BS HO Request message handler */
316 mgt_msg_handle
= find_dissector("mac_mgmt_msg_mob_bsho_req_handler");
318 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_MOB_BSHO_REQ
, mgt_msg_handle
);
320 /* find the MS HO Request message handler */
321 mgt_msg_handle
= find_dissector("mac_mgmt_msg_mob_msho_req_handler");
323 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_MOB_MSHO_REQ
, mgt_msg_handle
);
325 /* find the BS HO Response message handler */
326 mgt_msg_handle
= find_dissector("mac_mgmt_msg_mob_bsho_rsp_handler");
328 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_MOB_BSHO_RSP
, mgt_msg_handle
);
330 /* find the HO Indication message handler */
331 mgt_msg_handle
= find_dissector("mac_mgmt_msg_mob_ho_ind_handler");
333 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_MOB_HO_IND
, mgt_msg_handle
);
335 /* find the Scanning Result Report message handler */
336 mgt_msg_handle
= find_dissector("mac_mgmt_msg_mob_scn_rep_handler");
338 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_MOB_SCN_REP
, mgt_msg_handle
);
340 /* find the BS Broadcast Paging message handler */
341 mgt_msg_handle
= find_dissector("mac_mgmt_msg_mob_pag_adv_handler");
343 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_MOB_PAG_ADV
, mgt_msg_handle
);
345 /* find the MBS MAP message handler */
346 mgt_msg_handle
= find_dissector("mac_mgmt_msg_mbs_map_handler");
348 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_MBS_MAP
, mgt_msg_handle
);
350 /* find the Association Result Report message handler */
351 mgt_msg_handle
= find_dissector("mac_mgmt_msg_mob_asc_rep_handler");
353 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_MOB_ASC_REP
, mgt_msg_handle
);
357 * Editor modelines - https://www.wireshark.org/tools/modelines.html
362 * indent-tabs-mode: t
365 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
366 * :indentSize=8:tabSize=8:noTabs=false: