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