197403Sobrien/* $FreeBSD$ */ 297403Sobrien/* NetBSD: ieee802_11_radio.h,v 1.2 2006/02/26 03:04:03 dyoung Exp */ 397403Sobrien/* $Header: /tcpdump/master/tcpdump/ieee802_11_radio.h,v 1.3 2007-08-29 02:31:44 mcr Exp $ */ 497403Sobrien 597403Sobrien/*- 697403Sobrien * Copyright (c) 2003, 2004 David Young. All rights reserved. 797403Sobrien * 897403Sobrien * Redistribution and use in source and binary forms, with or without 997403Sobrien * modification, are permitted provided that the following conditions 1097403Sobrien * are met: 1197403Sobrien * 1. Redistributions of source code must retain the above copyright 1297403Sobrien * notice, this list of conditions and the following disclaimer. 1397403Sobrien * 2. Redistributions in binary form must reproduce the above copyright 1497403Sobrien * notice, this list of conditions and the following disclaimer in the 1597403Sobrien * documentation and/or other materials provided with the distribution. 1697403Sobrien * 3. The name of David Young may not be used to endorse or promote 1797403Sobrien * products derived from this software without specific prior 1897403Sobrien * written permission. 1997403Sobrien * 2097403Sobrien * THIS SOFTWARE IS PROVIDED BY DAVID YOUNG ``AS IS'' AND ANY 2197403Sobrien * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 2297403Sobrien * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 2397403Sobrien * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DAVID 2497403Sobrien * YOUNG BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 2597403Sobrien * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 2697403Sobrien * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2797403Sobrien * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 2897403Sobrien * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 2997403Sobrien * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3097403Sobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 3197403Sobrien * OF SUCH DAMAGE. 3297403Sobrien */ 3397403Sobrien#ifndef _NET_IF_IEEE80211RADIOTAP_H_ 3497403Sobrien#define _NET_IF_IEEE80211RADIOTAP_H_ 3597403Sobrien 3697403Sobrien/* A generic radio capture format is desirable. It must be 3797403Sobrien * rigidly defined (e.g., units for fields should be given), 3897403Sobrien * and easily extensible. 3997403Sobrien * 4097403Sobrien * The following is an extensible radio capture format. It is 4197403Sobrien * based on a bitmap indicating which fields are present. 4297403Sobrien * 4397403Sobrien * I am trying to describe precisely what the application programmer 4497403Sobrien * should expect in the following, and for that reason I tell the 4597403Sobrien * units and origin of each measurement (where it applies), or else I 4697403Sobrien * use sufficiently weaselly language ("is a monotonically nondecreasing 4797403Sobrien * function of...") that I cannot set false expectations for lawyerly 4897403Sobrien * readers. 4997403Sobrien */ 5097403Sobrien 5197403Sobrien/* 5297403Sobrien * The radio capture header precedes the 802.11 header. 5397403Sobrien * 5497403Sobrien * Note well: all radiotap fields are little-endian. 5597403Sobrien */ 5697403Sobrienstruct ieee80211_radiotap_header { 5797403Sobrien u_int8_t it_version; /* Version 0. Only increases 5897403Sobrien * for drastic changes, 5997403Sobrien * introduction of compatible 6097403Sobrien * new fields does not count. 6197403Sobrien */ 6297403Sobrien u_int8_t it_pad; 6397403Sobrien u_int16_t it_len; /* length of the whole 6497403Sobrien * header in bytes, including 6597403Sobrien * it_version, it_pad, 6697403Sobrien * it_len, and data fields. 6797403Sobrien */ 6897403Sobrien u_int32_t it_present; /* A bitmap telling which 6997403Sobrien * fields are present. Set bit 31 7097403Sobrien * (0x80000000) to extend the 7197403Sobrien * bitmap by another 32 bits. 7297403Sobrien * Additional extensions are made 7397403Sobrien * by setting bit 31. 7497403Sobrien */ 7597403Sobrien}; 7697403Sobrien 7797403Sobrien/* Name Data type Units 7897403Sobrien * ---- --------- ----- 7997403Sobrien * 8097403Sobrien * IEEE80211_RADIOTAP_TSFT u_int64_t microseconds 8197403Sobrien * 8297403Sobrien * Value in microseconds of the MAC's 64-bit 802.11 Time 8397403Sobrien * Synchronization Function timer when the first bit of the 8497403Sobrien * MPDU arrived at the MAC. For received frames, only. 8597403Sobrien * 8697403Sobrien * IEEE80211_RADIOTAP_CHANNEL 2 x u_int16_t MHz, bitmap 8797403Sobrien * 8897403Sobrien * Tx/Rx frequency in MHz, followed by flags (see below). 8997403Sobrien * Note that IEEE80211_RADIOTAP_XCHANNEL must be used to 9097403Sobrien * represent an HT channel as there is not enough room in 9197403Sobrien * the flags word. 9297403Sobrien * 9397403Sobrien * IEEE80211_RADIOTAP_FHSS u_int16_t see below 9497403Sobrien * 9597403Sobrien * For frequency-hopping radios, the hop set (first byte) 9697403Sobrien * and pattern (second byte). 9797403Sobrien * 9897403Sobrien * IEEE80211_RADIOTAP_RATE u_int8_t 500kb/s or index 9997403Sobrien * 10097403Sobrien * Tx/Rx data rate. If bit 0x80 is set then it represents an 10197403Sobrien * an MCS index and not an IEEE rate. 10297403Sobrien * 10397403Sobrien * IEEE80211_RADIOTAP_DBM_ANTSIGNAL int8_t decibels from 10497403Sobrien * one milliwatt (dBm) 10597403Sobrien * 10697403Sobrien * RF signal power at the antenna, decibel difference from 10797403Sobrien * one milliwatt. 10897403Sobrien * 10997403Sobrien * IEEE80211_RADIOTAP_DBM_ANTNOISE int8_t decibels from 11097403Sobrien * one milliwatt (dBm) 11197403Sobrien * 11297403Sobrien * RF noise power at the antenna, decibel difference from one 11397403Sobrien * milliwatt. 11497403Sobrien * 11597403Sobrien * IEEE80211_RADIOTAP_DB_ANTSIGNAL u_int8_t decibel (dB) 11697403Sobrien * 11797403Sobrien * RF signal power at the antenna, decibel difference from an 11897403Sobrien * arbitrary, fixed reference. 11997403Sobrien * 12097403Sobrien * IEEE80211_RADIOTAP_DB_ANTNOISE u_int8_t decibel (dB) 12197403Sobrien * 12297403Sobrien * RF noise power at the antenna, decibel difference from an 12397403Sobrien * arbitrary, fixed reference point. 12497403Sobrien * 12597403Sobrien * IEEE80211_RADIOTAP_LOCK_QUALITY u_int16_t unitless 12697403Sobrien * 12797403Sobrien * Quality of Barker code lock. Unitless. Monotonically 12897403Sobrien * nondecreasing with "better" lock strength. Called "Signal 12997403Sobrien * Quality" in datasheets. (Is there a standard way to measure 13097403Sobrien * this?) 13197403Sobrien * 13297403Sobrien * IEEE80211_RADIOTAP_TX_ATTENUATION u_int16_t unitless 13397403Sobrien * 13497403Sobrien * Transmit power expressed as unitless distance from max 13597403Sobrien * power set at factory calibration. 0 is max power. 13697403Sobrien * Monotonically nondecreasing with lower power levels. 13797403Sobrien * 13897403Sobrien * IEEE80211_RADIOTAP_DB_TX_ATTENUATION u_int16_t decibels (dB) 13997403Sobrien * 14097403Sobrien * Transmit power expressed as decibel distance from max power 14197403Sobrien * set at factory calibration. 0 is max power. Monotonically 14297403Sobrien * nondecreasing with lower power levels. 14397403Sobrien * 14497403Sobrien * IEEE80211_RADIOTAP_DBM_TX_POWER int8_t decibels from 14597403Sobrien * one milliwatt (dBm) 14697403Sobrien * 14797403Sobrien * Transmit power expressed as dBm (decibels from a 1 milliwatt 14897403Sobrien * reference). This is the absolute power level measured at 14997403Sobrien * the antenna port. 15097403Sobrien * 15197403Sobrien * IEEE80211_RADIOTAP_FLAGS u_int8_t bitmap 15297403Sobrien * 15397403Sobrien * Properties of transmitted and received frames. See flags 15497403Sobrien * defined below. 15597403Sobrien * 15697403Sobrien * IEEE80211_RADIOTAP_ANTENNA u_int8_t antenna index 15797403Sobrien * 15897403Sobrien * Unitless indication of the Rx/Tx antenna for this packet. 15997403Sobrien * The first antenna is antenna 0. 16097403Sobrien * 16197403Sobrien * IEEE80211_RADIOTAP_RX_FLAGS u_int16_t bitmap 16297403Sobrien * 16397403Sobrien * Properties of received frames. See flags defined below. 16497403Sobrien * 16597403Sobrien * IEEE80211_RADIOTAP_XCHANNEL u_int32_t bitmap 16697403Sobrien * u_int16_t MHz 16797403Sobrien * u_int8_t channel number 16897403Sobrien * u_int8_t .5 dBm 16997403Sobrien * 17097403Sobrien * Extended channel specification: flags (see below) followed by 17197403Sobrien * frequency in MHz, the corresponding IEEE channel number, and 17297403Sobrien * finally the maximum regulatory transmit power cap in .5 dBm 17397403Sobrien * units. This property supersedes IEEE80211_RADIOTAP_CHANNEL 17497403Sobrien * and only one of the two should be present. 17597403Sobrien * 17697403Sobrien * IEEE80211_RADIOTAP_MCS u_int8_t known 17797403Sobrien * u_int8_t flags 17897403Sobrien * u_int8_t mcs 17997403Sobrien * 18097403Sobrien * Bitset indicating which fields have known values, followed 18197403Sobrien * by bitset of flag values, followed by the MCS rate index as 18297403Sobrien * in IEEE 802.11n. 18397403Sobrien * 18497403Sobrien * IEEE80211_RADIOTAP_VENDOR_NAMESPACE 18597403Sobrien * u_int8_t OUI[3] 18697403Sobrien * u_int8_t subspace 18797403Sobrien * u_int16_t length 18897403Sobrien * 18997403Sobrien * The Vendor Namespace Field contains three sub-fields. The first 19097403Sobrien * sub-field is 3 bytes long. It contains the vendor's IEEE 802 19197403Sobrien * Organizationally Unique Identifier (OUI). The fourth byte is a 19297403Sobrien * vendor-specific "namespace selector." 19397403Sobrien * 19497403Sobrien */ 19597403Sobrienenum ieee80211_radiotap_type { 19697403Sobrien IEEE80211_RADIOTAP_TSFT = 0, 19797403Sobrien IEEE80211_RADIOTAP_FLAGS = 1, 19897403Sobrien IEEE80211_RADIOTAP_RATE = 2, 19997403Sobrien IEEE80211_RADIOTAP_CHANNEL = 3, 20097403Sobrien IEEE80211_RADIOTAP_FHSS = 4, 20197403Sobrien IEEE80211_RADIOTAP_DBM_ANTSIGNAL = 5, 20297403Sobrien IEEE80211_RADIOTAP_DBM_ANTNOISE = 6, 20397403Sobrien IEEE80211_RADIOTAP_LOCK_QUALITY = 7, 20497403Sobrien IEEE80211_RADIOTAP_TX_ATTENUATION = 8, 20597403Sobrien IEEE80211_RADIOTAP_DB_TX_ATTENUATION = 9, 20697403Sobrien IEEE80211_RADIOTAP_DBM_TX_POWER = 10, 20797403Sobrien IEEE80211_RADIOTAP_ANTENNA = 11, 20897403Sobrien IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12, 20997403Sobrien IEEE80211_RADIOTAP_DB_ANTNOISE = 13, 21097403Sobrien IEEE80211_RADIOTAP_RX_FLAGS = 14, 21197403Sobrien /* NB: gap for netbsd definitions */ 21297403Sobrien IEEE80211_RADIOTAP_XCHANNEL = 18, 21397403Sobrien IEEE80211_RADIOTAP_MCS = 19, 21497403Sobrien IEEE80211_RADIOTAP_NAMESPACE = 29, 21597403Sobrien IEEE80211_RADIOTAP_VENDOR_NAMESPACE = 30, 21697403Sobrien IEEE80211_RADIOTAP_EXT = 31 21797403Sobrien}; 21897403Sobrien 21997403Sobrien/* channel attributes */ 22097403Sobrien#define IEEE80211_CHAN_TURBO 0x00010 /* Turbo channel */ 22197403Sobrien#define IEEE80211_CHAN_CCK 0x00020 /* CCK channel */ 22297403Sobrien#define IEEE80211_CHAN_OFDM 0x00040 /* OFDM channel */ 22397403Sobrien#define IEEE80211_CHAN_2GHZ 0x00080 /* 2 GHz spectrum channel. */ 22497403Sobrien#define IEEE80211_CHAN_5GHZ 0x00100 /* 5 GHz spectrum channel */ 22597403Sobrien#define IEEE80211_CHAN_PASSIVE 0x00200 /* Only passive scan allowed */ 22697403Sobrien#define IEEE80211_CHAN_DYN 0x00400 /* Dynamic CCK-OFDM channel */ 22797403Sobrien#define IEEE80211_CHAN_GFSK 0x00800 /* GFSK channel (FHSS PHY) */ 22897403Sobrien#define IEEE80211_CHAN_GSM 0x01000 /* 900 MHz spectrum channel */ 22997403Sobrien#define IEEE80211_CHAN_STURBO 0x02000 /* 11a static turbo channel only */ 23097403Sobrien#define IEEE80211_CHAN_HALF 0x04000 /* Half rate channel */ 23197403Sobrien#define IEEE80211_CHAN_QUARTER 0x08000 /* Quarter rate channel */ 23297403Sobrien#define IEEE80211_CHAN_HT20 0x10000 /* HT 20 channel */ 23397403Sobrien#define IEEE80211_CHAN_HT40U 0x20000 /* HT 40 channel w/ ext above */ 23497403Sobrien#define IEEE80211_CHAN_HT40D 0x40000 /* HT 40 channel w/ ext below */ 23597403Sobrien 23697403Sobrien/* Useful combinations of channel characteristics, borrowed from Ethereal */ 23797403Sobrien#define IEEE80211_CHAN_A \ 23897403Sobrien (IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM) 23997403Sobrien#define IEEE80211_CHAN_B \ 24097403Sobrien (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_CCK) 24197403Sobrien#define IEEE80211_CHAN_G \ 24297403Sobrien (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_DYN) 24397403Sobrien#define IEEE80211_CHAN_TA \ 24497403Sobrien (IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM | IEEE80211_CHAN_TURBO) 24597403Sobrien#define IEEE80211_CHAN_TG \ 24697403Sobrien (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_DYN | IEEE80211_CHAN_TURBO) 24797403Sobrien 24897403Sobrien 24997403Sobrien/* For IEEE80211_RADIOTAP_FLAGS */ 25097403Sobrien#define IEEE80211_RADIOTAP_F_CFP 0x01 /* sent/received 25197403Sobrien * during CFP 25297403Sobrien */ 25397403Sobrien#define IEEE80211_RADIOTAP_F_SHORTPRE 0x02 /* sent/received 25497403Sobrien * with short 25597403Sobrien * preamble 25697403Sobrien */ 25797403Sobrien#define IEEE80211_RADIOTAP_F_WEP 0x04 /* sent/received 25897403Sobrien * with WEP encryption 25997403Sobrien */ 26097403Sobrien#define IEEE80211_RADIOTAP_F_FRAG 0x08 /* sent/received 26197403Sobrien * with fragmentation 26297403Sobrien */ 26397403Sobrien#define IEEE80211_RADIOTAP_F_FCS 0x10 /* frame includes FCS */ 26497403Sobrien#define IEEE80211_RADIOTAP_F_DATAPAD 0x20 /* frame has padding between 26597403Sobrien * 802.11 header and payload 26697403Sobrien * (to 32-bit boundary) 26797403Sobrien */ 26897403Sobrien#define IEEE80211_RADIOTAP_F_BADFCS 0x40 /* does not pass FCS check */ 26997403Sobrien 27097403Sobrien/* For IEEE80211_RADIOTAP_RX_FLAGS */ 27197403Sobrien#define IEEE80211_RADIOTAP_F_RX_BADFCS 0x0001 /* frame failed crc check */ 27297403Sobrien#define IEEE80211_RADIOTAP_F_RX_PLCP_CRC 0x0002 /* frame failed PLCP CRC check */ 27397403Sobrien 27497403Sobrien/* For IEEE80211_RADIOTAP_MCS known */ 27597403Sobrien#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_KNOWN 0x01 27697403Sobrien#define IEEE80211_RADIOTAP_MCS_MCS_INDEX_KNOWN 0x02 /* MCS index field */ 27797403Sobrien#define IEEE80211_RADIOTAP_MCS_GUARD_INTERVAL_KNOWN 0x04 27897403Sobrien#define IEEE80211_RADIOTAP_MCS_HT_FORMAT_KNOWN 0x08 27997403Sobrien#define IEEE80211_RADIOTAP_MCS_FEC_TYPE_KNOWN 0x10 28097403Sobrien 28197403Sobrien/* For IEEE80211_RADIOTAP_MCS flags */ 28297403Sobrien#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_MASK 0x03 28397403Sobrien#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_20 0 28497403Sobrien#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_40 1 28597403Sobrien#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_20L 2 28697403Sobrien#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_20U 3 28797403Sobrien#define IEEE80211_RADIOTAP_MCS_SHORT_GI 0x04 /* short guard interval */ 28897403Sobrien#define IEEE80211_RADIOTAP_MCS_HT_GREENFIELD 0x08 28997403Sobrien#define IEEE80211_RADIOTAP_MCS_FEC_LDPC 0x10 29097403Sobrien 29197403Sobrien#endif /* _NET_IF_IEEE80211RADIOTAP_H_ */ 29297403Sobrien