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_rx_data.h"
23 #include "hmac_mgmt_bss_comm.h"
24 #include "hmac_mgmt_classifier.h"
25 #include "hmac_fsm.h"
26 #include "hmac_sme_sta.h"
27 #include "hmac_mgmt_sta.h"
28 #include "hmac_mgmt_ap.h"
29 #include "hcc_hmac_if.h"
30 #include "wal_cfg80211_apt.h"
31 #ifdef _PRE_WLAN_FEATURE_ANY
32 #include "hmac_any.h"
33 #endif
34 #ifdef _PRE_WLAN_FEATURE_P2P
35 #include "hmac_p2p.h"
36 #endif
37
38 #ifdef __cplusplus
39 #if __cplusplus
40 extern "C" {
41 #endif
42 #endif
43
44 /* ****************************************************************************
45 2 全局变量定义
46 **************************************************************************** */
47 /* ****************************************************************************
48 3 函数实现
49 **************************************************************************** */
50 /* ****************************************************************************
51 功能描述 : ACTION帧发送
52 修改历史 :
53 1.日 期 : 2013年4月10日
54 作 者 : HiSilicon
55 修改内容 : 新生成函数
56 **************************************************************************** */
hmac_mgmt_tx_action(hmac_vap_stru * hmac_vap,hmac_user_stru * hmac_user,mac_action_mgmt_args_stru * action_args)57 hi_u32 hmac_mgmt_tx_action(hmac_vap_stru *hmac_vap, hmac_user_stru *hmac_user, mac_action_mgmt_args_stru *action_args)
58 {
59 hi_u32 ret;
60
61 if ((hmac_vap == HI_NULL) || (hmac_user == HI_NULL) || (action_args == HI_NULL)) {
62 oam_error_log3(0, OAM_SF_TX, "{hmac_mgmt_tx_action::param null, %p %p %p.}", (uintptr_t)hmac_vap,
63 (uintptr_t)hmac_user, (uintptr_t)action_args);
64 return HI_ERR_CODE_PTR_NULL;
65 }
66 if (action_args->category == MAC_ACTION_CATEGORY_BA) {
67 switch (action_args->action) {
68 case MAC_BA_ACTION_ADDBA_REQ:
69 oam_info_log0(hmac_vap->base_vap->vap_id, OAM_SF_TX,
70 "{hmac_mgmt_tx_action::MAC_BA_ACTION_ADDBA_REQ.}");
71 hmac_mgmt_tx_addba_req(hmac_vap, hmac_user, action_args);
72 break;
73
74 case MAC_BA_ACTION_DELBA:
75 oam_info_log0(hmac_vap->base_vap->vap_id, OAM_SF_TX, "{hmac_mgmt_tx_action::MAC_BA_ACTION_DELBA.}");
76 ret = hmac_mgmt_tx_delba(hmac_vap, hmac_user, action_args);
77 if (ret != HI_SUCCESS) {
78 oam_warning_log0(hmac_user->base_user->vap_id, OAM_SF_BA,
79 "hmac_mgmt_tx_delba return NON SUCCESS. ");
80 return ret;
81 }
82 break;
83
84 default:
85 oam_warning_log1(hmac_vap->base_vap->vap_id, OAM_SF_TX, "{hmac_mgmt_tx_action::invalid ba type[%d].}",
86 action_args->action);
87 return HI_FAIL;
88 }
89 } else {
90 oam_info_log1(hmac_vap->base_vap->vap_id, OAM_SF_TX, "{hmac_mgmt_tx_action::invalid ba type[%d].}",
91 action_args->category);
92 }
93 return HI_SUCCESS;
94 }
95
96
97 /* ****************************************************************************
98 功能描述 :
99 修改历史 :
100 1.日 期 : 2013年4月26日
101 作 者 : HiSilicon
102 修改内容 : 新生成函数
103 **************************************************************************** */
hmac_mgmt_tx_priv_req(hmac_vap_stru * hmac_vap,hmac_user_stru * hmac_user,mac_priv_req_args_stru * priv_req)104 hi_u32 hmac_mgmt_tx_priv_req(hmac_vap_stru *hmac_vap, hmac_user_stru *hmac_user, mac_priv_req_args_stru *priv_req)
105 {
106 mac_priv_req_11n_enum_uint8 req_type;
107
108 if ((hmac_vap == HI_NULL) || (hmac_user == HI_NULL) || (priv_req == HI_NULL)) {
109 oam_error_log3(0, OAM_SF_TX, "{hmac_mgmt_tx_priv_req::param null, %p %p %p.}", (uintptr_t)hmac_vap,
110 (uintptr_t)hmac_user, (uintptr_t)priv_req);
111 return HI_ERR_CODE_PTR_NULL;
112 }
113
114 req_type = priv_req->type;
115
116 switch (req_type) {
117 case MAC_A_MPDU_START:
118
119 hmac_mgmt_tx_ampdu_start(hmac_vap, hmac_user, priv_req);
120 break;
121
122 case MAC_A_MPDU_END:
123 hmac_mgmt_tx_ampdu_end(hmac_vap, hmac_user, priv_req);
124 break;
125
126 default:
127
128 oam_info_log1(hmac_vap->base_vap->vap_id, OAM_SF_TX,
129 "{hmac_mgmt_tx_priv_req::invalid en_req_type[%d].}", req_type);
130 break;
131 };
132
133 return HI_SUCCESS;
134 }
135
136 /* ****************************************************************************
137 功能描述 : 自身DMAC模块产生DELBA的处理函数
138 修改历史 :
139 1.日 期 : 2013年4月14日
140 作 者 : HiSilicon
141 修改内容 : 新生成函数
142 **************************************************************************** */
hmac_mgmt_rx_delba_event(frw_event_mem_stru * event_mem)143 hi_u32 hmac_mgmt_rx_delba_event(frw_event_mem_stru *event_mem)
144 {
145 frw_event_stru *event = HI_NULL;
146 frw_event_hdr_stru *event_hdr = HI_NULL;
147 dmac_ctx_action_event_stru *delba_event = HI_NULL;
148 hi_u8 *da_mac_addr = HI_NULL; /* 保存用户目的地址的指针 */
149 hmac_vap_stru *hmac_vap = HI_NULL; /* vap指针 */
150 hmac_user_stru *hmac_user = HI_NULL;
151 mac_action_mgmt_args_stru action_args;
152 hi_u32 ret;
153
154 if (event_mem == HI_NULL) {
155 oam_error_log0(0, OAM_SF_BA, "{hmac_mgmt_rx_delba_event::event_mem null.}");
156 return HI_ERR_CODE_PTR_NULL;
157 }
158
159 /* 获取事件头和事件结构体指针 */
160 event = (frw_event_stru *)event_mem->puc_data;
161 event_hdr = &(event->event_hdr);
162 delba_event = (dmac_ctx_action_event_stru *)(event->auc_event_data);
163
164 /* 获取vap结构信息 */
165 hmac_vap = hmac_vap_get_vap_stru(event_hdr->vap_id);
166 if (oal_unlikely(hmac_vap == HI_NULL)) {
167 oam_error_log0(event_hdr->vap_id, OAM_SF_BA, "{hmac_mgmt_rx_delba_event::pst_vap null.}");
168 return HI_ERR_CODE_PTR_NULL;
169 }
170
171 /* 获取目的用户的MAC ADDR */
172 da_mac_addr = delba_event->auc_mac_addr;
173
174 /* 获取发送端的用户指针 */
175 hmac_user = mac_vap_get_hmac_user_by_addr(hmac_vap->base_vap, da_mac_addr, WLAN_MAC_ADDR_LEN);
176 if (hmac_user == HI_NULL) {
177 oam_warning_log0(event_hdr->vap_id, OAM_SF_BA,
178 "{hmac_mgmt_rx_delba_event::mac_vap_find_user_by_macaddr failed.}");
179 return HI_FAIL;
180 }
181
182 action_args.category = MAC_ACTION_CATEGORY_BA;
183 action_args.action = MAC_BA_ACTION_DELBA;
184 action_args.arg1 = delba_event->tidno; /* 该数据帧对应的TID号 */
185 action_args.arg2 = delba_event->initiator; /* DELBA中,触发删除BA会话的发起端 */
186 action_args.arg3 = delba_event->stauts; /* DELBA中代表删除reason */
187 action_args.puc_arg5 = da_mac_addr; /* DELBA中代表目的地址 */
188
189 ret = hmac_mgmt_tx_action(hmac_vap, hmac_user, &action_args);
190 if (ret != HI_SUCCESS) {
191 oam_warning_log0(event_hdr->vap_id, OAM_SF_BA, "hmac_mgmt_tx_action return NON SUCCESS. ");
192 }
193
194 return HI_SUCCESS;
195 }
196
197 #ifdef _PRE_WLAN_FEATURE_PROMIS
hmac_rx_process_others_bss_management(const oal_netbuf_stru * netbuf)198 hi_u32 hmac_rx_process_others_bss_management(const oal_netbuf_stru *netbuf)
199 {
200 #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION)
201 hi_u32 ret;
202
203 /* 抛事件到wal层会出现由于事件队列满导致抛事件失败,直接调用可以提高效率 */
204 ret = hwal_send_others_bss_data(netbuf);
205 if (ret != HI_SUCCESS) {
206 oam_error_log1(0, OAM_SF_RX, "{hmac_rx_process_others_bss_data::hwal_send_others_bss_data fail,ul_ret=%d.}",
207 ret);
208 return HI_FAIL;
209 }
210 #endif
211 return HI_SUCCESS;
212 }
213 #endif
214
hmac_rx_vap_state_proc(const dmac_wlan_crx_event_stru * crx_event,hmac_vap_stru * hmac_vap,hi_u32 * ret)215 hi_void hmac_rx_vap_state_proc(const dmac_wlan_crx_event_stru *crx_event, hmac_vap_stru *hmac_vap, hi_u32 *ret)
216 {
217 if (hmac_vap->base_vap->vap_mode == WLAN_VAP_MODE_BSS_AP
218 #ifdef _PRE_WLAN_FEATURE_MESH
219 || (hmac_vap->base_vap->vap_mode == WLAN_VAP_MODE_MESH)
220 #endif
221 ) {
222 *ret = hmac_ap_up_rx_mgmt(hmac_vap, crx_event);
223 } else if (hmac_vap->base_vap->vap_mode == WLAN_VAP_MODE_BSS_STA) {
224 mac_vap_state_enum_uint8 vap_state = hmac_vap->base_vap->vap_state;
225
226 if (vap_state == MAC_VAP_STATE_STA_WAIT_AUTH_SEQ2) {
227 *ret = hmac_sta_wait_auth_seq2_rx(hmac_vap, crx_event);
228 } else if (vap_state == MAC_VAP_STATE_STA_WAIT_AUTH_SEQ4) {
229 *ret = hmac_sta_wait_auth_seq4_rx(hmac_vap, crx_event);
230 } else if (vap_state == MAC_VAP_STATE_STA_WAIT_ASOC) {
231 *ret = hmac_sta_wait_asoc_rx(hmac_vap, crx_event);
232 } else if (vap_state == MAC_VAP_STATE_UP) {
233 *ret = hmac_sta_up_rx_mgmt(hmac_vap, crx_event);
234 #ifdef _PRE_WLAN_FEATURE_P2P
235 } else if ((vap_state == MAC_VAP_STATE_STA_SCAN_COMP) || (vap_state == MAC_VAP_STATE_STA_WAIT_SCAN) ||
236 (vap_state == MAC_VAP_STATE_STA_FAKE_UP) || (vap_state == MAC_VAP_STATE_STA_LISTEN)) {
237 *ret = hmac_p2p_sta_not_up_rx_mgmt(hmac_vap, crx_event);
238 #endif
239 }
240 }
241 }
242
243 /* ****************************************************************************
244 功能描述 : HMAC模块接收WLAN_CRX事件的处理函数
245 输入参数 : event_mem: 事件内存结构体指针
246 返 回 值 : 成功或者失败原因
247 修改历史 :
248 1.日 期 : 2012年11月14日
249 作 者 : HiSilicon
250 修改内容 : 新生成函数
251 **************************************************************************** */
hmac_rx_process_mgmt_event(frw_event_mem_stru * event_mem)252 hi_u32 hmac_rx_process_mgmt_event(frw_event_mem_stru *event_mem)
253 {
254 hi_u32 ret = HI_SUCCESS;
255
256 if (event_mem == HI_NULL) {
257 oam_error_log0(0, OAM_SF_RX, "{hmac_rx_process_mgmt_event::param null.}");
258 return HI_ERR_CODE_PTR_NULL;
259 }
260
261 /* 获取事件头和事件结构体指针 */
262 frw_event_stru *event = (frw_event_stru *)event_mem->puc_data;
263 frw_event_hdr_stru *event_hdr = &(event->event_hdr);
264 dmac_wlan_crx_event_stru *crx_event = (dmac_wlan_crx_event_stru *)(event->auc_event_data);
265 oal_netbuf_stru *netbuf = (oal_netbuf_stru *)crx_event->netbuf;
266
267 if (netbuf == HI_NULL) {
268 oam_error_log0(0, OAM_SF_ANY, "hmac_rx_process_mgmt_event netbuf NULL.");
269 return HI_FAIL;
270 }
271
272 /* 获取vap结构信息 */
273 hmac_vap_stru *hmac_vap = hmac_vap_get_vap_stru(event_hdr->vap_id);
274 if (oal_unlikely((hmac_vap == HI_NULL) || (hmac_vap->base_vap == HI_NULL))) {
275 oam_warning_log0(event_hdr->vap_id, OAM_SF_BA, "{hmac_mgmt_rx_delba_event::pst_vap null.}");
276 return HI_ERR_CODE_PTR_NULL;
277 }
278
279 #ifdef _PRE_WLAN_FEATURE_ANY
280 hmac_rx_ctl_stru *rx_ctrl = (hmac_rx_ctl_stru *)oal_netbuf_cb(netbuf);
281 hi_u8 *data = (hi_u8 *)(rx_ctrl->pul_mac_hdr_start_addr) + rx_ctrl->mac_header_len; /* 获取帧体指针 */
282
283 /* 查找OUI-OUI type值为 00 E0 FC - 01 (ANY华为自定义的帧格式) */
284 /* 并用hmac_any_proc_rx_mgmt进行处理 */
285 if (mac_find_vendor_action(MAC_WLAN_OUI_VENDOR, MAC_OUITYPE_ANY, data,
286 rx_ctrl->us_frame_len - rx_ctrl->mac_header_len) != HI_FALSE) {
287 /* 处理接收到的ANY管理帧 */
288 ret = hmac_any_proc_rx_mgmt(hmac_vap, rx_ctrl->channel_number, netbuf, rx_ctrl->us_frame_len);
289 oal_netbuf_free(netbuf);
290 return ret;
291 }
292 #endif
293
294 /* 接收管理帧是状态机的一个输入,调用状态机接口 */
295 hmac_rx_vap_state_proc(crx_event, hmac_vap, &ret);
296
297 /* 管理帧统一释放接口 */
298 oal_netbuf_free(netbuf);
299 return ret;
300 }
301
302 #ifdef _PRE_WLAN_FEATURE_PROMIS
hmac_rx_process_mgmt_promis(frw_event_mem_stru * event_mem)303 hi_u32 hmac_rx_process_mgmt_promis(frw_event_mem_stru *event_mem)
304 {
305 hi_u32 ret = HI_SUCCESS;
306 /* 获取事件头和事件结构体指针 */
307 frw_event_stru *event = (frw_event_stru *)event_mem->puc_data;
308 frw_event_hdr_stru *event_hdr = &(event->event_hdr);
309 dmac_wlan_crx_event_stru *crx_event = (dmac_wlan_crx_event_stru *)(event->auc_event_data);
310 oal_netbuf_stru *netbuf = (oal_netbuf_stru *)crx_event->netbuf;
311
312 if (netbuf == HI_NULL) {
313 oam_error_log0(0, OAM_SF_ANY, "hmac_rx_process_mgmt_event netbuf NULL.");
314 return HI_FAIL;
315 }
316
317 /* 获取vap结构信息 */
318 hmac_vap_stru *hmac_vap = hmac_vap_get_vap_stru(event_hdr->vap_id);
319 if (oal_unlikely((hmac_vap == HI_NULL) || (hmac_vap->base_vap == HI_NULL))) {
320 oam_warning_log0(event_hdr->vap_id, OAM_SF_BA, "{hmac_mgmt_rx_delba_event::pst_vap null.}");
321 oal_netbuf_free(netbuf);
322 return HI_ERR_CODE_PTR_NULL;
323 }
324
325 if ((mac_res_get_dev())->promis_switch) {
326 /* 处理上报的其他BSS 管理帧 */
327 ret = hmac_rx_process_others_bss_management(netbuf);
328 }
329 /* 管理帧统一释放接口 */
330 oal_netbuf_free(netbuf);
331 return ret;
332 }
333 #endif
334
hmac_mgmt_send_disasoc_deauth_event_frame(const dmac_diasoc_deauth_event * disasoc_deauth_event,mac_vap_stru * mac_vap,const hi_u8 * mac_addr,hi_u16 us_err_code,hmac_vap_stru * hmac_vap)335 hi_u32 hmac_mgmt_send_disasoc_deauth_event_frame(const dmac_diasoc_deauth_event *disasoc_deauth_event,
336 mac_vap_stru *mac_vap, const hi_u8 *mac_addr, hi_u16 us_err_code, hmac_vap_stru *hmac_vap)
337 {
338 hi_unref_param(hmac_vap);
339
340 /* 发送去认证, 未关联状态收到第三类帧 */
341 if (disasoc_deauth_event->event == DMAC_WLAN_CRX_DEAUTH) {
342 hmac_mgmt_send_deauth_frame(mac_vap, mac_addr, WLAN_MAC_ADDR_LEN, us_err_code); /* 非PMF */
343 #ifdef _PRE_WLAN_FEATURE_MESH
344 /* Mesh下这种情况下无法区分是mesh用户还是sta用户,因此发两个帧 */
345 if (mac_vap->vap_mode == WLAN_VAP_MODE_MESH) {
346 hmac_handle_close_peer_mesh(hmac_vap, mac_addr, WLAN_MAC_ADDR_LEN, HMAC_REPORT_DISASSOC, MAC_NOT_ASSOCED);
347 }
348 #endif
349
350 #ifdef _PRE_WLAN_FEATURE_P2P
351 mac_vap_stru *up_vap1 = HI_NULL;
352 mac_vap_stru *up_vap2 = HI_NULL;
353
354 mac_device_stru *mac_dev = mac_res_get_dev();
355 /* 判断是异频DBAC模式时,无法判断是哪个信道收到的数据帧,两个信道都需要发去认证 */
356 if (mac_device_find_2up_vap(mac_dev, &up_vap1, &up_vap2) != HI_SUCCESS) {
357 return HI_SUCCESS;
358 }
359
360 if ((up_vap1->channel.chan_number == up_vap2->channel.chan_number) &&
361 (up_vap1->channel.en_bandwidth == up_vap2->channel.en_bandwidth)) {
362 return HI_SUCCESS;
363 }
364
365 /* 获取另一个VAP */
366 if (mac_vap->vap_id != up_vap1->vap_id) {
367 up_vap2 = up_vap1;
368 }
369
370 /* 另外一个VAP也发去认证帧。error code加上特殊标记,组去认证帧时要修改源地址 */
371 hmac_mgmt_send_deauth_frame(up_vap2, mac_addr, WLAN_MAC_ADDR_LEN, (us_err_code | MAC_SEND_TWO_DEAUTH_FLAG));
372 #endif
373
374 return HI_SUCCESS;
375 }
376 return HI_CONTINUE;
377 }
378
379 /* ****************************************************************************
380 功能描述 : 去关联/去认证事件处理
381 修改历史 :
382 1.日 期 : 2014年4月21日
383 作 者 : HiSilicon
384 修改内容 : 新生成函数
385 **************************************************************************** */
hmac_mgmt_send_disasoc_deauth_event(frw_event_mem_stru * event_mem)386 hi_u32 hmac_mgmt_send_disasoc_deauth_event(frw_event_mem_stru *event_mem)
387 {
388 hi_u8 user_idx = 0;
389
390 /* 获取事件头和事件结构体指针 */
391 frw_event_stru *event = (frw_event_stru *)event_mem->puc_data;
392 dmac_diasoc_deauth_event *deauth_event = (dmac_diasoc_deauth_event *)(event->auc_event_data);
393
394 /* 获取vap结构信息 */
395 hmac_vap_stru *hmac_vap = hmac_vap_get_vap_stru(event->event_hdr.vap_id); /* vap指针 */
396 if (oal_unlikely(hmac_vap == HI_NULL)) {
397 oam_error_log0(event->event_hdr.vap_id, OAM_SF_ASSOC, "{hmac_mgmt_send_disasoc_deauth_event::pst_vap null.}");
398 return HI_ERR_CODE_PTR_NULL;
399 }
400 mac_vap_stru *mac_vap = hmac_vap->base_vap;
401
402 /* 获取目的用户的MAC ADDR */
403 hi_u8 *mac_addr = deauth_event->auc_des_addr; /* 保存用户目的地址的指针 */
404 hi_u16 err_code = deauth_event->reason;
405
406 if (hmac_mgmt_send_disasoc_deauth_event_frame(deauth_event, mac_vap, mac_addr, err_code, hmac_vap) == HI_SUCCESS) {
407 return HI_SUCCESS;
408 }
409 /* 获取发送端的用户指针 */
410 if (mac_vap_find_user_by_macaddr(mac_vap, mac_addr, WLAN_MAC_ADDR_LEN, &user_idx) != HI_SUCCESS) {
411 oam_warning_log3(0, OAM_SF_RX,
412 "{hmac_mgmt_send_disasoc_deauth_event:cannot find USER by addr[XX:XX:XX:%02X:%02X:%02X]just del DMAC user}",
413 mac_addr[3], mac_addr[4], mac_addr[5]); /* 3 4 5 数组索引 */
414
415 return hmac_send_del_user_event(mac_vap, mac_addr, (hi_u8)MAC_INVALID_USER_ID);
416 }
417
418 /* 获取到hmac user,使用protected标志 */
419 hmac_user_stru *hmac_user = (hmac_user_stru *)hmac_user_get_user_stru(user_idx);
420 if ((hmac_user == HI_NULL) || (hmac_user->base_user == HI_NULL)) {
421 return HI_ERR_CODE_PTR_NULL;
422 }
423
424 #ifdef _PRE_WLAN_FEATURE_MESH
425 if ((mac_vap->vap_mode == WLAN_VAP_MODE_MESH) && (hmac_user->base_user->is_mesh_user == HI_TRUE)) {
426 /* Mesh VAP下的Mesh User需要上报WPA发送Mesh Peering Close Frame 来断联,不发Assoc帧
427 删除用户也由WPA调用STA remove 来删除 */
428 hmac_handle_close_peer_mesh(hmac_vap, hmac_user->base_user->user_mac_addr, WLAN_MAC_ADDR_LEN,
429 HMAC_REPORT_DISASSOC, err_code);
430 return HI_SUCCESS;
431 } else {
432 hmac_mgmt_send_disassoc_frame(mac_vap, mac_addr, err_code,
433 ((hmac_user == HI_NULL) ? HI_FALSE : hmac_user->base_user->cap_info.pmf_active));
434 }
435 #else
436 hmac_mgmt_send_disassoc_frame(mac_vap, mac_addr, err_code,
437 ((hmac_user == HI_NULL) ? HI_FALSE : hmac_user->base_user->cap_info.pmf_active));
438 #endif
439 /* AP删除用户之前抛事件上报内核,刷新hostapd,删除可能存在的对应STA记录 */
440 if (mac_vap->vap_mode == WLAN_VAP_MODE_BSS_AP) {
441 hmac_handle_disconnect_rsp_ap(hmac_vap, hmac_user);
442 }
443 /* 删除用户 */
444 hmac_user_del(mac_vap, hmac_user);
445
446 return HI_SUCCESS;
447 }
448
449 /* ****************************************************************************
450 功能描述 : HMAC去关联用户处理入口函数
451 输入参数 : event_mem: 事件内存指针
452 返 回 值 : HI_SUCCESS或其它错误码
453 修改历史 :
454 1.日 期 : 2015年1月15日
455 作 者 : HiSilicon
456 修改内容 : 新生成函数
457 **************************************************************************** */
hmac_proc_disasoc_misc_event(frw_event_mem_stru * event_mem)458 hi_u32 hmac_proc_disasoc_misc_event(frw_event_mem_stru *event_mem)
459 {
460 frw_event_stru *event = (frw_event_stru *)event_mem->puc_data;
461 dmac_disasoc_misc_stru *pdmac_disasoc_misc_stru = (dmac_disasoc_misc_stru *)event->auc_event_data;
462 hmac_vap_stru *hmac_vap = hmac_vap_get_vap_stru(event->event_hdr.vap_id);
463 if (oal_unlikely(hmac_vap == HI_NULL)) {
464 oam_error_log0(0, OAM_SF_ASSOC, "{hmac_proc_disasoc_misc_event::pst_hmac_vap is null.}");
465 return HI_ERR_CODE_PTR_NULL;
466 }
467
468 oam_warning_log2(hmac_vap->base_vap->vap_id, OAM_SF_ASSOC, "{hmac_proc_disasoc_misc_event::disas user[%d]in[%d]!}",
469 pdmac_disasoc_misc_stru->user_idx, pdmac_disasoc_misc_stru->disasoc_reason);
470
471 if (is_ap(hmac_vap->base_vap)) {
472 hmac_user_stru *hmac_user = (hmac_user_stru *)hmac_user_get_user_stru(pdmac_disasoc_misc_stru->user_idx);
473 if ((hmac_user == HI_NULL) || (hmac_user->base_user == HI_NULL)) {
474 oam_error_log0(0, OAM_SF_ASSOC, "{hmac_proc_disasoc_misc_event ap::pst_hmac_user is null.}");
475 return HI_ERR_CODE_PTR_NULL;
476 }
477
478 #ifdef _PRE_WLAN_FEATURE_MESH
479 if (hmac_user->base_user->is_mesh_user == HI_TRUE) {
480 hmac_handle_close_peer_mesh(hmac_vap, hmac_user->base_user->user_mac_addr, WLAN_MAC_ADDR_LEN,
481 HMAC_REPORT_DISASSOC, pdmac_disasoc_misc_stru->disasoc_reason);
482 } else {
483 #endif
484 hi_u8 is_protected = hmac_user->base_user->cap_info.pmf_active;
485 /* 抛事件上报内核,已经去关联某个STA */
486 hmac_handle_disconnect_rsp_ap(hmac_vap, hmac_user);
487 /* 发去关联帧 */
488 hmac_mgmt_send_disassoc_frame(hmac_vap->base_vap, hmac_user->base_user->user_mac_addr, MAC_DISAS_LV_SS,
489 is_protected);
490 /* 删除用户 */
491 hmac_user_del(hmac_vap->base_vap, hmac_user);
492 #ifdef _PRE_WLAN_FEATURE_MESH
493 }
494 #endif
495 } else {
496 /* 获用户 */
497 hmac_user_stru *hmac_user = (hmac_user_stru *)hmac_user_get_user_stru(hmac_vap->base_vap->assoc_vap_id);
498 if ((hmac_user == HI_NULL) || (hmac_user->base_user == HI_NULL)) {
499 oam_warning_log0(0, OAM_SF_ASSOC, "{hmac_proc_disasoc_misc_event::pst_hmac_user is null.}");
500 return HI_ERR_CODE_PTR_NULL;
501 }
502
503 if (pdmac_disasoc_misc_stru->disasoc_reason != DMAC_DISASOC_MISC_CHANNEL_MISMATCH) {
504 /* 发送去认证帧到AP */
505 hmac_mgmt_send_disassoc_frame(hmac_vap->base_vap, hmac_user->base_user->user_mac_addr, MAC_UNSPEC_REASON,
506 (hi_u8)hmac_user->base_user->cap_info.pmf_active);
507 }
508 /* 删除对应用户 */
509 hmac_user_del(hmac_vap->base_vap, hmac_user);
510 /* 设置状态为FAKE UP */
511 hmac_fsm_change_state(hmac_vap, MAC_VAP_STATE_STA_FAKE_UP);
512 /* hmac_proc_disasoc_misc_event, dmac_reason_code is 0~4 from dmac */
513 hmac_sta_disassoc_rsp(hmac_vap, HMAC_REPORT_DEAUTH, pdmac_disasoc_misc_stru->disasoc_reason);
514 }
515
516 return HI_SUCCESS;
517 }
518
519 #ifdef __cplusplus
520 #if __cplusplus
521 }
522 #endif
523 #endif
524