Path: blob/master/include/net/ieee80211_radiotap.h
10818 views
/*1* Copyright (c) 2003, 2004 David Young. All rights reserved.2*3* Redistribution and use in source and binary forms, with or without4* modification, are permitted provided that the following conditions5* are met:6* 1. Redistributions of source code must retain the above copyright7* notice, this list of conditions and the following disclaimer.8* 2. Redistributions in binary form must reproduce the above copyright9* notice, this list of conditions and the following disclaimer in the10* documentation and/or other materials provided with the distribution.11* 3. The name of David Young may not be used to endorse or promote12* products derived from this software without specific prior13* written permission.14*15* THIS SOFTWARE IS PROVIDED BY DAVID YOUNG ``AS IS'' AND ANY16* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,17* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A18* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DAVID19* YOUNG BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,20* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED21* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,22* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,24* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY25* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY26* OF SUCH DAMAGE.27*/2829/*30* Modifications to fit into the linux IEEE 802.11 stack,31* Mike Kershaw ([email protected])32*/3334#ifndef IEEE80211RADIOTAP_H35#define IEEE80211RADIOTAP_H3637#include <linux/if_ether.h>38#include <linux/kernel.h>39#include <asm/unaligned.h>4041/* Base version of the radiotap packet header data */42#define PKTHDR_RADIOTAP_VERSION 04344/* A generic radio capture format is desirable. There is one for45* Linux, but it is neither rigidly defined (there were not even46* units given for some fields) nor easily extensible.47*48* I suggest the following extensible radio capture format. It is49* based on a bitmap indicating which fields are present.50*51* I am trying to describe precisely what the application programmer52* should expect in the following, and for that reason I tell the53* units and origin of each measurement (where it applies), or else I54* use sufficiently weaselly language ("is a monotonically nondecreasing55* function of...") that I cannot set false expectations for lawyerly56* readers.57*/5859/*60* The radio capture header precedes the 802.11 header.61* All data in the header is little endian on all platforms.62*/63struct ieee80211_radiotap_header {64u8 it_version; /* Version 0. Only increases65* for drastic changes,66* introduction of compatible67* new fields does not count.68*/69u8 it_pad;70__le16 it_len; /* length of the whole71* header in bytes, including72* it_version, it_pad,73* it_len, and data fields.74*/75__le32 it_present; /* A bitmap telling which76* fields are present. Set bit 3177* (0x80000000) to extend the78* bitmap by another 32 bits.79* Additional extensions are made80* by setting bit 31.81*/82} __packed;8384/* Name Data type Units85* ---- --------- -----86*87* IEEE80211_RADIOTAP_TSFT __le64 microseconds88*89* Value in microseconds of the MAC's 64-bit 802.11 Time90* Synchronization Function timer when the first bit of the91* MPDU arrived at the MAC. For received frames, only.92*93* IEEE80211_RADIOTAP_CHANNEL 2 x __le16 MHz, bitmap94*95* Tx/Rx frequency in MHz, followed by flags (see below).96*97* IEEE80211_RADIOTAP_FHSS __le16 see below98*99* For frequency-hopping radios, the hop set (first byte)100* and pattern (second byte).101*102* IEEE80211_RADIOTAP_RATE u8 500kb/s103*104* Tx/Rx data rate105*106* IEEE80211_RADIOTAP_DBM_ANTSIGNAL s8 decibels from107* one milliwatt (dBm)108*109* RF signal power at the antenna, decibel difference from110* one milliwatt.111*112* IEEE80211_RADIOTAP_DBM_ANTNOISE s8 decibels from113* one milliwatt (dBm)114*115* RF noise power at the antenna, decibel difference from one116* milliwatt.117*118* IEEE80211_RADIOTAP_DB_ANTSIGNAL u8 decibel (dB)119*120* RF signal power at the antenna, decibel difference from an121* arbitrary, fixed reference.122*123* IEEE80211_RADIOTAP_DB_ANTNOISE u8 decibel (dB)124*125* RF noise power at the antenna, decibel difference from an126* arbitrary, fixed reference point.127*128* IEEE80211_RADIOTAP_LOCK_QUALITY __le16 unitless129*130* Quality of Barker code lock. Unitless. Monotonically131* nondecreasing with "better" lock strength. Called "Signal132* Quality" in datasheets. (Is there a standard way to measure133* this?)134*135* IEEE80211_RADIOTAP_TX_ATTENUATION __le16 unitless136*137* Transmit power expressed as unitless distance from max138* power set at factory calibration. 0 is max power.139* Monotonically nondecreasing with lower power levels.140*141* IEEE80211_RADIOTAP_DB_TX_ATTENUATION __le16 decibels (dB)142*143* Transmit power expressed as decibel distance from max power144* set at factory calibration. 0 is max power. Monotonically145* nondecreasing with lower power levels.146*147* IEEE80211_RADIOTAP_DBM_TX_POWER s8 decibels from148* one milliwatt (dBm)149*150* Transmit power expressed as dBm (decibels from a 1 milliwatt151* reference). This is the absolute power level measured at152* the antenna port.153*154* IEEE80211_RADIOTAP_FLAGS u8 bitmap155*156* Properties of transmitted and received frames. See flags157* defined below.158*159* IEEE80211_RADIOTAP_ANTENNA u8 antenna index160*161* Unitless indication of the Rx/Tx antenna for this packet.162* The first antenna is antenna 0.163*164* IEEE80211_RADIOTAP_RX_FLAGS __le16 bitmap165*166* Properties of received frames. See flags defined below.167*168* IEEE80211_RADIOTAP_TX_FLAGS __le16 bitmap169*170* Properties of transmitted frames. See flags defined below.171*172* IEEE80211_RADIOTAP_RTS_RETRIES u8 data173*174* Number of rts retries a transmitted frame used.175*176* IEEE80211_RADIOTAP_DATA_RETRIES u8 data177*178* Number of unicast retries a transmitted frame used.179*180* IEEE80211_RADIOTAP_MCS u8, u8, u8 unitless181*182* Contains a bitmap of known fields/flags, the flags, and183* the MCS index.184*185*/186enum ieee80211_radiotap_type {187IEEE80211_RADIOTAP_TSFT = 0,188IEEE80211_RADIOTAP_FLAGS = 1,189IEEE80211_RADIOTAP_RATE = 2,190IEEE80211_RADIOTAP_CHANNEL = 3,191IEEE80211_RADIOTAP_FHSS = 4,192IEEE80211_RADIOTAP_DBM_ANTSIGNAL = 5,193IEEE80211_RADIOTAP_DBM_ANTNOISE = 6,194IEEE80211_RADIOTAP_LOCK_QUALITY = 7,195IEEE80211_RADIOTAP_TX_ATTENUATION = 8,196IEEE80211_RADIOTAP_DB_TX_ATTENUATION = 9,197IEEE80211_RADIOTAP_DBM_TX_POWER = 10,198IEEE80211_RADIOTAP_ANTENNA = 11,199IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12,200IEEE80211_RADIOTAP_DB_ANTNOISE = 13,201IEEE80211_RADIOTAP_RX_FLAGS = 14,202IEEE80211_RADIOTAP_TX_FLAGS = 15,203IEEE80211_RADIOTAP_RTS_RETRIES = 16,204IEEE80211_RADIOTAP_DATA_RETRIES = 17,205206IEEE80211_RADIOTAP_MCS = 19,207208/* valid in every it_present bitmap, even vendor namespaces */209IEEE80211_RADIOTAP_RADIOTAP_NAMESPACE = 29,210IEEE80211_RADIOTAP_VENDOR_NAMESPACE = 30,211IEEE80211_RADIOTAP_EXT = 31212};213214/* Channel flags. */215#define IEEE80211_CHAN_TURBO 0x0010 /* Turbo channel */216#define IEEE80211_CHAN_CCK 0x0020 /* CCK channel */217#define IEEE80211_CHAN_OFDM 0x0040 /* OFDM channel */218#define IEEE80211_CHAN_2GHZ 0x0080 /* 2 GHz spectrum channel. */219#define IEEE80211_CHAN_5GHZ 0x0100 /* 5 GHz spectrum channel */220#define IEEE80211_CHAN_PASSIVE 0x0200 /* Only passive scan allowed */221#define IEEE80211_CHAN_DYN 0x0400 /* Dynamic CCK-OFDM channel */222#define IEEE80211_CHAN_GFSK 0x0800 /* GFSK channel (FHSS PHY) */223224/* For IEEE80211_RADIOTAP_FLAGS */225#define IEEE80211_RADIOTAP_F_CFP 0x01 /* sent/received226* during CFP227*/228#define IEEE80211_RADIOTAP_F_SHORTPRE 0x02 /* sent/received229* with short230* preamble231*/232#define IEEE80211_RADIOTAP_F_WEP 0x04 /* sent/received233* with WEP encryption234*/235#define IEEE80211_RADIOTAP_F_FRAG 0x08 /* sent/received236* with fragmentation237*/238#define IEEE80211_RADIOTAP_F_FCS 0x10 /* frame includes FCS */239#define IEEE80211_RADIOTAP_F_DATAPAD 0x20 /* frame has padding between240* 802.11 header and payload241* (to 32-bit boundary)242*/243#define IEEE80211_RADIOTAP_F_BADFCS 0x40 /* bad FCS */244245/* For IEEE80211_RADIOTAP_RX_FLAGS */246#define IEEE80211_RADIOTAP_F_RX_BADPLCP 0x0002 /* frame has bad PLCP */247248/* For IEEE80211_RADIOTAP_TX_FLAGS */249#define IEEE80211_RADIOTAP_F_TX_FAIL 0x0001 /* failed due to excessive250* retries */251#define IEEE80211_RADIOTAP_F_TX_CTS 0x0002 /* used cts 'protection' */252#define IEEE80211_RADIOTAP_F_TX_RTS 0x0004 /* used rts/cts handshake */253254255/* For IEEE80211_RADIOTAP_MCS */256#define IEEE80211_RADIOTAP_MCS_HAVE_BW 0x01257#define IEEE80211_RADIOTAP_MCS_HAVE_MCS 0x02258#define IEEE80211_RADIOTAP_MCS_HAVE_GI 0x04259#define IEEE80211_RADIOTAP_MCS_HAVE_FMT 0x08260#define IEEE80211_RADIOTAP_MCS_HAVE_FEC 0x10261262#define IEEE80211_RADIOTAP_MCS_BW_MASK 0x03263#define IEEE80211_RADIOTAP_MCS_BW_20 0264#define IEEE80211_RADIOTAP_MCS_BW_40 1265#define IEEE80211_RADIOTAP_MCS_BW_20L 2266#define IEEE80211_RADIOTAP_MCS_BW_20U 3267#define IEEE80211_RADIOTAP_MCS_SGI 0x04268#define IEEE80211_RADIOTAP_MCS_FMT_GF 0x08269#define IEEE80211_RADIOTAP_MCS_FEC_LDPC 0x10270271272/* Ugly macro to convert literal channel numbers into their mhz equivalents273* There are certianly some conditions that will break this (like feeding it '30')274* but they shouldn't arise since nothing talks on channel 30. */275#define ieee80211chan2mhz(x) \276(((x) <= 14) ? \277(((x) == 14) ? 2484 : ((x) * 5) + 2407) : \278((x) + 1000) * 5)279280/* helpers */281static inline int ieee80211_get_radiotap_len(unsigned char *data)282{283struct ieee80211_radiotap_header *hdr =284(struct ieee80211_radiotap_header *)data;285286return get_unaligned_le16(&hdr->it_len);287}288289#endif /* IEEE80211_RADIOTAP_H */290291292