1 /* 2 // Copyright (C) 2022 Beken Corporation 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #ifndef _ARCH_CONFIG_H_ 16 #define _ARCH_CONFIG_H_ 17 18 #include <common/bk_compiler.h> 19 20 //TODO 21 // 1. Rename this file 22 // 2. Optimize this file 23 24 #include <common/bk_include.h> 25 #include "modules/wifi_types.h" 26 27 #define CONFIG_ROLE_NULL 0 28 #define CONFIG_ROLE_AP 1 29 #define CONFIG_ROLE_STA 2 30 #define CONFIG_ROLE_COEXIST 3 31 32 #define DEFAULT_CHANNEL_AP 11 33 34 struct wifi_ssid { 35 /// Actual length of the SSID. 36 uint8_t length; 37 /// Array containing the SSID name. 38 uint8_t array[32]; 39 }; 40 41 #if CONFIG_MAC_BSSID 42 #define MAC_ADDR_LEN 6 43 /// MAC address structure. 44 struct mac_bssid 45 { 46 /// Array of 16-bit words that make up the MAC address. 47 uint16_t array[MAC_ADDR_LEN/2]; 48 } __bk_packed; 49 #endif 50 51 struct wifi_bssid { 52 uint8_t bssid[6]; 53 }; 54 55 typedef struct fast_connect_param { 56 uint8_t bssid[6]; 57 uint8_t chann; 58 } fast_connect_param_t; 59 60 typedef struct general_param { 61 uint8_t role; 62 uint8_t dhcp_enable; 63 uint32_t ip_addr; 64 uint32_t ip_mask; 65 uint32_t ip_gw; 66 } general_param_t; 67 68 typedef struct ap_param { 69 #if CONFIG_MAC_BSSID 70 struct mac_bssid bssid; 71 #else 72 struct wifi_bssid bssid; 73 #endif 74 struct wifi_ssid ssid; 75 76 uint8_t chann; 77 uint8_t cipher_suite; 78 uint8_t key[65]; 79 uint8_t key_len; 80 #if CONFIG_AP_VSIE 81 uint8_t vsie[255]; 82 uint8_t vsie_len; 83 #endif 84 } ap_param_t; 85 86 typedef struct sta_param { 87 uint8_t own_mac[6]; 88 struct wifi_ssid ssid; 89 uint8_t cipher_suite; 90 uint8_t key[65]; 91 uint8_t key_len; 92 uint8_t fast_connect_set; 93 fast_connect_param_t fast_connect; 94 95 #if CONFIG_COMPONENTS_STA_VSIE 96 struct { 97 uint8_t len; 98 uint8_t buf[255]; 99 } vsies[NUM_WIFI_VENDOR_ELEM_FRAMES]; 100 #endif 101 102 #if CONFIG_COMPONENTS_WPA2_ENTERPRISE 103 /* starts of WPA2-Enterprise/WPA3-Enterprise EAP-TLS configuration */ 104 char eap[16]; /**< phase1 authType: TLS/TTLS/SIM */ 105 char identity[32]; /**< user identity */ 106 char ca[32]; /**< CA certificate filename */ 107 char client_cert[32]; /**< client's Certification filename in PEM,DER format */ 108 char private_key[32]; /**< client's private key filename in PEM,DER format */ 109 char private_key_passwd[32]; /**< client's private key password */ 110 char phase1[32]; /**< client's phase1 parameters */ 111 #endif 112 113 int auto_reconnect_count; /**< auto reconnect max count, 0 for always reconnect */ 114 int auto_reconnect_timeout; /**< auto reconnect timeout in secs, 0 for no timeout */ 115 bool disable_auto_reconnect_after_disconnect; /**< disable auto reconnect if deauth/disassoc by AP when in connected state */ 116 } sta_param_t; 117 118 extern general_param_t *g_wlan_general_param; 119 extern ap_param_t *g_ap_param_ptr; 120 extern sta_param_t *g_sta_param_ptr; 121 122 uint32_t cfg_param_init(void); 123 124 //Optimize it 125 __attribute__((weak)) uint32_t cfg_ap_is_open_system(void); 126 #endif 127