ieee80211_radiotap.h revision 170573
1119782Ssam/* $FreeBSD: head/sys/net80211/ieee80211_radiotap.h 170573 2007-06-11 19:34:53Z imp $ */
2167443Ssam/* $NetBSD: ieee80211_radiotap.h,v 1.16 2007/01/06 05:51:15 dyoung Exp $ */
3119782Ssam
4119782Ssam/*-
5119782Ssam * Copyright (c) 2003, 2004 David Young.  All rights reserved.
6119782Ssam *
7119782Ssam * Redistribution and use in source and binary forms, with or without
8119782Ssam * modification, are permitted provided that the following conditions
9119782Ssam * are met:
10119782Ssam * 1. Redistributions of source code must retain the above copyright
11119782Ssam *    notice, this list of conditions and the following disclaimer.
12119782Ssam * 2. Redistributions in binary form must reproduce the above copyright
13119782Ssam *    notice, this list of conditions and the following disclaimer in the
14119782Ssam *    documentation and/or other materials provided with the distribution.
15119782Ssam * 3. The name of David Young may not be used to endorse or promote
16119782Ssam *    products derived from this software without specific prior
17119782Ssam *    written permission.
18119782Ssam *
19119782Ssam * THIS SOFTWARE IS PROVIDED BY DAVID YOUNG ``AS IS'' AND ANY
20119782Ssam * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21119782Ssam * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22119782Ssam * PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL DAVID
23119782Ssam * YOUNG BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24119782Ssam * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
25119782Ssam * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26119782Ssam * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
27119782Ssam * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28119782Ssam * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29119782Ssam * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
30119782Ssam * OF SUCH DAMAGE.
31119782Ssam */
32167443Ssam#ifndef _NET80211_IEEE80211_RADIOTAP_H_
33167443Ssam#define _NET80211_IEEE80211_RADIOTAP_H_
34119782Ssam
35167443Ssam/* A generic radio capture format is desirable. It must be
36167443Ssam * rigidly defined (e.g., units for fields should be given),
37167443Ssam * and easily extensible.
38119782Ssam *
39167443Ssam * The following is an extensible radio capture format. It is
40119782Ssam * based on a bitmap indicating which fields are present.
41119782Ssam *
42119782Ssam * I am trying to describe precisely what the application programmer
43119782Ssam * should expect in the following, and for that reason I tell the
44119782Ssam * units and origin of each measurement (where it applies), or else I
45119782Ssam * use sufficiently weaselly language ("is a monotonically nondecreasing
46119782Ssam * function of...") that I cannot set false expectations for lawyerly
47119782Ssam * readers.
48119782Ssam */
49138568Ssam#if defined(__KERNEL__) || defined(_KERNEL)
50119782Ssam#ifndef DLT_IEEE802_11_RADIO
51119782Ssam#define	DLT_IEEE802_11_RADIO	127	/* 802.11 plus WLAN header */
52119782Ssam#endif
53138568Ssam#endif /* defined(__KERNEL__) || defined(_KERNEL) */
54119782Ssam
55167443Ssam#define	IEEE80211_RADIOTAP_HDRLEN	64	/* XXX deprecated */
56167443Ssam
57167443Ssam/*
58167443Ssam * The radio capture header precedes the 802.11 header.
59167443Ssam *
60167443Ssam * Note well: all radiotap fields are little-endian.
61140630Ssam */
62119782Ssamstruct ieee80211_radiotap_header {
63170530Ssam	uint8_t		it_version;	/* Version 0. Only increases
64119782Ssam					 * for drastic changes,
65119782Ssam					 * introduction of compatible
66123926Ssam					 * new fields does not count.
67119782Ssam					 */
68170530Ssam	uint8_t		it_pad;
69170530Ssam	uint16_t	it_len;		/* length of the whole
70119782Ssam					 * header in bytes, including
71119782Ssam					 * it_version, it_pad,
72123926Ssam					 * it_len, and data fields.
73119782Ssam					 */
74170530Ssam	uint32_t	it_present;	/* A bitmap telling which
75119782Ssam					 * fields are present. Set bit 31
76119782Ssam					 * (0x80000000) to extend the
77119782Ssam					 * bitmap by another 32 bits.
78119782Ssam					 * Additional extensions are made
79119782Ssam					 * by setting bit 31.
80119782Ssam					 */
81170573Simp} __packed;
82119782Ssam
83167443Ssam/*
84167443Ssam * Name                                 Data type       Units
85119782Ssam * ----                                 ---------       -----
86119782Ssam *
87170530Ssam * IEEE80211_RADIOTAP_TSFT              uint64_t        microseconds
88119782Ssam *
89123926Ssam *      Value in microseconds of the MAC's 64-bit 802.11 Time
90123926Ssam *      Synchronization Function timer when the first bit of the
91123926Ssam *      MPDU arrived at the MAC. For received frames, only.
92119782Ssam *
93170530Ssam * IEEE80211_RADIOTAP_CHANNEL           2 x uint16_t    MHz, bitmap
94123926Ssam *
95123926Ssam *      Tx/Rx frequency in MHz, followed by flags (see below).
96123926Ssam *
97170530Ssam * IEEE80211_RADIOTAP_FHSS              uint16_t        see below
98119782Ssam *
99119782Ssam *      For frequency-hopping radios, the hop set (first byte)
100119782Ssam *      and pattern (second byte).
101119782Ssam *
102170530Ssam * IEEE80211_RADIOTAP_RATE              uint8_t         500kb/s or index
103119782Ssam *
104170530Ssam *      Tx/Rx data rate.  If bit 0x80 is set then it represents an
105170530Ssam *	an MCS index and not an IEEE rate.
106119782Ssam *
107123926Ssam * IEEE80211_RADIOTAP_DBM_ANTSIGNAL     int8_t          decibels from
108123926Ssam *                                                      one milliwatt (dBm)
109119782Ssam *
110123926Ssam *      RF signal power at the antenna, decibel difference from
111123926Ssam *      one milliwatt.
112119782Ssam *
113123926Ssam * IEEE80211_RADIOTAP_DBM_ANTNOISE      int8_t          decibels from
114123926Ssam *                                                      one milliwatt (dBm)
115119782Ssam *
116123926Ssam *      RF noise power at the antenna, decibel difference from one
117123926Ssam *      milliwatt.
118123926Ssam *
119170530Ssam * IEEE80211_RADIOTAP_DB_ANTSIGNAL      uint8_t         decibel (dB)
120123926Ssam *
121123926Ssam *      RF signal power at the antenna, decibel difference from an
122123926Ssam *      arbitrary, fixed reference.
123123926Ssam *
124170530Ssam * IEEE80211_RADIOTAP_DB_ANTNOISE       uint8_t         decibel (dB)
125123926Ssam *
126123926Ssam *      RF noise power at the antenna, decibel difference from an
127123926Ssam *      arbitrary, fixed reference point.
128123926Ssam *
129170530Ssam * IEEE80211_RADIOTAP_LOCK_QUALITY      uint16_t        unitless
130119782Ssam *
131119782Ssam *      Quality of Barker code lock. Unitless. Monotonically
132119782Ssam *      nondecreasing with "better" lock strength. Called "Signal
133119782Ssam *      Quality" in datasheets.  (Is there a standard way to measure
134119782Ssam *      this?)
135119782Ssam *
136170530Ssam * IEEE80211_RADIOTAP_TX_ATTENUATION    uint16_t        unitless
137119782Ssam *
138119782Ssam *      Transmit power expressed as unitless distance from max
139119782Ssam *      power set at factory calibration.  0 is max power.
140119782Ssam *      Monotonically nondecreasing with lower power levels.
141119782Ssam *
142170530Ssam * IEEE80211_RADIOTAP_DB_TX_ATTENUATION uint16_t        decibels (dB)
143119782Ssam *
144119782Ssam *      Transmit power expressed as decibel distance from max power
145119782Ssam *      set at factory calibration.  0 is max power.  Monotonically
146119782Ssam *      nondecreasing with lower power levels.
147119782Ssam *
148123926Ssam * IEEE80211_RADIOTAP_DBM_TX_POWER      int8_t          decibels from
149123926Ssam *                                                      one milliwatt (dBm)
150119782Ssam *
151119782Ssam *      Transmit power expressed as dBm (decibels from a 1 milliwatt
152119782Ssam *      reference). This is the absolute power level measured at
153119782Ssam *      the antenna port.
154119782Ssam *
155170530Ssam * IEEE80211_RADIOTAP_FLAGS             uint8_t         bitmap
156119782Ssam *
157119782Ssam *      Properties of transmitted and received frames. See flags
158119782Ssam *      defined below.
159119782Ssam *
160170530Ssam * IEEE80211_RADIOTAP_ANTENNA           uint8_t         antenna index
161119782Ssam *
162119782Ssam *      Unitless indication of the Rx/Tx antenna for this packet.
163119782Ssam *      The first antenna is antenna 0.
164170530Ssam *
165170530Ssam * IEEE80211_RADIOTAP_XCHANNEL          uint32_t        bitmap
166170530Ssam *                                      uint16_t        MHz
167170530Ssam *                                      uint8_t         channel number
168170530Ssam *                                      int8_t          .5 dBm
169170530Ssam *
170170530Ssam *      Extended channel specification: flags (see below) followed by
171170530Ssam *      frequency in MHz, the corresponding IEEE channel number, and
172170530Ssam *      finally the maximum regulatory transmit power cap in .5 dBm
173170530Ssam *      units.  This property supersedes IEEE80211_RADIOTAP_CHANNEL
174170530Ssam *      and only one of the two should be present.
175119782Ssam */
176119782Ssamenum ieee80211_radiotap_type {
177123926Ssam	IEEE80211_RADIOTAP_TSFT = 0,
178119782Ssam	IEEE80211_RADIOTAP_FLAGS = 1,
179119782Ssam	IEEE80211_RADIOTAP_RATE = 2,
180119782Ssam	IEEE80211_RADIOTAP_CHANNEL = 3,
181119782Ssam	IEEE80211_RADIOTAP_FHSS = 4,
182123926Ssam	IEEE80211_RADIOTAP_DBM_ANTSIGNAL = 5,
183123926Ssam	IEEE80211_RADIOTAP_DBM_ANTNOISE = 6,
184119782Ssam	IEEE80211_RADIOTAP_LOCK_QUALITY = 7,
185119782Ssam	IEEE80211_RADIOTAP_TX_ATTENUATION = 8,
186119782Ssam	IEEE80211_RADIOTAP_DB_TX_ATTENUATION = 9,
187119782Ssam	IEEE80211_RADIOTAP_DBM_TX_POWER = 10,
188119782Ssam	IEEE80211_RADIOTAP_ANTENNA = 11,
189123926Ssam	IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12,
190123926Ssam	IEEE80211_RADIOTAP_DB_ANTNOISE = 13,
191170530Ssam	IEEE80211_RADIOTAP_XCHANNEL = 14,
192119782Ssam	IEEE80211_RADIOTAP_EXT = 31,
193119782Ssam};
194119782Ssam
195123926Ssam#ifndef _KERNEL
196123926Ssam/* Channel flags. */
197170530Ssam#define	IEEE80211_CHAN_TURBO	0x00010	/* Turbo channel */
198170530Ssam#define	IEEE80211_CHAN_CCK	0x00020	/* CCK channel */
199170530Ssam#define	IEEE80211_CHAN_OFDM	0x00040	/* OFDM channel */
200170530Ssam#define	IEEE80211_CHAN_2GHZ	0x00080	/* 2 GHz spectrum channel. */
201170530Ssam#define	IEEE80211_CHAN_5GHZ	0x00100	/* 5 GHz spectrum channel */
202170530Ssam#define	IEEE80211_CHAN_PASSIVE	0x00200	/* Only passive scan allowed */
203170530Ssam#define	IEEE80211_CHAN_DYN	0x00400	/* Dynamic CCK-OFDM channel */
204170530Ssam#define	IEEE80211_CHAN_GFSK	0x00800	/* GFSK channel (FHSS PHY) */
205170530Ssam#define	IEEE80211_CHAN_GSM	0x01000	/* 900 MHz spectrum channel */
206170530Ssam#define	IEEE80211_CHAN_STURBO	0x02000	/* 11a static turbo channel only */
207170530Ssam#define	IEEE80211_CHAN_HALF	0x04000	/* Half rate channel */
208170530Ssam#define	IEEE80211_CHAN_QUARTER	0x08000	/* Quarter rate channel */
209170530Ssam#define	IEEE80211_CHAN_HT20	0x10000	/* HT 20 channel */
210170530Ssam#define	IEEE80211_CHAN_HT40U	0x20000	/* HT 40 channel w/ ext above */
211170530Ssam#define	IEEE80211_CHAN_HT40D	0x40000	/* HT 40 channel w/ ext below */
212123926Ssam#endif /* !_KERNEL */
213123926Ssam
214119782Ssam/* For IEEE80211_RADIOTAP_FLAGS */
215123926Ssam#define	IEEE80211_RADIOTAP_F_CFP	0x01	/* sent/received
216119782Ssam						 * during CFP
217119782Ssam						 */
218123926Ssam#define	IEEE80211_RADIOTAP_F_SHORTPRE	0x02	/* sent/received
219119782Ssam						 * with short
220119782Ssam						 * preamble
221119782Ssam						 */
222123926Ssam#define	IEEE80211_RADIOTAP_F_WEP	0x04	/* sent/received
223119782Ssam						 * with WEP encryption
224119782Ssam						 */
225123926Ssam#define	IEEE80211_RADIOTAP_F_FRAG	0x08	/* sent/received
226119782Ssam						 * with fragmentation
227119782Ssam						 */
228140630Ssam#define	IEEE80211_RADIOTAP_F_FCS	0x10	/* frame includes FCS */
229140630Ssam#define	IEEE80211_RADIOTAP_F_DATAPAD	0x20	/* frame has padding between
230140630Ssam						 * 802.11 header and payload
231140630Ssam						 * (to 32-bit boundary)
232140630Ssam						 */
233154139Ssam#define	IEEE80211_RADIOTAP_F_BADFCS	0x40	/* does not pass FCS check */
234170530Ssam#define	IEEE80211_RADIOTAP_F_SHORTGI	0x80	/* HT short GI */
235119782Ssam
236167443Ssam#endif /* !_NET80211_IEEE80211_RADIOTAP_H_ */
237