rtw_tdls.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of version 2 of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
  17. *
  18. *
  19. ******************************************************************************/
  20. #ifndef __RTW_TDLS_H_
  21. #define __RTW_TDLS_H_
  22. #ifdef CONFIG_TDLS
  23. /* TDLS STA state */
  24. #define TDLS_STATE_NONE 0x00000000 //default state
  25. #define TDLS_INITIATOR_STATE 0x10000000
  26. #define TDLS_RESPONDER_STATE 0x20000000
  27. #define TDLS_LINKED_STATE 0x40000000
  28. #define TDLS_CH_SWITCH_ON_STATE 0x01000000
  29. #define TDLS_PEER_AT_OFF_STATE 0x02000000 //could send pkt on target ch
  30. #define TDLS_AT_OFF_CH_STATE 0x04000000
  31. #define TDLS_CH_SW_INITIATOR_STATE 0x08000000 //avoiding duplicated or unconditional ch. switch rsp.
  32. #define TDLS_APSD_CHSW_STATE 0x00100000 //in APSD and want to setup channel switch
  33. #define TDLS_PEER_SLEEP_STATE 0x00200000 //peer sta is sleeping
  34. #define TDLS_SW_OFF_STATE 0x00400000 //terminate channel swithcing
  35. #define TDLS_ALIVE_STATE 0x00010000 //Check if peer sta is alived.
  36. #define TPK_RESEND_COUNT 301
  37. #define CH_SWITCH_TIME 10
  38. #define CH_SWITCH_TIMEOUT 30
  39. #define TDLS_STAY_TIME 500
  40. #define TDLS_SIGNAL_THRESH 0x20
  41. #define TDLS_WATCHDOG_PERIOD 10 //Periodically sending tdls discovery request in TDLS_WATCHDOG_PERIOD * 2 sec
  42. #define TDLS_ALIVE_TIMER_PH1 5000
  43. #define TDLS_ALIVE_TIMER_PH2 2000
  44. #define TDLS_STAY_TIME 500
  45. #define TDLS_HANDSHAKE_TIME 8000
  46. #define TDLS_ALIVE_COUNT 3
  47. #define TDLS_INI_MACID_ENTRY 6
  48. /* TDLS */
  49. #define TDLS_MIC_LEN 16
  50. #define WPA_NONCE_LEN 32
  51. #define TDLS_TIMEOUT_LEN 4
  52. struct wpa_tdls_ftie {
  53. u8 ie_type; /* FTIE */
  54. u8 ie_len;
  55. u8 mic_ctrl[2];
  56. u8 mic[TDLS_MIC_LEN];
  57. u8 Anonce[WPA_NONCE_LEN]; /* Responder Nonce in TDLS */
  58. u8 Snonce[WPA_NONCE_LEN]; /* Initiator Nonce in TDLS */
  59. /* followed by optional elements */
  60. } ;
  61. struct wpa_tdls_lnkid {
  62. u8 ie_type; /* Link Identifier IE */
  63. u8 ie_len;
  64. u8 bssid[ETH_ALEN];
  65. u8 init_sta[ETH_ALEN];
  66. u8 resp_sta[ETH_ALEN];
  67. } ;
  68. static u8 TDLS_RSNIE[]={ 0x01, 0x00, //version shall be set to 1
  69. 0x00, 0x0f, 0xac, 0x07, //group sipher suite
  70. 0x01, 0x00, //pairwise cipher suite count
  71. 0x00, 0x0f, 0xac, 0x04, //pairwise cipher suite list; CCMP only
  72. 0x01, 0x00, //AKM suite count
  73. 0x00, 0x0f, 0xac, 0x07, //TPK Handshake
  74. 0x00, 0x02,
  75. //PMKID shall not be present
  76. };
  77. static u8 TDLS_WMMIE[]={0x00, 0x50, 0xf2, 0x02, 0x00, 0x01, 0x00}; //Qos info all set zero
  78. static u8 TDLS_EXT_CAPIE[] = {0x00, 0x00, 0x00, 0x50, 0x20}; //bit(28), bit(30), bit(37)
  79. // SRC: Supported Regulatory Classes
  80. static u8 TDLS_SRC[] = { 0x01, 0x01, 0x02, 0x03, 0x04, 0x0c, 0x16, 0x17, 0x18, 0x19, 0x1b, 0x1c, 0x1d, 0x1e, 0x20, 0x21 };
  81. void rtw_reset_tdls_info(_adapter* padapter);
  82. int rtw_init_tdls_info(_adapter* padapter);
  83. void rtw_free_tdls_info(struct tdls_info *ptdlsinfo);
  84. void issue_nulldata_to_TDLS_peer_STA(_adapter *padapter, struct sta_info *ptdls_sta, unsigned int power_mode);
  85. void init_TPK_timer(_adapter *padapter, struct sta_info *psta);
  86. void init_ch_switch_timer(_adapter *padapter, struct sta_info *psta);
  87. void init_base_ch_timer(_adapter *padapter, struct sta_info *psta);
  88. void init_off_ch_timer(_adapter *padapter, struct sta_info *psta);
  89. void init_tdls_alive_timer(_adapter *padapter, struct sta_info *psta);
  90. void init_handshake_timer(_adapter *padapter, struct sta_info *psta);
  91. void free_tdls_sta(_adapter *padapter, struct sta_info *ptdls_sta);
  92. #ifdef CONFIG_WFD
  93. void issue_tunneled_probe_req(_adapter *padapter);
  94. void issue_tunneled_probe_rsp(_adapter *padapter, union recv_frame *precv_frame);
  95. #endif //CONFIG_WFD
  96. void issue_tdls_dis_req(_adapter *padapter, u8 *mac_addr);
  97. void issue_tdls_setup_req(_adapter *padapter, u8 *mac_addr);
  98. void issue_tdls_setup_rsp(_adapter *padapter, union recv_frame *precv_frame);
  99. void issue_tdls_setup_cfm(_adapter *padapter, union recv_frame *precv_frame);
  100. void issue_tdls_dis_rsp(_adapter * padapter, union recv_frame * precv_frame, u8 dialog);
  101. void issue_tdls_teardown(_adapter *padapter, u8 *mac_addr);
  102. void issue_tdls_peer_traffic_indication(_adapter *padapter, struct sta_info *psta);
  103. void issue_tdls_ch_switch_req(_adapter *padapter, u8 *mac_addr);
  104. void issue_tdls_ch_switch_rsp(_adapter *padapter, u8 *mac_addr);
  105. sint On_TDLS_Dis_Rsp(_adapter *adapter, union recv_frame *precv_frame);
  106. sint On_TDLS_Setup_Req(_adapter *adapter, union recv_frame *precv_frame);
  107. sint On_TDLS_Setup_Rsp(_adapter *adapter, union recv_frame *precv_frame);
  108. sint On_TDLS_Setup_Cfm(_adapter *adapter, union recv_frame *precv_frame);
  109. sint On_TDLS_Dis_Req(_adapter *adapter, union recv_frame *precv_frame);
  110. sint On_TDLS_Teardown(_adapter *adapter, union recv_frame *precv_frame);
  111. sint On_TDLS_Peer_Traffic_Rsp(_adapter *adapter, union recv_frame *precv_frame);
  112. sint On_TDLS_Ch_Switch_Req(_adapter *adapter, union recv_frame *precv_frame);
  113. sint On_TDLS_Ch_Switch_Rsp(_adapter *adapter, union recv_frame *precv_frame);
  114. void rtw_build_tdls_setup_req_ies(_adapter * padapter, struct xmit_frame * pxmitframe, u8 *pframe);
  115. void rtw_build_tdls_setup_rsp_ies(_adapter * padapter, struct xmit_frame * pxmitframe, u8 *pframe);
  116. void rtw_build_tdls_setup_cfm_ies(_adapter * padapter, struct xmit_frame * pxmitframe, u8 *pframe);
  117. void rtw_build_tdls_teardown_ies(_adapter * padapter, struct xmit_frame * pxmitframe, u8 *pframe);
  118. void rtw_build_tdls_dis_req_ies(_adapter * padapter, struct xmit_frame * pxmitframe, u8 *pframe);
  119. void rtw_build_tdls_dis_rsp_ies(_adapter * padapter, struct xmit_frame * pxmitframe, u8 *pframe, u8 dialog);
  120. void rtw_build_tdls_peer_traffic_indication_ies(_adapter * padapter, struct xmit_frame * pxmitframe, u8 *pframe);
  121. void rtw_build_tdls_ch_switch_req_ies(_adapter * padapter, struct xmit_frame * pxmitframe, u8 *pframe);
  122. void rtw_build_tdls_ch_switch_rsp_ies(_adapter * padapter, struct xmit_frame * pxmitframe, u8 *pframe);
  123. void rtw_build_tunneled_probe_req_ies(_adapter * padapter, struct xmit_frame * pxmitframe, u8 *pframe);
  124. void rtw_build_tunneled_probe_rsp_ies(_adapter * padapter, struct xmit_frame * pxmitframe, u8 *pframe);
  125. int update_sgi_tdls(_adapter *padapter, struct sta_info *psta);
  126. u32 update_mask_tdls(_adapter *padapter, struct sta_info *psta);
  127. #endif //CONFIG_TDLS
  128. #endif