ieee80211_radiotap.h revision 229948
1169695Skan/* $FreeBSD: head/sys/net80211/ieee80211_radiotap.h 229948 2012-01-10 23:37:32Z adrian $ */ 2169695Skan/* $NetBSD: ieee80211_radiotap.h,v 1.16 2007/01/06 05:51:15 dyoung Exp $ */ 3169695Skan 4169695Skan/*- 5169695Skan * Copyright (c) 2003, 2004 David Young. All rights reserved. 6169695Skan * 7169695Skan * Redistribution and use in source and binary forms, with or without 8169695Skan * modification, are permitted provided that the following conditions 9169695Skan * are met: 10169695Skan * 1. Redistributions of source code must retain the above copyright 11169695Skan * notice, this list of conditions and the following disclaimer. 12169695Skan * 2. Redistributions in binary form must reproduce the above copyright 13169695Skan * notice, this list of conditions and the following disclaimer in the 14169695Skan * documentation and/or other materials provided with the distribution. 15169695Skan * 3. The name of David Young may not be used to endorse or promote 16169695Skan * products derived from this software without specific prior 17169695Skan * written permission. 18169695Skan * 19169695Skan * THIS SOFTWARE IS PROVIDED BY DAVID YOUNG ``AS IS'' AND ANY 20169695Skan * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21169695Skan * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22169695Skan * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DAVID 23169695Skan * YOUNG BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 24169695Skan * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 25169695Skan * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26169695Skan * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27169695Skan * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28169695Skan * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29169695Skan * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 30169695Skan * OF SUCH DAMAGE. 31169695Skan */ 32169695Skan#ifndef _NET80211_IEEE80211_RADIOTAP_H_ 33169695Skan#define _NET80211_IEEE80211_RADIOTAP_H_ 34169695Skan 35169695Skan/* A generic radio capture format is desirable. It must be 36169695Skan * rigidly defined (e.g., units for fields should be given), 37169695Skan * and easily extensible. 38169695Skan * 39169695Skan * The following is an extensible radio capture format. It is 40169695Skan * based on a bitmap indicating which fields are present. 41169695Skan * 42169695Skan * I am trying to describe precisely what the application programmer 43169695Skan * should expect in the following, and for that reason I tell the 44169695Skan * units and origin of each measurement (where it applies), or else I 45169695Skan * use sufficiently weaselly language ("is a monotonically nondecreasing 46169695Skan * function of...") that I cannot set false expectations for lawyerly 47169695Skan * readers. 48169695Skan */ 49169695Skan#if defined(__KERNEL__) || defined(_KERNEL) 50169695Skan#ifndef DLT_IEEE802_11_RADIO 51169695Skan#define DLT_IEEE802_11_RADIO 127 /* 802.11 plus WLAN header */ 52169695Skan#endif 53169695Skan#endif /* defined(__KERNEL__) || defined(_KERNEL) */ 54169695Skan 55169695Skan#define IEEE80211_RADIOTAP_HDRLEN 64 /* XXX deprecated */ 56169695Skan 57169695Skan/* 58169695Skan * The radio capture header precedes the 802.11 header. 59169695Skan * 60169695Skan * Note well: all radiotap fields are little-endian. 61169695Skan */ 62169695Skanstruct ieee80211_radiotap_header { 63169695Skan uint8_t it_version; /* Version 0. Only increases 64169695Skan * for drastic changes, 65169695Skan * introduction of compatible 66169695Skan * new fields does not count. 67169695Skan */ 68169695Skan uint8_t it_pad; 69169695Skan uint16_t it_len; /* length of the whole 70169695Skan * header in bytes, including 71169695Skan * it_version, it_pad, 72169695Skan * it_len, and data fields. 73169695Skan */ 74169695Skan uint32_t it_present; /* A bitmap telling which 75169695Skan * fields are present. Set bit 31 76169695Skan * (0x80000000) to extend the 77169695Skan * bitmap by another 32 bits. 78169695Skan * Additional extensions are made 79169695Skan * by setting bit 31. 80169695Skan */ 81169695Skan} __packed; 82169695Skan 83169695Skan/* 84169695Skan * Name Data type Units 85169695Skan * ---- --------- ----- 86169695Skan * 87169695Skan * IEEE80211_RADIOTAP_TSFT uint64_t microseconds 88169695Skan * 89169695Skan * Value in microseconds of the MAC's 64-bit 802.11 Time 90169695Skan * Synchronization Function timer when the first bit of the 91169695Skan * MPDU arrived at the MAC. For received frames, only. 92169695Skan * 93169695Skan * IEEE80211_RADIOTAP_CHANNEL 2 x uint16_t MHz, bitmap 94169695Skan * 95169695Skan * Tx/Rx frequency in MHz, followed by flags (see below). 96169695Skan * 97169695Skan * IEEE80211_RADIOTAP_FHSS uint16_t see below 98169695Skan * 99169695Skan * For frequency-hopping radios, the hop set (first byte) 100169695Skan * and pattern (second byte). 101169695Skan * 102169695Skan * IEEE80211_RADIOTAP_RATE uint8_t 500kb/s or index 103169695Skan * 104169695Skan * Tx/Rx data rate. If bit 0x80 is set then it represents an 105169695Skan * an MCS index and not an IEEE rate. 106169695Skan * 107169695Skan * IEEE80211_RADIOTAP_DBM_ANTSIGNAL int8_t decibels from 108169695Skan * one milliwatt (dBm) 109169695Skan * 110169695Skan * RF signal power at the antenna, decibel difference from 111169695Skan * one milliwatt. 112169695Skan * 113169695Skan * IEEE80211_RADIOTAP_DBM_ANTNOISE int8_t decibels from 114169695Skan * one milliwatt (dBm) 115169695Skan * 116169695Skan * RF noise power at the antenna, decibel difference from one 117169695Skan * milliwatt. 118169695Skan * 119169695Skan * IEEE80211_RADIOTAP_DB_ANTSIGNAL uint8_t decibel (dB) 120169695Skan * 121169695Skan * RF signal power at the antenna, decibel difference from an 122169695Skan * arbitrary, fixed reference. 123169695Skan * 124169695Skan * IEEE80211_RADIOTAP_DB_ANTNOISE uint8_t decibel (dB) 125169695Skan * 126169695Skan * RF noise power at the antenna, decibel difference from an 127169695Skan * arbitrary, fixed reference point. 128169695Skan * 129169695Skan * IEEE80211_RADIOTAP_LOCK_QUALITY uint16_t unitless 130169695Skan * 131169695Skan * Quality of Barker code lock. Unitless. Monotonically 132169695Skan * nondecreasing with "better" lock strength. Called "Signal 133169695Skan * Quality" in datasheets. (Is there a standard way to measure 134169695Skan * this?) 135169695Skan * 136169695Skan * IEEE80211_RADIOTAP_TX_ATTENUATION uint16_t unitless 137169695Skan * 138169695Skan * Transmit power expressed as unitless distance from max 139169695Skan * power set at factory calibration. 0 is max power. 140169695Skan * Monotonically nondecreasing with lower power levels. 141169695Skan * 142 * IEEE80211_RADIOTAP_DB_TX_ATTENUATION uint16_t decibels (dB) 143 * 144 * Transmit power expressed as decibel distance from max power 145 * set at factory calibration. 0 is max power. Monotonically 146 * nondecreasing with lower power levels. 147 * 148 * IEEE80211_RADIOTAP_DBM_TX_POWER int8_t decibels from 149 * one milliwatt (dBm) 150 * 151 * Transmit power expressed as dBm (decibels from a 1 milliwatt 152 * reference). This is the absolute power level measured at 153 * the antenna port. 154 * 155 * IEEE80211_RADIOTAP_FLAGS uint8_t bitmap 156 * 157 * Properties of transmitted and received frames. See flags 158 * defined below. 159 * 160 * IEEE80211_RADIOTAP_ANTENNA uint8_t antenna index 161 * 162 * Unitless indication of the Rx/Tx antenna for this packet. 163 * The first antenna is antenna 0. 164 * 165 * IEEE80211_RADIOTAP_XCHANNEL uint32_t bitmap 166 * uint16_t MHz 167 * uint8_t channel number 168 * int8_t .5 dBm 169 * 170 * Extended channel specification: flags (see below) followed by 171 * frequency in MHz, the corresponding IEEE channel number, and 172 * finally the maximum regulatory transmit power cap in .5 dBm 173 * units. This property supersedes IEEE80211_RADIOTAP_CHANNEL 174 * and only one of the two should be present. 175 */ 176enum ieee80211_radiotap_type { 177 IEEE80211_RADIOTAP_TSFT = 0, 178 IEEE80211_RADIOTAP_FLAGS = 1, 179 IEEE80211_RADIOTAP_RATE = 2, 180 IEEE80211_RADIOTAP_CHANNEL = 3, 181 IEEE80211_RADIOTAP_FHSS = 4, 182 IEEE80211_RADIOTAP_DBM_ANTSIGNAL = 5, 183 IEEE80211_RADIOTAP_DBM_ANTNOISE = 6, 184 IEEE80211_RADIOTAP_LOCK_QUALITY = 7, 185 IEEE80211_RADIOTAP_TX_ATTENUATION = 8, 186 IEEE80211_RADIOTAP_DB_TX_ATTENUATION = 9, 187 IEEE80211_RADIOTAP_DBM_TX_POWER = 10, 188 IEEE80211_RADIOTAP_ANTENNA = 11, 189 IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12, 190 IEEE80211_RADIOTAP_DB_ANTNOISE = 13, 191 /* NB: gap for netbsd definitions */ 192 IEEE80211_RADIOTAP_XCHANNEL = 18, 193 IEEE80211_RADIOTAP_VENDOREXT = 30, 194 IEEE80211_RADIOTAP_EXT = 31, 195}; 196 197#ifndef _KERNEL 198/* channel attributes */ 199#define IEEE80211_CHAN_TURBO 0x00000010 /* Turbo channel */ 200#define IEEE80211_CHAN_CCK 0x00000020 /* CCK channel */ 201#define IEEE80211_CHAN_OFDM 0x00000040 /* OFDM channel */ 202#define IEEE80211_CHAN_2GHZ 0x00000080 /* 2 GHz spectrum channel. */ 203#define IEEE80211_CHAN_5GHZ 0x00000100 /* 5 GHz spectrum channel */ 204#define IEEE80211_CHAN_PASSIVE 0x00000200 /* Only passive scan allowed */ 205#define IEEE80211_CHAN_DYN 0x00000400 /* Dynamic CCK-OFDM channel */ 206#define IEEE80211_CHAN_GFSK 0x00000800 /* GFSK channel (FHSS PHY) */ 207#define IEEE80211_CHAN_GSM 0x00001000 /* 900 MHz spectrum channel */ 208#define IEEE80211_CHAN_STURBO 0x00002000 /* 11a static turbo channel only */ 209#define IEEE80211_CHAN_HALF 0x00004000 /* Half rate channel */ 210#define IEEE80211_CHAN_QUARTER 0x00008000 /* Quarter rate channel */ 211#endif /* !_KERNEL */ 212 213/* For IEEE80211_RADIOTAP_FLAGS */ 214#define IEEE80211_RADIOTAP_F_CFP 0x01 /* sent/received 215 * during CFP 216 */ 217#define IEEE80211_RADIOTAP_F_SHORTPRE 0x02 /* sent/received 218 * with short 219 * preamble 220 */ 221#define IEEE80211_RADIOTAP_F_WEP 0x04 /* sent/received 222 * with WEP encryption 223 */ 224#define IEEE80211_RADIOTAP_F_FRAG 0x08 /* sent/received 225 * with fragmentation 226 */ 227#define IEEE80211_RADIOTAP_F_FCS 0x10 /* frame includes FCS */ 228#define IEEE80211_RADIOTAP_F_DATAPAD 0x20 /* frame has padding between 229 * 802.11 header and payload 230 * (to 32-bit boundary) 231 */ 232#define IEEE80211_RADIOTAP_F_BADFCS 0x40 /* does not pass FCS check */ 233#define IEEE80211_RADIOTAP_F_SHORTGI 0x80 /* HT short GI */ 234 235#endif /* !_NET80211_IEEE80211_RADIOTAP_H_ */ 236