ieee80211_radiotap.h revision 123926
1119782Ssam/* $FreeBSD: head/sys/net80211/ieee80211_radiotap.h 123926 2003-12-28 06:57:28Z sam $ */
2123926Ssam/* $NetBSD: ieee80211_radiotap.h,v 1.3 2003/11/16 09:02:42 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 */
49123926Ssam#ifdef _KERNEL
50119782Ssam#ifndef DLT_IEEE802_11_RADIO
51119782Ssam#define	DLT_IEEE802_11_RADIO	127	/* 802.11 plus WLAN header */
52119782Ssam#endif
53123926Ssam#endif /* _KERNEL */
54119782Ssam
55119782Ssam/* The radio capture header precedes the 802.11 header. */
56119782Ssamstruct ieee80211_radiotap_header {
57119782Ssam	u_int8_t	it_version;	/* Version 0. Only increases
58119782Ssam					 * for drastic changes,
59119782Ssam					 * introduction of compatible
60123926Ssam					 * new fields does not count.
61119782Ssam					 */
62119782Ssam	u_int8_t	it_pad;
63119782Ssam	u_int16_t       it_len;         /* length of the whole
64119782Ssam					 * header in bytes, including
65119782Ssam					 * it_version, it_pad,
66123926Ssam					 * it_len, and data fields.
67119782Ssam					 */
68119782Ssam	u_int32_t       it_present;     /* A bitmap telling which
69119782Ssam					 * fields are present. Set bit 31
70119782Ssam					 * (0x80000000) to extend the
71119782Ssam					 * bitmap by another 32 bits.
72119782Ssam					 * Additional extensions are made
73119782Ssam					 * by setting bit 31.
74119782Ssam					 */
75123926Ssam} __attribute__((__packed__));
76119782Ssam
77119782Ssam/* Name                                 Data type       Units
78119782Ssam * ----                                 ---------       -----
79119782Ssam *
80123926Ssam * IEEE80211_RADIOTAP_TSFT              u_int64_t       microseconds
81119782Ssam *
82123926Ssam *      Value in microseconds of the MAC's 64-bit 802.11 Time
83123926Ssam *      Synchronization Function timer when the first bit of the
84123926Ssam *      MPDU arrived at the MAC. For received frames, only.
85119782Ssam *
86123926Ssam * IEEE80211_RADIOTAP_CHANNEL           2 x u_int16_t   MHz, bitmap
87123926Ssam *
88123926Ssam *      Tx/Rx frequency in MHz, followed by flags (see below).
89123926Ssam *
90119782Ssam * IEEE80211_RADIOTAP_FHSS              u_int16_t       see below
91119782Ssam *
92119782Ssam *      For frequency-hopping radios, the hop set (first byte)
93119782Ssam *      and pattern (second byte).
94119782Ssam *
95123926Ssam * IEEE80211_RADIOTAP_RATE              u_int8_t        500kb/s
96119782Ssam *
97123926Ssam *      Tx/Rx data rate
98119782Ssam *
99123926Ssam * IEEE80211_RADIOTAP_DBM_ANTSIGNAL     int8_t          decibels from
100123926Ssam *                                                      one milliwatt (dBm)
101119782Ssam *
102123926Ssam *      RF signal power at the antenna, decibel difference from
103123926Ssam *      one milliwatt.
104119782Ssam *
105123926Ssam * IEEE80211_RADIOTAP_DBM_ANTNOISE      int8_t          decibels from
106123926Ssam *                                                      one milliwatt (dBm)
107119782Ssam *
108123926Ssam *      RF noise power at the antenna, decibel difference from one
109123926Ssam *      milliwatt.
110123926Ssam *
111123926Ssam * IEEE80211_RADIOTAP_DB_ANTSIGNAL      u_int8_t        decibel (dB)
112123926Ssam *
113123926Ssam *      RF signal power at the antenna, decibel difference from an
114123926Ssam *      arbitrary, fixed reference.
115123926Ssam *
116123926Ssam * IEEE80211_RADIOTAP_DB_ANTNOISE       u_int8_t        decibel (dB)
117123926Ssam *
118123926Ssam *      RF noise power at the antenna, decibel difference from an
119123926Ssam *      arbitrary, fixed reference point.
120123926Ssam *
121119782Ssam * IEEE80211_RADIOTAP_BARKER_CODE_LOCK  u_int16_t       unitless
122119782Ssam *
123119782Ssam *      Quality of Barker code lock. Unitless. Monotonically
124119782Ssam *      nondecreasing with "better" lock strength. Called "Signal
125119782Ssam *      Quality" in datasheets.  (Is there a standard way to measure
126119782Ssam *      this?)
127119782Ssam *
128119782Ssam * IEEE80211_RADIOTAP_TX_ATTENUATION    u_int16_t       unitless
129119782Ssam *
130119782Ssam *      Transmit power expressed as unitless distance from max
131119782Ssam *      power set at factory calibration.  0 is max power.
132119782Ssam *      Monotonically nondecreasing with lower power levels.
133119782Ssam *
134119782Ssam * IEEE80211_RADIOTAP_DB_TX_ATTENUATION u_int16_t       decibels (dB)
135119782Ssam *
136119782Ssam *      Transmit power expressed as decibel distance from max power
137119782Ssam *      set at factory calibration.  0 is max power.  Monotonically
138119782Ssam *      nondecreasing with lower power levels.
139119782Ssam *
140123926Ssam * IEEE80211_RADIOTAP_DBM_TX_POWER      int8_t          decibels from
141123926Ssam *                                                      one milliwatt (dBm)
142119782Ssam *
143119782Ssam *      Transmit power expressed as dBm (decibels from a 1 milliwatt
144119782Ssam *      reference). This is the absolute power level measured at
145119782Ssam *      the antenna port.
146119782Ssam *
147123926Ssam * IEEE80211_RADIOTAP_FLAGS             u_int8_t        bitmap
148119782Ssam *
149119782Ssam *      Properties of transmitted and received frames. See flags
150119782Ssam *      defined below.
151119782Ssam *
152123926Ssam * IEEE80211_RADIOTAP_ANTENNA           u_int8_t        antenna index
153119782Ssam *
154119782Ssam *      Unitless indication of the Rx/Tx antenna for this packet.
155119782Ssam *      The first antenna is antenna 0.
156119782Ssam */
157119782Ssamenum ieee80211_radiotap_type {
158123926Ssam	IEEE80211_RADIOTAP_TSFT = 0,
159119782Ssam	IEEE80211_RADIOTAP_FLAGS = 1,
160119782Ssam	IEEE80211_RADIOTAP_RATE = 2,
161119782Ssam	IEEE80211_RADIOTAP_CHANNEL = 3,
162119782Ssam	IEEE80211_RADIOTAP_FHSS = 4,
163123926Ssam	IEEE80211_RADIOTAP_DBM_ANTSIGNAL = 5,
164123926Ssam	IEEE80211_RADIOTAP_DBM_ANTNOISE = 6,
165119782Ssam	IEEE80211_RADIOTAP_LOCK_QUALITY = 7,
166119782Ssam	IEEE80211_RADIOTAP_TX_ATTENUATION = 8,
167119782Ssam	IEEE80211_RADIOTAP_DB_TX_ATTENUATION = 9,
168119782Ssam	IEEE80211_RADIOTAP_DBM_TX_POWER = 10,
169119782Ssam	IEEE80211_RADIOTAP_ANTENNA = 11,
170123926Ssam	IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12,
171123926Ssam	IEEE80211_RADIOTAP_DB_ANTNOISE = 13,
172119782Ssam	IEEE80211_RADIOTAP_EXT = 31,
173119782Ssam};
174119782Ssam
175123926Ssam#ifndef _KERNEL
176123926Ssam/* Channel flags. */
177123926Ssam#define IEEE80211_CHAN_TURBO    0x0010  /* Turbo channel */
178123926Ssam#define IEEE80211_CHAN_CCK      0x0020  /* CCK channel */
179123926Ssam#define IEEE80211_CHAN_OFDM     0x0040  /* OFDM channel */
180123926Ssam#define IEEE80211_CHAN_2GHZ     0x0080  /* 2 GHz spectrum channel. */
181123926Ssam#define IEEE80211_CHAN_5GHZ     0x0100  /* 5 GHz spectrum channel */
182123926Ssam#define IEEE80211_CHAN_PASSIVE  0x0200  /* Only passive scan allowed */
183123926Ssam#define	IEEE80211_CHAN_DYN	0x0400	/* Dynamic CCK-OFDM channel */
184123926Ssam#define	IEEE80211_CHAN_GFSK	0x0800	/* GFSK channel (FHSS PHY) */
185123926Ssam#endif /* !_KERNEL */
186123926Ssam
187119782Ssam/* For IEEE80211_RADIOTAP_FLAGS */
188123926Ssam#define	IEEE80211_RADIOTAP_F_CFP	0x01	/* sent/received
189119782Ssam						 * during CFP
190119782Ssam						 */
191123926Ssam#define	IEEE80211_RADIOTAP_F_SHORTPRE	0x02	/* sent/received
192119782Ssam						 * with short
193119782Ssam						 * preamble
194119782Ssam						 */
195123926Ssam#define	IEEE80211_RADIOTAP_F_WEP	0x04	/* sent/received
196119782Ssam						 * with WEP encryption
197119782Ssam						 */
198123926Ssam#define	IEEE80211_RADIOTAP_F_FRAG	0x08	/* sent/received
199119782Ssam						 * with fragmentation
200119782Ssam						 */
201119782Ssam
202119782Ssam#endif /* _NET_IF_IEEE80211RADIOTAP_H_ */
203