From nobody Fri Mar 29 09:56:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+96355+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+96355+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1668449531; cv=none; d=zohomail.com; s=zohoarc; b=ndzFi33wLq2OHixbNxvUqsR7zWKRcJPDSOsklxn5lkp9TgPKkh+kr2DbyTj1Q5dUAdgqB6fVvmIcA/rQJFMpJF7nSxTUrX6RF8JKPWwByks3qqECsEJa2ui/8UiFBJu5Lcnm2Z3CZOO3rKjS93ZDBHT5HgACbzCkBbRbyEAQWr8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668449531; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=ziDkwU0ctEmVGsQ3S6jYPeTaQ3p/UAKskvIx4K/Kt08=; b=cicgW+GeZno47VxXnVh8xTuHu8MgFldW7IqhWH96iyVHCDcDcUP6LjIBV6Ql2B4OYMaiXxwhnefd0hDkslkJuLgm2pM9Zmb+QgKhF4TrnjmAw1VOEpplZY8J6+KDqLqKKNSJhInDo/bmsae4WuHiQiPiLdKtdjeHAy6BalGF60A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+96355+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1668449531292374.48914244311584; Mon, 14 Nov 2022 10:12:11 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 4q15YY1788612xXDol8uSumo; Mon, 14 Nov 2022 10:12:10 -0800 X-Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mx.groups.io with SMTP id smtpd.web11.108.1668449530041925616 for ; Mon, 14 Nov 2022 10:12:10 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10531"; a="309670542" X-IronPort-AV: E=Sophos;i="5.96,164,1665471600"; d="scan'208";a="309670542" X-Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Nov 2022 10:12:09 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10531"; a="638590323" X-IronPort-AV: E=Sophos;i="5.96,164,1665471600"; d="scan'208";a="638590323" X-Received: from vision-ws.amr.corp.intel.com ([10.53.88.48]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Nov 2022 10:12:08 -0800 From: "Clark-williams, Zachary" To: devel@edk2.groups.io Cc: Zachary Clark-Williams , Maciej Rabeda , Wu Jiaxin , Andrei Otcheretianski , Zachary Clark-Williams Subject: [edk2-devel] [PATCH] NetworkPkg: Add WiFi profile sync protocol support Date: Mon, 14 Nov 2022 10:11:52 -0800 Message-Id: <20221114181152.2540-1-zachary.clark-williams@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,zachary.clark-williams@intel.com X-Gm-Message-State: qYQ5xJVx4YxcaAS9tpnDvYBXx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1668449530; bh=ghzXBCilYIvw4ZOxo9lf8w4ObqpySjRGNrmeZz+OBMc=; h=Cc:Date:From:Reply-To:Subject:To; b=q10KPNylwzb4fQ4CuT5UojwF9budHSCAAYLcs1LrnFLJyG0YCFtsStpADcQJZtG51mG DNiLsUfU67vpJl4klmfxNI/zpiFV5lclzb2mSufXH4NrEvQ7BTi6huHP72neDAtxrLcvj VjZ+S7vjirqYFecHYC3Am/6RZJ3mrdUvgGU= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1668449532492100002 Content-Type: text/plain; charset="utf-8" From: Zachary Clark-Williams REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3845 Enables KVM and One Click Recovery WLAN capability with WiFi Profile Sync feature and protocol. Adding WiFiProfileSyncProtocol, which supports the profilesync driver operations for transferring WiFi profiles from AMT to the Supplicant. WiFiConnectionManager will check for the WifiProfileSyncProtocol and if found will operate on the premise of a One Click Recovery, or KVM flow with a Wifi profile provided by AMT. Cc: Maciej Rabeda Cc: Wu Jiaxin Cc: Andrei Otcheretianski Signed-off-by: Zachary Clark-Williams --- .../Protocol/WiFiProfileSyncProtocol.h | 86 ++++++++ NetworkPkg/NetworkPkg.dec | 3 + .../WifiConnectionManagerDxe.inf | 3 +- .../WifiConnectionMgrConfigNVDataStruct.h | 2 +- .../WifiConnectionMgrDriver.c | 126 ++++++++---- .../WifiConnectionMgrDxe.h | 4 +- .../WifiConnectionMgrImpl.c | 193 ++++++++++++++++-- .../WifiConnectionMgrMisc.c | 13 ++ 8 files changed, 370 insertions(+), 60 deletions(-) create mode 100644 NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h diff --git a/NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h b/Networ= kPkg/Include/Protocol/WiFiProfileSyncProtocol.h new file mode 100644 index 0000000000..bc8f58784e --- /dev/null +++ b/NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h @@ -0,0 +1,86 @@ +/** @file + WiFi profile sync protocol. Supports One Click Recovery or KVM OS recove= ry + boot flow over WiFi. + + Pulbic links to speficiation document for KVM and One Click Recovery fea= ture. + https://software.intel.com/sites/manageability/AMT_Implementation_and_Re= ference_Guide/default.htm?turl=3DWordDocuments%2Foneclickrecovery.htm + + Copyright (c) 2022, Intel Corporation. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef WIFI_PROFILE_SYNC_PROTOCOL_H_ +#define WIFI_PROFILE_SYNC_PROTOCOL_H_ + +#include + +// +// WiFi Profile Sync Protocol GUID variable. +// +extern EFI_GUID gEfiWiFiProfileSyncProtocolGuid; + +/** + Used by the WiFi connection manager to get the WiFi profile that AMT sha= red + and was stored in WiFi profile protocol. Aligns the AMT WiFi profile dat= a to + the WiFi connection manager profile structure fo connection use. + + @param[in, out] WcmProfile WiFi Connection Manager profile struct= ure + @param[in, out] MacAddress MAC address from AMT saved to NiC MAC = address + + @retval EFI_SUCCESS Stored WiFi profile converted and retu= rned succefully + @retval EFI_UNSUPPORTED Profile protocol sharing not supported= or enabled + @retval EFI_NOT_FOUND No profiles to returned + @retval Others Error Occurred +**/ +typedef +EFI_STATUS +(EFIAPI *WIFI_PROFILE_GET)( + IN OUT WIFI_MGR_NETWORK_PROFILE *Profile, + IN OUT EFI_80211_MAC_ADDRESS MacAddress + ); + +/** + Saves the WiFi connection status recieved by the WiFiConnectionManager w= hen + in a KVM OR One Click Recovery WLAN recovery flow. Input as + EFI_80211_CONNECT_NETWORK_RESULT_CODE then converted and stored as EFI_S= TATUS type. + + @param[in] ConnectionStatus WiFi connection attempt results +**/ +typedef +VOID +(EFIAPI *WIFI_SET_CONNECT_STATE)( + IN EFI_80211_CONNECT_NETWORK_RESULT_CODE ConnectionStatus + ); + +/** + Retrieves the stored WiFi connection status when in either KVM OR One Cl= ick + Recovery WLAN recovery flow. + + @retval EFI_SUCCESS WiFi connection completed succesfully + @retval Others Connection failure occurred +**/ +typedef +EFI_STATUS +(EFIAPI *WIFI_GET_CONNECT_STATE)( + VOID + ); + +// +// WiFi Profile Sync Protocol structure. +// +typedef struct { + UINT32 Revision; + WIFI_SET_CONNECT_STATE WifiProfileSyncSetConnectState; + WIFI_GET_CONNECT_STATE WifiProfileSyncGetConnectState; + WIFI_PROFILE_GET WifiProfileSyncGetProfile; +} EFI_WIFI_PROFILE_SYNC_PROTOCOL; + +/** + WiFi Profile Protocol revision number. + + Revision 1: Initial version +**/ +#define EFI_WIFI_PROFILE_SYNC_PROTOCOL_REVISION 1 + +#endif // WIFI_PROFILE_SYNC_PROTOCOL_H_ diff --git a/NetworkPkg/NetworkPkg.dec b/NetworkPkg/NetworkPkg.dec index 5e43ebf8c5..53fb34c4a0 100644 --- a/NetworkPkg/NetworkPkg.dec +++ b/NetworkPkg/NetworkPkg.dec @@ -91,6 +91,9 @@ ## Include/Protocol/HttpCallback.h gEdkiiHttpCallbackProtocolGuid =3D {0x611114f1, 0xa37b, 0x4468, {0xa4, = 0x36, 0x5b, 0xdd, 0xa1, 0x6a, 0xa2, 0x40}} =20 + ## Include/Protocol/WiFiProfileSyncProtocol.h + gEfiWiFiProfileSyncProtocolGuid =3D {0x399a2b8a, 0xc267, 0x44aa, {0x9a, = 0xb4, 0x30, 0x58, 0x8c, 0xd2, 0x2d, 0xcc}} + [PcdsFixedAtBuild] ## The max attempt number will be created by iSCSI driver. # @Prompt Max attempt number. diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionManagerDxe.i= nf b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionManagerDxe.inf index 4394b6f4bb..7e36016cf8 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionManagerDxe.inf +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionManagerDxe.inf @@ -9,7 +9,7 @@ # 2). WPA2 Personal Network # 3). EAP Networks (EAP-TLS, EAP-TTLS/MSCHAPv2 and PEAPv0/MSCHAPv2) # -# Copyright (c) 2019, Intel Corporation. All rights reserved.
+# Copyright (c) 2019 - 2022, Intel Corporation. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -71,6 +71,7 @@ gEfiAdapterInformationProtocolGuid ## SOMETIMES_CONSUMES gEfiSupplicantProtocolGuid ## SOMETIMES_CONSUMES gEfiEapConfigurationProtocolGuid ## SOMETIMES_CONSUMES + gEfiWiFiProfileSyncProtocolGuid ## SOMETIMES_CONSUMES =20 [Guids] gWifiConfigGuid ## PRODUCES ## GUID diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrConfigNVD= ataStruct.h b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrConfigNV= DataStruct.h index b5518a74d8..dcc4bf7e27 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrConfigNVDataStru= ct.h +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrConfigNVDataStru= ct.h @@ -25,7 +25,7 @@ =20 #define PASSWORD_MIN_LEN 8 #define PASSWORD_MAX_LEN 63 -#define PASSWORD_STORAGE_SIZE 64 +#define PASSWORD_STORAGE_SIZE 65 =20 #define EAP_IDENTITY_LEN 63 #define EAP_IDENTITY_SIZE 64 diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c = b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c index 67a01ca058..97ca7a9f0b 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c @@ -1,7 +1,7 @@ /** @file The driver binding protocol for the WiFi Connection Manager. =20 - Copyright (c) 2019, Intel Corporation. All rights reserved.
+ Copyright (c) 2019 - 2022, Intel Corporation. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -39,6 +39,11 @@ EFI_GUID mWifiConfigNetworkListRefreshGuid =3D WIFI_CON= FIG_NETWORK_LIST_REFRESH_G EFI_GUID mWifiConfigConnectFormRefreshGuid =3D WIFI_CONFIG_CONNECT_FORM_R= EFRESH_GUID; EFI_GUID mWifiConfigMainFormRefreshGuid =3D WIFI_CONFIG_MAIN_FORM_REFR= ESH_GUID; =20 +// +// Wifi connection attempt counter for retries +// +extern UINT8 mWifiConnectionCount; + /** Tests to see if this driver supports a given controller. If a child devi= ce is provided, it further tests to see if this driver supports creating a handle for th= e specified child device. @@ -167,8 +172,10 @@ WifiMgrDxeDriverBindingStart ( EFI_WIRELESS_MAC_CONNECTION_II_PROTOCOL *Wmp; EFI_SUPPLICANT_PROTOCOL *Supplicant; EFI_EAP_CONFIGURATION_PROTOCOL *EapConfig; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; =20 - Nic =3D NULL; + mWifiConnectionCount =3D 0; + Nic =3D NULL; =20 // // Open Protocols @@ -236,47 +243,73 @@ WifiMgrDxeDriverBindingStart ( InitializeListHead (&Nic->ProfileList); =20 // - // Record the MAC address of the incoming NIC. + // WiFi profile sync protocol installation check for OS recovery flow. // - Status =3D NetLibGetMacAddress ( - ControllerHandle, - (EFI_MAC_ADDRESS *)&Nic->MacAddress, - &AddressSize - ); - if (EFI_ERROR (Status)) { - goto ERROR2; - } - - // - // Create and start the timer for the status check - // - Status =3D gBS->CreateEvent ( - EVT_NOTIFY_SIGNAL | EVT_TIMER, - TPL_CALLBACK, - WifiMgrOnTimerTick, - Nic, - &Nic->TickTimer + Status =3D gBS->LocateProtocol ( + &gEfiWiFiProfileSyncProtocolGuid, + NULL, + (VOID **)&WiFiProfileSyncProtocol ); - if (EFI_ERROR (Status)) { - goto ERROR2; - } + if (!EFI_ERROR (Status)) { + Nic->ConnectPendingNetwork =3D (WIFI_MGR_NETWORK_PROFILE *)AllocateZer= oPool (sizeof (WIFI_MGR_NETWORK_PROFILE)); + if (Nic->ConnectPendingNetwork =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto ERROR1; + } =20 - Status =3D gBS->SetTimer (Nic->TickTimer, TimerPeriodic, EFI_TIMER_PERIO= D_MILLISECONDS (500)); - if (EFI_ERROR (Status)) { - goto ERROR3; - } + WiFiProfileSyncProtocol->WifiProfileSyncGetProfile (Nic->ConnectPendin= gNetwork, Nic->MacAddress); + if (Nic->ConnectPendingNetwork !=3D NULL) { + Status =3D WifiMgrConnectToNetwork (Nic, Nic->ConnectPendingNetwork); + if (EFI_ERROR (Status)) { + WiFiProfileSyncProtocol->WifiProfileSyncSetConnectState (Status); + } + } else { + goto ERROR1; + } + } else { + // + // Record the MAC address of the incoming NIC. + // + Status =3D NetLibGetMacAddress ( + ControllerHandle, + (EFI_MAC_ADDRESS *)&Nic->MacAddress, + &AddressSize + ); + if (EFI_ERROR (Status)) { + goto ERROR2; + } =20 - Nic->ConnectState =3D WifiMgrDisconnected; - Nic->ScanState =3D WifiMgrScanFinished; + // + // Create and start the timer for the status check + // + Status =3D gBS->CreateEvent ( + EVT_NOTIFY_SIGNAL | EVT_TIMER, + TPL_CALLBACK, + WifiMgrOnTimerTick, + Nic, + &Nic->TickTimer + ); + if (EFI_ERROR (Status)) { + goto ERROR2; + } =20 - OldTpl =3D gBS->RaiseTPL (TPL_CALLBACK); - InsertTailList (&mPrivate->NicList, &Nic->Link); - Nic->NicIndex =3D mPrivate->NicCount++; - if (mPrivate->CurrentNic =3D=3D NULL) { - mPrivate->CurrentNic =3D Nic; - } + Status =3D gBS->SetTimer (Nic->TickTimer, TimerPeriodic, EFI_TIMER_PER= IOD_MILLISECONDS (500)); + if (EFI_ERROR (Status)) { + goto ERROR3; + } =20 - gBS->RestoreTPL (OldTpl); + Nic->ConnectState =3D WifiMgrDisconnected; + Nic->ScanState =3D WifiMgrScanFinished; + + OldTpl =3D gBS->RaiseTPL (TPL_CALLBACK); + InsertTailList (&mPrivate->NicList, &Nic->Link); + Nic->NicIndex =3D mPrivate->NicCount++; + if (mPrivate->CurrentNic =3D=3D NULL) { + mPrivate->CurrentNic =3D Nic; + } + + gBS->RestoreTPL (OldTpl); + } =20 Status =3D gBS->InstallProtocolInterface ( &ControllerHandle, @@ -385,10 +418,11 @@ WifiMgrDxeDriverBindingStop ( IN EFI_HANDLE *ChildHandleBuffer OPTIONAL ) { - EFI_STATUS Status; - EFI_TPL OldTpl; - WIFI_MGR_PRIVATE_PROTOCOL *WifiMgrIdentifier; - WIFI_MGR_DEVICE_DATA *Nic; + EFI_STATUS Status; + EFI_TPL OldTpl; + WIFI_MGR_PRIVATE_PROTOCOL *WifiMgrIdentifier; + WIFI_MGR_DEVICE_DATA *Nic; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; =20 Status =3D gBS->OpenProtocol ( ControllerHandle, @@ -481,7 +515,15 @@ WifiMgrDxeDriverBindingStop ( // OldTpl =3D gBS->RaiseTPL (TPL_CALLBACK); =20 - RemoveEntryList (&Nic->Link); + Status =3D gBS->LocateProtocol ( + &gEfiWiFiProfileSyncProtocolGuid, + NULL, + (VOID **)&WiFiProfileSyncProtocol + ); + if (EFI_ERROR (Status)) { + RemoveEntryList (&Nic->Link); + } + mPrivate->NicCount--; if (mPrivate->CurrentNic =3D=3D Nic) { mPrivate->CurrentNic =3D NULL; diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDxe.h b/N= etworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDxe.h index 7b2e41e155..047f85dbc2 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDxe.h +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDxe.h @@ -47,6 +47,7 @@ #include #include #include +#include =20 // // Produced Protocols @@ -73,7 +74,8 @@ // #define WIFI_MGR_DXE_VERSION 0xb =20 -#define OUI_IEEE_80211I 0xAC0F00 +#define OUI_IEEE_80211I 0xAC0F00 +#define MAX_WIFI_CONNETION_ATTEMPTS 3 =20 typedef enum { Ieee80211PairwiseCipherSuiteUseGroupCipherSuite =3D 0, diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c b/= NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c index 59bac48c42..a73ab9f710 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c @@ -19,6 +19,8 @@ EFI_EAP_TYPE mEapSecondAuthMethod[] =3D { EFI_EAP_TYPE_MSCHAPV2 }; =20 +UINT8 mWifiConnectionCount =3D 0; + /** The callback function for scan operation. This function updates networks according to the latest scan result, and trigger UI refresh. @@ -424,18 +426,26 @@ WifiMgrConfigPassword ( return EFI_NOT_FOUND; } =20 - AsciiPassword =3D AllocateZeroPool ((StrLen (Profile->Password) + 1) * s= izeof (UINT8)); + if (StrLen (Profile->Password) >=3D PASSWORD_STORAGE_SIZE) { + ASSERT (EFI_INVALID_PARAMETER); + return EFI_INVALID_PARAMETER; + } + + AsciiPassword =3D AllocateZeroPool ((StrLen (Profile->Password) + 1) * s= izeof (CHAR8)); if (AsciiPassword =3D=3D NULL) { return EFI_OUT_OF_RESOURCES; } =20 - UnicodeStrToAsciiStrS (Profile->Password, (CHAR8 *)AsciiPassword, PASSWO= RD_STORAGE_SIZE); - Status =3D Supplicant->SetData ( - Supplicant, - EfiSupplicant80211PskPassword, - AsciiPassword, - (StrLen (Profile->Password) + 1) * sizeof (UINT8) - ); + Status =3D UnicodeStrToAsciiStrS (Profile->Password, (CHAR8 *)AsciiPassw= ord, (StrLen (Profile->Password) + 1)); + if (!EFI_ERROR (Status)) { + Status =3D Supplicant->SetData ( + Supplicant, + EfiSupplicant80211PskPassword, + AsciiPassword, + (StrLen (Profile->Password) + 1) * sizeof (CHAR= 8) + ); + } + ZeroMem (AsciiPassword, AsciiStrLen ((CHAR8 *)AsciiPassword) + 1); FreePool (AsciiPassword); =20 @@ -466,6 +476,7 @@ WifiMgrConfigEap ( ) { EFI_STATUS Status; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; EFI_EAP_CONFIGURATION_PROTOCOL *EapConfig; EFI_EAP_TYPE EapAuthMethod; EFI_EAP_TYPE EapSecondAuthMethod; @@ -567,7 +578,13 @@ WifiMgrConfigEap ( return EFI_OUT_OF_RESOURCES; } =20 - UnicodeStrToAsciiStrS (Profile->EapIdentity, Identity, IdentitySize); + Status =3D gBS->LocateProtocol (&gEfiWiFiProfileSyncProtocolGuid, NULL= , (VOID **)&WiFiProfileSyncProtocol); + if (!EFI_ERROR (Status)) { + CopyMem (Identity, &Profile->EapIdentity, IdentitySize); + } else { + UnicodeStrToAsciiStrS (Profile->EapIdentity, Identity, IdentitySize); + } + Status =3D EapConfig->SetData ( EapConfig, EFI_EAP_TYPE_IDENTITY, @@ -892,6 +909,133 @@ WifiMgrPrepareConnection ( return EFI_SUCCESS; } =20 +/** + Will reset NiC data, get profile from profile sync driver, and send for + another connection attempt.This function should not be called more than + 3 times. + + @param[in] WiFiProfileSyncProtocol The target network profile to conne= ct. + + @retval EFI_SUCCESS The operation is completed. + @retval other Operation failure. + +**/ +EFI_STATUS +ConnectionRetry ( + IN EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol + ) +{ + EFI_STATUS Status; + WIFI_MGR_DEVICE_DATA *Nic; + EFI_WIRELESS_MAC_CONNECTION_II_PROTOCOL *Wmp; + EFI_SUPPLICANT_PROTOCOL *Supplicant; + EFI_EAP_CONFIGURATION_PROTOCOL *EapConfig; + + Nic =3D NULL; + + Status =3D gBS->LocateProtocol ( + &gEfiWiFi2ProtocolGuid, + NULL, + (VOID **)&Wmp + ); + if (EFI_ERROR (Status)) { + return Status; + } + + Status =3D gBS->LocateProtocol ( + &gEfiSupplicantProtocolGuid, + NULL, + (VOID **)&Supplicant + ); + if (EFI_ERROR (Status)) { + Supplicant =3D NULL; + } + + Status =3D gBS->LocateProtocol ( + &gEfiEapConfigurationProtocolGuid, + NULL, + (VOID **)&EapConfig + ); + if (EFI_ERROR (Status)) { + EapConfig =3D NULL; + } + + // + // Initialize Nic device data + // + Nic =3D AllocateZeroPool (sizeof (WIFI_MGR_DEVICE_DATA)); + if (Nic =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + return Status; + } + + Nic->Signature =3D WIFI_MGR_DEVICE_DATA_SIGNATURE; + Nic->Private =3D mPrivate; + Nic->Wmp =3D Wmp; + Nic->Supplicant =3D Supplicant; + Nic->EapConfig =3D EapConfig; + Nic->UserSelectedProfile =3D NULL; + Nic->OneTimeScanRequest =3D FALSE; + + if (Nic->Supplicant !=3D NULL) { + Status =3D WifiMgrGetSupportedSuites (Nic); + } + + if (!EFI_ERROR (Status)) { + InitializeListHead (&Nic->ProfileList); + + Nic->ConnectPendingNetwork =3D (WIFI_MGR_NETWORK_PROFILE *)AllocateZer= oPool (sizeof (WIFI_MGR_NETWORK_PROFILE)); + if (Nic->ConnectPendingNetwork =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + DEBUG ((DEBUG_ERROR, "[WiFi Connection Manager] Failed to allocate m= emory for ConnectPendingNetwork\n")); + goto ERROR; + } + + Status =3D WiFiProfileSyncProtocol->WifiProfileSyncGetProfile (Nic->Co= nnectPendingNetwork, Nic->MacAddress); + if (!EFI_ERROR (Status) && (Nic->ConnectPendingNetwork !=3D NULL)) { + Status =3D WifiMgrConnectToNetwork (Nic, Nic->ConnectPendingNetwork); + if (!EFI_ERROR (Status)) { + return Status; + } + } else { + DEBUG ((DEBUG_ERROR, "[WiFi Connection Manager] Failed to get WiFi p= rofile with status %r\n", Status)); + } + } else { + DEBUG ((DEBUG_ERROR, "[WiFi Connection Manager] Failed to get Supporte= d suites with status %r\n", Status)); + } + + if (Nic->ConnectPendingNetwork !=3D NULL) { + if (Nic->ConnectPendingNetwork->Network.AKMSuite !=3D NULL) { + FreePool (Nic->ConnectPendingNetwork->Network.AKMSuite); + } + + if (Nic->ConnectPendingNetwork->Network.CipherSuite !=3D NULL) { + FreePool (Nic->ConnectPendingNetwork->Network.CipherSuite); + } + + FreePool (Nic->ConnectPendingNetwork); + } + +ERROR: + if (Nic->Supplicant !=3D NULL) { + if (Nic->SupportedSuites.SupportedAKMSuites !=3D NULL) { + FreePool (Nic->SupportedSuites.SupportedAKMSuites); + } + + if (Nic->SupportedSuites.SupportedSwCipherSuites !=3D NULL) { + FreePool (Nic->SupportedSuites.SupportedSwCipherSuites); + } + + if (Nic->SupportedSuites.SupportedHwCipherSuites !=3D NULL) { + FreePool (Nic->SupportedSuites.SupportedHwCipherSuites); + } + } + + FreePool (Nic); + + return Status; +} + /** The callback function for connect operation. =20 @@ -908,12 +1052,13 @@ WifiMgrOnConnectFinished ( IN VOID *Context ) { - EFI_STATUS Status; - WIFI_MGR_MAC_CONFIG_TOKEN *ConfigToken; - WIFI_MGR_NETWORK_PROFILE *ConnectedProfile; - UINT8 SecurityType; - UINT8 SSIdLen; - CHAR8 *AsciiSSId; + EFI_STATUS Status; + WIFI_MGR_MAC_CONFIG_TOKEN *ConfigToken; + WIFI_MGR_NETWORK_PROFILE *ConnectedProfile; + UINT8 SecurityType; + UINT8 SSIdLen; + CHAR8 *AsciiSSId; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; =20 ASSERT (Context !=3D NULL); =20 @@ -925,6 +1070,24 @@ WifiMgrOnConnectFinished ( ASSERT (ConfigToken->Type =3D=3D TokenTypeConnectNetworkToken); =20 ASSERT (ConfigToken->Token.ConnectNetworkToken !=3D NULL); + + Status =3D gBS->LocateProtocol (&gEfiWiFiProfileSyncProtocolGuid, NULL, = (VOID **)&WiFiProfileSyncProtocol); + if (!EFI_ERROR (Status)) { + WiFiProfileSyncProtocol->WifiProfileSyncSetConnectState (ConfigToken->= Token.ConnectNetworkToken->ResultCode); + if ((mWifiConnectionCount < MAX_WIFI_CONNETION_ATTEMPTS) && + (ConfigToken->Token.ConnectNetworkToken->ResultCode !=3D ConnectSu= ccess)) + { + mWifiConnectionCount++; + gBS->CloseEvent (Event); + Status =3D ConnectionRetry (WiFiProfileSyncProtocol); + if (!EFI_ERROR (Status)) { + return; + } + + WiFiProfileSyncProtocol->WifiProfileSyncSetConnectState (Status); + } + } + if (ConfigToken->Token.ConnectNetworkToken->Status !=3D EFI_SUCCESS) { if (ConfigToken->Nic->OneTimeConnectRequest) { // diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrMisc.c b/= NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrMisc.c index 4ad5643c24..87adfc5033 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrMisc.c +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrMisc.c @@ -672,10 +672,23 @@ WifiMgrCleanProfileSecrets ( IN WIFI_MGR_NETWORK_PROFILE *Profile ) { + EFI_STATUS Status; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; + ZeroMem (Profile->Password, sizeof (CHAR16) * PASSWORD_STORAGE_SIZE); ZeroMem (Profile->EapPassword, sizeof (CHAR16) * PASSWORD_STORAGE_SIZE); ZeroMem (Profile->PrivateKeyPassword, sizeof (CHAR16) * PASSWORD_STORAGE= _SIZE); =20 + // + // When EFI WiFi profile sync protocol is found the system is performin= g a recovery boot in secure + // boot mode. The profile sync driver will manage the CA certificate, c= lient certificate, and key + // data, cleaning them at exit boot services. + // + Status =3D gBS->LocateProtocol (&gEfiWiFiProfileSyncProtocolGuid, NULL, = (VOID **)&WiFiProfileSyncProtocol); + if (!EFI_ERROR (Status)) { + return; + } + if (Profile->CACertData !=3D NULL) { ZeroMem (Profile->CACertData, Profile->CACertSize); FreePool (Profile->CACertData); --=20 2.37.3.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#96355): https://edk2.groups.io/g/devel/message/96355 Mute This Topic: https://groups.io/mt/95025543/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-