ieee80211_radiotap.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. /* $OpenBSD: ieee80211_radiotap.h,v 1.11 2010/07/17 16:25:09 damien Exp $ */
  2. /* $FreeBSD: src/sys/net80211/ieee80211_radiotap.h,v 1.3 2004/04/05 22:13:21 sam Exp $ */
  3. /* $NetBSD: ieee80211_radiotap.h,v 1.9 2004/06/06 04:13:28 dyoung Exp $ */
  4. /*-
  5. * Copyright (c) 2003, 2004 David Young. All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions
  9. * are met:
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY DAVID YOUNG ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  18. * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
  19. * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DAVID
  20. * YOUNG BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  21. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
  22. * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  23. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  24. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  25. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  26. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
  27. * OF SUCH DAMAGE.
  28. */
  29. #ifndef _NET_IF_IEEE80211RADIOTAP_H_
  30. #define _NET_IF_IEEE80211RADIOTAP_H_
  31. /* A generic radio capture format is desirable. There is one for
  32. * Linux, but it is neither rigidly defined (there were not even
  33. * units given for some fields) nor easily extensible.
  34. *
  35. * I suggest the following extensible radio capture format. It is
  36. * based on a bitmap indicating which fields are present.
  37. *
  38. * I am trying to describe precisely what the application programmer
  39. * should expect in the following, and for that reason I tell the
  40. * units and origin of each measurement (where it applies), or else I
  41. * use sufficiently weaselly language ("is a monotonically nondecreasing
  42. * function of...") that I cannot set false expectations for lawyerly
  43. * readers.
  44. */
  45. /* XXX tcpdump/libpcap do not tolerate variable-length headers,
  46. * yet, so we pad every radiotap header to 64 bytes. Ugh.
  47. */
  48. #define IEEE80211_RADIOTAP_HDRLEN 64
  49. /* The radio capture header precedes the 802.11 header. */
  50. struct ieee80211_radiotap_header {
  51. u_int8_t it_version; /* Version 0. Only increases
  52. * for drastic changes,
  53. * introduction of compatible
  54. * new fields does not count.
  55. */
  56. u_int8_t it_pad;
  57. u_int16_t it_len; /* length of the whole
  58. * header in bytes, including
  59. * it_version, it_pad,
  60. * it_len, and data fields.
  61. */
  62. u_int32_t it_present; /* A bitmap telling which
  63. * fields are present. Set bit 31
  64. * (0x80000000) to extend the
  65. * bitmap by another 32 bits.
  66. * Additional extensions are made
  67. * by setting bit 31.
  68. */
  69. } __packed;
  70. /* Name Data type Units
  71. * ---- --------- -----
  72. *
  73. * IEEE80211_RADIOTAP_TSFT u_int64_t microseconds
  74. *
  75. * Value in microseconds of the MAC's 64-bit 802.11 Time
  76. * Synchronization Function timer when the first bit of the
  77. * MPDU arrived at the MAC. For received frames, only.
  78. *
  79. * IEEE80211_RADIOTAP_CHANNEL 2 x u_int16_t MHz, bitmap
  80. *
  81. * Tx/Rx frequency in MHz, followed by flags (see below).
  82. *
  83. * IEEE80211_RADIOTAP_FHSS u_int16_t see below
  84. *
  85. * For frequency-hopping radios, the hop set (first byte)
  86. * and pattern (second byte).
  87. *
  88. * IEEE80211_RADIOTAP_RATE u_int8_t 500kb/s
  89. *
  90. * Tx/Rx data rate
  91. *
  92. * IEEE80211_RADIOTAP_DBM_ANTSIGNAL int8_t decibels from
  93. * one milliwatt (dBm)
  94. *
  95. * RF signal power at the antenna, decibel difference from
  96. * one milliwatt.
  97. *
  98. * IEEE80211_RADIOTAP_DBM_ANTNOISE int8_t decibels from
  99. * one milliwatt (dBm)
  100. *
  101. * RF noise power at the antenna, decibel difference from one
  102. * milliwatt.
  103. *
  104. * IEEE80211_RADIOTAP_DB_ANTSIGNAL u_int8_t decibel (dB)
  105. *
  106. * RF signal power at the antenna, decibel difference from an
  107. * arbitrary, fixed reference.
  108. *
  109. * IEEE80211_RADIOTAP_DB_ANTNOISE u_int8_t decibel (dB)
  110. *
  111. * RF noise power at the antenna, decibel difference from an
  112. * arbitrary, fixed reference point.
  113. *
  114. * IEEE80211_RADIOTAP_BARKER_CODE_LOCK u_int16_t unitless
  115. *
  116. * Quality of Barker code lock. Unitless. Monotonically
  117. * nondecreasing with "better" lock strength. Called "Signal
  118. * Quality" in datasheets. (Is there a standard way to measure
  119. * this?)
  120. *
  121. * IEEE80211_RADIOTAP_TX_ATTENUATION u_int16_t unitless
  122. *
  123. * Transmit power expressed as unitless distance from max
  124. * power set at factory calibration. 0 is max power.
  125. * Monotonically nondecreasing with lower power levels.
  126. *
  127. * IEEE80211_RADIOTAP_DB_TX_ATTENUATION u_int16_t decibels (dB)
  128. *
  129. * Transmit power expressed as decibel distance from max power
  130. * set at factory calibration. 0 is max power. Monotonically
  131. * nondecreasing with lower power levels.
  132. *
  133. * IEEE80211_RADIOTAP_DBM_TX_POWER int8_t decibels from
  134. * one milliwatt (dBm)
  135. *
  136. * Transmit power expressed as dBm (decibels from a 1 milliwatt
  137. * reference). This is the absolute power level measured at
  138. * the antenna port.
  139. *
  140. * IEEE80211_RADIOTAP_FLAGS u_int8_t bitmap
  141. *
  142. * Properties of transmitted and received frames. See flags
  143. * defined below.
  144. *
  145. * IEEE80211_RADIOTAP_ANTENNA u_int8_t antenna index
  146. *
  147. * Unitless indication of the Rx/Tx antenna for this packet.
  148. * The first antenna is antenna 0.
  149. *
  150. * IEEE80211_RADIOTAP_FCS u_int32_t data
  151. *
  152. * FCS from frame in network byte order.
  153. *
  154. * IEEE80211_RADIOTAP_HWQUEUE u_int8_t data
  155. *
  156. * A specific hardware queue (used by WME)
  157. *
  158. * IEEE80211_RADIOTAP_RSSI 2x u_int8_t RSSI, max RSSI
  159. *
  160. * A relative Received Signal Strength Index
  161. */
  162. enum ieee80211_radiotap_type {
  163. IEEE80211_RADIOTAP_TSFT = 0,
  164. IEEE80211_RADIOTAP_FLAGS = 1,
  165. IEEE80211_RADIOTAP_RATE = 2,
  166. IEEE80211_RADIOTAP_CHANNEL = 3,
  167. IEEE80211_RADIOTAP_FHSS = 4,
  168. IEEE80211_RADIOTAP_DBM_ANTSIGNAL = 5,
  169. IEEE80211_RADIOTAP_DBM_ANTNOISE = 6,
  170. IEEE80211_RADIOTAP_LOCK_QUALITY = 7,
  171. IEEE80211_RADIOTAP_TX_ATTENUATION = 8,
  172. IEEE80211_RADIOTAP_DB_TX_ATTENUATION = 9,
  173. IEEE80211_RADIOTAP_DBM_TX_POWER = 10,
  174. IEEE80211_RADIOTAP_ANTENNA = 11,
  175. IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12,
  176. IEEE80211_RADIOTAP_DB_ANTNOISE = 13,
  177. IEEE80211_RADIOTAP_FCS = 14,
  178. IEEE80211_RADIOTAP_HWQUEUE = 15,
  179. IEEE80211_RADIOTAP_RSSI = 16,
  180. IEEE80211_RADIOTAP_EXT = 31
  181. };
  182. #ifndef _KERNEL
  183. /* For IEEE80211_RADIOTAP_CHANNEL */
  184. #define IEEE80211_CHAN_TURBO 0x0010 /* Turbo channel */
  185. #define IEEE80211_CHAN_CCK 0x0020 /* CCK channel */
  186. #define IEEE80211_CHAN_OFDM 0x0040 /* OFDM channel */
  187. #define IEEE80211_CHAN_2GHZ 0x0080 /* 2 GHz spectrum channel */
  188. #define IEEE80211_CHAN_5GHZ 0x0100 /* 5 GHz spectrum channel */
  189. #define IEEE80211_CHAN_PASSIVE 0x0200 /* Only passive scan allowed */
  190. #define IEEE80211_CHAN_DYN 0x0400 /* Dynamic CCK-OFDM channel */
  191. #define IEEE80211_CHAN_GFSK 0x0800 /* GFSK channel (FHSS PHY) */
  192. #define IEEE80211_CHAN_XR 0x1000 /* Extended range OFDM channel */
  193. #endif /* !_KERNEL */
  194. /* For IEEE80211_RADIOTAP_FLAGS */
  195. #define IEEE80211_RADIOTAP_F_CFP 0x01 /* sent/received
  196. * during CFP
  197. */
  198. #define IEEE80211_RADIOTAP_F_SHORTPRE 0x02 /* sent/received
  199. * with short
  200. * preamble
  201. */
  202. #define IEEE80211_RADIOTAP_F_WEP 0x04 /* sent/received
  203. * with WEP encryption
  204. */
  205. #define IEEE80211_RADIOTAP_F_FRAG 0x08 /* sent/received
  206. * with fragmentation
  207. */
  208. #define IEEE80211_RADIOTAP_F_FCS 0x10 /* frame includes FCS */
  209. #endif /* _NET_IF_IEEE80211RADIOTAP_H_ */