xref: /openwifi/user_space/inject_80211/ieee80211_radiotap.h (revision 7273ec43e17ceddce2fc08da166686f9b26c5c00)
1*7273ec43Smmehari /*
2*7273ec43Smmehari  * Copyright (c) 2003, 2004 David Young.  All rights reserved.
3*7273ec43Smmehari  *
4*7273ec43Smmehari  * Redistribution and use in source and binary forms, with or without
5*7273ec43Smmehari  * modification, are permitted provided that the following conditions
6*7273ec43Smmehari  * are met:
7*7273ec43Smmehari  * 1. Redistributions of source code must retain the above copyright
8*7273ec43Smmehari  *    notice, this list of conditions and the following disclaimer.
9*7273ec43Smmehari  * 2. Redistributions in binary form must reproduce the above copyright
10*7273ec43Smmehari  *    notice, this list of conditions and the following disclaimer in the
11*7273ec43Smmehari  *    documentation and/or other materials provided with the distribution.
12*7273ec43Smmehari  * 3. The name of David Young may not be used to endorse or promote
13*7273ec43Smmehari  *    products derived from this software without specific prior
14*7273ec43Smmehari  *    written permission.
15*7273ec43Smmehari  *
16*7273ec43Smmehari  * THIS SOFTWARE IS PROVIDED BY DAVID YOUNG ``AS IS'' AND ANY
17*7273ec43Smmehari  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
18*7273ec43Smmehari  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
19*7273ec43Smmehari  * PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL DAVID
20*7273ec43Smmehari  * YOUNG BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21*7273ec43Smmehari  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
22*7273ec43Smmehari  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23*7273ec43Smmehari  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24*7273ec43Smmehari  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25*7273ec43Smmehari  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26*7273ec43Smmehari  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
27*7273ec43Smmehari  * OF SUCH DAMAGE.
28*7273ec43Smmehari  */
29*7273ec43Smmehari 
30*7273ec43Smmehari /*
31*7273ec43Smmehari  * Modifications to fit into the linux IEEE 802.11 stack,
32*7273ec43Smmehari  * Mike Kershaw ([email protected])
33*7273ec43Smmehari  */
34*7273ec43Smmehari 
35*7273ec43Smmehari #ifndef IEEE80211RADIOTAP_H
36*7273ec43Smmehari #define IEEE80211RADIOTAP_H
37*7273ec43Smmehari 
38*7273ec43Smmehari #include <linux/if_ether.h>
39*7273ec43Smmehari #include <linux/kernel.h>
40*7273ec43Smmehari 
41*7273ec43Smmehari /* Base version of the radiotap packet header data */
42*7273ec43Smmehari #define PKTHDR_RADIOTAP_VERSION		0
43*7273ec43Smmehari 
44*7273ec43Smmehari /* A generic radio capture format is desirable. There is one for
45*7273ec43Smmehari  * Linux, but it is neither rigidly defined (there were not even
46*7273ec43Smmehari  * units given for some fields) nor easily extensible.
47*7273ec43Smmehari  *
48*7273ec43Smmehari  * I suggest the following extensible radio capture format. It is
49*7273ec43Smmehari  * based on a bitmap indicating which fields are present.
50*7273ec43Smmehari  *
51*7273ec43Smmehari  * I am trying to describe precisely what the application programmer
52*7273ec43Smmehari  * should expect in the following, and for that reason I tell the
53*7273ec43Smmehari  * units and origin of each measurement (where it applies), or else I
54*7273ec43Smmehari  * use sufficiently weaselly language ("is a monotonically nondecreasing
55*7273ec43Smmehari  * function of...") that I cannot set false expectations for lawyerly
56*7273ec43Smmehari  * readers.
57*7273ec43Smmehari  */
58*7273ec43Smmehari 
59*7273ec43Smmehari /*
60*7273ec43Smmehari  * The radio capture header precedes the 802.11 header.
61*7273ec43Smmehari  * All data in the header is little endian on all platforms.
62*7273ec43Smmehari  */
63*7273ec43Smmehari struct ieee80211_radiotap_header {
64*7273ec43Smmehari 	u8 it_version;		/* Version 0. Only increases
65*7273ec43Smmehari 				 * for drastic changes,
66*7273ec43Smmehari 				 * introduction of compatible
67*7273ec43Smmehari 				 * new fields does not count.
68*7273ec43Smmehari 				 */
69*7273ec43Smmehari 	u8 it_pad;
70*7273ec43Smmehari 	__le16 it_len;		/* length of the whole
71*7273ec43Smmehari 				 * header in bytes, including
72*7273ec43Smmehari 				 * it_version, it_pad,
73*7273ec43Smmehari 				 * it_len, and data fields.
74*7273ec43Smmehari 				 */
75*7273ec43Smmehari 	__le32 it_present;	/* A bitmap telling which
76*7273ec43Smmehari 				 * fields are present. Set bit 31
77*7273ec43Smmehari 				 * (0x80000000) to extend the
78*7273ec43Smmehari 				 * bitmap by another 32 bits.
79*7273ec43Smmehari 				 * Additional extensions are made
80*7273ec43Smmehari 				 * by setting bit 31.
81*7273ec43Smmehari 				 */
82*7273ec43Smmehari } __packed;
83*7273ec43Smmehari 
84*7273ec43Smmehari /* Name                                 Data type    Units
85*7273ec43Smmehari  * ----                                 ---------    -----
86*7273ec43Smmehari  *
87*7273ec43Smmehari  * IEEE80211_RADIOTAP_TSFT              __le64       microseconds
88*7273ec43Smmehari  *
89*7273ec43Smmehari  *      Value in microseconds of the MAC's 64-bit 802.11 Time
90*7273ec43Smmehari  *      Synchronization Function timer when the first bit of the
91*7273ec43Smmehari  *      MPDU arrived at the MAC. For received frames, only.
92*7273ec43Smmehari  *
93*7273ec43Smmehari  * IEEE80211_RADIOTAP_CHANNEL           2 x __le16   MHz, bitmap
94*7273ec43Smmehari  *
95*7273ec43Smmehari  *      Tx/Rx frequency in MHz, followed by flags (see below).
96*7273ec43Smmehari  *
97*7273ec43Smmehari  * IEEE80211_RADIOTAP_FHSS              __le16       see below
98*7273ec43Smmehari  *
99*7273ec43Smmehari  *      For frequency-hopping radios, the hop set (first byte)
100*7273ec43Smmehari  *      and pattern (second byte).
101*7273ec43Smmehari  *
102*7273ec43Smmehari  * IEEE80211_RADIOTAP_RATE              u8           500kb/s
103*7273ec43Smmehari  *
104*7273ec43Smmehari  *      Tx/Rx data rate
105*7273ec43Smmehari  *
106*7273ec43Smmehari  * IEEE80211_RADIOTAP_DBM_ANTSIGNAL     s8           decibels from
107*7273ec43Smmehari  *                                                   one milliwatt (dBm)
108*7273ec43Smmehari  *
109*7273ec43Smmehari  *      RF signal power at the antenna, decibel difference from
110*7273ec43Smmehari  *      one milliwatt.
111*7273ec43Smmehari  *
112*7273ec43Smmehari  * IEEE80211_RADIOTAP_DBM_ANTNOISE      s8           decibels from
113*7273ec43Smmehari  *                                                   one milliwatt (dBm)
114*7273ec43Smmehari  *
115*7273ec43Smmehari  *      RF noise power at the antenna, decibel difference from one
116*7273ec43Smmehari  *      milliwatt.
117*7273ec43Smmehari  *
118*7273ec43Smmehari  * IEEE80211_RADIOTAP_DB_ANTSIGNAL      u8           decibel (dB)
119*7273ec43Smmehari  *
120*7273ec43Smmehari  *      RF signal power at the antenna, decibel difference from an
121*7273ec43Smmehari  *      arbitrary, fixed reference.
122*7273ec43Smmehari  *
123*7273ec43Smmehari  * IEEE80211_RADIOTAP_DB_ANTNOISE       u8           decibel (dB)
124*7273ec43Smmehari  *
125*7273ec43Smmehari  *      RF noise power at the antenna, decibel difference from an
126*7273ec43Smmehari  *      arbitrary, fixed reference point.
127*7273ec43Smmehari  *
128*7273ec43Smmehari  * IEEE80211_RADIOTAP_LOCK_QUALITY      __le16       unitless
129*7273ec43Smmehari  *
130*7273ec43Smmehari  *      Quality of Barker code lock. Unitless. Monotonically
131*7273ec43Smmehari  *      nondecreasing with "better" lock strength. Called "Signal
132*7273ec43Smmehari  *      Quality" in datasheets.  (Is there a standard way to measure
133*7273ec43Smmehari  *      this?)
134*7273ec43Smmehari  *
135*7273ec43Smmehari  * IEEE80211_RADIOTAP_TX_ATTENUATION    __le16       unitless
136*7273ec43Smmehari  *
137*7273ec43Smmehari  *      Transmit power expressed as unitless distance from max
138*7273ec43Smmehari  *      power set at factory calibration.  0 is max power.
139*7273ec43Smmehari  *      Monotonically nondecreasing with lower power levels.
140*7273ec43Smmehari  *
141*7273ec43Smmehari  * IEEE80211_RADIOTAP_DB_TX_ATTENUATION __le16       decibels (dB)
142*7273ec43Smmehari  *
143*7273ec43Smmehari  *      Transmit power expressed as decibel distance from max power
144*7273ec43Smmehari  *      set at factory calibration.  0 is max power.  Monotonically
145*7273ec43Smmehari  *      nondecreasing with lower power levels.
146*7273ec43Smmehari  *
147*7273ec43Smmehari  * IEEE80211_RADIOTAP_DBM_TX_POWER      s8           decibels from
148*7273ec43Smmehari  *                                                   one milliwatt (dBm)
149*7273ec43Smmehari  *
150*7273ec43Smmehari  *      Transmit power expressed as dBm (decibels from a 1 milliwatt
151*7273ec43Smmehari  *      reference). This is the absolute power level measured at
152*7273ec43Smmehari  *      the antenna port.
153*7273ec43Smmehari  *
154*7273ec43Smmehari  * IEEE80211_RADIOTAP_FLAGS             u8           bitmap
155*7273ec43Smmehari  *
156*7273ec43Smmehari  *      Properties of transmitted and received frames. See flags
157*7273ec43Smmehari  *      defined below.
158*7273ec43Smmehari  *
159*7273ec43Smmehari  * IEEE80211_RADIOTAP_ANTENNA           u8           antenna index
160*7273ec43Smmehari  *
161*7273ec43Smmehari  *      Unitless indication of the Rx/Tx antenna for this packet.
162*7273ec43Smmehari  *      The first antenna is antenna 0.
163*7273ec43Smmehari  *
164*7273ec43Smmehari  * IEEE80211_RADIOTAP_RX_FLAGS          __le16       bitmap
165*7273ec43Smmehari  *
166*7273ec43Smmehari  *     Properties of received frames. See flags defined below.
167*7273ec43Smmehari  *
168*7273ec43Smmehari  * IEEE80211_RADIOTAP_TX_FLAGS          __le16       bitmap
169*7273ec43Smmehari  *
170*7273ec43Smmehari  *     Properties of transmitted frames. See flags defined below.
171*7273ec43Smmehari  *
172*7273ec43Smmehari  * IEEE80211_RADIOTAP_RTS_RETRIES       u8           data
173*7273ec43Smmehari  *
174*7273ec43Smmehari  *     Number of rts retries a transmitted frame used.
175*7273ec43Smmehari  *
176*7273ec43Smmehari  * IEEE80211_RADIOTAP_DATA_RETRIES      u8           data
177*7273ec43Smmehari  *
178*7273ec43Smmehari  *     Number of unicast retries a transmitted frame used.
179*7273ec43Smmehari  *
180*7273ec43Smmehari  * IEEE80211_RADIOTAP_MCS	u8, u8, u8		unitless
181*7273ec43Smmehari  *
182*7273ec43Smmehari  *     Contains a bitmap of known fields/flags, the flags, and
183*7273ec43Smmehari  *     the MCS index.
184*7273ec43Smmehari  *
185*7273ec43Smmehari  * IEEE80211_RADIOTAP_AMPDU_STATUS	u32, u16, u8, u8	unitless
186*7273ec43Smmehari  *
187*7273ec43Smmehari  *	Contains the AMPDU information for the subframe.
188*7273ec43Smmehari  *
189*7273ec43Smmehari  * IEEE80211_RADIOTAP_VHT	u16, u8, u8, u8[4], u8, u8, u16
190*7273ec43Smmehari  *
191*7273ec43Smmehari  *	Contains VHT information about this frame.
192*7273ec43Smmehari  */
193*7273ec43Smmehari enum ieee80211_radiotap_type {
194*7273ec43Smmehari 	IEEE80211_RADIOTAP_TSFT = 0,
195*7273ec43Smmehari 	IEEE80211_RADIOTAP_FLAGS = 1,
196*7273ec43Smmehari 	IEEE80211_RADIOTAP_RATE = 2,
197*7273ec43Smmehari 	IEEE80211_RADIOTAP_CHANNEL = 3,
198*7273ec43Smmehari 	IEEE80211_RADIOTAP_FHSS = 4,
199*7273ec43Smmehari 	IEEE80211_RADIOTAP_DBM_ANTSIGNAL = 5,
200*7273ec43Smmehari 	IEEE80211_RADIOTAP_DBM_ANTNOISE = 6,
201*7273ec43Smmehari 	IEEE80211_RADIOTAP_LOCK_QUALITY = 7,
202*7273ec43Smmehari 	IEEE80211_RADIOTAP_TX_ATTENUATION = 8,
203*7273ec43Smmehari 	IEEE80211_RADIOTAP_DB_TX_ATTENUATION = 9,
204*7273ec43Smmehari 	IEEE80211_RADIOTAP_DBM_TX_POWER = 10,
205*7273ec43Smmehari 	IEEE80211_RADIOTAP_ANTENNA = 11,
206*7273ec43Smmehari 	IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12,
207*7273ec43Smmehari 	IEEE80211_RADIOTAP_DB_ANTNOISE = 13,
208*7273ec43Smmehari 	IEEE80211_RADIOTAP_RX_FLAGS = 14,
209*7273ec43Smmehari 	IEEE80211_RADIOTAP_TX_FLAGS = 15,
210*7273ec43Smmehari 	IEEE80211_RADIOTAP_RTS_RETRIES = 16,
211*7273ec43Smmehari 	IEEE80211_RADIOTAP_DATA_RETRIES = 17,
212*7273ec43Smmehari 
213*7273ec43Smmehari 	IEEE80211_RADIOTAP_MCS = 19,
214*7273ec43Smmehari 	IEEE80211_RADIOTAP_AMPDU_STATUS = 20,
215*7273ec43Smmehari 	IEEE80211_RADIOTAP_VHT = 21,
216*7273ec43Smmehari 
217*7273ec43Smmehari 	/* valid in every it_present bitmap, even vendor namespaces */
218*7273ec43Smmehari 	IEEE80211_RADIOTAP_RADIOTAP_NAMESPACE = 29,
219*7273ec43Smmehari 	IEEE80211_RADIOTAP_VENDOR_NAMESPACE = 30,
220*7273ec43Smmehari 	IEEE80211_RADIOTAP_EXT = 31
221*7273ec43Smmehari };
222*7273ec43Smmehari 
223*7273ec43Smmehari /* Channel flags. */
224*7273ec43Smmehari #define	IEEE80211_CHAN_TURBO	0x0010	/* Turbo channel */
225*7273ec43Smmehari #define	IEEE80211_CHAN_CCK	0x0020	/* CCK channel */
226*7273ec43Smmehari #define	IEEE80211_CHAN_OFDM	0x0040	/* OFDM channel */
227*7273ec43Smmehari #define	IEEE80211_CHAN_2GHZ	0x0080	/* 2 GHz spectrum channel. */
228*7273ec43Smmehari #define	IEEE80211_CHAN_5GHZ	0x0100	/* 5 GHz spectrum channel */
229*7273ec43Smmehari #define	IEEE80211_CHAN_PASSIVE	0x0200	/* Only passive scan allowed */
230*7273ec43Smmehari #define	IEEE80211_CHAN_DYN	0x0400	/* Dynamic CCK-OFDM channel */
231*7273ec43Smmehari #define	IEEE80211_CHAN_GFSK	0x0800	/* GFSK channel (FHSS PHY) */
232*7273ec43Smmehari 
233*7273ec43Smmehari /* For IEEE80211_RADIOTAP_FLAGS */
234*7273ec43Smmehari #define	IEEE80211_RADIOTAP_F_CFP	0x01	/* sent/received
235*7273ec43Smmehari 						 * during CFP
236*7273ec43Smmehari 						 */
237*7273ec43Smmehari #define	IEEE80211_RADIOTAP_F_SHORTPRE	0x02	/* sent/received
238*7273ec43Smmehari 						 * with short
239*7273ec43Smmehari 						 * preamble
240*7273ec43Smmehari 						 */
241*7273ec43Smmehari #define	IEEE80211_RADIOTAP_F_WEP	0x04	/* sent/received
242*7273ec43Smmehari 						 * with WEP encryption
243*7273ec43Smmehari 						 */
244*7273ec43Smmehari #define	IEEE80211_RADIOTAP_F_FRAG	0x08	/* sent/received
245*7273ec43Smmehari 						 * with fragmentation
246*7273ec43Smmehari 						 */
247*7273ec43Smmehari #define	IEEE80211_RADIOTAP_F_FCS	0x10	/* frame includes FCS */
248*7273ec43Smmehari #define	IEEE80211_RADIOTAP_F_DATAPAD	0x20	/* frame has padding between
249*7273ec43Smmehari 						 * 802.11 header and payload
250*7273ec43Smmehari 						 * (to 32-bit boundary)
251*7273ec43Smmehari 						 */
252*7273ec43Smmehari #define IEEE80211_RADIOTAP_F_BADFCS	0x40	/* bad FCS */
253*7273ec43Smmehari 
254*7273ec43Smmehari /* For IEEE80211_RADIOTAP_RX_FLAGS */
255*7273ec43Smmehari #define IEEE80211_RADIOTAP_F_RX_BADPLCP	0x0002	/* frame has bad PLCP */
256*7273ec43Smmehari 
257*7273ec43Smmehari /* For IEEE80211_RADIOTAP_TX_FLAGS */
258*7273ec43Smmehari #define IEEE80211_RADIOTAP_F_TX_FAIL	0x0001	/* failed due to excessive
259*7273ec43Smmehari 						 * retries */
260*7273ec43Smmehari #define IEEE80211_RADIOTAP_F_TX_CTS	0x0002	/* used cts 'protection' */
261*7273ec43Smmehari #define IEEE80211_RADIOTAP_F_TX_RTS	0x0004	/* used rts/cts handshake */
262*7273ec43Smmehari #define IEEE80211_RADIOTAP_F_TX_NOACK	0x0008	/* don't expect an ack */
263*7273ec43Smmehari 
264*7273ec43Smmehari 
265*7273ec43Smmehari /* For IEEE80211_RADIOTAP_MCS */
266*7273ec43Smmehari #define IEEE80211_RADIOTAP_MCS_HAVE_BW		0x01
267*7273ec43Smmehari #define IEEE80211_RADIOTAP_MCS_HAVE_MCS		0x02
268*7273ec43Smmehari #define IEEE80211_RADIOTAP_MCS_HAVE_GI		0x04
269*7273ec43Smmehari #define IEEE80211_RADIOTAP_MCS_HAVE_FMT		0x08
270*7273ec43Smmehari #define IEEE80211_RADIOTAP_MCS_HAVE_FEC		0x10
271*7273ec43Smmehari 
272*7273ec43Smmehari #define IEEE80211_RADIOTAP_MCS_BW_MASK		0x03
273*7273ec43Smmehari #define		IEEE80211_RADIOTAP_MCS_BW_20	0
274*7273ec43Smmehari #define		IEEE80211_RADIOTAP_MCS_BW_40	1
275*7273ec43Smmehari #define		IEEE80211_RADIOTAP_MCS_BW_20L	2
276*7273ec43Smmehari #define		IEEE80211_RADIOTAP_MCS_BW_20U	3
277*7273ec43Smmehari #define IEEE80211_RADIOTAP_MCS_SGI		0x04
278*7273ec43Smmehari #define IEEE80211_RADIOTAP_MCS_FMT_GF		0x08
279*7273ec43Smmehari #define IEEE80211_RADIOTAP_MCS_FEC_LDPC		0x10
280*7273ec43Smmehari 
281*7273ec43Smmehari /* For IEEE80211_RADIOTAP_AMPDU_STATUS */
282*7273ec43Smmehari #define IEEE80211_RADIOTAP_AMPDU_REPORT_ZEROLEN		0x0001
283*7273ec43Smmehari #define IEEE80211_RADIOTAP_AMPDU_IS_ZEROLEN		0x0002
284*7273ec43Smmehari #define IEEE80211_RADIOTAP_AMPDU_LAST_KNOWN		0x0004
285*7273ec43Smmehari #define IEEE80211_RADIOTAP_AMPDU_IS_LAST		0x0008
286*7273ec43Smmehari #define IEEE80211_RADIOTAP_AMPDU_DELIM_CRC_ERR		0x0010
287*7273ec43Smmehari #define IEEE80211_RADIOTAP_AMPDU_DELIM_CRC_KNOWN	0x0020
288*7273ec43Smmehari 
289*7273ec43Smmehari /* For IEEE80211_RADIOTAP_VHT */
290*7273ec43Smmehari #define IEEE80211_RADIOTAP_VHT_KNOWN_STBC			0x0001
291*7273ec43Smmehari #define IEEE80211_RADIOTAP_VHT_KNOWN_TXOP_PS_NA			0x0002
292*7273ec43Smmehari #define IEEE80211_RADIOTAP_VHT_KNOWN_GI				0x0004
293*7273ec43Smmehari #define IEEE80211_RADIOTAP_VHT_KNOWN_SGI_NSYM_DIS		0x0008
294*7273ec43Smmehari #define IEEE80211_RADIOTAP_VHT_KNOWN_LDPC_EXTRA_OFDM_SYM	0x0010
295*7273ec43Smmehari #define IEEE80211_RADIOTAP_VHT_KNOWN_BEAMFORMED			0x0020
296*7273ec43Smmehari #define IEEE80211_RADIOTAP_VHT_KNOWN_BANDWIDTH			0x0040
297*7273ec43Smmehari #define IEEE80211_RADIOTAP_VHT_KNOWN_GROUP_ID			0x0080
298*7273ec43Smmehari #define IEEE80211_RADIOTAP_VHT_KNOWN_PARTIAL_AID		0x0100
299*7273ec43Smmehari 
300*7273ec43Smmehari #define IEEE80211_RADIOTAP_VHT_FLAG_STBC			0x01
301*7273ec43Smmehari #define IEEE80211_RADIOTAP_VHT_FLAG_TXOP_PS_NA			0x02
302*7273ec43Smmehari #define IEEE80211_RADIOTAP_VHT_FLAG_SGI				0x04
303*7273ec43Smmehari #define IEEE80211_RADIOTAP_VHT_FLAG_SGI_NSYM_M10_9		0x08
304*7273ec43Smmehari #define IEEE80211_RADIOTAP_VHT_FLAG_LDPC_EXTRA_OFDM_SYM		0x10
305*7273ec43Smmehari #define IEEE80211_RADIOTAP_VHT_FLAG_BEAMFORMED			0x20
306*7273ec43Smmehari 
307*7273ec43Smmehari #endif				/* IEEE80211_RADIOTAP_H */
308