From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mx.groups.io with SMTP id smtpd.web09.8150.1664263889760544882 for ; Tue, 27 Sep 2022 00:31:29 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=MtwzF58K; spf=pass (domain: intel.com, ip: 192.55.52.151, mailfrom: heng.luo@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664263889; x=1695799889; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=t5U/UL39bBitPt07dQJuALo8+yNah4gc99YlMYCaeRY=; b=MtwzF58KqrzrRews53g2fXowEkiA6ubS6RkvA0dVZZtGS1jh2NMTaC0C zunXBCl8Cp8cEHnYrjU5RxP0YdiPSvgnz2XjiB94F+zsJsFS5lWFaX4/w LA+kbAlJ+Nktl+px21UYb0qZj3olF+TbEI7ZNISP+WdFoCblcQG6JkNvE kwzto1iSSALEtiUeqTbN3o/ChXFI2IcQZJ15JP70LAsWF5C+xdINDkMGz uOt9EdHzc//DGHissRudYGGZy+6o3E908v0o/rQ7yvo2/2SvUoHb4pxLQ tp+yA86fsW0Nebbbo91RhVGu1Ou1R8ccW2uHcUYGEDUewpfIQY4n5uHU1 Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10482"; a="281616543" X-IronPort-AV: E=Sophos;i="5.93,348,1654585200"; d="scan'208";a="281616543" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Sep 2022 00:31:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10482"; a="623661788" X-IronPort-AV: E=Sophos;i="5.93,348,1654585200"; d="scan'208";a="623661788" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by fmsmga007.fm.intel.com with ESMTP; 27 Sep 2022 00:31:06 -0700 Received: from fmsmsx607.amr.corp.intel.com (10.18.126.87) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 27 Sep 2022 00:31:06 -0700 Received: from fmsmsx602.amr.corp.intel.com (10.18.126.82) by fmsmsx607.amr.corp.intel.com (10.18.126.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 27 Sep 2022 00:31:05 -0700 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31 via Frontend Transport; Tue, 27 Sep 2022 00:31:05 -0700 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.108) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2375.31; Tue, 27 Sep 2022 00:31:05 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=grjFUuaVDZ/9wYmqXZMpsnGz4yzMO4dyxN/8uzLNsV8eQob4xB08KlH5lCkB0QLTFqGvWHONkrucwPLP0mvtbspm9MtRqr+nixLHHEWRwtPJ3tJAh4HIwIjPg8/YwlyrJrwoc4beFKRubitSsxzrWFIjEp9Td2Axpkucy+D/om41MRB8hbdlI6y6b54LnEGwxy2uqfhxsE3wYBShh7kKACMGJdWEI0ndHvj1U8hR65zaIru0+jjpl0pVxEbDDqixuNbyXCutOX64RBBPk99LBBVn6GZFEkR2a9GFIGmo0b5LUy/FT1ti0SdfFZARHylCQ2YkbZQ1vBqZmtqiNECZ2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=pgYr/qICQebROwWp/C4lIlhimX2z0+XirDMPgXQgOyg=; b=PDMgatQzvFzz1vOajscYl+ZjIfMlOpC/cfKSY4ays8TElIo4VNuy6z2KHsDJSb1Z8ZGukDD7Z81XJbQGp0XV45nPC6BKEBOZRcSwUeSSXd2cTizYeeFCA9wQEvWrXlF5hzoCjurY0Kgfyh9OJbFVpfNSj9zn22BauuE6/StW5OQdiTUDLEWh5Ww00Mb8oDe/8XLSywzXscUwJfmSdrEam/gE0rPT05HgtOMR++3UzCeo5zC4giu6dnK3Hy4ueirSe/chkqzANYlMSC1b1YAoSKpAgtx7TMwxYgBJcYubMWmj7nVcE0aWHXqpBVXS/6v6mVyhE5YqZ81fYcZWcWVNPw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from SN6PR11MB2752.namprd11.prod.outlook.com (2603:10b6:805:59::31) by CH0PR11MB5251.namprd11.prod.outlook.com (2603:10b6:610:e2::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.26; Tue, 27 Sep 2022 07:30:58 +0000 Received: from SN6PR11MB2752.namprd11.prod.outlook.com ([fe80::2891:b96f:4eea:87eb]) by SN6PR11MB2752.namprd11.prod.outlook.com ([fe80::2891:b96f:4eea:87eb%4]) with mapi id 15.20.5654.026; Tue, 27 Sep 2022 07:30:58 +0000 From: "Heng Luo" To: "devel@edk2.groups.io" , "Clark-williams, Zachary" CC: Zachary Clark-Williams Subject: Re: [edk2-devel] [PATCH V2 2/2] NetworkPkg: Add WiFi profile sync protocol support Thread-Topic: [edk2-devel] [PATCH V2 2/2] NetworkPkg: Add WiFi profile sync protocol support Thread-Index: AQHY0dS7ydzyUfxZokSsRp/ooIcrZq3y2Z4A Date: Tue, 27 Sep 2022 07:30:58 +0000 Message-ID: References: <8fdb4de628120a8736ee47522d1941e3ad3bdf8a.1664216197.git.zachary.clark-williams@intel.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.6.500.17 authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: SN6PR11MB2752:EE_|CH0PR11MB5251:EE_ x-ms-office365-filtering-correlation-id: 1965f0f6-39c7-4a69-0647-08daa05a3880 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: qA6s7fEdwHtbCEGJJ/iofTTgDGAtWz2HU3+miVf2vNLaas0RT9DpduMO1c8dcxLkZGFMRdl0R6eltttNHW5Ny86ycKkAxdQ4GUp8Lw/SsyxJ0LonitKcIbCLlMZ2kDdwhO6v/gNXeLub0PjSXXQK4ModWh0qhIz2R0dQnQguA7gy+8+Pe5qiwD2iZtyInbd+6/M7+afPafTAfrMPZC+nZytlVMaXASlEr5nFGvv8+89Vqhqa+QJ4w/RODAw7zG98dboK2suV1gDNBCZRS6ht5wm2cXNfKiT1anB+SWy5X6LStFUeO/I+VOxLuP8XI4xbyV9iXMruJkMbYQfuo+HWvMpP9PVYZ/L3i5DWKRCtaesAlxDV4ZhnlRDscWpwSz4UOmkNkLvC6Jhon/Z9URFcVgzmgyQJ6nVh5suINi6GzObh7pfhkgKxZSVKx57aEhTWkYYP0PX89T/YuSJ1/0giPPaAA3W5Xuc7gFwGJPYfAWxAdpTl8pe5rYfODmujVaJglW076b7SLbQrRFfXxCfUG61iVLHrMdTt7E+lu9MIAcRh2Y5qWjUoqPdwhGXKok5wVIpwPfWONq5tXSUXwx5w9IsqnM5GoqRkC4FVjySLPzbQEigIozB/MCRxWlJOnBW6pHlcIOWVdjO1LGg2L7e4hysQ6oHYXtIc4HUGo2b3pqt1AF/+kJ1ZBYAiQO2z5Gk6DX/yxm6AyvojeWoOKlWHMXxZTU07urV70/1KNlo91Eo/OpSMavIJXgM2u43nXhf+jeBY5N72+dEVn6G/dEQKGHJCb8sGs9Z2jW0p64sCPD/nl8W41pzyVwQ+xPisJt7pzpOXBXq0DLwizpf2usrI+Jz7UtlRttMBfZJ1sKKjXOg= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR11MB2752.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(6029001)(39860400002)(346002)(366004)(136003)(396003)(376002)(451199015)(110136005)(6636002)(52536014)(19627235002)(478600001)(316002)(66556008)(66946007)(66476007)(76116006)(71200400001)(7696005)(6506007)(53546011)(2906002)(8936002)(41300700001)(26005)(30864003)(9686003)(5660300002)(66899015)(38070700005)(83380400001)(33656002)(122000001)(38100700002)(55016003)(186003)(64756008)(4326008)(66446008)(966005)(8676002)(86362001)(82960400001)(579004)(559001)(44824005);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?L8qy4M6FcDa5VXxNFDkoP1sq1lETTr4LP4I/nOhl9aPqQyTQnmEmlXgh/kUF?= =?us-ascii?Q?bUzdM4HiAbC9VJG7tDn+ikjpOxdSa/PufZSb1sfOZjcMEOhWC5J/vv+pcqxr?= =?us-ascii?Q?F2kE/f5FTPkmmCRMK+QvmolQrtQ9WwlVek/wfORnLD3kVCweQhx2+o8X9eq9?= =?us-ascii?Q?Z7scZ/yRmxlN5wVKxYvhC0MZJ4q5vnKW6i3krOTBQ3B88jTjcy2ir60OyKre?= =?us-ascii?Q?XId8G+lNfcuZjKyQbyYS5WH8i9JxEpi3/EvEFT95lEIeqO3x7ZgXivTbA0Gs?= =?us-ascii?Q?dUMfP8JR7nVrNPegXq+wkDFaybkHXCl62X5KrjMa91ITjW9pdZqTGOmnzBw+?= =?us-ascii?Q?VxZb2onMm89L/x96vxh1zcyQdq9P6kxYptvIxSCiS185q3vBSZ3Wfehmx3g/?= =?us-ascii?Q?TjzAnxUNEL9jQTMTg8PQ4ZugvpkvSuoL96tucSlNkZl/aq2C9kBZON3ltmdH?= =?us-ascii?Q?YK63CC2hfkkBgjmtr1ccKfIphDyKlMmYFEbLlFw7BL/Yb+qc9fc0mmaPCZ+m?= =?us-ascii?Q?1T4EII7os38ZMVQ/WnTH1E9P7ziHKjOMg8QpbGXN6KIq4oIgg061QbKc3fpp?= =?us-ascii?Q?BqTc8Ia5ipmxmxslgf6cFJ2gwoJ/zAdvHLyZULqlRCQdK5SabJvz6ZXU+59k?= =?us-ascii?Q?aqnM4x5knj9VJYQpYm7XyNzlHMq0J5bxKm4aLVMSLKj72UJl57I9l7jF9o61?= =?us-ascii?Q?7qv901vGAorRwtOvJm1Uw3O/AFvuQYMVva95S35J1hMEFqxlfQhOxLkqpZIP?= =?us-ascii?Q?X6Bs7PzTMbMZpdcCk135DMb+KtFZkQqXwydfan49Ffn0gO9GGOe0oPrCRFy1?= =?us-ascii?Q?M54Vpzq4mLIF/b6cVR6B4UHauCvsQUk1PqG6XOq19ArTg+gXoFOjS1hvW/Yy?= =?us-ascii?Q?6YZtAhzQbEo66lVJXF3SRpHM9JTTuaJobN/x00PI24UMnLYVSQGh/flSBQK0?= =?us-ascii?Q?pZh1y84mYdWMWdN43AVZVYxpVt3D6zMASux8PuzAF5vSeIAEJX+T7JeJJ1/y?= =?us-ascii?Q?NtLHh8GNXZSehaaH7/UCCfoQtc5zZmLwa4tT4Hj32vbLLOzMyGE2dQqoTG9s?= =?us-ascii?Q?8OgCPmsy9mca/ctfRfaPwiprGdysXbieRkxhtfwjMSBh7CnFvXgTh3QWHBlW?= =?us-ascii?Q?kpDSze53nE61ZijUcaT2+63gZBm58oADf6W5Gyt4L/sqmZA71EZEdWB/MXwQ?= =?us-ascii?Q?o6BwhesKf1AOeVA5lhSKaiz6EuvNKGXTAKwM6HsOdWpcjikktJB8x9Gg9Cxx?= =?us-ascii?Q?lPB42tngDZkHxOwTzN3g3itnXPlxc0Y7x6BE0g2EUr0ieuvcH4w8GiJOfgl7?= =?us-ascii?Q?+LeS5FGIDMIVX5W2gqB5XJia6IFLAfFXU6GvHbfpKeyfx09R5mHP7NKrvlIS?= =?us-ascii?Q?FoICEEf/ameqVcvmO2970GYRoi91f5dR3o9DwuQSDEHZZp+uDniXl+vFv51I?= =?us-ascii?Q?UZStdj3mNP/sylE96VrsahTlonM+Q0vMpom6NWXzYHbM8/R5oLKg0RUoB9H/?= =?us-ascii?Q?aZSATZ5yC54mqXgF24SI/dlw7JLNN3gkMv8qtM6U7XaL7sCeIxrbwboHSIv0?= =?us-ascii?Q?D55ZQdtqa2TF4+SDGSipUUV1QrHMMzQz2dgOHrLA?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SN6PR11MB2752.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1965f0f6-39c7-4a69-0647-08daa05a3880 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Sep 2022 07:30:58.1292 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: R/SW+LBB1cBAvaXdW1NydFY9GpErux4cQtSs28uAt45BULwbS37zGxZPN1DjaT9M53qe/0SCuq63B0J0hWLsRg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR11MB5251 Return-Path: heng.luo@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Zack, 1. > + Status =3D UnicodeStrToAsciiStrS (Profile->Password, (CHAR8 > + *)AsciiPassword, ((StrLen (Profile->Password) + 1) * sizeof (CHAR8))); = =20 I think we should remove '* sizeof (CHAR8)' because the third parameter is = the length of string but not size of the memory: Status =3D UnicodeStrToAsciiStrS (Profile->Password, (CHAR8 *)AsciiPasswor= d, ((StrLen (Profile->Password) + 1))); =20 2.=20 > + if (StrLen (Profile->Password) > PASSWORD_STORAGE_SIZE) { > + ASSERT (EFI_INVALID_PARAMETER); > + return EFI_INVALID_PARAMETER; > + } Need null terminator at end of password, so I think the conditional should = be: if (StrLen (Profile->Password) >=3D PASSWORD_STORAGE_SIZE) in order to support 32 bytes PSK passwords with null terminator. Maybe need= to change PASSWORD_STORAGE_SIZE to 65? But PASSWORD_MAX_LEN should still = be 63, because according to the 802.11i specification: A pass-phrase is a sequence of between 8 and 63 ASCII-encoded characters. T= he limit of 63 comes from the desire to distinguish between a pass-phrase a= nd a PSK displayed as 64 hexadecimal characters. 3.=20 Suggest to add maintainers in Cc of the commit msg to speed up review. Fox example: WifiProfileSyncProtocol and if found will operate on the premise of a One Click Recovery, or KVM flow with a Wifi profile provided by AMT. =20 Cc: Maciej Rabeda Cc: Fu Siyuan Cc: Wu Jiaxin Signed-off-by: Zachary Clark-Williams Thanks, Heng > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of Clark- > williams, Zachary > Sent: Tuesday, September 27, 2022 2:20 AM > To: devel@edk2.groups.io > Cc: Zachary Clark-Williams ; Clark-williams, Zachar= y > > Subject: [edk2-devel] [PATCH V2 2/2] NetworkPkg: Add WiFi profile sync > protocol support >=20 > From: Zachary Clark-Williams >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3845 >=20 > 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. >=20 > Signed-off-by: Zachary Clark-Williams > --- > .../Protocol/WiFiProfileSyncProtocol.h | 83 ++++++++ > NetworkPkg/NetworkPkg.dec | 3 + > .../WifiConnectionManagerDxe.inf | 3 +- > .../WifiConnectionMgrDriver.c | 126 ++++++++---- > .../WifiConnectionMgrDxe.h | 4 +- > .../WifiConnectionMgrImpl.c | 193 ++++++++++++++++-- > .../WifiConnectionMgrMisc.c | 13 ++ > 7 files changed, 366 insertions(+), 59 deletions(-) create mode 100644 > NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h >=20 > diff --git a/NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h > b/NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h > new file mode 100644 > index 0000000000..e36daceabf > --- /dev/null > +++ b/NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h > @@ -0,0 +1,83 @@ > +/** @file > + WiFi profile sync protocol. Supports One Click Recovery or KVM OS > +recovery > + boot flow over WiFi. > + > + 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 > +shared > + and was stored in WiFi profile protocol. Aligns the AMT WiFi profile > +data to > + the WiFi connection manager profile structure fo connection use. > + > + @param[in, out] WcmProfile WiFi Connection Manager profile > structure > + @param[in, out] MacAddress MAC address from AMT saved to NiC > MAC address > + > + @retval EFI_SUCCESS Stored WiFi profile converted and re= turned > succefully > + @retval EFI_UNSUPPORTED Profile protocol sharing not support= ed 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 when > + in a KVM OR One Click Recovery WLAN recovery flow. Input as > + EFI_80211_CONNECT_NETWORK_RESULT_CODE then converted and > stored as EFI_STATUS 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 > +Click > + Recovery WLAN recovery flow. > + > + @retval EFI_SUCCESS WiFi connection completed succesfull= y > + @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.inf > 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/WifiConnectionMgrDriver.c > b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c > index 67a01ca058..65df5b2c8a 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_CONFIG_NETWORK_LIST_REFRESH_G > EFI_GUID mWifiConfigConnectFormRefreshGuid =3D > WIFI_CONFIG_CONNECT_FORM_REFRESH_GUID; > EFI_GUID mWifiConfigMainFormRefreshGuid =3D > WIFI_CONFIG_MAIN_FORM_REFRESH_GUID; >=20 > +// > +// Wifi connection attempt counter for retries // extern UINT8 > +WifiConnectionCount; > + > /** > Tests to see if this driver supports a given controller. If a child de= vice is > provided, > it further tests to see if this driver supports creating a handle for = the > 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; > + WifiConnectionCount =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 > *)AllocateZeroPool (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_PERIOD_MILLISECONDS (500)); > - if (EFI_ERROR (Status)) { > - goto ERROR3; > - } > + WiFiProfileSyncProtocol->WifiProfileSyncGetProfile (Nic- > >ConnectPendingNetwork, Nic->MacAddress); > + if (Nic->ConnectPendingNetwork !=3D NULL) { > + Status =3D WifiMgrConnectToNetwork (Nic, Nic->ConnectPendingNetwor= k); > + 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_PERIOD_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/NetworkPkg/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..936fe3e721 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 WifiConnectionCount =3D 0; > + > /** > The callback function for scan operation. This function updates networ= ks > 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) *= sizeof > (UINT8)); > + if (StrLen (Profile->Password) > PASSWORD_STORAGE_SIZE) { > + ASSERT (EFI_INVALID_PARAMETER); > + return EFI_INVALID_PARAMETER; > + } > + > + AsciiPassword =3D AllocateZeroPool ((StrLen (Profile->Password) + 1) * > + sizeof (CHAR8)); > if (AsciiPassword =3D=3D NULL) { > return EFI_OUT_OF_RESOURCES; > } >=20 > - UnicodeStrToAsciiStrS (Profile->Password, (CHAR8 *)AsciiPassword, > PASSWORD_STORAGE_SIZE); > - Status =3D Supplicant->SetData ( > - Supplicant, > - EfiSupplicant80211PskPassword, > - AsciiPassword, > - (StrLen (Profile->Password) + 1) * sizeof (UINT= 8) > - ); > + Status =3D UnicodeStrToAsciiStrS (Profile->Password, (CHAR8 > + *)AsciiPassword, ((StrLen (Profile->Password) + 1) * sizeof (CHAR8))); = if > (!EFI_ERROR (Status)) { > + Status =3D Supplicant->SetData ( > + Supplicant, > + EfiSupplicant80211PskPassword, > + AsciiPassword, > + (StrLen (Profile->Password) + 1) * sizeof (CH= AR8) > + ); > + } > + > 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, NU= LL, > (VOID **)&WiFiProfileSyncProtocol); > + if (!EFI_ERROR (Status)) { > + CopyMem (Identity, &Profile->EapIdentity, IdentitySize); > + } else { > + UnicodeStrToAsciiStrS (Profile->EapIdentity, Identity, IdentitySiz= e); > + } > + > 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 > connect. > + > + @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 > *)AllocateZeroPool (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 > memory for ConnectPendingNetwork\n")); > + goto ERROR; > + } > + > + Status =3D WiFiProfileSyncProtocol->WifiProfileSyncGetProfile (Nic- > >ConnectPendingNetwork, Nic->MacAddress); > + if (!EFI_ERROR (Status) && (Nic->ConnectPendingNetwork !=3D NULL)) { > + Status =3D WifiMgrConnectToNetwork (Nic, Nic->ConnectPendingNetwor= k); > + if (!EFI_ERROR (Status)) { > + return Status; > + } > + } else { > + DEBUG ((DEBUG_ERROR, "[WiFi Connection Manager] Failed to get WiFi > profile with status %r\n", Status)); > + } > + } else { > + DEBUG ((DEBUG_ERROR, "[WiFi Connection Manager] Failed to get > + Supported 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 ((WifiConnectionCount < MAX_WIFI_CONNETION_ATTEMPTS) && > + (ConfigToken->Token.ConnectNetworkToken->ResultCode !=3D > ConnectSuccess)) > + { > + WifiConnectionCount++; > + 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 > + performing a recovery boot in secure // boot mode. The profile sync > + driver will manage the CA certificate, client 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); > -- > 2.37.3.windows.1 >=20 >=20 >=20 >=20 >=20