dot11d.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /******************************************************************************
  2. * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved.
  3. *
  4. * This program is distributed in the hope that it will be useful, but WITHOUT
  5. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  6. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  7. * more details.
  8. *
  9. * You should have received a copy of the GNU General Public License along with
  10. * this program; if not, write to the Free Software Foundation, Inc.,
  11. * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
  12. *
  13. * The full GNU General Public License is included in this distribution in the
  14. * file called LICENSE.
  15. *
  16. * Contact Information:
  17. * wlanfae <wlanfae@realtek.com>
  18. ******************************************************************************/
  19. #ifndef __INC_DOT11D_H
  20. #define __INC_DOT11D_H
  21. #include "rtllib.h"
  22. struct chnl_txpow_triple {
  23. u8 FirstChnl;
  24. u8 NumChnls;
  25. u8 MaxTxPowerInDbm;
  26. };
  27. enum dot11d_state {
  28. DOT11D_STATE_NONE = 0,
  29. DOT11D_STATE_LEARNED,
  30. DOT11D_STATE_DONE,
  31. };
  32. /**
  33. * struct rt_dot11d_info * @CountryIeLen: value greater than 0 if @CountryIeBuf contains
  34. * valid country information element.
  35. * @channel_map: holds channel values
  36. * 0 - invalid,
  37. * 1 - valid (active scan),
  38. * 2 - valid (passive scan)
  39. * @CountryIeSrcAddr - Source AP of the country IE
  40. */
  41. struct rt_dot11d_info {
  42. bool bEnabled;
  43. u16 CountryIeLen;
  44. u8 CountryIeBuf[MAX_IE_LEN];
  45. u8 CountryIeSrcAddr[6];
  46. u8 CountryIeWatchdog;
  47. u8 channel_map[MAX_CHANNEL_NUMBER+1];
  48. u8 MaxTxPwrDbmList[MAX_CHANNEL_NUMBER+1];
  49. enum dot11d_state State;
  50. };
  51. static inline void cpMacAddr(unsigned char *des, unsigned char *src)
  52. {
  53. memcpy(des, src, 6);
  54. }
  55. #define GET_DOT11D_INFO(__pIeeeDev) \
  56. ((struct rt_dot11d_info *)((__pIeeeDev)->pDot11dInfo))
  57. #define IS_DOT11D_ENABLE(__pIeeeDev) \
  58. (GET_DOT11D_INFO(__pIeeeDev)->bEnabled)
  59. #define IS_COUNTRY_IE_VALID(__pIeeeDev) \
  60. (GET_DOT11D_INFO(__pIeeeDev)->CountryIeLen > 0)
  61. #define IS_EQUAL_CIE_SRC(__pIeeeDev, __pTa) \
  62. eqMacAddr(GET_DOT11D_INFO(__pIeeeDev)->CountryIeSrcAddr, __pTa)
  63. #define UPDATE_CIE_SRC(__pIeeeDev, __pTa) \
  64. cpMacAddr(GET_DOT11D_INFO(__pIeeeDev)->CountryIeSrcAddr, __pTa)
  65. #define IS_COUNTRY_IE_CHANGED(__pIeeeDev, __Ie) \
  66. (((__Ie).Length == 0 || (__Ie).Length != \
  67. GET_DOT11D_INFO(__pIeeeDev)->CountryIeLen) ? \
  68. false : (!memcmp(GET_DOT11D_INFO(__pIeeeDev)->CountryIeBuf, \
  69. (__Ie).Octet, (__Ie).Length)))
  70. #define CIE_WATCHDOG_TH 1
  71. #define GET_CIE_WATCHDOG(__pIeeeDev) \
  72. (GET_DOT11D_INFO(__pIeeeDev)->CountryIeWatchdog)
  73. static inline void RESET_CIE_WATCHDOG(struct rtllib_device *__pIeeeDev)
  74. {
  75. GET_CIE_WATCHDOG(__pIeeeDev) = 0;
  76. }
  77. #define UPDATE_CIE_WATCHDOG(__pIeeeDev) (++GET_CIE_WATCHDOG(__pIeeeDev))
  78. #define IS_DOT11D_STATE_DONE(__pIeeeDev) \
  79. (GET_DOT11D_INFO(__pIeeeDev)->State == DOT11D_STATE_DONE)
  80. void dot11d_init(struct rtllib_device *dev);
  81. void Dot11d_Channelmap(u8 channel_plan, struct rtllib_device *ieee);
  82. void Dot11d_Reset(struct rtllib_device *dev);
  83. void Dot11d_UpdateCountryIe(struct rtllib_device *dev, u8 *pTaddr,
  84. u16 CoutryIeLen, u8 *pCoutryIe);
  85. u8 DOT11D_GetMaxTxPwrInDbm(struct rtllib_device *dev, u8 Channel);
  86. void DOT11D_ScanComplete(struct rtllib_device *dev);
  87. int ToLegalChannel(struct rtllib_device *dev, u8 channel);
  88. #endif