rtw_p2p.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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_P2P_H_
  21. #define __RTW_P2P_H_
  22. u32 build_beacon_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
  23. u32 build_probe_resp_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
  24. u32 build_prov_disc_request_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pbuf, u8* pssid, u8 ussidlen, u8* pdev_raddr );
  25. u32 build_assoc_resp_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pbuf, u8 status_code);
  26. u32 build_deauth_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
  27. #ifdef CONFIG_WFD
  28. u32 build_probe_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
  29. u32 build_probe_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf, u8 tunneled);
  30. u32 build_beacon_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
  31. u32 build_nego_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
  32. u32 build_nego_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
  33. u32 build_nego_confirm_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
  34. u32 build_invitation_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
  35. u32 build_invitation_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
  36. u32 build_assoc_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
  37. u32 build_assoc_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
  38. u32 build_provdisc_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
  39. u32 build_provdisc_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf);
  40. #endif //CONFIG_WFD
  41. u32 process_probe_req_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pframe, uint len);
  42. u32 process_assoc_req_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pframe, uint len, struct sta_info *psta);
  43. u32 process_p2p_devdisc_req(struct wifidirect_info *pwdinfo, u8 *pframe, uint len);
  44. u32 process_p2p_devdisc_resp(struct wifidirect_info *pwdinfo, u8 *pframe, uint len);
  45. u8 process_p2p_provdisc_req(struct wifidirect_info *pwdinfo, u8 *pframe, uint len);
  46. u8 process_p2p_provdisc_resp(struct wifidirect_info *pwdinfo, u8 *pframe);
  47. u8 process_p2p_group_negotation_req( struct wifidirect_info *pwdinfo, u8 *pframe, uint len );
  48. u8 process_p2p_group_negotation_resp( struct wifidirect_info *pwdinfo, u8 *pframe, uint len );
  49. u8 process_p2p_group_negotation_confirm( struct wifidirect_info *pwdinfo, u8 *pframe, uint len );
  50. u8 process_p2p_presence_req(struct wifidirect_info *pwdinfo, u8 *pframe, uint len);
  51. void p2p_protocol_wk_hdl(_adapter *padapter, int intCmdType);
  52. #ifdef CONFIG_P2P_PS
  53. void process_p2p_ps_ie(PADAPTER padapter, u8 *IEs, u32 IELength);
  54. void p2p_ps_wk_hdl(_adapter *padapter, u8 p2p_ps_state);
  55. u8 p2p_ps_wk_cmd(_adapter*padapter, u8 p2p_ps_state, u8 enqueue);
  56. #endif // CONFIG_P2P_PS
  57. #ifdef CONFIG_IOCTL_CFG80211
  58. void rtw_init_cfg80211_wifidirect_info( _adapter* padapter);
  59. int rtw_p2p_check_frames(_adapter *padapter, const u8 *buf, u32 len, u8 tx);
  60. void rtw_append_wfd_ie(_adapter *padapter, u8 *buf, u32 *len);
  61. #endif //CONFIG_IOCTL_CFG80211
  62. void reset_global_wifidirect_info( _adapter* padapter );
  63. int rtw_init_wifi_display_info(_adapter* padapter);
  64. void rtw_init_wifidirect_timers(_adapter* padapter);
  65. void rtw_init_wifidirect_addrs(_adapter* padapter, u8 *dev_addr, u8 *iface_addr);
  66. void init_wifidirect_info( _adapter* padapter, enum P2P_ROLE role);
  67. int rtw_p2p_enable(_adapter *padapter, enum P2P_ROLE role);
  68. static inline void _rtw_p2p_set_state(struct wifidirect_info *wdinfo, enum P2P_STATE state)
  69. {
  70. if(wdinfo->p2p_state != state) {
  71. //wdinfo->pre_p2p_state = wdinfo->p2p_state;
  72. wdinfo->p2p_state = state;
  73. }
  74. }
  75. static inline void _rtw_p2p_set_pre_state(struct wifidirect_info *wdinfo, enum P2P_STATE state)
  76. {
  77. if(wdinfo->pre_p2p_state != state) {
  78. wdinfo->pre_p2p_state = state;
  79. }
  80. }
  81. #if 0
  82. static inline void _rtw_p2p_restore_state(struct wifidirect_info *wdinfo)
  83. {
  84. if(wdinfo->pre_p2p_state != -1) {
  85. wdinfo->p2p_state = wdinfo->pre_p2p_state;
  86. wdinfo->pre_p2p_state = -1;
  87. }
  88. }
  89. #endif
  90. static inline void _rtw_p2p_set_role(struct wifidirect_info *wdinfo, enum P2P_ROLE role)
  91. {
  92. if(wdinfo->role != role) {
  93. wdinfo->role = role;
  94. }
  95. }
  96. static inline int _rtw_p2p_state(struct wifidirect_info *wdinfo)
  97. {
  98. return wdinfo->p2p_state;
  99. }
  100. static inline int _rtw_p2p_pre_state(struct wifidirect_info *wdinfo)
  101. {
  102. return wdinfo->pre_p2p_state;
  103. }
  104. static inline int _rtw_p2p_role(struct wifidirect_info *wdinfo)
  105. {
  106. return wdinfo->role;
  107. }
  108. static inline bool _rtw_p2p_chk_state(struct wifidirect_info *wdinfo, enum P2P_STATE state)
  109. {
  110. return wdinfo->p2p_state == state;
  111. }
  112. static inline bool _rtw_p2p_chk_role(struct wifidirect_info *wdinfo, enum P2P_ROLE role)
  113. {
  114. return wdinfo->role == role;
  115. }
  116. #ifdef CONFIG_DBG_P2P
  117. void dbg_rtw_p2p_set_state(struct wifidirect_info *wdinfo, enum P2P_STATE state, const char *caller, int line);
  118. void dbg_rtw_p2p_set_pre_state(struct wifidirect_info *wdinfo, enum P2P_STATE state, const char *caller, int line);
  119. //void dbg_rtw_p2p_restore_state(struct wifidirect_info *wdinfo, const char *caller, int line);
  120. void dbg_rtw_p2p_set_role(struct wifidirect_info *wdinfo, enum P2P_ROLE role, const char *caller, int line);
  121. #define rtw_p2p_set_state(wdinfo, state) dbg_rtw_p2p_set_state(wdinfo, state, __FUNCTION__, __LINE__)
  122. #define rtw_p2p_set_pre_state(wdinfo, state) dbg_rtw_p2p_set_pre_state(wdinfo, state, __FUNCTION__, __LINE__)
  123. #define rtw_p2p_set_role(wdinfo, role) dbg_rtw_p2p_set_role(wdinfo, role, __FUNCTION__, __LINE__)
  124. //#define rtw_p2p_restore_state(wdinfo) dbg_rtw_p2p_restore_state(wdinfo, __FUNCTION__, __LINE__)
  125. #else //CONFIG_DBG_P2P
  126. #define rtw_p2p_set_state(wdinfo, state) _rtw_p2p_set_state(wdinfo, state)
  127. #define rtw_p2p_set_pre_state(wdinfo, state) _rtw_p2p_set_pre_state(wdinfo, state)
  128. #define rtw_p2p_set_role(wdinfo, role) _rtw_p2p_set_role(wdinfo, role)
  129. //#define rtw_p2p_restore_state(wdinfo) _rtw_p2p_restore_state(wdinfo)
  130. #endif //CONFIG_DBG_P2P
  131. #define rtw_p2p_state(wdinfo) _rtw_p2p_state(wdinfo)
  132. #define rtw_p2p_pre_state(wdinfo) _rtw_p2p_pre_state(wdinfo)
  133. #define rtw_p2p_role(wdinfo) _rtw_p2p_role(wdinfo)
  134. #define rtw_p2p_chk_state(wdinfo, state) _rtw_p2p_chk_state(wdinfo, state)
  135. #define rtw_p2p_chk_role(wdinfo, role) _rtw_p2p_chk_role(wdinfo, role)
  136. #define rtw_p2p_findphase_ex_set(wdinfo, value) \
  137. (wdinfo)->find_phase_state_exchange_cnt = (value)
  138. //is this find phase exchange for social channel scan?
  139. #define rtw_p2p_findphase_ex_is_social(wdinfo) \
  140. (wdinfo)->find_phase_state_exchange_cnt >= P2P_FINDPHASE_EX_SOCIAL_FIRST
  141. //should we need find phase exchange anymore?
  142. #define rtw_p2p_findphase_ex_is_needed(wdinfo) \
  143. ((wdinfo)->find_phase_state_exchange_cnt < P2P_FINDPHASE_EX_MAX && \
  144. (wdinfo)->find_phase_state_exchange_cnt != P2P_FINDPHASE_EX_NONE)
  145. #endif