1 /** @file 2 The Miscellaneous Routines for WiFi Connection Manager. 3 4 Copyright (c) 2019, Intel Corporation. All rights reserved.<BR> 5 6 SPDX-License-Identifier: BSD-2-Clause-Patent 7 8 **/ 9 10 #ifndef __EFI_WIFI_MGR_MISC_H__ 11 #define __EFI_WIFI_MGR_MISC_H__ 12 13 /** 14 Empty function for event process function. 15 16 @param[in] Event The Event needs to be processed 17 @param[in] Context The context of the event 18 19 **/ 20 VOID 21 EFIAPI 22 WifiMgrInternalEmptyFunction ( 23 IN EFI_EVENT Event, 24 IN VOID *Context 25 ); 26 27 /** 28 Convert the mac address into a hexadecimal encoded ":" seperated string. 29 30 @param[in] Mac The mac address 31 @param[in] StrSize The size, in bytes, of the output buffer specified by Str 32 @param[out] Str The storage to return the mac string 33 34 **/ 35 VOID 36 WifiMgrMacAddrToStr ( 37 IN EFI_80211_MAC_ADDRESS *Mac, 38 IN UINT32 StrSize, 39 OUT CHAR16 *Str 40 ); 41 42 /** 43 Read private key file to buffer. 44 45 @param[in] FileContext The file context of private key file. 46 @param[out] PrivateKeyDataAddr The buffer address to restore private key file, should be 47 freed by caller. 48 @param[out] PrivateKeyDataSize The size of read private key file. 49 50 @retval EFI_SUCCESS Successfully read the private key file. 51 @retval EFI_INVALID_PARAMETER One or more of the parameters is invalid. 52 53 **/ 54 EFI_STATUS 55 WifiMgrReadFileToBuffer ( 56 IN WIFI_MGR_FILE_CONTEXT *FileContext, 57 OUT VOID **PrivateKeyDataAddr, 58 OUT UINTN *PrivateKeyDataSize 59 ); 60 61 62 /** 63 Get the Nic data by the NicIndex. 64 65 @param[in] Private The pointer to the global private data structure. 66 @param[in] NicIndex The index indicates the position of wireless NIC. 67 68 @return Pointer to the Nic data, or NULL if not found. 69 70 **/ 71 WIFI_MGR_DEVICE_DATA * 72 WifiMgrGetNicByIndex ( 73 IN WIFI_MGR_PRIVATE_DATA *Private, 74 IN UINT32 NicIndex 75 ); 76 77 /** 78 Find a network profile through its' SSId and securit type, and the SSId is an unicode string. 79 80 @param[in] SSId The target network's SSId. 81 @param[in] SecurityType The target network's security type. 82 @param[in] ProfileList The profile list on a Nic. 83 84 @return Pointer to a network profile, or NULL if not found. 85 86 **/ 87 WIFI_MGR_NETWORK_PROFILE * 88 WifiMgrGetProfileByUnicodeSSId ( 89 IN CHAR16 *SSId, 90 IN UINT8 SecurityType, 91 IN LIST_ENTRY *ProfileList 92 ); 93 94 /** 95 Find a network profile through its' SSId and securit type, and the SSId is an ascii string. 96 97 @param[in] SSId The target network's SSId. 98 @param[in] SecurityType The target network's security type. 99 @param[in] ProfileList The profile list on a Nic. 100 101 @return Pointer to a network profile, or NULL if not found. 102 103 **/ 104 WIFI_MGR_NETWORK_PROFILE * 105 WifiMgrGetProfileByAsciiSSId ( 106 IN CHAR8 *SSId, 107 IN UINT8 SecurityType, 108 IN LIST_ENTRY *ProfileList 109 ); 110 111 /** 112 Find a network profile through its' profile index. 113 114 @param[in] ProfileIndex The target network's profile index. 115 @param[in] ProfileList The profile list on a Nic. 116 117 @return Pointer to a network profile, or NULL if not found. 118 119 **/ 120 WIFI_MGR_NETWORK_PROFILE * 121 WifiMgrGetProfileByProfileIndex ( 122 IN UINT32 ProfileIndex, 123 IN LIST_ENTRY *ProfileList 124 ); 125 126 /** 127 To test if the AKMSuite is in supported AKMSuite list. 128 129 @param[in] SupportedAKMSuiteCount The count of the supported AKMSuites. 130 @param[in] SupportedAKMSuiteList The supported AKMSuite list. 131 @param[in] AKMSuite The AKMSuite to be tested. 132 133 @return True if this AKMSuite is supported, or False if not. 134 135 **/ 136 BOOLEAN 137 WifiMgrSupportAKMSuite ( 138 IN UINT16 SupportedAKMSuiteCount, 139 IN UINT32 *SupportedAKMSuiteList, 140 IN UINT32 *AKMSuite 141 ); 142 143 /** 144 To check if the CipherSuite is in supported CipherSuite list. 145 146 @param[in] SupportedCipherSuiteCount The count of the supported CipherSuites. 147 @param[in] SupportedCipherSuiteList The supported CipherSuite list. 148 @param[in] CipherSuite The CipherSuite to be tested. 149 150 @return True if this CipherSuite is supported, or False if not. 151 152 **/ 153 BOOLEAN 154 WifiMgrSupportCipherSuite ( 155 IN UINT16 SupportedCipherSuiteCount, 156 IN UINT32 *SupportedCipherSuiteList, 157 IN UINT32 *CipherSuite 158 ); 159 160 /** 161 Check an AKM suite list and a Cipher suite list to see if one or more AKM suites or Cipher suites 162 are supported and find the matchable security type. 163 164 @param[in] AKMList The target AKM suite list to be checked. 165 @param[in] CipherList The target Cipher suite list to be checked 166 @param[in] Nic The Nic to operate, contains the supported AKMSuite list 167 and supported CipherSuite list 168 @param[out] SecurityType To identify a security type from the AKM suite list and 169 Cipher suite list 170 @param[out] AKMSuiteSupported To identify if this security type is supported. If it is 171 NULL, overcome this field 172 @param[out] CipherSuiteSupported To identify if this security type is supported. If it is 173 NULL, overcome this field 174 175 @retval EFI_SUCCESS This operation has completed successfully. 176 @retval EFI_INVALID_PARAMETER No Nic found or the suite list is null. 177 178 **/ 179 EFI_STATUS 180 WifiMgrCheckRSN ( 181 IN EFI_80211_AKM_SUITE_SELECTOR *AKMList, 182 IN EFI_80211_CIPHER_SUITE_SELECTOR *CipherList, 183 IN WIFI_MGR_DEVICE_DATA *Nic, 184 OUT UINT8 *SecurityType, 185 OUT BOOLEAN *AKMSuiteSupported, 186 OUT BOOLEAN *CipherSuiteSupported 187 ); 188 189 /** 190 To get the security type for a certain AKMSuite and CipherSuite. 191 192 @param[in] AKMSuite An certain AKMSuite. 193 @param[in] CipherSuite An certain CipherSuite. 194 195 @return a security type if found, or SECURITY_TYPE_UNKNOWN. 196 197 **/ 198 UINT8 199 WifiMgrGetSecurityType ( 200 IN UINT32 *AKMSuite, 201 IN UINT32 *CipherSuite 202 ); 203 204 /** 205 Get supported AKMSuites and CipherSuites from supplicant. 206 207 @param[in] Nic The Nic to operate. 208 209 @retval EFI_SUCCESS Get the supported suite list successfully. 210 @retval EFI_INVALID_PARAMETER No Nic found or supplicant is NULL. 211 212 **/ 213 EFI_STATUS 214 WifiMgrGetSupportedSuites ( 215 IN WIFI_MGR_DEVICE_DATA *Nic 216 ); 217 218 /** 219 Clean secrets from a network profile. 220 221 @param[in] Profile The profile to be cleanned. 222 223 **/ 224 VOID 225 WifiMgrCleanProfileSecrets ( 226 IN WIFI_MGR_NETWORK_PROFILE *Profile 227 ); 228 229 /** 230 Free all network profiles in a profile list. 231 232 @param[in] ProfileList The profile list to be freed. 233 234 **/ 235 VOID 236 WifiMgrFreeProfileList ( 237 IN LIST_ENTRY *ProfileList 238 ); 239 240 /** 241 Free user configured hidden network list. 242 243 @param[in] HiddenList The hidden network list to be freed. 244 245 **/ 246 VOID 247 WifiMgrFreeHiddenList ( 248 IN LIST_ENTRY *HiddenList 249 ); 250 251 /** 252 Free the resources of a config token. 253 254 @param[in] ConfigToken The config token to be freed. 255 256 **/ 257 VOID 258 WifiMgrFreeToken ( 259 IN WIFI_MGR_MAC_CONFIG_TOKEN *ConfigToken 260 ); 261 262 #endif 263