ieee80211_priv.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /* $OpenBSD: ieee80211_priv.h,v 1.5 2009/01/26 19:09:41 damien Exp $ */
  2. /*-
  3. * Copyright (c) 2008 Damien Bergamini <damien.bergamini@free.fr>
  4. *
  5. * Permission to use, copy, modify, and distribute this software for any
  6. * purpose with or without fee is hereby granted, provided that the above
  7. * copyright notice and this permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  10. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  11. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  12. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  13. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  14. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  15. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  16. */
  17. #ifndef _NET80211_IEEE80211_PRIV_H_
  18. #define _NET80211_IEEE80211_PRIV_H_
  19. #ifdef IEEE80211_DEBUG
  20. extern int ieee80211_debug;
  21. #define DPRINTF(X) do { \
  22. if (ieee80211_debug) { \
  23. printf("%s: ", __func__); \
  24. printf X; \
  25. } \
  26. } while(0)
  27. #else
  28. #define DPRINTF(X)
  29. #endif
  30. #define SEQ_LT(a,b) \
  31. ((((u_int16_t)(a) - (u_int16_t)(b)) & 0xfff) > 2048)
  32. #define IEEE80211_AID_SET(b, w) \
  33. ((w)[IEEE80211_AID(b) / 32] |= (1 << (IEEE80211_AID(b) % 32)))
  34. #define IEEE80211_AID_CLR(b, w) \
  35. ((w)[IEEE80211_AID(b) / 32] &= ~(1 << (IEEE80211_AID(b) % 32)))
  36. #define IEEE80211_AID_ISSET(b, w) \
  37. ((w)[IEEE80211_AID(b) / 32] & (1 << (IEEE80211_AID(b) % 32)))
  38. #define IEEE80211_RSNIE_MAXLEN \
  39. (2 + /* Version */ \
  40. 4 + /* Group Data Cipher Suite */ \
  41. 2 + /* Pairwise Cipher Suite Count */ \
  42. 4 * 2 + /* Pairwise Cipher Suite List (max 2) */ \
  43. 2 + /* AKM Suite List Count */ \
  44. 4 * 4 + /* AKM Suite List (max 4) */ \
  45. 2 + /* RSN Capabilities */ \
  46. 2 + /* PMKID Count */ \
  47. 16 * 1 + /* PMKID List (max 1) */ \
  48. 4) /* 11w: Group Integrity Cipher Suite */
  49. #define IEEE80211_WPAIE_MAXLEN \
  50. (4 + /* MICROSOFT_OUI */ \
  51. 2 + /* Version */ \
  52. 4 + /* Group Cipher Suite */ \
  53. 2 + /* Pairwise Cipher Suite Count */ \
  54. 4 * 2 + /* Pairwise Cipher Suite List (max 2) */ \
  55. 2 + /* AKM Suite List Count */ \
  56. 4 * 2) /* AKM Suite List (max 2) */
  57. struct ieee80211_rsnparams {
  58. u_int16_t rsn_nakms;
  59. u_int32_t rsn_akms;
  60. u_int16_t rsn_nciphers;
  61. u_int32_t rsn_ciphers;
  62. enum ieee80211_cipher rsn_groupcipher;
  63. enum ieee80211_cipher rsn_groupmgmtcipher;
  64. u_int16_t rsn_caps;
  65. u_int8_t rsn_npmkids;
  66. const u_int8_t *rsn_pmkids;
  67. };
  68. /* unaligned big endian access */
  69. #define BE_READ_2(p) \
  70. ((u_int16_t) \
  71. ((((const u_int8_t *)(p))[0] << 8) | \
  72. (((const u_int8_t *)(p))[1])))
  73. #define BE_READ_8(p) \
  74. ((u_int64_t)(p)[0] << 56 | (u_int64_t)(p)[1] << 48 | \
  75. (u_int64_t)(p)[2] << 40 | (u_int64_t)(p)[3] << 32 | \
  76. (u_int64_t)(p)[4] << 24 | (u_int64_t)(p)[5] << 16 | \
  77. (u_int64_t)(p)[6] << 8 | (u_int64_t)(p)[7])
  78. #define BE_WRITE_2(p, v) do { \
  79. ((u_int8_t *)(p))[0] = (v) >> 8; \
  80. ((u_int8_t *)(p))[1] = (v) & 0xff; \
  81. } while (0)
  82. #define BE_WRITE_8(p, v) do { \
  83. (p)[0] = (v) >> 56; (p)[1] = (v) >> 48; \
  84. (p)[2] = (v) >> 40; (p)[3] = (v) >> 32; \
  85. (p)[4] = (v) >> 24; (p)[5] = (v) >> 16; \
  86. (p)[6] = (v) >> 8; (p)[7] = (v); \
  87. } while (0)
  88. /* unaligned little endian access */
  89. #define LE_READ_2(p) \
  90. ((u_int16_t) \
  91. ((((const u_int8_t *)(p))[0]) | \
  92. (((const u_int8_t *)(p))[1] << 8)))
  93. #define LE_READ_4(p) \
  94. ((u_int32_t) \
  95. ((((const u_int8_t *)(p))[0]) | \
  96. (((const u_int8_t *)(p))[1] << 8) | \
  97. (((const u_int8_t *)(p))[2] << 16) | \
  98. (((const u_int8_t *)(p))[3] << 24)))
  99. #define LE_READ_6(p) \
  100. ((u_int64_t)(p)[5] << 40 | (u_int64_t)(p)[4] << 32 | \
  101. (u_int64_t)(p)[3] << 24 | (u_int64_t)(p)[2] << 16 | \
  102. (u_int64_t)(p)[1] << 8 | (u_int64_t)(p)[0])
  103. #define LE_WRITE_2(p, v) do { \
  104. ((u_int8_t *)(p))[0] = (v) & 0xff; \
  105. ((u_int8_t *)(p))[1] = (v) >> 8; \
  106. } while (0)
  107. #define LE_WRITE_4(p, v) do { \
  108. (p)[3] = (v) >> 24; (p)[2] = (v) >> 16; \
  109. (p)[1] = (v) >> 8; (p)[0] = (v); \
  110. } while (0)
  111. #define LE_WRITE_6(p, v) do { \
  112. (p)[5] = (v) >> 40; (p)[4] = (v) >> 32; \
  113. (p)[3] = (v) >> 24; (p)[2] = (v) >> 16; \
  114. (p)[1] = (v) >> 8; (p)[0] = (v); \
  115. } while (0)
  116. #endif /* _NET80211_IEEE80211_PRIV_H_ */