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