1 /*
2 * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 * Description: hmac_p2p.c 的头文件.
15 */
16
17 #ifndef __HMAC_P2P_H__
18 #define __HMAC_P2P_H__
19
20 #include "hmac_fsm.h"
21
22 #ifdef __cplusplus
23 #if __cplusplus
24 extern "C" {
25 #endif
26 #endif
27
28 #undef THIS_FILE_ID
29 #define THIS_FILE_ID OAM_FILE_ID_HMAC_P2P_H
30
31 #ifdef _PRE_WLAN_FEATURE_P2P
32 /*****************************************************************************
33 1 其他头文件包含
34 *****************************************************************************/
35
36 /*****************************************************************************
37 2 宏定义
38 *****************************************************************************/
39 #define HMAC_P2P_WILDCARD_SSID "DIRECT-"
40 #define HMAC_P2P_WILDCARD_SSID_LEN 7
41
42 #define P2P_NOA_DESC_NUM 1
43
44
45 /*****************************************************************************
46 3 枚举定义
47 *****************************************************************************/
48 /* p2p 状态码 */
49 typedef enum {
50 P2P_STATUS_DISCOVERY_ON = 0,
51 P2P_STATUS_SEARCH_ENABLED,
52 P2P_STATUS_IF_ADD,
53 P2P_STATUS_IF_DEL,
54 P2P_STATUS_IF_DELETING,
55 P2P_STATUS_IF_CHANGING,
56 P2P_STATUS_IF_CHANGED,
57 P2P_STATUS_LISTEN_EXPIRED,
58 P2P_STATUS_ACTION_TX_COMPLETED,
59 P2P_STATUS_ACTION_TX_NOACK,
60 P2P_STATUS_SCANNING,
61 P2P_STATUS_GO_NEG_PHASE,
62 P2P_STATUS_DISC_IN_PROGRESS
63 } hmac_cfgp2p_status_enum;
64 typedef osal_u32 hmac_cfgp2p_status_enum_uint32;
65
66 typedef enum {
67 P2P_PM_AWAKE_STATE = 0,
68 P2P_PM_SLEEP_STATE = 1
69 } p2p_pm_state_enum;
70
71 /*****************************************************************************
72 5 内联函数
73 *****************************************************************************/
is_p2p_wildcard_ssid(const osal_u8 * ssid,osal_u8 len)74 static INLINE__ osal_u8 is_p2p_wildcard_ssid(const osal_u8 *ssid, osal_u8 len)
75 {
76 return ((len == HMAC_P2P_WILDCARD_SSID_LEN) &&
77 !oal_memcmp(ssid, HMAC_P2P_WILDCARD_SSID, HMAC_P2P_WILDCARD_SSID_LEN));
78 }
79
is_p2p_oppps_enabled(const hmac_vap_stru * hmac_vap)80 static INLINE__ osal_u8 is_p2p_oppps_enabled(const hmac_vap_stru *hmac_vap)
81 {
82 return (hmac_vap->p2p_ops_param.ops_ctrl != 0);
83 }
84
is_p2p_noa_enabled(const hmac_vap_stru * hmac_vap)85 static INLINE__ osal_u8 is_p2p_noa_enabled(const hmac_vap_stru *hmac_vap)
86 {
87 return (hmac_vap->p2p_noa_param.count != 0);
88 }
89
is_p2p_ps_enabled(const hmac_vap_stru * hmac_vap)90 static INLINE__ osal_u8 is_p2p_ps_enabled(const hmac_vap_stru *hmac_vap)
91 {
92 return (is_p2p_oppps_enabled(hmac_vap) || is_p2p_noa_enabled(hmac_vap));
93 }
94
get_attr_len(const osal_u8 * buf)95 static INLINE__ osal_u16 get_attr_len(const osal_u8 *buf)
96 {
97 return oal_make_word16(buf[1], buf[2]);
98 }
99
100 /*****************************************************************************
101 10 函数声明
102 *****************************************************************************/
103 wlan_p2p_mode_enum_uint8 hmac_get_p2p_mode_etc(const hmac_vap_stru *hmac_vap);
104 void hmac_dec_p2p_num_etc(hmac_vap_stru *hmac_vap);
105 void hmac_inc_p2p_num_etc(hmac_vap_stru *hmac_vap);
106 osal_s32 hmac_set_p2p_common_info(hmac_vap_stru *hmac_vap, frw_msg *msg);
107 osal_u8 hmac_get_p2p_protocol_info(osal_void);
108 osal_u8 hmac_get_p2p_common_band_info(osal_void);
109 osal_u8 hmac_get_p2p_common_enable_info(osal_void);
110 extern osal_u32 hmac_p2p_send_listen_expired_to_host_etc(hmac_vap_stru *hmac_vap);
111 extern osal_u32 hmac_p2p_send_listen_expired_to_device_etc(hmac_vap_stru *hmac_vap);
112 extern osal_u32 hmac_p2p_check_can_enter_state_etc(hmac_vap_stru *hmac_vap,
113 hmac_fsm_input_type_enum_uint8 input_req);
114 extern osal_void hmac_disable_p2p_pm_etc(hmac_vap_stru *hmac_vap);
115 osal_void mac_set_p2p_none_noa(const hmac_vap_stru *hmac_vap, osal_u8 *buffer, osal_u8 *ie_len);
116 osal_u8 hmac_p2p_listen_rx_mgmt(hmac_vap_stru *hmac_vap, oal_netbuf_stru *netbuf);
117 oal_bool_enum_uint8 hmac_is_p2p_go_neg_req_frame(const osal_u8* data);
118 oal_bool_enum_uint8 hmac_is_p2p_pd_disc_req_frame(const osal_u8 *data);
119 oal_bool_enum_uint8 hmac_is_p2p_presence_req_frame(const osal_u8 *data);
120 osal_u32 hmac_p2p_listen_filter_vap(const hmac_vap_stru *hmac_vap);
121 osal_u32 hmac_p2p_listen_filter_frame(const hmac_vap_stru *hmac_vap, osal_u8 *frame_body, osal_u16 frame_len);
122 osal_void hmac_process_p2p_noa(hmac_vap_stru *hmac_vap, oal_netbuf_stru *netbuf);
123 osal_u8 *hmac_get_p2p_noa_attr(osal_u8 *frame_body, osal_u16 rx_len, osal_u16 tag_param_offset, osal_u16 *attr_len);
124 osal_void hmac_p2p_oppps_ctwindow_start_event(hmac_vap_stru *hmac_vap);
125 osal_u32 hmac_send_p2p_state_to_device(hmac_vap_stru *hmac_vap,
126 oal_bool_enum_uint8 pause, wlan_vap_mode_enum_uint8 mode);
127 oal_bool_enum_uint8 hmac_is_p2p_action_frame(const osal_u8 *data);
128 osal_s32 hmac_p2p_opps_info_event(hmac_vap_stru *hmac_vap, frw_msg *msg);
129 oal_bool_enum_uint8 hmac_is_p2p_ie(const osal_u8 *data);
130 osal_void mac_set_p2p0_ssid_ie(const hmac_vap_stru *hmac_vap, osal_u8 *buffer, osal_u8 *ie_len, osal_u16 frm_type);
131 osal_void mac_set_p2p_noa(hmac_vap_stru *hmac_vap, osal_u8 *buffer, osal_u8 *e_len);
132 osal_void mac_set_p2p_status(osal_u8 *buffer, osal_u8 *ie_len, p2p_status_code_t status);
133 osal_void hmac_p2p_handle_ps(hmac_vap_stru *hmac_vap, oal_bool_enum_uint8 pause);
134 osal_u32 hmac_process_p2p_presence_req(hmac_vap_stru *hmac_vap, oal_netbuf_stru *netbuf);
135 osal_u16 hmac_mgmt_encap_p2p_presence_rsp(hmac_vap_stru *hmac_vap, oal_netbuf_stru *netbuf,
136 const osal_u8 *ra, const osal_u8 *data);
137 osal_u32 hmac_p2p_event_sync2device(hmac_vap_stru *hmac_vap, osal_u8 type);
138 extern osal_u8 hmac_get_p2p_status_etc(osal_u32 p2p_status, hmac_cfgp2p_status_enum_uint32 status);
139 extern osal_void hmac_set_p2p_status_etc(osal_u32 *pul_p2p_status, hmac_cfgp2p_status_enum_uint32 status);
140 osal_s32 hmac_config_cancel_remain_on_channel(hmac_vap_stru *hmac_vap);
141 osal_s32 hmac_config_set_p2p_ps_noa(hmac_vap_stru *hmac_vap, mac_cfg_p2p_noa_param_stru *p2p_noa);
142 osal_s32 hmac_config_set_p2p_ps_ops(hmac_vap_stru *hmac_vap, mac_cfg_p2p_ops_param_stru *p2p_ops);
143 osal_s32 hmac_config_set_p2p_noa_adapt(hmac_vap_stru *hmac_vap, frw_msg *msg);
144 osal_u32 hmac_p2p_remain_on_channel_etc(hmac_vap_stru *hmac_vap_sta, osal_void *p_param);
145 osal_u32 hmac_p2p_listen_timeout_etc(hmac_vap_stru *hmac_vap, osal_void *p_param);
146 osal_s32 hmac_config_remain_on_channel_etc(hmac_vap_stru *hmac_vap, frw_msg *msg);
147 osal_s32 hmac_config_cancel_remain_on_channel_etc(hmac_vap_stru *hmac_vap, frw_msg *msg);
148 #endif /* _PRE_WLAN_FEATURE_P2P */
149
150 #ifdef __cplusplus
151 #if __cplusplus
152 }
153 #endif
154 #endif
155
156 #endif /* end of hmac_p2p.h */
157