xref: /openwifi/user_space/inject_80211/ieee80211_radiotap.h (revision 0802e503a4f76f633c2f238c3ad39f8352240a6e)
17273ec43Smmehari /*
27273ec43Smmehari  * Copyright (c) 2003, 2004 David Young.  All rights reserved.
37273ec43Smmehari  *
47273ec43Smmehari  * Redistribution and use in source and binary forms, with or without
57273ec43Smmehari  * modification, are permitted provided that the following conditions
67273ec43Smmehari  * are met:
77273ec43Smmehari  * 1. Redistributions of source code must retain the above copyright
87273ec43Smmehari  *    notice, this list of conditions and the following disclaimer.
97273ec43Smmehari  * 2. Redistributions in binary form must reproduce the above copyright
107273ec43Smmehari  *    notice, this list of conditions and the following disclaimer in the
117273ec43Smmehari  *    documentation and/or other materials provided with the distribution.
127273ec43Smmehari  * 3. The name of David Young may not be used to endorse or promote
137273ec43Smmehari  *    products derived from this software without specific prior
147273ec43Smmehari  *    written permission.
157273ec43Smmehari  *
167273ec43Smmehari  * THIS SOFTWARE IS PROVIDED BY DAVID YOUNG ``AS IS'' AND ANY
177273ec43Smmehari  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
187273ec43Smmehari  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
197273ec43Smmehari  * PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL DAVID
207273ec43Smmehari  * YOUNG BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
217273ec43Smmehari  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
227273ec43Smmehari  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
237273ec43Smmehari  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
247273ec43Smmehari  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
257273ec43Smmehari  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
267273ec43Smmehari  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
277273ec43Smmehari  * OF SUCH DAMAGE.
287273ec43Smmehari  */
297273ec43Smmehari 
307273ec43Smmehari /*
317273ec43Smmehari  * Modifications to fit into the linux IEEE 802.11 stack,
327273ec43Smmehari  * Mike Kershaw ([email protected])
337273ec43Smmehari  */
347273ec43Smmehari 
357273ec43Smmehari #ifndef IEEE80211RADIOTAP_H
367273ec43Smmehari #define IEEE80211RADIOTAP_H
377273ec43Smmehari 
387273ec43Smmehari #include <linux/if_ether.h>
397273ec43Smmehari #include <linux/kernel.h>
407273ec43Smmehari 
417273ec43Smmehari /* Base version of the radiotap packet header data */
427273ec43Smmehari #define PKTHDR_RADIOTAP_VERSION		0
437273ec43Smmehari 
447273ec43Smmehari /* A generic radio capture format is desirable. There is one for
457273ec43Smmehari  * Linux, but it is neither rigidly defined (there were not even
467273ec43Smmehari  * units given for some fields) nor easily extensible.
477273ec43Smmehari  *
487273ec43Smmehari  * I suggest the following extensible radio capture format. It is
497273ec43Smmehari  * based on a bitmap indicating which fields are present.
507273ec43Smmehari  *
517273ec43Smmehari  * I am trying to describe precisely what the application programmer
527273ec43Smmehari  * should expect in the following, and for that reason I tell the
537273ec43Smmehari  * units and origin of each measurement (where it applies), or else I
547273ec43Smmehari  * use sufficiently weaselly language ("is a monotonically nondecreasing
557273ec43Smmehari  * function of...") that I cannot set false expectations for lawyerly
567273ec43Smmehari  * readers.
577273ec43Smmehari  */
587273ec43Smmehari 
597273ec43Smmehari /*
607273ec43Smmehari  * The radio capture header precedes the 802.11 header.
617273ec43Smmehari  * All data in the header is little endian on all platforms.
627273ec43Smmehari  */
637273ec43Smmehari struct ieee80211_radiotap_header {
647273ec43Smmehari 	u8 it_version;		/* Version 0. Only increases
657273ec43Smmehari 				 * for drastic changes,
667273ec43Smmehari 				 * introduction of compatible
677273ec43Smmehari 				 * new fields does not count.
687273ec43Smmehari 				 */
697273ec43Smmehari 	u8 it_pad;
707273ec43Smmehari 	__le16 it_len;		/* length of the whole
717273ec43Smmehari 				 * header in bytes, including
727273ec43Smmehari 				 * it_version, it_pad,
737273ec43Smmehari 				 * it_len, and data fields.
747273ec43Smmehari 				 */
757273ec43Smmehari 	__le32 it_present;	/* A bitmap telling which
767273ec43Smmehari 				 * fields are present. Set bit 31
777273ec43Smmehari 				 * (0x80000000) to extend the
787273ec43Smmehari 				 * bitmap by another 32 bits.
797273ec43Smmehari 				 * Additional extensions are made
807273ec43Smmehari 				 * by setting bit 31.
817273ec43Smmehari 				 */
82*0802e503SXianjun Jiao } __attribute__((packed));
837273ec43Smmehari 
847273ec43Smmehari /* Name                                 Data type    Units
857273ec43Smmehari  * ----                                 ---------    -----
867273ec43Smmehari  *
877273ec43Smmehari  * IEEE80211_RADIOTAP_TSFT              __le64       microseconds
887273ec43Smmehari  *
897273ec43Smmehari  *      Value in microseconds of the MAC's 64-bit 802.11 Time
907273ec43Smmehari  *      Synchronization Function timer when the first bit of the
917273ec43Smmehari  *      MPDU arrived at the MAC. For received frames, only.
927273ec43Smmehari  *
937273ec43Smmehari  * IEEE80211_RADIOTAP_CHANNEL           2 x __le16   MHz, bitmap
947273ec43Smmehari  *
957273ec43Smmehari  *      Tx/Rx frequency in MHz, followed by flags (see below).
967273ec43Smmehari  *
977273ec43Smmehari  * IEEE80211_RADIOTAP_FHSS              __le16       see below
987273ec43Smmehari  *
997273ec43Smmehari  *      For frequency-hopping radios, the hop set (first byte)
1007273ec43Smmehari  *      and pattern (second byte).
1017273ec43Smmehari  *
1027273ec43Smmehari  * IEEE80211_RADIOTAP_RATE              u8           500kb/s
1037273ec43Smmehari  *
1047273ec43Smmehari  *      Tx/Rx data rate
1057273ec43Smmehari  *
1067273ec43Smmehari  * IEEE80211_RADIOTAP_DBM_ANTSIGNAL     s8           decibels from
1077273ec43Smmehari  *                                                   one milliwatt (dBm)
1087273ec43Smmehari  *
1097273ec43Smmehari  *      RF signal power at the antenna, decibel difference from
1107273ec43Smmehari  *      one milliwatt.
1117273ec43Smmehari  *
1127273ec43Smmehari  * IEEE80211_RADIOTAP_DBM_ANTNOISE      s8           decibels from
1137273ec43Smmehari  *                                                   one milliwatt (dBm)
1147273ec43Smmehari  *
1157273ec43Smmehari  *      RF noise power at the antenna, decibel difference from one
1167273ec43Smmehari  *      milliwatt.
1177273ec43Smmehari  *
1187273ec43Smmehari  * IEEE80211_RADIOTAP_DB_ANTSIGNAL      u8           decibel (dB)
1197273ec43Smmehari  *
1207273ec43Smmehari  *      RF signal power at the antenna, decibel difference from an
1217273ec43Smmehari  *      arbitrary, fixed reference.
1227273ec43Smmehari  *
1237273ec43Smmehari  * IEEE80211_RADIOTAP_DB_ANTNOISE       u8           decibel (dB)
1247273ec43Smmehari  *
1257273ec43Smmehari  *      RF noise power at the antenna, decibel difference from an
1267273ec43Smmehari  *      arbitrary, fixed reference point.
1277273ec43Smmehari  *
1287273ec43Smmehari  * IEEE80211_RADIOTAP_LOCK_QUALITY      __le16       unitless
1297273ec43Smmehari  *
1307273ec43Smmehari  *      Quality of Barker code lock. Unitless. Monotonically
1317273ec43Smmehari  *      nondecreasing with "better" lock strength. Called "Signal
1327273ec43Smmehari  *      Quality" in datasheets.  (Is there a standard way to measure
1337273ec43Smmehari  *      this?)
1347273ec43Smmehari  *
1357273ec43Smmehari  * IEEE80211_RADIOTAP_TX_ATTENUATION    __le16       unitless
1367273ec43Smmehari  *
1377273ec43Smmehari  *      Transmit power expressed as unitless distance from max
1387273ec43Smmehari  *      power set at factory calibration.  0 is max power.
1397273ec43Smmehari  *      Monotonically nondecreasing with lower power levels.
1407273ec43Smmehari  *
1417273ec43Smmehari  * IEEE80211_RADIOTAP_DB_TX_ATTENUATION __le16       decibels (dB)
1427273ec43Smmehari  *
1437273ec43Smmehari  *      Transmit power expressed as decibel distance from max power
1447273ec43Smmehari  *      set at factory calibration.  0 is max power.  Monotonically
1457273ec43Smmehari  *      nondecreasing with lower power levels.
1467273ec43Smmehari  *
1477273ec43Smmehari  * IEEE80211_RADIOTAP_DBM_TX_POWER      s8           decibels from
1487273ec43Smmehari  *                                                   one milliwatt (dBm)
1497273ec43Smmehari  *
1507273ec43Smmehari  *      Transmit power expressed as dBm (decibels from a 1 milliwatt
1517273ec43Smmehari  *      reference). This is the absolute power level measured at
1527273ec43Smmehari  *      the antenna port.
1537273ec43Smmehari  *
1547273ec43Smmehari  * IEEE80211_RADIOTAP_FLAGS             u8           bitmap
1557273ec43Smmehari  *
1567273ec43Smmehari  *      Properties of transmitted and received frames. See flags
1577273ec43Smmehari  *      defined below.
1587273ec43Smmehari  *
1597273ec43Smmehari  * IEEE80211_RADIOTAP_ANTENNA           u8           antenna index
1607273ec43Smmehari  *
1617273ec43Smmehari  *      Unitless indication of the Rx/Tx antenna for this packet.
1627273ec43Smmehari  *      The first antenna is antenna 0.
1637273ec43Smmehari  *
1647273ec43Smmehari  * IEEE80211_RADIOTAP_RX_FLAGS          __le16       bitmap
1657273ec43Smmehari  *
1667273ec43Smmehari  *     Properties of received frames. See flags defined below.
1677273ec43Smmehari  *
1687273ec43Smmehari  * IEEE80211_RADIOTAP_TX_FLAGS          __le16       bitmap
1697273ec43Smmehari  *
1707273ec43Smmehari  *     Properties of transmitted frames. See flags defined below.
1717273ec43Smmehari  *
1727273ec43Smmehari  * IEEE80211_RADIOTAP_RTS_RETRIES       u8           data
1737273ec43Smmehari  *
1747273ec43Smmehari  *     Number of rts retries a transmitted frame used.
1757273ec43Smmehari  *
1767273ec43Smmehari  * IEEE80211_RADIOTAP_DATA_RETRIES      u8           data
1777273ec43Smmehari  *
1787273ec43Smmehari  *     Number of unicast retries a transmitted frame used.
1797273ec43Smmehari  *
1807273ec43Smmehari  * IEEE80211_RADIOTAP_MCS	u8, u8, u8		unitless
1817273ec43Smmehari  *
1827273ec43Smmehari  *     Contains a bitmap of known fields/flags, the flags, and
1837273ec43Smmehari  *     the MCS index.
1847273ec43Smmehari  *
1857273ec43Smmehari  * IEEE80211_RADIOTAP_AMPDU_STATUS	u32, u16, u8, u8	unitless
1867273ec43Smmehari  *
1877273ec43Smmehari  *	Contains the AMPDU information for the subframe.
1887273ec43Smmehari  *
1897273ec43Smmehari  * IEEE80211_RADIOTAP_VHT	u16, u8, u8, u8[4], u8, u8, u16
1907273ec43Smmehari  *
1917273ec43Smmehari  *	Contains VHT information about this frame.
1927273ec43Smmehari  */
1937273ec43Smmehari enum ieee80211_radiotap_type {
1947273ec43Smmehari 	IEEE80211_RADIOTAP_TSFT = 0,
1957273ec43Smmehari 	IEEE80211_RADIOTAP_FLAGS = 1,
1967273ec43Smmehari 	IEEE80211_RADIOTAP_RATE = 2,
1977273ec43Smmehari 	IEEE80211_RADIOTAP_CHANNEL = 3,
1987273ec43Smmehari 	IEEE80211_RADIOTAP_FHSS = 4,
1997273ec43Smmehari 	IEEE80211_RADIOTAP_DBM_ANTSIGNAL = 5,
2007273ec43Smmehari 	IEEE80211_RADIOTAP_DBM_ANTNOISE = 6,
2017273ec43Smmehari 	IEEE80211_RADIOTAP_LOCK_QUALITY = 7,
2027273ec43Smmehari 	IEEE80211_RADIOTAP_TX_ATTENUATION = 8,
2037273ec43Smmehari 	IEEE80211_RADIOTAP_DB_TX_ATTENUATION = 9,
2047273ec43Smmehari 	IEEE80211_RADIOTAP_DBM_TX_POWER = 10,
2057273ec43Smmehari 	IEEE80211_RADIOTAP_ANTENNA = 11,
2067273ec43Smmehari 	IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12,
2077273ec43Smmehari 	IEEE80211_RADIOTAP_DB_ANTNOISE = 13,
2087273ec43Smmehari 	IEEE80211_RADIOTAP_RX_FLAGS = 14,
2097273ec43Smmehari 	IEEE80211_RADIOTAP_TX_FLAGS = 15,
2107273ec43Smmehari 	IEEE80211_RADIOTAP_RTS_RETRIES = 16,
2117273ec43Smmehari 	IEEE80211_RADIOTAP_DATA_RETRIES = 17,
2127273ec43Smmehari 
2137273ec43Smmehari 	IEEE80211_RADIOTAP_MCS = 19,
2147273ec43Smmehari 	IEEE80211_RADIOTAP_AMPDU_STATUS = 20,
2157273ec43Smmehari 	IEEE80211_RADIOTAP_VHT = 21,
2167273ec43Smmehari 
2177273ec43Smmehari 	/* valid in every it_present bitmap, even vendor namespaces */
2187273ec43Smmehari 	IEEE80211_RADIOTAP_RADIOTAP_NAMESPACE = 29,
2197273ec43Smmehari 	IEEE80211_RADIOTAP_VENDOR_NAMESPACE = 30,
2207273ec43Smmehari 	IEEE80211_RADIOTAP_EXT = 31
2217273ec43Smmehari };
2227273ec43Smmehari 
2237273ec43Smmehari /* Channel flags. */
2247273ec43Smmehari #define	IEEE80211_CHAN_TURBO	0x0010	/* Turbo channel */
2257273ec43Smmehari #define	IEEE80211_CHAN_CCK	0x0020	/* CCK channel */
2267273ec43Smmehari #define	IEEE80211_CHAN_OFDM	0x0040	/* OFDM channel */
2277273ec43Smmehari #define	IEEE80211_CHAN_2GHZ	0x0080	/* 2 GHz spectrum channel. */
2287273ec43Smmehari #define	IEEE80211_CHAN_5GHZ	0x0100	/* 5 GHz spectrum channel */
2297273ec43Smmehari #define	IEEE80211_CHAN_PASSIVE	0x0200	/* Only passive scan allowed */
2307273ec43Smmehari #define	IEEE80211_CHAN_DYN	0x0400	/* Dynamic CCK-OFDM channel */
2317273ec43Smmehari #define	IEEE80211_CHAN_GFSK	0x0800	/* GFSK channel (FHSS PHY) */
2327273ec43Smmehari 
2337273ec43Smmehari /* For IEEE80211_RADIOTAP_FLAGS */
2347273ec43Smmehari #define	IEEE80211_RADIOTAP_F_CFP	0x01	/* sent/received
2357273ec43Smmehari 						 * during CFP
2367273ec43Smmehari 						 */
2377273ec43Smmehari #define	IEEE80211_RADIOTAP_F_SHORTPRE	0x02	/* sent/received
2387273ec43Smmehari 						 * with short
2397273ec43Smmehari 						 * preamble
2407273ec43Smmehari 						 */
2417273ec43Smmehari #define	IEEE80211_RADIOTAP_F_WEP	0x04	/* sent/received
2427273ec43Smmehari 						 * with WEP encryption
2437273ec43Smmehari 						 */
2447273ec43Smmehari #define	IEEE80211_RADIOTAP_F_FRAG	0x08	/* sent/received
2457273ec43Smmehari 						 * with fragmentation
2467273ec43Smmehari 						 */
2477273ec43Smmehari #define	IEEE80211_RADIOTAP_F_FCS	0x10	/* frame includes FCS */
2487273ec43Smmehari #define	IEEE80211_RADIOTAP_F_DATAPAD	0x20	/* frame has padding between
2497273ec43Smmehari 						 * 802.11 header and payload
2507273ec43Smmehari 						 * (to 32-bit boundary)
2517273ec43Smmehari 						 */
2527273ec43Smmehari #define IEEE80211_RADIOTAP_F_BADFCS	0x40	/* bad FCS */
2537273ec43Smmehari 
2547273ec43Smmehari /* For IEEE80211_RADIOTAP_RX_FLAGS */
2557273ec43Smmehari #define IEEE80211_RADIOTAP_F_RX_BADPLCP	0x0002	/* frame has bad PLCP */
2567273ec43Smmehari 
2577273ec43Smmehari /* For IEEE80211_RADIOTAP_TX_FLAGS */
2587273ec43Smmehari #define IEEE80211_RADIOTAP_F_TX_FAIL	0x0001	/* failed due to excessive
2597273ec43Smmehari 						 * retries */
2607273ec43Smmehari #define IEEE80211_RADIOTAP_F_TX_CTS	0x0002	/* used cts 'protection' */
2617273ec43Smmehari #define IEEE80211_RADIOTAP_F_TX_RTS	0x0004	/* used rts/cts handshake */
2627273ec43Smmehari #define IEEE80211_RADIOTAP_F_TX_NOACK	0x0008	/* don't expect an ack */
2637273ec43Smmehari 
2647273ec43Smmehari 
2657273ec43Smmehari /* For IEEE80211_RADIOTAP_MCS */
2667273ec43Smmehari #define IEEE80211_RADIOTAP_MCS_HAVE_BW		0x01
2677273ec43Smmehari #define IEEE80211_RADIOTAP_MCS_HAVE_MCS		0x02
2687273ec43Smmehari #define IEEE80211_RADIOTAP_MCS_HAVE_GI		0x04
2697273ec43Smmehari #define IEEE80211_RADIOTAP_MCS_HAVE_FMT		0x08
2707273ec43Smmehari #define IEEE80211_RADIOTAP_MCS_HAVE_FEC		0x10
2717273ec43Smmehari 
2727273ec43Smmehari #define IEEE80211_RADIOTAP_MCS_BW_MASK		0x03
2737273ec43Smmehari #define		IEEE80211_RADIOTAP_MCS_BW_20	0
2747273ec43Smmehari #define		IEEE80211_RADIOTAP_MCS_BW_40	1
2757273ec43Smmehari #define		IEEE80211_RADIOTAP_MCS_BW_20L	2
2767273ec43Smmehari #define		IEEE80211_RADIOTAP_MCS_BW_20U	3
2777273ec43Smmehari #define IEEE80211_RADIOTAP_MCS_SGI		0x04
2787273ec43Smmehari #define IEEE80211_RADIOTAP_MCS_FMT_GF		0x08
2797273ec43Smmehari #define IEEE80211_RADIOTAP_MCS_FEC_LDPC		0x10
2807273ec43Smmehari 
2817273ec43Smmehari /* For IEEE80211_RADIOTAP_AMPDU_STATUS */
2827273ec43Smmehari #define IEEE80211_RADIOTAP_AMPDU_REPORT_ZEROLEN		0x0001
2837273ec43Smmehari #define IEEE80211_RADIOTAP_AMPDU_IS_ZEROLEN		0x0002
2847273ec43Smmehari #define IEEE80211_RADIOTAP_AMPDU_LAST_KNOWN		0x0004
2857273ec43Smmehari #define IEEE80211_RADIOTAP_AMPDU_IS_LAST		0x0008
2867273ec43Smmehari #define IEEE80211_RADIOTAP_AMPDU_DELIM_CRC_ERR		0x0010
2877273ec43Smmehari #define IEEE80211_RADIOTAP_AMPDU_DELIM_CRC_KNOWN	0x0020
2887273ec43Smmehari 
2897273ec43Smmehari /* For IEEE80211_RADIOTAP_VHT */
2907273ec43Smmehari #define IEEE80211_RADIOTAP_VHT_KNOWN_STBC			0x0001
2917273ec43Smmehari #define IEEE80211_RADIOTAP_VHT_KNOWN_TXOP_PS_NA			0x0002
2927273ec43Smmehari #define IEEE80211_RADIOTAP_VHT_KNOWN_GI				0x0004
2937273ec43Smmehari #define IEEE80211_RADIOTAP_VHT_KNOWN_SGI_NSYM_DIS		0x0008
2947273ec43Smmehari #define IEEE80211_RADIOTAP_VHT_KNOWN_LDPC_EXTRA_OFDM_SYM	0x0010
2957273ec43Smmehari #define IEEE80211_RADIOTAP_VHT_KNOWN_BEAMFORMED			0x0020
2967273ec43Smmehari #define IEEE80211_RADIOTAP_VHT_KNOWN_BANDWIDTH			0x0040
2977273ec43Smmehari #define IEEE80211_RADIOTAP_VHT_KNOWN_GROUP_ID			0x0080
2987273ec43Smmehari #define IEEE80211_RADIOTAP_VHT_KNOWN_PARTIAL_AID		0x0100
2997273ec43Smmehari 
3007273ec43Smmehari #define IEEE80211_RADIOTAP_VHT_FLAG_STBC			0x01
3017273ec43Smmehari #define IEEE80211_RADIOTAP_VHT_FLAG_TXOP_PS_NA			0x02
3027273ec43Smmehari #define IEEE80211_RADIOTAP_VHT_FLAG_SGI				0x04
3037273ec43Smmehari #define IEEE80211_RADIOTAP_VHT_FLAG_SGI_NSYM_M10_9		0x08
3047273ec43Smmehari #define IEEE80211_RADIOTAP_VHT_FLAG_LDPC_EXTRA_OFDM_SYM		0x10
3057273ec43Smmehari #define IEEE80211_RADIOTAP_VHT_FLAG_BEAMFORMED			0x20
3067273ec43Smmehari 
3077273ec43Smmehari #endif				/* IEEE80211_RADIOTAP_H */
308