13905ec45SJames Ketrenos /* $FreeBSD: src/sys/net80211/ieee80211_radiotap.h,v 1.5 2005/01/22 20:12:05 sam Exp $ */ 23905ec45SJames Ketrenos /* $NetBSD: ieee80211_radiotap.h,v 1.11 2005/06/22 06:16:02 dyoung Exp $ */ 33905ec45SJames Ketrenos 43905ec45SJames Ketrenos /*- 53905ec45SJames Ketrenos * Copyright (c) 2003, 2004 David Young. All rights reserved. 63905ec45SJames Ketrenos * 73905ec45SJames Ketrenos * Redistribution and use in source and binary forms, with or without 83905ec45SJames Ketrenos * modification, are permitted provided that the following conditions 93905ec45SJames Ketrenos * are met: 103905ec45SJames Ketrenos * 1. Redistributions of source code must retain the above copyright 113905ec45SJames Ketrenos * notice, this list of conditions and the following disclaimer. 123905ec45SJames Ketrenos * 2. Redistributions in binary form must reproduce the above copyright 133905ec45SJames Ketrenos * notice, this list of conditions and the following disclaimer in the 143905ec45SJames Ketrenos * documentation and/or other materials provided with the distribution. 153905ec45SJames Ketrenos * 3. The name of David Young may not be used to endorse or promote 163905ec45SJames Ketrenos * products derived from this software without specific prior 173905ec45SJames Ketrenos * written permission. 183905ec45SJames Ketrenos * 193905ec45SJames Ketrenos * THIS SOFTWARE IS PROVIDED BY DAVID YOUNG ``AS IS'' AND ANY 203905ec45SJames Ketrenos * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 213905ec45SJames Ketrenos * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 223905ec45SJames Ketrenos * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DAVID 233905ec45SJames Ketrenos * YOUNG BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 243905ec45SJames Ketrenos * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 253905ec45SJames Ketrenos * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 263905ec45SJames Ketrenos * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 273905ec45SJames Ketrenos * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 283905ec45SJames Ketrenos * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 293905ec45SJames Ketrenos * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 303905ec45SJames Ketrenos * OF SUCH DAMAGE. 313905ec45SJames Ketrenos */ 323905ec45SJames Ketrenos 333905ec45SJames Ketrenos /* 343905ec45SJames Ketrenos * Modifications to fit into the linux IEEE 802.11 stack, 353905ec45SJames Ketrenos * Mike Kershaw (dragorn@kismetwireless.net) 363905ec45SJames Ketrenos */ 373905ec45SJames Ketrenos 383905ec45SJames Ketrenos #ifndef IEEE80211RADIOTAP_H 393905ec45SJames Ketrenos #define IEEE80211RADIOTAP_H 403905ec45SJames Ketrenos 413905ec45SJames Ketrenos #include <linux/if_ether.h> 423905ec45SJames Ketrenos #include <linux/kernel.h> 433905ec45SJames Ketrenos 443905ec45SJames Ketrenos /* Radiotap header version (from official NetBSD feed) */ 453905ec45SJames Ketrenos #define IEEE80211RADIOTAP_VERSION "1.5" 463905ec45SJames Ketrenos /* Base version of the radiotap packet header data */ 473905ec45SJames Ketrenos #define PKTHDR_RADIOTAP_VERSION 0 483905ec45SJames Ketrenos 493905ec45SJames Ketrenos /* A generic radio capture format is desirable. There is one for 503905ec45SJames Ketrenos * Linux, but it is neither rigidly defined (there were not even 513905ec45SJames Ketrenos * units given for some fields) nor easily extensible. 523905ec45SJames Ketrenos * 533905ec45SJames Ketrenos * I suggest the following extensible radio capture format. It is 543905ec45SJames Ketrenos * based on a bitmap indicating which fields are present. 553905ec45SJames Ketrenos * 563905ec45SJames Ketrenos * I am trying to describe precisely what the application programmer 573905ec45SJames Ketrenos * should expect in the following, and for that reason I tell the 583905ec45SJames Ketrenos * units and origin of each measurement (where it applies), or else I 593905ec45SJames Ketrenos * use sufficiently weaselly language ("is a monotonically nondecreasing 603905ec45SJames Ketrenos * function of...") that I cannot set false expectations for lawyerly 613905ec45SJames Ketrenos * readers. 623905ec45SJames Ketrenos */ 633905ec45SJames Ketrenos 643905ec45SJames Ketrenos /* XXX tcpdump/libpcap do not tolerate variable-length headers, 653905ec45SJames Ketrenos * yet, so we pad every radiotap header to 64 bytes. Ugh. 663905ec45SJames Ketrenos */ 673905ec45SJames Ketrenos #define IEEE80211_RADIOTAP_HDRLEN 64 683905ec45SJames Ketrenos 693905ec45SJames Ketrenos /* The radio capture header precedes the 802.11 header. */ 703905ec45SJames Ketrenos struct ieee80211_radiotap_header { 713905ec45SJames Ketrenos u8 it_version; /* Version 0. Only increases 723905ec45SJames Ketrenos * for drastic changes, 733905ec45SJames Ketrenos * introduction of compatible 743905ec45SJames Ketrenos * new fields does not count. 753905ec45SJames Ketrenos */ 763905ec45SJames Ketrenos u8 it_pad; 773905ec45SJames Ketrenos u16 it_len; /* length of the whole 783905ec45SJames Ketrenos * header in bytes, including 793905ec45SJames Ketrenos * it_version, it_pad, 803905ec45SJames Ketrenos * it_len, and data fields. 813905ec45SJames Ketrenos */ 823905ec45SJames Ketrenos u32 it_present; /* A bitmap telling which 833905ec45SJames Ketrenos * fields are present. Set bit 31 843905ec45SJames Ketrenos * (0x80000000) to extend the 853905ec45SJames Ketrenos * bitmap by another 32 bits. 863905ec45SJames Ketrenos * Additional extensions are made 873905ec45SJames Ketrenos * by setting bit 31. 883905ec45SJames Ketrenos */ 893905ec45SJames Ketrenos }; 903905ec45SJames Ketrenos 913905ec45SJames Ketrenos /* Name Data type Units 923905ec45SJames Ketrenos * ---- --------- ----- 933905ec45SJames Ketrenos * 943905ec45SJames Ketrenos * IEEE80211_RADIOTAP_TSFT u64 microseconds 953905ec45SJames Ketrenos * 963905ec45SJames Ketrenos * Value in microseconds of the MAC's 64-bit 802.11 Time 973905ec45SJames Ketrenos * Synchronization Function timer when the first bit of the 983905ec45SJames Ketrenos * MPDU arrived at the MAC. For received frames, only. 993905ec45SJames Ketrenos * 1003905ec45SJames Ketrenos * IEEE80211_RADIOTAP_CHANNEL 2 x u16 MHz, bitmap 1013905ec45SJames Ketrenos * 1023905ec45SJames Ketrenos * Tx/Rx frequency in MHz, followed by flags (see below). 1033905ec45SJames Ketrenos * 1043905ec45SJames Ketrenos * IEEE80211_RADIOTAP_FHSS u16 see below 1053905ec45SJames Ketrenos * 1063905ec45SJames Ketrenos * For frequency-hopping radios, the hop set (first byte) 1073905ec45SJames Ketrenos * and pattern (second byte). 1083905ec45SJames Ketrenos * 1093905ec45SJames Ketrenos * IEEE80211_RADIOTAP_RATE u8 500kb/s 1103905ec45SJames Ketrenos * 1113905ec45SJames Ketrenos * Tx/Rx data rate 1123905ec45SJames Ketrenos * 1133905ec45SJames Ketrenos * IEEE80211_RADIOTAP_DBM_ANTSIGNAL int8_t decibels from 1143905ec45SJames Ketrenos * one milliwatt (dBm) 1153905ec45SJames Ketrenos * 1163905ec45SJames Ketrenos * RF signal power at the antenna, decibel difference from 1173905ec45SJames Ketrenos * one milliwatt. 1183905ec45SJames Ketrenos * 1193905ec45SJames Ketrenos * IEEE80211_RADIOTAP_DBM_ANTNOISE int8_t decibels from 1203905ec45SJames Ketrenos * one milliwatt (dBm) 1213905ec45SJames Ketrenos * 1223905ec45SJames Ketrenos * RF noise power at the antenna, decibel difference from one 1233905ec45SJames Ketrenos * milliwatt. 1243905ec45SJames Ketrenos * 1253905ec45SJames Ketrenos * IEEE80211_RADIOTAP_DB_ANTSIGNAL u8 decibel (dB) 1263905ec45SJames Ketrenos * 1273905ec45SJames Ketrenos * RF signal power at the antenna, decibel difference from an 1283905ec45SJames Ketrenos * arbitrary, fixed reference. 1293905ec45SJames Ketrenos * 1303905ec45SJames Ketrenos * IEEE80211_RADIOTAP_DB_ANTNOISE u8 decibel (dB) 1313905ec45SJames Ketrenos * 1323905ec45SJames Ketrenos * RF noise power at the antenna, decibel difference from an 1333905ec45SJames Ketrenos * arbitrary, fixed reference point. 1343905ec45SJames Ketrenos * 1353905ec45SJames Ketrenos * IEEE80211_RADIOTAP_LOCK_QUALITY u16 unitless 1363905ec45SJames Ketrenos * 1373905ec45SJames Ketrenos * Quality of Barker code lock. Unitless. Monotonically 1383905ec45SJames Ketrenos * nondecreasing with "better" lock strength. Called "Signal 1393905ec45SJames Ketrenos * Quality" in datasheets. (Is there a standard way to measure 1403905ec45SJames Ketrenos * this?) 1413905ec45SJames Ketrenos * 1423905ec45SJames Ketrenos * IEEE80211_RADIOTAP_TX_ATTENUATION u16 unitless 1433905ec45SJames Ketrenos * 1443905ec45SJames Ketrenos * Transmit power expressed as unitless distance from max 1453905ec45SJames Ketrenos * power set at factory calibration. 0 is max power. 1463905ec45SJames Ketrenos * Monotonically nondecreasing with lower power levels. 1473905ec45SJames Ketrenos * 1483905ec45SJames Ketrenos * IEEE80211_RADIOTAP_DB_TX_ATTENUATION u16 decibels (dB) 1493905ec45SJames Ketrenos * 1503905ec45SJames Ketrenos * Transmit power expressed as decibel distance from max power 1513905ec45SJames Ketrenos * set at factory calibration. 0 is max power. Monotonically 1523905ec45SJames Ketrenos * nondecreasing with lower power levels. 1533905ec45SJames Ketrenos * 1543905ec45SJames Ketrenos * IEEE80211_RADIOTAP_DBM_TX_POWER int8_t decibels from 1553905ec45SJames Ketrenos * one milliwatt (dBm) 1563905ec45SJames Ketrenos * 1573905ec45SJames Ketrenos * Transmit power expressed as dBm (decibels from a 1 milliwatt 1583905ec45SJames Ketrenos * reference). This is the absolute power level measured at 1593905ec45SJames Ketrenos * the antenna port. 1603905ec45SJames Ketrenos * 1613905ec45SJames Ketrenos * IEEE80211_RADIOTAP_FLAGS u8 bitmap 1623905ec45SJames Ketrenos * 1633905ec45SJames Ketrenos * Properties of transmitted and received frames. See flags 1643905ec45SJames Ketrenos * defined below. 1653905ec45SJames Ketrenos * 1663905ec45SJames Ketrenos * IEEE80211_RADIOTAP_ANTENNA u8 antenna index 1673905ec45SJames Ketrenos * 1683905ec45SJames Ketrenos * Unitless indication of the Rx/Tx antenna for this packet. 1693905ec45SJames Ketrenos * The first antenna is antenna 0. 1703905ec45SJames Ketrenos * 171*876c9d3aSMarcelo Tosatti * IEEE80211_RADIOTAP_RX_FLAGS u_int16_t bitmap 172*876c9d3aSMarcelo Tosatti * 173*876c9d3aSMarcelo Tosatti * Properties of received frames. See flags defined below. 174*876c9d3aSMarcelo Tosatti * 175*876c9d3aSMarcelo Tosatti * IEEE80211_RADIOTAP_TX_FLAGS u_int16_t bitmap 176*876c9d3aSMarcelo Tosatti * 177*876c9d3aSMarcelo Tosatti * Properties of transmitted frames. See flags defined below. 178*876c9d3aSMarcelo Tosatti * 179*876c9d3aSMarcelo Tosatti * IEEE80211_RADIOTAP_RTS_RETRIES u_int8_t data 180*876c9d3aSMarcelo Tosatti * 181*876c9d3aSMarcelo Tosatti * Number of rts retries a transmitted frame used. 182*876c9d3aSMarcelo Tosatti * 183*876c9d3aSMarcelo Tosatti * IEEE80211_RADIOTAP_DATA_RETRIES u_int8_t data 184*876c9d3aSMarcelo Tosatti * 185*876c9d3aSMarcelo Tosatti * Number of unicast retries a transmitted frame used. 186*876c9d3aSMarcelo Tosatti * 187*876c9d3aSMarcelo Tosatti * 1883905ec45SJames Ketrenos * IEEE80211_RADIOTAP_FCS u32 data 1893905ec45SJames Ketrenos * 1903905ec45SJames Ketrenos * FCS from frame in network byte order. 1913905ec45SJames Ketrenos */ 1923905ec45SJames Ketrenos enum ieee80211_radiotap_type { 1933905ec45SJames Ketrenos IEEE80211_RADIOTAP_TSFT = 0, 1943905ec45SJames Ketrenos IEEE80211_RADIOTAP_FLAGS = 1, 1953905ec45SJames Ketrenos IEEE80211_RADIOTAP_RATE = 2, 1963905ec45SJames Ketrenos IEEE80211_RADIOTAP_CHANNEL = 3, 1973905ec45SJames Ketrenos IEEE80211_RADIOTAP_FHSS = 4, 1983905ec45SJames Ketrenos IEEE80211_RADIOTAP_DBM_ANTSIGNAL = 5, 1993905ec45SJames Ketrenos IEEE80211_RADIOTAP_DBM_ANTNOISE = 6, 2003905ec45SJames Ketrenos IEEE80211_RADIOTAP_LOCK_QUALITY = 7, 2013905ec45SJames Ketrenos IEEE80211_RADIOTAP_TX_ATTENUATION = 8, 2023905ec45SJames Ketrenos IEEE80211_RADIOTAP_DB_TX_ATTENUATION = 9, 2033905ec45SJames Ketrenos IEEE80211_RADIOTAP_DBM_TX_POWER = 10, 2043905ec45SJames Ketrenos IEEE80211_RADIOTAP_ANTENNA = 11, 2053905ec45SJames Ketrenos IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12, 2063905ec45SJames Ketrenos IEEE80211_RADIOTAP_DB_ANTNOISE = 13, 207*876c9d3aSMarcelo Tosatti IEEE80211_RADIOTAP_RX_FLAGS = 14, 208*876c9d3aSMarcelo Tosatti IEEE80211_RADIOTAP_TX_FLAGS = 15, 209*876c9d3aSMarcelo Tosatti IEEE80211_RADIOTAP_RTS_RETRIES = 16, 210*876c9d3aSMarcelo Tosatti IEEE80211_RADIOTAP_DATA_RETRIES = 17, 211*876c9d3aSMarcelo Tosatti IEEE80211_RADIOTAP_EXT = 31 2123905ec45SJames Ketrenos }; 2133905ec45SJames Ketrenos 2143905ec45SJames Ketrenos /* Channel flags. */ 2153905ec45SJames Ketrenos #define IEEE80211_CHAN_TURBO 0x0010 /* Turbo channel */ 2163905ec45SJames Ketrenos #define IEEE80211_CHAN_CCK 0x0020 /* CCK channel */ 2173905ec45SJames Ketrenos #define IEEE80211_CHAN_OFDM 0x0040 /* OFDM channel */ 2183905ec45SJames Ketrenos #define IEEE80211_CHAN_2GHZ 0x0080 /* 2 GHz spectrum channel. */ 2193905ec45SJames Ketrenos #define IEEE80211_CHAN_5GHZ 0x0100 /* 5 GHz spectrum channel */ 2203905ec45SJames Ketrenos #define IEEE80211_CHAN_PASSIVE 0x0200 /* Only passive scan allowed */ 2213905ec45SJames Ketrenos #define IEEE80211_CHAN_DYN 0x0400 /* Dynamic CCK-OFDM channel */ 2223905ec45SJames Ketrenos #define IEEE80211_CHAN_GFSK 0x0800 /* GFSK channel (FHSS PHY) */ 2233905ec45SJames Ketrenos 2243905ec45SJames Ketrenos /* For IEEE80211_RADIOTAP_FLAGS */ 2253905ec45SJames Ketrenos #define IEEE80211_RADIOTAP_F_CFP 0x01 /* sent/received 2263905ec45SJames Ketrenos * during CFP 2273905ec45SJames Ketrenos */ 2283905ec45SJames Ketrenos #define IEEE80211_RADIOTAP_F_SHORTPRE 0x02 /* sent/received 2293905ec45SJames Ketrenos * with short 2303905ec45SJames Ketrenos * preamble 2313905ec45SJames Ketrenos */ 2323905ec45SJames Ketrenos #define IEEE80211_RADIOTAP_F_WEP 0x04 /* sent/received 2333905ec45SJames Ketrenos * with WEP encryption 2343905ec45SJames Ketrenos */ 2353905ec45SJames Ketrenos #define IEEE80211_RADIOTAP_F_FRAG 0x08 /* sent/received 2363905ec45SJames Ketrenos * with fragmentation 2373905ec45SJames Ketrenos */ 2383905ec45SJames Ketrenos #define IEEE80211_RADIOTAP_F_FCS 0x10 /* frame includes FCS */ 2393905ec45SJames Ketrenos #define IEEE80211_RADIOTAP_F_DATAPAD 0x20 /* frame has padding between 2403905ec45SJames Ketrenos * 802.11 header and payload 2413905ec45SJames Ketrenos * (to 32-bit boundary) 2423905ec45SJames Ketrenos */ 243*876c9d3aSMarcelo Tosatti /* For IEEE80211_RADIOTAP_RX_FLAGS */ 244*876c9d3aSMarcelo Tosatti #define IEEE80211_RADIOTAP_F_RX_BADFCS 0x0001 /* frame failed crc check */ 245*876c9d3aSMarcelo Tosatti 246*876c9d3aSMarcelo Tosatti /* For IEEE80211_RADIOTAP_TX_FLAGS */ 247*876c9d3aSMarcelo Tosatti #define IEEE80211_RADIOTAP_F_TX_FAIL 0x0001 /* failed due to excessive 248*876c9d3aSMarcelo Tosatti * retries */ 249*876c9d3aSMarcelo Tosatti #define IEEE80211_RADIOTAP_F_TX_CTS 0x0002 /* used cts 'protection' */ 250*876c9d3aSMarcelo Tosatti #define IEEE80211_RADIOTAP_F_TX_RTS 0x0004 /* used rts/cts handshake */ 2513905ec45SJames Ketrenos 2523905ec45SJames Ketrenos /* Ugly macro to convert literal channel numbers into their mhz equivalents 2533905ec45SJames Ketrenos * There are certianly some conditions that will break this (like feeding it '30') 2543905ec45SJames Ketrenos * but they shouldn't arise since nothing talks on channel 30. */ 2553905ec45SJames Ketrenos #define ieee80211chan2mhz(x) \ 2563905ec45SJames Ketrenos (((x) <= 14) ? \ 2573905ec45SJames Ketrenos (((x) == 14) ? 2484 : ((x) * 5) + 2407) : \ 2583905ec45SJames Ketrenos ((x) + 1000) * 5) 2593905ec45SJames Ketrenos 2603905ec45SJames Ketrenos #endif /* IEEE80211_RADIOTAP_H */ 261