radiotap.h revision 252726
1252726Srpaulo/* $FreeBSD: head/contrib/wpa/src/utils/radiotap.h 214734 2010-11-03 10:43:38Z rpaulo $ */ 2214501Srpaulo/* $NetBSD: ieee80211_radiotap.h,v 1.11 2005/06/22 06:16:02 dyoung Exp $ */ 3214501Srpaulo 4214501Srpaulo/*- 5214501Srpaulo * Copyright (c) 2003, 2004 David Young. All rights reserved. 6214501Srpaulo * 7214501Srpaulo * Redistribution and use in source and binary forms, with or without 8214501Srpaulo * modification, are permitted provided that the following conditions 9214501Srpaulo * are met: 10214501Srpaulo * 1. Redistributions of source code must retain the above copyright 11214501Srpaulo * notice, this list of conditions and the following disclaimer. 12214501Srpaulo * 2. Redistributions in binary form must reproduce the above copyright 13214501Srpaulo * notice, this list of conditions and the following disclaimer in the 14214501Srpaulo * documentation and/or other materials provided with the distribution. 15214501Srpaulo * 3. The name of David Young may not be used to endorse or promote 16214501Srpaulo * products derived from this software without specific prior 17214501Srpaulo * written permission. 18214501Srpaulo * 19214501Srpaulo * THIS SOFTWARE IS PROVIDED BY DAVID YOUNG ``AS IS'' AND ANY 20214501Srpaulo * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21214501Srpaulo * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22214501Srpaulo * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DAVID 23214501Srpaulo * YOUNG BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 24214501Srpaulo * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 25214501Srpaulo * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26214501Srpaulo * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27214501Srpaulo * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28214501Srpaulo * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29214501Srpaulo * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 30214501Srpaulo * OF SUCH DAMAGE. 31214501Srpaulo */ 32214501Srpaulo 33214501Srpaulo/* 34214501Srpaulo * Modifications to fit into the linux IEEE 802.11 stack, 35214501Srpaulo * Mike Kershaw (dragorn@kismetwireless.net) 36214501Srpaulo */ 37214501Srpaulo 38214501Srpaulo#ifndef IEEE80211RADIOTAP_H 39214501Srpaulo#define IEEE80211RADIOTAP_H 40214501Srpaulo 41214501Srpaulo#include <stdint.h> 42214501Srpaulo 43214501Srpaulo/* Base version of the radiotap packet header data */ 44214501Srpaulo#define PKTHDR_RADIOTAP_VERSION 0 45214501Srpaulo 46214501Srpaulo/* A generic radio capture format is desirable. There is one for 47214501Srpaulo * Linux, but it is neither rigidly defined (there were not even 48214501Srpaulo * units given for some fields) nor easily extensible. 49214501Srpaulo * 50214501Srpaulo * I suggest the following extensible radio capture format. It is 51214501Srpaulo * based on a bitmap indicating which fields are present. 52214501Srpaulo * 53214501Srpaulo * I am trying to describe precisely what the application programmer 54214501Srpaulo * should expect in the following, and for that reason I tell the 55214501Srpaulo * units and origin of each measurement (where it applies), or else I 56214501Srpaulo * use sufficiently weaselly language ("is a monotonically nondecreasing 57214501Srpaulo * function of...") that I cannot set false expectations for lawyerly 58214501Srpaulo * readers. 59214501Srpaulo */ 60214501Srpaulo 61214501Srpaulo/* The radio capture header precedes the 802.11 header. 62214501Srpaulo * All data in the header is little endian on all platforms. 63214501Srpaulo */ 64214501Srpaulostruct ieee80211_radiotap_header { 65214501Srpaulo uint8_t it_version; /* Version 0. Only increases 66214501Srpaulo * for drastic changes, 67214501Srpaulo * introduction of compatible 68214501Srpaulo * new fields does not count. 69214501Srpaulo */ 70214501Srpaulo uint8_t it_pad; 71214501Srpaulo uint16_t it_len; /* length of the whole 72214501Srpaulo * header in bytes, including 73214501Srpaulo * it_version, it_pad, 74214501Srpaulo * it_len, and data fields. 75214501Srpaulo */ 76214501Srpaulo uint32_t it_present; /* A bitmap telling which 77214501Srpaulo * fields are present. Set bit 31 78214501Srpaulo * (0x80000000) to extend the 79214501Srpaulo * bitmap by another 32 bits. 80214501Srpaulo * Additional extensions are made 81214501Srpaulo * by setting bit 31. 82214501Srpaulo */ 83214501Srpaulo}; 84214501Srpaulo 85214501Srpaulo/* Name Data type Units 86214501Srpaulo * ---- --------- ----- 87214501Srpaulo * 88214501Srpaulo * IEEE80211_RADIOTAP_TSFT __le64 microseconds 89214501Srpaulo * 90214501Srpaulo * Value in microseconds of the MAC's 64-bit 802.11 Time 91214501Srpaulo * Synchronization Function timer when the first bit of the 92214501Srpaulo * MPDU arrived at the MAC. For received frames, only. 93214501Srpaulo * 94214501Srpaulo * IEEE80211_RADIOTAP_CHANNEL 2 x uint16_t MHz, bitmap 95214501Srpaulo * 96214501Srpaulo * Tx/Rx frequency in MHz, followed by flags (see below). 97214501Srpaulo * 98214501Srpaulo * IEEE80211_RADIOTAP_FHSS uint16_t see below 99214501Srpaulo * 100214501Srpaulo * For frequency-hopping radios, the hop set (first byte) 101214501Srpaulo * and pattern (second byte). 102214501Srpaulo * 103214501Srpaulo * IEEE80211_RADIOTAP_RATE u8 500kb/s 104214501Srpaulo * 105214501Srpaulo * Tx/Rx data rate 106214501Srpaulo * 107214501Srpaulo * IEEE80211_RADIOTAP_DBM_ANTSIGNAL s8 decibels from 108214501Srpaulo * one milliwatt (dBm) 109214501Srpaulo * 110214501Srpaulo * RF signal power at the antenna, decibel difference from 111214501Srpaulo * one milliwatt. 112214501Srpaulo * 113214501Srpaulo * IEEE80211_RADIOTAP_DBM_ANTNOISE s8 decibels from 114214501Srpaulo * one milliwatt (dBm) 115214501Srpaulo * 116214501Srpaulo * RF noise power at the antenna, decibel difference from one 117214501Srpaulo * milliwatt. 118214501Srpaulo * 119214501Srpaulo * IEEE80211_RADIOTAP_DB_ANTSIGNAL u8 decibel (dB) 120214501Srpaulo * 121214501Srpaulo * RF signal power at the antenna, decibel difference from an 122214501Srpaulo * arbitrary, fixed reference. 123214501Srpaulo * 124214501Srpaulo * IEEE80211_RADIOTAP_DB_ANTNOISE u8 decibel (dB) 125214501Srpaulo * 126214501Srpaulo * RF noise power at the antenna, decibel difference from an 127214501Srpaulo * arbitrary, fixed reference point. 128214501Srpaulo * 129214501Srpaulo * IEEE80211_RADIOTAP_LOCK_QUALITY uint16_t unitless 130214501Srpaulo * 131214501Srpaulo * Quality of Barker code lock. Unitless. Monotonically 132214501Srpaulo * nondecreasing with "better" lock strength. Called "Signal 133214501Srpaulo * Quality" in datasheets. (Is there a standard way to measure 134214501Srpaulo * this?) 135214501Srpaulo * 136214501Srpaulo * IEEE80211_RADIOTAP_TX_ATTENUATION uint16_t unitless 137214501Srpaulo * 138214501Srpaulo * Transmit power expressed as unitless distance from max 139214501Srpaulo * power set at factory calibration. 0 is max power. 140214501Srpaulo * Monotonically nondecreasing with lower power levels. 141214501Srpaulo * 142214501Srpaulo * IEEE80211_RADIOTAP_DB_TX_ATTENUATION uint16_t decibels (dB) 143214501Srpaulo * 144214501Srpaulo * Transmit power expressed as decibel distance from max power 145214501Srpaulo * set at factory calibration. 0 is max power. Monotonically 146214501Srpaulo * nondecreasing with lower power levels. 147214501Srpaulo * 148214501Srpaulo * IEEE80211_RADIOTAP_DBM_TX_POWER s8 decibels from 149214501Srpaulo * one milliwatt (dBm) 150214501Srpaulo * 151214501Srpaulo * Transmit power expressed as dBm (decibels from a 1 milliwatt 152214501Srpaulo * reference). This is the absolute power level measured at 153214501Srpaulo * the antenna port. 154214501Srpaulo * 155214501Srpaulo * IEEE80211_RADIOTAP_FLAGS u8 bitmap 156214501Srpaulo * 157214501Srpaulo * Properties of transmitted and received frames. See flags 158214501Srpaulo * defined below. 159214501Srpaulo * 160214501Srpaulo * IEEE80211_RADIOTAP_ANTENNA u8 antenna index 161214501Srpaulo * 162214501Srpaulo * Unitless indication of the Rx/Tx antenna for this packet. 163214501Srpaulo * The first antenna is antenna 0. 164214501Srpaulo * 165214501Srpaulo * IEEE80211_RADIOTAP_RX_FLAGS uint16_t bitmap 166214501Srpaulo * 167214501Srpaulo * Properties of received frames. See flags defined below. 168214501Srpaulo * 169214501Srpaulo * IEEE80211_RADIOTAP_TX_FLAGS uint16_t bitmap 170214501Srpaulo * 171214501Srpaulo * Properties of transmitted frames. See flags defined below. 172214501Srpaulo * 173214501Srpaulo * IEEE80211_RADIOTAP_RTS_RETRIES u8 data 174214501Srpaulo * 175214501Srpaulo * Number of rts retries a transmitted frame used. 176214501Srpaulo * 177214501Srpaulo * IEEE80211_RADIOTAP_DATA_RETRIES u8 data 178214501Srpaulo * 179214501Srpaulo * Number of unicast retries a transmitted frame used. 180214501Srpaulo * 181214501Srpaulo */ 182214501Srpauloenum ieee80211_radiotap_type { 183214501Srpaulo IEEE80211_RADIOTAP_TSFT = 0, 184214501Srpaulo IEEE80211_RADIOTAP_FLAGS = 1, 185214501Srpaulo IEEE80211_RADIOTAP_RATE = 2, 186214501Srpaulo IEEE80211_RADIOTAP_CHANNEL = 3, 187214501Srpaulo IEEE80211_RADIOTAP_FHSS = 4, 188214501Srpaulo IEEE80211_RADIOTAP_DBM_ANTSIGNAL = 5, 189214501Srpaulo IEEE80211_RADIOTAP_DBM_ANTNOISE = 6, 190214501Srpaulo IEEE80211_RADIOTAP_LOCK_QUALITY = 7, 191214501Srpaulo IEEE80211_RADIOTAP_TX_ATTENUATION = 8, 192214501Srpaulo IEEE80211_RADIOTAP_DB_TX_ATTENUATION = 9, 193214501Srpaulo IEEE80211_RADIOTAP_DBM_TX_POWER = 10, 194214501Srpaulo IEEE80211_RADIOTAP_ANTENNA = 11, 195214501Srpaulo IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12, 196214501Srpaulo IEEE80211_RADIOTAP_DB_ANTNOISE = 13, 197214501Srpaulo IEEE80211_RADIOTAP_RX_FLAGS = 14, 198214501Srpaulo IEEE80211_RADIOTAP_TX_FLAGS = 15, 199214501Srpaulo IEEE80211_RADIOTAP_RTS_RETRIES = 16, 200214501Srpaulo IEEE80211_RADIOTAP_DATA_RETRIES = 17, 201214501Srpaulo IEEE80211_RADIOTAP_EXT = 31 202214501Srpaulo}; 203214501Srpaulo 204214501Srpaulo/* Channel flags. */ 205214501Srpaulo#define IEEE80211_CHAN_TURBO 0x0010 /* Turbo channel */ 206214501Srpaulo#define IEEE80211_CHAN_CCK 0x0020 /* CCK channel */ 207214501Srpaulo#define IEEE80211_CHAN_OFDM 0x0040 /* OFDM channel */ 208214501Srpaulo#define IEEE80211_CHAN_2GHZ 0x0080 /* 2 GHz spectrum channel. */ 209214501Srpaulo#define IEEE80211_CHAN_5GHZ 0x0100 /* 5 GHz spectrum channel */ 210214501Srpaulo#define IEEE80211_CHAN_PASSIVE 0x0200 /* Only passive scan allowed */ 211214501Srpaulo#define IEEE80211_CHAN_DYN 0x0400 /* Dynamic CCK-OFDM channel */ 212214501Srpaulo#define IEEE80211_CHAN_GFSK 0x0800 /* GFSK channel (FHSS PHY) */ 213214501Srpaulo 214214501Srpaulo/* For IEEE80211_RADIOTAP_FLAGS */ 215214501Srpaulo#define IEEE80211_RADIOTAP_F_CFP 0x01 /* sent/received 216214501Srpaulo * during CFP 217214501Srpaulo */ 218214501Srpaulo#define IEEE80211_RADIOTAP_F_SHORTPRE 0x02 /* sent/received 219214501Srpaulo * with short 220214501Srpaulo * preamble 221214501Srpaulo */ 222214501Srpaulo#define IEEE80211_RADIOTAP_F_WEP 0x04 /* sent/received 223214501Srpaulo * with WEP encryption 224214501Srpaulo */ 225214501Srpaulo#define IEEE80211_RADIOTAP_F_FRAG 0x08 /* sent/received 226214501Srpaulo * with fragmentation 227214501Srpaulo */ 228214501Srpaulo#define IEEE80211_RADIOTAP_F_FCS 0x10 /* frame includes FCS */ 229214501Srpaulo#define IEEE80211_RADIOTAP_F_DATAPAD 0x20 /* frame has padding between 230214501Srpaulo * 802.11 header and payload 231214501Srpaulo * (to 32-bit boundary) 232214501Srpaulo */ 233214501Srpaulo/* For IEEE80211_RADIOTAP_RX_FLAGS */ 234214501Srpaulo#define IEEE80211_RADIOTAP_F_RX_BADFCS 0x0001 /* frame failed crc check */ 235214501Srpaulo 236214501Srpaulo/* For IEEE80211_RADIOTAP_TX_FLAGS */ 237214501Srpaulo#define IEEE80211_RADIOTAP_F_TX_FAIL 0x0001 /* failed due to excessive 238214501Srpaulo * retries */ 239214501Srpaulo#define IEEE80211_RADIOTAP_F_TX_CTS 0x0002 /* used cts 'protection' */ 240214501Srpaulo#define IEEE80211_RADIOTAP_F_TX_RTS 0x0004 /* used rts/cts handshake */ 241252726Srpaulo#define IEEE80211_RADIOTAP_F_TX_NOACK 0x0008 /* don't expect an ACK */ 242214501Srpaulo 243214501Srpaulo#endif /* IEEE80211_RADIOTAP_H */ 244