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 #include "oal_mem.h"
20 #include "wlan_types.h"
21 #include "mac_vap.h"
22 #include "mac_device.h"
23 #include "mac_regdomain.h"
24
25 #ifdef __cplusplus
26 #if __cplusplus
27 extern "C" {
28 #endif
29 #endif
30
31 #ifdef _PRE_WLAN_FEATURE_MESH_ROM
32 /* ****************************************************************************
33 功能描述 : 设置Mesh ID值
34 输入参数 : [1]mac_vap mac vap结构体
35 [2]len
36 [3]puc_param
37 返 回 值 : hi_u32
38 **************************************************************************** */
mac_mib_set_meshid(const mac_vap_stru * mac_vap,hi_u8 len,const hi_u8 * puc_param)39 WIFI_ROM_TEXT hi_u32 mac_mib_set_meshid(const mac_vap_stru *mac_vap, hi_u8 len, const hi_u8 *puc_param)
40 {
41 mac_cfg_ssid_param_stru *param = HI_NULL;
42 hi_u8 *puc_mib_meshid = HI_NULL;
43 hi_u8 meshid_len;
44
45 hi_unref_param(len);
46
47 param = (mac_cfg_ssid_param_stru *)puc_param;
48 meshid_len = param->ssid_len; /* 长度不包括字符串结尾'\0' */
49 /* uc_len 长度不包括字符串结尾'\0' */
50 if (meshid_len > WLAN_SSID_MAX_LEN - 1) {
51 meshid_len = WLAN_SSID_MAX_LEN - 1;
52 }
53 puc_mib_meshid = mac_vap->mib_info->wlan_mib_mesh_sta_cfg.auc_dot11_mesh_id;
54 if (memcpy_s(puc_mib_meshid, WLAN_SSID_MAX_LEN, param->ac_ssid, meshid_len) != EOK) {
55 return HI_FAIL;
56 }
57 puc_mib_meshid[meshid_len] = '\0';
58 return HI_SUCCESS;
59 }
60
61 /* ****************************************************************************
62 功能描述 : 获取Mesh ID值
63 输入参数 : [1]mac_vap mac vap结构体
64 [2]puc_len
65 [3]puc_param
66 返 回 值 : hi_u32
67 **************************************************************************** */
mac_mib_get_meshid(const mac_vap_stru * mac_vap,hi_u8 * puc_len,const hi_u8 * puc_param)68 WIFI_ROM_TEXT hi_u32 mac_mib_get_meshid(const mac_vap_stru *mac_vap, hi_u8 *puc_len, const hi_u8 *puc_param)
69 {
70 mac_cfg_ssid_param_stru *param = HI_NULL;
71 hi_u8 meshid_len;
72 hi_u8 *puc_mib_meshid = HI_NULL;
73
74 puc_mib_meshid = mac_vap->mib_info->wlan_mib_mesh_sta_cfg.auc_dot11_mesh_id;
75 meshid_len = (hi_u8)strlen((hi_char *)puc_mib_meshid);
76
77 param = (mac_cfg_ssid_param_stru *)puc_param;
78
79 param->ssid_len = meshid_len;
80 if (memcpy_s(param->ac_ssid, WLAN_SSID_MAX_LEN, puc_mib_meshid, meshid_len) != EOK) {
81 return HI_FAIL;
82 }
83
84 *puc_len = sizeof(mac_cfg_ssid_param_stru);
85
86 return HI_SUCCESS;
87 }
88 #endif
89
90 /* ****************************************************************************
91 功能描述 : 获取实现的pairwise cipher suites个数
92 输入参数 : pst_mac_vap: 指向vap
93 输出参数 : puc_num : 实现的pairwise cipher suites个数
94 修改历史 :
95 1.日 期 : 2013年4月16日
96 作 者 : HiSilicon
97 修改内容 : 新生成函数
98 **************************************************************************** */
mac_mib_get_wpa_pairwise_cipher_suite(const mac_vap_stru * mac_vap,hi_u8 * puc_num)99 WIFI_ROM_TEXT hi_void mac_mib_get_wpa_pairwise_cipher_suite(const mac_vap_stru *mac_vap, hi_u8 *puc_num)
100 {
101 hi_u8 num = 0;
102 hi_u8 loop;
103 wlan_mib_dot11_rsna_cfg_pwise_cpher_en_stru *wlan_mib_rsna_cfg_wpa_pairwise_cipher;
104
105 wlan_mib_rsna_cfg_wpa_pairwise_cipher = mac_vap->mib_info->ast_wlan_mib_rsna_cfg_wpa_pairwise_cipher;
106
107 for (loop = 0; loop < WLAN_PAIRWISE_CIPHER_SUITES; loop++) {
108 if (wlan_mib_rsna_cfg_wpa_pairwise_cipher[loop].dot11_rsna_config_pairwise_cipher_activated) {
109 num++;
110 }
111 }
112 *puc_num = num;
113 }
114
115 /* ****************************************************************************
116 功能描述 : 获取实现的pairwise cipher suites个数
117 输入参数 : pst_mac_vap: 指向vap
118 输出参数 : puc_num : 实现的pairwise cipher suites个数
119 修改历史 :
120 1.日 期 : 2013年4月16日
121 作 者 : HiSilicon
122 修改内容 : 新生成函数
123 **************************************************************************** */
mac_mib_get_wpa2_pairwise_cipher_suite(const mac_vap_stru * mac_vap,hi_u8 * puc_num)124 WIFI_ROM_TEXT hi_void mac_mib_get_wpa2_pairwise_cipher_suite(const mac_vap_stru *mac_vap, hi_u8 *puc_num)
125 {
126 hi_u8 num = 0;
127 hi_u8 loop;
128 wlan_mib_dot11_rsna_cfg_pwise_cpher_en_stru *wlan_mib_rsna_cfg_wpa2_pairwise_cipher =
129 mac_vap->mib_info->ast_wlan_mib_rsna_cfg_wpa2_pairwise_cipher;
130
131 for (loop = 0; loop < WLAN_PAIRWISE_CIPHER_SUITES; loop++) {
132 if (wlan_mib_rsna_cfg_wpa2_pairwise_cipher[loop].dot11_rsna_config_pairwise_cipher_activated) {
133 num++;
134 }
135 }
136 *puc_num = num;
137 }
138
139 /* ****************************************************************************
140 功能描述 : 获取实现的authentication suites个数
141 输入参数 : pst_mac_vap: 指向vap
142 输出参数 : puc_num : 实现的authentication suites个数
143 修改历史 :
144 1.日 期 : 2013年4月16日
145 作 者 : HiSilicon
146 修改内容 : 新生成函数
147 2.日 期 : 2019年1月23日
148 作 者 : HiSilicon
149 修改内容 : 新增参数uc_is_mesh_rsn
150
151 **************************************************************************** */
mac_mib_get_authentication_suite(const mac_vap_stru * mac_vap,hi_u8 * puc_num)152 WIFI_ROM_TEXT hi_void mac_mib_get_authentication_suite(const mac_vap_stru *mac_vap, hi_u8 *puc_num)
153 {
154 hi_u8 num = 0;
155 hi_u8 loop;
156 hi_u8 auth_suite_num = MAC_AUTHENTICATION_SUITE_NUM;
157 wlan_mib_dot11_rsna_cfg_authentication_suites_en_stru *wlan_mib_rsna_cfg_auth_suite =
158 mac_vap->mib_info->ast_wlan_mib_rsna_cfg_auth_suite;
159
160 for (loop = 0; loop < auth_suite_num; loop++) {
161 if (wlan_mib_rsna_cfg_auth_suite[loop].dot11_rsna_config_authentication_suite_activated) {
162 num++;
163 }
164 }
165 *puc_num = num;
166 }
167
168 /* ****************************************************************************
169 功能描述 : 获取实现的pairwise cipher suites 加密套件值
170 输入参数 : pst_mac_vap : 指向vap
171 输出参数 : puc_pairwise_value : 实现的pairwise cipher suites 加密套件值
172 修改历史 :
173 1.日 期 : 2014年4月22日
174 作 者 : HiSilicon
175 修改内容 : 新生成函数
176 **************************************************************************** */
mac_mib_get_wpa2_pairwise_cipher_suite_value(const mac_vap_stru * mac_vap,hi_u8 * puc_pairwise_value,hi_u8 pairwise_len)177 WIFI_ROM_TEXT hi_void mac_mib_get_wpa2_pairwise_cipher_suite_value(const mac_vap_stru *mac_vap,
178 hi_u8 *puc_pairwise_value, hi_u8 pairwise_len)
179 {
180 hi_u8 loop;
181 hi_u8 pairwise_index = 0;
182 wlan_mib_dot11_rsna_cfg_pwise_cpher_en_stru *wlan_mib_rsna_cfg_wpa2_pairwise_cipher;
183
184 wlan_mib_rsna_cfg_wpa2_pairwise_cipher = mac_vap->mib_info->ast_wlan_mib_rsna_cfg_wpa2_pairwise_cipher;
185
186 for (loop = 0; loop < pairwise_len; loop++) {
187 if (wlan_mib_rsna_cfg_wpa2_pairwise_cipher[loop].dot11_rsna_config_pairwise_cipher_activated) {
188 puc_pairwise_value[pairwise_index++] =
189 wlan_mib_rsna_cfg_wpa2_pairwise_cipher[loop].dot11_rsna_config_pairwise_cipher_implemented;
190 }
191 }
192 }
193
194 /* ****************************************************************************
195 功能描述 : 获取实现的pairwise cipher suites 加密套件值
196 输入参数 : pst_mac_vap : 指向vap
197 输出参数 : puc_pairwise_value : 实现的pairwise cipher suites 加密套件值
198 修改历史 :
199 1.日 期 : 2014年4月22日
200 作 者 : HiSilicon
201 修改内容 : 新生成函数
202 **************************************************************************** */
mac_mib_get_wpa_pairwise_cipher_suite_value(const mac_vap_stru * mac_vap,hi_u8 * puc_pairwise_value,hi_u8 pairwise_len)203 WIFI_ROM_TEXT hi_void mac_mib_get_wpa_pairwise_cipher_suite_value(const mac_vap_stru *mac_vap,
204 hi_u8 *puc_pairwise_value, hi_u8 pairwise_len)
205 {
206 hi_u8 loop;
207 hi_u8 pairwise_index = 0;
208 wlan_mib_dot11_rsna_cfg_pwise_cpher_en_stru *wlan_mib_rsna_cfg_wpa_pairwise_cipher;
209
210 wlan_mib_rsna_cfg_wpa_pairwise_cipher = mac_vap->mib_info->ast_wlan_mib_rsna_cfg_wpa_pairwise_cipher;
211
212 for (loop = 0; loop < pairwise_len; loop++) {
213 if (wlan_mib_rsna_cfg_wpa_pairwise_cipher[loop].dot11_rsna_config_pairwise_cipher_activated) {
214 puc_pairwise_value[pairwise_index++] =
215 wlan_mib_rsna_cfg_wpa_pairwise_cipher[loop].dot11_rsna_config_pairwise_cipher_implemented;
216 }
217 }
218 }
219
220 /* ****************************************************************************
221 功能描述 : 设置 RSN认证套件信息
222 修改历史 :
223 1.日 期 : 2014年08月14日
224 作 者 : HiSilicon
225 修改内容 : 新生成函数
226 **************************************************************************** */
mac_mib_set_rsna_auth_suite(const mac_vap_stru * mac_vap,hi_u8 auth_value)227 WIFI_ROM_TEXT hi_void mac_mib_set_rsna_auth_suite(const mac_vap_stru *mac_vap, hi_u8 auth_value)
228 {
229 hi_u8 index;
230
231 if ((auth_value == WLAN_AUTH_SUITE_1X) || (auth_value == WLAN_AUTH_SUITE_PSK)) {
232 index = 0;
233 } else if ((auth_value == WLAN_AUTH_SUITE_1X_SHA256) || (auth_value == WLAN_AUTH_SUITE_PSK_SHA256)) {
234 index = 1;
235 } else {
236 return;
237 }
238 mac_vap->mib_info->ast_wlan_mib_rsna_cfg_auth_suite[index].dot11_rsna_config_authentication_suite_implemented =
239 auth_value;
240 mac_vap->mib_info->ast_wlan_mib_rsna_cfg_auth_suite[index].dot11_rsna_config_authentication_suite_activated =
241 HI_TRUE;
242 }
243
mac_mib_set_rsnaconfig_wpa_pairwise_cipher_implemented(const mac_vap_stru * mac_vap,hi_u8 pairwise_value)244 WIFI_ROM_TEXT hi_void mac_mib_set_rsnaconfig_wpa_pairwise_cipher_implemented(const mac_vap_stru *mac_vap,
245 hi_u8 pairwise_value)
246 {
247 hi_u8 index;
248
249 if (pairwise_value == WLAN_80211_CIPHER_SUITE_CCMP) {
250 index = 0;
251 } else if (pairwise_value == WLAN_80211_CIPHER_SUITE_TKIP) {
252 index = 1;
253 } else {
254 hi_diag_log_msg_e1(0, "{mac_mib_set_RSNAConfigWpaPairwiseCipherImplemented::invalid uc_pairwise_value[%d].}",
255 pairwise_value);
256 return;
257 }
258 mac_vap->mib_info->ast_wlan_mib_rsna_cfg_wpa_pairwise_cipher[index].dot11_rsna_config_pairwise_cipher_implemented =
259 pairwise_value;
260 mac_vap->mib_info->ast_wlan_mib_rsna_cfg_wpa_pairwise_cipher[index].dot11_rsna_config_pairwise_cipher_activated =
261 HI_TRUE;
262 }
263
mac_mib_set_rsnaconfig_wpa2_pairwise_cipher_implemented(const mac_vap_stru * mac_vap,hi_u8 pairwise_value)264 WIFI_ROM_TEXT hi_void mac_mib_set_rsnaconfig_wpa2_pairwise_cipher_implemented(const mac_vap_stru *mac_vap,
265 hi_u8 pairwise_value)
266 {
267 hi_u8 index;
268
269 if (pairwise_value == WLAN_80211_CIPHER_SUITE_CCMP) {
270 index = 0;
271 } else if (pairwise_value == WLAN_80211_CIPHER_SUITE_TKIP) {
272 index = 1;
273 } else {
274 hi_diag_log_msg_e1(0, "{mac_mib_set_RSNAConfigWpa2PairwiseCipherImplemented::invalid uc_pairwise_value[%d].}",
275 pairwise_value);
276 return;
277 }
278 mac_vap->mib_info->ast_wlan_mib_rsna_cfg_wpa2_pairwise_cipher[index].dot11_rsna_config_pairwise_cipher_implemented =
279 pairwise_value;
280 mac_vap->mib_info->ast_wlan_mib_rsna_cfg_wpa2_pairwise_cipher[index].dot11_rsna_config_pairwise_cipher_activated =
281 HI_TRUE;
282 }
283
284 /* ****************************************************************************
285 功能描述 : 设置ssid mib值
286 输入参数 : pst_mac_vap: 指向mac vap结构体
287 uc_len : 参数长度
288 pc_param : 参数
289 修改历史 :
290 1.日 期 : 2013年1月15日
291 作 者 : HiSilicon
292 修改内容 : 新生成函数
293 **************************************************************************** */
mac_mib_set_ssid(const mac_vap_stru * mac_vap,hi_u8 len,const hi_u8 * puc_param)294 WIFI_ROM_TEXT hi_u32 mac_mib_set_ssid(const mac_vap_stru *mac_vap, hi_u8 len, const hi_u8 *puc_param)
295 {
296 mac_cfg_ssid_param_stru *param = HI_NULL;
297 hi_u8 ssid_len;
298 hi_u8 *puc_mib_ssid = HI_NULL;
299 hi_unref_param(len);
300 param = (mac_cfg_ssid_param_stru *)puc_param;
301 ssid_len = param->ssid_len; /* 长度不包括字符串结尾'\0' */
302 if (ssid_len > WLAN_SSID_MAX_LEN - 1) {
303 ssid_len = WLAN_SSID_MAX_LEN - 1;
304 }
305 puc_mib_ssid = mac_vap->mib_info->wlan_mib_sta_config.auc_dot11_desired_ssid;
306 if (memcpy_s(puc_mib_ssid, WLAN_SSID_MAX_LEN, param->ac_ssid, ssid_len) != EOK) {
307 return HI_FAIL;
308 }
309 puc_mib_ssid[ssid_len] = '\0';
310 return HI_SUCCESS;
311 }
312
313 /* ****************************************************************************
314 功能描述 : 读取ssid mib值
315 **************************************************************************** */
mac_mib_get_ssid(const mac_vap_stru * mac_vap,hi_u8 * puc_len,const hi_u8 * puc_param)316 hi_u32 mac_mib_get_ssid(const mac_vap_stru *mac_vap, hi_u8 *puc_len, const hi_u8 *puc_param)
317 {
318 mac_cfg_ssid_param_stru *param = HI_NULL;
319 hi_u8 ssid_len;
320 hi_u8 *puc_mib_ssid = HI_NULL;
321
322 puc_mib_ssid = mac_vap->mib_info->wlan_mib_sta_config.auc_dot11_desired_ssid;
323 ssid_len = (hi_u8)strlen((hi_char *)puc_mib_ssid);
324 param = (mac_cfg_ssid_param_stru *)puc_param;
325 param->ssid_len = ssid_len;
326 if (memcpy_s(param->ac_ssid, WLAN_SSID_MAX_LEN, puc_mib_ssid, ssid_len) != EOK) {
327 return HI_FAIL;
328 }
329 *puc_len = sizeof(mac_cfg_ssid_param_stru);
330 return HI_SUCCESS;
331 }
332
333 #ifdef __cplusplus
334 #if __cplusplus
335 }
336 #endif
337 #endif
338