2 * packet-netmon-802_11.c
3 * Decode packets with a Network Monitor 802.11 radio header
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * Copied from README.developer
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
35 #include <epan/packet.h>
38 static int proto_netmon_802_11 = -1;
40 #define MIN_HEADER_LEN 32
43 #define OP_MODE_STA 0x00000001 /* station mode */
44 #define OP_MODE_AP 0x00000002 /* AP mode */
45 #define OP_MODE_STA_EXT 0x00000004 /* extensible station mode */
46 #define OP_MODE_MON 0x80000000 /* monitor mode */
49 #define PHY_TYPE_11A 4
50 #define PHY_TYPE_11B 5
51 #define PHY_TYPE_11G 6
52 #define PHY_TYPE_11N 7
54 static int hf_netmon_802_11_version = -1;
55 static int hf_netmon_802_11_length = -1;
56 static int hf_netmon_802_11_op_mode = -1;
57 static int hf_netmon_802_11_op_mode_sta = -1;
58 static int hf_netmon_802_11_op_mode_ap = -1;
59 static int hf_netmon_802_11_op_mode_sta_ext = -1;
60 static int hf_netmon_802_11_op_mode_mon = -1;
61 static int hf_netmon_802_11_flags = -1;
62 static int hf_netmon_802_11_phy_type = -1;
63 static int hf_netmon_802_11_channel = -1;
64 static int hf_netmon_802_11_frequency = -1;
65 static int hf_netmon_802_11_rssi = -1;
66 static int hf_netmon_802_11_datarate = -1;
67 static int hf_netmon_802_11_timestamp = -1;
69 static gint ett_netmon_802_11 = -1;
70 static gint ett_netmon_802_11_op_mode = -1;
72 static dissector_handle_t ieee80211_handle;
75 dissect_netmon_802_11(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
77 proto_tree *wlan_tree, *opmode_tree;
88 col_set_str(pinfo->cinfo, COL_PROTOCOL, "WLAN");
89 col_clear(pinfo->cinfo, COL_INFO);
92 version = tvb_get_guint8(tvb, offset);
93 length = tvb_get_letohs(tvb, offset+1);
94 col_add_fstr(pinfo->cinfo, COL_INFO, "NetMon WLAN Capture v%u, Length %u",
100 if (length < MIN_HEADER_LEN) {
105 /* Dissect the packet */
107 ti = proto_tree_add_item(tree, proto_netmon_802_11, tvb, 0, length,
109 wlan_tree = proto_item_add_subtree(ti, ett_netmon_802_11);
110 proto_tree_add_item(wlan_tree, hf_netmon_802_11_version, tvb, offset, 1,
113 proto_tree_add_item(wlan_tree, hf_netmon_802_11_length, tvb, offset, 2,
116 ti = proto_tree_add_item(wlan_tree, hf_netmon_802_11_op_mode, tvb, offset, 4, ENC_LITTLE_ENDIAN);
117 opmode_tree = proto_item_add_subtree(ti, ett_netmon_802_11_op_mode);
118 proto_tree_add_item(opmode_tree, hf_netmon_802_11_op_mode_sta, tvb, offset,
119 4, ENC_LITTLE_ENDIAN);
120 proto_tree_add_item(opmode_tree, hf_netmon_802_11_op_mode_ap, tvb, offset,
121 4, ENC_LITTLE_ENDIAN);
122 proto_tree_add_item(opmode_tree, hf_netmon_802_11_op_mode_sta_ext, tvb,
123 offset, 4, ENC_LITTLE_ENDIAN);
124 proto_tree_add_item(opmode_tree, hf_netmon_802_11_op_mode_mon, tvb, offset,
125 4, ENC_LITTLE_ENDIAN);
127 flags = tvb_get_letohl(tvb, offset);
129 if (flags != 0xffffffff) {
130 proto_tree_add_item(wlan_tree, hf_netmon_802_11_phy_type, tvb, offset, 4,
133 channel = tvb_get_letohl(tvb, offset);
134 if (channel < 1000) {
135 proto_tree_add_uint(wlan_tree, hf_netmon_802_11_channel,
136 tvb, offset, 4, channel);
138 proto_tree_add_uint_format_value(wlan_tree, hf_netmon_802_11_frequency,
139 tvb, offset, 4, channel,
143 rssi = tvb_get_letohl(tvb, offset);
144 proto_tree_add_int_format_value(wlan_tree, hf_netmon_802_11_rssi,
145 tvb, offset, 4, rssi,
148 rate = tvb_get_guint8(tvb, offset);
150 proto_tree_add_uint_format_value(wlan_tree, hf_netmon_802_11_datarate,
151 tvb, offset, 1, rate,
154 proto_tree_add_uint_format_value(wlan_tree, hf_netmon_802_11_datarate,
155 tvb, offset, 1, rate,
161 proto_tree_add_item(wlan_tree, hf_netmon_802_11_timestamp, tvb, offset, 8,
169 /* dissect the 802.11 header next */
170 next_tvb = tvb_new_subset(tvb, offset, -1, -1);
171 call_dissector(ieee80211_handle, next_tvb, pinfo, tree);
175 proto_register_netmon_802_11(void)
177 static const value_string phy_type[] = {
178 { PHY_TYPE_11A, "802.11a" },
179 { PHY_TYPE_11B, "802.11b" },
180 { PHY_TYPE_11G, "802.11g" },
181 { PHY_TYPE_11N, "802.11n" },
185 static hf_register_info hf[] = {
186 { &hf_netmon_802_11_version, { "Header revision", "netmon_802_11.version", FT_UINT8,
187 BASE_DEC, NULL, 0x0, "", HFILL } },
188 { &hf_netmon_802_11_length, { "Header length", "netmon_802_11.length", FT_UINT16,
189 BASE_DEC, NULL, 0x0, "", HFILL } },
190 { &hf_netmon_802_11_op_mode, { "Operation mode", "netmon_802_11.op_mode", FT_UINT32,
191 BASE_HEX, NULL, 0x0, "", HFILL } },
192 { &hf_netmon_802_11_op_mode_sta, { "Station mode", "netmon_802_11.op_mode.sta", FT_UINT32,
193 BASE_HEX, NULL, OP_MODE_STA, "", HFILL } },
194 { &hf_netmon_802_11_op_mode_ap, { "AP mode", "netmon_802_11.op_mode.ap", FT_UINT32,
195 BASE_HEX, NULL, OP_MODE_AP, "", HFILL } },
196 { &hf_netmon_802_11_op_mode_sta_ext, { "Extensible station mode", "netmon_802_11.op_mode.sta_ext", FT_UINT32,
197 BASE_HEX, NULL, OP_MODE_STA_EXT, "", HFILL } },
198 { &hf_netmon_802_11_op_mode_mon, { "Monitor mode", "netmon_802_11.op_mode.on", FT_UINT32,
199 BASE_HEX, NULL, OP_MODE_MON, "", HFILL } },
200 { &hf_netmon_802_11_flags, { "Flags", "netmon_802_11.flags", FT_UINT32,
201 BASE_HEX, NULL, 0x0, "", HFILL } },
202 { &hf_netmon_802_11_phy_type, { "PHY type", "netmon_802_11.phy_type", FT_UINT32,
203 BASE_DEC, VALS(phy_type), 0x0, "", HFILL } },
204 { &hf_netmon_802_11_channel, { "Channel", "netmon_802_11.channel", FT_UINT32,
205 BASE_DEC, NULL, 0x0, "", HFILL } },
206 { &hf_netmon_802_11_frequency, { "Center frequency", "netmon_802_11.frequency", FT_UINT32,
207 BASE_DEC, NULL, 0x0, "", HFILL } },
208 { &hf_netmon_802_11_rssi, { "RSSI", "netmon_802_11.rssi", FT_INT32,
209 BASE_DEC, NULL, 0x0, "", HFILL } },
210 { &hf_netmon_802_11_datarate, { "Data rate", "netmon_802_11.datarate", FT_UINT32,
211 BASE_DEC, NULL, 0x0, "", HFILL } },
213 * XXX - is this host, or MAC, time stamp?
214 * It might be a FILETIME.
216 { &hf_netmon_802_11_timestamp, { "Timestamp", "netmon_802_11.timestamp", FT_UINT64,
217 BASE_DEC, NULL, 0x0, "", HFILL } },
219 static gint *ett[] = {
221 &ett_netmon_802_11_op_mode
224 proto_netmon_802_11 = proto_register_protocol("NetMon 802.11 capture header",
227 proto_register_field_array(proto_netmon_802_11, hf, array_length(hf));
228 proto_register_subtree_array(ett, array_length(ett));
232 proto_reg_handoff_netmon_802_11(void)
234 dissector_handle_t netmon_802_11_handle;
236 /* handle for 802.11 dissector */
237 ieee80211_handle = find_dissector("wlan");
238 netmon_802_11_handle = create_dissector_handle(dissect_netmon_802_11,
239 proto_netmon_802_11);
240 dissector_add("wtap_encap", WTAP_ENCAP_IEEE802_11_NETMON_RADIO, netmon_802_11_handle);