From nobody Thu Apr 25 16:21:48 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+96917+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+96917+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1670008356; cv=none; d=zohomail.com; s=zohoarc; b=LTdbnbCKnSy3u3+Q3xV8Mb8EKJkQqi22s6AkEJbfcEi2ahQYvcglaeLRZhJzjHgLp6JDKjkk3+BMpQI4YIYdo8oCs+EWoW7+WhdbJ7XUjZPpridZ/9c8NHicUFprLLBnkSGa/7EncHvwsPKuUXG9gBuNEHqgvfchoa6AIj6CiuU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670008356; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=sO+HD7X7bvdaKNwVfbp8b0KqflR49K0LqULducjzrqk=; b=el6FKMK5gmsdhxRhvnJfdq8/KjKpkoLmXKTebdyt4PFg7IWSlMciVCbUKbWVGLKSnQX38yaJSDIQuq31DxjuHlQmQx27S8vekjaBRtRF2kj+k5o8nlcz9zTc9zqjkFYZnuBuGLtx02haiIWTsFVF0XQrHbIubkoT7qYTUGfbzDg= 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+96917+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 1670008356594599.7477175655597; Fri, 2 Dec 2022 11:12:36 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id fGpCYY1788612xkMZfOXS6q3; Fri, 02 Dec 2022 11:12:36 -0800 X-Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mx.groups.io with SMTP id smtpd.web11.84900.1670008354257768666 for ; Fri, 02 Dec 2022 11:12:35 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10549"; a="296382558" X-IronPort-AV: E=Sophos;i="5.96,213,1665471600"; d="scan'208";a="296382558" X-Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2022 11:12:35 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10549"; a="733916657" X-IronPort-AV: E=Sophos;i="5.96,213,1665471600"; d="scan'208";a="733916657" X-Received: from fmbiosdev02.amr.corp.intel.com ([10.80.127.10]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2022 11:12:35 -0800 From: "Saloni Kasbekar" To: devel@edk2.groups.io Cc: Saloni Kasbekar , Jian J Wang , Liming Gao , Maciej Rabeda Subject: [edk2-devel] [edk2-staging/HttpProxy PATCH v3 1/7] MdeModulePkg/Library: Support multi-URI HTTP Boot device path Date: Fri, 2 Dec 2022 11:12:20 -0800 Message-Id: <43c7fb80b5323567d5f3eead656f16ddec769c6e.1670008048.git.saloni.kasbekar@intel.com> In-Reply-To: References: 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,saloni.kasbekar@intel.com X-Gm-Message-State: hrFbChBOAKKKpPYX60NODziXx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1670008356; bh=YlBSnBIL8ZiUzj0UfwI4wr0qBkffuQ1wS3JjCqKMg6U=; h=Cc:Date:From:Reply-To:Subject:To; b=wPmnmKsm5UUmiYCL/JRAiMS2ne9ZcXr0xc5HaSH31nt+QKulbjo/OGbgxiTJt4alLqp y4YHXAH1xuysps7MydNbX2hcKif3lqxxt3C38v7BbxIK1eKuwZCXTKltHbqTsOiCFYulw qpLG749rH9VXwC+MJ4f9aupxDYBpO+OP5Dg= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1670008357615100003 Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3951 Process device path with proxy server and endpoint server included. Update comment for sample HTTP Boot device path. Cc: Jian J Wang Cc: Liming Gao Cc: Maciej Rabeda Signed-off-by: Saloni Kasbekar --- .../Library/UefiBootManagerLib/BmBoot.c | 28 +++++++++++++++++++ .../UefiBootManagerLib/BmBootDescription.c | 4 +-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c b/MdeModulePk= g/Library/UefiBootManagerLib/BmBoot.c index 962892d38f..fdef1ba292 100644 --- a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c @@ -1513,6 +1513,9 @@ BmExpandLoadFiles ( UINTN HandleCount; UINTN Index; EFI_DEVICE_PATH_PROTOCOL *Node; + URI_DEVICE_PATH *NullUriPath; + + NullUriPath =3D NULL; =20 // // Get file buffer from load file instance. @@ -1545,11 +1548,36 @@ BmExpandLoadFiles ( =20 for (Index =3D 0; Index < HandleCount; Index++) { if (BmMatchHttpBootDevicePath (DevicePathFromHandle (Handles[Index])= , FilePath)) { + // + // Matches HTTP Boot Device Path described as + // ....../Mac(...)[/Vlan(...)][/Wi-Fi(...)]/IPv4(...)[/Dns(...)]= /Uri(...) + // ....../Mac(...)[/Vlan(...)][/Wi-Fi(...)]/IPv6(...)[/Dns(...)]= /Uri(...) + // + Handle =3D Handles[Index]; + goto Done; + } + } + + NullUriPath =3D (URI_DEVICE_PATH *)CreateDeviceNode ( + MESSAGING_DEVICE_PATH, + MSG_URI_DP, + (UINT16)(sizeof (URI_DEVICE_PATH)) + ); + for (Index =3D 0; Index < HandleCount; Index++) { + if (BmMatchHttpBootDevicePath (AppendDevicePathNode (DevicePathFromH= andle (Handles[Index]), (EFI_DEVICE_PATH_PROTOCOL *)NullUriPath), FilePath)= ) { + // + // Matches HTTP Boot Device Path described as + // ....../Mac(...)[/Vlan(...)][/Wi-Fi(...)]/IPv4(...)[/Dns(...)]= /Uri(...)/Uri(...) + // ....../Mac(...)[/Vlan(...)][/Wi-Fi(...)]/IPv6(...)[/Dns(...)]= /Uri(...)/Uri(...) + // Handle =3D Handles[Index]; break; } } =20 + FreePool (NullUriPath); + +Done: if (Handles !=3D NULL) { FreePool (Handles); } diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c b/= MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c index fac33b9ee9..108efd8096 100644 --- a/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c @@ -412,8 +412,8 @@ BmGetNetworkDescription ( // ....../Mac(...)[/Vlan(...)][/Wi-Fi(...)]/IPv6(...) // // The HTTP device path is like: - // ....../Mac(...)[/Vlan(...)][/Wi-Fi(...)]/IPv4(...)[/Dns(...)]/Uri(.= ..) - // ....../Mac(...)[/Vlan(...)][/Wi-Fi(...)]/IPv6(...)[/Dns(...)]/Uri(.= ..) + // ....../Mac(...)[/Vlan(...)][/Wi-Fi(...)]/IPv4(...)[/Dns(...)][/Uri(= ...)]/Uri(...) + // ....../Mac(...)[/Vlan(...)][/Wi-Fi(...)]/IPv6(...)[/Dns(...)][/Uri(= ...)]/Uri(...) // while (!IsDevicePathEnd (DevicePath) && ((DevicePathType (DevicePath) !=3D MESSAGING_DEVICE_PATH) || --=20 2.36.1.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 (#96917): https://edk2.groups.io/g/devel/message/96917 Mute This Topic: https://groups.io/mt/95413291/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- From nobody Thu Apr 25 16:21:48 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+96918+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+96918+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1670008358; cv=none; d=zohomail.com; s=zohoarc; b=nNtvVbCGOAkj41NLoIhPlrLkY1uuTOksGuwfgDN2DL4r5EiLOscQVPQDOdsuk7uOgoNP/yhAsw0iKMjRhZmSykH0L3a/XPwzU42NmS8ZbmcljyNuMJYHD7h/xBev2xrM+b567O0Eya0mNwOUZn2+Uupt+o46lfMv/8Vrg6qoyE8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670008358; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=z+kti64Ljk79a4vw9iM6UuWQAMlAecfNNOGJ6MJDwL0=; b=CutQnugtI/jY/uE4d/blf3ikdYYTd5vZeeevuWg3iZGMp5AHkuZoGU5LUrJDbnpc+J7s1qx9HmQ5ECy0u4R1brzIiCHJECqAg/QQa3q9uDRRW/fpFrpl+At33hmdKXtSeNJKjPAcI4R+UlQF9H/QHtRR+8sJ02sycJrA59oeu30= 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+96918+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 1670008358382174.23706539702994; Fri, 2 Dec 2022 11:12:38 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 7GI2YY1788612xGqoghXWsmw; Fri, 02 Dec 2022 11:12:37 -0800 X-Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mx.groups.io with SMTP id smtpd.web11.84900.1670008354257768666 for ; Fri, 02 Dec 2022 11:12:37 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10549"; a="296382569" X-IronPort-AV: E=Sophos;i="5.96,213,1665471600"; d="scan'208";a="296382569" X-Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2022 11:12:36 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10549"; a="733916666" X-IronPort-AV: E=Sophos;i="5.96,213,1665471600"; d="scan'208";a="733916666" X-Received: from fmbiosdev02.amr.corp.intel.com ([10.80.127.10]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2022 11:12:36 -0800 From: "Saloni Kasbekar" To: devel@edk2.groups.io Cc: Saloni Kasbekar , Zhiguang Liu , Michael D Kinney , Liming Gao , Maciej Rabeda Subject: [edk2-devel] [edk2-staging/HttpProxy PATCH v3 2/7] MdePkg/Include: Add Proxy Server URL in EFI_HTTP_REQUEST_DATA Date: Fri, 2 Dec 2022 11:12:21 -0800 Message-Id: <71d7eb44c188622e87c6373e1da9c3a1cbd80d48.1670008048.git.saloni.kasbekar@intel.com> In-Reply-To: References: 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,saloni.kasbekar@intel.com X-Gm-Message-State: imsILRgijhu1LbJ6WsaTiPfyx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1670008357; bh=OmJ/YG8hVsMAZxwa0R1QsQkHYgJPxn1ZrHBm4a/DAdk=; h=Cc:Date:From:Reply-To:Subject:To; b=gpB0ibQN6rFaB5sFbC2XMUi5ww0EsnTWZOvYOHomr5xyam5jNIzX7+FWPkE+JMgRnjb qdnX2dAXkV9aVh0z7uljdZqen/jM/OKBAoTJ4Qm9/FTWmvKMxgedcMRwqoJq/QyJjcMlf 5mP4c4LlA5mM8tewv0c8QH/66NqNkIVJXdo= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1670008359624100009 Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3951 Add Proxy Server URL to EFI_HTTP_REQUEST_DATA. This will be used when a Proxy Server URL is a part of the HTTP Boot device path. Cc: Zhiguang Liu Cc: Michael D Kinney Cc: Liming Gao Cc: Maciej Rabeda Signed-off-by: Saloni Kasbekar --- MdePkg/Include/Protocol/Http.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/MdePkg/Include/Protocol/Http.h b/MdePkg/Include/Protocol/Http.h index 28e6221593..9ee08baa14 100644 --- a/MdePkg/Include/Protocol/Http.h +++ b/MdePkg/Include/Protocol/Http.h @@ -188,9 +188,17 @@ typedef struct { /// The URI of a remote host. From the information in this field, the HT= TP instance /// will be able to determine whether to use HTTP or HTTPS and will also= be able to /// determine the port number to use. If no port number is specified, po= rt 80 (HTTP) - /// is assumed. See RFC 3986 for more details on URI syntax. + /// or 443 (HTTPS) is assumed. See RFC 3986 for more details on URI synt= ax. /// CHAR16 *Url; + /// + /// The URI of an Proxy Host. This field will be NULL if there is no Pro= xy Host + /// in the device path. From the information in this field, the HTTP ins= tance will + /// be able to determine whether to use HTTP or HTTPS and will also be a= ble to + /// determine the port number to use. If no port number is specified, po= rt 80 (HTTP) + /// or 443 (HTTPS) is assumed. See RFC 3986 for more details on URI synt= ax. + /// + CHAR16 *ProxyUrl; } EFI_HTTP_REQUEST_DATA; =20 /// --=20 2.36.1.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 (#96918): https://edk2.groups.io/g/devel/message/96918 Mute This Topic: https://groups.io/mt/95413292/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- From nobody Thu Apr 25 16:21:48 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+96919+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+96919+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1670008359; cv=none; d=zohomail.com; s=zohoarc; b=KSH5U4I1hJPuOAoKm6Iq2gQ7TUusg3mNNweoYglICipcjvQQYy0GpFiPUcGWolOWpSkTSvaIcCc60fZI/DkWClJvAWNSWjIBRwYoJpycWNtZpL9WEFnOWlhcbNC2OCbJ3g0n8QvSj7Hp9wAAjUpY6FL3WTMQeoNVIqIc5AQWhJE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670008359; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=7PIIxLVhgeSKnCAT89s8Usu7h/idCQAzxNtoxkKOiYk=; b=dxrehXKXz31vAb6Ahm9xSrKe4toSbTS1YJJOep57pVAR6RcC8jkR5fjTTtZpxdJlkdaDY7QxyUjxbhX1t++x982ilLGOYQWZlSPLBk+vAyWgwjERZie/1NRVhrK1nXgd+8wLNoLswAfZDJ/61A9ISLxPybpDfRtuBNiNN014DMs= 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+96919+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 1670008359179457.8511961266771; Fri, 2 Dec 2022 11:12:39 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id SNKqYY1788612x0RZWhsp9vy; Fri, 02 Dec 2022 11:12:38 -0800 X-Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mx.groups.io with SMTP id smtpd.web11.84900.1670008354257768666 for ; Fri, 02 Dec 2022 11:12:37 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10549"; a="296382579" X-IronPort-AV: E=Sophos;i="5.96,213,1665471600"; d="scan'208";a="296382579" X-Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2022 11:12:37 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10549"; a="733916670" X-IronPort-AV: E=Sophos;i="5.96,213,1665471600"; d="scan'208";a="733916670" X-Received: from fmbiosdev02.amr.corp.intel.com ([10.80.127.10]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2022 11:12:37 -0800 From: "Saloni Kasbekar" To: devel@edk2.groups.io Cc: Saloni Kasbekar , Maciej Rabeda , Wu Jiaxin , Siyuan Fu Subject: [edk2-devel] [edk2-staging/HttpProxy PATCH v3 3/7] NetworkPkg/HttpBootDxe: Update HTTP Boot Driver with parsed Proxy URL Date: Fri, 2 Dec 2022 11:12:22 -0800 Message-Id: <40249646b0fd9e44940b3a001589c1d22e53e076.1670008048.git.saloni.kasbekar@intel.com> In-Reply-To: References: 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,saloni.kasbekar@intel.com X-Gm-Message-State: L7gru1qaNBw7gZmhYUBBAPybx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1670008358; bh=FRYzjAoSpyYzDuzqHrZUuqOOOjL1fbuJG/IxQyjhTTw=; h=Cc:Date:From:Reply-To:Subject:To; b=FIEpOAuFH4ah7qXtIeeZCQSgz0ETDM1WoDsy25cw7j+T1iRwtwM/V1FpyEAS0GHDunQ Y3/In2VMCbT11XtZiO7fkc16zHyEFaThbqPUZdI2GAVJkY5GApBohB1tNYtw57CcxDRVX hTjrBxLVaLYebSzFZdN7cK+qmYKX+iiUtfE= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1670008359661100012 Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3951 Add ProxyUri to HTTP_BOOT_PRIVATE_DATA Parse HTTP Boot Device path to process Proxy and EndPoint URLs Cc: Maciej Rabeda Cc: Wu Jiaxin Cc: Siyuan Fu Signed-off-by: Saloni Kasbekar --- NetworkPkg/HttpBootDxe/HttpBootClient.c | 30 ++++- NetworkPkg/HttpBootDxe/HttpBootDxe.h | 6 + NetworkPkg/HttpBootDxe/HttpBootImpl.c | 57 +++++---- NetworkPkg/HttpBootDxe/HttpBootSupport.c | 154 +++++++++++++++++------ NetworkPkg/HttpBootDxe/HttpBootSupport.h | 13 +- 5 files changed, 189 insertions(+), 71 deletions(-) diff --git a/NetworkPkg/HttpBootDxe/HttpBootClient.c b/NetworkPkg/HttpBootD= xe/HttpBootClient.c index 40f64fcb6b..b13155b576 100644 --- a/NetworkPkg/HttpBootDxe/HttpBootClient.c +++ b/NetworkPkg/HttpBootDxe/HttpBootClient.c @@ -678,6 +678,10 @@ HttpBootFreeCache ( FreePool (Cache->RequestData->Url); } =20 + if (Cache->RequestData->ProxyUrl !=3D NULL) { + FreePool (Cache->RequestData->ProxyUrl); + } + FreePool (Cache->RequestData); } =20 @@ -950,6 +954,7 @@ HttpBootGetBootFile ( UINT8 *Block; UINTN UrlSize; CHAR16 *Url; + CHAR16 *ProxyUrl; BOOLEAN IdentityMode; UINTN ReceivedSize; CHAR8 BaseAuthValue[80]; @@ -989,6 +994,22 @@ HttpBootGetBootFile ( // Not found in cache, try to download it through HTTP. // =20 + // + // Initialize ProxyUrl - Set to NULL if connecting without Proxy + // + if (Private->ProxyUri !=3D NULL) { + UrlSize =3D AsciiStrSize (Private->ProxyUri); + ProxyUrl =3D AllocatePool (UrlSize * (sizeof (CHAR16))); + if (ProxyUrl =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto ERROR_1; + } + + AsciiStrToUnicodeStrS (Private->ProxyUri, ProxyUrl, UrlSize); + } else { + ProxyUrl =3D NULL; + } + // // 1. Create a temp cache item for the requested URI if caller doesn't p= rovide buffer. // @@ -1106,8 +1127,9 @@ HttpBootGetBootFile ( goto ERROR_3; } =20 - RequestData->Method =3D HeaderOnly ? HttpMethodHead : HttpMethodGet; - RequestData->Url =3D Url; + RequestData->Method =3D HeaderOnly ? HttpMethodHead : HttpMethodGet; + RequestData->Url =3D Url; + RequestData->ProxyUrl =3D ProxyUrl; =20 // // 2.3 Record the request info in a temp cache item. @@ -1441,6 +1463,10 @@ ERROR_2: } =20 ERROR_1: + if (ProxyUrl !=3D NULL) { + FreePool (ProxyUrl); + } + if (Url !=3D NULL) { FreePool (Url); } diff --git a/NetworkPkg/HttpBootDxe/HttpBootDxe.h b/NetworkPkg/HttpBootDxe/= HttpBootDxe.h index 5ff8ad4698..8caf2e9a45 100644 --- a/NetworkPkg/HttpBootDxe/HttpBootDxe.h +++ b/NetworkPkg/HttpBootDxe/HttpBootDxe.h @@ -223,6 +223,12 @@ struct _HTTP_BOOT_PRIVATE_DATA { CHAR8 *FilePathUri; VOID *FilePathUriParser; =20 + // + // URI string for the Proxy host if BootFileUri contains a Proxy + // URI in the path + // + CHAR8 *ProxyUri; + // // Cached HTTP data // diff --git a/NetworkPkg/HttpBootDxe/HttpBootImpl.c b/NetworkPkg/HttpBootDxe= /HttpBootImpl.c index b4c61925b9..5735b96d9e 100644 --- a/NetworkPkg/HttpBootDxe/HttpBootImpl.c +++ b/NetworkPkg/HttpBootDxe/HttpBootImpl.c @@ -115,19 +115,21 @@ HttpBootStart ( { UINTN Index; EFI_STATUS Status; - CHAR8 *Uri; + CHAR8 *ProxyUri; + CHAR8 *EndPointUri; =20 - Uri =3D NULL; + ProxyUri =3D NULL; + EndPointUri =3D NULL; =20 if ((Private =3D=3D NULL) || (FilePath =3D=3D NULL)) { return EFI_INVALID_PARAMETER; } =20 // - // Check the URI in the input FilePath, in order to see whether it is + // Check the URIs in the input FilePath, in order to see whether it is // required to boot from a new specified boot file. // - Status =3D HttpBootParseFilePath (FilePath, &Uri); + Status =3D HttpBootParseFilePath (FilePath, &ProxyUri, &EndPointUri); if (EFI_ERROR (Status)) { return EFI_INVALID_PARAMETER; } @@ -143,28 +145,21 @@ HttpBootStart ( // recorded before. // if ((UsingIpv6 !=3D Private->UsingIpv6) || - ((Uri !=3D NULL) && (AsciiStrCmp (Private->BootFileUri, Uri) !=3D = 0))) + ((EndPointUri !=3D NULL) && (AsciiStrCmp (Private->BootFileUri, En= dPointUri) !=3D 0))) { // // Restart is required, first stop then continue this start function. // Status =3D HttpBootStop (Private); if (EFI_ERROR (Status)) { - if (Uri !=3D NULL) { - FreePool (Uri); - } - - return Status; + goto ERROR; } } else { // // Restart is not required. // - if (Uri !=3D NULL) { - FreePool (Uri); - } - - return EFI_ALREADY_STARTED; + Status =3D EFI_ALREADY_STARTED; + goto ERROR; } } =20 @@ -176,17 +171,16 @@ HttpBootStart ( } else if (!UsingIpv6 && (Private->Ip4Nic !=3D NULL)) { Private->UsingIpv6 =3D FALSE; } else { - if (Uri !=3D NULL) { - FreePool (Uri); - } - - return EFI_UNSUPPORTED; + Status =3D EFI_UNSUPPORTED; + goto ERROR; } =20 // - // Record the specified URI and prepare the URI parser if needed. + // Record the specified URIs and prepare the URI parser if needed. // - Private->FilePathUri =3D Uri; + Private->ProxyUri =3D ProxyUri; + Private->FilePathUri =3D EndPointUri; + if (Private->FilePathUri !=3D NULL) { Status =3D HttpParseUrl ( Private->FilePathUri, @@ -195,8 +189,7 @@ HttpBootStart ( &Private->FilePathUriParser ); if (EFI_ERROR (Status)) { - FreePool (Private->FilePathUri); - return Status; + goto ERROR; } } =20 @@ -228,6 +221,17 @@ HttpBootStart ( Print (L"\n>>Start HTTP Boot over IPv%d", Private->UsingIpv6 ? 6 : 4); =20 return EFI_SUCCESS; + +ERROR: + if (ProxyUri !=3D NULL) { + FreePool (ProxyUri); + } + + if (EndPointUri !=3D NULL) { + FreePool (EndPointUri); + } + + return Status; } =20 /** @@ -522,6 +526,11 @@ HttpBootStop ( Private->FilePathUriParser =3D NULL; } =20 + if (Private->ProxyUri !=3D NULL) { + FreePool (Private->ProxyUri); + Private->ProxyUri =3D NULL; + } + ZeroMem (Private->OfferBuffer, sizeof (Private->OfferBuffer)); Private->OfferNum =3D 0; ZeroMem (Private->OfferCount, sizeof (Private->OfferCount)); diff --git a/NetworkPkg/HttpBootDxe/HttpBootSupport.c b/NetworkPkg/HttpBoot= Dxe/HttpBootSupport.c index 236ef25931..9af6cf0c69 100644 --- a/NetworkPkg/HttpBootDxe/HttpBootSupport.c +++ b/NetworkPkg/HttpBootDxe/HttpBootSupport.c @@ -551,71 +551,145 @@ HttpBootCheckUriScheme ( return Status; } =20 +/** + Get the URI address string from the URI device path node. + + Caller need to free the buffer in the Uri pointer. + + @param[in] Node Pointer to the URI device path node. + @param[out] Uri URI string extracted from the device pat= h. + + @retval EFI_SUCCESS The URI string is returned. + @retval EFI_INVALID_PARAMETER Parameters are NULL or invalid URI node. + @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. + +**/ +EFI_STATUS +HttpBootUriFromDevicePath ( + IN URI_DEVICE_PATH *Node, + OUT CHAR8 **Uri + ) +{ + UINTN UriStrLength; + + if ((Node =3D=3D NULL) || (Uri =3D=3D NULL)) { + return EFI_INVALID_PARAMETER; + } + + UriStrLength =3D DevicePathNodeLength (Node) - sizeof (EFI_DEVICE_PATH_P= ROTOCOL); + + if (UriStrLength =3D=3D 0) { + // Invalid URI, return. + return EFI_INVALID_PARAMETER; + } + + *Uri =3D AllocatePool (UriStrLength + 1); + if (*Uri =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + CopyMem (*Uri, Node->Uri, UriStrLength); + (*Uri)[UriStrLength] =3D '\0'; + + return EFI_SUCCESS; +} + /** Get the URI address string from the input device path. =20 - Caller need to free the buffer in the UriAddress pointer. + Caller needs to free the buffers returned by this function. =20 - @param[in] FilePath Pointer to the device path which contains = a URI device path node. - @param[out] UriAddress The URI address string extract from the de= vice path. + @param[in] FilePath Pointer to the device path which contain= s a URI device path node. + @param[out] ProxyUriAddress The proxy URI address string extract fro= m the device path (if it exists) + @param[out] EndPointUriAddress The endpoint URI address string for the = endpoint host. =20 @retval EFI_SUCCESS The URI string is returned. + @retval EFI_INVALID_PARAMETER Parameters are NULL or device path is inv= alid. @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. =20 **/ EFI_STATUS HttpBootParseFilePath ( - IN EFI_DEVICE_PATH_PROTOCOL *FilePath, - OUT CHAR8 **UriAddress + IN EFI_DEVICE_PATH_PROTOCOL *FilePath, + OUT CHAR8 **ProxyUriAddress, + OUT CHAR8 **EndPointUriAddress ) { - EFI_DEVICE_PATH_PROTOCOL *TempDevicePath; - URI_DEVICE_PATH *UriDevicePath; - CHAR8 *Uri; - UINTN UriStrLength; - - if (FilePath =3D=3D NULL) { + EFI_STATUS Status; + EFI_DEVICE_PATH_PROTOCOL *Node[2]; + EFI_DEVICE_PATH_PROTOCOL *TempNode; + BOOLEAN NodeIsUri[2]; + UINTN Index; + + if ((FilePath =3D=3D NULL) || + (ProxyUriAddress =3D=3D NULL) || + (EndPointUriAddress =3D=3D NULL)) + { return EFI_INVALID_PARAMETER; } =20 - *UriAddress =3D NULL; + *ProxyUriAddress =3D NULL; + *EndPointUriAddress =3D NULL; + ZeroMem (Node, sizeof (Node)); =20 + // Obtain last 2 device path nodes. + // Looking for sequences: + // 1) //....../Mac(...)[/Vlan(...)][/Wi-Fi(...)]/IPv6(...)[/Dns(...)]/Ur= i(ProxyServer)/Uri(EndPointServer/FilePath) + // 2) //....../Mac(...)[/Vlan(...)][/Wi-Fi(...)]/IPv6(...)[/Dns(...)]/Ur= i(EndPointServer/FilePath) // - // Extract the URI address from the FilePath - // - TempDevicePath =3D FilePath; - while (!IsDevicePathEnd (TempDevicePath)) { - if ((DevicePathType (TempDevicePath) =3D=3D MESSAGING_DEVICE_PATH) && - (DevicePathSubType (TempDevicePath) =3D=3D MSG_URI_DP)) - { - UriDevicePath =3D (URI_DEVICE_PATH *)TempDevicePath; - // - // UEFI Spec doesn't require the URI to be a NULL-terminated string - // So we allocate a new buffer and always append a '\0' to it. - // - UriStrLength =3D DevicePathNodeLength (UriDevicePath) - sizeof (EFI_= DEVICE_PATH_PROTOCOL); - if (UriStrLength =3D=3D 0) { - // - // return a NULL UriAddress if it's a empty URI device path node. - // - break; - } - - Uri =3D AllocatePool (UriStrLength + 1); - if (Uri =3D=3D NULL) { - return EFI_OUT_OF_RESOURCES; - } + // Expected: + // Node[1] - Uri(EndPointServer/FilePath) + // Node[0] - Either Uri(EndPointServer/FilePath) or other. + TempNode =3D FilePath; + + while (!IsDevicePathEnd (TempNode)) { + Node[0] =3D Node[1]; + Node[1] =3D TempNode; + TempNode =3D NextDevicePathNode (TempNode); + } + + // Verify if device path nodes are of type MESSAGING + URI. + for (Index =3D 0; Index < 2; Index++) { + if (Node[Index] =3D=3D NULL) { + NodeIsUri[Index] =3D FALSE; + } else { + NodeIsUri[Index] =3D ((DevicePathType (Node[Index]) =3D=3D MESSAGING= _DEVICE_PATH) && + (DevicePathSubType (Node[Index]) =3D=3D MSG_URI_= DP)); + } + } =20 - CopyMem (Uri, UriDevicePath->Uri, DevicePathNodeLength (UriDevicePat= h) - sizeof (EFI_DEVICE_PATH_PROTOCOL)); - Uri[DevicePathNodeLength (UriDevicePath) - sizeof (EFI_DEVICE_PATH_P= ROTOCOL)] =3D '\0'; + // If exists, obtain endpoint URI string. + if (NodeIsUri[1]) { + Status =3D HttpBootUriFromDevicePath ( + (URI_DEVICE_PATH *)Node[1], + EndPointUriAddress + ); =20 - *UriAddress =3D Uri; + if (EFI_ERROR (Status)) { + return Status; } =20 - TempDevicePath =3D NextDevicePathNode (TempDevicePath); + // If exists, obtain proxy URI string. + if (NodeIsUri[0]) { + Status =3D HttpBootUriFromDevicePath ( + (URI_DEVICE_PATH *)Node[0], + ProxyUriAddress + ); + + if (EFI_ERROR (Status)) { + goto ErrorExit; + } + } } =20 return EFI_SUCCESS; + +ErrorExit: + ASSERT (*EndPointUriAddress !=3D NULL); + FreePool (*EndPointUriAddress); + *EndPointUriAddress =3D NULL; + + return Status; } =20 /** diff --git a/NetworkPkg/HttpBootDxe/HttpBootSupport.h b/NetworkPkg/HttpBoot= Dxe/HttpBootSupport.h index 3698e55936..5a46894517 100644 --- a/NetworkPkg/HttpBootDxe/HttpBootSupport.h +++ b/NetworkPkg/HttpBootDxe/HttpBootSupport.h @@ -136,19 +136,22 @@ HttpBootCheckUriScheme ( /** Get the URI address string from the input device path. =20 - Caller need to free the buffer in the UriAddress pointer. + Caller needs to free the buffers returned by this function. =20 - @param[in] FilePath Pointer to the device path which contains = a URI device path node. - @param[out] UriAddress The URI address string extract from the de= vice path. + @param[in] FilePath Pointer to the device path which contain= s a URI device path node. + @param[out] ProxyUriAddress The proxy URI address string extract fro= m the device path (if it exists) + @param[out] EndPointUriAddress The endpoint URI address string for the = endpoint host. =20 @retval EFI_SUCCESS The URI string is returned. + @retval EFI_INVALID_PARAMETER Parameters are NULL or device path is inv= alid. @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. =20 **/ EFI_STATUS HttpBootParseFilePath ( - IN EFI_DEVICE_PATH_PROTOCOL *FilePath, - OUT CHAR8 **UriAddress + IN EFI_DEVICE_PATH_PROTOCOL *FilePath, + OUT CHAR8 **ProxyUriAddress, + OUT CHAR8 **EndPointUriAddress ); =20 /** --=20 2.36.1.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 (#96919): https://edk2.groups.io/g/devel/message/96919 Mute This Topic: https://groups.io/mt/95413293/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- From nobody Thu Apr 25 16:21:48 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+96920+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+96920+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1670008359; cv=none; d=zohomail.com; s=zohoarc; b=VCOjmCA++Xzz0Bd4MD9+NEO02a6PxGSqSfEVkd0VUN0XjNjKpX8W/+A4osQjptHiCX3gtj+kQdC9uBIRcTZT67VWia4vhcPFxzzMxZ8BcKrk7YtfNThMZoZut55+C7I8wJGysTcAtQnOZlenQHaxuzAfdtvOmhNvEzbeMj1/Pqc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670008359; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=POAMJD8CuPr3MqLgaQyB7sSvCmEUzl9DwzBQH2cUCfs=; b=Io9lR3N/bsrS9S0F4Qax7key8tnVLFwP4HQc3FBIYn0cSuS6BBN0GP1RaeVzLqx9OxZbb7LjcSpTCEpM3ggwfjocg0iPgqIRIlfE8g3Mebpfy+T1Kuir8jwJ5IEBEsMCAdROYSytRKFCzdgZVDvmVqyfpepaeeN8woXd067e1KU= 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+96920+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 1670008359411526.4863825239346; Fri, 2 Dec 2022 11:12:39 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id DE6nYY1788612x4fDwwUo0h1; Fri, 02 Dec 2022 11:12:39 -0800 X-Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mx.groups.io with SMTP id smtpd.web11.84900.1670008354257768666 for ; Fri, 02 Dec 2022 11:12:38 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10549"; a="296382592" X-IronPort-AV: E=Sophos;i="5.96,213,1665471600"; d="scan'208";a="296382592" X-Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2022 11:12:38 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10549"; a="733916683" X-IronPort-AV: E=Sophos;i="5.96,213,1665471600"; d="scan'208";a="733916683" X-Received: from fmbiosdev02.amr.corp.intel.com ([10.80.127.10]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2022 11:12:38 -0800 From: "Saloni Kasbekar" To: devel@edk2.groups.io Cc: Saloni Kasbekar , Maciej Rabeda , Wu Jiaxin , Siyuan Fu Subject: [edk2-devel] [edk2-staging/HttpProxy PATCH v3 4/7] NetworkPkg: Add Proxy Support to HTTP_PROTOCOL Date: Fri, 2 Dec 2022 11:12:23 -0800 Message-Id: <5725304efc9d9463081770ed01fb3d07c405ab2e.1670008048.git.saloni.kasbekar@intel.com> In-Reply-To: References: 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,saloni.kasbekar@intel.com X-Gm-Message-State: fEisFSeWX5Xt7Xru93quGdslx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1670008359; bh=sIovj/SODanoMtmz4rpwYRKReueTKY8z0QgabLzLCQo=; h=Cc:Date:From:Reply-To:Subject:To; b=mnjR47ZeMWfZ6CbfEq1Q9vLLbNMBofevMBmCiGgqn62+7qY15CXYlom1mCwEm8mMcKa Lx4TTBkgWiE4a7KaYvlM3CyMeTkzq+aVM+ZbYiGoe/TXEVd/hvyGSwRytYXXe+k9sbB6p 8+ugliEoR8GjVAx6hOaR6pqeGFIt1u/oNLs= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1670008359657100011 Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3951 Update HTTP Protocol with variables to support Proxy Use state machine to call HttpBootGetBootFile() Add switch/case for EfiHttpRequest request method Cc: Maciej Rabeda Cc: Wu Jiaxin Cc: Siyuan Fu Signed-off-by: Saloni Kasbekar --- NetworkPkg/HttpBootDxe/HttpBootImpl.c | 178 +++++++++++++++++--------- NetworkPkg/HttpBootDxe/HttpBootImpl.h | 7 + NetworkPkg/HttpDxe/HttpImpl.c | 59 +++++++-- NetworkPkg/HttpDxe/HttpProto.c | 18 ++- NetworkPkg/HttpDxe/HttpProto.h | 9 ++ 5 files changed, 199 insertions(+), 72 deletions(-) diff --git a/NetworkPkg/HttpBootDxe/HttpBootImpl.c b/NetworkPkg/HttpBootDxe= /HttpBootImpl.c index 5735b96d9e..4748de0603 100644 --- a/NetworkPkg/HttpBootDxe/HttpBootImpl.c +++ b/NetworkPkg/HttpBootDxe/HttpBootImpl.c @@ -278,6 +278,122 @@ HttpBootDhcp ( return Status; } =20 +/** + Issue calls to HttpBootGetBootFile() based on current Boot File State + + @param[in] Private The pointer to the driver's private = data. + @param[in, out] BufferSize On input the size of Buffer in bytes= . On output with a return + code of EFI_SUCCESS, the amount of d= ata transferred to + Buffer. On output with a return code= of EFI_BUFFER_TOO_SMALL, + the size of Buffer required to retri= eve the requested file. + @param[in] Buffer The memory buffer to transfer the fi= le to. If Buffer is NULL, + then the size of the requested file = is returned in + BufferSize. + @param[out] ImageType The image type of the downloaded fil= e. + + @retval EFI_SUCCESS The file was loaded. + @retval EFI_INVALID_PARAMETER BufferSize is NULL or Buffer Size is no= t NULL but Buffer is NULL. + @retval EFI_OUT_OF_RESOURCES Could not allocate needed resources + @retval EFI_BUFFER_TOO_SMALL The BufferSize is too small to read the= current directory entry. + BufferSize has been updated with the si= ze needed to complete + the request. + @retval EFI_ACCESS_DENIED Server authentication failed. + @retval Others Unexpected error happened. + +**/ +EFI_STATUS +HttpBootGetBootFileCaller ( + IN HTTP_BOOT_PRIVATE_DATA *Private, + IN OUT UINTN *BufferSize, + IN VOID *Buffer OPTIONAL, + OUT HTTP_BOOT_IMAGE_TYPE *ImageType + ) +{ + HTTP_GET_BOOT_FILE_STATE State; + EFI_STATUS Status; + + if (Private->BootFileSize =3D=3D 0) { + State =3D GetBootFileHead; + } else { + State =3D LoadBootFile; + } + + for ( ; ;) { + switch (State) { + case GetBootFileHead: + // + // Try to use HTTP HEAD method. + // + Status =3D HttpBootGetBootFile ( + Private, + TRUE, + &Private->BootFileSize, + NULL, + &Private->ImageType + ); + if ((EFI_ERROR (Status)) && (Status !=3D EFI_BUFFER_TOO_SMALL)) { + if ((Private->AuthData !=3D NULL) && (Status =3D=3D EFI_ACCESS_D= ENIED)) { + // + // Try to use HTTP HEAD method again since the Authentication = information is provided. + // + State =3D GetBootFileHead; + } else { + State =3D GetBootFileGet; + } + } else { + State =3D LoadBootFile; + } + + break; + + case GetBootFileGet: + // + // Failed to get file size by HEAD method, may be trunked encoding= , try HTTP GET method. + // + ASSERT (Private->BootFileSize =3D=3D 0); + Status =3D HttpBootGetBootFile ( + Private, + FALSE, + &Private->BootFileSize, + NULL, + &Private->ImageType + ); + if (EFI_ERROR (Status) && (Status !=3D EFI_BUFFER_TOO_SMALL)) { + State =3D GetBootFileError; + } else { + State =3D LoadBootFile; + } + + break; + + case LoadBootFile: + if (*BufferSize < Private->BootFileSize) { + *BufferSize =3D Private->BootFileSize; + *ImageType =3D Private->ImageType; + Status =3D EFI_BUFFER_TOO_SMALL; + return Status; + } + + // + // Load the boot file into Buffer + // + Status =3D HttpBootGetBootFile ( + Private, + FALSE, + BufferSize, + Buffer, + ImageType + ); + return Status; + + case GetBootFileError: + default: + AsciiPrint ("\n Error: Could not retrieve NBP file size from HTTP= server.\n"); + return Status; + } + } +} + /** Attempt to download the boot file through HTTP message exchange. =20 @@ -349,68 +465,10 @@ HttpBootLoadFile ( } } =20 - if (Private->BootFileSize =3D=3D 0) { - // - // Discover the information about the bootfile if we haven't. - // - - // - // Try to use HTTP HEAD method. - // - Status =3D HttpBootGetBootFile ( - Private, - TRUE, - &Private->BootFileSize, - NULL, - &Private->ImageType - ); - if ((Private->AuthData !=3D NULL) && (Status =3D=3D EFI_ACCESS_DENIED)= ) { - // - // Try to use HTTP HEAD method again since the Authentication inform= ation is provided. - // - Status =3D HttpBootGetBootFile ( - Private, - TRUE, - &Private->BootFileSize, - NULL, - &Private->ImageType - ); - } else if ((EFI_ERROR (Status)) && (Status !=3D EFI_BUFFER_TOO_SMALL))= { - // - // Failed to get file size by HEAD method, may be trunked encoding, = try HTTP GET method. - // - ASSERT (Private->BootFileSize =3D=3D 0); - Status =3D HttpBootGetBootFile ( - Private, - FALSE, - &Private->BootFileSize, - NULL, - &Private->ImageType - ); - if (EFI_ERROR (Status) && (Status !=3D EFI_BUFFER_TOO_SMALL)) { - AsciiPrint ("\n Error: Could not retrieve NBP file size from HTTP= server.\n"); - goto ON_EXIT; - } - } - } - - if (*BufferSize < Private->BootFileSize) { - *BufferSize =3D Private->BootFileSize; - *ImageType =3D Private->ImageType; - Status =3D EFI_BUFFER_TOO_SMALL; - goto ON_EXIT; - } - // - // Load the boot file into Buffer + // Load the Boot File // - Status =3D HttpBootGetBootFile ( - Private, - FALSE, - BufferSize, - Buffer, - ImageType - ); + Status =3D HttpBootGetBootFileCaller (Private, BufferSize, Buffer, Image= Type); =20 ON_EXIT: HttpBootUninstallCallback (Private); diff --git a/NetworkPkg/HttpBootDxe/HttpBootImpl.h b/NetworkPkg/HttpBootDxe= /HttpBootImpl.h index 55adc9cb50..33da4fec51 100644 --- a/NetworkPkg/HttpBootDxe/HttpBootImpl.h +++ b/NetworkPkg/HttpBootDxe/HttpBootImpl.h @@ -11,6 +11,13 @@ SPDX-License-Identifier: BSD-2-Clause-Patent =20 #define HTTP_BOOT_CHECK_MEDIA_WAITING_TIME EFI_TIMER_PERIOD_SECONDS(20) =20 +typedef enum { + GetBootFileHead, + GetBootFileGet, + LoadBootFile, + GetBootFileError +} HTTP_GET_BOOT_FILE_STATE; + /** Attempt to complete a DHCPv4 D.O.R.A or DHCPv6 S.R.A.A sequence to retri= eve the boot resource information. =20 diff --git a/NetworkPkg/HttpDxe/HttpImpl.c b/NetworkPkg/HttpDxe/HttpImpl.c index 7c5c925cf7..a761ce3d5d 100644 --- a/NetworkPkg/HttpDxe/HttpImpl.c +++ b/NetworkPkg/HttpDxe/HttpImpl.c @@ -162,6 +162,7 @@ EfiHttpConfigure ( HttpInstance->TimeOutMillisec =3D HttpConfigData->TimeOutMillisec; HttpInstance->LocalAddressIsIPv6 =3D HttpConfigData->LocalAddressIsIPv= 6; HttpInstance->ConnectionClose =3D FALSE; + HttpInstance->ProxyConnected =3D FALSE; =20 if (HttpConfigData->LocalAddressIsIPv6) { CopyMem ( @@ -244,6 +245,8 @@ EfiHttpRequest ( CHAR8 *RequestMsg; CHAR8 *Url; UINTN UrlLen; + CHAR8 *ProxyUrl; + UINTN ProxyUrlLen; CHAR16 *HostNameStr; HTTP_TOKEN_WRAP *Wrap; CHAR8 *FileUrl; @@ -254,6 +257,7 @@ EfiHttpRequest ( // Initializations // Url =3D NULL; + ProxyUrl =3D NULL; UrlParser =3D NULL; RemotePort =3D 0; HostName =3D NULL; @@ -277,12 +281,18 @@ EfiHttpRequest ( // // Only support GET, HEAD, DELETE, PATCH, PUT and POST method in current= implementation. // - if ((Request !=3D NULL) && (Request->Method !=3D HttpMethodGet) && - (Request->Method !=3D HttpMethodHead) && (Request->Method !=3D HttpM= ethodDelete) && - (Request->Method !=3D HttpMethodPut) && (Request->Method !=3D HttpMe= thodPost) && - (Request->Method !=3D HttpMethodPatch)) - { - return EFI_UNSUPPORTED; + if (Request !=3D NULL) { + switch (Request->Method) { + case HttpMethodGet: + case HttpMethodHead: + case HttpMethodDelete: + case HttpMethodPut: + case HttpMethodPost: + case HttpMethodPatch: + break; + default: + return EFI_UNSUPPORTED; + } } =20 HttpInstance =3D HTTP_INSTANCE_FROM_PROTOCOL (This); @@ -337,22 +347,49 @@ EfiHttpRequest ( } =20 // - // Parse the URI of the remote host. + // Parse the Request URI. // Url =3D HttpInstance->Url; UrlLen =3D StrLen (Request->Url) + 1; - if (UrlLen > HTTP_URL_BUFFER_LEN) { + if (UrlLen > HttpInstance->UrlLen) { Url =3D AllocateZeroPool (UrlLen); if (Url =3D=3D NULL) { return EFI_OUT_OF_RESOURCES; } =20 - FreePool (HttpInstance->Url); - HttpInstance->Url =3D Url; + if (HttpInstance->Url !=3D NULL) { + FreePool (HttpInstance->Url); + } + + HttpInstance->Url =3D Url; + HttpInstance->UrlLen =3D UrlLen; } =20 UnicodeStrToAsciiStrS (Request->Url, Url, UrlLen); =20 + // + // In case of HTTP Connect, parse proxy URI from Request. + // + if (Request->Method =3D=3D HttpMethodConnect) { + ProxyUrl =3D HttpInstance->ProxyUrl; + ProxyUrlLen =3D StrLen (Request->ProxyUrl) + 1; + if (ProxyUrlLen > HttpInstance->ProxyUrlLen) { + ProxyUrl =3D AllocateZeroPool (ProxyUrlLen); + if (ProxyUrl =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + if (HttpInstance->ProxyUrl !=3D NULL) { + FreePool (HttpInstance->ProxyUrl); + } + + HttpInstance->ProxyUrl =3D ProxyUrl; + HttpInstance->ProxyUrlLen =3D ProxyUrlLen; + } + + UnicodeStrToAsciiStrS (Request->ProxyUrl, ProxyUrl, ProxyUrlLen); + } + // // From the information in Url, the HTTP instance will // be able to determine whether to use http or https. @@ -395,7 +432,7 @@ EfiHttpRequest ( } =20 UrlParser =3D NULL; - Status =3D HttpParseUrl (Url, (UINT32)AsciiStrLen (Url), FALSE, &Ur= lParser); + Status =3D HttpParseUrl (Url, (UINT32)AsciiStrLen (Url), FALSE, &UrlPa= rser); if (EFI_ERROR (Status)) { goto Error1; } diff --git a/NetworkPkg/HttpDxe/HttpProto.c b/NetworkPkg/HttpDxe/HttpProto.c index 33ae622c3f..6767d90c7d 100644 --- a/NetworkPkg/HttpDxe/HttpProto.c +++ b/NetworkPkg/HttpDxe/HttpProto.c @@ -737,6 +737,8 @@ HttpInitProtocol ( goto ON_ERROR; } =20 + HttpInstance->UrlLen =3D HTTP_URL_BUFFER_LEN; + return EFI_SUCCESS; =20 ON_ERROR: @@ -846,9 +848,23 @@ HttpCleanProtocol ( =20 if (HttpInstance->Url !=3D NULL) { FreePool (HttpInstance->Url); - HttpInstance->Url =3D NULL; + HttpInstance->Url =3D NULL; + HttpInstance->UrlLen =3D 0; + } + + if (HttpInstance->ProxyUrl !=3D NULL) { + FreePool (HttpInstance->ProxyUrl); + HttpInstance->ProxyUrl =3D NULL; + HttpInstance->ProxyUrlLen =3D 0; } =20 + if (HttpInstance->EndPointHostName !=3D NULL) { + FreePool (HttpInstance->EndPointHostName); + HttpInstance->EndPointHostName =3D NULL; + } + + HttpInstance->ProxyConnected =3D FALSE; + NetMapClean (&HttpInstance->TxTokens); NetMapClean (&HttpInstance->RxTokens); =20 diff --git a/NetworkPkg/HttpDxe/HttpProto.h b/NetworkPkg/HttpDxe/HttpProto.h index 620eb39158..3e4e86dad9 100644 --- a/NetworkPkg/HttpDxe/HttpProto.h +++ b/NetworkPkg/HttpDxe/HttpProto.h @@ -164,6 +164,15 @@ typedef struct _HTTP_PROTOCOL { NET_MAP RxTokens; =20 CHAR8 *Url; + UINTN UrlLen; + + // + // Proxy support + // + CHAR8 *ProxyUrl; + UINTN ProxyUrlLen; + BOOLEAN ProxyConnected; + CHAR8 *EndPointHostName; =20 // // Https Support --=20 2.36.1.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 (#96920): https://edk2.groups.io/g/devel/message/96920 Mute This Topic: https://groups.io/mt/95413295/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- From nobody Thu Apr 25 16:21:48 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+96921+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+96921+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1670008361; cv=none; d=zohomail.com; s=zohoarc; b=amG3jAjDifx/ZNK9MCS8oc6xdzLr4DcVhV6JRD8syKXyx8MAzXVzKUO+OywBiREqFl+Ih06wCVack6pL4WuvA8N2XFytAQLOM4zy1s6RtVQuemBCUPp5/PBHU9IyZPv597BuqzPHIfQQg/Qutk8cX5GTDCXkjYEeg5Lrwt/rTUQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670008361; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=5lEunW7pcRn5emQPW90xgY+MFYD4JvPzQHF+iY655Vk=; b=Q7fZsTVpT4Lij5V6Pg8+UZ0ymcMdAmVPWwPo+1LRsutNlUIQNwN4tLvPtaZvaMmOGp4lDji1dK5EdFCABLAaI3SbMUmorhhsy2W/0mE7vucU3kPy1P72wd/8S1l2gHPqHzreH1/5PxmANGgMx+Prlpy9/x1jCpr0BXNnMdBw3Lk= 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+96921+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 1670008361538310.64769592883147; Fri, 2 Dec 2022 11:12:41 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id xxpaYY1788612x0lVCa5uh4D; Fri, 02 Dec 2022 11:12:40 -0800 X-Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mx.groups.io with SMTP id smtpd.web11.84900.1670008354257768666 for ; Fri, 02 Dec 2022 11:12:39 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10549"; a="296382611" X-IronPort-AV: E=Sophos;i="5.96,213,1665471600"; d="scan'208";a="296382611" X-Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2022 11:12:39 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10549"; a="733916700" X-IronPort-AV: E=Sophos;i="5.96,213,1665471600"; d="scan'208";a="733916700" X-Received: from fmbiosdev02.amr.corp.intel.com ([10.80.127.10]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2022 11:12:38 -0800 From: "Saloni Kasbekar" To: devel@edk2.groups.io Cc: Saloni Kasbekar , Maciej Rabeda , Wu Jiaxin , Siyuan Fu Subject: [edk2-devel] [edk2-staging/HttpProxy PATCH v3 5/7] NetworkPkg: Add support for HTTP CONNECT Method Date: Fri, 2 Dec 2022 11:12:24 -0800 Message-Id: <99951a1bb8751c1e9b001a047575be45413ef616.1670008048.git.saloni.kasbekar@intel.com> In-Reply-To: References: 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,saloni.kasbekar@intel.com X-Gm-Message-State: wAxZDTBdmWizOgFmP8KjYowLx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1670008360; bh=CczQjRPKWQDBQ8QFj3lVf0R7VUvtBL9sKJPuh7drxdY=; h=Cc:Date:From:Reply-To:Subject:To; b=OgS1+LNFmNhjjEOvUyhzZ+oI6kv97zbeGjSm1Pa91mGOyGF2gaNphps4Lapk0hzGOX2 KBRiQJLqW2WYQWHBDJ/UQLarxy2Q5aFGtUBjkk08hXvW0pp1NGT/7JBSqpcORRv3gerwE UjfwEaF6roJLR5/inmpaSOD26C8c+Rv4sZM= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1670008363668100027 Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3951 Add support for the HTTP CONNECT method to request the Proxy Server to open a tunnel to the EndPoint Server Cc: Maciej Rabeda Cc: Wu Jiaxin Cc: Siyuan Fu Signed-off-by: Saloni Kasbekar --- NetworkPkg/HttpBootDxe/HttpBootClient.c | 176 +++++++++++++++++++++ NetworkPkg/HttpBootDxe/HttpBootClient.h | 15 ++ NetworkPkg/HttpBootDxe/HttpBootImpl.c | 16 +- NetworkPkg/HttpBootDxe/HttpBootImpl.h | 1 + NetworkPkg/HttpDxe/HttpDriver.h | 2 + NetworkPkg/HttpDxe/HttpDxe.inf | 1 + NetworkPkg/HttpDxe/HttpImpl.c | 151 ++++++++++++++---- NetworkPkg/Library/DxeHttpLib/DxeHttpLib.c | 5 + 8 files changed, 335 insertions(+), 32 deletions(-) diff --git a/NetworkPkg/HttpBootDxe/HttpBootClient.c b/NetworkPkg/HttpBootD= xe/HttpBootClient.c index b13155b576..b4d02eaff2 100644 --- a/NetworkPkg/HttpBootDxe/HttpBootClient.c +++ b/NetworkPkg/HttpBootDxe/HttpBootClient.c @@ -905,6 +905,182 @@ HttpBootGetBootFileCallback ( return EFI_SUCCESS; } =20 +/** + This function establishes a connection through a proxy server + + @param[in] Private The pointer to the driver's private dat= a. + + @retval EFI_SUCCESS Connection successful. + @retval EFI_OUT_OF_RESOURCES Could not allocate needed resources + @retval Others Unexpected error happened. + +**/ +EFI_STATUS +HttpBootConnectProxy ( + IN HTTP_BOOT_PRIVATE_DATA *Private + ) +{ + EFI_STATUS Status; + EFI_HTTP_STATUS_CODE StatusCode; + CHAR8 *HostName; + EFI_HTTP_REQUEST_DATA *RequestData; + HTTP_IO_RESPONSE_DATA *ResponseData; + HTTP_IO *HttpIo; + HTTP_IO_HEADER *HttpIoHeader; + CHAR16 *Url; + CHAR16 *ProxyUrl; + UINTN UrlSize; + + Url =3D NULL; + ProxyUrl =3D NULL; + RequestData =3D NULL; + ResponseData =3D NULL; + HttpIoHeader =3D NULL; + + UrlSize =3D AsciiStrSize (Private->BootFileUri); + Url =3D AllocatePool (UrlSize * sizeof (CHAR16)); + if (Url =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + AsciiStrToUnicodeStrS (Private->BootFileUri, Url, UrlSize); + + UrlSize =3D AsciiStrSize (Private->ProxyUri); + ProxyUrl =3D AllocatePool (UrlSize * (sizeof (CHAR16))); + if (ProxyUrl =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto EXIT; + } + + AsciiStrToUnicodeStrS (Private->ProxyUri, ProxyUrl, UrlSize); + + // + // Send HTTP request message. + // + + // + // Build HTTP header for the request, 2 headers are needed to send a CON= NECT method: + // Host + // User + // + HttpIoHeader =3D HttpIoCreateHeader (2); + if (HttpIoHeader =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto EXIT; + } + + // + // Add HTTP header field 1: Host (EndPoint URI) + // + HostName =3D NULL; + Status =3D HttpUrlGetHostName ( + Private->BootFileUri, + Private->BootFileUriParser, + &HostName + ); + if (EFI_ERROR (Status)) { + goto EXIT; + } + + Status =3D HttpIoSetHeader ( + HttpIoHeader, + HTTP_HEADER_HOST, + HostName + ); + if (EFI_ERROR (Status)) { + goto EXIT; + } + + // + // Add HTTP header field 2: User-Agent + // + Status =3D HttpIoSetHeader ( + HttpIoHeader, + HTTP_HEADER_USER_AGENT, + HTTP_USER_AGENT_EFI_HTTP_BOOT + ); + if (EFI_ERROR (Status)) { + goto EXIT; + } + + // + // Build the rest of HTTP request info. + // + RequestData =3D AllocatePool (sizeof (EFI_HTTP_REQUEST_DATA)); + if (RequestData =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto EXIT; + } + + RequestData->Method =3D HttpMethodConnect; + RequestData->ProxyUrl =3D ProxyUrl; + RequestData->Url =3D Url; + + // + // Send out the request to HTTP server. + // + HttpIo =3D &Private->HttpIo; + Status =3D HttpIoSendRequest ( + HttpIo, + RequestData, + HttpIoHeader->HeaderCount, + HttpIoHeader->Headers, + 0, + NULL + ); + if (EFI_ERROR (Status)) { + goto EXIT; + } + + // + // Receive HTTP response message. + // + + // + // Use zero BodyLength to only receive the response headers. + // + ResponseData =3D AllocateZeroPool (sizeof (HTTP_IO_RESPONSE_DATA)); + if (ResponseData =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto EXIT; + } + + Status =3D HttpIoRecvResponse ( + &Private->HttpIo, + TRUE, + ResponseData + ); + + if (EFI_ERROR (Status) || EFI_ERROR (ResponseData->Status)) { + if (EFI_ERROR (ResponseData->Status)) { + StatusCode =3D HttpIo->RspToken.Message->Data.Response->StatusCode; + HttpBootPrintErrorMessage (StatusCode); + Status =3D ResponseData->Status; + } + } + +EXIT: + if (ResponseData !=3D NULL) { + FreePool (ResponseData); + } + + if (RequestData !=3D NULL) { + FreePool (RequestData); + } + + HttpIoFreeHeader (HttpIoHeader); + + if (ProxyUrl !=3D NULL) { + FreePool (ProxyUrl); + } + + if (Url !=3D NULL) { + FreePool (Url); + } + + return Status; +} + /** This function download the boot file by using UEFI HTTP protocol. =20 diff --git a/NetworkPkg/HttpBootDxe/HttpBootClient.h b/NetworkPkg/HttpBootD= xe/HttpBootClient.h index 2fba713679..fcd624f536 100644 --- a/NetworkPkg/HttpBootDxe/HttpBootClient.h +++ b/NetworkPkg/HttpBootDxe/HttpBootClient.h @@ -86,6 +86,21 @@ HttpBootCreateHttpIo ( IN HTTP_BOOT_PRIVATE_DATA *Private ); =20 +/** + This function establishes a connection through a proxy server + + @param[in] Private The pointer to the driver's private dat= a. + + @retval EFI_SUCCESS Connection successful. + @retval EFI_OUT_OF_RESOURCES Could not allocate needed resources + @retval Others Unexpected error happened. + +**/ +EFI_STATUS +HttpBootConnectProxy ( + IN HTTP_BOOT_PRIVATE_DATA *Private + ); + /** This function download the boot file by using UEFI HTTP protocol. =20 diff --git a/NetworkPkg/HttpBootDxe/HttpBootImpl.c b/NetworkPkg/HttpBootDxe= /HttpBootImpl.c index 4748de0603..d4a7c8385a 100644 --- a/NetworkPkg/HttpBootDxe/HttpBootImpl.c +++ b/NetworkPkg/HttpBootDxe/HttpBootImpl.c @@ -313,7 +313,11 @@ HttpBootGetBootFileCaller ( EFI_STATUS Status; =20 if (Private->BootFileSize =3D=3D 0) { - State =3D GetBootFileHead; + if (Private->ProxyUri !=3D NULL) { + State =3D ConnectToProxy; + } else { + State =3D GetBootFileHead; + } } else { State =3D LoadBootFile; } @@ -366,6 +370,16 @@ HttpBootGetBootFileCaller ( =20 break; =20 + case ConnectToProxy: + Status =3D HttpBootConnectProxy (Private); + if (Status =3D=3D EFI_SUCCESS) { + State =3D GetBootFileHead; + } else { + State =3D GetBootFileError; + } + + break; + case LoadBootFile: if (*BufferSize < Private->BootFileSize) { *BufferSize =3D Private->BootFileSize; diff --git a/NetworkPkg/HttpBootDxe/HttpBootImpl.h b/NetworkPkg/HttpBootDxe= /HttpBootImpl.h index 33da4fec51..e4ffc3ed48 100644 --- a/NetworkPkg/HttpBootDxe/HttpBootImpl.h +++ b/NetworkPkg/HttpBootDxe/HttpBootImpl.h @@ -14,6 +14,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent typedef enum { GetBootFileHead, GetBootFileGet, + ConnectToProxy, LoadBootFile, GetBootFileError } HTTP_GET_BOOT_FILE_STATE; diff --git a/NetworkPkg/HttpDxe/HttpDriver.h b/NetworkPkg/HttpDxe/HttpDrive= r.h index 01a6bb7f4b..e0917f431e 100644 --- a/NetworkPkg/HttpDxe/HttpDriver.h +++ b/NetworkPkg/HttpDxe/HttpDriver.h @@ -26,6 +26,7 @@ #include #include #include +#include =20 // // UEFI Driver Model Protocols @@ -64,6 +65,7 @@ // Driver Version // #define HTTP_DRIVER_VERSION 0xa +#define URI_STR_MAX_SIZE 255 =20 // // Protocol instances diff --git a/NetworkPkg/HttpDxe/HttpDxe.inf b/NetworkPkg/HttpDxe/HttpDxe.inf index c9502d0bb6..30b7de1951 100644 --- a/NetworkPkg/HttpDxe/HttpDxe.inf +++ b/NetworkPkg/HttpDxe/HttpDxe.inf @@ -47,6 +47,7 @@ NetLib HttpLib DpcLib + PrintLib =20 [Protocols] gEfiHttpServiceBindingProtocolGuid ## BY_START diff --git a/NetworkPkg/HttpDxe/HttpImpl.c b/NetworkPkg/HttpDxe/HttpImpl.c index a761ce3d5d..2a305e0864 100644 --- a/NetworkPkg/HttpDxe/HttpImpl.c +++ b/NetworkPkg/HttpDxe/HttpImpl.c @@ -234,6 +234,7 @@ EfiHttpRequest ( EFI_HTTP_MESSAGE *HttpMsg; EFI_HTTP_REQUEST_DATA *Request; VOID *UrlParser; + VOID *EndPointUrlParser; EFI_STATUS Status; CHAR8 *HostName; UINTN HostNameSize; @@ -247,25 +248,31 @@ EfiHttpRequest ( UINTN UrlLen; CHAR8 *ProxyUrl; UINTN ProxyUrlLen; + CHAR8 *ParseUrl; CHAR16 *HostNameStr; HTTP_TOKEN_WRAP *Wrap; CHAR8 *FileUrl; UINTN RequestMsgSize; EFI_HANDLE ImageHandle; + UINT16 EndPointRemotePort; + CHAR8 *EndPointUrlMsg; =20 // // Initializations // - Url =3D NULL; - ProxyUrl =3D NULL; - UrlParser =3D NULL; - RemotePort =3D 0; - HostName =3D NULL; - RequestMsg =3D NULL; - HostNameStr =3D NULL; - Wrap =3D NULL; - FileUrl =3D NULL; - TlsConfigure =3D FALSE; + Url =3D NULL; + ProxyUrl =3D NULL; + UrlParser =3D NULL; + EndPointUrlParser =3D NULL; + RemotePort =3D 0; + HostName =3D NULL; + RequestMsg =3D NULL; + HostNameStr =3D NULL; + Wrap =3D NULL; + FileUrl =3D NULL; + TlsConfigure =3D FALSE; + EndPointUrlMsg =3D NULL; + EndPointRemotePort =3D 0; =20 if ((This =3D=3D NULL) || (Token =3D=3D NULL)) { return EFI_INVALID_PARAMETER; @@ -279,7 +286,7 @@ EfiHttpRequest ( Request =3D HttpMsg->Data.Request; =20 // - // Only support GET, HEAD, DELETE, PATCH, PUT and POST method in current= implementation. + // Only support GET, HEAD, DELETE, CONNECT, PATCH, PUT and POST method i= n current implementation. // if (Request !=3D NULL) { switch (Request->Method) { @@ -289,6 +296,12 @@ EfiHttpRequest ( case HttpMethodPut: case HttpMethodPost: case HttpMethodPatch: + break; + case HttpMethodConnect: + if (Request->ProxyUrl =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + break; default: return EFI_UNSUPPORTED; @@ -391,10 +404,14 @@ EfiHttpRequest ( } =20 // - // From the information in Url, the HTTP instance will + // From the information in the Urls, the HTTP instance will // be able to determine whether to use http or https. // - HttpInstance->UseHttps =3D IsHttpsUrl (Url); + if (Request->Method =3D=3D HttpMethodConnect) { + HttpInstance->UseHttps =3D IsHttpsUrl (ProxyUrl); + } else { + HttpInstance->UseHttps =3D IsHttpsUrl (Url); + } =20 // // HTTP is disabled, return directly if the URI is not HTTPS. @@ -431,13 +448,26 @@ EfiHttpRequest ( TlsConfigure =3D TRUE; } =20 - UrlParser =3D NULL; - Status =3D HttpParseUrl (Url, (UINT32)AsciiStrLen (Url), FALSE, &UrlPa= rser); + // + // Setup RemoteAddress and RemotePort of HttpInstance. + // + if (Request->Method =3D=3D HttpMethodConnect) { + // Case 1: HTTP Connect request + ParseUrl =3D ProxyUrl; + } else if (HttpInstance->ProxyConnected =3D=3D TRUE) { + // Case 2: Other HTTP request (proxy connected) + ParseUrl =3D HttpInstance->ProxyUrl; + } else { + // Case 3: Other HTTP request (proxy not connected) + ParseUrl =3D Url; + } + + Status =3D HttpParseUrl (ParseUrl, (UINT32)AsciiStrLen (ParseUrl), FAL= SE, &UrlParser); if (EFI_ERROR (Status)) { goto Error1; } =20 - Status =3D HttpUrlGetHostName (Url, UrlParser, &HostName); + Status =3D HttpUrlGetHostName (ParseUrl, UrlParser, &HostName); if (EFI_ERROR (Status)) { goto Error1; } @@ -455,7 +485,7 @@ EfiHttpRequest ( } } =20 - Status =3D HttpUrlGetPort (Url, UrlParser, &RemotePort); + Status =3D HttpUrlGetPort (ParseUrl, UrlParser, &RemotePort); if (EFI_ERROR (Status)) { if (HttpInstance->UseHttps) { RemotePort =3D HTTPS_DEFAULT_PORT; @@ -551,7 +581,7 @@ EfiHttpRequest ( if (!HttpInstance->LocalAddressIsIPv6) { Status =3D NetLibAsciiStrToIp4 (HostName, &HttpInstance->RemoteAddr); } else { - Status =3D HttpUrlGetIp6 (Url, UrlParser, &HttpInstance->RemoteIpv6A= ddr); + Status =3D HttpUrlGetIp6 (ParseUrl, UrlParser, &HttpInstance->Remote= Ipv6Addr); } =20 if (EFI_ERROR (Status)) { @@ -649,27 +679,74 @@ EfiHttpRequest ( // // Create request message. // - FileUrl =3D Url; - if ((Url !=3D NULL) && (*FileUrl !=3D '/')) { + if (Request->Method =3D=3D HttpMethodConnect) { // - // Convert the absolute-URI to the absolute-path + // HTTP Connect shall contain EndPoint host name in URI // - while (*FileUrl !=3D ':') { - FileUrl++; + Status =3D HttpParseUrl (Url, (UINT32)AsciiStrLen (Url), FALSE, &EndPo= intUrlParser); + if (EFI_ERROR (Status)) { + goto Error3; } =20 - if ((*(FileUrl+1) =3D=3D '/') && (*(FileUrl+2) =3D=3D '/')) { - FileUrl +=3D 3; - while (*FileUrl !=3D '/') { - FileUrl++; + Status =3D HttpUrlGetHostName ( + Url, + EndPointUrlParser, + &HttpInstance->EndPointHostName + ); + if (EFI_ERROR (Status)) { + goto Error3; + } + + Status =3D HttpUrlGetPort (Url, EndPointUrlParser, &EndPointRemotePort= ); + if (EFI_ERROR (Status)) { + if (IsHttpsUrl (Url)) { + EndPointRemotePort =3D HTTPS_DEFAULT_PORT; + } else { + EndPointRemotePort =3D HTTP_DEFAULT_PORT; } - } else { - Status =3D EFI_INVALID_PARAMETER; + } + + EndPointUrlMsg =3D AllocateZeroPool (URI_STR_MAX_SIZE); + if (EndPointUrlMsg =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; goto Error3; } - } =20 - Status =3D HttpGenRequestMessage (HttpMsg, FileUrl, &RequestMsg, &Reques= tMsgSize); + AsciiSPrint ( + EndPointUrlMsg, + URI_STR_MAX_SIZE, + "%a:%d", + HttpInstance->EndPointHostName, + EndPointRemotePort + ); + + Status =3D HttpGenRequestMessage (HttpMsg, EndPointUrlMsg, &RequestMsg= , &RequestMsgSize); + + FreePool (EndPointUrlMsg); + HttpUrlFreeParser (EndPointUrlParser); + } else { + FileUrl =3D Url; + if ((Url !=3D NULL) && (*FileUrl !=3D '/')) { + // + // Convert the absolute-URI to the absolute-path + // + while (*FileUrl !=3D ':') { + FileUrl++; + } + + if ((*(FileUrl+1) =3D=3D '/') && (*(FileUrl+2) =3D=3D '/')) { + FileUrl +=3D 3; + while (*FileUrl !=3D '/') { + FileUrl++; + } + } else { + Status =3D EFI_INVALID_PARAMETER; + goto Error3; + } + } + + Status =3D HttpGenRequestMessage (HttpMsg, FileUrl, &RequestMsg, &Requ= estMsgSize); + } =20 if (EFI_ERROR (Status) || (NULL =3D=3D RequestMsg)) { goto Error3; @@ -705,6 +782,10 @@ EfiHttpRequest ( =20 DispatchDpc (); =20 + if (HttpInstance->Method =3D=3D HttpMethodConnect) { + HttpInstance->ProxyConnected =3D TRUE; + } + if (HostName !=3D NULL) { FreePool (HostName); } @@ -750,6 +831,14 @@ Error2: } =20 Error1: + if (EndPointUrlMsg !=3D NULL) { + FreePool (EndPointUrlMsg); + } + + if (EndPointUrlParser !=3D NULL) { + HttpUrlFreeParser (EndPointUrlParser); + } + if (HostName !=3D NULL) { FreePool (HostName); } diff --git a/NetworkPkg/Library/DxeHttpLib/DxeHttpLib.c b/NetworkPkg/Librar= y/DxeHttpLib/DxeHttpLib.c index 6a5d78629b..45087a1935 100644 --- a/NetworkPkg/Library/DxeHttpLib/DxeHttpLib.c +++ b/NetworkPkg/Library/DxeHttpLib/DxeHttpLib.c @@ -1927,6 +1927,11 @@ HttpGenRequestMessage ( CopyMem (RequestPtr, HTTP_METHOD_DELETE, StrLength); RequestPtr +=3D StrLength; break; + case HttpMethodConnect: + StrLength =3D sizeof (HTTP_METHOD_CONNECT) - 1; + CopyMem (RequestPtr, HTTP_METHOD_CONNECT, StrLength); + RequestPtr +=3D StrLength; + break; default: ASSERT (FALSE); Status =3D EFI_INVALID_PARAMETER; --=20 2.36.1.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 (#96921): https://edk2.groups.io/g/devel/message/96921 Mute This Topic: https://groups.io/mt/95413296/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- From nobody Thu Apr 25 16:21:48 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+96922+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+96922+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1670008362; cv=none; d=zohomail.com; s=zohoarc; b=SGTeRYYuhZ9kHIwb8Tf3W9BAX0kTkuU+IRA3KLvnzsYIOgg7BN8RdmjPFShWgRdh2mTfVVMvejsbn7evIyCQx0W3oW8GBfUMsM/xxFEYiJygRrhIvW49SSHaUpEWlN4TP5IyO6VAN6zeLU0nOu3E8BgHLDKYUuzyko+Kad9eAFo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670008362; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=8Am9oDUsMGCXOlPk5Jo7i6TlvxB5GvmkJWymfZKkmHw=; b=KNZHoyg5r+hjC5aWn7PcS+AWcz0EPpNAaxevJ/Zam/r2w8unHa5iTpLdJHl1IfMm6Dm5woQigVUxccTuyQ7joQ5DVMOCDWgUUTNsvLIQ3HKM6wXkMSxKE7oglGNfXfs5RgSRxZqvg2PV6y+l0MDUMGpAwTI3ScsI2D8Vxpez1nI= 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+96922+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 167000836209977.67130978886189; Fri, 2 Dec 2022 11:12:42 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id y23UYY1788612xDq24AJ7Tg1; Fri, 02 Dec 2022 11:12:41 -0800 X-Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mx.groups.io with SMTP id smtpd.web11.84900.1670008354257768666 for ; Fri, 02 Dec 2022 11:12:40 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10549"; a="296382625" X-IronPort-AV: E=Sophos;i="5.96,213,1665471600"; d="scan'208";a="296382625" X-Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2022 11:12:39 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10549"; a="733916713" X-IronPort-AV: E=Sophos;i="5.96,213,1665471600"; d="scan'208";a="733916713" X-Received: from fmbiosdev02.amr.corp.intel.com ([10.80.127.10]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2022 11:12:39 -0800 From: "Saloni Kasbekar" To: devel@edk2.groups.io Cc: Saloni Kasbekar , Maciej Rabeda , Wu Jiaxin , Siyuan Fu Subject: [edk2-devel] [edk2-staging/HttpProxy PATCH v3 6/7] NetworkPkg/HttpDxe: Support HTTPS EndPoint server with Proxy Date: Fri, 2 Dec 2022 11:12:25 -0800 Message-Id: <4f06d6837febe6d4d02c10cf182a7e43275d94c0.1670008048.git.saloni.kasbekar@intel.com> In-Reply-To: References: 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,saloni.kasbekar@intel.com X-Gm-Message-State: LqX3SasisxYcxzpXiGuVXQckx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1670008361; bh=Byn8jHJnnQPwxMIkEm4d/KhBhIpG1azMEFgGNJbPbeI=; h=Cc:Date:From:Reply-To:Subject:To; b=PwsNdtGxhfOkunsVPC9y0Z4zttyKSsUrP3/0MjZImgGNbK4lgkbg+iIH7C4vJ4wptfp PXoNoR7dR8DX17JdG9SJLhQmn8PQPJzM6dUNKLE8LSjhsRGkImfCHi4Y45gDwKUG9VSXy UdUJUVrsRRgGOO2Vex6D2TCv6bieWBUqPRQ= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1670008363660100023 Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3951 Add support for Proxy server to connect to a HTTPS EndPoint server. TLS Connection to be created during GET/HEAD after CONNECT method. Cc: Maciej Rabeda Cc: Wu Jiaxin Cc: Siyuan Fu Signed-off-by: Saloni Kasbekar --- NetworkPkg/HttpDxe/HttpImpl.c | 9 +++---- NetworkPkg/HttpDxe/HttpProto.c | 40 ++++++++++++++++++------------- NetworkPkg/HttpDxe/HttpProto.h | 8 +++++-- NetworkPkg/HttpDxe/HttpsSupport.c | 16 +++++++++---- 4 files changed, 46 insertions(+), 27 deletions(-) diff --git a/NetworkPkg/HttpDxe/HttpImpl.c b/NetworkPkg/HttpDxe/HttpImpl.c index 2a305e0864..f7d6a4c8f6 100644 --- a/NetworkPkg/HttpDxe/HttpImpl.c +++ b/NetworkPkg/HttpDxe/HttpImpl.c @@ -511,9 +511,10 @@ EfiHttpRequest ( if ((HttpInstance->ConnectionClose =3D=3D FALSE) && (HttpInstance->RemotePort =3D=3D RemotePort) && (AsciiStrCmp (HttpInstance->RemoteHost, HostName) =3D=3D 0) && - (!HttpInstance->UseHttps || (HttpInstance->UseHttps && - !TlsConfigure && - (HttpInstance->TlsSessionState =3D= =3D EfiTlsSessionDataTransferring)))) + (!HttpInstance->UseHttps || + HttpInstance->ProxyConnected || (HttpInstance->UseHttps && + !TlsConfigure && + (HttpInstance->TlsSessionState= =3D=3D EfiTlsSessionDataTransferring)))) { // // Host Name and port number of the request URL are the same with = previous call to Request(). @@ -666,7 +667,7 @@ EfiHttpRequest ( goto Error2; } =20 - if (!Configure && !ReConfigure && !TlsConfigure) { + if ((!Configure && !ReConfigure) && ((HttpInstance->ProxyConnected && Tl= sConfigure) || (!TlsConfigure))) { // // For the new HTTP token, create TX TCP token events. // diff --git a/NetworkPkg/HttpDxe/HttpProto.c b/NetworkPkg/HttpDxe/HttpProto.c index 6767d90c7d..cc69401943 100644 --- a/NetworkPkg/HttpDxe/HttpProto.c +++ b/NetworkPkg/HttpDxe/HttpProto.c @@ -1222,6 +1222,7 @@ HttpConfigureTcp6 ( connect one TLS session if required. =20 @param[in] HttpInstance The HTTP instance private data. + @param[in] TlsConfigure The Flag indicates whether it's the new T= ls session. =20 @retval EFI_SUCCESS The TCP connection is established. @retval EFI_NOT_READY TCP4 protocol child is not created or con= figured. @@ -1230,7 +1231,8 @@ HttpConfigureTcp6 ( **/ EFI_STATUS HttpConnectTcp4 ( - IN HTTP_PROTOCOL *HttpInstance + IN HTTP_PROTOCOL *HttpInstance, + IN BOOLEAN TlsConfigure ) { EFI_STATUS Status; @@ -1253,16 +1255,18 @@ HttpConnectTcp4 ( return Status; } =20 - if (Tcp4State =3D=3D Tcp4StateEstablished) { + if ((Tcp4State =3D=3D Tcp4StateEstablished) && (!HttpInstance->ProxyConn= ected || !TlsConfigure)) { return EFI_SUCCESS; - } else if (Tcp4State > Tcp4StateEstablished ) { + } else if (Tcp4State > Tcp4StateEstablished) { HttpCloseConnection (HttpInstance); } =20 - Status =3D HttpCreateConnection (HttpInstance); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "Tcp4 Connection fail - %x\n", Status)); - return Status; + if (!HttpInstance->ProxyConnected) { + Status =3D HttpCreateConnection (HttpInstance); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Tcp4 Connection fail - %x\n", Status)); + return Status; + } } =20 // @@ -1314,6 +1318,7 @@ HttpConnectTcp4 ( connect one TLS session if required. =20 @param[in] HttpInstance The HTTP instance private data. + @param[in] TlsConfigure The Flag indicates whether it's the new T= ls session. =20 @retval EFI_SUCCESS The TCP connection is established. @retval EFI_NOT_READY TCP6 protocol child is not created or con= figured. @@ -1322,7 +1327,8 @@ HttpConnectTcp4 ( **/ EFI_STATUS HttpConnectTcp6 ( - IN HTTP_PROTOCOL *HttpInstance + IN HTTP_PROTOCOL *HttpInstance, + IN BOOLEAN TlsConfigure ) { EFI_STATUS Status; @@ -1346,16 +1352,18 @@ HttpConnectTcp6 ( return Status; } =20 - if (Tcp6State =3D=3D Tcp6StateEstablished) { + if ((Tcp6State =3D=3D Tcp6StateEstablished) && (!HttpInstance->ProxyConn= ected || !TlsConfigure)) { return EFI_SUCCESS; - } else if (Tcp6State > Tcp6StateEstablished ) { + } else if (Tcp6State > Tcp6StateEstablished) { HttpCloseConnection (HttpInstance); } =20 - Status =3D HttpCreateConnection (HttpInstance); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "Tcp6 Connection fail - %x\n", Status)); - return Status; + if (!HttpInstance->ProxyConnected) { + Status =3D HttpCreateConnection (HttpInstance); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Tcp6 Connection fail - %x\n", Status)); + return Status; + } } =20 // @@ -1450,7 +1458,7 @@ HttpInitSession ( // // Connect TCP. // - Status =3D HttpConnectTcp4 (HttpInstance); + Status =3D HttpConnectTcp4 (HttpInstance, TlsConfigure); if (EFI_ERROR (Status)) { return Status; } @@ -1468,7 +1476,7 @@ HttpInitSession ( // // Connect TCP. // - Status =3D HttpConnectTcp6 (HttpInstance); + Status =3D HttpConnectTcp6 (HttpInstance, TlsConfigure); if (EFI_ERROR (Status)) { return Status; } diff --git a/NetworkPkg/HttpDxe/HttpProto.h b/NetworkPkg/HttpDxe/HttpProto.h index 3e4e86dad9..6fd2082e1b 100644 --- a/NetworkPkg/HttpDxe/HttpProto.h +++ b/NetworkPkg/HttpDxe/HttpProto.h @@ -407,6 +407,7 @@ HttpConfigureTcp6 ( connect one TLS session if required. =20 @param[in] HttpInstance The HTTP instance private data. + @param[in] TlsConfigure The Flag indicates whether it's the new T= ls session. =20 @retval EFI_SUCCESS The TCP connection is established. @retval EFI_NOT_READY TCP4 protocol child is not created or con= figured. @@ -415,7 +416,8 @@ HttpConfigureTcp6 ( **/ EFI_STATUS HttpConnectTcp4 ( - IN HTTP_PROTOCOL *HttpInstance + IN HTTP_PROTOCOL *HttpInstance, + IN BOOLEAN TlsConfigure ); =20 /** @@ -423,6 +425,7 @@ HttpConnectTcp4 ( connect one TLS session if required. =20 @param[in] HttpInstance The HTTP instance private data. + @param[in] TlsConfigure The Flag indicates whether it's the new T= ls session. =20 @retval EFI_SUCCESS The TCP connection is established. @retval EFI_NOT_READY TCP6 protocol child is not created or con= figured. @@ -431,7 +434,8 @@ HttpConnectTcp4 ( **/ EFI_STATUS HttpConnectTcp6 ( - IN HTTP_PROTOCOL *HttpInstance + IN HTTP_PROTOCOL *HttpInstance, + IN BOOLEAN TlsConfigure ); =20 /** diff --git a/NetworkPkg/HttpDxe/HttpsSupport.c b/NetworkPkg/HttpDxe/HttpsSu= pport.c index ad611e7c38..81c65758d3 100644 --- a/NetworkPkg/HttpDxe/HttpsSupport.c +++ b/NetworkPkg/HttpDxe/HttpsSupport.c @@ -644,11 +644,17 @@ TlsConfigureSession ( // // TlsConfigData initialization // - HttpInstance->TlsConfigData.ConnectionEnd =3D EfiTlsClient; - HttpInstance->TlsConfigData.VerifyMethod =3D EFI_TLS_VERIFY_PEER; - HttpInstance->TlsConfigData.VerifyHost.Flags =3D EFI_TLS_VERIFY_FLAG_= NONE; - HttpInstance->TlsConfigData.VerifyHost.HostName =3D HttpInstance->Remote= Host; - HttpInstance->TlsConfigData.SessionState =3D EfiTlsSessionNotStar= ted; + HttpInstance->TlsConfigData.ConnectionEnd =3D EfiTlsClient; + HttpInstance->TlsConfigData.VerifyMethod =3D EFI_TLS_VERIFY_PEER; + HttpInstance->TlsConfigData.VerifyHost.Flags =3D EFI_TLS_VERIFY_FLAG_NON= E; + HttpInstance->TlsConfigData.SessionState =3D EfiTlsSessionNotStarted; + + if (HttpInstance->ProxyConnected) { + ASSERT (HttpInstance->EndPointHostName !=3D NULL); + HttpInstance->TlsConfigData.VerifyHost.HostName =3D HttpInstance->EndP= ointHostName; + } else { + HttpInstance->TlsConfigData.VerifyHost.HostName =3D HttpInstance->Remo= teHost; + } =20 // // EfiTlsConnectionEnd, --=20 2.36.1.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 (#96922): https://edk2.groups.io/g/devel/message/96922 Mute This Topic: https://groups.io/mt/95413297/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- From nobody Thu Apr 25 16:21:48 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+96923+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+96923+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1670008363; cv=none; d=zohomail.com; s=zohoarc; b=FwRV87JZRj+xssA5YXMPcz91y26ZHd2gOdGGt4YA2fWwBEqC8l3dNQQDIkopA0woTugJuRVXk2twcx5mdLIO54Ru7lAJ4b/U8xJeuGKM1szFmFyHOEWFT2oRRLAqn1MiWwH6KJhD1Polk+hCMtyNNxW/XeIeYxvxNb6AzjZ0eRc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670008363; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=XqgNFL46VkT7p51Omx6IfAovZpyI6SPKFomGuAfDQkc=; b=lY/+8VlDk70PiVPfjmndP9cDNZSPVJbFJos6LyfDDiawwYou5wxHE9cJsV023FiPzW9Aw72GWhhHW8yYMeiM1M0qGGwQBw8pZ964cdwhpYIjUxC9SkG9i09esyVtPu4ufr/+QFVrzWKM/nQrBOKHuGc1sWcc413/iMFAEiBeTZk= 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+96923+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 1670008363245302.08954728137553; Fri, 2 Dec 2022 11:12:43 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 0iFuYY1788612xnvcGx1umnE; Fri, 02 Dec 2022 11:12:42 -0800 X-Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mx.groups.io with SMTP id smtpd.web11.84900.1670008354257768666 for ; Fri, 02 Dec 2022 11:12:42 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10549"; a="296382637" X-IronPort-AV: E=Sophos;i="5.96,213,1665471600"; d="scan'208";a="296382637" X-Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2022 11:12:40 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10549"; a="733916728" X-IronPort-AV: E=Sophos;i="5.96,213,1665471600"; d="scan'208";a="733916728" X-Received: from fmbiosdev02.amr.corp.intel.com ([10.80.127.10]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2022 11:12:40 -0800 From: "Saloni Kasbekar" To: devel@edk2.groups.io Cc: Saloni Kasbekar , Maciej Rabeda , Wu Jiaxin , Siyuan Fu Subject: [edk2-devel] [edk2-staging/HttpProxy PATCH v3 7/7] NetworkPkg/HttpBootDxe: Add Proxy URI input in setup menu Date: Fri, 2 Dec 2022 11:12:26 -0800 Message-Id: <14497137c1d8f0a847047080bd9f5e922f780ffa.1670008048.git.saloni.kasbekar@intel.com> In-Reply-To: References: 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,saloni.kasbekar@intel.com X-Gm-Message-State: kcE3T6GufI13vDW6oaSHjSPvx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1670008362; bh=PUTNK0RM/50ZNSx3PcBE7c4xMSQ/wf89s5UrSjk/Tok=; h=Cc:Date:From:Reply-To:Subject:To; b=R2V5JhA+Yh+VkkGvNpA2X6T5snc0IzZtAKrxq3Pjgw5diRyPhyybEYL9EH+vyP6RlXO R4xw9BPH2I8Uxk3v95vgRrG46/3xcQrlL163Gm/zjJtY+pKGwVAaeW2fQi70xe+YU717v ILRDiwTA3pKsPov1OknvaeOIscwiim9bieM= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1670008363668100026 Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3951 Allows users to input the Proxy Server URI in the HTTP setup menu Cc: Maciej Rabeda Cc: Wu Jiaxin Cc: Siyuan Fu Signed-off-by: Saloni Kasbekar --- NetworkPkg/HttpBootDxe/HttpBootConfig.c | 99 ++++++++++++++----- .../HttpBootDxe/HttpBootConfigNVDataStruc.h | 4 +- .../HttpBootDxe/HttpBootConfigStrings.uni | 2 + NetworkPkg/HttpBootDxe/HttpBootConfigVfr.vfr | 9 ++ 4 files changed, 88 insertions(+), 26 deletions(-) diff --git a/NetworkPkg/HttpBootDxe/HttpBootConfig.c b/NetworkPkg/HttpBootD= xe/HttpBootConfig.c index 42d3fdc1fb..2cdd5043fe 100644 --- a/NetworkPkg/HttpBootDxe/HttpBootConfig.c +++ b/NetworkPkg/HttpBootDxe/HttpBootConfig.c @@ -18,6 +18,7 @@ CHAR16 mHttpBootConfigStorageName[] =3D L"HTTP_BOOT_CONF= IG_IFR_NVDATA"; @param[in] UsingIpv6 Set to TRUE if creating boot option for = IPv6. @param[in] Description The description text of the boot option. @param[in] Uri The URI string of the boot file. + @param[in] ProxyUri The Proxy URI string for the boot path. =20 @retval EFI_SUCCESS The boot option is created successfully. @retval Others Failed to create new boot option. @@ -28,48 +29,59 @@ HttpBootAddBootOption ( IN HTTP_BOOT_PRIVATE_DATA *Private, IN BOOLEAN UsingIpv6, IN CHAR16 *Description, - IN CHAR16 *Uri + IN CHAR16 *Uri, + IN CHAR16 *ProxyUri ) { EFI_DEV_PATH *Node; EFI_DEVICE_PATH_PROTOCOL *TmpDevicePath; EFI_DEVICE_PATH_PROTOCOL *NewDevicePath; + EFI_DEVICE_PATH_PROTOCOL *FinalDevicePath; UINTN Length; CHAR8 AsciiUri[URI_STR_MAX_SIZE]; + CHAR8 AsciiProxyUri[URI_STR_MAX_SIZE]; + UINTN AsciiProxyUriSize; EFI_STATUS Status; - UINTN Index; EFI_BOOT_MANAGER_LOAD_OPTION NewOption; =20 - NewDevicePath =3D NULL; - Node =3D NULL; - TmpDevicePath =3D NULL; + NewDevicePath =3D NULL; + Node =3D NULL; + TmpDevicePath =3D NULL; + FinalDevicePath =3D NULL; =20 if (StrLen (Description) =3D=3D 0) { return EFI_INVALID_PARAMETER; } =20 // - // Convert the scheme to all lower case. + // Check the URI Scheme // - for (Index =3D 0; Index < StrLen (Uri); Index++) { - if (Uri[Index] =3D=3D L':') { - break; + UnicodeStrToAsciiStrS (Uri, AsciiUri, sizeof (AsciiUri)); + UnicodeStrToAsciiStrS (ProxyUri, AsciiProxyUri, sizeof (AsciiProxyUri)); + Status =3D HttpBootCheckUriScheme (AsciiUri); + if (EFI_ERROR (Status)) { + if (Status =3D=3D EFI_INVALID_PARAMETER) { + DEBUG ((DEBUG_ERROR, "Error: Invalid URI address.\n")); + } else if (Status =3D=3D EFI_ACCESS_DENIED) { + DEBUG ((DEBUG_ERROR, "Error: Access forbidden, only HTTPS connection= is allowed.\n")); } =20 - if ((Uri[Index] >=3D L'A') && (Uri[Index] <=3D L'Z')) { - Uri[Index] -=3D (CHAR16)(L'A' - L'a'); - } + return Status; } =20 - // - // Only accept empty URI, or http and https URI. - // - if ((StrLen (Uri) !=3D 0) && (StrnCmp (Uri, L"http://", 7) !=3D 0) && (S= trnCmp (Uri, L"https://", 8) !=3D 0)) { - return EFI_INVALID_PARAMETER; + Status =3D HttpBootCheckUriScheme (AsciiProxyUri); + if (EFI_ERROR (Status)) { + if (Status =3D=3D EFI_INVALID_PARAMETER) { + DEBUG ((DEBUG_ERROR, "Error: Invalid URI address.\n")); + } else if (Status =3D=3D EFI_ACCESS_DENIED) { + DEBUG ((DEBUG_ERROR, "Error: Access forbidden, only HTTPS connection= is allowed.\n")); + } + + return Status; } =20 // - // Create a new device path by appending the IP node and URI node to + // Create a new device path by appending the IP node, Proxy node and URI= node to // the driver's parent device path // if (!UsingIpv6) { @@ -100,15 +112,43 @@ HttpBootAddBootOption ( return EFI_OUT_OF_RESOURCES; } =20 + // + // Update the Proxy node with the input Proxy URI + // + if (StrLen (ProxyUri) !=3D 0) { + AsciiProxyUriSize =3D AsciiStrSize (AsciiProxyUri); + Length =3D sizeof (EFI_DEVICE_PATH_PROTOCOL) + AsciiProxyUr= iSize; + Node =3D AllocatePool (Length); + if (Node =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto ON_EXIT; + } + + Node->DevPath.Type =3D MESSAGING_DEVICE_PATH; + Node->DevPath.SubType =3D MSG_URI_DP; + SetDevicePathNodeLength (Node, Length); + CopyMem ( + (UINT8 *)Node + sizeof (EFI_DEVICE_PATH_PROTOCOL), + AsciiProxyUri, + AsciiProxyUriSize + ); + NewDevicePath =3D AppendDevicePathNode (TmpDevicePath, (EFI_DEVICE_PAT= H_PROTOCOL *)Node); + FreePool (Node); + if (NewDevicePath =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto ON_EXIT; + } + } else { + NewDevicePath =3D TmpDevicePath; + } + // // Update the URI node with the input boot file URI. // - UnicodeStrToAsciiStrS (Uri, AsciiUri, sizeof (AsciiUri)); Length =3D sizeof (EFI_DEVICE_PATH_PROTOCOL) + AsciiStrSize (AsciiUri); Node =3D AllocatePool (Length); if (Node =3D=3D NULL) { Status =3D EFI_OUT_OF_RESOURCES; - FreePool (TmpDevicePath); goto ON_EXIT; } =20 @@ -116,10 +156,9 @@ HttpBootAddBootOption ( Node->DevPath.SubType =3D MSG_URI_DP; SetDevicePathNodeLength (Node, Length); CopyMem ((UINT8 *)Node + sizeof (EFI_DEVICE_PATH_PROTOCOL), AsciiUri, As= ciiStrSize (AsciiUri)); - NewDevicePath =3D AppendDevicePathNode (TmpDevicePath, (EFI_DEVICE_PATH_= PROTOCOL *)Node); + FinalDevicePath =3D AppendDevicePathNode (NewDevicePath, (EFI_DEVICE_PAT= H_PROTOCOL *)Node); FreePool (Node); - FreePool (TmpDevicePath); - if (NewDevicePath =3D=3D NULL) { + if (FinalDevicePath =3D=3D NULL) { Status =3D EFI_OUT_OF_RESOURCES; goto ON_EXIT; } @@ -133,7 +172,7 @@ HttpBootAddBootOption ( LoadOptionTypeBoot, LOAD_OPTION_ACTIVE, Description, - NewDevicePath, + FinalDevicePath, NULL, 0 ); @@ -146,10 +185,18 @@ HttpBootAddBootOption ( =20 ON_EXIT: =20 + if (TmpDevicePath !=3D NULL) { + FreePool (TmpDevicePath); + } + if (NewDevicePath !=3D NULL) { FreePool (NewDevicePath); } =20 + if (FinalDevicePath !=3D NULL) { + FreePool (FinalDevicePath); + } + return Status; } =20 @@ -406,7 +453,8 @@ HttpBootFormRouteConfig ( Private, (CallbackInfo->HttpBootNvData.IpVersion =3D=3D HTTP_BOOT_IP_VERSION_6)= ? TRUE : FALSE, CallbackInfo->HttpBootNvData.Description, - CallbackInfo->HttpBootNvData.Uri + CallbackInfo->HttpBootNvData.Uri, + CallbackInfo->HttpBootNvData.ProxyUri ); =20 return EFI_SUCCESS; @@ -472,6 +520,7 @@ HttpBootFormCallback ( =20 switch (QuestionId) { case KEY_INITIATOR_URI: + case KEY_INITIATOR_PROXY_URI: // // Get user input URI string // diff --git a/NetworkPkg/HttpBootDxe/HttpBootConfigNVDataStruc.h b/NetworkPk= g/HttpBootDxe/HttpBootConfigNVDataStruc.h index a24fa5cb08..f0da21e8fd 100644 --- a/NetworkPkg/HttpBootDxe/HttpBootConfigNVDataStruc.h +++ b/NetworkPkg/HttpBootDxe/HttpBootConfigNVDataStruc.h @@ -27,7 +27,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent =20 #define FORMID_MAIN_FORM 1 =20 -#define KEY_INITIATOR_URI 0x101 +#define KEY_INITIATOR_URI 0x101 +#define KEY_INITIATOR_PROXY_URI 0x102 =20 #define HTTP_BOOT_DEFAULT_DESCRIPTION_STR L"UEFI HTTP" =20 @@ -37,6 +38,7 @@ typedef struct _HTTP_BOOT_CONFIG_IFR_NVDATA { UINT8 Padding; CHAR16 Description[DESCRIPTION_STR_MAX_SIZE]; CHAR16 Uri[URI_STR_MAX_SIZE]; + CHAR16 ProxyUri[URI_STR_MAX_SIZE]; } HTTP_BOOT_CONFIG_IFR_NVDATA; #pragma pack() =20 diff --git a/NetworkPkg/HttpBootDxe/HttpBootConfigStrings.uni b/NetworkPkg/= HttpBootDxe/HttpBootConfigStrings.uni index 40abb13d0d..28af02bc14 100644 --- a/NetworkPkg/HttpBootDxe/HttpBootConfigStrings.uni +++ b/NetworkPkg/HttpBootDxe/HttpBootConfigStrings.uni @@ -18,4 +18,6 @@ #string STR_BOOT_URI_PROMPT #language en-US "Boot URI" #string STR_BOOT_URI_HELP #language en-US "A new Boot = Option will be created according to this Boot URI." #string STR_BOOT_DESCRIPTION_PROMPT #language en-US "Input the d= escription" +#string STR_BOOT_PROXY_URI_PROMPT #language en-US "Proxy URI" +#string STR_BOOT_PROXY_URI_HELP #language en-US "Proxy URI t= hrough which to connect to Boot URI" #string STR_NULL_STRING #language en-US "" diff --git a/NetworkPkg/HttpBootDxe/HttpBootConfigVfr.vfr b/NetworkPkg/Http= BootDxe/HttpBootConfigVfr.vfr index 65a60216bc..6a23e57d6b 100644 --- a/NetworkPkg/HttpBootDxe/HttpBootConfigVfr.vfr +++ b/NetworkPkg/HttpBootDxe/HttpBootConfigVfr.vfr @@ -44,6 +44,15 @@ formset minsize =3D URI_STR_MIN_SIZE, maxsize =3D URI_STR_MAX_SIZE, endstring; + + string varid =3D HTTP_BOOT_CONFIG_IFR_NVDATA.ProxyUri, + prompt =3D STRING_TOKEN(STR_BOOT_PROXY_URI_PROMPT), + help =3D STRING_TOKEN(STR_BOOT_PROXY_URI_HELP), + flags =3D INTERACTIVE, + key =3D KEY_INITIATOR_PROXY_URI, + minsize =3D URI_STR_MIN_SIZE, + maxsize =3D URI_STR_MAX_SIZE, + endstring; endform; =20 endformset; --=20 2.36.1.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 (#96923): https://edk2.groups.io/g/devel/message/96923 Mute This Topic: https://groups.io/mt/95413298/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-