xref: /openbsd/sys/net80211/ieee80211_radiotap.h (revision 898184e3)
1 /* $OpenBSD: ieee80211_radiotap.h,v 1.11 2010/07/17 16:25:09 damien 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
94  *
95  *      Tx/Rx data rate
96  *
97  * IEEE80211_RADIOTAP_DBM_ANTSIGNAL     int8_t          decibels from
98  *                                                      one milliwatt (dBm)
99  *
100  *      RF signal power at the antenna, decibel difference from
101  *      one milliwatt.
102  *
103  * IEEE80211_RADIOTAP_DBM_ANTNOISE      int8_t          decibels from
104  *                                                      one milliwatt (dBm)
105  *
106  *      RF noise power at the antenna, decibel difference from one
107  *      milliwatt.
108  *
109  * IEEE80211_RADIOTAP_DB_ANTSIGNAL      u_int8_t        decibel (dB)
110  *
111  *      RF signal power at the antenna, decibel difference from an
112  *      arbitrary, fixed reference.
113  *
114  * IEEE80211_RADIOTAP_DB_ANTNOISE       u_int8_t        decibel (dB)
115  *
116  *      RF noise power at the antenna, decibel difference from an
117  *      arbitrary, fixed reference point.
118  *
119  * IEEE80211_RADIOTAP_BARKER_CODE_LOCK  u_int16_t       unitless
120  *
121  *      Quality of Barker code lock. Unitless. Monotonically
122  *      nondecreasing with "better" lock strength. Called "Signal
123  *      Quality" in datasheets.  (Is there a standard way to measure
124  *      this?)
125  *
126  * IEEE80211_RADIOTAP_TX_ATTENUATION    u_int16_t       unitless
127  *
128  *      Transmit power expressed as unitless distance from max
129  *      power set at factory calibration.  0 is max power.
130  *      Monotonically nondecreasing with lower power levels.
131  *
132  * IEEE80211_RADIOTAP_DB_TX_ATTENUATION u_int16_t       decibels (dB)
133  *
134  *      Transmit power expressed as decibel distance from max power
135  *      set at factory calibration.  0 is max power.  Monotonically
136  *      nondecreasing with lower power levels.
137  *
138  * IEEE80211_RADIOTAP_DBM_TX_POWER      int8_t          decibels from
139  *                                                      one milliwatt (dBm)
140  *
141  *      Transmit power expressed as dBm (decibels from a 1 milliwatt
142  *      reference). This is the absolute power level measured at
143  *      the antenna port.
144  *
145  * IEEE80211_RADIOTAP_FLAGS             u_int8_t        bitmap
146  *
147  *      Properties of transmitted and received frames. See flags
148  *      defined below.
149  *
150  * IEEE80211_RADIOTAP_ANTENNA           u_int8_t        antenna index
151  *
152  *      Unitless indication of the Rx/Tx antenna for this packet.
153  *      The first antenna is antenna 0.
154  *
155  * IEEE80211_RADIOTAP_FCS           	u_int32_t       data
156  *
157  *	FCS from frame in network byte order.
158  *
159  * IEEE80211_RADIOTAP_HWQUEUE           u_int8_t       data
160  *
161  *	A specific hardware queue (used by WME)
162  *
163  * IEEE80211_RADIOTAP_RSSI              2x u_int8_t    RSSI, max RSSI
164  *
165  *	A relative Received Signal Strength Index
166  */
167 enum ieee80211_radiotap_type {
168 	IEEE80211_RADIOTAP_TSFT = 0,
169 	IEEE80211_RADIOTAP_FLAGS = 1,
170 	IEEE80211_RADIOTAP_RATE = 2,
171 	IEEE80211_RADIOTAP_CHANNEL = 3,
172 	IEEE80211_RADIOTAP_FHSS = 4,
173 	IEEE80211_RADIOTAP_DBM_ANTSIGNAL = 5,
174 	IEEE80211_RADIOTAP_DBM_ANTNOISE = 6,
175 	IEEE80211_RADIOTAP_LOCK_QUALITY = 7,
176 	IEEE80211_RADIOTAP_TX_ATTENUATION = 8,
177 	IEEE80211_RADIOTAP_DB_TX_ATTENUATION = 9,
178 	IEEE80211_RADIOTAP_DBM_TX_POWER = 10,
179 	IEEE80211_RADIOTAP_ANTENNA = 11,
180 	IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12,
181 	IEEE80211_RADIOTAP_DB_ANTNOISE = 13,
182 	IEEE80211_RADIOTAP_FCS = 14,
183 	IEEE80211_RADIOTAP_HWQUEUE = 15,
184 	IEEE80211_RADIOTAP_RSSI = 16,
185 	IEEE80211_RADIOTAP_EXT = 31
186 };
187 
188 #ifndef _KERNEL
189 /* For IEEE80211_RADIOTAP_CHANNEL */
190 #define IEEE80211_CHAN_TURBO	0x0010	/* Turbo channel */
191 #define IEEE80211_CHAN_CCK	0x0020	/* CCK channel */
192 #define IEEE80211_CHAN_OFDM	0x0040	/* OFDM channel */
193 #define IEEE80211_CHAN_2GHZ	0x0080	/* 2 GHz spectrum channel */
194 #define IEEE80211_CHAN_5GHZ	0x0100	/* 5 GHz spectrum channel */
195 #define IEEE80211_CHAN_PASSIVE	0x0200	/* Only passive scan allowed */
196 #define IEEE80211_CHAN_DYN	0x0400	/* Dynamic CCK-OFDM channel */
197 #define IEEE80211_CHAN_GFSK	0x0800	/* GFSK channel (FHSS PHY) */
198 #define IEEE80211_CHAN_XR	0x1000	/* Extended range OFDM channel */
199 #endif	/* !_KERNEL */
200 
201 /* For IEEE80211_RADIOTAP_FLAGS */
202 #define	IEEE80211_RADIOTAP_F_CFP	0x01	/* sent/received
203 						 * during CFP
204 						 */
205 #define	IEEE80211_RADIOTAP_F_SHORTPRE	0x02	/* sent/received
206 						 * with short
207 						 * preamble
208 						 */
209 #define	IEEE80211_RADIOTAP_F_WEP	0x04	/* sent/received
210 						 * with WEP encryption
211 						 */
212 #define	IEEE80211_RADIOTAP_F_FRAG	0x08	/* sent/received
213 						 * with fragmentation
214 						 */
215 #define	IEEE80211_RADIOTAP_F_FCS	0x10	/* frame includes FCS */
216 
217 #endif /* _NET_IF_IEEE80211RADIOTAP_H_ */
218