1119782Ssam/* $FreeBSD$ */ 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 57232095Sadrianstruct ieee80211_radiotap_vendor_header { 58232095Sadrian uint8_t vh_oui[3]; /* 3 byte vendor OUI */ 59232095Sadrian uint8_t vh_sub_ns; /* Sub namespace of this section */ 60232095Sadrian uint16_t vh_skip_len; /* Length of this vendor section */ 61232095Sadrian} __packed; 62232095Sadrian 63167443Ssam/* 64167443Ssam * The radio capture header precedes the 802.11 header. 65167443Ssam * 66167443Ssam * Note well: all radiotap fields are little-endian. 67140630Ssam */ 68119782Ssamstruct ieee80211_radiotap_header { 69170530Ssam uint8_t it_version; /* Version 0. Only increases 70119782Ssam * for drastic changes, 71119782Ssam * introduction of compatible 72123926Ssam * new fields does not count. 73119782Ssam */ 74170530Ssam uint8_t it_pad; 75170530Ssam uint16_t it_len; /* length of the whole 76119782Ssam * header in bytes, including 77119782Ssam * it_version, it_pad, 78123926Ssam * it_len, and data fields. 79119782Ssam */ 80170530Ssam uint32_t it_present; /* A bitmap telling which 81119782Ssam * fields are present. Set bit 31 82119782Ssam * (0x80000000) to extend the 83119782Ssam * bitmap by another 32 bits. 84119782Ssam * Additional extensions are made 85119782Ssam * by setting bit 31. 86119782Ssam */ 87170573Simp} __packed; 88119782Ssam 89167443Ssam/* 90167443Ssam * Name Data type Units 91119782Ssam * ---- --------- ----- 92119782Ssam * 93170530Ssam * IEEE80211_RADIOTAP_TSFT uint64_t microseconds 94119782Ssam * 95123926Ssam * Value in microseconds of the MAC's 64-bit 802.11 Time 96123926Ssam * Synchronization Function timer when the first bit of the 97123926Ssam * MPDU arrived at the MAC. For received frames, only. 98119782Ssam * 99170530Ssam * IEEE80211_RADIOTAP_CHANNEL 2 x uint16_t MHz, bitmap 100123926Ssam * 101123926Ssam * Tx/Rx frequency in MHz, followed by flags (see below). 102123926Ssam * 103170530Ssam * IEEE80211_RADIOTAP_FHSS uint16_t see below 104119782Ssam * 105119782Ssam * For frequency-hopping radios, the hop set (first byte) 106119782Ssam * and pattern (second byte). 107119782Ssam * 108170530Ssam * IEEE80211_RADIOTAP_RATE uint8_t 500kb/s or index 109119782Ssam * 110170530Ssam * Tx/Rx data rate. If bit 0x80 is set then it represents an 111170530Ssam * an MCS index and not an IEEE rate. 112119782Ssam * 113123926Ssam * IEEE80211_RADIOTAP_DBM_ANTSIGNAL int8_t decibels from 114123926Ssam * one milliwatt (dBm) 115119782Ssam * 116123926Ssam * RF signal power at the antenna, decibel difference from 117123926Ssam * one milliwatt. 118119782Ssam * 119123926Ssam * IEEE80211_RADIOTAP_DBM_ANTNOISE int8_t decibels from 120123926Ssam * one milliwatt (dBm) 121119782Ssam * 122123926Ssam * RF noise power at the antenna, decibel difference from one 123123926Ssam * milliwatt. 124123926Ssam * 125170530Ssam * IEEE80211_RADIOTAP_DB_ANTSIGNAL uint8_t decibel (dB) 126123926Ssam * 127123926Ssam * RF signal power at the antenna, decibel difference from an 128123926Ssam * arbitrary, fixed reference. 129123926Ssam * 130170530Ssam * IEEE80211_RADIOTAP_DB_ANTNOISE uint8_t decibel (dB) 131123926Ssam * 132123926Ssam * RF noise power at the antenna, decibel difference from an 133123926Ssam * arbitrary, fixed reference point. 134123926Ssam * 135170530Ssam * IEEE80211_RADIOTAP_LOCK_QUALITY uint16_t unitless 136119782Ssam * 137119782Ssam * Quality of Barker code lock. Unitless. Monotonically 138119782Ssam * nondecreasing with "better" lock strength. Called "Signal 139119782Ssam * Quality" in datasheets. (Is there a standard way to measure 140119782Ssam * this?) 141119782Ssam * 142170530Ssam * IEEE80211_RADIOTAP_TX_ATTENUATION uint16_t unitless 143119782Ssam * 144119782Ssam * Transmit power expressed as unitless distance from max 145119782Ssam * power set at factory calibration. 0 is max power. 146119782Ssam * Monotonically nondecreasing with lower power levels. 147119782Ssam * 148170530Ssam * IEEE80211_RADIOTAP_DB_TX_ATTENUATION uint16_t decibels (dB) 149119782Ssam * 150119782Ssam * Transmit power expressed as decibel distance from max power 151119782Ssam * set at factory calibration. 0 is max power. Monotonically 152119782Ssam * nondecreasing with lower power levels. 153119782Ssam * 154123926Ssam * IEEE80211_RADIOTAP_DBM_TX_POWER int8_t decibels from 155123926Ssam * one milliwatt (dBm) 156119782Ssam * 157119782Ssam * Transmit power expressed as dBm (decibels from a 1 milliwatt 158119782Ssam * reference). This is the absolute power level measured at 159119782Ssam * the antenna port. 160119782Ssam * 161170530Ssam * IEEE80211_RADIOTAP_FLAGS uint8_t bitmap 162119782Ssam * 163119782Ssam * Properties of transmitted and received frames. See flags 164119782Ssam * defined below. 165119782Ssam * 166170530Ssam * IEEE80211_RADIOTAP_ANTENNA uint8_t antenna index 167119782Ssam * 168119782Ssam * Unitless indication of the Rx/Tx antenna for this packet. 169119782Ssam * The first antenna is antenna 0. 170170530Ssam * 171170530Ssam * IEEE80211_RADIOTAP_XCHANNEL uint32_t bitmap 172170530Ssam * uint16_t MHz 173170530Ssam * uint8_t channel number 174170530Ssam * int8_t .5 dBm 175170530Ssam * 176170530Ssam * Extended channel specification: flags (see below) followed by 177170530Ssam * frequency in MHz, the corresponding IEEE channel number, and 178170530Ssam * finally the maximum regulatory transmit power cap in .5 dBm 179170530Ssam * units. This property supersedes IEEE80211_RADIOTAP_CHANNEL 180170530Ssam * and only one of the two should be present. 181119782Ssam */ 182119782Ssamenum ieee80211_radiotap_type { 183123926Ssam IEEE80211_RADIOTAP_TSFT = 0, 184119782Ssam IEEE80211_RADIOTAP_FLAGS = 1, 185119782Ssam IEEE80211_RADIOTAP_RATE = 2, 186119782Ssam IEEE80211_RADIOTAP_CHANNEL = 3, 187119782Ssam IEEE80211_RADIOTAP_FHSS = 4, 188123926Ssam IEEE80211_RADIOTAP_DBM_ANTSIGNAL = 5, 189123926Ssam IEEE80211_RADIOTAP_DBM_ANTNOISE = 6, 190119782Ssam IEEE80211_RADIOTAP_LOCK_QUALITY = 7, 191119782Ssam IEEE80211_RADIOTAP_TX_ATTENUATION = 8, 192119782Ssam IEEE80211_RADIOTAP_DB_TX_ATTENUATION = 9, 193119782Ssam IEEE80211_RADIOTAP_DBM_TX_POWER = 10, 194119782Ssam IEEE80211_RADIOTAP_ANTENNA = 11, 195123926Ssam IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12, 196123926Ssam IEEE80211_RADIOTAP_DB_ANTNOISE = 13, 197245156Sadrian /* 198245156Sadrian * 14-17 are from Linux, they overlap the netbsd-specific 199245156Sadrian * fields. 200245156Sadrian */ 201245156Sadrian IEEE80211_RADIOTAP_RX_FLAGS = 14, 202245156Sadrian IEEE80211_RADIOTAP_TX_FLAGS = 15, 203245156Sadrian IEEE80211_RADIOTAP_RTS_RETRIES = 16, 204245156Sadrian IEEE80211_RADIOTAP_DATA_RETRIES = 17, 205245156Sadrian 206171127Sthompsa IEEE80211_RADIOTAP_XCHANNEL = 18, 207229952Sadrian IEEE80211_RADIOTAP_MCS = 19, 208245156Sadrian IEEE80211_RADIOTAP_AMPDU_STATUS = 20, 209245156Sadrian 210245156Sadrian IEEE80211_RADIOTAP_RADIOTAP_NAMESPACE = 29, 211229948Sadrian IEEE80211_RADIOTAP_VENDOREXT = 30, 212119782Ssam IEEE80211_RADIOTAP_EXT = 31, 213119782Ssam}; 214119782Ssam 215123926Ssam#ifndef _KERNEL 216174568Ssam/* channel attributes */ 217174568Ssam#define IEEE80211_CHAN_TURBO 0x00000010 /* Turbo channel */ 218174568Ssam#define IEEE80211_CHAN_CCK 0x00000020 /* CCK channel */ 219174568Ssam#define IEEE80211_CHAN_OFDM 0x00000040 /* OFDM channel */ 220174568Ssam#define IEEE80211_CHAN_2GHZ 0x00000080 /* 2 GHz spectrum channel. */ 221174568Ssam#define IEEE80211_CHAN_5GHZ 0x00000100 /* 5 GHz spectrum channel */ 222174568Ssam#define IEEE80211_CHAN_PASSIVE 0x00000200 /* Only passive scan allowed */ 223174568Ssam#define IEEE80211_CHAN_DYN 0x00000400 /* Dynamic CCK-OFDM channel */ 224174568Ssam#define IEEE80211_CHAN_GFSK 0x00000800 /* GFSK channel (FHSS PHY) */ 225174568Ssam#define IEEE80211_CHAN_GSM 0x00001000 /* 900 MHz spectrum channel */ 226174568Ssam#define IEEE80211_CHAN_STURBO 0x00002000 /* 11a static turbo channel only */ 227174568Ssam#define IEEE80211_CHAN_HALF 0x00004000 /* Half rate channel */ 228174568Ssam#define IEEE80211_CHAN_QUARTER 0x00008000 /* Quarter rate channel */ 229123926Ssam#endif /* !_KERNEL */ 230123926Ssam 231119782Ssam/* For IEEE80211_RADIOTAP_FLAGS */ 232123926Ssam#define IEEE80211_RADIOTAP_F_CFP 0x01 /* sent/received 233119782Ssam * during CFP 234119782Ssam */ 235123926Ssam#define IEEE80211_RADIOTAP_F_SHORTPRE 0x02 /* sent/received 236119782Ssam * with short 237119782Ssam * preamble 238119782Ssam */ 239123926Ssam#define IEEE80211_RADIOTAP_F_WEP 0x04 /* sent/received 240119782Ssam * with WEP encryption 241119782Ssam */ 242123926Ssam#define IEEE80211_RADIOTAP_F_FRAG 0x08 /* sent/received 243119782Ssam * with fragmentation 244119782Ssam */ 245140630Ssam#define IEEE80211_RADIOTAP_F_FCS 0x10 /* frame includes FCS */ 246140630Ssam#define IEEE80211_RADIOTAP_F_DATAPAD 0x20 /* frame has padding between 247140630Ssam * 802.11 header and payload 248140630Ssam * (to 32-bit boundary) 249140630Ssam */ 250154139Ssam#define IEEE80211_RADIOTAP_F_BADFCS 0x40 /* does not pass FCS check */ 251170530Ssam#define IEEE80211_RADIOTAP_F_SHORTGI 0x80 /* HT short GI */ 252119782Ssam 253167443Ssam#endif /* !_NET80211_IEEE80211_RADIOTAP_H_ */ 254