• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 /* 1 头文件包含 */
19 #include "oam_ext_if.h"
20 #include "mac_resource.h"
21 #include "mac_device.h"
22 #include "mac_user.h"
23 #include "hmac_11i.h"
24 
25 #ifdef __cplusplus
26 #if __cplusplus
27 extern "C" {
28 #endif
29 #endif
30 
31 /* ****************************************************************************
32   2 全局变量定义
33 **************************************************************************** */
34 #define __WIFI_ROM_SECTION__               /* 代码ROM段起始位置 */
35 WIFI_ROM_BSS hi_u16 g_us_user_res_map = 0; /* user资源map表 最大支持16个用户 */
36 WIFI_ROM_BSS hi_u8 *g_puc_mac_user_res = HI_NULL;
37 
38 /* ****************************************************************************
39   3 函数实现
40 **************************************************************************** */
41 /* ****************************************************************************
42  功能描述  : mac user资源初始化,根据user数量申请内存
43 **************************************************************************** */
mac_user_res_init(const hi_u8 user_num)44 WIFI_ROM_TEXT hi_u32 mac_user_res_init(const hi_u8 user_num)
45 {
46     hi_u32 user_size = sizeof(mac_user_stru) * user_num;
47     /* mac user 在非offload模式下存在两次申请的情况,已经申请过则跳过 */
48     if (g_puc_mac_user_res != HI_NULL) {
49         return HI_SUCCESS;
50     }
51     g_puc_mac_user_res = hi_malloc(HI_MOD_ID_WIFI_DRV, user_size);
52     if (g_puc_mac_user_res == HI_NULL) {
53         oam_error_log0(0, OAM_SF_ANY, "{mac_user_res_init::mem alloc user res null.}");
54         return HI_ERR_CODE_ALLOC_MEM_FAIL;
55     }
56     /* 安全编程规则6.6例外(3)从堆中分配内存后,赋予初值 */
57     memset_s(g_puc_mac_user_res, user_size, 0, user_size);
58     return HI_SUCCESS;
59 }
60 
61 /* ****************************************************************************
62  功能描述  : mac 用户资源池去初始化
63  修改历史      :
64   1.日    期   : 2019年5月30日
65     作    者   : HiSilicon
66     修改内容   : 新生成函数
67 **************************************************************************** */
mac_user_res_exit(hi_void)68 WIFI_ROM_TEXT hi_void mac_user_res_exit(hi_void)
69 {
70     if (g_puc_mac_user_res != HI_NULL) {
71         hi_free(HI_MOD_ID_WIFI_DRV, g_puc_mac_user_res);
72         g_puc_mac_user_res = HI_NULL;
73     }
74 }
75 
76 /* ****************************************************************************
77  功能描述  : 获取全局用户数量 用于申请用户内存 user数量=配置的单播用户 + vap数量(组播用户)
78  修改历史      :
79   1.日    期   : 2019年5月30日
80     作    者   : HiSilicon
81     修改内容   : 新生成函数
82 **************************************************************************** */
mac_user_get_user_num(hi_void)83 WIFI_ROM_TEXT hi_u8 mac_user_get_user_num(hi_void)
84 {
85     hi_u8 ucast_user_num = oal_mem_get_user_res_num(); /* 单播用户 = 用户配置数 */
86     /* 组播用户 = vap数-1(配置vap无组播用户) */
87     hi_u8 mcast_user_num = oal_mem_get_vap_res_num() - WLAN_CFG_VAP_NUM_PER_DEVICE;
88     hi_u8 user_num = ucast_user_num + mcast_user_num;
89     /* USER资源设置时已做规格校验此处不再校验 */
90     return user_num;
91 }
92 
93 /* ****************************************************************************
94  功能描述  : 分配一个未使用user资源
95  返 回 值  : 未使用的user资源id
96  修改历史      :
97   1.日    期   : 2019年5月30日
98     作    者   : HiSilicon
99     修改内容   : 新生成函数
100 **************************************************************************** */
mac_user_alloc_user_res(hi_void)101 WIFI_ROM_TEXT hi_u8 mac_user_alloc_user_res(hi_void)
102 {
103     hi_u8 user_idx;
104     hi_u8 user_num = mac_user_get_user_num();
105     user_idx = oal_bit_find_first_zero((hi_u32)g_us_user_res_map, user_num);
106     if (user_idx >= user_num) {
107         oam_error_log2(0, OAM_SF_ANY, "{mac_user_alloc_user_res::alloc user res fail. res mac[%x], max user spec[%d].}",
108             g_us_user_res_map, user_num);
109         user_idx = MAC_INVALID_USER_ID;
110     } else {
111         /* 将对应的res标志位置1 */
112         g_us_user_res_map |= (hi_u16)(BIT0 << user_idx);
113     }
114     return user_idx;
115 }
116 
117 /* ****************************************************************************
118  功能描述  : user初始化时 获取对应MAC USER索引的内存
119              仅用于与hmac dmac建立匹配关系 入参调用处已校验
120  输入参数  : 对应MAC USER内存索引
121  返 回 值  : 对应内存地址
122  修改历史      :
123   1.日    期   : 2019年5月30日
124     作    者   : HiSilicon
125     修改内容   : 新生成函数
126 **************************************************************************** */
mac_user_init_get_user_stru(hi_u8 idx)127 WIFI_ROM_TEXT hi_u8 *mac_user_init_get_user_stru(hi_u8 idx)
128 {
129     return (g_puc_mac_user_res + sizeof(mac_user_stru) * idx);
130 }
131 
132 /* ****************************************************************************
133  功能描述  : 获取对应MAC USER索引的内存
134  输入参数  : 对应MAC USER内存索引
135  返 回 值  : 对应内存地址
136  修改历史      :
137   1.日    期   : 2019年5月30日
138     作    者   : HiSilicon
139     修改内容   : 新生成函数
140 **************************************************************************** */
mac_user_get_user_stru(hi_u8 idx)141 WIFI_ROM_TEXT mac_user_stru *mac_user_get_user_stru(hi_u8 idx)
142 {
143     hi_u8 user_num = mac_user_get_user_num();
144     mac_user_stru *mac_user = HI_NULL;
145     if ((g_puc_mac_user_res == HI_NULL) || (idx >= user_num)) {
146         return HI_NULL;
147     }
148     mac_user = (mac_user_stru *)(g_puc_mac_user_res + sizeof(mac_user_stru) * idx);
149     /* user id=0为特殊user,单播不为0 */
150     if ((mac_user->is_user_alloced != MAC_USER_ALLOCED) && (idx != 0)) {
151         /* 获取用户时用户已经释放属于正常,直接返回空指针即可 */
152         return HI_NULL;
153     }
154     return mac_user;
155 }
156 
157 /* ****************************************************************************
158  功能描述  : 删除一个已使用使用user资源
159              OFFLOAD模式下dmac hmac各自释放,非OFFLOAD模式下统一由hmac申请和释放
160  输入参数  : vap资源id
161  修改历史      :
162   1.日    期   : 2019年5月25日
163     作    者   : HiSilicon
164     修改内容   : 新生成函数
165 **************************************************************************** */
mac_user_free_user_res(hi_u8 idx)166 WIFI_ROM_TEXT hi_void mac_user_free_user_res(hi_u8 idx)
167 {
168     g_us_user_res_map &= (~((hi_u16)BIT0 << idx)); // ~操作符表达式中所有变量都是无符号数,误报告警,lin_t e502告警屏蔽
169 }
170 
171 /* ****************************************************************************
172  功能描述  : 添加wep密钥到指定的密钥槽
173  修改历史      :
174   1.日    期   : 2015年5月14日
175     作    者   : HiSilicon
176     修改内容   : 新生成函数
177 **************************************************************************** */
mac_user_add_key_common(mac_user_stru * mac_user,hi_u8 key_index,const mac_key_params_stru * key)178 WIFI_ROM_TEXT hi_u32 mac_user_add_key_common(mac_user_stru *mac_user, hi_u8 key_index, const mac_key_params_stru *key)
179 {
180     hi_s32 key_max_len;
181 
182     if (key_index >= WLAN_NUM_TK) {
183         return HI_ERR_CODE_SECURITY_KEY_ID;
184     }
185 
186     if (((hi_u8)key->cipher == WLAN_80211_CIPHER_SUITE_WEP_40) ||
187         ((hi_u8)key->cipher == WLAN_80211_CIPHER_SUITE_WEP_104)) {
188         key_max_len = WLAN_WEP104_KEY_LEN;
189     } else if (((hi_u8)key->cipher == WLAN_80211_CIPHER_SUITE_TKIP) ||
190         ((hi_u8)key->cipher == WLAN_80211_CIPHER_SUITE_CCMP)) {
191         key_max_len = WLAN_WPA_KEY_LEN;
192     } else {
193         return HI_ERR_CODE_SECURITY_CHIPER_TYPE;
194     }
195 
196     if (key->key_len > key_max_len) {
197         return HI_ERR_CODE_SECURITY_KEY_LEN;
198     }
199 
200     if ((hi_u32)key->seq_len > WLAN_WPA_SEQ_LEN) {
201         return HI_ERR_CODE_SECURITY_KEY_LEN;
202     }
203 
204     mac_user->key_info.ast_key[key_index].cipher = key->cipher;
205     mac_user->key_info.ast_key[key_index].key_len = (hi_u32)key->key_len;
206     mac_user->key_info.ast_key[key_index].seq_len = (hi_u32)key->seq_len;
207 
208     if (memcpy_s(mac_user->key_info.ast_key[key_index].auc_key, WLAN_WPA_KEY_LEN, key->auc_key, (hi_u32)key->key_len) !=
209         EOK) {
210         return HI_FAIL;
211     }
212     if (memcpy_s(mac_user->key_info.ast_key[key_index].auc_seq, WLAN_WPA_SEQ_LEN, key->auc_seq, (hi_u32)key->seq_len) !=
213         EOK) {
214         return HI_FAIL;
215     }
216 
217     if (((hi_u8)key->cipher == WLAN_80211_CIPHER_SUITE_WEP_40) ||
218         ((hi_u8)key->cipher == WLAN_80211_CIPHER_SUITE_WEP_104)) {
219         mac_user->user_tx_info.security.cipher_key_type = WLAN_KEY_TYPE_TX_GTK;
220     } else {
221         mac_user->key_info.cipher_type = (hi_u8)key->cipher;
222         mac_user->key_info.default_index = key_index;
223     }
224 
225     return HI_SUCCESS;
226 }
227 
mac_user_add_wep_key(mac_user_stru * mac_user,hi_u8 key_index,const mac_key_params_stru * key)228 WIFI_ROM_TEXT hi_u32 mac_user_add_wep_key(mac_user_stru *mac_user, hi_u8 key_index, const mac_key_params_stru *key)
229 {
230     return mac_user_add_key_common(mac_user, key_index, key);
231 }
232 
233 /* ****************************************************************************
234  函 数 名  : mac_user_add_rsn_key
235  功能描述  : 更新rsn单播信息
236  输入参数  :
237  输出参数  : 无
238  返 回 值  :
239  调用函数  :
240  被调函数  :
241 
242  修改历史      :
243   1.日    期   : 2014年11月21日
244     作    者   : HiSilicon
245     修改内容   : 新生成函数
246 
247 **************************************************************************** */
mac_user_add_rsn_key(mac_user_stru * mac_user,hi_u8 key_index,const mac_key_params_stru * key)248 WIFI_ROM_TEXT hi_u32 mac_user_add_rsn_key(mac_user_stru *mac_user, hi_u8 key_index, const mac_key_params_stru *key)
249 {
250     return mac_user_add_key_common(mac_user, key_index, key);
251 }
252 
253 /* ****************************************************************************
254  功能描述  : 更新bip信息
255  修改历史      :
256   1.日    期   : 2014年11月21日
257     作    者   : HiSilicon
258     修改内容   : 新生成函数
259 **************************************************************************** */
mac_user_add_bip_key(mac_user_stru * mac_user,hi_u8 key_index,const mac_key_params_stru * key)260 WIFI_ROM_TEXT hi_u32 mac_user_add_bip_key(mac_user_stru *mac_user, hi_u8 key_index, const mac_key_params_stru *key)
261 {
262     /* keyid校验 */
263     if (key_index < WLAN_NUM_TK || key_index > WLAN_MAX_IGTK_KEY_INDEX) {
264         return HI_ERR_CODE_SECURITY_KEY_ID;
265     }
266 
267     if (memcpy_s(mac_user->key_info.ast_key[key_index].auc_key, WLAN_WPA_KEY_LEN, key->auc_key,
268         (hi_u32)key->key_len) != EOK) {
269         return HI_FAIL;
270     }
271     if (memcpy_s(mac_user->key_info.ast_key[key_index].auc_seq, WLAN_WPA_SEQ_LEN, key->auc_seq,
272         (hi_u32)key->seq_len) != EOK) {
273         return HI_FAIL;
274     }
275     mac_user->key_info.ast_key[key_index].cipher = key->cipher;
276     mac_user->key_info.ast_key[key_index].key_len = (hi_u32)key->key_len;
277     mac_user->key_info.ast_key[key_index].seq_len = (hi_u32)key->seq_len;
278 
279     mac_user->key_info.igtk_key_index = key_index;
280     return HI_SUCCESS;
281 }
282 
283 /* ****************************************************************************
284  功能描述  : 初始化用户的密钥信息
285  修改历史      :
286   1.日    期   : 2015年5月14日
287     作    者   : HiSilicon
288     修改内容   : 新生成函数
289 **************************************************************************** */
mac_user_init_key(mac_user_stru * mac_user)290 WIFI_ROM_TEXT hi_void mac_user_init_key(mac_user_stru *mac_user)
291 {
292     /* 安全编程规则6.6例外(1) 对固定长度的数组进行初始化,或对固定长度的结构体进行内存初始化 */
293     memset_s(&mac_user->key_info, sizeof(mac_key_mgmt_stru), 0, sizeof(mac_key_mgmt_stru));
294     mac_user->key_info.cipher_type = WLAN_80211_CIPHER_SUITE_NO_ENCRYP;
295     mac_user->key_info.last_gtk_key_idx = 0xFF;
296 }
297 
298 /* ****************************************************************************
299  功能描述  : 初始化mac user公共部分
300  输入参数  : pst_mac_user: 指向user的结构体
301              uc_user_idx : 用户索引
302              puc_mac_addr: MAC地址
303              uc_vap_id   :
304  修改历史      :
305   1.日    期   : 2013年8月21日
306     作    者   : HiSilicon
307     修改内容   : 新生成函数
308 **************************************************************************** */
mac_user_init(mac_user_stru * mac_user,hi_u8 user_idx,const hi_u8 * mac_addr,hi_u8 vap_id)309 WIFI_ROM_TEXT hi_void mac_user_init(mac_user_stru *mac_user, hi_u8 user_idx, const hi_u8 *mac_addr, hi_u8 vap_id)
310 {
311     /* 初始清0 */
312     if (memset_s(mac_user, sizeof(mac_user_stru), 0, sizeof(mac_user_stru)) != EOK) {
313         return;
314     }
315     mac_user->is_user_alloced = MAC_USER_ALLOCED;
316     mac_user->vap_id = vap_id;
317     mac_user->us_assoc_id = user_idx;
318     /* 初始化密钥 */
319     mac_user->user_tx_info.security.cipher_key_type = WLAN_KEY_TYPE_PTK;
320     mac_user->user_tx_info.security.cipher_protocol_type = WLAN_80211_CIPHER_SUITE_NO_ENCRYP;
321     /* 初始化安全加密信息 */
322     mac_user_init_key(mac_user);
323     mac_user_set_key(mac_user, WLAN_KEY_TYPE_PTK, WLAN_80211_CIPHER_SUITE_NO_ENCRYP, 0);
324     mac_user->port_valid = HI_FALSE;
325     mac_user->user_asoc_state = MAC_USER_STATE_BUTT;
326 
327     if (mac_addr == HI_NULL) {
328         mac_user->is_multi_user = HI_TRUE;
329         mac_user->user_asoc_state = MAC_USER_STATE_ASSOC;
330     } else {
331         /* 初始化一个用户是否是组播用户的标志,组播用户初始化时不会调用本函数 */
332         mac_user->is_multi_user = HI_FALSE;
333         /* 设置mac地址 */
334         if (memcpy_s(mac_user->user_mac_addr, WLAN_MAC_ADDR_LEN, mac_addr, WLAN_MAC_ADDR_LEN) != EOK) {
335             return;
336         }
337     }
338     mac_user->mesh_user_leave = HI_FALSE;
339     /* 初始化能力 */
340     mac_user_set_pmf_active(mac_user, HI_FALSE);
341     mac_user_set_avail_num_spatial_stream(mac_user, MAC_USER_INIT_STREAM);
342 #ifdef _PRE_WLAN_FEATURE_MESH_ROM
343     /* RSSI统计量初始化 */
344     mac_user->rx_conn_rssi = WLAN_RSSI_DUMMY_MARKER;
345 #endif
346 }
347 
348 /* ****************************************************************************
349  功能描述  : 设置可用带宽的信息
350  修改历史      :
351   1.日    期   : 2015年4月27日
352     作    者   : HiSilicon
353     修改内容   : 新生成函数
354   1.日    期   : 2015年5月27日
355     作    者   : HiSilicon
356     修改内容   : 针对协议切换, 对带宽更新进行特殊判断
357 **************************************************************************** */
mac_user_set_bandwidth_info(mac_user_stru * mac_user,wlan_bw_cap_enum_uint8 avail_bandwidth,wlan_bw_cap_enum_uint8 cur_bandwidth)358 WIFI_ROM_TEXT hi_void mac_user_set_bandwidth_info(mac_user_stru *mac_user, wlan_bw_cap_enum_uint8 avail_bandwidth,
359     wlan_bw_cap_enum_uint8 cur_bandwidth)
360 {
361     mac_user->avail_bandwidth = avail_bandwidth;
362     mac_user->cur_bandwidth = cur_bandwidth;
363     /* Autorate将协议从11n切换成11b后, cur_bandwidth会变为20M
364        此时如果软件将带宽改为40M, cur_bandwidth仍需要保持20M */
365     if ((WLAN_LEGACY_11B_MODE == mac_user->cur_protocol_mode) && (WLAN_BW_CAP_20M != mac_user->cur_bandwidth)) {
366         mac_user->cur_bandwidth = WLAN_BW_CAP_20M;
367     }
368 }
369 
370 /* ****************************************************************************
371  功能描述  : 获取用户的带宽
372  修改历史      :
373   1.日    期   : 2013年10月15日
374     作    者   : HiSilicon
375     修改内容   : 新生成函数
376 *****************************************************************************/
mac_user_get_sta_cap_bandwidth(mac_user_stru * mac_user,wlan_bw_cap_enum_uint8 * pen_bandwidth_cap)377 WIFI_ROM_TEXT hi_void mac_user_get_sta_cap_bandwidth(mac_user_stru *mac_user,
378                                                      wlan_bw_cap_enum_uint8 *pen_bandwidth_cap)
379 {
380     mac_user_ht_hdl_stru *mac_ht_hdl = HI_NULL;
381 
382     *pen_bandwidth_cap = WLAN_BW_CAP_20M;
383     /* 获取HT和VHT结构体指针 */
384     mac_ht_hdl = &(mac_user->ht_hdl);
385 
386     if (mac_ht_hdl->ht_capable) {
387         if (mac_ht_hdl->ht_capinfo.supported_channel_width == HI_TRUE) {
388             *pen_bandwidth_cap = WLAN_BW_CAP_40M;
389         }
390     } else {
391         /* else分支不需要处理 使用默认值20M */
392     }
393     mac_user_set_bandwidth_cap(mac_user, *pen_bandwidth_cap);
394 }
395 
396 /* ****************************************************************************
397  功能描述  : 设置en_user_asoc_state 的统一接口
398  修改历史      :
399   1.日    期   : 2015年5月3日
400     作    者   : HiSilicon
401     修改内容   : 新生成函数
402 **************************************************************************** */
mac_user_set_asoc_state(mac_user_stru * mac_user,mac_user_asoc_state_enum_uint8 value)403 WIFI_ROM_TEXT hi_void mac_user_set_asoc_state(mac_user_stru *mac_user, mac_user_asoc_state_enum_uint8 value)
404 {
405     mac_user->user_asoc_state = value;
406 }
407 
408 /* ****************************************************************************
409  功能描述  : 对用户的ht信息进行设置
410  修改历史      :
411   1.日    期   : 2015年5月6日
412     作    者   : HiSilicon
413     修改内容   : 新生成函数
414 **************************************************************************** */
mac_user_set_ht_hdl(mac_user_stru * mac_user,const mac_user_ht_hdl_stru * ht_hdl)415 WIFI_ROM_TEXT hi_void mac_user_set_ht_hdl(mac_user_stru *mac_user, const mac_user_ht_hdl_stru *ht_hdl)
416 {
417     if (memcpy_s((hi_u8 *)(&mac_user->ht_hdl), sizeof(mac_user_ht_hdl_stru), (hi_u8 *)ht_hdl,
418         sizeof(mac_user_ht_hdl_stru)) != EOK) {
419         return;
420     }
421 }
422 
423 /* ****************************************************************************
424  功能描述  : 获取用户的ht信息
425  修改历史      :
426   1.日    期   : 2015年5月6日
427     作    者   : HiSilicon
428     修改内容   : 新生成函数
429 
430 **************************************************************************** */
mac_user_get_ht_hdl(const mac_user_stru * mac_user,mac_user_ht_hdl_stru * ht_hdl)431 WIFI_ROM_TEXT hi_void mac_user_get_ht_hdl(const mac_user_stru *mac_user, mac_user_ht_hdl_stru *ht_hdl)
432 {
433     if (memcpy_s((hi_u8 *)ht_hdl, sizeof(mac_user_ht_hdl_stru), (hi_u8 *)(&mac_user->ht_hdl),
434         sizeof(mac_user_ht_hdl_stru)) != EOK) {
435         return;
436     }
437 }
438 
439 /* ****************************************************************************
440  功能描述  : 设置用户wep加密密钥信息
441  修改历史      :
442   1.日    期   : 2014年1月26日
443     作    者   : HiSilicon
444     修改内容   : 新生成函数
445 **************************************************************************** */
mac_user_update_wep_key(mac_user_stru * mac_usr,hi_u8 multi_user_idx)446 WIFI_ROM_TEXT hi_u32 mac_user_update_wep_key(mac_user_stru *mac_usr, hi_u8 multi_user_idx)
447 {
448     mac_user_stru *multi_user = HI_NULL;
449 
450     multi_user = mac_user_get_user_stru(multi_user_idx);
451     if (multi_user == HI_NULL) {
452         return HI_ERR_CODE_SECURITY_USER_INVAILD;
453     }
454     if (multi_user->key_info.cipher_type != WLAN_80211_CIPHER_SUITE_WEP_104 &&
455         multi_user->key_info.cipher_type != WLAN_80211_CIPHER_SUITE_WEP_40) {
456         oam_error_log1(0, OAM_SF_WPA, "{mac_wep_add_usr_key::en_cipher_type==%d}", multi_user->key_info.cipher_type);
457         return HI_ERR_CODE_SECURITY_CHIPER_TYPE;
458     }
459     if (multi_user->key_info.default_index >= WLAN_MAX_WEP_KEY_COUNT) {
460         return HI_ERR_CODE_SECURITY_KEY_ID;
461     }
462     /* wep加密下,拷贝组播用户的密钥信息到单播用户 */
463     /* 安全编程规则6.6例外(1) 固定长度的结构体进行内存初始化 */
464     memcpy_s(&mac_usr->key_info, sizeof(mac_key_mgmt_stru), &multi_user->key_info, sizeof(mac_key_mgmt_stru));
465     mac_usr->user_tx_info.security.cipher_key_type = mac_usr->key_info.default_index + HAL_KEY_TYPE_PTK;
466     return HI_SUCCESS;
467 }
468 
469 /* ****************************************************************************
470  功能描述  : 判断mac地址是否全0
471  修改历史      :
472   1.日    期   : 2014年11月21日
473     作    者   : HiSilicon
474     修改内容   : 新生成函数
475 **************************************************************************** */
mac_addr_is_zero(const hi_u8 * mac_addr)476 WIFI_ROM_TEXT hi_u8 mac_addr_is_zero(const hi_u8 *mac_addr)
477 {
478     hi_u8 zero_mac_addr[OAL_MAC_ADDR_LEN] = {0};
479 
480     if (mac_addr == HI_NULL) {
481         return HI_TRUE;
482     }
483 
484     return (0 == memcmp(zero_mac_addr, mac_addr, OAL_MAC_ADDR_LEN));
485 }
486 
487 /* 代码ROM段结束位置 新增ROM代码请放在SECTION中 */
488 #undef __WIFI_ROM_SECTION__
489 
490 /* ****************************************************************************
491  功能描述  : 根据en_key_type,调用相应的函数,更新vap信息
492  修改历史      :
493   1.日    期   : 2014年11月21日
494     作    者   : HiSilicon
495     修改内容   : 新生成函数
496 **************************************************************************** */
mac_user_get_key(mac_user_stru * mac_user,hi_u8 key_id)497 wlan_priv_key_param_stru *mac_user_get_key(mac_user_stru *mac_user, hi_u8 key_id)
498 {
499     if (key_id >= WLAN_NUM_TK + WLAN_NUM_IGTK) {
500         return HI_NULL;
501     }
502     return &mac_user->key_info.ast_key[key_id];
503 }
504 
505 /* ****************************************************************************
506  功能描述  : 根据AP的operation ie获取ap的工作带宽
507  修改历史      :
508   1.日    期   : 2014年4月26日
509     作    者   : HiSilicon
510     修改内容   : 新生成函数
511 **************************************************************************** */
mac_user_get_ap_opern_bandwidth(mac_user_stru * mac_user,wlan_bw_cap_enum_uint8 * pen_bandwidth_cap)512 hi_void mac_user_get_ap_opern_bandwidth(mac_user_stru *mac_user, wlan_bw_cap_enum_uint8 *pen_bandwidth_cap)
513 {
514     mac_user_ht_hdl_stru *mac_ht_hdl = HI_NULL;
515     wlan_bw_cap_enum_uint8 bandwidth_cap;
516 
517     bandwidth_cap = WLAN_BW_CAP_20M;
518     /* 获取HT和VHT结构体指针 */
519     mac_ht_hdl = &(mac_user->ht_hdl);
520 
521     if (mac_ht_hdl->ht_capable) {
522         if (mac_ht_hdl->secondary_chan_offset != MAC_SCN) {
523             bandwidth_cap = WLAN_BW_CAP_40M;
524         }
525     }
526 
527     *pen_bandwidth_cap = bandwidth_cap;
528     mac_user_set_bandwidth_cap(mac_user, bandwidth_cap);
529 }
530 
531 /* ****************************************************************************
532  功能描述  : 设置ht cap信息
533  修改历史      :
534   1.日    期   : 2015年5月7日
535     作    者   : HiSilicon
536     修改内容   : 新生成函数
537 **************************************************************************** */
mac_user_set_ht_capable(mac_user_stru * mac_user,hi_u8 ht_capable)538 hi_void mac_user_set_ht_capable(mac_user_stru *mac_user, hi_u8 ht_capable)
539 {
540     mac_user->ht_hdl.ht_capable = ht_capable;
541 }
542 
543 /* ****************************************************************************
544  功能描述  : 设置更新用户bit_spectrum_mgmt能力的信息
545  修改历史      :
546   1.日    期   : 2015年5月11日
547     作    者   : HiSilicon
548     修改内容   : 新生成函数
549 **************************************************************************** */
mac_user_set_spectrum_mgmt(mac_user_stru * mac_user,hi_u8 spectrum_mgmt)550 hi_void mac_user_set_spectrum_mgmt(mac_user_stru *mac_user, hi_u8 spectrum_mgmt)
551 {
552     mac_user->cap_info.spectrum_mgmt = spectrum_mgmt;
553 }
554 
555 /* ****************************************************************************
556  功能描述  : 设置用户公共区域的bit_apsd能力
557  修改历史      :
558   1.日    期   : 2015年5月21日
559     作    者   : HiSilicon
560     修改内容   : 新生成函数
561 **************************************************************************** */
mac_user_set_apsd(mac_user_stru * mac_user,hi_u8 apsd)562 hi_void mac_user_set_apsd(mac_user_stru *mac_user, hi_u8 apsd)
563 {
564     mac_user->cap_info.apsd = apsd;
565 }
566 
mac_user_is_user_valid(hi_u8 idx)567 hi_u8 mac_user_is_user_valid(hi_u8 idx)
568 {
569     return (g_us_user_res_map & ((hi_u16)BIT0 << idx)) ? HI_TRUE : HI_FALSE;
570 }
571 #ifdef __cplusplus
572 #if __cplusplus
573 }
574 #endif
575 #endif
576