HTTPS (almost) everywhere.
[metze/wireshark/wip.git] / plugins / epan / wimax / wimax_phy_attributes_decoder.c
1 /* wimax_phy_attributes_decoder.c
2  * WiMax PDU Burst Physical Attributes decoder
3  *
4  * Copyright (c) 2007 by Intel Corporation.
5  *
6  * Author: Lu Pan <lu.pan@intel.com>
7  *
8  * Wireshark - Network traffic analyzer
9  * By Gerald Combs <gerald@wireshark.org>
10  * Copyright 1999 Gerald Combs
11  *
12  * SPDX-License-Identifier: GPL-2.0-or-later
13  */
14
15 /* Include files */
16
17 #include "config.h"
18
19 #include <epan/packet.h>
20 #include "wimax-int.h"
21
22 extern gint proto_wimax;
23
24 static gint proto_wimax_phy_attributes_decoder = -1;
25 static gint ett_wimax_phy_attributes_decoder = -1;
26
27 static const value_string vals_subchannel_types[] =
28 {
29         { 0, "DL PUSC"},
30         { 1, "DL FUSC"},
31         {16, "UL PUSC"},
32         {0, NULL}
33 };
34
35 static const value_string vals_modulation_rates[] =
36 {
37         {0, "BPSK R=1/2"},
38         {1, "QPSK R=1/2"},
39         {2, "QPSK R=3/4"},
40         {3, "16-QAM R=1/2"},
41         {4, "16-QAM R=3/4"},
42         {5, "64-QAM R=1/2"},
43         {6, "64-QAM R=2/3"},
44         {7, "64-QAM R=3/4"},
45         {8, "64-QAM R=5/6"},
46         {0, NULL}
47 };
48
49 static const value_string vals_encoding_types[] =
50 {
51         {0, "Tail biting convolutional coding (CCTB)"},
52         {1, "Convolutional turbo coding (CTC)"},
53         {0, NULL}
54 };
55
56 static gint hf_phy_attributes_subchannelization_type = -1;
57 static gint hf_phy_attributes_permbase = -1;
58 static gint hf_phy_attributes_modulation_rate = -1;
59 static gint hf_phy_attributes_encoding_type = -1;
60 static gint hf_phy_attributes_num_repeat = -1;
61 static gint hf_phy_attributes_symbol_offset = -1;
62 static gint hf_phy_attributes_num_of_slots = -1;
63 static gint hf_phy_attributes_subchannel = -1;
64
65
66
67 static int dissect_wimax_phy_attributes_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
68 {
69         guint offset = 0;
70         guint tvb_len;
71 /*      guint num_of_slots;*/
72         proto_item *phy_item = NULL;
73         proto_tree *phy_tree = NULL;
74
75         /* update the info column */
76         /*col_append_str(pinfo->cinfo, COL_INFO, "PDU Burst Physical Attributes:");*/
77         col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "PHY-attr");
78         if (tree)
79         {       /* we are being asked for details */
80                 /* get the tvb reported length */
81                 tvb_len = tvb_reported_length(tvb);
82                 /* display PDU Burst Physical Attributes dissector info */
83                 phy_item = proto_tree_add_protocol_format(tree, proto_wimax_phy_attributes_decoder, tvb, offset, tvb_len, "PDU Burst Physical Attributes (%u bytes)", tvb_len);
84                 /* add PDU Burst Physical Attributes subtree */
85                 phy_tree = proto_item_add_subtree(phy_item, ett_wimax_phy_attributes_decoder);
86                 /* display the subchannelization type */
87                 proto_tree_add_item(phy_tree, hf_phy_attributes_subchannelization_type, tvb, offset++, 1, ENC_BIG_ENDIAN);
88                 /* display the permbase */
89                 proto_tree_add_item(phy_tree, hf_phy_attributes_permbase, tvb, offset++, 1, ENC_BIG_ENDIAN);
90                 /* display the modulation rate */
91                 proto_tree_add_item(phy_tree, hf_phy_attributes_modulation_rate, tvb, offset++, 1, ENC_BIG_ENDIAN);
92                 /* display the encoding type */
93                 proto_tree_add_item(phy_tree, hf_phy_attributes_encoding_type, tvb, offset++, 1, ENC_BIG_ENDIAN);
94                 /* display the numRepeat */
95                 proto_tree_add_item(phy_tree, hf_phy_attributes_num_repeat, tvb, offset++, 1, ENC_BIG_ENDIAN);
96                 /* display the symbol offset */
97                 proto_tree_add_item(phy_tree, hf_phy_attributes_symbol_offset, tvb, offset++, 1, ENC_BIG_ENDIAN);
98                 /* display the number of slots */
99                 proto_tree_add_item(phy_tree, hf_phy_attributes_num_of_slots, tvb, offset, 2, ENC_BIG_ENDIAN);
100                 /* get the number of slots */
101 /*              num_of_slots =  tvb_get_guint16(tvb, offset);*/
102                 /* move to next field */
103                 offset += 2;
104                 /* display the physical subchannel list */
105                 while(offset < tvb_len)
106                 {
107                         proto_tree_add_item(phy_tree, hf_phy_attributes_subchannel, tvb, offset++, 1, ENC_BIG_ENDIAN);
108                 }
109         }
110         return tvb_captured_length(tvb);
111 }
112
113 /* Register Wimax PDU Burst Physical Attributes Protocol */
114 void wimax_proto_register_wimax_phy_attributes(void)
115 {
116         /* Physical Attributes display */
117         static hf_register_info hf[] =
118         {
119                 {
120                         &hf_phy_attributes_subchannelization_type,
121                         {"Subchannelization Type", "wmx.phy_attributes.subchannelization_type", FT_UINT8, BASE_DEC, VALS(vals_subchannel_types), 0x0, NULL, HFILL}
122                 },
123                 {
124                         &hf_phy_attributes_permbase,
125                         {"Permbase", "wmx.phy_attributes.permbase", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
126                 },
127                 {
128                         &hf_phy_attributes_modulation_rate,
129                         {"Modulation Rate", "wmx.phy_attributes.modulation_rate", FT_UINT8, BASE_DEC, VALS(vals_modulation_rates), 0x0, NULL, HFILL}
130                 },
131                 {
132                         &hf_phy_attributes_encoding_type,
133                         {"Encoding Type", "wmx.phy_attributes.encoding_type", FT_UINT8, BASE_DEC, VALS(vals_encoding_types), 0x0, NULL, HFILL}
134                 },
135                 {
136                         &hf_phy_attributes_num_repeat,
137                         {"numRepeat", "wmx.phy_attributes.num_repeat", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}
138                 },
139                 {
140                         &hf_phy_attributes_symbol_offset,
141                         {"Symbol Offset", "wmx.phy_attributes.symbol_offset", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}
142                 },
143                 {
144                         &hf_phy_attributes_num_of_slots,
145                         {"Number Of Slots", "wmx.phy_attributes.num_of_slots", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
146                 },
147                 {
148                         &hf_phy_attributes_subchannel,
149                         {"Subchannel", "wmx.phy_attributes.subchannel", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
150                 }
151         };
152
153         /* Setup protocol subtree array */
154         static gint *ett[] =
155                 {
156                         &ett_wimax_phy_attributes_decoder
157                 };
158
159         proto_wimax_phy_attributes_decoder = proto_wimax;
160
161         register_dissector("wimax_phy_attributes_burst_handler", dissect_wimax_phy_attributes_decoder, -1);
162
163         proto_register_field_array(proto_wimax_phy_attributes_decoder, hf, array_length(hf));
164         proto_register_subtree_array(ett, array_length(ett));
165 }
166
167 /*
168  * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
169  *
170  * Local variables:
171  * c-basic-offset: 8
172  * tab-width: 8
173  * indent-tabs-mode: t
174  * End:
175  *
176  * vi: set shiftwidth=8 tabstop=8 noexpandtab:
177  * :indentSize=8:tabSize=8:noTabs=false:
178  */