ieee80211_radiotap.h revision 119782
1119782Ssam/* $FreeBSD: head/sys/net80211/ieee80211_radiotap.h 119782 2003-09-05 22:19:32Z sam $ */
2119782Ssam/*	$NetBSD: $	*/
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 */
49119782Ssam#ifndef DLT_IEEE802_11_RADIO
50119782Ssam#define	DLT_IEEE802_11_RADIO	127	/* 802.11 plus WLAN header */
51119782Ssam#endif
52119782Ssam
53119782Ssam/* The radio capture header precedes the 802.11 header. */
54119782Ssamstruct ieee80211_radiotap_header {
55119782Ssam	u_int8_t	it_version;	/* Version 0. Only increases
56119782Ssam					 * for drastic changes,
57119782Ssam					 * introduction of compatible
58119782Ssam					 * new LTVs does not count.
59119782Ssam					 */
60119782Ssam	u_int8_t	it_pad;
61119782Ssam	u_int16_t       it_len;         /* length of the whole
62119782Ssam					 * header in bytes, including
63119782Ssam					 * it_version, it_pad,
64119782Ssam					 * it_len, and LTVs.
65119782Ssam					 */
66119782Ssam	u_int32_t       it_present;     /* A bitmap telling which
67119782Ssam					 * fields are present. Set bit 31
68119782Ssam					 * (0x80000000) to extend the
69119782Ssam					 * bitmap by another 32 bits.
70119782Ssam					 * Additional extensions are made
71119782Ssam					 * by setting bit 31.
72119782Ssam					 */
73119782Ssam};
74119782Ssam
75119782Ssam/* Name                                 Data type       Units
76119782Ssam * ----                                 ---------       -----
77119782Ssam *
78119782Ssam * IEEE80211_RADIOTAP_CHANNEL           u_int8_t	MHz
79119782Ssam *
80119782Ssam *      Tx/Rx channel number (for DSSS/OFDM/PBCC PHY)
81119782Ssam *
82119782Ssam * IEEE80211_RADIOTAP_FHSS              u_int16_t       see below
83119782Ssam *
84119782Ssam *      For frequency-hopping radios, the hop set (first byte)
85119782Ssam *      and pattern (second byte).
86119782Ssam *
87119782Ssam * IEEE80211_RADIOTAP_RATE              u_int8_t	.5Mb/s
88119782Ssam *
89119782Ssam *      IEEE Tx/Rx data rate cookie (including basic rate flag)
90119782Ssam *
91119782Ssam * IEEE80211_RADIOTAP_DB_ANTSIGNAL      int16_t         decibel (dB)
92119782Ssam *
93119782Ssam *      RF signal power at the antenna, measured from a fixed,
94119782Ssam *      arbitrary reference point.
95119782Ssam *
96119782Ssam * IEEE80211_RADIOTAP_DB_ANTNOISE       int16_t         decibel (dB)
97119782Ssam *
98119782Ssam *      RF noise power at the antenna in decibels from an arbitrary,
99119782Ssam *      fixed reference point.
100119782Ssam *
101119782Ssam * IEEE80211_RADIOTAP_BARKER_CODE_LOCK  u_int16_t       unitless
102119782Ssam *
103119782Ssam *      Quality of Barker code lock. Unitless. Monotonically
104119782Ssam *      nondecreasing with "better" lock strength. Called "Signal
105119782Ssam *      Quality" in datasheets.  (Is there a standard way to measure
106119782Ssam *      this?)
107119782Ssam *
108119782Ssam * IEEE80211_RADIOTAP_TX_ATTENUATION    u_int16_t       unitless
109119782Ssam *
110119782Ssam *      Transmit power expressed as unitless distance from max
111119782Ssam *      power set at factory calibration.  0 is max power.
112119782Ssam *      Monotonically nondecreasing with lower power levels.
113119782Ssam *
114119782Ssam * IEEE80211_RADIOTAP_DB_TX_ATTENUATION u_int16_t       decibels (dB)
115119782Ssam *
116119782Ssam *      Transmit power expressed as decibel distance from max power
117119782Ssam *      set at factory calibration.  0 is max power.  Monotonically
118119782Ssam *      nondecreasing with lower power levels.
119119782Ssam *
120119782Ssam * IEEE80211_RADIOTAP_DBM_TX_POWER      u_int16_t       decibels from
121119782Ssam *                                                      milliwatt (dBm)
122119782Ssam *
123119782Ssam *      Transmit power expressed as dBm (decibels from a 1 milliwatt
124119782Ssam *      reference). This is the absolute power level measured at
125119782Ssam *      the antenna port.
126119782Ssam *
127119782Ssam * IEEE80211_RADIOTAP_TSFT              u_int64_t       microseconds
128119782Ssam *
129119782Ssam *      Value in microseconds of the MAC's 64-bit 802.11 Time
130119782Ssam *      Synchronization Function timer when the first bit of the
131119782Ssam *      MPDU arrived at the MAC. For received frames, only.
132119782Ssam *      Little-endian byte order.
133119782Ssam *
134119782Ssam * IEEE80211_RADIOTAP_FLAGS             u_int16_t       bitmap
135119782Ssam *
136119782Ssam *      Properties of transmitted and received frames. See flags
137119782Ssam *      defined below.
138119782Ssam *
139119782Ssam * IEEE80211_RADIOTAP_TIME              u_int32_t       microseconds
140119782Ssam *
141119782Ssam *      For radios that provide it: packet arrival time in
142119782Ssam *      microseconds. Prism hardware will provide this, but it is
143119782Ssam *      not known whether it marks the first or the last bit of
144119782Ssam *      the frame. Nor is it known where that bit has arrived
145119782Ssam *      (antenna, modem, MAC?) when the time is measured.
146119782Ssam *
147119782Ssam * IEEE80211_RADIOTAP_ANTENNA           u_int16_t       antenna index
148119782Ssam *
149119782Ssam *      Unitless indication of the Rx/Tx antenna for this packet.
150119782Ssam *      The first antenna is antenna 0.
151119782Ssam */
152119782Ssamenum ieee80211_radiotap_type {
153119782Ssam	IEEE80211_RADIOTAP_PAD = 0,
154119782Ssam	IEEE80211_RADIOTAP_FLAGS = 1,
155119782Ssam	IEEE80211_RADIOTAP_RATE = 2,
156119782Ssam	IEEE80211_RADIOTAP_CHANNEL = 3,
157119782Ssam	IEEE80211_RADIOTAP_FHSS = 4,
158119782Ssam	IEEE80211_RADIOTAP_DB_ANTSIGNAL = 5,
159119782Ssam	IEEE80211_RADIOTAP_DB_ANTNOISE = 6,
160119782Ssam	IEEE80211_RADIOTAP_LOCK_QUALITY = 7,
161119782Ssam	IEEE80211_RADIOTAP_TX_ATTENUATION = 8,
162119782Ssam	IEEE80211_RADIOTAP_DB_TX_ATTENUATION = 9,
163119782Ssam	IEEE80211_RADIOTAP_DBM_TX_POWER = 10,
164119782Ssam	IEEE80211_RADIOTAP_ANTENNA = 11,
165119782Ssam	IEEE80211_RADIOTAP_TSFT = 12,
166119782Ssam	IEEE80211_RADIOTAP_EXT = 31,
167119782Ssam	IEEE80211_RADIOTAP_TIME = 32
168119782Ssam};
169119782Ssam
170119782Ssam/* For IEEE80211_RADIOTAP_FLAGS */
171119782Ssam#define	IEEE80211_RADIOTAP_F_CFP	0x0001  /* sent/received
172119782Ssam						 * during CFP
173119782Ssam						 */
174119782Ssam#define	IEEE80211_RADIOTAP_F_SHORTPRE	0x0002  /* sent/received
175119782Ssam						 * with short
176119782Ssam						 * preamble
177119782Ssam						 */
178119782Ssam#define	IEEE80211_RADIOTAP_F_WEP	0x0004  /* sent/received
179119782Ssam						 * with WEP encryption
180119782Ssam						 */
181119782Ssam#define	IEEE80211_RADIOTAP_F_FRAG	0x0008  /* sent/received
182119782Ssam						 * with fragmentation
183119782Ssam						 */
184119782Ssam
185119782Ssam#endif /* _NET_IF_IEEE80211RADIOTAP_H_ */
186