ieee80211_radiotap.h revision 154139
1119782Ssam/* $FreeBSD: head/sys/net80211/ieee80211_radiotap.h 154139 2006-01-09 17:04:56Z sam $ */
2140630Ssam/* $NetBSD: ieee80211_radiotap.h,v 1.10 2005/01/04 00:34:58 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 */
32119782Ssam#ifndef _NET_IF_IEEE80211RADIOTAP_H_
33119782Ssam#define _NET_IF_IEEE80211RADIOTAP_H_
34119782Ssam
35119782Ssam/* A generic radio capture format is desirable. There is one for
36119782Ssam * Linux, but it is neither rigidly defined (there were not even
37119782Ssam * units given for some fields) nor easily extensible.
38119782Ssam *
39119782Ssam * I suggest the following 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
55140630Ssam/* XXX tcpdump/libpcap do not tolerate variable-length headers,
56140630Ssam * yet, so we pad every radiotap header to 64 bytes. Ugh.
57140630Ssam */
58140630Ssam#define IEEE80211_RADIOTAP_HDRLEN	64
59140630Ssam
60119782Ssam/* The radio capture header precedes the 802.11 header. */
61119782Ssamstruct ieee80211_radiotap_header {
62119782Ssam	u_int8_t	it_version;	/* Version 0. Only increases
63119782Ssam					 * for drastic changes,
64119782Ssam					 * introduction of compatible
65123926Ssam					 * new fields does not count.
66119782Ssam					 */
67119782Ssam	u_int8_t	it_pad;
68119782Ssam	u_int16_t       it_len;         /* length of the whole
69119782Ssam					 * header in bytes, including
70119782Ssam					 * it_version, it_pad,
71123926Ssam					 * it_len, and data fields.
72119782Ssam					 */
73119782Ssam	u_int32_t       it_present;     /* A bitmap telling which
74119782Ssam					 * fields are present. Set bit 31
75119782Ssam					 * (0x80000000) to extend the
76119782Ssam					 * bitmap by another 32 bits.
77119782Ssam					 * Additional extensions are made
78119782Ssam					 * by setting bit 31.
79119782Ssam					 */
80123926Ssam} __attribute__((__packed__));
81119782Ssam
82119782Ssam/* Name                                 Data type       Units
83119782Ssam * ----                                 ---------       -----
84119782Ssam *
85123926Ssam * IEEE80211_RADIOTAP_TSFT              u_int64_t       microseconds
86119782Ssam *
87123926Ssam *      Value in microseconds of the MAC's 64-bit 802.11 Time
88123926Ssam *      Synchronization Function timer when the first bit of the
89123926Ssam *      MPDU arrived at the MAC. For received frames, only.
90119782Ssam *
91123926Ssam * IEEE80211_RADIOTAP_CHANNEL           2 x u_int16_t   MHz, bitmap
92123926Ssam *
93123926Ssam *      Tx/Rx frequency in MHz, followed by flags (see below).
94123926Ssam *
95119782Ssam * IEEE80211_RADIOTAP_FHSS              u_int16_t       see below
96119782Ssam *
97119782Ssam *      For frequency-hopping radios, the hop set (first byte)
98119782Ssam *      and pattern (second byte).
99119782Ssam *
100123926Ssam * IEEE80211_RADIOTAP_RATE              u_int8_t        500kb/s
101119782Ssam *
102123926Ssam *      Tx/Rx data rate
103119782Ssam *
104123926Ssam * IEEE80211_RADIOTAP_DBM_ANTSIGNAL     int8_t          decibels from
105123926Ssam *                                                      one milliwatt (dBm)
106119782Ssam *
107123926Ssam *      RF signal power at the antenna, decibel difference from
108123926Ssam *      one milliwatt.
109119782Ssam *
110123926Ssam * IEEE80211_RADIOTAP_DBM_ANTNOISE      int8_t          decibels from
111123926Ssam *                                                      one milliwatt (dBm)
112119782Ssam *
113123926Ssam *      RF noise power at the antenna, decibel difference from one
114123926Ssam *      milliwatt.
115123926Ssam *
116123926Ssam * IEEE80211_RADIOTAP_DB_ANTSIGNAL      u_int8_t        decibel (dB)
117123926Ssam *
118123926Ssam *      RF signal power at the antenna, decibel difference from an
119123926Ssam *      arbitrary, fixed reference.
120123926Ssam *
121123926Ssam * IEEE80211_RADIOTAP_DB_ANTNOISE       u_int8_t        decibel (dB)
122123926Ssam *
123123926Ssam *      RF noise power at the antenna, decibel difference from an
124123926Ssam *      arbitrary, fixed reference point.
125123926Ssam *
126140630Ssam * IEEE80211_RADIOTAP_LOCK_QUALITY      u_int16_t       unitless
127119782Ssam *
128119782Ssam *      Quality of Barker code lock. Unitless. Monotonically
129119782Ssam *      nondecreasing with "better" lock strength. Called "Signal
130119782Ssam *      Quality" in datasheets.  (Is there a standard way to measure
131119782Ssam *      this?)
132119782Ssam *
133119782Ssam * IEEE80211_RADIOTAP_TX_ATTENUATION    u_int16_t       unitless
134119782Ssam *
135119782Ssam *      Transmit power expressed as unitless distance from max
136119782Ssam *      power set at factory calibration.  0 is max power.
137119782Ssam *      Monotonically nondecreasing with lower power levels.
138119782Ssam *
139119782Ssam * IEEE80211_RADIOTAP_DB_TX_ATTENUATION u_int16_t       decibels (dB)
140119782Ssam *
141119782Ssam *      Transmit power expressed as decibel distance from max power
142119782Ssam *      set at factory calibration.  0 is max power.  Monotonically
143119782Ssam *      nondecreasing with lower power levels.
144119782Ssam *
145123926Ssam * IEEE80211_RADIOTAP_DBM_TX_POWER      int8_t          decibels from
146123926Ssam *                                                      one milliwatt (dBm)
147119782Ssam *
148119782Ssam *      Transmit power expressed as dBm (decibels from a 1 milliwatt
149119782Ssam *      reference). This is the absolute power level measured at
150119782Ssam *      the antenna port.
151119782Ssam *
152123926Ssam * IEEE80211_RADIOTAP_FLAGS             u_int8_t        bitmap
153119782Ssam *
154119782Ssam *      Properties of transmitted and received frames. See flags
155119782Ssam *      defined below.
156119782Ssam *
157123926Ssam * IEEE80211_RADIOTAP_ANTENNA           u_int8_t        antenna index
158119782Ssam *
159119782Ssam *      Unitless indication of the Rx/Tx antenna for this packet.
160119782Ssam *      The first antenna is antenna 0.
161127917Ssam *
162127917Ssam * IEEE80211_RADIOTAP_FCS           	u_int32_t       data
163127917Ssam *
164127917Ssam *	FCS from frame in network byte order.
165119782Ssam */
166119782Ssamenum ieee80211_radiotap_type {
167123926Ssam	IEEE80211_RADIOTAP_TSFT = 0,
168119782Ssam	IEEE80211_RADIOTAP_FLAGS = 1,
169119782Ssam	IEEE80211_RADIOTAP_RATE = 2,
170119782Ssam	IEEE80211_RADIOTAP_CHANNEL = 3,
171119782Ssam	IEEE80211_RADIOTAP_FHSS = 4,
172123926Ssam	IEEE80211_RADIOTAP_DBM_ANTSIGNAL = 5,
173123926Ssam	IEEE80211_RADIOTAP_DBM_ANTNOISE = 6,
174119782Ssam	IEEE80211_RADIOTAP_LOCK_QUALITY = 7,
175119782Ssam	IEEE80211_RADIOTAP_TX_ATTENUATION = 8,
176119782Ssam	IEEE80211_RADIOTAP_DB_TX_ATTENUATION = 9,
177119782Ssam	IEEE80211_RADIOTAP_DBM_TX_POWER = 10,
178119782Ssam	IEEE80211_RADIOTAP_ANTENNA = 11,
179123926Ssam	IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12,
180123926Ssam	IEEE80211_RADIOTAP_DB_ANTNOISE = 13,
181119782Ssam	IEEE80211_RADIOTAP_EXT = 31,
182119782Ssam};
183119782Ssam
184123926Ssam#ifndef _KERNEL
185123926Ssam/* Channel flags. */
186140630Ssam#define	IEEE80211_CHAN_TURBO	0x0010	/* Turbo channel */
187140630Ssam#define	IEEE80211_CHAN_CCK	0x0020	/* CCK channel */
188140630Ssam#define	IEEE80211_CHAN_OFDM	0x0040	/* OFDM channel */
189140630Ssam#define	IEEE80211_CHAN_2GHZ	0x0080	/* 2 GHz spectrum channel. */
190140630Ssam#define	IEEE80211_CHAN_5GHZ	0x0100	/* 5 GHz spectrum channel */
191140630Ssam#define	IEEE80211_CHAN_PASSIVE	0x0200	/* Only passive scan allowed */
192123926Ssam#define	IEEE80211_CHAN_DYN	0x0400	/* Dynamic CCK-OFDM channel */
193123926Ssam#define	IEEE80211_CHAN_GFSK	0x0800	/* GFSK channel (FHSS PHY) */
194123926Ssam#endif /* !_KERNEL */
195123926Ssam
196119782Ssam/* For IEEE80211_RADIOTAP_FLAGS */
197123926Ssam#define	IEEE80211_RADIOTAP_F_CFP	0x01	/* sent/received
198119782Ssam						 * during CFP
199119782Ssam						 */
200123926Ssam#define	IEEE80211_RADIOTAP_F_SHORTPRE	0x02	/* sent/received
201119782Ssam						 * with short
202119782Ssam						 * preamble
203119782Ssam						 */
204123926Ssam#define	IEEE80211_RADIOTAP_F_WEP	0x04	/* sent/received
205119782Ssam						 * with WEP encryption
206119782Ssam						 */
207123926Ssam#define	IEEE80211_RADIOTAP_F_FRAG	0x08	/* sent/received
208119782Ssam						 * with fragmentation
209119782Ssam						 */
210140630Ssam#define	IEEE80211_RADIOTAP_F_FCS	0x10	/* frame includes FCS */
211140630Ssam#define	IEEE80211_RADIOTAP_F_DATAPAD	0x20	/* frame has padding between
212140630Ssam						 * 802.11 header and payload
213140630Ssam						 * (to 32-bit boundary)
214140630Ssam						 */
215154139Ssam#define	IEEE80211_RADIOTAP_F_BADFCS	0x40	/* does not pass FCS check */
216119782Ssam
217119782Ssam#endif /* _NET_IF_IEEE80211RADIOTAP_H_ */
218