ieee80211_radiotap.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. /*
  2. * Copyright (c) 2017 Intel Deutschland GmbH
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #ifndef __RADIOTAP_H
  17. #define __RADIOTAP_H
  18. #include <linux/kernel.h>
  19. #include <asm/unaligned.h>
  20. /**
  21. * struct ieee82011_radiotap_header - base radiotap header
  22. */
  23. struct ieee80211_radiotap_header {
  24. /**
  25. * @it_version: radiotap version, always 0
  26. */
  27. uint8_t it_version;
  28. /**
  29. * @it_pad: padding (or alignment)
  30. */
  31. uint8_t it_pad;
  32. /**
  33. * @it_len: overall radiotap header length
  34. */
  35. __le16 it_len;
  36. /**
  37. * @it_present: (first) present word
  38. */
  39. __le32 it_present;
  40. } __packed;
  41. /* version is always 0 */
  42. #define PKTHDR_RADIOTAP_VERSION 0
  43. /* see the radiotap website for the descriptions */
  44. enum ieee80211_radiotap_presence {
  45. IEEE80211_RADIOTAP_TSFT = 0,
  46. IEEE80211_RADIOTAP_FLAGS = 1,
  47. IEEE80211_RADIOTAP_RATE = 2,
  48. IEEE80211_RADIOTAP_CHANNEL = 3,
  49. IEEE80211_RADIOTAP_FHSS = 4,
  50. IEEE80211_RADIOTAP_DBM_ANTSIGNAL = 5,
  51. IEEE80211_RADIOTAP_DBM_ANTNOISE = 6,
  52. IEEE80211_RADIOTAP_LOCK_QUALITY = 7,
  53. IEEE80211_RADIOTAP_TX_ATTENUATION = 8,
  54. IEEE80211_RADIOTAP_DB_TX_ATTENUATION = 9,
  55. IEEE80211_RADIOTAP_DBM_TX_POWER = 10,
  56. IEEE80211_RADIOTAP_ANTENNA = 11,
  57. IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12,
  58. IEEE80211_RADIOTAP_DB_ANTNOISE = 13,
  59. IEEE80211_RADIOTAP_RX_FLAGS = 14,
  60. IEEE80211_RADIOTAP_TX_FLAGS = 15,
  61. IEEE80211_RADIOTAP_RTS_RETRIES = 16,
  62. IEEE80211_RADIOTAP_DATA_RETRIES = 17,
  63. /* 18 is XChannel, but it's not defined yet */
  64. IEEE80211_RADIOTAP_MCS = 19,
  65. IEEE80211_RADIOTAP_AMPDU_STATUS = 20,
  66. IEEE80211_RADIOTAP_VHT = 21,
  67. IEEE80211_RADIOTAP_TIMESTAMP = 22,
  68. /* valid in every it_present bitmap, even vendor namespaces */
  69. IEEE80211_RADIOTAP_RADIOTAP_NAMESPACE = 29,
  70. IEEE80211_RADIOTAP_VENDOR_NAMESPACE = 30,
  71. IEEE80211_RADIOTAP_EXT = 31
  72. };
  73. /* for IEEE80211_RADIOTAP_FLAGS */
  74. enum ieee80211_radiotap_flags {
  75. IEEE80211_RADIOTAP_F_CFP = 0x01,
  76. IEEE80211_RADIOTAP_F_SHORTPRE = 0x02,
  77. IEEE80211_RADIOTAP_F_WEP = 0x04,
  78. IEEE80211_RADIOTAP_F_FRAG = 0x08,
  79. IEEE80211_RADIOTAP_F_FCS = 0x10,
  80. IEEE80211_RADIOTAP_F_DATAPAD = 0x20,
  81. IEEE80211_RADIOTAP_F_BADFCS = 0x40,
  82. };
  83. /* for IEEE80211_RADIOTAP_CHANNEL */
  84. enum ieee80211_radiotap_channel_flags {
  85. IEEE80211_CHAN_CCK = 0x0020,
  86. IEEE80211_CHAN_OFDM = 0x0040,
  87. IEEE80211_CHAN_2GHZ = 0x0080,
  88. IEEE80211_CHAN_5GHZ = 0x0100,
  89. IEEE80211_CHAN_DYN = 0x0400,
  90. IEEE80211_CHAN_HALF = 0x4000,
  91. IEEE80211_CHAN_QUARTER = 0x8000,
  92. };
  93. /* for IEEE80211_RADIOTAP_RX_FLAGS */
  94. enum ieee80211_radiotap_rx_flags {
  95. IEEE80211_RADIOTAP_F_RX_BADPLCP = 0x0002,
  96. };
  97. /* for IEEE80211_RADIOTAP_TX_FLAGS */
  98. enum ieee80211_radiotap_tx_flags {
  99. IEEE80211_RADIOTAP_F_TX_FAIL = 0x0001,
  100. IEEE80211_RADIOTAP_F_TX_CTS = 0x0002,
  101. IEEE80211_RADIOTAP_F_TX_RTS = 0x0004,
  102. IEEE80211_RADIOTAP_F_TX_NOACK = 0x0008,
  103. };
  104. /* for IEEE80211_RADIOTAP_MCS "have" flags */
  105. enum ieee80211_radiotap_mcs_have {
  106. IEEE80211_RADIOTAP_MCS_HAVE_BW = 0x01,
  107. IEEE80211_RADIOTAP_MCS_HAVE_MCS = 0x02,
  108. IEEE80211_RADIOTAP_MCS_HAVE_GI = 0x04,
  109. IEEE80211_RADIOTAP_MCS_HAVE_FMT = 0x08,
  110. IEEE80211_RADIOTAP_MCS_HAVE_FEC = 0x10,
  111. IEEE80211_RADIOTAP_MCS_HAVE_STBC = 0x20,
  112. };
  113. enum ieee80211_radiotap_mcs_flags {
  114. IEEE80211_RADIOTAP_MCS_BW_MASK = 0x03,
  115. IEEE80211_RADIOTAP_MCS_BW_20 = 0,
  116. IEEE80211_RADIOTAP_MCS_BW_40 = 1,
  117. IEEE80211_RADIOTAP_MCS_BW_20L = 2,
  118. IEEE80211_RADIOTAP_MCS_BW_20U = 3,
  119. IEEE80211_RADIOTAP_MCS_SGI = 0x04,
  120. IEEE80211_RADIOTAP_MCS_FMT_GF = 0x08,
  121. IEEE80211_RADIOTAP_MCS_FEC_LDPC = 0x10,
  122. IEEE80211_RADIOTAP_MCS_STBC_MASK = 0x60,
  123. IEEE80211_RADIOTAP_MCS_STBC_1 = 1,
  124. IEEE80211_RADIOTAP_MCS_STBC_2 = 2,
  125. IEEE80211_RADIOTAP_MCS_STBC_3 = 3,
  126. IEEE80211_RADIOTAP_MCS_STBC_SHIFT = 5,
  127. };
  128. /* for IEEE80211_RADIOTAP_AMPDU_STATUS */
  129. enum ieee80211_radiotap_ampdu_flags {
  130. IEEE80211_RADIOTAP_AMPDU_REPORT_ZEROLEN = 0x0001,
  131. IEEE80211_RADIOTAP_AMPDU_IS_ZEROLEN = 0x0002,
  132. IEEE80211_RADIOTAP_AMPDU_LAST_KNOWN = 0x0004,
  133. IEEE80211_RADIOTAP_AMPDU_IS_LAST = 0x0008,
  134. IEEE80211_RADIOTAP_AMPDU_DELIM_CRC_ERR = 0x0010,
  135. IEEE80211_RADIOTAP_AMPDU_DELIM_CRC_KNOWN = 0x0020,
  136. };
  137. /* for IEEE80211_RADIOTAP_VHT */
  138. enum ieee80211_radiotap_vht_known {
  139. IEEE80211_RADIOTAP_VHT_KNOWN_STBC = 0x0001,
  140. IEEE80211_RADIOTAP_VHT_KNOWN_TXOP_PS_NA = 0x0002,
  141. IEEE80211_RADIOTAP_VHT_KNOWN_GI = 0x0004,
  142. IEEE80211_RADIOTAP_VHT_KNOWN_SGI_NSYM_DIS = 0x0008,
  143. IEEE80211_RADIOTAP_VHT_KNOWN_LDPC_EXTRA_OFDM_SYM = 0x0010,
  144. IEEE80211_RADIOTAP_VHT_KNOWN_BEAMFORMED = 0x0020,
  145. IEEE80211_RADIOTAP_VHT_KNOWN_BANDWIDTH = 0x0040,
  146. IEEE80211_RADIOTAP_VHT_KNOWN_GROUP_ID = 0x0080,
  147. IEEE80211_RADIOTAP_VHT_KNOWN_PARTIAL_AID = 0x0100,
  148. };
  149. enum ieee80211_radiotap_vht_flags {
  150. IEEE80211_RADIOTAP_VHT_FLAG_STBC = 0x01,
  151. IEEE80211_RADIOTAP_VHT_FLAG_TXOP_PS_NA = 0x02,
  152. IEEE80211_RADIOTAP_VHT_FLAG_SGI = 0x04,
  153. IEEE80211_RADIOTAP_VHT_FLAG_SGI_NSYM_M10_9 = 0x08,
  154. IEEE80211_RADIOTAP_VHT_FLAG_LDPC_EXTRA_OFDM_SYM = 0x10,
  155. IEEE80211_RADIOTAP_VHT_FLAG_BEAMFORMED = 0x20,
  156. };
  157. enum ieee80211_radiotap_vht_coding {
  158. IEEE80211_RADIOTAP_CODING_LDPC_USER0 = 0x01,
  159. IEEE80211_RADIOTAP_CODING_LDPC_USER1 = 0x02,
  160. IEEE80211_RADIOTAP_CODING_LDPC_USER2 = 0x04,
  161. IEEE80211_RADIOTAP_CODING_LDPC_USER3 = 0x08,
  162. };
  163. /* for IEEE80211_RADIOTAP_TIMESTAMP */
  164. enum ieee80211_radiotap_timestamp_unit_spos {
  165. IEEE80211_RADIOTAP_TIMESTAMP_UNIT_MASK = 0x000F,
  166. IEEE80211_RADIOTAP_TIMESTAMP_UNIT_MS = 0x0000,
  167. IEEE80211_RADIOTAP_TIMESTAMP_UNIT_US = 0x0001,
  168. IEEE80211_RADIOTAP_TIMESTAMP_UNIT_NS = 0x0003,
  169. IEEE80211_RADIOTAP_TIMESTAMP_SPOS_MASK = 0x00F0,
  170. IEEE80211_RADIOTAP_TIMESTAMP_SPOS_BEGIN_MDPU = 0x0000,
  171. IEEE80211_RADIOTAP_TIMESTAMP_SPOS_PLCP_SIG_ACQ = 0x0010,
  172. IEEE80211_RADIOTAP_TIMESTAMP_SPOS_EO_PPDU = 0x0020,
  173. IEEE80211_RADIOTAP_TIMESTAMP_SPOS_EO_MPDU = 0x0030,
  174. IEEE80211_RADIOTAP_TIMESTAMP_SPOS_UNKNOWN = 0x00F0,
  175. };
  176. enum ieee80211_radiotap_timestamp_flags {
  177. IEEE80211_RADIOTAP_TIMESTAMP_FLAG_64BIT = 0x00,
  178. IEEE80211_RADIOTAP_TIMESTAMP_FLAG_32BIT = 0x01,
  179. IEEE80211_RADIOTAP_TIMESTAMP_FLAG_ACCURACY = 0x02,
  180. };
  181. /**
  182. * ieee80211_get_radiotap_len - get radiotap header length
  183. */
  184. static inline u16 ieee80211_get_radiotap_len(const char *data)
  185. {
  186. struct ieee80211_radiotap_header *hdr = (void *)data;
  187. return get_unaligned_le16(&hdr->it_len);
  188. }
  189. #endif /* __RADIOTAP_H */