1 /*
2 * Copyright (C) 2021 HiSilicon (Shanghai) Technologies CO., LIMITED.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18
19 /* ****************************************************************************
20 1 头文件包含
21 **************************************************************************** */
22 #include "hmac_sme_sta.h"
23 #include "mac_regdomain.h"
24 #include "hmac_main.h"
25 #include "hmac_fsm.h"
26 #include "hmac_mgmt_sta.h"
27 #include "hmac_device.h"
28 #include "hmac_scan.h"
29 #include "hmac_p2p.h"
30 #include "hmac_sme_sta.h"
31 #include "hcc_hmac_if.h"
32 #include "wal_customize.h"
33 #include "hmac_event.h"
34
35 #ifdef __cplusplus
36 #if __cplusplus
37 extern "C" {
38 #endif
39 #endif
40
41 /* ****************************************************************************
42 2 全局变量定义
43 **************************************************************************** */
44 /* ****************************************************************************
45 g_handle_rsp_func_sta: 处理发给sme的消息
46 **************************************************************************** */
47 static hmac_sme_handle_rsp_func g_handle_rsp_func_sta[HMAC_SME_RSP_BUTT] = {
48 hmac_handle_scan_rsp_sta,
49 hmac_handle_join_rsp_sta,
50 hmac_handle_auth_rsp_sta,
51 hmac_handle_asoc_rsp_sta,
52 };
53
54 /* ****************************************************************************
55 3 函数实现
56 **************************************************************************** */
57 /* ****************************************************************************
58 功能描述 : wpa_supplicant下发的扫描请求的回调函数,用于对扫描完成时对结果的处理
59 输入参数 : *p_scan_record,扫描记录,包括扫描发起者信息和扫描结果
60 修改历史 :
61 1.日 期 : 2015年5月20日
62 作 者 : HiSilicon
63 修改内容 : 新生成函数
64 **************************************************************************** */
hmac_process_scan_complete_event(hi_void * scan_record)65 static hi_void hmac_process_scan_complete_event(hi_void *scan_record)
66 {
67 hmac_scan_record_stru *scan_record_value = (hmac_scan_record_stru *)scan_record;
68 hmac_vap_stru *hmac_vap = HI_NULL;
69 hmac_scan_rsp_stru scan_rsp;
70
71 /* 获取hmac vap */
72 hmac_vap = hmac_vap_get_vap_stru(scan_record_value->vap_id);
73 if (hmac_vap == HI_NULL) {
74 oam_error_log0(0, OAM_SF_SCAN, "{hmac_process_scan_complete_event::pst_hmac_vap is null.");
75 return;
76 }
77
78 /* 上报扫描结果结构体初始化 */
79 if (memset_s(&scan_rsp, sizeof(scan_rsp), 0, sizeof(scan_rsp)) != EOK) {
80 return;
81 }
82
83 scan_rsp.result_code = scan_record_value->scan_rsp_status;
84
85 /* 扫描结果发给sme */
86 hmac_send_rsp_to_sme_sta(hmac_vap, HMAC_SME_SCAN_RSP, (hi_u8 *)&scan_rsp);
87
88 return;
89 }
90
hmac_set_scan_req_ssid(mac_scan_req_stru * mac_scan_req,const mac_cfg80211_scan_param_stru * scan_param)91 static hi_u32 hmac_set_scan_req_ssid(mac_scan_req_stru *mac_scan_req, const mac_cfg80211_scan_param_stru *scan_param)
92 {
93 hi_u8 loop;
94 /* 如果上层下发了指定ssid,则每次扫描发送的probe req帧的个数为下发的ssid个数 */
95 for (loop = 0; loop < scan_param->l_ssid_num; loop++) {
96 if (loop >= WLAN_SCAN_REQ_MAX_BSS) {
97 break;
98 }
99
100 if (scan_param->ssids[loop].auc_ssid[0] == '\0') {
101 continue;
102 }
103
104 if (memcpy_s(mac_scan_req->ac_ssid[loop], sizeof(mac_scan_req->ac_ssid[loop]),
105 scan_param->ssids[loop].auc_ssid, scan_param->ssids[loop].ssid_len) != EOK) {
106 oam_error_log0(0, OAM_SF_CFG, "hmac_set_can_req_ssid::fail to copy ssid to hmac.");
107 return HI_FAIL;
108 }
109 mac_scan_req->ac_ssid[loop][scan_param->ssids[loop].ssid_len] = '\0'; /* ssid末尾置'\0' */
110 }
111 mac_scan_req->max_send_probe_cnt_per_channel = loop;
112
113 return HI_SUCCESS;
114 }
115
hmac_set_scan_req_channel_param(const mac_vap_stru * mac_vap,mac_scan_req_stru * mac_scan_req,const mac_cfg80211_scan_param_stru * cfg80211_scan_param)116 static hi_void hmac_set_scan_req_channel_param(const mac_vap_stru *mac_vap, mac_scan_req_stru *mac_scan_req,
117 const mac_cfg80211_scan_param_stru *cfg80211_scan_param)
118 {
119 hmac_device_stru *hmac_dev = HI_NULL;
120 hmac_scan_stru *scan_mgmt = HI_NULL;
121 hi_u8 loop;
122 hi_u8 channel_number;
123 hi_u8 channel_idx = 0;
124 hi_u8 chan_num_2g = 0;
125 hi_u32 ret;
126
127 /* 设置扫描信道 */
128 /* 每次发起扫描的时候先将对应的信道map置0 */
129 hmac_dev = hmac_get_device_stru();
130 scan_mgmt = &(hmac_dev->scan_mgmt);
131 scan_mgmt->scan_2g_ch_list_map = 0;
132
133 for (loop = 0; loop < cfg80211_scan_param->num_channels_2_g; loop++) {
134 channel_number = (hi_u8)cfg80211_scan_param->pul_channels_2_g[loop];
135
136 /* 判断信道是不是在管制域内 */
137 ret = mac_is_channel_num_valid(WLAN_BAND_2G, channel_number);
138 if (ret == HI_SUCCESS) {
139 ret = mac_get_channel_idx_from_num(WLAN_BAND_2G, channel_number, &channel_idx);
140 if (ret != HI_SUCCESS) {
141 oam_warning_log1(mac_vap->vap_id, OAM_SF_SCAN,
142 "{WLAN_BAND_2G::hmac_set_scan_req_channel_param::mac_get_channel_idx fail. channel_number: %u.}",
143 channel_number);
144 }
145
146 mac_scan_req->ast_channel_list[chan_num_2g].band = WLAN_BAND_2G;
147 mac_scan_req->ast_channel_list[chan_num_2g].chan_number = channel_number;
148 mac_scan_req->ast_channel_list[chan_num_2g].idx = channel_idx;
149 mac_scan_req->ast_channel_list[chan_num_2g].en_bandwidth = mac_vap->channel.en_bandwidth;
150 /* 将请求的扫描信道对应的bit位置1 */
151 scan_mgmt->scan_2g_ch_list_map |= (BIT0 << channel_number);
152
153 mac_scan_req->channel_nums++;
154 chan_num_2g++;
155 }
156 }
157
158 /* 设置信道扫描时间 */
159 mac_scan_req->us_scan_time =
160 (mac_scan_req->scan_type == WLAN_SCAN_TYPE_ACTIVE) ? WLAN_ACTIVE_SCAN_TIME : WLAN_PASSIVE_SCAN_TIME;
161 #ifdef _PRE_WLAN_FEATURE_MESH
162 if (mac_vap->vap_mode == WLAN_VAP_MODE_MESH) {
163 /* 普通Mesh扫描 */
164 mac_scan_req->us_scan_time = WLAN_ACTIVE_SCAN_TIME;
165 mac_scan_req->max_scan_cnt_per_channel = FGSCAN_SCAN_CNT_PER_CHANNEL;
166 }
167 #endif
168 }
169 /* ****************************************************************************
170 功能描述 : 解析内核下发的扫描命令参数
171 修改历史 :
172 1.日 期 : 2013年9月10日
173 作 者 : HiSilicon
174 修改内容 : 新生成函数
175 **************************************************************************** */
hmac_encap_scan_req(const mac_vap_stru * mac_vap,mac_scan_req_stru * mac_scan_req,hi_s8 * puc_param)176 static hi_u32 hmac_encap_scan_req(const mac_vap_stru *mac_vap, mac_scan_req_stru *mac_scan_req, hi_s8 *puc_param)
177 {
178 mac_cfg80211_scan_param_stru *cfg80211_scan_param = HI_NULL;
179 #ifdef _PRE_WLAN_FEATURE_P2P
180 mac_device_stru *mac_dev = HI_NULL;
181 mac_vap_stru *mac_vap_temp = HI_NULL;
182 #endif
183 hi_u8 scan_when_go_up = HI_FALSE;
184 const hi_u8 *bcast_mac_addr = mac_get_mac_bcast_addr();
185
186 cfg80211_scan_param = (mac_cfg80211_scan_param_stru *)puc_param;
187
188 mac_scan_req->bss_type = WLAN_MIB_DESIRED_BSSTYPE_INFRA;
189 mac_scan_req->scan_type = cfg80211_scan_param->scan_type;
190 mac_scan_req->scan_func = MAC_SCAN_FUNC_BSS; /* 默认扫描bss */
191 mac_scan_req->fn_cb = hmac_process_scan_complete_event; /* 扫描完成回调函数 */
192 mac_scan_req->max_scan_cnt_per_channel = 2; /* channel赋值为2 */
193
194 #ifdef _PRE_WLAN_FEATURE_P2P
195 /* p2p Go发起扫描时,会使用p2p device设备进行 */
196 mac_dev = mac_res_get_dev();
197 if (WLAN_P2P_DEV_MODE == mac_vap->p2p_mode) {
198 if ((mac_device_find_up_p2p_go(mac_dev, &mac_vap_temp) == HI_SUCCESS) && (mac_vap_temp != HI_NULL)) {
199 scan_when_go_up = HI_TRUE;
200 }
201 }
202 #endif /* _PRE_WLAN_FEATURE_P2P */
203
204 if (scan_when_go_up == HI_TRUE || mac_vap->vap_state == MAC_VAP_STATE_UP ||
205 mac_vap->vap_state == MAC_VAP_STATE_PAUSE ||
206 (mac_vap->vap_state == MAC_VAP_STATE_STA_LISTEN && mac_vap->user_nums > 0)) {
207 mac_scan_req->max_scan_cnt_per_channel = 1;
208 }
209 /* 如果是指定信道背景扫描每个信道扫两次,适配对端是dbac场景 */
210 if (mac_vap->vap_state == MAC_VAP_STATE_UP && cfg80211_scan_param->num_channels_2_g == 1) {
211 mac_scan_req->max_scan_cnt_per_channel = FGSCAN_SCAN_CNT_PER_CHANNEL;
212 }
213 /* 设置ssid 和每次发送扫描请求帧的个数 */
214 if (hmac_set_scan_req_ssid(mac_scan_req, cfg80211_scan_param) != HI_SUCCESS) {
215 return HI_FAIL;
216 }
217
218 /* 设置广播MAC地址 */
219 if (memcpy_s(mac_scan_req->auc_bssid[0], WLAN_MAC_ADDR_LEN, bcast_mac_addr, WLAN_MAC_ADDR_LEN) != EOK) {
220 oam_error_log0(0, OAM_SF_CFG, "hmac_encap_scan_req::fail to set broadcast MAC address.");
221 return HI_FAIL;
222 }
223
224 /* 设置扫描信道相关信息 */
225 hmac_set_scan_req_channel_param(mac_vap, mac_scan_req, cfg80211_scan_param);
226
227 #ifdef _PRE_WLAN_FEATURE_P2P
228 /* WLAN/P2P 共存时,判断是否p2p0 发起扫描 */
229 mac_scan_req->is_p2p0_scan = cfg80211_scan_param->is_p2p0_scan;
230 if (cfg80211_scan_param->is_p2p0_scan) {
231 mac_scan_req->bss_type = 0;
232 }
233 #endif /* _PRE_WLAN_FEATURE_P2P */
234 return HI_SUCCESS;
235 }
236
237 /* ****************************************************************************
238 功能描述 : 准备加入请求
239 修改历史 :
240 1.日 期 : 2013年7月1日
241 作 者 : HiSilicon
242 修改内容 : 新生成函数
243 **************************************************************************** */
hmac_prepare_join_req(hmac_join_req_stru * join_req,const mac_bss_dscr_stru * bss_dscr)244 static hi_void hmac_prepare_join_req(hmac_join_req_stru *join_req, const mac_bss_dscr_stru *bss_dscr)
245 {
246 if (memset_s(join_req, sizeof(hmac_join_req_stru), 0, sizeof(hmac_join_req_stru)) != EOK) {
247 return;
248 }
249
250 if (memcpy_s(&(join_req->bss_dscr), sizeof(mac_bss_dscr_stru), bss_dscr, sizeof(mac_bss_dscr_stru)) != EOK) {
251 oam_error_log0(0, OAM_SF_CFG, "hmac_prepare_join_req:: pst_bss_dscr memcpy_s fail.");
252 return;
253 }
254
255 join_req->us_join_timeout = WLAN_JOIN_START_TIMEOUT;
256 join_req->us_probe_delay = 0; /* 未使用 后续整改删除 */
257 }
258
259 /* ****************************************************************************
260 功能描述 : 准备认证请求
261 修改历史 :
262 1.日 期 : 2013年7月1日
263 作 者 : HiSilicon
264 修改内容 : 新生成函数
265 **************************************************************************** */
hmac_prepare_auth_req(const mac_vap_stru * mac_vap,hi_u16 * auth_timeout)266 static hi_void hmac_prepare_auth_req(const mac_vap_stru *mac_vap, hi_u16 *auth_timeout)
267 {
268 /* 适配对端是dbac的场景,增加认证超时时间 */
269 *auth_timeout = (hi_u16)(mac_vap->mib_info->wlan_mib_sta_config.dot11_authentication_response_time_out << 1);
270 }
271
272 /* ****************************************************************************
273 功能描述 : 准备关联请求
274 修改历史 :
275 1.日 期 : 2013年7月1日
276 作 者 : HiSilicon
277 修改内容 : 新生成函数
278 **************************************************************************** */
hmac_prepare_asoc_req(const mac_vap_stru * mac_vap,hi_u16 * us_assoc_timeout)279 static hi_void hmac_prepare_asoc_req(const mac_vap_stru *mac_vap, hi_u16 *us_assoc_timeout)
280 {
281 /* 适配对端是dbac场景,增加关联时间 */
282 *us_assoc_timeout = (hi_u16)mac_vap->mib_info->wlan_mib_sta_config.dot11_association_response_time_out;
283 }
284
285 #if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
286 /* ****************************************************************************
287 功能描述 : 检测是否可以启动调度扫描
288 修改历史 :
289 1.日 期 : 2015年6月9日
290 作 者 : HiSilicon
291 修改内容 : 新生成函数
292 **************************************************************************** */
hmac_is_sched_scan_allowed(const mac_vap_stru * mac_vap)293 static hi_u8 hmac_is_sched_scan_allowed(const mac_vap_stru *mac_vap)
294 {
295 hmac_device_stru *hmac_dev = hmac_get_device_stru();
296 mac_device_stru *mac_dev = mac_res_get_dev();
297 mac_vap_stru *mac_vap_tmp = HI_NULL;
298
299 /* 如果vap的模式不是STA,则返回,不支持其它模式的vap的调度扫描 */
300 if (mac_vap->vap_mode != WLAN_VAP_MODE_BSS_STA) {
301 oam_warning_log1(mac_vap->vap_id, OAM_SF_SCAN,
302 "{hmac_is_sched_scan_allowed::vap mode[%d] don't support sched scan.}", mac_vap->vap_mode);
303
304 hmac_dev->scan_mgmt.sched_scan_req = HI_NULL;
305 hmac_dev->scan_mgmt.sched_scan_complete = HI_TRUE;
306 return HI_FALSE;
307 }
308
309 /* 如果存在当前device存在up的vap,则不启动调度扫描 */
310 mac_device_find_up_vap(mac_dev, &mac_vap_tmp);
311 if (mac_vap_tmp != HI_NULL) {
312 oam_warning_log0(mac_vap->vap_id, OAM_SF_SCAN,
313 "{hmac_is_sched_scan_allowed::exist up vap, don't start sched scan.}");
314 hmac_dev->scan_mgmt.sched_scan_req = HI_NULL;
315 hmac_dev->scan_mgmt.sched_scan_complete = HI_TRUE;
316 return HI_FALSE;
317 }
318
319 return HI_TRUE;
320 }
321
322 /* ****************************************************************************
323 功能描述 : 根据内核下发命令启动扫描
324 修改历史 :
325 1.日 期 : 2015年6月9日
326 作 者 : HiSilicon
327 修改内容 : 新生成函数
328 **************************************************************************** */
hmac_start_sched_scan(mac_vap_stru * mac_vap,hi_u16 us_len,const hi_u8 * puc_param)329 hi_u32 hmac_start_sched_scan(mac_vap_stru *mac_vap, hi_u16 us_len, const hi_u8 *puc_param)
330 {
331 mac_pno_scan_stru pno_scan_params;
332 hi_u32 ret = HI_FAIL;
333 hmac_device_stru *hmac_dev = HI_NULL;
334
335 hi_unref_param(us_len);
336 /* 参数合法性检查 */
337 if (oal_unlikely(mac_vap == HI_NULL) || oal_unlikely(puc_param == HI_NULL)) {
338 oam_error_log2(0, OAM_SF_SCAN, "{hmac_start_sched_scan::input null %p %p.}", (uintptr_t)mac_vap,
339 (uintptr_t)puc_param);
340 return HI_ERR_CODE_PTR_NULL;
341 }
342
343 /* 上层传的是地址,因此需要取值获取到真正的pno扫描参数所在的地址 */
344 mac_pno_scan_stru *cfg80211_pno_scan_params = (mac_pno_scan_stru *)(*(uintptr_t *)puc_param);
345
346 /* 获取hmac vap */
347 hmac_vap_stru *hmac_vap = hmac_vap_get_vap_stru(mac_vap->vap_id);
348 if (oal_unlikely(hmac_vap == HI_NULL)) {
349 oam_warning_log0(mac_vap->vap_id, OAM_SF_SCAN, "{hmac_start_sched_scan::pst_hmac_vap null.}");
350
351 oal_mem_free(cfg80211_pno_scan_params);
352 return HI_ERR_CODE_PTR_NULL;
353 }
354 /* 获取hmac device */
355 hmac_dev = hmac_get_device_stru();
356 /* 拷贝上层下发的pno扫描参数 */
357 if (memcpy_s(&pno_scan_params, sizeof(mac_pno_scan_stru), cfg80211_pno_scan_params,
358 sizeof(mac_pno_scan_stru)) != EOK) {
359 oam_error_log0(0, OAM_SF_CFG, "hmac_start_sched_scan:: pst_cfg80211_pno_scan_params memcpy_s fail.");
360 return HI_FAIL;
361 }
362
363 /* 释放本地内存池的内存 */
364 oal_mem_free(cfg80211_pno_scan_params);
365
366 /* 检测当前device是否可以启动调度扫描 */
367 if (hmac_is_sched_scan_allowed(mac_vap) != HI_TRUE) {
368 return HI_FAIL;
369 }
370
371 /* 设置PNO调度扫描结束时,如果有结果上报,则上报扫描结果的回调函数 */
372 pno_scan_params.fn_cb = hmac_process_scan_complete_event;
373 /* 设置发送的probe req帧中源mac addr */
374 pno_scan_params.is_random_mac_addr_scan = hmac_dev->scan_mgmt.is_random_mac_addr_scan;
375 hmac_scan_set_sour_mac_addr_in_probe_req(hmac_vap, pno_scan_params.auc_sour_mac_addr, WLAN_MAC_ADDR_LEN,
376 pno_scan_params.is_random_mac_addr_scan, HI_FALSE);
377
378 /* 状态机调用 */
379 switch (hmac_vap->base_vap->vap_state) {
380 case MAC_VAP_STATE_STA_FAKE_UP:
381 case MAC_VAP_STATE_STA_SCAN_COMP:
382 ret = hmac_scan_proc_sched_scan_req_event(hmac_vap, &pno_scan_params);
383 break;
384 default:
385 break;
386 }
387 if (ret != HI_SUCCESS) {
388 oam_warning_log1(mac_vap->vap_id, OAM_SF_SCAN, "{hmac_start_sched_scan::process scan req fail[%d].}", ret);
389 hmac_dev->scan_mgmt.sched_scan_req = HI_NULL;
390 hmac_dev->scan_mgmt.sched_scan_complete = HI_TRUE;
391 }
392
393 return ret;
394 }
395
396 /* ****************************************************************************
397 功能描述 : 根据内核下发命令停止PNO调度扫描
398 修改历史 :
399 1.日 期 : 2015年6月9日
400 作 者 : HiSilicon
401 修改内容 : 新生成函数
402 **************************************************************************** */
hmac_stop_sched_scan(mac_vap_stru * mac_vap,hi_u16 us_len,const hi_u8 * puc_param)403 hi_u32 hmac_stop_sched_scan(mac_vap_stru *mac_vap, hi_u16 us_len, const hi_u8 *puc_param)
404 {
405 hi_u32 ret;
406
407 /* **************************************************************************
408 抛事件到DMAC层, 同步DMAC数据
409 ************************************************************************** */
410 ret = hmac_config_send_event(mac_vap, WLAN_CFGID_STOP_SCHED_SCAN, us_len, puc_param);
411 if (oal_unlikely(ret != HI_SUCCESS)) {
412 oam_warning_log1(mac_vap->vap_id, OAM_SF_CFG,
413 "{hmac_stop_sched_scan::hmac_config_send_event failed[%d].}", ret);
414 return ret;
415 }
416
417 return HI_SUCCESS;
418 }
419 #endif
420
421 /* ****************************************************************************
422 功能描述 : 根据内核下发命令启动扫描
423 修改历史 :
424 1.日 期 : 2013年9月10日
425 作 者 : HiSilicon
426 修改内容 : 新生成函数
427 **************************************************************************** */
hmac_process_scan_req(mac_vap_stru * mac_vap,hi_u16 us_len,const hi_u8 * puc_param)428 hi_u32 hmac_process_scan_req(mac_vap_stru *mac_vap, hi_u16 us_len, const hi_u8 *puc_param)
429 {
430 mac_scan_req_stru mac_scan_req = { 0 };
431 mac_cfg80211_scan_param_stru *scan_param = HI_NULL;
432 oal_app_ie_stru user_ie;
433
434 hi_unref_param(us_len);
435
436 if (oal_unlikely(puc_param == HI_NULL) || oal_unlikely(mac_vap == HI_NULL)) {
437 oam_error_log0(0, OAM_SF_SCAN, "{hmac_process_scan_req::paramter is null, fail to scan.}");
438 return HI_ERR_CODE_PTR_NULL;
439 }
440
441 mac_cfg80211_scan_param_pst_stru *cfg80211_scan_param_pst = (mac_cfg80211_scan_param_pst_stru *)puc_param;
442 scan_param = cfg80211_scan_param_pst->mac_cfg80211_scan_param;
443 if (oal_unlikely(scan_param == HI_NULL)) {
444 return HI_ERR_CODE_PTR_NULL;
445 }
446
447 /* 将内核下发的扫描参数更新到驱动扫描请求结构体中 */
448 if (hmac_encap_scan_req(mac_vap, &mac_scan_req, (hi_s8 *)scan_param) != HI_SUCCESS) {
449 return HI_FAIL;
450 }
451
452 #ifdef _PRE_WLAN_FEATURE_P2P
453 if (is_legacy_vap(mac_vap)) {
454 hmac_p2p_del_ie((hi_u8 *)(scan_param->puc_ie), &(scan_param->ie_len));
455 }
456
457 /* P2P0 扫描时记录P2P listen channel */
458 if (scan_param->is_p2p0_scan == HI_TRUE) {
459 hmac_p2p_find_listen_channel(mac_vap, (hi_u16)(scan_param->ie_len), (hi_u8 *)(scan_param->puc_ie));
460 mac_scan_req.p2p0_listen_channel = mac_vap->p2p_listen_channel;
461 }
462
463 #endif
464 user_ie.ie_len = scan_param->ie_len;
465
466 if ((scan_param->puc_ie != HI_NULL) && (user_ie.ie_len != 0)) {
467 if (memcpy_s(user_ie.auc_ie, WLAN_WPS_IE_MAX_SIZE, scan_param->puc_ie, user_ie.ie_len) != EOK) {
468 oam_error_log0(0, OAM_SF_SCAN, "{hmac_process_scan_req::fail to copy scan ie to hmac.}");
469 return HI_FAIL;
470 }
471 }
472 user_ie.app_ie_type = OAL_APP_PROBE_REQ_IE;
473 if (hmac_config_set_app_ie_to_vap(mac_vap, &user_ie, user_ie.app_ie_type) != HI_SUCCESS) {
474 oam_warning_log0(0, OAM_SF_SCAN, "hmac_config_set_app_ie_to_vap return NON SUCCESS. ");
475 }
476
477 return hmac_fsm_handle_scan_req(mac_vap, &mac_scan_req);
478 }
479
480 /* ****************************************************************************
481 功能描述 : 发起加入
482 修改历史 :
483 1.日 期 : 2013年7月1日
484 作 者 : HiSilicon
485 修改内容 : 新生成函数
486 **************************************************************************** */
hmac_sta_initiate_join(mac_vap_stru * mac_vap,mac_bss_dscr_stru * bss_dscr)487 hi_u32 hmac_sta_initiate_join(mac_vap_stru *mac_vap, mac_bss_dscr_stru *bss_dscr)
488 {
489 hi_u32 ret = HI_SUCCESS;
490
491 if (oal_unlikely((mac_vap == HI_NULL) || (bss_dscr == HI_NULL))) {
492 oam_error_log2(0, OAM_SF_ASSOC, "{hmac_sta_initiate_join::nul%p %p}", (uintptr_t)mac_vap, (uintptr_t)bss_dscr);
493 return HI_ERR_CODE_PTR_NULL;
494 }
495
496 hmac_vap_stru *hmac_vap = hmac_vap_get_vap_stru(mac_vap->vap_id);
497 if (hmac_vap == HI_NULL) {
498 oam_warning_log0(mac_vap->vap_id, OAM_SF_ASSOC, "{hmac_sta_initiate_join::hmac_vap_get_vap_stru null.}");
499 return HI_ERR_CODE_PTR_NULL;
500 }
501 /* 是否关联到Mesh */
502 hmac_vap->base_vap->is_conn_to_mesh = HI_FALSE;
503 /* STA为11B模式时,更新为11B基础速率 */
504 if (mac_vap->protocol == WLAN_LEGACY_11B_MODE) {
505 hmac_vap->auc_supp_rates[0] = WLAN_11B_SUPPORT_RATE_1M;
506 hmac_vap->auc_supp_rates[1] = WLAN_11B_SUPPORT_RATE_2M;
507 hmac_vap->auc_supp_rates[2] = WLAN_11B_SUPPORT_RATE_5M; /* 2 元素索引 */
508 hmac_vap->auc_supp_rates[3] = WLAN_11B_SUPPORT_RATE_11M; /* 3 元素索引 */
509 hmac_vap->rs_nrates = WLAN_11B_SUPPORT_RATE_NUM;
510 #ifdef _PRE_WLAN_FEATURE_MESH
511 } else if (bss_dscr->is_hisi_mesh == HI_TRUE) { /* 对端为Hisi-Mesh时, 使用本VAP的速率集 */
512 mac_rateset_stru *rates_set = &(mac_vap->curr_sup_rates.rate);
513 hmac_vap->rs_nrates = rates_set->rs_nrates;
514 hmac_vap->base_vap->is_conn_to_mesh = HI_TRUE;
515 /* 将速率拷贝到VAP结构体下的速率集中 */
516 for (hi_u8 rate_index = 0; rate_index < rates_set->rs_nrates; rate_index++) {
517 hmac_vap->auc_supp_rates[rate_index] = rates_set->ast_rs_rates[rate_index].mac_rate;
518 }
519 /* 关联Mesh开启 */
520 hmac_set_retry_time_en(mac_vap, 30, MAC_CFG_RETRY_MGMT); /* 当前sta关联Mesh采用30ms重传策略 */
521 #endif
522 } else {
523 if (memcpy_s(hmac_vap->auc_supp_rates, WLAN_MAX_SUPP_RATES, bss_dscr->auc_supp_rates,
524 bss_dscr->num_supp_rates) != EOK) {
525 oam_error_log0(0, OAM_SF_CFG, "hmac_sta_initiate_join:: auc_supp_rates memcpy_s fail.");
526 return HI_FAIL;
527 }
528 hmac_vap->rs_nrates = bss_dscr->num_supp_rates;
529 }
530
531 hmac_join_req_stru *join_req = (hmac_join_req_stru *)oal_memalloc(sizeof(hmac_join_req_stru));
532 if (join_req == HI_NULL) {
533 oam_error_log0(mac_vap->vap_id, OAM_SF_ANY, "{hmac_sta_initiate_join:: failed alloc join_req}\r\n");
534 return HI_ERR_CODE_PTR_NULL;
535 }
536
537 hmac_prepare_join_req(join_req, bss_dscr);
538
539 if ((mac_vap->vap_state == MAC_VAP_STATE_STA_FAKE_UP) || (mac_vap->vap_state == MAC_VAP_STATE_STA_SCAN_COMP)) {
540 ret = hmac_sta_wait_join(hmac_vap, join_req);
541 }
542 oal_free(join_req);
543 return ret;
544 }
545
546 /* ****************************************************************************
547 功能描述 : 发起认证
548 修改历史 :
549 1.日 期 : 2013年7月1日
550 作 者 : HiSilicon
551 修改内容 : 新生成函数
552 **************************************************************************** */
hmac_sta_initiate_auth(const mac_vap_stru * mac_vap)553 hi_u32 hmac_sta_initiate_auth(const mac_vap_stru *mac_vap)
554 {
555 hi_u16 auth_timeout;
556 hmac_vap_stru *hmac_vap = HI_NULL;
557
558 if (oal_unlikely(mac_vap == HI_NULL)) {
559 oam_error_log0(0, OAM_SF_SCAN, "{hmac_sta_initiate_auth: pst_mac_vap is null.}");
560 return HI_ERR_CODE_PTR_NULL;
561 }
562
563 hmac_vap = hmac_vap_get_vap_stru(mac_vap->vap_id);
564 if (hmac_vap == HI_NULL) {
565 oam_error_log0(0, OAM_SF_SCAN, "{hmac_sta_initiate_auth: pst_hmac_vap is null.}");
566 return HI_ERR_CODE_PTR_NULL;
567 }
568
569 hmac_prepare_auth_req(mac_vap, &auth_timeout);
570
571 /* 状态机调用 */
572 switch (mac_vap->vap_state) {
573 case MAC_VAP_STATE_STA_JOIN_COMP:
574 return hmac_sta_wait_auth(hmac_vap, auth_timeout);
575 default:
576 return HI_SUCCESS;
577 }
578 }
579
580 /* ****************************************************************************
581 功能描述 : 发起关联
582 修改历史 :
583 1.日 期 : 2013年7月1日
584 作 者 : HiSilicon
585 修改内容 : 新生成函数
586 **************************************************************************** */
hmac_sta_initiate_asoc(const mac_vap_stru * mac_vap)587 hi_u32 hmac_sta_initiate_asoc(const mac_vap_stru *mac_vap)
588 {
589 hi_u16 us_assoc_timeout;
590 hmac_vap_stru *hmac_vap = HI_NULL;
591
592 if (oal_unlikely(mac_vap == HI_NULL)) {
593 oam_error_log0(0, OAM_SF_ASSOC, "{hmac_sta_initiate_asoc::pst_mac_vap null!}");
594 return HI_ERR_CODE_PTR_NULL;
595 }
596
597 hmac_vap = hmac_vap_get_vap_stru(mac_vap->vap_id);
598 if (hmac_vap == HI_NULL) {
599 oam_warning_log0(mac_vap->vap_id, OAM_SF_ASSOC, "hmac_sta_initiate_asoc: pst_hmac_vap null!");
600 return HI_ERR_CODE_PTR_NULL;
601 }
602
603 hmac_prepare_asoc_req(mac_vap, &us_assoc_timeout);
604
605 /* 状态机调用 */
606 switch (mac_vap->vap_state) {
607 case MAC_VAP_STATE_STA_AUTH_COMP:
608 return hmac_sta_wait_asoc(hmac_vap, us_assoc_timeout);
609 default:
610 return HI_SUCCESS;
611 }
612 }
613
614 /* ****************************************************************************
615 功能描述 : 处理扫描结果
616 修改历史 :
617 1.日 期 : 2013年7月1日
618 作 者 : HiSilicon
619 修改内容 : 新生成函数
620 **************************************************************************** */
hmac_handle_scan_rsp_sta(hmac_vap_stru * hmac_vap,const hi_u8 * puc_msg)621 hi_void hmac_handle_scan_rsp_sta(hmac_vap_stru *hmac_vap, const hi_u8 *puc_msg)
622 {
623 hmac_send_event_to_host(hmac_vap->base_vap, puc_msg, sizeof(hmac_scan_rsp_stru),
624 HMAC_HOST_CTX_EVENT_SUB_TYPE_SCAN_COMP_STA);
625 return;
626 }
627
628 /* ****************************************************************************
629 功能描述 : 入网失败通知DMAC
630 修改历史 :
631 1.日 期 : 2014年11月15日
632 作 者 : HiSilicon
633 修改内容 : 新生成函数
634 **************************************************************************** */
hmac_send_connect_result_to_dmac_sta(const hmac_vap_stru * hmac_vap,hi_u32 result)635 static hi_u32 hmac_send_connect_result_to_dmac_sta(const hmac_vap_stru *hmac_vap, hi_u32 result)
636 {
637 frw_event_mem_stru *event_mem = HI_NULL;
638 frw_event_stru *event = HI_NULL;
639
640 /* 抛事件到DMAC, 申请事件内存 */
641 event_mem = frw_event_alloc(sizeof(hi_u32));
642 if (event_mem == HI_NULL) {
643 oam_error_log0(hmac_vap->base_vap->vap_id, OAM_SF_ASSOC, "event_mem null.");
644 return HI_ERR_CODE_PTR_NULL;
645 }
646
647 /* 填写事件 */
648 event = (frw_event_stru *)event_mem->puc_data;
649
650 frw_event_hdr_init(&(event->event_hdr), FRW_EVENT_TYPE_WLAN_CTX, DMAC_WLAN_CTX_EVENT_SUB_TYPE_CONN_RESULT,
651 sizeof(hi_u32), FRW_EVENT_PIPELINE_STAGE_1, hmac_vap->base_vap->vap_id);
652
653 *((hi_u32 *)(event->auc_event_data)) = result;
654
655 /* 分发事件 */
656 hcc_hmac_tx_control_event(event_mem, sizeof(hi_u32));
657 frw_event_free(event_mem);
658
659 return HI_SUCCESS;
660 }
661
662 /* ****************************************************************************
663 功能描述 : 处理加入结果
664 修改历史 :
665 1.日 期 : 2013年7月1日
666 作 者 : HiSilicon
667 修改内容 : 新生成函数
668 **************************************************************************** */
hmac_handle_join_rsp_sta(hmac_vap_stru * hmac_vap,const hi_u8 * puc_msg)669 hi_void hmac_handle_join_rsp_sta(hmac_vap_stru *hmac_vap, const hi_u8 *puc_msg)
670 {
671 hmac_mgmt_status_enum_uint8 join_result_code = *puc_msg;
672 hi_u32 ret;
673
674 if (join_result_code == HMAC_MGMT_SUCCESS) {
675 oam_info_log0(hmac_vap->base_vap->vap_id, OAM_SF_ASSOC, "{hmac_handle_join_rsp_sta::join succ.}");
676
677 /* 初始化AUTH次数 */
678 hmac_vap->auth_cnt = 1;
679 ret = hmac_sta_initiate_auth(hmac_vap->base_vap);
680 if (ret != HI_SUCCESS) {
681 hmac_handle_conn_fail(hmac_vap->base_vap);
682 }
683 } else {
684 oam_warning_log1(hmac_vap->base_vap->vap_id, OAM_SF_ASSOC, "hmac_handle_join_rsp_sta::join fail[%d]",
685 join_result_code);
686
687 ret = hmac_send_connect_result_to_dmac_sta(hmac_vap, HI_FAIL);
688 if (ret != HI_SUCCESS) {
689 oam_warning_log0(hmac_vap->base_vap->vap_id, OAM_SF_ASSOC,
690 "hmac_send_connect_result_to_dmac_sta return NON SUCCESS. ");
691 }
692 }
693 }
694
695 /* ****************************************************************************
696 功能描述 : 发送关联失败结果到wpa_supplicant
697 修改历史 :
698 1.日 期 : 2015年3月30日
699 作 者 : HiSilicon
700 修改内容 : 新生成函数
701 **************************************************************************** */
hmac_report_connect_failed_result(hmac_vap_stru * hmac_vap,mac_status_code_enum_uint16 reason_code)702 hi_void hmac_report_connect_failed_result(hmac_vap_stru *hmac_vap, mac_status_code_enum_uint16 reason_code)
703 {
704 hmac_asoc_rsp_stru asoc_rsp = { 0 };
705
706 asoc_rsp.result_code = HMAC_MGMT_TIMEOUT;
707 asoc_rsp.status_code = reason_code;
708 /* 扫描超时需要释放对应HMAC VAP下的关联请求buff */
709 asoc_rsp.puc_asoc_req_ie_buff = hmac_vap->puc_asoc_req_ie_buff;
710
711 hi_u32 ret = hmac_send_event_to_host(hmac_vap->base_vap, (const hi_u8 *)(&asoc_rsp), sizeof(hmac_asoc_rsp_stru),
712 HMAC_HOST_CTX_EVENT_SUB_TYPE_ASOC_COMP_STA);
713 if (ret != HI_SUCCESS) {
714 oam_error_log0(0, OAM_SF_CFG, "hmac_report_connect_failed_result:: hmac_send_event_to_host fail.");
715 /* 释放关联管理帧内存 */
716 oal_mem_free(hmac_vap->puc_asoc_req_ie_buff);
717 }
718
719 hmac_vap->puc_asoc_req_ie_buff = HI_NULL;
720 return;
721 }
722
723 /* ****************************************************************************
724 功能描述 : 处理认证结果
725 修改历史 :
726 1.日 期 : 2013年7月1日
727 作 者 : HiSilicon
728 修改内容 : 新生成函数
729 **************************************************************************** */
hmac_handle_auth_rsp_sta(hmac_vap_stru * hmac_vap,const hi_u8 * puc_msg)730 hi_void hmac_handle_auth_rsp_sta(hmac_vap_stru *hmac_vap, const hi_u8 *puc_msg)
731 {
732 hmac_auth_rsp_stru *auth_rsp = (hmac_auth_rsp_stru *)puc_msg;
733 hmac_user_stru *hmac_user = HI_NULL;
734 hi_u32 ret;
735
736 if (MAC_SUCCESSFUL_STATUSCODE == auth_rsp->us_status_code) {
737 oam_info_log0(hmac_vap->base_vap->vap_id, OAM_SF_AUTH, "{hmac_handle_auth_rsp_sta::auth succ.}");
738
739 /* 初始化AOSC次数 */
740 hmac_vap->asoc_cnt = 1;
741 ret = hmac_sta_initiate_asoc(hmac_vap->base_vap);
742 if (ret != HI_SUCCESS) {
743 hmac_handle_conn_fail(hmac_vap->base_vap);
744 }
745 return;
746 }
747
748 oam_warning_log2(0, 0, "hmac_handle_auth_rsp_sta::auth fail[%d],cnt[%d]", auth_rsp->us_status_code,
749 hmac_vap->auth_cnt);
750
751 if ((MAC_UNSUPT_ALG == auth_rsp->us_status_code || hmac_vap->auth_cnt >= MAX_AUTH_CNT) &&
752 (hmac_vap->auth_mode == WLAN_WITP_AUTH_AUTOMATIC)) {
753 hmac_vap->auth_mode = WLAN_WITP_AUTH_SHARED_KEY;
754 /* 需要将状态机设置为 */
755 hmac_fsm_change_state(hmac_vap, MAC_VAP_STATE_STA_JOIN_COMP);
756
757 /* 更新AUTH的次数 */
758 hmac_vap->auth_cnt = 0;
759
760 /* 重新发起关联动作 */
761 ret = hmac_sta_initiate_auth(hmac_vap->base_vap);
762 if (ret != HI_SUCCESS) {
763 hmac_handle_conn_fail(hmac_vap->base_vap);
764 }
765 return;
766 }
767
768 if (hmac_vap->auth_cnt < MAX_AUTH_CNT) {
769 /* 需要将状态机设置为 */
770 hmac_fsm_change_state(hmac_vap, MAC_VAP_STATE_STA_JOIN_COMP);
771
772 /* 更新AUTH的次数 */
773 hmac_vap->auth_cnt++;
774
775 /* 重新发起关联动作 */
776 ret = hmac_sta_initiate_auth(hmac_vap->base_vap);
777 if (ret != HI_SUCCESS) {
778 hmac_handle_conn_fail(hmac_vap->base_vap);
779 }
780 return;
781 }
782
783 ret = hmac_send_connect_result_to_dmac_sta(hmac_vap, HI_FAIL);
784 if (ret != HI_SUCCESS) {
785 oam_warning_log0(hmac_vap->base_vap->vap_id, OAM_SF_AUTH, "hmac_send_connect_result_to_dmac_sta returnON SUCC");
786 }
787
788 /* The MAC state is changed to fake up state. Further MLME */
789 /* requests are processed in this state. */
790 hmac_fsm_change_state(hmac_vap, MAC_VAP_STATE_STA_FAKE_UP);
791
792 /* 获取用户指针 */
793 hmac_user = (hmac_user_stru *)hmac_user_get_user_stru(hmac_vap->base_vap->assoc_vap_id);
794 if (hmac_user != HI_NULL) {
795 /* 删除对应用户 */
796 hmac_user_del(hmac_vap->base_vap, hmac_user);
797 }
798
799 if (hmac_vap->base_vap->is_conn_to_mesh == HI_TRUE) {
800 /* 关闭25ms重传策略 */
801 hmac_set_retry_time_close(hmac_vap->base_vap);
802 }
803 /* 上报关联失败到wpa_supplicant */
804 hmac_report_connect_failed_result(hmac_vap, MAC_CHLNG_FAIL);
805 }
806
hmac_asoc_rsp_success_proc(hmac_vap_stru * hmac_vap,const hi_u8 * msg,hmac_asoc_rsp_stru * asoc_rsp)807 hi_u32 hmac_asoc_rsp_success_proc(hmac_vap_stru *hmac_vap, const hi_u8 *msg, hmac_asoc_rsp_stru *asoc_rsp)
808 {
809 hi_u8 *mgmt_data = (hi_u8 *)oal_memalloc(asoc_rsp->asoc_rsp_ie_len);
810 if (mgmt_data == HI_NULL) {
811 oam_error_log0(hmac_vap->base_vap->vap_id, OAM_SF_ASSOC, "{hmac_handle_asoc_rsp_sta::malloc null.}");
812 /* 返回错误 */
813 return HI_FAIL;
814 }
815
816 if ((asoc_rsp->puc_asoc_rsp_ie_buff != HI_NULL) && (memcpy_s(mgmt_data, asoc_rsp->asoc_rsp_ie_len,
817 asoc_rsp->puc_asoc_rsp_ie_buff, asoc_rsp->asoc_rsp_ie_len) != EOK)) {
818 oam_error_log0(0, OAM_SF_CFG, "hmac_handle_asoc_rsp_sta:: puc_asoc_rsp_ie_buff memcpy_s fail.");
819 oal_free(mgmt_data);
820 return HI_FAIL;
821 }
822 hi_u8 *puc_save = asoc_rsp->puc_asoc_rsp_ie_buff;
823 asoc_rsp->puc_asoc_rsp_ie_buff = mgmt_data;
824
825 hi_u32 ret = hmac_send_event_to_host(hmac_vap->base_vap, msg, sizeof(hmac_asoc_rsp_stru),
826 HMAC_HOST_CTX_EVENT_SUB_TYPE_ASOC_COMP_STA);
827 if (ret != HI_SUCCESS) {
828 oam_error_log0(0, OAM_SF_CFG, "hmac_handle_asoc_rsp_sta:: puc_msg memcpy_s fail.");
829 oal_free(mgmt_data);
830 asoc_rsp->puc_asoc_rsp_ie_buff = puc_save;
831 return HI_FAIL;
832 }
833
834 hmac_vap->puc_asoc_req_ie_buff = HI_NULL;
835 return HI_SUCCESS;
836 }
837
838 /* ****************************************************************************
839 功能描述 : 处理认证结果
840 修改历史 :
841 1.日 期 : 2013年7月1日
842 作 者 : HiSilicon
843 修改内容 : 新生成函数
844 **************************************************************************** */
hmac_handle_asoc_rsp_sta(hmac_vap_stru * hmac_vap,const hi_u8 * msg)845 hi_void hmac_handle_asoc_rsp_sta(hmac_vap_stru *hmac_vap, const hi_u8 *msg)
846 {
847 hmac_asoc_rsp_stru *asoc_rsp = (hmac_asoc_rsp_stru *)msg;
848
849 if (msg == HI_NULL) {
850 oam_error_log0(0, OAM_SF_SCAN, "{hmac_handle_asoc_rsp_sta::puc_msg fail!}");
851 return;
852 }
853
854 /* end add */
855 if (asoc_rsp->result_code == HMAC_MGMT_SUCCESS) {
856 oam_info_log0(hmac_vap->base_vap->vap_id, OAM_SF_ASSOC, "{hmac_handle_asoc_rsp_sta::asoc succ.}");
857
858 if (hmac_asoc_rsp_success_proc(hmac_vap, msg, asoc_rsp) != HI_SUCCESS) {
859 /* 由oal_mem_free负责判空 */
860 oal_mem_free(hmac_vap->puc_asoc_req_ie_buff);
861 hmac_vap->puc_asoc_req_ie_buff = HI_NULL;
862 return;
863 }
864 } else {
865 oam_warning_log2(hmac_vap->base_vap->vap_id, OAM_SF_AUTH,
866 "{hmac_handle_asoc_rsp_sta::asoc fail=%d,assoc_cnt=%d}", asoc_rsp->result_code, hmac_vap->asoc_cnt);
867
868 hi_u8 max_reassoc_count = MAX_ASOC_CNT;
869 #ifdef _PRE_WLAN_FEATURE_PMF
870 max_reassoc_count = (asoc_rsp->status_code == MAC_REJECT_TEMP) ? MAX_ASOC_REJECT_CNT : MAX_ASOC_CNT;
871 #endif
872 if (hmac_vap->asoc_cnt >= max_reassoc_count) {
873 /* 获取用户指针 */
874 hmac_user_stru *hmac_user = (hmac_user_stru *)hmac_user_get_user_stru(hmac_vap->base_vap->assoc_vap_id);
875 if ((hmac_user != HI_NULL) && (hmac_user->base_user != HI_NULL)) {
876 /* 发送去认证帧到AP */
877 hmac_mgmt_send_deauth_frame(hmac_vap->base_vap, hmac_user->base_user->user_mac_addr, WLAN_MAC_ADDR_LEN,
878 MAC_AUTH_NOT_VALID);
879
880 /* 删除对应用户 */
881 hmac_user_del(hmac_vap->base_vap, hmac_user);
882 } else {
883 oam_warning_log0(hmac_vap->base_vap->vap_id, OAM_SF_AUTH, "asoc:pst_hmac_user NULL.");
884 }
885
886 /* 设置状态为FAKE UP */
887 hmac_fsm_change_state(hmac_vap, MAC_VAP_STATE_STA_FAKE_UP);
888
889 /* 同步DMAC状态 */
890 if (hmac_send_connect_result_to_dmac_sta(hmac_vap, HI_FAIL) != HI_SUCCESS) {
891 oam_warning_log0(hmac_vap->base_vap->vap_id, OAM_SF_AUTH, "hmac_send_connect_result_to_dmac_sta Err");
892 }
893
894 /* 上报关联失败到wpa_supplicant */
895 hmac_report_connect_failed_result(hmac_vap, asoc_rsp->status_code);
896 } else {
897 /* 需要将状态机设置为 */
898 hmac_fsm_change_state(hmac_vap, MAC_VAP_STATE_STA_AUTH_COMP);
899
900 /* 发起ASOC的次数 */
901 hmac_vap->asoc_cnt++;
902
903 /* 重新发起关联动作 */
904 if (hmac_sta_initiate_asoc(hmac_vap->base_vap) != HI_SUCCESS) {
905 /* 由oal_mem_free负责判空 */
906 oal_mem_free(hmac_vap->puc_asoc_req_ie_buff);
907 hmac_vap->puc_asoc_req_ie_buff = HI_NULL;
908 hmac_handle_conn_fail(hmac_vap->base_vap);
909 }
910 return;
911 }
912 }
913
914 if (hmac_vap->base_vap->is_conn_to_mesh == HI_TRUE) {
915 /* 关闭25ms重传策略 */
916 hmac_set_retry_time_close(hmac_vap->base_vap);
917 }
918 }
919
920 /* ****************************************************************************
921 功能描述 : 将连接状态机结果上报给SME
922 修改历史 :
923 1.日 期 : 2013年7月1日
924 作 者 : HiSilicon
925 修改内容 : 新生成函数
926 **************************************************************************** */
hmac_send_rsp_to_sme_sta(hmac_vap_stru * hmac_vap,hmac_sme_rsp_enum_uint8 type,const hi_u8 * puc_msg)927 hi_void hmac_send_rsp_to_sme_sta(hmac_vap_stru *hmac_vap, hmac_sme_rsp_enum_uint8 type, const hi_u8 *puc_msg)
928 {
929 g_handle_rsp_func_sta[type](hmac_vap, puc_msg);
930 }
931
932 /* ****************************************************************************
933 功能描述 : 向lwip上报sta关联/去关联事件
934 输入参数:hmac_vap_stru *pst_hmac_vap
935 hi_u8 *puc_addr:关联/去关联的AP地址
936 hi_u8 en_assoc:HI_TRUE:上报关联事件、Hi_False:上报去关联事件
937 修改历史 :
938 1.日 期 : 2019年7月9日
939 作 者 : HiSilicon
940 修改内容 : 新生成函数
941 **************************************************************************** */
hmac_report_assoc_state_sta(const hmac_vap_stru * hmac_vap,const hi_u8 * mac_addr,hi_u8 assoc)942 hi_void hmac_report_assoc_state_sta(const hmac_vap_stru *hmac_vap, const hi_u8 *mac_addr, hi_u8 assoc)
943 {
944 /* 抛加入完成事件到WAL */
945 frw_event_mem_stru *event_mem = frw_event_alloc(sizeof(hmac_sta_report_assoc_info_stru));
946 if (event_mem == HI_NULL) {
947 oam_error_log0(0, OAM_SF_SCAN, "{hmac_report_assoc_state_sta::frw_event_alloc fail!}");
948 return;
949 }
950
951 /* 填写事件 */
952 frw_event_stru *event = (frw_event_stru *)event_mem->puc_data;
953
954 frw_event_hdr_init(&(event->event_hdr), FRW_EVENT_TYPE_HOST_CTX, HMAC_HOST_CTX_EVENT_SUB_TYPE_STA_CONN_RESULT,
955 sizeof(hmac_sta_report_assoc_info_stru), FRW_EVENT_PIPELINE_STAGE_0, hmac_vap->base_vap->vap_id);
956
957 if (assoc == HI_TRUE) {
958 /* 获取hmac device 结构 */
959 hmac_device_stru *hmac_dev = hmac_get_device_stru();
960 /* 获取管理扫描的bss结果的结构体 */
961 hmac_bss_mgmt_stru *bss_mgmt = &(hmac_dev->scan_mgmt.scan_record_mgmt.bss_mgmt);
962 /* 对链表删操作前加锁 */
963 oal_spin_lock(&(bss_mgmt->st_lock));
964
965 hmac_scanned_bss_info *scanned_bss_info = hmac_scan_find_scanned_bss_by_bssid(bss_mgmt, mac_addr);
966 if (scanned_bss_info == HI_NULL) {
967 oam_warning_log3(hmac_vap->base_vap->vap_id, OAM_SF_CFG,
968 "{hmac_report_assoc_state_sta::find the bss failed by bssid:XX:XX:XX:%02X:%02X:%02X}",
969 mac_addr[3], mac_addr[4], mac_addr[5]); /* 3:4:5 元素索引 */
970 /* 解锁 */
971 oal_spin_unlock(&(bss_mgmt->st_lock));
972 frw_event_free(event_mem);
973 return;
974 }
975 /* 解锁 */
976 oal_spin_unlock(&(bss_mgmt->st_lock));
977
978 oam_info_log0(hmac_vap->base_vap->vap_id, OAM_SF_ASSOC, "{hmac_report_assoc_state_sta::Asoc Report!}");
979
980 hmac_sta_report_assoc_info_stru *sta_asoc = (hmac_sta_report_assoc_info_stru *)(event->auc_event_data);
981 sta_asoc->is_assoc = HI_TRUE;
982 sta_asoc->rssi = (hi_u8)oal_abs(scanned_bss_info->bss_dscr_info.rssi);
983 sta_asoc->conn_to_mesh = scanned_bss_info->bss_dscr_info.is_hisi_mesh;
984 if (memcpy_s(sta_asoc->auc_mac_addr, WLAN_MAC_ADDR_LEN, mac_addr, WLAN_MAC_ADDR_LEN) != EOK) {
985 oam_error_log0(0, OAM_SF_SCAN, "hmac_report_assoc_state_sta:: mem safe function err!");
986 frw_event_free(event_mem);
987 return;
988 }
989 } else {
990 oam_info_log0(hmac_vap->base_vap->vap_id, OAM_SF_ASSOC, "{hmac_report_assoc_state_sta::Disasoc Report!}");
991
992 hmac_sta_report_assoc_info_stru *sta_asoc = (hmac_sta_report_assoc_info_stru *)(event->auc_event_data);
993 sta_asoc->is_assoc = HI_FALSE;
994 sta_asoc->rssi = WLAN_RSSI_DUMMY_MARKER;
995 sta_asoc->conn_to_mesh = HI_FALSE;
996 if (memcpy_s(sta_asoc->auc_mac_addr, WLAN_MAC_ADDR_LEN, mac_addr, WLAN_MAC_ADDR_LEN) != EOK) {
997 oam_error_log0(0, OAM_SF_SCAN, "hmac_report_assoc_state_sta:: mem safe function err!");
998 frw_event_free(event_mem);
999 return;
1000 }
1001 }
1002
1003 /* 分发事件 */
1004 frw_event_dispatch_event(event_mem);
1005 /* end add */
1006 frw_event_free(event_mem);
1007
1008 return;
1009 }
1010
hmac_handle_conn_fail(const mac_vap_stru * mac_vap)1011 hi_void hmac_handle_conn_fail(const mac_vap_stru *mac_vap)
1012 {
1013 frw_event_mem_stru *event_mem = HI_NULL;
1014 frw_event_stru *event = HI_NULL;
1015
1016 /* 抛事件到DMAC, 申请事件内存 */
1017 event_mem = frw_event_alloc(sizeof(hi_u32));
1018 if (event_mem == HI_NULL) {
1019 oam_error_log0(0, OAM_SF_SCAN, "{hmac_auth_fail_coex_handle::event_mem null.}");
1020 return;
1021 }
1022
1023 /* 填写事件 */
1024 event = (frw_event_stru *)event_mem->puc_data;
1025 frw_event_hdr_init(&(event->event_hdr), FRW_EVENT_TYPE_WLAN_CTX, DMAC_WLAN_CTX_EVENT_SUB_TYPE_CONN_FAIL_SET_CHANNEL,
1026 sizeof(hi_u32), FRW_EVENT_PIPELINE_STAGE_1, mac_vap->vap_id);
1027 /* 分发事件 */
1028 hcc_hmac_tx_control_event(event_mem, sizeof(hi_u32));
1029 frw_event_free(event_mem);
1030 }
1031
1032 #ifdef __cplusplus
1033 #if __cplusplus
1034 }
1035 #endif
1036 #endif
1037