WifiConnectionMgrMisc.h 7.6 KB

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