ieee80211_radiotap.h revision 1.22 1 /* $FreeBSD: src/sys/net80211/ieee80211_radiotap.h,v 1.11 2007/12/13 01:23:40 sa
2 m Exp $ */
3 /* $NetBSD: ieee80211_radiotap.h,v 1.22 2011/02/25 08:01:49 cegger 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 _NET80211_IEEE80211_RADIOTAP_H_
31 #define _NET80211_IEEE80211_RADIOTAP_H_
32
33 /* A generic radio capture format is desirable. It must be
34 * rigidly defined (e.g., units for fields should be given),
35 * and easily extensible.
36 *
37 * The following is an 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 #if defined(__KERNEL__) || defined(_KERNEL)
48 #ifndef DLT_IEEE802_11_RADIO
49 #define DLT_IEEE802_11_RADIO 127 /* 802.11 plus WLAN header */
50 #endif
51 #endif /* defined(__KERNEL__) || defined(_KERNEL) */
52
53 /* XXX tcpdump/libpcap do not tolerate variable-length headers,
54 * yet, so we pad every radiotap header to 64 bytes. Ugh.
55 */
56 #define IEEE80211_RADIOTAP_HDRLEN 64
57
58 /*
59 * The radio capture header precedes the 802.11 header.
60 *
61 * Note well: all radiotap fields are little-endian.
62 */
63 struct ieee80211_radiotap_header {
64 uint8_t it_version; /* Version 0. Only increases
65 * for drastic changes,
66 * introduction of compatible
67 * new fields does not count.
68 */
69 uint8_t it_pad;
70 uint16_t it_len; /* length of the whole
71 * header in bytes, including
72 * it_version, it_pad,
73 * it_len, and data fields.
74 */
75 uint32_t it_present; /* A bitmap telling which
76 * fields are present. Set bit 31
77 * (0x80000000) to extend the
78 * bitmap by another 32 bits.
79 * Additional extensions are made
80 * by setting bit 31.
81 */
82 } __packed __aligned(8);
83
84 /*
85 * Name Data type Units
86 * ---- --------- -----
87 *
88 * IEEE80211_RADIOTAP_TSFT uint64_t microseconds
89 *
90 * Value in microseconds of the MAC's 64-bit 802.11 Time
91 * Synchronization Function timer when the first bit of the
92 * MPDU arrived at the MAC. For received frames, only.
93 *
94 * IEEE80211_RADIOTAP_CHANNEL 2 x uint16_t MHz, bitmap
95 *
96 * Tx/Rx frequency in MHz, followed by flags (see below).
97 *
98 * IEEE80211_RADIOTAP_FHSS uint16_t see below
99 *
100 * For frequency-hopping radios, the hop set (first byte)
101 * and pattern (second byte).
102 *
103 * IEEE80211_RADIOTAP_RATE uint8_t 500kb/s
104 *
105 * Tx/Rx data rate
106 *
107 * IEEE80211_RADIOTAP_DBM_ANTSIGNAL int8_t decibels from
108 * one milliwatt (dBm)
109 *
110 * RF signal power at the antenna, decibel difference from
111 * one milliwatt.
112 *
113 * IEEE80211_RADIOTAP_DBM_ANTNOISE int8_t decibels from
114 * one milliwatt (dBm)
115 *
116 * RF noise power at the antenna, decibel difference from one
117 * milliwatt.
118 *
119 * IEEE80211_RADIOTAP_DB_ANTSIGNAL uint8_t decibel (dB)
120 *
121 * RF signal power at the antenna, decibel difference from an
122 * arbitrary, fixed reference.
123 *
124 * IEEE80211_RADIOTAP_DB_ANTNOISE uint8_t decibel (dB)
125 *
126 * RF noise power at the antenna, decibel difference from an
127 * arbitrary, fixed reference point.
128 *
129 * IEEE80211_RADIOTAP_LOCK_QUALITY uint16_t unitless
130 *
131 * Quality of Barker code lock. Unitless. Monotonically
132 * nondecreasing with "better" lock strength. Called "Signal
133 * Quality" in datasheets. (Is there a standard way to measure
134 * this?)
135 *
136 * IEEE80211_RADIOTAP_TX_ATTENUATION uint16_t unitless
137 *
138 * Transmit power expressed as unitless distance from max
139 * power set at factory calibration. 0 is max power.
140 * Monotonically nondecreasing with lower power levels.
141 *
142 * IEEE80211_RADIOTAP_DB_TX_ATTENUATION uint16_t decibels (dB)
143 *
144 * Transmit power expressed as decibel distance from max power
145 * set at factory calibration. 0 is max power. Monotonically
146 * nondecreasing with lower power levels.
147 *
148 * IEEE80211_RADIOTAP_DBM_TX_POWER int8_t decibels from
149 * one milliwatt (dBm)
150 *
151 * Transmit power expressed as dBm (decibels from a 1 milliwatt
152 * reference). This is the absolute power level measured at
153 * the antenna port.
154 *
155 * IEEE80211_RADIOTAP_FLAGS uint8_t bitmap
156 *
157 * Properties of transmitted and received frames. See flags
158 * defined below.
159 *
160 * IEEE80211_RADIOTAP_ANTENNA uint8_t antenna index
161 *
162 * Unitless indication of the Rx/Tx antenna for this packet.
163 * The first antenna is antenna 0.
164 *
165 * IEEE80211_RADIOTAP_RX_FLAGS uint16_t bitmap
166 *
167 * Properties of received frames. See flags defined below.
168 *
169 * IEEE80211_RADIOTAP_TX_FLAGS uint16_t bitmap
170 *
171 * Properties of transmitted frames. See flags defined below.
172 *
173 * IEEE80211_RADIOTAP_RTS_RETRIES uint8_t data
174 *
175 * Number of rts retries a transmitted frame used.
176 *
177 * IEEE80211_RADIOTAP_DATA_RETRIES uint8_t data
178 *
179 * Number of unicast retries a transmitted frame used.
180 *
181 * IEEE80211_RADIOTAP_XCHANNEL uint32_t bitmap
182 * uint16_t MHz
183 * uint8_t channel number
184 * int8_t .5 dBm
185 *
186 * Extended channel specification: flags (see below) followed by
187 * frequency in MHz, the corresponding IEEE channel number, and
188 * finally the maximum regulatory transmit power cap in .5 dBm
189 * units. This property supersedes IEEE80211_RADIOTAP_CHANNEL
190 * and only one of the two should be present.
191 */
192 enum ieee80211_radiotap_type {
193 IEEE80211_RADIOTAP_TSFT = 0,
194 IEEE80211_RADIOTAP_FLAGS = 1,
195 IEEE80211_RADIOTAP_RATE = 2,
196 IEEE80211_RADIOTAP_CHANNEL = 3,
197 IEEE80211_RADIOTAP_FHSS = 4,
198 IEEE80211_RADIOTAP_DBM_ANTSIGNAL = 5,
199 IEEE80211_RADIOTAP_DBM_ANTNOISE = 6,
200 IEEE80211_RADIOTAP_LOCK_QUALITY = 7,
201 IEEE80211_RADIOTAP_TX_ATTENUATION = 8,
202 IEEE80211_RADIOTAP_DB_TX_ATTENUATION = 9,
203 IEEE80211_RADIOTAP_DBM_TX_POWER = 10,
204 IEEE80211_RADIOTAP_ANTENNA = 11,
205 IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12,
206 IEEE80211_RADIOTAP_DB_ANTNOISE = 13,
207 IEEE80211_RADIOTAP_RX_FLAGS = 14,
208 IEEE80211_RADIOTAP_TX_FLAGS = 15,
209 IEEE80211_RADIOTAP_RTS_RETRIES = 16,
210 IEEE80211_RADIOTAP_DATA_RETRIES = 17,
211 IEEE80211_RADIOTAP_XCHANNEL = 18,
212 IEEE80211_RADIOTAP_EXT = 31
213 };
214
215 #ifndef _KERNEL
216 /* Channel flags. */
217 #define IEEE80211_CHAN_TURBO 0x00000010 /* Turbo channel */
218 #define IEEE80211_CHAN_CCK 0x00000020 /* CCK channel */
219 #define IEEE80211_CHAN_OFDM 0x00000040 /* OFDM channel */
220 #define IEEE80211_CHAN_2GHZ 0x00000080 /* 2 GHz spectrum channel. */
221 #define IEEE80211_CHAN_5GHZ 0x00000100 /* 5 GHz spectrum channel */
222 #define IEEE80211_CHAN_PASSIVE 0x00000200 /* Only passive scan allowed */
223 #define IEEE80211_CHAN_DYN 0x00000400 /* Dynamic CCK-OFDM channel */
224 #define IEEE80211_CHAN_GFSK 0x00000800 /* GFSK channel (FHSS PHY) */
225 #define IEEE80211_CHAN_GSM 0x00001000 /* 900 MHz spectrum channel */
226 #define IEEE80211_CHAN_STURBO 0x00002000 /* 11a static turbo channel only */
227 #define IEEE80211_CHAN_HALF 0x00004000 /* Half rate channel */
228 #define IEEE80211_CHAN_QUARTER 0x00008000 /* Quarter rate channel */
229 #endif /* !_KERNEL */
230
231 /* For IEEE80211_RADIOTAP_FLAGS */
232 #define IEEE80211_RADIOTAP_F_CFP 0x01 /* sent/received
233 * during CFP
234 */
235 #define IEEE80211_RADIOTAP_F_SHORTPRE 0x02 /* sent/received
236 * with short
237 * preamble
238 */
239 #define IEEE80211_RADIOTAP_F_WEP 0x04 /* sent/received
240 * with WEP encryption
241 */
242 #define IEEE80211_RADIOTAP_F_FRAG 0x08 /* sent/received
243 * with fragmentation
244 */
245 #define IEEE80211_RADIOTAP_F_FCS 0x10 /* frame includes FCS */
246 #define IEEE80211_RADIOTAP_F_DATAPAD 0x20 /* frame has padding between
247 * 802.11 header and payload
248 * (to 32-bit boundary)
249 */
250 #define IEEE80211_RADIOTAP_F_BADFCS 0x40 /* does not pass FCS check */
251 #define IEEE80211_RADIOTAP_F_SHORTGI 0x80 /* HT short GI */
252
253 /* For IEEE80211_RADIOTAP_RX_FLAGS */
254 #define IEEE80211_RADIOTAP_F_RX_BADFCS 0x0001 /* Frame failed CRC check.
255 *
256 * Deprecated: use the flag
257 * IEEE80211_RADIOTAP_F_BADFCS in
258 * the IEEE80211_RADIOTAP_FLAGS
259 * field, instead.
260 */
261
262 /* For IEEE80211_RADIOTAP_TX_FLAGS */
263 #define IEEE80211_RADIOTAP_F_TX_FAIL 0x0001 /* failed due to excessive
264 * retries
265 */
266 #define IEEE80211_RADIOTAP_F_TX_CTS 0x0002 /* used cts 'protection' */
267 #define IEEE80211_RADIOTAP_F_TX_RTS 0x0004 /* used rts/cts handshake */
268
269 #endif /* !_NET80211_IEEE80211_RADIOTAP_H_ */
270