3 * Decode packets with a AVS-WLAN header
5 * AVS linux-wlan-based products use a new sniff header to replace the
6 * old prism2-specific one dissected in packet-prism2.c. This one has
7 * additional fields, is designed to be non-hardware-specific, and more
8 * importantly, version and length fields so it can be extended later
9 * without breaking anything.
13 * $Id: packet-wlancap.c,v 1.2 2003/08/05 19:09:27 guy Exp $
15 * Ethereal - Network traffic analyzer
16 * By Gerald Combs <gerald@ethereal.com>
17 * Copyright 1998 Gerald Combs
19 * Copied from README.developer
21 * This program is free software; you can redistribute it and/or
22 * modify it under the terms of the GNU General Public License
23 * as published by the Free Software Foundation; either version 2
24 * of the License, or (at your option) any later version.
26 * This program is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 * GNU General Public License for more details.
31 * You should have received a copy of the GNU General Public License
32 * along with this program; if not, write to the Free Software
33 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
43 #include <epan/packet.h>
44 #include "packet-ieee80211.h"
45 #include "packet-wlancap.h"
50 static int proto_wlancap = -1;
52 /* header attached during wlan monitor mode */
53 struct wlan_header_v1 {
70 static int hf_wlan_version = -1;
71 static int hf_wlan_length = -1;
72 static int hf_wlan_mactime = -1;
73 static int hf_wlan_hosttime = -1;
74 static int hf_wlan_phytype = -1;
75 static int hf_wlan_channel = -1;
76 static int hf_wlan_datarate = -1;
77 static int hf_wlan_antenna = -1;
78 static int hf_wlan_priority = -1;
79 static int hf_wlan_ssi_type = -1;
80 static int hf_wlan_ssi_signal = -1;
81 static int hf_wlan_ssi_noise = -1;
82 static int hf_wlan_preamble = -1;
83 static int hf_wlan_encoding = -1;
85 static gint ett_wlan = -1;
87 static dissector_handle_t ieee80211_handle;
90 dissect_wlancap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
93 capture_wlancap(const guchar *pd, int offset, int len, packet_counts *ld)
95 /* XXX eventually add in a version test. */
96 if(!BYTES_ARE_IN_FRAME(offset, len, (int)sizeof(struct wlan_header_v1))) {
100 offset += sizeof(struct wlan_header_v1);
102 /* 802.11 header follows */
103 capture_ieee80211(pd, offset, len, ld);
107 proto_register_wlancap(void)
110 static const value_string phy_type[] = {
112 { 1, "FHSS 802.11 '97" },
113 { 2, "DSSS 802.11 '97" },
114 { 3, "IR Baseband" },
115 { 4, "DSSS 802.11b" },
116 { 5, "PBCC 802.11b" },
117 { 6, "OFDM 802.11g" },
118 { 7, "PBCC 802.11g" },
119 { 8, "OFDM 802.11a" },
122 static const value_string encoding_type[] = {
129 static const value_string ssi_type[] = {
131 { 1, "Normalized RSSI" },
136 static const value_string preamble_type[] = {
142 static hf_register_info hf[] = {
143 { &hf_wlan_version, { "Header revision", "wlancap.version", FT_UINT32,
144 BASE_DEC, NULL, 0x0, "", HFILL } },
145 { &hf_wlan_length, { "Header length", "wlancap.length", FT_UINT32,
146 BASE_DEC, NULL, 0x0, "", HFILL } },
147 { &hf_wlan_mactime, { "MAC timestamp", "wlancap.mactime", FT_UINT64,
148 BASE_DEC, NULL, 0x0, "", HFILL } },
149 { &hf_wlan_hosttime, { "Host timestamp", "wlancap.hosttime", FT_UINT64,
150 BASE_DEC, NULL, 0x0, "", HFILL } },
151 { &hf_wlan_phytype, { "PHY type", "wlancap.phytype", FT_UINT32, BASE_DEC,
152 VALS(phy_type), 0x0, "", HFILL } },
153 { &hf_wlan_channel, { "Channel", "wlancap.channel", FT_UINT32, BASE_DEC,
154 NULL, 0x0, "", HFILL } },
155 { &hf_wlan_datarate, { "Data rate", "wlancap.datarate", FT_UINT32,
156 BASE_DEC, NULL, 0x0, "", HFILL } },
157 { &hf_wlan_antenna, { "Antenna", "wlancap.antenna", FT_UINT32, BASE_DEC,
158 NULL, 0x0, "", HFILL } },
159 { &hf_wlan_priority, { "Priority", "wlancap.priority", FT_UINT32, BASE_DEC,
160 NULL, 0x0, "", HFILL } },
161 { &hf_wlan_ssi_type, { "SSI Type", "wlancap.ssi_type", FT_UINT32, BASE_DEC,
162 VALS(ssi_type), 0x0, "", HFILL } },
163 { &hf_wlan_ssi_signal, { "SSI Signal", "wlancap.ssi_signal", FT_INT32,
164 BASE_DEC, NULL, 0x0, "", HFILL } },
165 { &hf_wlan_ssi_noise, { "SSI Noise", "wlancap.ssi_noise", FT_INT32,
166 BASE_DEC, NULL, 0x0, "", HFILL } },
167 { &hf_wlan_preamble, { "Preamble", "wlancap.preamble", FT_UINT32,
168 BASE_DEC, VALS(preamble_type), 0x0, "", HFILL } },
169 { &hf_wlan_encoding, { "Encoding Type", "wlancap.encoding", FT_UINT32,
170 BASE_DEC, VALS(encoding_type), 0x0, "", HFILL } },
172 static gint *ett[] = {
176 proto_wlancap = proto_register_protocol("AVS WLAN Capture header", "AVS WLANCAP", "wlancap");
177 proto_register_field_array(proto_wlancap, hf, array_length(hf));
178 proto_register_subtree_array(ett, array_length(ett));
179 register_dissector("wlancap", dissect_wlancap, proto_wlancap);
184 dissect_wlancap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
186 proto_tree *wlan_tree;
193 if(check_col(pinfo->cinfo, COL_PROTOCOL))
194 col_set_str(pinfo->cinfo, COL_PROTOCOL, "WLAN");
195 if(check_col(pinfo->cinfo, COL_INFO))
196 col_clear(pinfo->cinfo, COL_INFO);
199 version = tvb_get_ntohl(tvb, offset) - WLANCAP_MAGIC_COOKIE_BASE;
200 length = tvb_get_ntohl(tvb, offset+4);
202 if(check_col(pinfo->cinfo, COL_INFO))
203 col_add_fstr(pinfo->cinfo, COL_INFO, "AVS WLAN Capture v%x, Length %d",version, length);
205 /* Dissect the packet */
207 ti = proto_tree_add_protocol_format(tree, proto_wlancap,
208 tvb, 0, length, "AVS WLAN Monitoring Header");
209 wlan_tree = proto_item_add_subtree(ti, ett_wlan);
210 proto_tree_add_uint(wlan_tree, hf_wlan_version, tvb, offset,
211 4, tvb_get_ntohl(tvb, offset) - WLANCAP_MAGIC_COOKIE_BASE);
213 proto_tree_add_uint(wlan_tree, hf_wlan_length, tvb, offset,
214 4, tvb_get_ntohl(tvb, offset));
216 proto_tree_add_item(wlan_tree, hf_wlan_mactime, tvb, offset,
219 proto_tree_add_item(wlan_tree, hf_wlan_hosttime, tvb, offset,
223 proto_tree_add_uint(wlan_tree, hf_wlan_phytype, tvb, offset,
224 4, tvb_get_ntohl(tvb, offset));
226 /* XXX cook channel (fh uses different numbers) */
227 proto_tree_add_uint(wlan_tree, hf_wlan_channel, tvb, offset,
228 4, tvb_get_ntohl(tvb, offset));
231 proto_tree_add_uint_format(wlan_tree, hf_wlan_datarate, tvb, offset,
232 4, tvb_get_ntohl(tvb, offset) * 100,
234 tvb_get_ntohl(tvb, offset) * 100);
236 proto_tree_add_uint(wlan_tree, hf_wlan_antenna, tvb, offset,
237 4, tvb_get_ntohl(tvb, offset));
239 proto_tree_add_uint(wlan_tree, hf_wlan_priority, tvb, offset,
240 4, tvb_get_ntohl(tvb, offset));
242 proto_tree_add_uint(wlan_tree, hf_wlan_ssi_type, tvb, offset,
243 4, tvb_get_ntohl(tvb, offset));
245 /* XXX cook ssi_signal (Based on type; ie format) */
246 proto_tree_add_int(wlan_tree, hf_wlan_ssi_signal, tvb, offset,
247 4, tvb_get_ntohl(tvb, offset));
249 /* XXX cook ssi_noise (Based on type; ie format) */
250 proto_tree_add_int(wlan_tree, hf_wlan_ssi_noise, tvb, offset,
251 4, tvb_get_ntohl(tvb, offset));
253 proto_tree_add_uint(wlan_tree, hf_wlan_preamble, tvb, offset,
254 4, tvb_get_ntohl(tvb, offset));
256 proto_tree_add_uint(wlan_tree, hf_wlan_encoding, tvb, offset,
257 4, tvb_get_ntohl(tvb, offset));
264 /* dissect the 802.11 header next */
265 next_tvb = tvb_new_subset(tvb, offset, -1, -1);
266 call_dissector(ieee80211_handle, next_tvb, pinfo, tree);
270 proto_reg_handoff_wlancap(void)
272 dissector_handle_t wlancap_handle;
274 /* handle for 802.11 dissector */
275 ieee80211_handle = find_dissector("wlan");
277 wlancap_handle = create_dissector_handle(dissect_wlancap, proto_wlancap);
279 dissector_add("wtap_encap", WTAP_ENCAP_WLAN_HEADER, wlancap_handle);