xref: /openbsd/sys/net80211/ieee80211_radiotap.h (revision 3f2f3bd2)
1 /* $OpenBSD: ieee80211_radiotap.h,v 1.17 2022/03/14 15:06:04 stsp Exp $ */
2 /* $FreeBSD: src/sys/net80211/ieee80211_radiotap.h,v 1.3 2004/04/05 22:13:21 sam Exp $ */
3 /* $NetBSD: ieee80211_radiotap.h,v 1.9 2004/06/06 04:13:28 dyoung Exp $ */
4 
5 /*-
6  * Copyright (c) 2003, 2004 David Young.  All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY DAVID YOUNG ``AS IS'' AND ANY
18  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
19  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
20  * PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL DAVID
21  * YOUNG BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
23  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
28  * OF SUCH DAMAGE.
29  */
30 #ifndef _NET_IF_IEEE80211RADIOTAP_H_
31 #define _NET_IF_IEEE80211RADIOTAP_H_
32 
33 /* A generic radio capture format is desirable. There is one for
34  * Linux, but it is neither rigidly defined (there were not even
35  * units given for some fields) nor easily extensible.
36  *
37  * I suggest the following extensible radio capture format. It is
38  * based on a bitmap indicating which fields are present.
39  *
40  * I am trying to describe precisely what the application programmer
41  * should expect in the following, and for that reason I tell the
42  * units and origin of each measurement (where it applies), or else I
43  * use sufficiently weaselly language ("is a monotonically nondecreasing
44  * function of...") that I cannot set false expectations for lawyerly
45  * readers.
46  */
47 
48 /* XXX tcpdump/libpcap do not tolerate variable-length headers,
49  * yet, so we pad every radiotap header to 64 bytes. Ugh.
50  */
51 #define IEEE80211_RADIOTAP_HDRLEN	64
52 
53 /* The radio capture header precedes the 802.11 header. */
54 struct ieee80211_radiotap_header {
55 	u_int8_t	it_version;	/* Version 0. Only increases
56 					 * for drastic changes,
57 					 * introduction of compatible
58 					 * new fields does not count.
59 					 */
60 	u_int8_t	it_pad;
61 	u_int16_t       it_len;         /* length of the whole
62 					 * header in bytes, including
63 					 * it_version, it_pad,
64 					 * it_len, and data fields.
65 					 */
66 	u_int32_t       it_present;     /* A bitmap telling which
67 					 * fields are present. Set bit 31
68 					 * (0x80000000) to extend the
69 					 * bitmap by another 32 bits.
70 					 * Additional extensions are made
71 					 * by setting bit 31.
72 					 */
73 } __packed;
74 
75 /* Name                                 Data type       Units
76  * ----                                 ---------       -----
77  *
78  * IEEE80211_RADIOTAP_TSFT              u_int64_t       microseconds
79  *
80  *      Value in microseconds of the MAC's 64-bit 802.11 Time
81  *      Synchronization Function timer when the first bit of the
82  *      MPDU arrived at the MAC. For received frames, only.
83  *
84  * IEEE80211_RADIOTAP_CHANNEL           2 x u_int16_t   MHz, bitmap
85  *
86  *      Tx/Rx frequency in MHz, followed by flags (see below).
87  *
88  * IEEE80211_RADIOTAP_FHSS              u_int16_t       see below
89  *
90  *      For frequency-hopping radios, the hop set (first byte)
91  *      and pattern (second byte).
92  *
93  * IEEE80211_RADIOTAP_RATE              u_int8_t        500kb/s or MCS index
94  *
95  *      Tx/Rx data rate in units of 500kb/s. If the high bit (0x80) is set
96  *      the remaining bits contain an MCS index instead of a date rate.
97  *
98  * IEEE80211_RADIOTAP_DBM_ANTSIGNAL     int8_t          decibels from
99  *                                                      one milliwatt (dBm)
100  *
101  *      RF signal power at the antenna, decibel difference from
102  *      one milliwatt.
103  *
104  * IEEE80211_RADIOTAP_DBM_ANTNOISE      int8_t          decibels from
105  *                                                      one milliwatt (dBm)
106  *
107  *      RF noise power at the antenna, decibel difference from one
108  *      milliwatt.
109  *
110  * IEEE80211_RADIOTAP_DB_ANTSIGNAL      u_int8_t        decibel (dB)
111  *
112  *      RF signal power at the antenna, decibel difference from an
113  *      arbitrary, fixed reference.
114  *
115  * IEEE80211_RADIOTAP_DB_ANTNOISE       u_int8_t        decibel (dB)
116  *
117  *      RF noise power at the antenna, decibel difference from an
118  *      arbitrary, fixed reference point.
119  *
120  * IEEE80211_RADIOTAP_BARKER_CODE_LOCK  u_int16_t       unitless
121  *
122  *      Quality of Barker code lock. Unitless. Monotonically
123  *      nondecreasing with "better" lock strength. Called "Signal
124  *      Quality" in datasheets.  (Is there a standard way to measure
125  *      this?)
126  *
127  * IEEE80211_RADIOTAP_TX_ATTENUATION    u_int16_t       unitless
128  *
129  *      Transmit power expressed as unitless distance from max
130  *      power set at factory calibration.  0 is max power.
131  *      Monotonically nondecreasing with lower power levels.
132  *
133  * IEEE80211_RADIOTAP_DB_TX_ATTENUATION u_int16_t       decibels (dB)
134  *
135  *      Transmit power expressed as decibel distance from max power
136  *      set at factory calibration.  0 is max power.  Monotonically
137  *      nondecreasing with lower power levels.
138  *
139  * IEEE80211_RADIOTAP_DBM_TX_POWER      int8_t          decibels from
140  *                                                      one milliwatt (dBm)
141  *
142  *      Transmit power expressed as dBm (decibels from a 1 milliwatt
143  *      reference). This is the absolute power level measured at
144  *      the antenna port.
145  *
146  * IEEE80211_RADIOTAP_FLAGS             u_int8_t        bitmap
147  *
148  *      Properties of transmitted and received frames. See flags
149  *      defined below.
150  *
151  * IEEE80211_RADIOTAP_ANTENNA           u_int8_t        antenna index
152  *
153  *      Unitless indication of the Rx/Tx antenna for this packet.
154  *      The first antenna is antenna 0.
155  *
156  * IEEE80211_RADIOTAP_FCS           	u_int32_t       data
157  *
158  *	FCS from frame in network byte order.
159  *
160  * IEEE80211_RADIOTAP_RSSI              2x u_int8_t    RSSI, max RSSI
161  *
162  *	A relative Received Signal Strength Index
163  */
164 enum ieee80211_radiotap_type {
165 	IEEE80211_RADIOTAP_TSFT = 0,
166 	IEEE80211_RADIOTAP_FLAGS = 1,
167 	IEEE80211_RADIOTAP_RATE = 2,
168 	IEEE80211_RADIOTAP_CHANNEL = 3,
169 	IEEE80211_RADIOTAP_FHSS = 4,
170 	IEEE80211_RADIOTAP_DBM_ANTSIGNAL = 5,
171 	IEEE80211_RADIOTAP_DBM_ANTNOISE = 6,
172 	IEEE80211_RADIOTAP_LOCK_QUALITY = 7,
173 	IEEE80211_RADIOTAP_TX_ATTENUATION = 8,
174 	IEEE80211_RADIOTAP_DB_TX_ATTENUATION = 9,
175 	IEEE80211_RADIOTAP_DBM_TX_POWER = 10,
176 	IEEE80211_RADIOTAP_ANTENNA = 11,
177 	IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12,
178 	IEEE80211_RADIOTAP_DB_ANTNOISE = 13,
179 	IEEE80211_RADIOTAP_FCS = 14,
180 	IEEE80211_RADIOTAP_RSSI = 16,
181 	IEEE80211_RADIOTAP_EXT = 31
182 };
183 
184 #ifndef _KERNEL
185 /* For IEEE80211_RADIOTAP_CHANNEL */
186 #define IEEE80211_CHAN_CCK	0x0020	/* CCK channel */
187 #define IEEE80211_CHAN_OFDM	0x0040	/* OFDM channel */
188 #define IEEE80211_CHAN_2GHZ	0x0080	/* 2 GHz spectrum channel */
189 #define IEEE80211_CHAN_5GHZ	0x0100	/* 5 GHz spectrum channel */
190 #define IEEE80211_CHAN_PASSIVE	0x0200	/* Only passive scan allowed */
191 #define IEEE80211_CHAN_DYN	0x0400	/* Dynamic CCK-OFDM channel */
192 #define IEEE80211_CHAN_GFSK	0x0800	/* GFSK channel (FHSS PHY) */
193 #define IEEE80211_CHAN_XR	0x1000	/* Extended range OFDM channel */
194 #define IEEE80211_CHAN_HT	0x2000	/* 11n/HT channel */
195 #define IEEE80211_CHAN_VHT	0x4000	/* 11ac/VHT channel */
196 #define IEEE80211_CHAN_40MHZ	0x8000	/* use of 40 MHz is allowed */
197 #endif	/* !_KERNEL */
198 
199 /* For IEEE80211_RADIOTAP_FLAGS */
200 #define	IEEE80211_RADIOTAP_F_CFP	0x01	/* sent/received
201 						 * during CFP
202 						 */
203 #define	IEEE80211_RADIOTAP_F_SHORTPRE	0x02	/* sent/received
204 						 * with short
205 						 * preamble
206 						 */
207 #define	IEEE80211_RADIOTAP_F_WEP	0x04	/* sent/received
208 						 * with WEP encryption
209 						 */
210 #define	IEEE80211_RADIOTAP_F_FRAG	0x08	/* sent/received
211 						 * with fragmentation
212 						 */
213 #define	IEEE80211_RADIOTAP_F_FCS	0x10	/* frame includes FCS */
214 
215 #endif /* _NET_IF_IEEE80211RADIOTAP_H_ */
216