From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 7E310941611 for ; Thu, 22 Feb 2024 09:16:31 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=NBH8nCC/1jIfpw0FyZ8jK18Wh1Z0ed5Tbc4EGSEH7Gs=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:From:To:CC:Subject:Thread-Topic:Thread-Index:Date:Message-ID:References:In-Reply-To:Accept-Language:msip_labels:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1708593390; v=1; b=jXy+D9RGasqAaPYf4B4wp1q+5myLu6n9oiBqhF0sXAIZAAZJ9CkeBcDcbpjox19p8O8lkLER 6iixVmzG6XS3Y0i0mM1onCjjxRl4aNaiPiVmfF1cOcnkftimOrQMGZrrZJTMOl4cj0C8ywzHs7M rLwgb44ecbsj7cnISEt82N+E= X-Received: by 127.0.0.2 with SMTP id D9IyYY7687511xZG6QE3eo2q; Thu, 22 Feb 2024 01:16:30 -0800 X-Received: from NAM11-CO1-obe.outbound.protection.outlook.com (NAM11-CO1-obe.outbound.protection.outlook.com [40.107.220.41]) by mx.groups.io with SMTP id smtpd.web11.9104.1708593389417948798 for ; Thu, 22 Feb 2024 01:16:29 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FYfOvik8Yn9qvvjmx0PSw8R3dN8+dl9PsdBv5KoFnHkOmeZJBGSfFgLSgjVpTd/iGKuVztR51Ni5VTR96f+sJ7Ukn//2cEAM4iXtjh4nigUvhvga/EXAsFP7jkT6SN/SMd/OruSyceJWXvPFKt/YaD9+aXLW5PeBvGck3epC6DzUfGouhpw4dxc5CIUTy/OCrvhp5/35YIn/JeJcAxvyAmjmIRdRxv0SOla8zqz0wMohF6Oldu1wHehRM0E16EHxZ8hH1D4xdTpiCtpVoGn3DAf7+D8UGU/gVsuu0d4NWj9Y6KiipN4G0kstR3xWE1VDwuNoqDZrWbSQmo3ELUFtZQ== 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=CFULYPcYVPoZOZN8yhN6srL9mLfWt/NDUd9MTgLxioY=; b=ZJlw34qEfOHoP+VoAo2BHUjhkwsaaX3Bj3ImFqhEZKTD7AfxNdaa5xRw9qYivrqqR7GACUQGUQsGCbvVGvee4ao3H8hiLANyiDyDYA9lHitnj2X3tmTPdM7u4vdsZhCFTsCr6wVtd7YQ8+2Uo5vkOTLOQlnZHa8Ohvdd6Kl+cSFViAZtDlvEo6472mb7kdHP1VSLTQ48mJokOy1HYxF/S8F7sGqPfTFX1AuGjdpvgEeszxiGczH5CzeWMVxnJinJWuz9nNICsMdWpu1TbprSWC7gH4bGbA+S7eJlWNJL7BydY+27WoZHbHY+HMmZghKjayqU/GtTOTzzz0xgXAX7xQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none X-Received: from MW4PR12MB7031.namprd12.prod.outlook.com (2603:10b6:303:1ef::6) by MW3PR12MB4521.namprd12.prod.outlook.com (2603:10b6:303:53::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.24; Thu, 22 Feb 2024 09:16:25 +0000 X-Received: from MW4PR12MB7031.namprd12.prod.outlook.com ([fe80::aa79:3ab0:fbcd:d61b]) by MW4PR12MB7031.namprd12.prod.outlook.com ([fe80::aa79:3ab0:fbcd:d61b%5]) with mapi id 15.20.7316.018; Thu, 22 Feb 2024 09:16:25 +0000 From: "Nickle Wang via groups.io" To: "Chang, Abner" , "devel@edk2.groups.io" CC: Igor Kulchytskyy , Nick Ramirez Subject: Re: [edk2-devel] [PATCH 2/6] RedfishPkg: implement Redfish HTTP protocol Thread-Topic: [PATCH 2/6] RedfishPkg: implement Redfish HTTP protocol Thread-Index: AQHaY8fcdZtP35PvAkqWBUFcjPzZEbEUBwKQgAIQ8PA= Date: Thu, 22 Feb 2024 09:16:25 +0000 Message-ID: References: <20240220064123.28359-1-nicklew@nvidia.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ActionId=abc1970f-682d-4a32-b23a-6e432c48d2d9;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ContentBits=0;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Enabled=true;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Method=Standard;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Name=General;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SetDate=2024-02-21T01:42:53Z;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SiteId=3dd8961f-e488-4e60-8e11-a82d994e183d; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MW4PR12MB7031:EE_|MW3PR12MB4521:EE_ x-ms-office365-filtering-correlation-id: de8570c9-b0b3-4d1d-e920-08dc3386f1ef x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: pX1lVPRqjPmy0TBH/TMCNtjsv4IZTrJzlF4qZAkRRRWJ+C7ZlA1DgTDXjOXEhVHxC6rZtQsX9pt8piGUvEIusc5phZeurDVE2kl6icqrFCnf/nThx+3l87KhW/nYV2mr/NChKTdVttxVF/x02i/8TLUzD51p6DllorpGpvXPmwu/m5pzCNtnGVyz+YBvGQPbbUJ/M/GVNcb2ulAXOI+aOH3Pa1P3GxrgSHkWER+pHgCfdUMNTCfS0j9LNQD31+OhdJxP7TSm3rrYQ3pq/bO0i9nymorzjPebwHJqM0xzN2t8dC+mC1Oe4Orhvf8EuOld0NWuyrYjoLBUxmvNdHV/Ts9HJ1OfUlbeEUWjYuOFlxG+zP5tAQ362ON/PoK7VY5UYPJZFgcC/mtoTSoVvUJe5oXWGfLfaZwH/zfBvyL0VCeiCr+JhkZPZ9vtlmE58N08ftnUYjvNN0FsJlRIvuDkZgr1643/lhefRLIOpjUoPx7Usct2rwJFU/AP6McykZGVZP7OrkDkfjwhSaAqqdYy894C5NlPMLiY9+XoZ7YMOGQRQkoiSVwmqCjkz/ZEN9YOYHVc/TNLO4vYyNooTx1CGHR6SSWzEKJL52cs07gHtR8= x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?Q7Ot9H+QrHnH3oqmP7xnN9DnAqbHfphBzGlFlu3/uxoUega3Fg1NMxR3SFDr?= =?us-ascii?Q?JHOEAQBaoaR1rf5t2MVk4Om8aRFZcyuzxf5qptUPNHuE+/WOk5Vv+yGAMQub?= =?us-ascii?Q?eP1D1dvf+PJR8QUv5+4QI97CywQz1gg9WHKnzHcZYr1QijYtdaPXPjGPk/tJ?= =?us-ascii?Q?H/Xbi8CNHLgtcOz1HZsogWPzcGzRqQHonzFI+KeykWMEHE52dlbtSpdWTinL?= =?us-ascii?Q?3CDa2NhEeg/nYYwathcEC7Wy4isHLj/zZNNrrOtO39nyGLWXFGRm5Ij2/XLD?= =?us-ascii?Q?S0EpGgltBlHac+Ea1dakrYe4UaBD/Zv56tsh6D3QPiQX6d75QcK3dTYbhfN9?= =?us-ascii?Q?6rJM2jL7cfPQWXx8pzdwdpBYujS1O63tJBicwqRbxHCkZuIJ/LGENGbS4t4o?= =?us-ascii?Q?7gw+w0TtHijjvtYyYcp1Vw+q+R4OYHry7W0bbN1AR2aL+TLiJzvtBhDy7Syy?= =?us-ascii?Q?a+hRAhg3az17qRGPIzOyW9kl3v8hr9SLReOkt28uyYRCvvFQwOfOowGE9fLH?= =?us-ascii?Q?rs0fZ7TxpFUwm0qTLkv2wmaA/N9VJl2WY1Wirsu57ZWPS9ZkPcAPVXM7wra8?= =?us-ascii?Q?TbAnwrA+tzkpbKWrx+1l019ZjHaGKD/n1C8xH5Cpwx0fB/mzpjOj37QbFj7H?= =?us-ascii?Q?9GGmrcHjnAbZT7sjRPlZZXnONhFGCA6KA5mxtSJD9gjBsMOhyzPC99fKBFGo?= =?us-ascii?Q?GWkX/+onmq8imCnrNvCVIzZR1Thm/Ls30W8n3sHGuEOZ9y/Q4G5y4mgUIsjS?= =?us-ascii?Q?/QjNtoHTtu1Pbk9csTIMGCrNkOnSS+JHqA11WodH7fuCZtu1cc4Aan/d9D59?= =?us-ascii?Q?7pe0znCtlFSEcFYmLF8BSUI+Ab3fzlMcJ9mbOKpjNDXfb+5WacctaLHOORK0?= =?us-ascii?Q?w19N7afd6mBzCnJOe6SLfYsbw+KFSC5sIxGX8x9G+1R5Ayq0vPQR7LuIXNhR?= =?us-ascii?Q?r1sn5l2NrIzSgKYIiwHmN3ATzNw/NO+2kvSdRVj6RpZlbHdLlhWtHve6xSrj?= =?us-ascii?Q?OW3qv2nUmiLYdvGv5kdu8bn3wKRNMd6ofpYgvV4nUEXq4PDCxOX5/Jb7cgN2?= =?us-ascii?Q?ASEenCZgxH5MwhuwsRmPQgHE5hR8PyLdPWULANxDKyIgT4JXKwToiSigy2p5?= =?us-ascii?Q?5X076ZsfTghl2g9FDtotmzA99dwtS2eDxS43aeovgNFqHBeOUK+in+ogcdNI?= =?us-ascii?Q?kHIBOLaxBeVq3KVg3YNhv7Xxz6cYCcoPFU8B8oMskHHTNyoKE/4PMTr7z6Yy?= =?us-ascii?Q?MItta3CWMhslVo59k4ZmmLtQyBhD+LCiyRAsCQHG5ErcGpUFFeO7qMaT3GBj?= =?us-ascii?Q?AGURl2IZwfh6+2gKJvW5pl4nfpX4zvZkQGOvzlVgmHHtotBgR2AUQHEvP5q1?= =?us-ascii?Q?nTW6xVfLhG7j6SdqpSsgAipFFkFW54tJcABhEnSOkImxg+p1M32ASl1YhsPH?= =?us-ascii?Q?RV97Mky3i4BG9MvYXJmYyrgqmgAn1rsTcmOos1vYMmX9DGYm3Hujl+qElk1L?= =?us-ascii?Q?2BJ/QlHp+DrkD/HDZyeUPtqWfBu3E6kNlLiJ5jEqHVPm5QW2c+4j3n/qoCwU?= =?us-ascii?Q?OLiXSmBXHeLYXaQaataaPKTP3Hg+Ygyh1a7vbWFD9X+FVx6LvIC7yLPcGPi7?= =?us-ascii?Q?C0J3P7ujmb92RX6GtYFL0DQgK0ddljRBljiHJ+vhSdDb?= MIME-Version: 1.0 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW4PR12MB7031.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: de8570c9-b0b3-4d1d-e920-08dc3386f1ef X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Feb 2024 09:16:25.6878 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: J1JfmtpT3JjvoX7jWjdz75bTCSPCj4kmc9PYazwcaRym/zejjDokFU0ObYwwqQywYEUHN2tnzSbDcrO39eJtpw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4521 Precedence: Bulk 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,nicklew@nvidia.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: TnBvPiZLb412EHZrrme2usMwx7686176AA= Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Spam-Flag: yes X-Spam-Level: ************ X-GND-Spam-Score: 190 X-GND-Status: SPAM Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=jXy+D9RG; dmarc=pass (policy=none) header.from=groups.io; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io Thanks for catching this typo, Abner. Version 2 patch is sent. Regards, Nickle > -----Original Message----- > From: Chang, Abner > Sent: Wednesday, February 21, 2024 9:52 AM > To: Nickle Wang ; devel@edk2.groups.io > Cc: Igor Kulchytskyy ; Nick Ramirez > Subject: RE: [PATCH 2/6] RedfishPkg: implement Redfish HTTP protocol > > External email: Use caution opening links or attachments > > > [AMD Official Use Only - General] > > One comment below. > > > -----Original Message----- > > From: Nickle Wang > > Sent: Tuesday, February 20, 2024 2:41 PM > > To: devel@edk2.groups.io > > Cc: Igor Kulchytskyy ; Chang, Abner > > ; Nick Ramirez > > Subject: [PATCH 2/6] RedfishPkg: implement Redfish HTTP protocol > > > > Caution: This message originated from an External Source. Use proper ca= ution > > when opening attachments, clicking links, or responding. > > > > > > implement Redfish HTTP protocol driver. > > > > Signed-off-by: Nickle Wang > > Co-authored-by: Igor Kulchytskyy > > Cc: Abner Chang > > Cc: Igor Kulchytskyy > > Cc: Nick Ramirez > > --- > > RedfishPkg/RedfishPkg.dec | 7 +- > > RedfishPkg/RedfishComponents.dsc.inc | 3 +- > > RedfishPkg/RedfishPkg.dsc | 2 + > > RedfishPkg/RedfishHttpDxe/RedfishHttpDxe.inf | 73 + > > RedfishPkg/RedfishHttpDxe/RedfishHttpData.h | 256 ++++ > > RedfishPkg/RedfishHttpDxe/RedfishHttpDxe.h | 44 + > > .../RedfishHttpDxe/RedfishHttpOperation.h | 76 + > > RedfishPkg/RedfishHttpDxe/RedfishHttpData.c | 667 ++++++++ > > RedfishPkg/RedfishHttpDxe/RedfishHttpDxe.c | 1344 > > +++++++++++++++++ > > .../RedfishHttpDxe/RedfishHttpOperation.c | 693 +++++++++ > > RedfishPkg/Redfish.fdf.inc | 3 +- > > 11 files changed, 3164 insertions(+), 4 deletions(-) > > create mode 100644 RedfishPkg/RedfishHttpDxe/RedfishHttpDxe.inf > > create mode 100644 RedfishPkg/RedfishHttpDxe/RedfishHttpData.h > > create mode 100644 RedfishPkg/RedfishHttpDxe/RedfishHttpDxe.h > > create mode 100644 RedfishPkg/RedfishHttpDxe/RedfishHttpOperation.h > > create mode 100644 RedfishPkg/RedfishHttpDxe/RedfishHttpData.c > > create mode 100644 RedfishPkg/RedfishHttpDxe/RedfishHttpDxe.c > > create mode 100644 RedfishPkg/RedfishHttpDxe/RedfishHttpOperation.c > > > > diff --git a/RedfishPkg/RedfishPkg.dec b/RedfishPkg/RedfishPkg.dec > > index 9b424efdf3..114f8d2ad8 100644 > > --- a/RedfishPkg/RedfishPkg.dec > > +++ b/RedfishPkg/RedfishPkg.dec > > @@ -157,8 +157,11 @@ > > # set to EFI_REST_EX_PROTOCOL. > > # > > > > gEfiRedfishPkgTokenSpaceGuid.PcdRedfishSendReceiveTimeout|5000|UINT3 > > 2|0x00001009 > > - ## This is used to enable HTTP content encoding on Redfish communica= tion. > > - > > gEfiRedfishPkgTokenSpaceGuid.PcdRedfishServiceContentEncoding|TRUE|BO > > OLEAN|0x0000100A > > + # > > + # This PCD string is introduced for platform developer to set the en= coding > > method supported by BMC Redfish. > > + # Currently only "None" and "gzip" are supported. > > + # > > + > > gEfiRedfishPkgTokenSpaceGuid.PcdRedfishServiceContentEncoding|"None"|V > > OID*|0x0000100A > > # > > # Use below PCDs to control Redfhs HTTP protocol. > > # > > diff --git a/RedfishPkg/RedfishComponents.dsc.inc > > b/RedfishPkg/RedfishComponents.dsc.inc > > index 464ffc8606..d6c5b73d7f 100644 > > --- a/RedfishPkg/RedfishComponents.dsc.inc > > +++ b/RedfishPkg/RedfishComponents.dsc.inc > > @@ -7,7 +7,7 @@ > > # "RedfishDefines.dsc.inc". > > # > > # (C) Copyright 2020-2021 Hewlett Packard Enterprise Development LP > > -# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights > > reserved. > > +# Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights > > reserved. > > # > > # SPDX-License-Identifier: BSD-2-Clause-Patent > > # > > @@ -28,4 +28,5 @@ > > RedfishPkg/RedfishConfigHandler/RedfishConfigHandlerDriver.inf > > RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.inf > > MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.inf > > + RedfishPkg/RedfishHttpDxe/RedfishHttpDxe.inf > > !endif > > diff --git a/RedfishPkg/RedfishPkg.dsc b/RedfishPkg/RedfishPkg.dsc > > index 25ed193182..5849e7cf9e 100644 > > --- a/RedfishPkg/RedfishPkg.dsc > > +++ b/RedfishPkg/RedfishPkg.dsc > > @@ -45,6 +45,8 @@ > > > > UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServi= cesL > > ib.inf > > > > RedfishPlatformCredentialLib|RedfishPkg/Library/PlatformCredentialLibNu= ll/ > > PlatformCredentialLibNull.inf > > > > RedfishContentCodingLib|RedfishPkg/Library/RedfishContentCodingLibNull/ > > RedfishContentCodingLibNull.inf > > + > > ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeR > > eportStatusCodeLib.inf > > + SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf > > > > # NULL instance of IPMI related library. > > IpmiLib|MdeModulePkg/Library/BaseIpmiLibNull/BaseIpmiLibNull.inf > > diff --git a/RedfishPkg/RedfishHttpDxe/RedfishHttpDxe.inf > > b/RedfishPkg/RedfishHttpDxe/RedfishHttpDxe.inf > > new file mode 100644 > > index 0000000000..c7dfdffacf > > --- /dev/null > > +++ b/RedfishPkg/RedfishHttpDxe/RedfishHttpDxe.inf > > @@ -0,0 +1,73 @@ > > +## @file > > +# RedfishHttpDxe is the DXE driver which provides > > +# EdkIIRedfishHttpProtocol to EDK2 Redfish Feature > > +# drivers for HTTP operation. > > +# > > +# Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All right= s > > reserved. > > +# > > +# SPDX-License-Identifier: BSD-2-Clause-Patent > > +# > > +## > > + > > +[Defines] > > + INF_VERSION =3D 0x0001000b > > + BASE_NAME =3D RedfishHttpDxe > > + FILE_GUID =3D 85ADB2F1-DA93-47D4-AF4F-3D920D9BD= 2C0 > > + MODULE_TYPE =3D DXE_DRIVER > > + VERSION_STRING =3D 1.0 > > + ENTRY_POINT =3D RedfishHttpEntryPoint > > + UNLOAD_IMAGE =3D RedfishHttpDriverUnload > > + > > +# > > +# VALID_ARCHITECTURES =3D IA32 X64 ARM AARCH64 RISCV64 > > +# > > + > > +[Sources] > > + RedfishHttpData.c > > + RedfishHttpData.h > > + RedfishHttpDxe.c > > + RedfishHttpDxe.h > > + RedfishHttpOperation.c > > + RedfishHttpOperation.h > > + > > +[Packages] > > + MdePkg/MdePkg.dec > > + MdeModulePkg/MdeModulePkg.dec > > + NetworkPkg/NetworkPkg.dec > > + RedfishPkg/RedfishPkg.dec > > + > > +[LibraryClasses.ARM] > > + ArmSoftFloatLib > > + > > +[LibraryClasses] > > + BaseLib > > + BaseMemoryLib > > + RedfishContentCodingLib > > + DebugLib > > + HttpLib > > + JsonLib > > + MemoryAllocationLib > > + PrintLib > > + RedfishDebugLib > > + ReportStatusCodeLib > > + UefiBootServicesTableLib > > + UefiDriverEntryPoint > > + UefiLib > > + > > +[Protocols] > > + gEdkIIRedfishHttpProtocolGuid ## PRODUCED > > + gEdkIIRedfishCredentialProtocolGuid ## CONSUMES > > + gEfiRestExProtocolGuid ## CONSUEMS > > + > > +[Pcd] > > + gEfiRedfishPkgTokenSpaceGuid.PcdHttpGetRetry > > + gEfiRedfishPkgTokenSpaceGuid.PcdHttpPutRetry > > + gEfiRedfishPkgTokenSpaceGuid.PcdHttpPatchRetry > > + gEfiRedfishPkgTokenSpaceGuid.PcdHttpPostRetry > > + gEfiRedfishPkgTokenSpaceGuid.PcdHttpDeleteRetry > > + gEfiRedfishPkgTokenSpaceGuid.PcdHttpRetryWaitInSecond > > + gEfiRedfishPkgTokenSpaceGuid.PcdHttpCacheDisabled > > + gEfiRedfishPkgTokenSpaceGuid.PcdRedfishServiceContentEncoding > > + > > +[Depex] > > + TRUE > > diff --git a/RedfishPkg/RedfishHttpDxe/RedfishHttpData.h > > b/RedfishPkg/RedfishHttpDxe/RedfishHttpData.h > > new file mode 100644 > > index 0000000000..6be610142e > > --- /dev/null > > +++ b/RedfishPkg/RedfishHttpDxe/RedfishHttpData.h > > @@ -0,0 +1,256 @@ > > +/** @file > > + Definitions of RedfishHttpData > > + > > + Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights > > reserved. > > + > > + SPDX-License-Identifier: BSD-2-Clause-Patent > > + > > +**/ > > + > > +#ifndef EDKII_REDFISH_HTTP_DATA_H_ > > +#define EDKII_REDFISH_HTTP_DATA_H_ > > + > > +#include "RedfishHttpDxe.h" > > + > > +#define REDFISH_HTTP_DRIVER_SIGNATURE SIGNATURE_32 ('r', 'f', 'h', '= p') > > +#define REDFISH_HTTP_CACHE_SIGNATURE SIGNATURE_32 ('r', 'f', 'c', '= h') > > +#define REDFISH_HTTP_SERVICE_SIGNATURE SIGNATURE_32 ('r', 'f', 's', '= v') > > +#define REDFISH_HTTP_PAYLOAD_SIGNATURE SIGNATURE_32 ('r', 'f', 'p', '= l') > > +#define REDFISH_HTTP_BASIC_AUTH_STR "Basic " > > + > > +/// > > +/// REDFISH_SERVICE_PRIVATE definition. > > +/// > > +typedef struct { > > + UINT32 Signature; > > + CHAR8 *Host; > > + CHAR8 *HostName; > > + CHAR8 *BasicAuth; > > + CHAR8 *SessionToken; > > + EFI_REST_EX_PROTOCOL *RestEx; > > +} REDFISH_SERVICE_PRIVATE; > > + > > +/// > > +/// REDFISH_PAYLOAD_PRIVATE definition. > > +/// > > +typedef struct { > > + UINT32 Signature; > > + REDFISH_SERVICE_PRIVATE *Service; > > + EDKII_JSON_VALUE JsonValue; > > +} REDFISH_PAYLOAD_PRIVATE; > > + > > +/// > > +/// Definition of REDFISH_HTTP_CACHE_DATA > > +/// > > +typedef struct { > > + UINT32 Signature; > > + LIST_ENTRY List; > > + EFI_STRING Uri; > > + UINTN HitCount; > > + REDFISH_RESPONSE *Response; > > +} REDFISH_HTTP_CACHE_DATA; > > + > > +#define REDFISH_HTTP_CACHE_FROM_LIST(a) CR (a, > > REDFISH_HTTP_CACHE_DATA, List, REDFISH_HTTP_CACHE_SIGNATURE) > > + > > +/// > > +/// Definition of REDFISH_HTTP_CACHE_LIST > > +/// > > +typedef struct { > > + LIST_ENTRY Head; > > + UINTN Count; > > + UINTN Capacity; > > +} REDFISH_HTTP_CACHE_LIST; > > + > > +/// > > +/// Definition of REDFISH_HTTP_RETRY_SETTING > > +/// > > +typedef struct { > > + UINT16 MaximumRetryGet; > > + UINT16 MaximumRetryPut; > > + UINT16 MaximumRetryPost; > > + UINT16 MaximumRetryPatch; > > + UINT16 MaximumRetryDelete; > > + UINTN RetryWait; > > +} REDFISH_HTTP_RETRY_SETTING; > > + > > +/// > > +/// Definition of REDFISH_HTTP_CACHE_PRIVATE > > +/// > > +typedef struct { > > + UINT32 Signature; > > + EFI_HANDLE ImageHandle; > > + BOOLEAN CacheDisabled; > > + EFI_EVENT NotifyEvent; > > + REDFISH_HTTP_CACHE_LIST CacheList; > > + EDKII_REDFISH_HTTP_PROTOCOL Protocol; > > + EDKII_REDFISH_CREDENTIAL_PROTOCOL *CredentialProtocol; > > + REDFISH_HTTP_RETRY_SETTING RetrySetting; > > +} REDFISH_HTTP_CACHE_PRIVATE; > > + > > +#define REDFISH_HTTP_CACHE_PRIVATE_FROM_THIS(a) CR (a, > > REDFISH_HTTP_CACHE_PRIVATE, Protocol, > > REDFISH_HTTP_DRIVER_SIGNATURE) > > + > > +/** > > + Search on given ListHeader for given URI string. > > + > > + @param[in] ListHeader Target list to search. > > + @param[in] Uri Target URI to search. > > + > > + @retval REDFISH_HTTP_CACHE_DATA Target cache data is found. > > + @retval NULL No cache data with given URI is fo= und. > > + > > +**/ > > +REDFISH_HTTP_CACHE_DATA * > > +FindHttpCacheData ( > > + IN LIST_ENTRY *ListHeader, > > + IN EFI_STRING Uri > > + ); > > + > > +/** > > + This function copy the data in SrcResponse to DstResponse. > > + > > + @param[in] SrcResponse Source Response to copy. > > + @param[out] DstResponse Destination Response. > > + > > + @retval EFI_SUCCESS Response is copied successfully. > > + @retval Others Error occurs. > > + > > +**/ > > +EFI_STATUS > > +CopyRedfishResponse ( > > + IN REDFISH_RESPONSE *SrcResponse, > > + OUT REDFISH_RESPONSE *DstResponse > > + ); > > + > > +/** > > + Release all cache from list. > > + > > + @param[in] CacheList The list to be released. > > + > > + @retval EFI_SUCCESS All cache data are released. > > + @retval EFI_INVALID_PARAMETER CacheList is NULL. > > + > > +**/ > > +EFI_STATUS > > +ReleaseCacheList ( > > + IN REDFISH_HTTP_CACHE_LIST *CacheList > > + ); > > + > > +/** > > + Add new cache by given URI and HTTP response to specify List. > > + > > + @param[in] List Target cache list to add. > > + @param[in] Uri The URI string matching to this cache data. > > + @param[in] Response HTTP response. > > + > > + @retval EFI_SUCCESS Cache data is added. > > + @retval Others Fail to add cache data. > > + > > +**/ > > +EFI_STATUS > > +AddHttpCacheData ( > > + IN REDFISH_HTTP_CACHE_LIST *List, > > + IN EFI_STRING Uri, > > + IN REDFISH_RESPONSE *Response > > + ); > > + > > +/** > > + Delete a cache data by given cache instance. > > + > > + @param[in] List Target cache list to be removed. > > + @param[in] Data Pointer to the instance to be deleted. > > + > > + @retval EFI_SUCCESS Cache data is removed. > > + @retval Others Fail to remove cache data. > > + > > +**/ > > +EFI_STATUS > > +DeleteHttpCacheData ( > > + IN REDFISH_HTTP_CACHE_LIST *List, > > + IN REDFISH_HTTP_CACHE_DATA *Data > > + ); > > + > > +/** > > + This function release Redfish Payload. > > + > > + @param[in] Payload Pointer to payload instance. > > + > > + @retval EFI_SUCCESS Payload is released. > > + @retval Others Error occurs. > > + > > +**/ > > +EFI_STATUS > > +ReleaseRedfishPayload ( > > + IN REDFISH_PAYLOAD_PRIVATE *Payload > > + ); > > + > > +/** > > + This function creat new payload. Server and JsonObj are > > + copied to newly created payload. > > + > > + @param[in] Service Pointer to Service instance. > > + @param[in] JsonObj Pointer to JSON object. > > + > > + @retval REDFISH_PAYLOAD_PRIVATE Newly created payload. > > + @retval NULL Error occurs. > > + > > +**/ > > +REDFISH_PAYLOAD_PRIVATE * > > +CreateRedfishPayload ( > > + IN REDFISH_SERVICE_PRIVATE *Service, > > + IN EDKII_JSON_VALUE JsonValue > > + ); > > + > > +/** > > + This function release Redfish Service. > > + > > + @param[in] Service Pointer to service instance. > > + > > + @retval EFI_SUCCESS Service is released. > > + @retval Others Error occurs. > > + > > +**/ > > +EFI_STATUS > > +ReleaseRedfishService ( > > + IN REDFISH_SERVICE_PRIVATE *Service > > + ); > > + > > +/** > > + This function creat new service. Host and HostName are copied to > > + newly created service instance. > > + > > + @param[in] Host Host string. > > + @param[in] HostName Hostname string. > > + @param[in] BasicAuth Basic Authorization string. > > + @param[in] SessionToken Session token string. > > + @param[in] RestEx Rest EX protocol instance. > > + > > + @retval REDFISH_PAYLOAD_PRIVATE Newly created service. > > + @retval NULL Error occurs. > > + > > +**/ > > +REDFISH_SERVICE_PRIVATE * > > +CreateRedfishService ( > > + IN CHAR8 *Host, > > + IN CHAR8 *HostName, > > + IN CHAR8 *BasicAuth OPTIONAL, > > + IN CHAR8 *SessionToken OPTIONAL, > > + IN EFI_REST_EX_PROTOCOL *RestEx > > + ); > > + > > +/** > > + This function update session token in Redfish Service. > > + > > + @param[in] Service Pointer to service instance. > > + @param[in] Token Session token. > > + > > + @retval EFI_SUCCESS Session token is updated. > > + @retval Others Error occurs. > > + > > +**/ > > +EFI_STATUS > > +UpdateSessionToken ( > > + IN REDFISH_SERVICE_PRIVATE *Service, > > + IN CHAR8 *Token > > + ); > > + > > +#endif > > diff --git a/RedfishPkg/RedfishHttpDxe/RedfishHttpDxe.h > > b/RedfishPkg/RedfishHttpDxe/RedfishHttpDxe.h > > new file mode 100644 > > index 0000000000..cf6ba9cb47 > > --- /dev/null > > +++ b/RedfishPkg/RedfishHttpDxe/RedfishHttpDxe.h > > @@ -0,0 +1,44 @@ > > +/** @file > > + Definitions of RedfishHttpDxe > > + > > + Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights > > reserved. > > + > > + SPDX-License-Identifier: BSD-2-Clause-Patent > > + > > +**/ > > + > > +#ifndef EDKII_REDFISH_HTTP_DXE_H_ > > +#define EDKII_REDFISH_HTTP_DXE_H_ > > + > > +#include > > +#include > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +#include > > +#include > > +#include > > +#include > > + > > +#define IS_EMPTY_STRING(a) ((a) =3D=3D NULL || (a)[0] =3D=3D '\0') > > +#define REDFISH_HTTP_CACHE_LIST_SIZE 0x80 > > +#define REDFISH_ERROR_MSG_MAX 128 > > +#define REDFISH_DEBUG_STRING_LENGTH 200 > > +#define REDFISH_HOST_NAME_MAX 64 // IPv6 maximum length = (39) > > + "https://" (8) + port number (maximum 5) > > +#define REDFISH_HTTP_ERROR_REPORT "Redfish HTTP %a failure(0x%= x): > > %s" > > +#define REDFISH_HTTP_CACHE_DEBUG DEBUG_MANAGEABILITY > > +#define REDFISH_HTTP_CACHE_DEBUG_DUMP DEBUG_MANAGEABILITY > > +#define REDFISH_HTTP_CACHE_DEBUG_REQUEST DEBUG_MANAGEABILITY > > + > > +#endif > > diff --git a/RedfishPkg/RedfishHttpDxe/RedfishHttpOperation.h > > b/RedfishPkg/RedfishHttpDxe/RedfishHttpOperation.h > > new file mode 100644 > > index 0000000000..e4fc053e96 > > --- /dev/null > > +++ b/RedfishPkg/RedfishHttpDxe/RedfishHttpOperation.h > > @@ -0,0 +1,76 @@ > > +/** @file > > + Definitions of RedfishHttpOperation > > + > > + Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights > > reserved. > > + > > + SPDX-License-Identifier: BSD-2-Clause-Patent > > + > > +**/ > > + > > +#ifndef EDKII_REDFISH_HTTP_OP_H_ > > +#define EDKII_REDFISH_HTTP_OP_H_ > > Nickle, I missed this when I reviewed it offline. > Could you please update the macro to align with header file name, > EDKII_REDFISH_HTTP_OPERATION_H_ > > Thanks > Abner > > > > + > > +#include "RedfishHttpDxe.h" > > + > > +#define REDFISH_CONTENT_LENGTH_SIZE 80 > > +#define REDFISH_COMMON_HEADER_SIZE 5 > > +#define REDFISH_HTTP_HEADER_ODATA_VERSION_STR "OData-Version" > > +#define REDFISH_HTTP_HEADER_ODATA_VERSION_VALUE "4.0" > > +#define REDFISH_HTTP_HEADER_USER_AGENT_VALUE "edk2redfish" > > +#define REDFISH_HTTP_HEADER_CONNECTION_STR "Connection" > > +#define REDFISH_HTTP_HEADER_CONNECTION_VALUE "Keep-Alive" > > +#define REDFISH_HTTP_CONTENT_ENCODING_NONE "None" > > + > > +/** > > + This function free resources in Request. Request is no longer availa= ble > > + after this function returns successfully. > > + > > + @param[in] Request HTTP request to be released. > > + > > + @retval EFI_SUCCESS Resrouce is released successfully. > > + @retval Others Errors occur. > > + > > +**/ > > +EFI_STATUS > > +ReleaseRedfishRequest ( > > + IN REDFISH_REQUEST *Request > > + ); > > + > > +/** > > + This function free resources in given Response. > > + > > + @param[in] Response HTTP response to be released. > > + > > + @retval EFI_SUCCESS Resrouce is released successfully. > > + @retval Others Errors occur. > > + > > +**/ > > +EFI_STATUS > > +ReleaseRedfishResponse ( > > + IN REDFISH_RESPONSE *Response > > + ); > > + > > +/** > > + This function send Redfish request to Redfish service by calling > > + Rest Ex protocol. > > + > > + @param[in] Service Pointer to Redfish service. > > + @param[in] Uri Uri of Redfish service. > > + @param[in] Method HTTP method. > > + @param[in] Request Request data. This is optional. > > + @param[out] Response Redfish response data. > > + > > + @retval EFI_SUCCESS Request is sent and received successfull= y. > > + @retval Others Errors occur. > > + > > +**/ > > +EFI_STATUS > > +HttpSendReceive ( > > + IN REDFISH_SERVICE Service, > > + IN EFI_STRING Uri, > > + IN EFI_HTTP_METHOD Method, > > + IN REDFISH_REQUEST *Request OPTIONAL, > > + OUT REDFISH_RESPONSE *Response > > + ); > > + > > +#endif > > diff --git a/RedfishPkg/RedfishHttpDxe/RedfishHttpData.c > > b/RedfishPkg/RedfishHttpDxe/RedfishHttpData.c > > new file mode 100644 > > index 0000000000..bf95e9f8d4 > > --- /dev/null > > +++ b/RedfishPkg/RedfishHttpDxe/RedfishHttpData.c > > @@ -0,0 +1,667 @@ > > +/** @file > > + RedfishHttpData handles internal data to support Redfish HTTP protoc= ol. > > + > > + Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights > > reserved. > > + > > + SPDX-License-Identifier: BSD-2-Clause-Patent > > + > > +**/ > > + > > +#include "RedfishHttpData.h" > > +#include "RedfishHttpOperation.h" > > + > > +/** > > + This function update session token in Redfish Service. > > + > > + @param[in] Service Pointer to service instance. > > + @param[in] Token Session token. > > + > > + @retval EFI_SUCCESS Session token is updated. > > + @retval Others Error occurs. > > + > > +**/ > > +EFI_STATUS > > +UpdateSessionToken ( > > + IN REDFISH_SERVICE_PRIVATE *Service, > > + IN CHAR8 *Token > > + ) > > +{ > > + if ((Service =3D=3D NULL) || IS_EMPTY_STRING (Token)) { > > + return EFI_INVALID_PARAMETER; > > + } > > + > > + if (Service->SessionToken !=3D NULL) { > > + FreePool (Service->SessionToken); > > + } > > + > > + Service->SessionToken =3D AllocateCopyPool (AsciiStrSize (Token), To= ken); > > + if (Service->SessionToken =3D=3D NULL) { > > + return EFI_OUT_OF_RESOURCES; > > + } > > + > > + return EFI_SUCCESS; > > +} > > + > > +/** > > + This function release Redfish Service. > > + > > + @param[in] Service Pointer to service instance. > > + > > + @retval EFI_SUCCESS Service is released. > > + @retval Others Error occurs. > > + > > +**/ > > +EFI_STATUS > > +ReleaseRedfishService ( > > + IN REDFISH_SERVICE_PRIVATE *Service > > + ) > > +{ > > + if (Service =3D=3D NULL) { > > + return EFI_INVALID_PARAMETER; > > + } > > + > > + if (Service->Host !=3D NULL) { > > + FreePool (Service->Host); > > + } > > + > > + if (Service->HostName !=3D NULL) { > > + FreePool (Service->HostName); > > + } > > + > > + if (Service->BasicAuth !=3D NULL) { > > + ZeroMem (Service->BasicAuth, AsciiStrSize (Service->BasicAuth)); > > + FreePool (Service->BasicAuth); > > + } > > + > > + if (Service->SessionToken !=3D NULL) { > > + ZeroMem (Service->SessionToken, AsciiStrSize (Service->SessionToke= n)); > > + FreePool (Service->SessionToken); > > + } > > + > > + FreePool (Service); > > + > > + return EFI_SUCCESS; > > +} > > + > > +/** > > + This function creat new service. Host and HostName are copied to > > + newly created service instance. > > + > > + @param[in] Host Host string. > > + @param[in] HostName Hostname string. > > + @param[in] BasicAuth Basic Authorization string. > > + @param[in] SessionToken Session token string. > > + @param[in] RestEx Rest EX protocol instance. > > + > > + @retval REDFISH_PAYLOAD_PRIVATE Newly created service. > > + @retval NULL Error occurs. > > + > > +**/ > > +REDFISH_SERVICE_PRIVATE * > > +CreateRedfishService ( > > + IN CHAR8 *Host, > > + IN CHAR8 *HostName, > > + IN CHAR8 *BasicAuth OPTIONAL, > > + IN CHAR8 *SessionToken OPTIONAL, > > + IN EFI_REST_EX_PROTOCOL *RestEx > > + ) > > +{ > > + REDFISH_SERVICE_PRIVATE *NewService; > > + UINTN AuthStrSize; > > + > > + if (IS_EMPTY_STRING (Host) || IS_EMPTY_STRING (HostName) || (RestEx > > =3D=3D NULL)) { > > + return NULL; > > + } > > + > > + NewService =3D AllocateZeroPool (sizeof (REDFISH_SERVICE_PRIVATE)); > > + if (NewService =3D=3D NULL) { > > + return NULL; > > + } > > + > > + NewService->Signature =3D REDFISH_HTTP_SERVICE_SIGNATURE; > > + NewService->Host =3D AllocateCopyPool (AsciiStrSize (Host), Hos= t); > > + if (NewService->Host =3D=3D NULL) { > > + goto ON_ERROR; > > + } > > + > > + NewService->HostName =3D AllocateCopyPool (AsciiStrSize (HostName), > > HostName); > > + if (NewService->HostName =3D=3D NULL) { > > + goto ON_ERROR; > > + } > > + > > + if (!IS_EMPTY_STRING (BasicAuth)) { > > + AuthStrSize =3D AsciiStrSize (BasicAuth) + AsciiStrLen > > (REDFISH_HTTP_BASIC_AUTH_STR); > > + NewService->BasicAuth =3D AllocateZeroPool (AuthStrSize); > > + if (NewService->BasicAuth =3D=3D NULL) { > > + goto ON_ERROR; > > + } > > + > > + AsciiSPrint (NewService->BasicAuth, AuthStrSize, "%a%a", > > REDFISH_HTTP_BASIC_AUTH_STR, BasicAuth); > > + } > > + > > + if (!IS_EMPTY_STRING (SessionToken)) { > > + NewService->SessionToken =3D AllocateCopyPool (AsciiStrSize > > (SessionToken), SessionToken); > > + if (NewService->SessionToken =3D=3D NULL) { > > + goto ON_ERROR; > > + } > > + } > > + > > + NewService->RestEx =3D RestEx; > > + > > + return NewService; > > + > > +ON_ERROR: > > + > > + ReleaseRedfishService (NewService); > > + > > + return NULL; > > +} > > + > > +/** > > + This function release Redfish Payload. > > + > > + @param[in] Payload Pointer to payload instance. > > + > > + @retval EFI_SUCCESS Payload is released. > > + @retval Others Error occurs. > > + > > +**/ > > +EFI_STATUS > > +ReleaseRedfishPayload ( > > + IN REDFISH_PAYLOAD_PRIVATE *Payload > > + ) > > +{ > > + if (Payload =3D=3D NULL) { > > + return EFI_INVALID_PARAMETER; > > + } > > + > > + if (Payload->Service !=3D NULL) { > > + ReleaseRedfishService (Payload->Service); > > + } > > + > > + if (Payload->JsonValue !=3D NULL) { > > + JsonValueFree (Payload->JsonValue); > > + } > > + > > + FreePool (Payload); > > + > > + return EFI_SUCCESS; > > +} > > + > > +/** > > + This function creat new payload. Server and JsonObj are > > + copied to newly created payload. > > + > > + @param[in] Service Pointer to Service instance. > > + @param[in] JsonValue Pointer to JSON value. > > + > > + @retval REDFISH_PAYLOAD_PRIVATE Newly created payload. > > + @retval NULL Error occurs. > > + > > +**/ > > +REDFISH_PAYLOAD_PRIVATE * > > +CreateRedfishPayload ( > > + IN REDFISH_SERVICE_PRIVATE *Service, > > + IN EDKII_JSON_VALUE JsonValue > > + ) > > +{ > > + REDFISH_PAYLOAD_PRIVATE *NewPayload; > > + > > + if ((Service =3D=3D NULL) || (JsonValue =3D=3D NULL)) { > > + return NULL; > > + } > > + > > + NewPayload =3D AllocateZeroPool (sizeof (REDFISH_PAYLOAD_PRIVATE)); > > + if (NewPayload =3D=3D NULL) { > > + return NULL; > > + } > > + > > + NewPayload->Signature =3D REDFISH_HTTP_PAYLOAD_SIGNATURE; > > + NewPayload->Service =3D CreateRedfishService (Service->Host, Servi= ce- > > >HostName, Service->BasicAuth, Service->SessionToken, Service->RestEx); > > + if (NewPayload->Service =3D=3D NULL) { > > + goto ON_ERROR; > > + } > > + > > + NewPayload->JsonValue =3D JsonValueClone (JsonValue); > > + if (NewPayload->JsonValue =3D=3D NULL) { > > + goto ON_ERROR; > > + } > > + > > + return NewPayload; > > + > > +ON_ERROR: > > + > > + ReleaseRedfishPayload (NewPayload); > > + > > + return NULL; > > +} > > + > > +/** > > + This function copy the data in SrcResponse to DstResponse. > > + > > + @param[in] SrcResponse Source Response to copy. > > + @param[out] DstResponse Destination Response. > > + > > + @retval EFI_SUCCESS Response is copied successfully. > > + @retval Others Error occurs. > > + > > +**/ > > +EFI_STATUS > > +CopyRedfishResponse ( > > + IN REDFISH_RESPONSE *SrcResponse, > > + OUT REDFISH_RESPONSE *DstResponse > > + ) > > +{ > > + REDFISH_PAYLOAD_PRIVATE *Payload; > > + UINTN Index; > > + > > + if ((SrcResponse =3D=3D NULL) || (DstResponse =3D=3D NULL)) { > > + return EFI_INVALID_PARAMETER; > > + } > > + > > + if (SrcResponse =3D=3D DstResponse) { > > + return EFI_SUCCESS; > > + } > > + > > + // > > + // Status code > > + // > > + if (SrcResponse->StatusCode !=3D NULL) { > > + DstResponse->StatusCode =3D AllocateCopyPool (sizeof > > (EFI_HTTP_STATUS_CODE), SrcResponse->StatusCode); > > + if (DstResponse->StatusCode =3D=3D NULL) { > > + goto ON_ERROR; > > + } > > + } > > + > > + // > > + // Header > > + // > > + if ((SrcResponse->HeaderCount > 0) && (SrcResponse->Headers !=3D NUL= L)) { > > + DstResponse->HeaderCount =3D 0; > > + DstResponse->Headers =3D AllocateZeroPool (sizeof (EFI_HTTP_HE= ADER) * > > SrcResponse->HeaderCount); > > + if (DstResponse->Headers =3D=3D NULL) { > > + goto ON_ERROR; > > + } > > + > > + for (Index =3D 0; Index < SrcResponse->HeaderCount; Index++) { > > + DstResponse->Headers[Index].FieldName =3D AllocateCopyPool (Asci= iStrSize > > (SrcResponse->Headers[Index].FieldName), SrcResponse- > > >Headers[Index].FieldName); > > + if (DstResponse->Headers[Index].FieldName =3D=3D NULL) { > > + goto ON_ERROR; > > + } > > + > > + DstResponse->Headers[Index].FieldValue =3D AllocateCopyPool (Asc= iiStrSize > > (SrcResponse->Headers[Index].FieldValue), SrcResponse- > > >Headers[Index].FieldValue); > > + if (DstResponse->Headers[Index].FieldValue =3D=3D NULL) { > > + goto ON_ERROR; > > + } > > + > > + DstResponse->HeaderCount +=3D 1; > > + } > > + } > > + > > + // > > + // Payload > > + // > > + if (SrcResponse->Payload !=3D NULL) { > > + Payload =3D (REDFISH_PAYLOAD_PRIVATE *)SrcResponse->Payload; > > + if (Payload->Signature !=3D REDFISH_HTTP_PAYLOAD_SIGNATURE) { > > + DEBUG ((DEBUG_ERROR, "%a: signature check failure\n", __func__))= ; > > + goto ON_ERROR; > > + } > > + > > + DstResponse->Payload =3D CreateRedfishPayload (Payload->Service, P= ayload- > > >JsonValue); > > + if (DstResponse->Payload =3D=3D NULL) { > > + goto ON_ERROR; > > + } > > + } > > + > > + return EFI_SUCCESS; > > + > > +ON_ERROR: > > + > > + ReleaseRedfishResponse (DstResponse); > > + > > + return EFI_OUT_OF_RESOURCES; > > +} > > + > > +/** > > + This function clone input response and return to caller > > + > > + @param[in] Response Response to clone. > > + > > + @retval REDFISH_RESPONSE * Response is cloned. > > + @retval NULL Errors occur. > > + > > +**/ > > +REDFISH_RESPONSE * > > +CloneRedfishResponse ( > > + IN REDFISH_RESPONSE *Response > > + ) > > +{ > > + EFI_STATUS Status; > > + REDFISH_RESPONSE *NewResponse; > > + > > + if (Response =3D=3D NULL) { > > + return NULL; > > + } > > + > > + NewResponse =3D AllocateZeroPool (sizeof (REDFISH_RESPONSE)); > > + if (NewResponse =3D=3D NULL) { > > + return NULL; > > + } > > + > > + Status =3D CopyRedfishResponse (Response, NewResponse); > > + if (EFI_ERROR (Status)) { > > + FreePool (NewResponse); > > + return NULL; > > + } > > + > > + return NewResponse; > > +} > > + > > +/** > > + Release REDFISH_HTTP_CACHE_DATA resource > > + > > + @param[in] Data Pointer to REDFISH_HTTP_CACHE_DATA instance > > + > > + @retval EFI_SUCCESS REDFISH_HTTP_CACHE_DATA is released > > successfully. > > + @retval EFI_INVALID_PARAMETER Data is NULL > > + > > +**/ > > +EFI_STATUS > > +ReleaseHttpCacheData ( > > + IN REDFISH_HTTP_CACHE_DATA *Data > > + ) > > +{ > > + if (Data =3D=3D NULL) { > > + return EFI_INVALID_PARAMETER; > > + } > > + > > + if (Data->Uri !=3D NULL) { > > + FreePool (Data->Uri); > > + } > > + > > + if (Data->Response !=3D NULL) { > > + ReleaseRedfishResponse (Data->Response); > > + FreePool (Data->Response); > > + } > > + > > + FreePool (Data); > > + > > + return EFI_SUCCESS; > > +} > > + > > +/** > > + Create new cache data. > > + > > + @param[in] Uri The URI string matching to this cache data. > > + @param[in] Response HTTP response. > > + > > + @retval REDFISH_HTTP_CACHE_DATA * Pointer to newly created cache > > data. > > + @retval NULL No memory available. > > + > > +**/ > > +REDFISH_HTTP_CACHE_DATA * > > +NewHttpCacheData ( > > + IN EFI_STRING Uri, > > + IN REDFISH_RESPONSE *Response > > + ) > > +{ > > + REDFISH_HTTP_CACHE_DATA *NewData; > > + UINTN Size; > > + > > + if (IS_EMPTY_STRING (Uri) || (Response =3D=3D NULL)) { > > + return NULL; > > + } > > + > > + NewData =3D AllocateZeroPool (sizeof (REDFISH_HTTP_CACHE_DATA)); > > + if (NewData =3D=3D NULL) { > > + return NULL; > > + } > > + > > + NewData->Signature =3D REDFISH_HTTP_CACHE_SIGNATURE; > > + Size =3D StrSize (Uri); > > + NewData->Uri =3D AllocateCopyPool (Size, Uri); > > + if (NewData->Uri =3D=3D NULL) { > > + goto ON_ERROR; > > + } > > + > > + NewData->Response =3D Response; > > + NewData->HitCount =3D 1; > > + > > + return NewData; > > + > > +ON_ERROR: > > + > > + if (NewData !=3D NULL) { > > + ReleaseHttpCacheData (NewData); > > + } > > + > > + return NULL; > > +} > > + > > +/** > > + Search on given ListHeader for given URI string. > > + > > + @param[in] ListHeader Target list to search. > > + @param[in] Uri Target URI to search. > > + > > + @retval REDFISH_HTTP_CACHE_DATA Target cache data is found. > > + @retval NULL No cache data with given URI is fo= und. > > + > > +**/ > > +REDFISH_HTTP_CACHE_DATA * > > +FindHttpCacheData ( > > + IN LIST_ENTRY *ListHeader, > > + IN EFI_STRING Uri > > + ) > > +{ > > + LIST_ENTRY *List; > > + REDFISH_HTTP_CACHE_DATA *Data; > > + > > + if (IS_EMPTY_STRING (Uri)) { > > + return NULL; > > + } > > + > > + if (IsListEmpty (ListHeader)) { > > + return NULL; > > + } > > + > > + Data =3D NULL; > > + List =3D GetFirstNode (ListHeader); > > + while (!IsNull (ListHeader, List)) { > > + Data =3D REDFISH_HTTP_CACHE_FROM_LIST (List); > > + > > + if (StrCmp (Data->Uri, Uri) =3D=3D 0) { > > + return Data; > > + } > > + > > + List =3D GetNextNode (ListHeader, List); > > + } > > + > > + return NULL; > > +} > > + > > +/** > > + Search on given ListHeader and return cache data with minimum hit co= unt. > > + > > + @param[in] ListHeader Target list to search. > > + > > + @retval REDFISH_HTTP_CACHE_DATA Target cache data is returned. > > + @retval NULL No cache data is found. > > + > > +**/ > > +REDFISH_HTTP_CACHE_DATA * > > +FindUnusedHttpCacheData ( > > + IN LIST_ENTRY *ListHeader > > + ) > > +{ > > + LIST_ENTRY *List; > > + REDFISH_HTTP_CACHE_DATA *Data; > > + REDFISH_HTTP_CACHE_DATA *UnusedData; > > + UINTN HitCount; > > + > > + if (IsListEmpty (ListHeader)) { > > + return NULL; > > + } > > + > > + Data =3D NULL; > > + UnusedData =3D NULL; > > + HitCount =3D 0; > > + > > + List =3D GetFirstNode (ListHeader); > > + Data =3D REDFISH_HTTP_CACHE_FROM_LIST (List); > > + UnusedData =3D Data; > > + HitCount =3D Data->HitCount; > > + List =3D GetNextNode (ListHeader, List); > > + > > + while (!IsNull (ListHeader, List)) { > > + Data =3D REDFISH_HTTP_CACHE_FROM_LIST (List); > > + > > + if (Data->HitCount < HitCount) { > > + HitCount =3D Data->HitCount; > > + UnusedData =3D Data; > > + } > > + > > + List =3D GetNextNode (ListHeader, List); > > + } > > + > > + return UnusedData; > > +} > > + > > +/** > > + Delete a cache data by given cache instance. > > + > > + @param[in] List Target cache list to be removed. > > + @param[in] Data Pointer to the instance to be deleted. > > + > > + @retval EFI_SUCCESS Cache data is removed. > > + @retval Others Fail to remove cache data. > > + > > +**/ > > +EFI_STATUS > > +DeleteHttpCacheData ( > > + IN REDFISH_HTTP_CACHE_LIST *List, > > + IN REDFISH_HTTP_CACHE_DATA *Data > > + ) > > +{ > > + if ((List =3D=3D NULL) || (Data =3D=3D NULL)) { > > + return EFI_INVALID_PARAMETER; > > + } > > + > > + DEBUG ((REDFISH_HTTP_CACHE_DEBUG, "%a: delete: %s\n", __func__, > > Data->Uri)); > > + > > + RemoveEntryList (&Data->List); > > + --List->Count; > > + > > + return ReleaseHttpCacheData (Data); > > +} > > + > > +/** > > + Add new cache by given URI and HTTP response to specify List. > > + > > + @param[in] List Target cache list to add. > > + @param[in] Uri The URI string matching to this cache data. > > + @param[in] Response HTTP response. > > + > > + @retval EFI_SUCCESS Cache data is added. > > + @retval Others Fail to add cache data. > > + > > +**/ > > +EFI_STATUS > > +AddHttpCacheData ( > > + IN REDFISH_HTTP_CACHE_LIST *List, > > + IN EFI_STRING Uri, > > + IN REDFISH_RESPONSE *Response > > + ) > > +{ > > + REDFISH_HTTP_CACHE_DATA *NewData; > > + REDFISH_HTTP_CACHE_DATA *OldData; > > + REDFISH_HTTP_CACHE_DATA *UnusedData; > > + REDFISH_RESPONSE *NewResponse; > > + > > + if ((List =3D=3D NULL) || IS_EMPTY_STRING (Uri) || (Response =3D=3D = NULL)) { > > + return EFI_INVALID_PARAMETER; > > + } > > + > > + // > > + // If same cache data exist, replace it with latest one. > > + // > > + OldData =3D FindHttpCacheData (&List->Head, Uri); > > + if (OldData !=3D NULL) { > > + DeleteHttpCacheData (List, OldData); > > + } > > + > > + // > > + // Check capacity > > + // > > + if (List->Count >=3D List->Capacity) { > > + DEBUG ((REDFISH_HTTP_CACHE_DEBUG, "%a: list is full and retire unu= sed > > cache\n", __func__)); > > + UnusedData =3D FindUnusedHttpCacheData (&List->Head); > > + if (UnusedData =3D=3D NULL) { > > + return EFI_OUT_OF_RESOURCES; > > + } > > + > > + DeleteHttpCacheData (List, UnusedData); > > + } > > + > > + // > > + // Clone a local copy > > + // > > + NewResponse =3D CloneRedfishResponse (Response); > > + if (NewResponse =3D=3D NULL) { > > + return EFI_OUT_OF_RESOURCES; > > + } > > + > > + NewData =3D NewHttpCacheData (Uri, NewResponse); > > + if (NewData =3D=3D NULL) { > > + return EFI_OUT_OF_RESOURCES; > > + } > > + > > + InsertTailList (&List->Head, &NewData->List); > > + ++List->Count; > > + > > + DEBUG ((REDFISH_HTTP_CACHE_DEBUG, "%a: cache(%d/%d) %s\n", > > __func__, List->Count, List->Capacity, NewData->Uri)); > > + > > + return EFI_SUCCESS; > > +} > > + > > +/** > > + Release all cache from list. > > + > > + @param[in] CacheList The list to be released. > > + > > + @retval EFI_SUCCESS All cache data are released. > > + @retval EFI_INVALID_PARAMETER CacheList is NULL. > > + > > +**/ > > +EFI_STATUS > > +ReleaseCacheList ( > > + IN REDFISH_HTTP_CACHE_LIST *CacheList > > + ) > > +{ > > + LIST_ENTRY *List; > > + LIST_ENTRY *Next; > > + REDFISH_HTTP_CACHE_DATA *Data; > > + > > + if (CacheList =3D=3D NULL) { > > + return EFI_INVALID_PARAMETER; > > + } > > + > > + if (IsListEmpty (&CacheList->Head)) { > > + return EFI_SUCCESS; > > + } > > + > > + Data =3D NULL; > > + Next =3D NULL; > > + List =3D GetFirstNode (&CacheList->Head); > > + while (!IsNull (&CacheList->Head, List)) { > > + Data =3D REDFISH_HTTP_CACHE_FROM_LIST (List); > > + Next =3D GetNextNode (&CacheList->Head, List); > > + > > + DeleteHttpCacheData (CacheList, Data); > > + > > + List =3D Next; > > + } > > + > > + return EFI_SUCCESS; > > +} > > diff --git a/RedfishPkg/RedfishHttpDxe/RedfishHttpDxe.c > > b/RedfishPkg/RedfishHttpDxe/RedfishHttpDxe.c > > new file mode 100644 > > index 0000000000..39958d4865 > > --- /dev/null > > +++ b/RedfishPkg/RedfishHttpDxe/RedfishHttpDxe.c > > @@ -0,0 +1,1344 @@ > > +/** @file > > + RedfishHttpDxe produces EdkIIRedfishHttpProtocol > > + for EDK2 Redfish Feature driver to do HTTP operations. > > + > > + Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights > > reserved. > > + > > + SPDX-License-Identifier: BSD-2-Clause-Patent > > + > > +**/ > > + > > +#include "RedfishHttpDxe.h" > > +#include "RedfishHttpData.h" > > +#include "RedfishHttpOperation.h" > > + > > +REDFISH_HTTP_CACHE_PRIVATE *mRedfishHttpCachePrivate =3D NULL; > > + > > +/** > > + Debug output the cache list. > > + > > + @param[in] Msg Debug message string. > > + @param[in] ErrorLevel Output error level. > > + @param[in] CacheList Target list to dump. > > + > > + @retval EFI_SUCCESS Debug dump finished. > > + @retval EFI_INVALID_PARAMETER HttpCacheList is NULL. > > + > > +**/ > > +EFI_STATUS > > +DebugPrintHttpCacheList ( > > + IN CONST CHAR8 *Msg, > > + IN UINTN ErrorLevel, > > + IN REDFISH_HTTP_CACHE_LIST *CacheList > > + ) > > +{ > > + LIST_ENTRY *List; > > + REDFISH_HTTP_CACHE_DATA *Data; > > + UINTN Index; > > + > > + if (CacheList =3D=3D NULL) { > > + return EFI_INVALID_PARAMETER; > > + } > > + > > + if (!IS_EMPTY_STRING (Msg)) { > > + DEBUG ((ErrorLevel, "%a\n", Msg)); > > + } > > + > > + if (IsListEmpty (&CacheList->Head)) { > > + DEBUG ((ErrorLevel, "list is empty\n")); > > + return EFI_NOT_FOUND; > > + } > > + > > + DEBUG ((ErrorLevel, "list count: %d capacity: %d\n", CacheList->Coun= t, > > CacheList->Capacity)); > > + Data =3D NULL; > > + Index =3D 0; > > + List =3D GetFirstNode (&CacheList->Head); > > + while (!IsNull (&CacheList->Head, List)) { > > + Data =3D REDFISH_HTTP_CACHE_FROM_LIST (List); > > + > > + DEBUG ((ErrorLevel, "%d) Uri: %s Hit: %d\n", ++Index, Data->Uri, D= ata- > > >HitCount)); > > + > > + List =3D GetNextNode (&CacheList->Head, List); > > + } > > + > > + return EFI_SUCCESS; > > +} > > + > > +/** > > + > > + Check HTTP status code to see if we like to retry HTTP request or no= t. > > + > > + @param[in] StatusCode HTTP status code. > > + > > + @retval BOOLEAN Return true when we like to retry reques= t. > > + Return false when we don't want to retry= request. > > + > > +**/ > > +BOOLEAN > > +RedfishRetryRequired ( > > + IN EFI_HTTP_STATUS_CODE *StatusCode > > + ) > > +{ > > + if (StatusCode =3D=3D NULL) { > > + return TRUE; > > + } > > + > > + if ((*StatusCode =3D=3D HTTP_STATUS_500_INTERNAL_SERVER_ERROR) || > > + (*StatusCode =3D=3D HTTP_STATUS_UNSUPPORTED_STATUS)) > > + { > > + return TRUE; > > + } > > + > > + return FALSE; > > +} > > + > > +/** > > + > > + Convert Unicode string to ASCII string. It's call responsibility to = release > > returned buffer. > > + > > + @param[in] UnicodeStr Unicode string to convert. > > + > > + @retval CHAR8 * ASCII string returned. > > + @retval NULL Errors occur. > > + > > +**/ > > +CHAR8 * > > +StringUnicodeToAscii ( > > + IN EFI_STRING UnicodeStr > > + ) > > +{ > > + CHAR8 *AsciiStr; > > + UINTN AsciiStrSize; > > + EFI_STATUS Status; > > + > > + if (IS_EMPTY_STRING (UnicodeStr)) { > > + return NULL; > > + } > > + > > + AsciiStrSize =3D StrLen (UnicodeStr) + 1; > > + AsciiStr =3D AllocateZeroPool (AsciiStrSize); > > + if (AsciiStr =3D=3D NULL) { > > + return NULL; > > + } > > + > > + Status =3D UnicodeStrToAsciiStrS (UnicodeStr, AsciiStr, AsciiStrSize= ); > > + if (EFI_ERROR (Status)) { > > + DEBUG ((DEBUG_ERROR, "UnicodeStrToAsciiStrS failed: %r\n", Status)= ); > > + FreePool (AsciiStr); > > + return NULL; > > + } > > + > > + return AsciiStr; > > +} > > + > > +/** > > + Return HTTP method in ASCII string. Caller does not need > > + to free returned string buffer. > > + > > + @param[in] Method HTTP method. > > + > > + @retval CHAR8 * Method in string. > > +**/ > > +CHAR8 * > > +HttpMethodToString ( > > + IN EFI_HTTP_METHOD Method > > + ) > > +{ > > + switch (Method) { > > + case HttpMethodGet: > > + return HTTP_METHOD_GET; > > + break; > > + case HttpMethodPost: > > + return HTTP_METHOD_POST; > > + break; > > + case HttpMethodPatch: > > + return HTTP_METHOD_PATCH; > > + break; > > + case HttpMethodPut: > > + return HTTP_METHOD_PUT; > > + break; > > + case HttpMethodDelete: > > + return HTTP_METHOD_DELETE; > > + break; > > + default: > > + break; > > + } > > + > > + return "Unknown"; > > +} > > + > > +/** > > + Report HTTP communication error via report status code. > > + > > + @param[in] Method HTTP method. > > + @param[in] Uri The URI which has failure. > > + @param[in] HttpStatusCode HTTP status code. > > + > > +**/ > > +VOID > > +ReportHttpError ( > > + IN EFI_HTTP_METHOD Method, > > + IN EFI_STRING Uri, > > + IN EFI_HTTP_STATUS_CODE *HttpStatusCode OPTIONAL > > + ) > > +{ > > + CHAR8 ErrorMsg[REDFISH_ERROR_MSG_MAX]; > > + > > + if (IS_EMPTY_STRING (Uri)) { > > + DEBUG ((DEBUG_ERROR, "%a: no URI to report error status\n", > > __func__)); > > + return; > > + } > > + > > + // > > + // Report failure of URI and HTTP status code. > > + // > > + AsciiSPrint (ErrorMsg, sizeof (ErrorMsg), REDFISH_HTTP_ERROR_REPORT, > > HttpMethodToString (Method), (HttpStatusCode =3D=3D NULL ? > > HTTP_STATUS_UNSUPPORTED_STATUS : *HttpStatusCode), Uri); > > + DEBUG ((DEBUG_ERROR, "%a\n", ErrorMsg)); > > + // > > + // TODO: > > + // Below PI status code is approved by PIWG and wait for specificati= on > > published. > > + // We will uncomment below report status code after PI status code g= et > > published. > > + // REF: > https://bugzilla.ti/ > anocore.org%2Fshow_bug.cgi%3Fid%3D4483&data=3D05%7C02%7Cnicklew%40nvi > dia.com%7C170113d9065b49ddd38b08dc327faeab%7C43083d15727340c1b7db > 39efd9ccc17a%7C0%7C0%7C638440771190654082%7CUnknown%7CTWFpbGZs > b3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0% > 3D%7C0%7C%7C%7C&sdata=3Dna71Yv8MEbiiQFzc437B3fNcMZ5%2B7wrhzFjwTZb > KPl4%3D&reserved=3D0 > > + // > > + // REPORT_STATUS_CODE_WITH_EXTENDED_DATA ( > > + // EFI_ERROR_CODE | EFI_ERROR_MAJOR, > > + // EFI_COMPUTING_UNIT_MANAGEABILITY | > > EFI_MANAGEABILITY_EC_REDFISH_COMMUNICATION_ERROR, > > + // ErrorMsg, > > + // AsciiStrSize (ErrorMsg) > > + // ); > > +} > > + > > +/** > > + This function create Redfish service. It's caller's responsibility t= o free > > returned > > + Redfish service by calling FreeService (). > > + > > + @param[in] This Pointer to EDKII_REDFISH_HTTP= _PROTOCOL > > instance. > > + @param[in] RedfishConfigServiceInfo Redfish config service inform= ation. > > + > > + @retval REDFISH_SERVICE Redfish service is created. > > + @retval NULL Errors occur. > > + > > +**/ > > +REDFISH_SERVICE > > +EFIAPI > > +RedfishCreateRedfishService ( > > + IN EDKII_REDFISH_HTTP_PROTOCOL *This, > > + IN REDFISH_CONFIG_SERVICE_INFORMATION *RedfishConfigServiceInfo > > + ) > > +{ > > + EFI_STATUS Status; > > + REDFISH_HTTP_CACHE_PRIVATE *Private; > > + REDFISH_SERVICE_PRIVATE *NewService; > > + CHAR8 *AsciiLocation; > > + CHAR8 *Host; > > + CHAR8 *BasicAuthString; > > + UINTN BasicAuthStrSize; > > + CHAR8 *EncodedAuthString; > > + UINTN EncodedAuthStrSize; > > + EDKII_REDFISH_AUTH_METHOD AuthMethod; > > + CHAR8 *Username; > > + CHAR8 *Password; > > + UINTN UsernameSize; > > + UINTN PasswordSize; > > + EFI_REST_EX_PROTOCOL *RestEx; > > + > > + if ((This =3D=3D NULL) || (RedfishConfigServiceInfo =3D=3D NULL)) { > > + return NULL; > > + } > > + > > + DEBUG ((REDFISH_HTTP_CACHE_DEBUG, "%a: service location: %s\n", > > __func__, RedfishConfigServiceInfo->RedfishServiceLocation)); > > + > > + Private =3D REDFISH_HTTP_CACHE_PRIVATE_FROM_THIS (This); > > + BasicAuthString =3D NULL; > > + EncodedAuthString =3D NULL; > > + Username =3D NULL; > > + Password =3D NULL; > > + NewService =3D NULL; > > + AsciiLocation =3D NULL; > > + Host =3D NULL; > > + BasicAuthStrSize =3D 0; > > + EncodedAuthStrSize =3D 0; > > + UsernameSize =3D 0; > > + PasswordSize =3D 0; > > + > > + // > > + // Build host and host name from service location > > + // > > + if (!IS_EMPTY_STRING (RedfishConfigServiceInfo->RedfishServiceLocati= on)) > > { > > + AsciiLocation =3D StringUnicodeToAscii (RedfishConfigServiceInfo- > > >RedfishServiceLocation); > > + if (AsciiLocation =3D=3D NULL) { > > + goto ON_RELEASE; > > + } > > + > > + Host =3D AllocateZeroPool (REDFISH_HOST_NAME_MAX); > > + if (AsciiLocation =3D=3D NULL) { > > + goto ON_RELEASE; > > + } > > + > > + if (RedfishConfigServiceInfo->RedfishServiceUseHttps) { > > + AsciiSPrint (Host, REDFISH_HOST_NAME_MAX, "https://%a", > > AsciiLocation); > > + } else { > > + AsciiSPrint (Host, REDFISH_HOST_NAME_MAX, "http://%a", > > AsciiLocation); > > + } > > + > > + DEBUG ((REDFISH_HTTP_CACHE_DEBUG, "%a: Host: %a\n", __func__, > > Host)); > > + } > > + > > + // > > + // Find Rest Ex protocol > > + // > > + if (RedfishConfigServiceInfo->RedfishServiceRestExHandle !=3D NULL) = { > > + Status =3D gBS->HandleProtocol ( > > + RedfishConfigServiceInfo->RedfishServiceRestExHand= le, > > + &gEfiRestExProtocolGuid, > > + (VOID **)&RestEx > > + ); > > + } else { > > + DEBUG ((DEBUG_ERROR, "%a: Rest Ex protocol is not available\n", > > __func__)); > > + goto ON_RELEASE; > > + } > > + > > + // > > + // Get credential > > + // > > + if (Private->CredentialProtocol =3D=3D NULL) { > > + // > > + // No credential available on this system. > > + // > > + DEBUG ((DEBUG_WARN, "%a: no credential protocol available\n", > > __func__)); > > + } else { > > + Status =3D Private->CredentialProtocol->GetAuthInfo ( > > + Private->CredentialProtoco= l, > > + &AuthMethod, > > + &Username, > > + &Password > > + ); > > + if (EFI_ERROR (Status) || IS_EMPTY_STRING (Username) || > > IS_EMPTY_STRING (Password)) { > > + DEBUG ((DEBUG_ERROR, "%a: cannot get authentication information: > > %r\n", __func__, Status)); > > + goto ON_RELEASE; > > + } else { > > + DEBUG ((REDFISH_HTTP_CACHE_DEBUG, "%a: Auth method: 0x%x > > username: %a password: %a\n", __func__, AuthMethod, Username, > > Password)); > > + > > + // > > + // Perform base64 encoding (RFC 7617) > > + // > > + UsernameSize =3D AsciiStrSize (Username); > > + PasswordSize =3D AsciiStrSize (Password); > > + BasicAuthStrSize =3D UsernameSize + PasswordSize; // one byte = taken from > > null-terminator for ':' > > + BasicAuthString =3D AllocateZeroPool (BasicAuthStrSize); > > + if (BasicAuthString =3D=3D NULL) { > > + goto ON_RELEASE; > > + } > > + > > + AsciiSPrint ( > > + BasicAuthString, > > + BasicAuthStrSize, > > + "%a:%a", > > + Username, > > + Password > > + ); > > + > > + Status =3D Base64Encode ( > > + (CONST UINT8 *)BasicAuthString, > > + BasicAuthStrSize, > > + EncodedAuthString, > > + &EncodedAuthStrSize > > + ); > > + if ((Status =3D=3D EFI_BUFFER_TOO_SMALL) && (EncodedAuthStrSize = > 0)) { > > + EncodedAuthString =3D AllocateZeroPool (EncodedAuthStrSize); > > + if (EncodedAuthString =3D=3D NULL) { > > + goto ON_RELEASE; > > + } > > + > > + Status =3D Base64Encode ( > > + (CONST UINT8 *)BasicAuthString, > > + BasicAuthStrSize, > > + EncodedAuthString, > > + &EncodedAuthStrSize > > + ); > > + if (EFI_ERROR (Status)) { > > + DEBUG ((DEBUG_ERROR, "%a: Base64Encode failure: %r\n", __fun= c__, > > Status)); > > + } > > + > > + DEBUG ((REDFISH_HTTP_CACHE_DEBUG, "%a: Basic authorization: > > %a\n", __func__, EncodedAuthString)); > > + } else { > > + DEBUG ((DEBUG_ERROR, "%a: Base64Encode failure: %r\n", __func_= _, > > Status)); > > + goto ON_RELEASE; > > + } > > + } > > + } > > + > > + NewService =3D CreateRedfishService (Host, AsciiLocation, > > EncodedAuthString, NULL, RestEx); > > + if (NewService =3D=3D NULL) { > > + DEBUG ((DEBUG_ERROR, "%a: CreateRedfishService\n", __func__)); > > + } > > + > > +ON_RELEASE: > > + > > + if (BasicAuthString !=3D NULL) { > > + ZeroMem (BasicAuthString, BasicAuthStrSize); > > + FreePool (BasicAuthString); > > + } > > + > > + if (EncodedAuthString !=3D NULL) { > > + ZeroMem (BasicAuthString, EncodedAuthStrSize); > > + FreePool (EncodedAuthString); > > + } > > + > > + if (Username !=3D NULL) { > > + ZeroMem (Username, UsernameSize); > > + FreePool (Username); > > + } > > + > > + if (Password !=3D NULL) { > > + ZeroMem (Password, PasswordSize); > > + FreePool (Password); > > + } > > + > > + if (AsciiLocation !=3D NULL) { > > + FreePool (AsciiLocation); > > + } > > + > > + if (Host !=3D NULL) { > > + FreePool (Host); > > + } > > + > > + return NewService; > > +} > > + > > +/** > > + This function free resources in Redfish service. RedfishService is n= o longer > > available > > + after this function returns successfully. > > + > > + @param[in] This Pointer to EDKII_REDFISH_HTTP_PROTOCOL > > instance. > > + @param[in] RedfishService Pointer to Redfish service to be release= d. > > + > > + @retval EFI_SUCCESS Resrouce is released successfully. > > + @retval Others Errors occur. > > + > > +**/ > > +EFI_STATUS > > +EFIAPI > > +RedfishFreeRedfishService ( > > + IN EDKII_REDFISH_HTTP_PROTOCOL *This, > > + IN REDFISH_SERVICE RedfishService > > + ) > > +{ > > + REDFISH_SERVICE_PRIVATE *Service; > > + > > + if ((This =3D=3D NULL) || (RedfishService =3D=3D NULL)) { > > + return EFI_INVALID_PARAMETER; > > + } > > + > > + Service =3D (REDFISH_SERVICE_PRIVATE *)RedfishService; > > + if (Service->Signature !=3D REDFISH_HTTP_SERVICE_SIGNATURE) { > > + DEBUG ((DEBUG_ERROR, "%a: signature check failure\n", __func__)); > > + } > > + > > + return ReleaseRedfishService (Service); > > +} > > + > > +/** > > + This function returns JSON value in given RedfishPayload. Returned J= SON > > value > > + is a reference to the JSON value in RedfishPayload. Any modification= to > > returned > > + JSON value will change JSON value in RedfishPayload. > > + > > + @param[in] This Pointer to EDKII_REDFISH_HTTP_PROTOCOL > > instance. > > + @param[in] RedfishPayload Pointer to Redfish payload. > > + > > + @retval EDKII_JSON_VALUE JSON value is returned. > > + @retval NULL Errors occur. > > + > > +**/ > > +EDKII_JSON_VALUE > > +EFIAPI > > +RedfishJsonInRedfishPayload ( > > + IN EDKII_REDFISH_HTTP_PROTOCOL *This, > > + IN REDFISH_PAYLOAD RedfishPayload > > + ) > > +{ > > + REDFISH_PAYLOAD_PRIVATE *Payload; > > + > > + if ((This =3D=3D NULL) || (RedfishPayload =3D=3D NULL)) { > > + return NULL; > > + } > > + > > + Payload =3D (REDFISH_PAYLOAD_PRIVATE *)RedfishPayload; > > + if (Payload->Signature !=3D REDFISH_HTTP_PAYLOAD_SIGNATURE) { > > + DEBUG ((DEBUG_ERROR, "%a: signature check failure\n", __func__)); > > + } > > + > > + return Payload->JsonValue; > > +} > > + > > +/** > > + Perform HTTP GET to Get redfish resource from given resource URI wit= h > > + cache mechanism supported. It's caller's responsibility to free Resp= onse > > + by calling FreeResponse (). > > + > > + @param[in] This Pointer to EDKII_REDFISH_HTTP_PROTOCOL ins= tance. > > + @param[in] Service Redfish service instance to perform HTTP G= ET. > > + @param[in] Uri Target resource URI. > > + @param[in] Request Additional request context. This is option= al. > > + @param[out] Response HTTP response from redfish service. > > + @param[in] UseCache If it is TRUE, this function will search f= or > > + cache first. If it is FALSE, this function > > + will query Redfish URI directly. > > + > > + @retval EFI_SUCCESS Resrouce is returned successfully. > > + @retval Others Errors occur. > > + > > +**/ > > +EFI_STATUS > > +EFIAPI > > +RedfishGetResource ( > > + IN EDKII_REDFISH_HTTP_PROTOCOL *This, > > + IN REDFISH_SERVICE Service, > > + IN EFI_STRING Uri, > > + IN REDFISH_REQUEST *Request OPTIONAL, > > + OUT REDFISH_RESPONSE *Response, > > + IN BOOLEAN UseCache > > + ) > > +{ > > + EFI_STATUS Status; > > + REDFISH_HTTP_CACHE_DATA *CacheData; > > + UINTN RetryCount; > > + REDFISH_HTTP_CACHE_PRIVATE *Private; > > + > > + if ((This =3D=3D NULL) || (Service =3D=3D NULL) || (Response =3D=3D = NULL) || > > IS_EMPTY_STRING (Uri)) { > > + return EFI_INVALID_PARAMETER; > > + } > > + > > + DEBUG ((REDFISH_HTTP_CACHE_DEBUG, "%a: Get URI: %s cache: %a\n", > > __func__, Uri, (UseCache ? "true" : "false"))); > > + > > + Private =3D REDFISH_HTTP_CACHE_PRIVATE_FROM_THIS (This); > > + CacheData =3D NULL; > > + RetryCount =3D 0; > > + ZeroMem (Response, sizeof (REDFISH_RESPONSE)); > > + > > + if (Private->CacheDisabled) { > > + UseCache =3D FALSE; > > + DEBUG ((REDFISH_HTTP_CACHE_DEBUG, "%a: cache is disabled by > > PCD!\n", __func__)); > > + } > > + > > + // > > + // Search for cache list. > > + // > > + if (UseCache) { > > + CacheData =3D FindHttpCacheData (&Private->CacheList.Head, Uri); > > + if (CacheData !=3D NULL) { > > + DEBUG ((REDFISH_HTTP_CACHE_DEBUG_REQUEST, "%a: cache hit! > > %s\n", __func__, Uri)); > > + > > + // > > + // Copy cached response to caller's buffer. > > + // > > + Status =3D CopyRedfishResponse (CacheData->Respons= e, Response); > > + CacheData->HitCount +=3D 1; > > + return Status; > > + } > > + } > > + > > + // > > + // Get resource from redfish service. > > + // > > + do { > > + RetryCount +=3D 1; > > + Status =3D HttpSendReceive ( > > + Service, > > + Uri, > > + HttpMethodGet, > > + Request, > > + Response > > + ); > > + DEBUG ((REDFISH_HTTP_CACHE_DEBUG_REQUEST, "%a: HTTP request: > > %s :%r\n", __func__, Uri, Status)); > > + if (!EFI_ERROR (Status) || (RetryCount >=3D Private- > > >RetrySetting.MaximumRetryGet)) { > > + break; > > + } > > + > > + // > > + // Retry when BMC is not ready. > > + // > > + if ((Response->StatusCode !=3D NULL)) { > > + DEBUG_CODE ( > > + DumpRedfishResponse (NULL, DEBUG_ERROR, Response); > > + ); > > + > > + if (!RedfishRetryRequired (Response->StatusCode)) { > > + break; > > + } > > + > > + // > > + // Release response for next round of request. > > + // > > + This->FreeResponse (This, Response); > > + } > > + > > + DEBUG ((DEBUG_WARN, "%a: RedfishGetByUriEx failed, retry (%d/%d)\n= ", > > __func__, RetryCount, Private->RetrySetting.MaximumRetryGet)); > > + if (Private->RetrySetting.RetryWait > 0) { > > + gBS->Stall (Private->RetrySetting.RetryWait); > > + } > > + } while (TRUE); > > + > > + if (EFI_ERROR (Status)) { > > + DEBUG_CODE ( > > + DumpRedfishResponse (NULL, DEBUG_ERROR, Response); > > + ); > > + // > > + // Report status code for Redfish failure > > + // > > + ReportHttpError (HttpMethodGet, Uri, Response->StatusCode); > > + DEBUG ((DEBUG_ERROR, "%a: get %s failed (%d/%d): %r\n", __func__, = Uri, > > RetryCount, Private->RetrySetting.MaximumRetryGet, Status)); > > + goto ON_RELEASE; > > + } > > + > > + if (!Private->CacheDisabled) { > > + // > > + // Keep response in cache list > > + // > > + Status =3D AddHttpCacheData (&Private->CacheList, Uri, Response); > > + if (EFI_ERROR (Status)) { > > + DEBUG ((DEBUG_ERROR, "%a: failed to cache %s: %r\n", __func__, U= ri, > > Status)); > > + goto ON_RELEASE; > > + } > > + > > + DEBUG_CODE ( > > + DebugPrintHttpCacheList (__func__, > > REDFISH_HTTP_CACHE_DEBUG_DUMP, &Private->CacheList); > > + ); > > + } > > + > > +ON_RELEASE: > > + > > + return Status; > > +} > > + > > +/** > > + This function free resources in Request. Request is no longer availa= ble > > + after this function returns successfully. > > + > > + @param[in] This Pointer to EDKII_REDFISH_HTTP_PROTOCOL inst= ance. > > + @param[in] Request HTTP request to be released. > > + > > + @retval EFI_SUCCESS Resrouce is released successfully. > > + @retval Others Errors occur. > > + > > +**/ > > +EFI_STATUS > > +EFIAPI > > +RedfishFreeRequest ( > > + IN EDKII_REDFISH_HTTP_PROTOCOL *This, > > + IN REDFISH_REQUEST *Request > > + ) > > +{ > > + if ((This =3D=3D NULL) || (Request =3D=3D NULL)) { > > + return EFI_INVALID_PARAMETER; > > + } > > + > > + DEBUG ((REDFISH_HTTP_CACHE_DEBUG, "%a: entry\n", __func__)); > > + > > + return ReleaseRedfishRequest (Request); > > +} > > + > > +/** > > + This function free resources in given Response. > > + > > + @param[in] This Pointer to EDKII_REDFISH_HTTP_PROTOCOL inst= ance. > > + @param[in] Response HTTP response to be released. > > + > > + @retval EFI_SUCCESS Resrouce is released successfully. > > + @retval Others Errors occur. > > + > > +**/ > > +EFI_STATUS > > +EFIAPI > > +RedfishFreeResponse ( > > + IN EDKII_REDFISH_HTTP_PROTOCOL *This, > > + IN REDFISH_RESPONSE *Response > > + ) > > +{ > > + if ((This =3D=3D NULL) || (Response =3D=3D NULL)) { > > + return EFI_INVALID_PARAMETER; > > + } > > + > > + DEBUG ((REDFISH_HTTP_CACHE_DEBUG, "%a: entry\n", __func__)); > > + > > + return ReleaseRedfishResponse (Response); > > +} > > + > > +/** > > + This function expire the cached response of given URI. > > + > > + @param[in] This Pointer to EDKII_REDFISH_HTTP_PROTOCOL inst= ance. > > + @param[in] Uri Target response of URI. > > + > > + @retval EFI_SUCCESS Target response is expired successfully. > > + @retval Others Errors occur. > > + > > +**/ > > +EFI_STATUS > > +EFIAPI > > +RedfishExpireResponse ( > > + IN EDKII_REDFISH_HTTP_PROTOCOL *This, > > + IN EFI_STRING Uri > > + ) > > +{ > > + REDFISH_HTTP_CACHE_PRIVATE *Private; > > + REDFISH_HTTP_CACHE_DATA *CacheData; > > + > > + if ((This =3D=3D NULL) || IS_EMPTY_STRING (Uri)) { > > + return EFI_INVALID_PARAMETER; > > + } > > + > > + DEBUG ((REDFISH_HTTP_CACHE_DEBUG, "%a: expire URI: %s\n", __func__, > > Uri)); > > + > > + Private =3D REDFISH_HTTP_CACHE_PRIVATE_FROM_THIS (This); > > + > > + CacheData =3D FindHttpCacheData (&Private->CacheList.Head, Uri); > > + if (CacheData =3D=3D NULL) { > > + return EFI_NOT_FOUND; > > + } > > + > > + return DeleteHttpCacheData (&Private->CacheList, CacheData); > > +} > > + > > +/** > > + Perform HTTP PATCH to send redfish resource to given resource URI. > > + It's caller's responsibility to free Response by calling FreeRespons= e (). > > + > > + @param[in] This Pointer to EDKII_REDFISH_HTTP_PROTOCOL ins= tance. > > + @param[in] Service Redfish service instance to perform HTTP P= ATCH. > > + @param[in] Uri Target resource URI. > > + @param[in] Content Data to patch. > > + @param[in] ContentSize Size of the Content to be send to Redfish = service. > > + This is optional. When ContentSize is 0, C= ontentSize > > + is the size of Content. > > + @param[in] ContentType Type of the Content to be send to Redfish > > service. > > + This is optional. When ContentType is NULL= , content > > + type HTTP_CONTENT_TYPE_APP_JSON will be us= ed. > > + @param[out] Response HTTP response from redfish service. > > + > > + @retval EFI_SUCCESS Resrouce is returned successfully. > > + @retval Others Errors occur. > > + > > +**/ > > +EFI_STATUS > > +EFIAPI > > +RedfishPatchResource ( > > + IN EDKII_REDFISH_HTTP_PROTOCOL *This, > > + IN REDFISH_SERVICE Service, > > + IN EFI_STRING Uri, > > + IN CHAR8 *Content, > > + IN UINTN ContentSize OPTIONAL, > > + IN CHAR8 *ContentType OPTIONAL, > > + OUT REDFISH_RESPONSE *Response > > + ) > > +{ > > + EFI_STATUS Status; > > + UINTN RetryCount; > > + REDFISH_REQUEST Request; > > + REDFISH_HTTP_CACHE_PRIVATE *Private; > > + > > + if ((This =3D=3D NULL) || (Service =3D=3D NULL) || (Response =3D=3D = NULL) || > > IS_EMPTY_STRING (Uri) || IS_EMPTY_STRING (Content)) { > > + return EFI_INVALID_PARAMETER; > > + } > > + > > + DEBUG ((REDFISH_HTTP_CACHE_DEBUG, "%a: Patch URI: %s\n", __func__, > > Uri)); > > + > > + Private =3D REDFISH_HTTP_CACHE_PRIVATE_FROM_THIS (This); > > + RetryCount =3D 0; > > + ZeroMem (Response, sizeof (REDFISH_RESPONSE)); > > + ZeroMem (&Request, sizeof (REDFISH_REQUEST)); > > + > > + Request.Content =3D Content; > > + Request.ContentLength =3D ContentSize; > > + Request.ContentType =3D ContentType; > > + > > + // > > + // Patch resource to redfish service. > > + // > > + do { > > + RetryCount +=3D 1; > > + Status =3D HttpSendReceive ( > > + Service, > > + Uri, > > + HttpMethodPatch, > > + &Request, > > + Response > > + ); > > + DEBUG ((REDFISH_HTTP_CACHE_DEBUG_REQUEST, "%a: HTTP request: > > %s :%r\n", __func__, Uri, Status)); > > + if (!EFI_ERROR (Status) || (RetryCount >=3D Private- > > >RetrySetting.MaximumRetryPatch)) { > > + break; > > + } > > + > > + // > > + // Retry when BMC is not ready. > > + // > > + if ((Response->StatusCode !=3D NULL)) { > > + DEBUG_CODE ( > > + DumpRedfishResponse (NULL, DEBUG_ERROR, Response); > > + ); > > + > > + if (!RedfishRetryRequired (Response->StatusCode)) { > > + break; > > + } > > + > > + // > > + // Release response for next round of request. > > + // > > + This->FreeResponse (This, Response); > > + } > > + > > + DEBUG ((DEBUG_WARN, "%a: RedfishPatchToUriEx failed, retry > > (%d/%d)\n", __func__, RetryCount, Private- > > >RetrySetting.MaximumRetryPatch)); > > + if (Private->RetrySetting.RetryWait > 0) { > > + gBS->Stall (Private->RetrySetting.RetryWait); > > + } > > + } while (TRUE); > > + > > + // > > + // Redfish resource is updated. Automatically expire the cached resp= onse > > + // so application can directly get resource from Redfish service aga= in. > > + // > > + DEBUG ((REDFISH_HTTP_CACHE_DEBUG, "%a: Resource is updated, expire > > URI: %s\n", __func__, Uri)); > > + RedfishExpireResponse (This, Uri); > > + > > + if (EFI_ERROR (Status)) { > > + DEBUG_CODE ( > > + DumpRedfishResponse (NULL, DEBUG_ERROR, Response); > > + ); > > + // > > + // Report status code for Redfish failure > > + // > > + ReportHttpError (HttpMethodPatch, Uri, Response->StatusCode); > > + DEBUG ((DEBUG_ERROR, "%a: patch %s failed (%d/%d): %r\n", __func__= , > > Uri, RetryCount, Private->RetrySetting.MaximumRetryPatch, Status)); > > + goto ON_RELEASE; > > + } > > + > > +ON_RELEASE: > > + > > + return Status; > > +} > > + > > +/** > > + Perform HTTP PUT to send redfish resource to given resource URI. > > + It's caller's responsibility to free Response by calling FreeRespons= e (). > > + > > + @param[in] This Pointer to EDKII_REDFISH_HTTP_PROTOCOL ins= tance. > > + @param[in] Service Redfish service instance to perform HTTP P= UT. > > + @param[in] Uri Target resource URI. > > + @param[in] Content Data to put. > > + @param[in] ContentSize Size of the Content to be send to Redfish = service. > > + This is optional. When ContentSize is 0, C= ontentSize > > + is the size of Content. > > + @param[in] ContentType Type of the Content to be send to Redfish > > service. > > + This is optional. When ContentType is NULL= , content > > + type HTTP_CONTENT_TYPE_APP_JSON will be us= ed. > > + @param[out] Response HTTP response from redfish service. > > + > > + @retval EFI_SUCCESS Resrouce is returned successfully. > > + @retval Others Errors occur. > > + > > +**/ > > +EFI_STATUS > > +EFIAPI > > +RedfishPutResource ( > > + IN EDKII_REDFISH_HTTP_PROTOCOL *This, > > + IN REDFISH_SERVICE Service, > > + IN EFI_STRING Uri, > > + IN CHAR8 *Content, > > + IN UINTN ContentSize OPTIONAL, > > + IN CHAR8 *ContentType OPTIONAL, > > + OUT REDFISH_RESPONSE *Response > > + ) > > +{ > > + EFI_STATUS Status; > > + UINTN RetryCount; > > + REDFISH_REQUEST Request; > > + REDFISH_HTTP_CACHE_PRIVATE *Private; > > + > > + if ((This =3D=3D NULL) || (Service =3D=3D NULL) || (Response =3D=3D = NULL) || > > IS_EMPTY_STRING (Uri) || IS_EMPTY_STRING (Content)) { > > + return EFI_INVALID_PARAMETER; > > + } > > + > > + DEBUG ((REDFISH_HTTP_CACHE_DEBUG, "%a: Put URI: %s\n", __func__, > > Uri)); > > + > > + Private =3D REDFISH_HTTP_CACHE_PRIVATE_FROM_THIS (This); > > + RetryCount =3D 0; > > + ZeroMem (Response, sizeof (REDFISH_RESPONSE)); > > + ZeroMem (&Request, sizeof (REDFISH_REQUEST)); > > + > > + Request.Content =3D Content; > > + Request.ContentLength =3D ContentSize; > > + Request.ContentType =3D ContentType; > > + > > + // > > + // Patch resource to redfish service. > > + // > > + do { > > + RetryCount +=3D 1; > > + Status =3D HttpSendReceive ( > > + Service, > > + Uri, > > + HttpMethodPut, > > + &Request, > > + Response > > + ); > > + DEBUG ((REDFISH_HTTP_CACHE_DEBUG_REQUEST, "%a: HTTP request: > > %s :%r\n", __func__, Uri, Status)); > > + if (!EFI_ERROR (Status) || (RetryCount >=3D Private- > > >RetrySetting.MaximumRetryPut)) { > > + break; > > + } > > + > > + // > > + // Retry when BMC is not ready. > > + // > > + if ((Response->StatusCode !=3D NULL)) { > > + DEBUG_CODE ( > > + DumpRedfishResponse (NULL, DEBUG_ERROR, Response); > > + ); > > + > > + if (!RedfishRetryRequired (Response->StatusCode)) { > > + break; > > + } > > + > > + // > > + // Release response for next round of request. > > + // > > + This->FreeResponse (This, Response); > > + } > > + > > + DEBUG ((DEBUG_WARN, "%a: RedfishPutToUri failed, retry (%d/%d)\n", > > __func__, RetryCount, Private->RetrySetting.MaximumRetryPut)); > > + if (Private->RetrySetting.RetryWait > 0) { > > + gBS->Stall (Private->RetrySetting.RetryWait); > > + } > > + } while (TRUE); > > + > > + // > > + // Redfish resource is updated. Automatically expire the cached resp= onse > > + // so application can directly get resource from Redfish service aga= in. > > + // > > + DEBUG ((REDFISH_HTTP_CACHE_DEBUG, "%a: Resource is updated, expire > > URI: %s\n", __func__, Uri)); > > + RedfishExpireResponse (This, Uri); > > + > > + if (EFI_ERROR (Status)) { > > + DEBUG_CODE ( > > + DumpRedfishResponse (NULL, DEBUG_ERROR, Response); > > + ); > > + // > > + // Report status code for Redfish failure > > + // > > + ReportHttpError (HttpMethodPut, Uri, Response->StatusCode); > > + DEBUG ((DEBUG_ERROR, "%a: put %s failed (%d/%d): %r\n", __func__, > > Uri, RetryCount, Private->RetrySetting.MaximumRetryPut, Status)); > > + goto ON_RELEASE; > > + } > > + > > +ON_RELEASE: > > + > > + return Status; > > +} > > + > > +/** > > + Perform HTTP POST to send redfish resource to given resource URI. > > + It's caller's responsibility to free Response by calling FreeRespons= e (). > > + > > + @param[in] This Pointer to EDKII_REDFISH_HTTP_PROTOCOL ins= tance. > > + @param[in] Service Redfish service instance to perform HTTP P= OST. > > + @param[in] Uri Target resource URI. > > + @param[in] Content Data to post. > > + @param[in] ContentSize Size of the Content to be send to Redfish = service. > > + This is optional. When ContentSize is 0, C= ontentSize > > + is the size of Content. > > + @param[in] ContentType Type of the Content to be send to Redfish > > service. > > + This is optional. When ContentType is NULL= , content > > + type HTTP_CONTENT_TYPE_APP_JSON will be us= ed. > > + @param[out] Response HTTP response from redfish service. > > + > > + @retval EFI_SUCCESS Resrouce is returned successfully. > > + @retval Others Errors occur. > > + > > +**/ > > +EFI_STATUS > > +EFIAPI > > +RedfishPostResource ( > > + IN EDKII_REDFISH_HTTP_PROTOCOL *This, > > + IN REDFISH_SERVICE Service, > > + IN EFI_STRING Uri, > > + IN CHAR8 *Content, > > + IN UINTN ContentSize OPTIONAL, > > + IN CHAR8 *ContentType OPTIONAL, > > + OUT REDFISH_RESPONSE *Response > > + ) > > +{ > > + EFI_STATUS Status; > > + UINTN RetryCount; > > + REDFISH_REQUEST Request; > > + REDFISH_HTTP_CACHE_PRIVATE *Private; > > + > > + if ((This =3D=3D NULL) || (Service =3D=3D NULL) || (Response =3D=3D = NULL) || > > IS_EMPTY_STRING (Uri) || IS_EMPTY_STRING (Content)) { > > + return EFI_INVALID_PARAMETER; > > + } > > + > > + DEBUG ((REDFISH_HTTP_CACHE_DEBUG, "%a: Post URI: %s\n", __func__, > > Uri)); > > + > > + Private =3D REDFISH_HTTP_CACHE_PRIVATE_FROM_THIS (This); > > + RetryCount =3D 0; > > + ZeroMem (Response, sizeof (REDFISH_RESPONSE)); > > + ZeroMem (&Request, sizeof (REDFISH_REQUEST)); > > + > > + Request.Content =3D Content; > > + Request.ContentLength =3D ContentSize; > > + Request.ContentType =3D ContentType; > > + > > + // > > + // Patch resource to redfish service. > > + // > > + do { > > + RetryCount +=3D 1; > > + Status =3D HttpSendReceive ( > > + Service, > > + Uri, > > + HttpMethodPost, > > + &Request, > > + Response > > + ); > > + DEBUG ((REDFISH_HTTP_CACHE_DEBUG_REQUEST, "%a: HTTP request: > > %s :%r\n", __func__, Uri, Status)); > > + if (!EFI_ERROR (Status) || (RetryCount >=3D Private- > > >RetrySetting.MaximumRetryPost)) { > > + break; > > + } > > + > > + // > > + // Retry when BMC is not ready. > > + // > > + if ((Response->StatusCode !=3D NULL)) { > > + DEBUG_CODE ( > > + DumpRedfishResponse (NULL, DEBUG_ERROR, Response); > > + ); > > + > > + if (!RedfishRetryRequired (Response->StatusCode)) { > > + break; > > + } > > + > > + // > > + // Release response for next round of request. > > + // > > + This->FreeResponse (This, Response); > > + } > > + > > + DEBUG ((DEBUG_WARN, "%a: RedfishPostToUri failed, retry (%d/%d)\n"= , > > __func__, RetryCount, Private->RetrySetting.MaximumRetryPost)); > > + if (Private->RetrySetting.RetryWait > 0) { > > + gBS->Stall (Private->RetrySetting.RetryWait); > > + } > > + } while (TRUE); > > + > > + // > > + // Redfish resource is updated. Automatically expire the cached resp= onse > > + // so application can directly get resource from Redfish service aga= in. > > + // > > + DEBUG ((REDFISH_HTTP_CACHE_DEBUG, "%a: Resource is updated, expire > > URI: %s\n", __func__, Uri)); > > + RedfishExpireResponse (This, Uri); > > + > > + if (EFI_ERROR (Status)) { > > + DEBUG_CODE ( > > + DumpRedfishResponse (NULL, DEBUG_ERROR, Response); > > + ); > > + // > > + // Report status code for Redfish failure > > + // > > + ReportHttpError (HttpMethodPost, Uri, Response->StatusCode); > > + DEBUG ((DEBUG_ERROR, "%a: post %s failed (%d/%d): %r\n", __func__, > > Uri, RetryCount, Private->RetrySetting.MaximumRetryPost, Status)); > > + goto ON_RELEASE; > > + } > > + > > +ON_RELEASE: > > + > > + return Status; > > +} > > + > > +/** > > + Perform HTTP DELETE to delete redfish resource on given resource URI= . > > + It's caller's responsibility to free Response by calling FreeRespons= e (). > > + > > + @param[in] This Pointer to EDKII_REDFISH_HTTP_PROTOCOL ins= tance. > > + @param[in] Service Redfish service instance to perform HTTP D= ELETE. > > + @param[in] Uri Target resource URI. > > + @param[in] Content JSON represented properties to be deleted.= This is > > + optional. > > + @param[in] ContentSize Size of the Content to be send to Redfish = service. > > + This is optional. When ContentSize is 0, C= ontentSize > > + is the size of Content if Content is not N= ULL. > > + @param[in] ContentType Type of the Content to be send to Redfish > > service. > > + This is optional. When Content is not NULL= and > > + ContentType is NULL, content type > > HTTP_CONTENT_TYPE_APP_JSON > > + will be used. > > + @param[out] Response HTTP response from redfish service. > > + > > + @retval EFI_SUCCESS Resrouce is returned successfully. > > + @retval Others Errors occur. > > + > > +**/ > > +EFI_STATUS > > +EFIAPI > > +RedfishDeleteResource ( > > + IN EDKII_REDFISH_HTTP_PROTOCOL *This, > > + IN REDFISH_SERVICE Service, > > + IN EFI_STRING Uri, > > + IN CHAR8 *Content OPTIONAL, > > + IN UINTN ContentSize OPTIONAL, > > + IN CHAR8 *ContentType OPTIONAL, > > + OUT REDFISH_RESPONSE *Response > > + ) > > +{ > > + EFI_STATUS Status; > > + UINTN RetryCount; > > + REDFISH_REQUEST Request; > > + REDFISH_HTTP_CACHE_PRIVATE *Private; > > + > > + if ((This =3D=3D NULL) || (Service =3D=3D NULL) || (Response =3D=3D = NULL) || > > IS_EMPTY_STRING (Uri)) { > > + return EFI_INVALID_PARAMETER; > > + } > > + > > + DEBUG ((REDFISH_HTTP_CACHE_DEBUG, "%a: Delete URI: %s\n", __func__, > > Uri)); > > + > > + Private =3D REDFISH_HTTP_CACHE_PRIVATE_FROM_THIS (This); > > + RetryCount =3D 0; > > + ZeroMem (Response, sizeof (REDFISH_RESPONSE)); > > + ZeroMem (&Request, sizeof (REDFISH_REQUEST)); > > + > > + Request.Content =3D Content; > > + Request.ContentLength =3D ContentSize; > > + Request.ContentType =3D ContentType; > > + > > + // > > + // Patch resource to redfish service. > > + // > > + do { > > + RetryCount +=3D 1; > > + Status =3D HttpSendReceive ( > > + Service, > > + Uri, > > + HttpMethodDelete, > > + &Request, > > + Response > > + ); > > + DEBUG ((REDFISH_HTTP_CACHE_DEBUG_REQUEST, "%a: HTTP request: > > %s :%r\n", __func__, Uri, Status)); > > + if (!EFI_ERROR (Status) || (RetryCount >=3D Private- > > >RetrySetting.MaximumRetryDelete)) { > > + break; > > + } > > + > > + // > > + // Retry when BMC is not ready. > > + // > > + if ((Response->StatusCode !=3D NULL)) { > > + DEBUG_CODE ( > > + DumpRedfishResponse (NULL, DEBUG_ERROR, Response); > > + ); > > + > > + if (!RedfishRetryRequired (Response->StatusCode)) { > > + break; > > + } > > + > > + // > > + // Release response for next round of request. > > + // > > + This->FreeResponse (This, Response); > > + } > > + > > + DEBUG ((DEBUG_WARN, "%a: RedfishDeleteByUri failed, retry > > (%d/%d)\n", __func__, RetryCount, Private- > > >RetrySetting.MaximumRetryDelete)); > > + if (Private->RetrySetting.RetryWait > 0) { > > + gBS->Stall (Private->RetrySetting.RetryWait); > > + } > > + } while (TRUE); > > + > > + // > > + // Redfish resource is updated. Automatically expire the cached resp= onse > > + // so application can directly get resource from Redfish service aga= in. > > + // > > + DEBUG ((REDFISH_HTTP_CACHE_DEBUG, "%a: Resource is updated, expire > > URI: %s\n", __func__, Uri)); > > + RedfishExpireResponse (This, Uri); > > + > > + if (EFI_ERROR (Status)) { > > + DEBUG_CODE ( > > + DumpRedfishResponse (NULL, DEBUG_ERROR, Response); > > + ); > > + // > > + // Report status code for Redfish failure > > + // > > + ReportHttpError (HttpMethodDelete, Uri, Response->StatusCode); > > + DEBUG ((DEBUG_ERROR, "%a: delete %s failed (%d/%d): %r\n", __func_= _, > > Uri, RetryCount, Private->RetrySetting.MaximumRetryDelete, Status)); > > + goto ON_RELEASE; > > + } > > + > > +ON_RELEASE: > > + > > + return Status; > > +} > > + > > +EDKII_REDFISH_HTTP_PROTOCOL mEdkIIRedfishHttpProtocol =3D { > > + EDKII_REDFISH_HTTP_PROTOCOL_REVISION, > > + RedfishCreateRedfishService, > > + RedfishFreeRedfishService, > > + RedfishJsonInRedfishPayload, > > + RedfishGetResource, > > + RedfishPatchResource, > > + RedfishPutResource, > > + RedfishPostResource, > > + RedfishDeleteResource, > > + RedfishFreeRequest, > > + RedfishFreeResponse, > > + RedfishExpireResponse > > +}; > > + > > +/** > > + Unloads an image. > > + > > + @param[in] ImageHandle Handle that identifies the image to = be > > unloaded. > > + > > + @retval EFI_SUCCESS The image has been unloaded. > > + @retval EFI_INVALID_PARAMETER ImageHandle is not a valid image > > handle. > > + > > +**/ > > +EFI_STATUS > > +EFIAPI > > +RedfishHttpDriverUnload ( > > + IN EFI_HANDLE ImageHandle > > + ) > > +{ > > + if (mRedfishHttpCachePrivate =3D=3D NULL) { > > + return EFI_SUCCESS; > > + } > > + > > + if (!IsListEmpty (&mRedfishHttpCachePrivate->CacheList.Head)) { > > + ReleaseCacheList (&mRedfishHttpCachePrivate->CacheList); > > + } > > + > > + gBS->UninstallMultipleProtocolInterfaces ( > > + ImageHandle, > > + &gEdkIIRedfishHttpProtocolGuid, > > + &mRedfishHttpCachePrivate->Protocol, > > + NULL > > + ); > > + > > + FreePool (mRedfishHttpCachePrivate); > > + mRedfishHttpCachePrivate =3D NULL; > > + > > + return EFI_SUCCESS; > > +} > > + > > +/** > > + This is a EDKII_REDFISH_CREDENTIAL_PROTOCOL notification event handl= er. > > + > > + @param[in] Event Event whose notification function is being invok= ed. > > + @param[in] Context Pointer to the notification function's context. > > + > > +**/ > > +VOID > > +EFIAPI > > +CredentialProtocolInstalled ( > > + IN EFI_EVENT Event, > > + IN VOID *Context > > + ) > > +{ > > + EFI_STATUS Status; > > + REDFISH_HTTP_CACHE_PRIVATE *Private; > > + > > + Private =3D (REDFISH_HTTP_CACHE_PRIVATE *)Context; > > + if (Private->Signature !=3D REDFISH_HTTP_DRIVER_SIGNATURE) { > > + DEBUG ((DEBUG_ERROR, "%a: signature check failure\n", __func__)); > > + return; > > + } > > + > > + // > > + // Locate HII database protocol. > > + // > > + Status =3D gBS->LocateProtocol ( > > + &gEdkIIRedfishCredentialProtocolGuid, > > + NULL, > > + (VOID **)&Private->CredentialProtocol > > + ); > > + if (EFI_ERROR (Status)) { > > + return; > > + } > > + > > + gBS->CloseEvent (Event); > > +} > > + > > +/** > > + Main entry for this driver. > > + > > + @param[in] ImageHandle Image handle this driver. > > + @param[in] SystemTable Pointer to SystemTable. > > + > > + @retval EFI_SUCCESS This function always complete successfully. > > + > > +**/ > > +EFI_STATUS > > +EFIAPI > > +RedfishHttpEntryPoint ( > > + IN EFI_HANDLE ImageHandle, > > + IN EFI_SYSTEM_TABLE *SystemTable > > + ) > > +{ > > + EFI_STATUS Status; > > + VOID *Registration; > > + > > + if (mRedfishHttpCachePrivate !=3D NULL) { > > + return EFI_ALREADY_STARTED; > > + } > > + > > + mRedfishHttpCachePrivate =3D AllocateZeroPool (sizeof > > (REDFISH_HTTP_CACHE_PRIVATE)); > > + if (mRedfishHttpCachePrivate =3D=3D NULL) { > > + return EFI_OUT_OF_RESOURCES; > > + } > > + > > + // > > + // Initial cache list and protocol instance. > > + // > > + mRedfishHttpCachePrivate->Signature =3D > > REDFISH_HTTP_DRIVER_SIGNATURE; > > + mRedfishHttpCachePrivate->ImageHandle =3D ImageHandle; > > + CopyMem (&mRedfishHttpCachePrivate->Protocol, > > &mEdkIIRedfishHttpProtocol, sizeof (EDKII_REDFISH_HTTP_PROTOCOL)); > > + mRedfishHttpCachePrivate->CacheList.Capacity =3D > > REDFISH_HTTP_CACHE_LIST_SIZE; > > + mRedfishHttpCachePrivate->CacheList.Count =3D 0x00; > > + mRedfishHttpCachePrivate->CacheDisabled =3D PcdGetBool > > (PcdHttpCacheDisabled); > > + InitializeListHead (&mRedfishHttpCachePrivate->CacheList.Head); > > + > > + // > > + // Get retry settings > > + // > > + mRedfishHttpCachePrivate->RetrySetting.MaximumRetryGet =3D PcdGet= 16 > > (PcdHttpGetRetry); > > + mRedfishHttpCachePrivate->RetrySetting.MaximumRetryPut =3D PcdGet= 16 > > (PcdHttpPutRetry); > > + mRedfishHttpCachePrivate->RetrySetting.MaximumRetryPatch =3D PcdGet= 16 > > (PcdHttpPatchRetry); > > + mRedfishHttpCachePrivate->RetrySetting.MaximumRetryPost =3D PcdGet= 16 > > (PcdHttpPostRetry); > > + mRedfishHttpCachePrivate->RetrySetting.MaximumRetryDelete =3D PcdGet= 16 > > (PcdHttpDeleteRetry); > > + mRedfishHttpCachePrivate->RetrySetting.RetryWait =3D PcdGet= 16 > > (PcdHttpRetryWaitInSecond) * 1000000U; > > + > > + // > > + // Install the gEdkIIRedfishHttpProtocolGuid onto Handle. > > + // > > + Status =3D gBS->InstallMultipleProtocolInterfaces ( > > + &mRedfishHttpCachePrivate->ImageHandle, > > + &gEdkIIRedfishHttpProtocolGuid, > > + &mRedfishHttpCachePrivate->Protocol, > > + NULL > > + ); > > + if (EFI_ERROR (Status)) { > > + DEBUG ((DEBUG_ERROR, "%a: cannot install Redfish http protocol: %r= \n", > > __func__, Status)); > > + RedfishHttpDriverUnload (ImageHandle); > > + return Status; > > + } > > + > > + // > > + // Install protocol notification if credential protocol is installed= . > > + // > > + mRedfishHttpCachePrivate->NotifyEvent =3D EfiCreateProtocolNotifyEve= nt ( > > + &gEdkIIRedfishCredentialPr= otocolGuid, > > + TPL_CALLBACK, > > + CredentialProtocolInstalle= d, > > + mRedfishHttpCachePrivate, > > + &Registration > > + ); > > + if (mRedfishHttpCachePrivate->NotifyEvent =3D=3D NULL) { > > + DEBUG ((DEBUG_ERROR, "%a: failed to create protocol notification f= or > > gEdkIIRedfishCredentialProtocolGuid\n", __func__)); > > + ASSERT (FALSE); > > + RedfishHttpDriverUnload (ImageHandle); > > + return Status; > > + } > > + > > + return EFI_SUCCESS; > > +} > > diff --git a/RedfishPkg/RedfishHttpDxe/RedfishHttpOperation.c > > b/RedfishPkg/RedfishHttpDxe/RedfishHttpOperation.c > > new file mode 100644 > > index 0000000000..5652818d16 > > --- /dev/null > > +++ b/RedfishPkg/RedfishHttpDxe/RedfishHttpOperation.c > > @@ -0,0 +1,693 @@ > > +/** @file > > + RedfishHttpOperation handles HTTP operations. > > + > > + Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights > > reserved. > > + > > + SPDX-License-Identifier: BSD-2-Clause-Patent > > + > > +**/ > > + > > +#include "RedfishHttpOperation.h" > > +#include "RedfishHttpData.h" > > + > > +/** > > + This function copies all headers in SrcHeaders to DstHeaders. > > + It's call responsibility to release returned DstHeaders. > > + > > + @param[in] SrcHeaders Source headers. > > + @param[in] SrcHeaderCount Number of header in source headers. > > + @param[out] DstHeaders Destination headers. > > + @param[out] DstHeaderCount Number of header in designation headers. > > + > > + @retval EFI_SUCCESS Headers are copied successfully. > > + @retval Others Errors occur. > > + > > +**/ > > +EFI_STATUS > > +CopyHttpHeaders ( > > + IN EFI_HTTP_HEADER *SrcHeaders, > > + IN UINTN SrcHeaderCount, > > + OUT EFI_HTTP_HEADER **DstHeaders, > > + OUT UINTN *DstHeaderCount > > + ) > > +{ > > + UINTN Index; > > + > > + if ((SrcHeaders =3D=3D NULL) || (SrcHeaderCount =3D=3D 0) || (DstHea= ders =3D=3D NULL) > > || (DstHeaderCount =3D=3D NULL)) { > > + return EFI_INVALID_PARAMETER; > > + } > > + > > + *DstHeaderCount =3D 0; > > + *DstHeaders =3D AllocateZeroPool (sizeof (EFI_HTTP_HEADER) * > > SrcHeaderCount); > > + if (*DstHeaders =3D=3D NULL) { > > + return EFI_OUT_OF_RESOURCES; > > + } > > + > > + for (Index =3D 0; Index < SrcHeaderCount; Index++) { > > + (*DstHeaders)[Index].FieldName =3D AllocateCopyPool (AsciiStrSize > > (SrcHeaders[Index].FieldName), SrcHeaders[Index].FieldName); > > + if ((*DstHeaders)[Index].FieldName =3D=3D NULL) { > > + return EFI_OUT_OF_RESOURCES; > > + } > > + > > + (*DstHeaders)[Index].FieldValue =3D AllocateCopyPool (AsciiStrSize > > (SrcHeaders[Index].FieldValue), SrcHeaders[Index].FieldValue); > > + if ((*DstHeaders)[Index].FieldValue =3D=3D NULL) { > > + return EFI_OUT_OF_RESOURCES; > > + } > > + > > + *DstHeaderCount +=3D 1; > > + } > > + > > + return EFI_SUCCESS; > > +} > > + > > +/** > > + This function free resources in Request. Request is no longer availa= ble > > + after this function returns successfully. > > + > > + @param[in] Request HTTP request to be released. > > + > > + @retval EFI_SUCCESS Resrouce is released successfully. > > + @retval Others Errors occur. > > + > > +**/ > > +EFI_STATUS > > +ReleaseRedfishRequest ( > > + IN REDFISH_REQUEST *Request > > + ) > > +{ > > + if (Request =3D=3D NULL) { > > + return EFI_INVALID_PARAMETER; > > + } > > + > > + if ((Request->Headers !=3D NULL) && (Request->HeaderCount > 0)) { > > + HttpFreeHeaderFields (Request->Headers, Request->HeaderCount); > > + Request->Headers =3D NULL; > > + Request->HeaderCount =3D 0; > > + } > > + > > + if (Request->Content !=3D NULL) { > > + FreePool (Request->Content); > > + Request->Content =3D NULL; > > + } > > + > > + if (Request->ContentType !=3D NULL) { > > + FreePool (Request->ContentType); > > + Request->ContentType =3D NULL; > > + } > > + > > + Request->ContentLength =3D 0; > > + > > + return EFI_SUCCESS; > > +} > > + > > +/** > > + This function free resources in given Response. > > + > > + @param[in] Response HTTP response to be released. > > + > > + @retval EFI_SUCCESS Resrouce is released successfully. > > + @retval Others Errors occur. > > + > > +**/ > > +EFI_STATUS > > +ReleaseRedfishResponse ( > > + IN REDFISH_RESPONSE *Response > > + ) > > +{ > > + if (Response =3D=3D NULL) { > > + return EFI_INVALID_PARAMETER; > > + } > > + > > + if ((Response->Headers !=3D NULL) && (Response->HeaderCount > 0)) { > > + HttpFreeHeaderFields (Response->Headers, Response->HeaderCount); > > + Response->Headers =3D NULL; > > + Response->HeaderCount =3D 0; > > + } > > + > > + if (Response->Payload !=3D NULL) { > > + ReleaseRedfishPayload (Response->Payload); > > + Response->Payload =3D NULL; > > + } > > + > > + if (Response->StatusCode !=3D NULL) { > > + FreePool (Response->StatusCode); > > + Response->StatusCode =3D NULL; > > + } > > + > > + return EFI_SUCCESS; > > +} > > + > > +/** > > + This function free resources in given HTTP message. > > + > > + @param[in] HttpMessage HTTP message to be released. > > + @param[in] IsRequest TRUE if this is request type of HTTP mes= sage. > > + FALSE if this is response type of HTTP m= essage. > > + > > + @retval EFI_SUCCESS Resrouce is released successfully. > > + @retval Others Errors occur. > > + > > +**/ > > +EFI_STATUS > > +ReleaseHttpMessage ( > > + IN EFI_HTTP_MESSAGE *HttpMessage, > > + IN BOOLEAN IsRequest > > + ) > > +{ > > + if (HttpMessage =3D=3D NULL) { > > + return EFI_INVALID_PARAMETER; > > + } > > + > > + if (IsRequest) { > > + if (HttpMessage->Data.Request !=3D NULL) { > > + if (HttpMessage->Data.Request->Url !=3D NULL) { > > + FreePool (HttpMessage->Data.Request->Url); > > + } > > + > > + FreePool (HttpMessage->Data.Request); > > + HttpMessage->Data.Request =3D NULL; > > + } > > + } else { > > + if (HttpMessage->Data.Response !=3D NULL) { > > + FreePool (HttpMessage->Data.Response); > > + HttpMessage->Data.Response =3D NULL; > > + } > > + } > > + > > + if (HttpMessage->Body !=3D NULL) { > > + FreePool (HttpMessage->Body); > > + HttpMessage->Body =3D NULL; > > + } > > + > > + if (HttpMessage->Headers !=3D NULL) { > > + HttpFreeHeaderFields (HttpMessage->Headers, HttpMessage- > > >HeaderCount); > > + HttpMessage->Headers =3D NULL; > > + HttpMessage->HeaderCount =3D 0; > > + } > > + > > + return EFI_SUCCESS; > > +} > > + > > +/** > > + This function build Redfish message for sending data to Redfish serv= ice. > > + It's call responsibility to properly release returned HTTP message b= y > > + calling ReleaseHttpMessage. > > + > > + @param[in] ServicePrivate Pointer to Redfish service private da= ta. > > + @param[in] Uri Redfish service URI. > > + @param[in] Method HTTP method. > > + @param[in] Request Additional data to send to Redfish se= rvice. > > + This is optional. > > + @param[in] ContentEncoding Content encoding method to compress > > HTTP context. > > + This is optional. When ContentEncodin= g is NULL, > > + No compress method will be performed. > > + > > + @retval EFI_HTTP_MESSAGE * Pointer to newly created HTTP messa= ge. > > + @retval NULL Error occurred. > > + > > +**/ > > +EFI_HTTP_MESSAGE * > > +BuildRequestMessage ( > > + IN REDFISH_SERVICE_PRIVATE *ServicePrivate, > > + IN EFI_STRING Uri, > > + IN EFI_HTTP_METHOD Method, > > + IN REDFISH_REQUEST *Request OPTIONAL, > > + IN CHAR8 *ContentEncoding OPTIONAL > > + ) > > +{ > > + EFI_STATUS Status; > > + EFI_STRING Url; > > + UINTN UrlSize; > > + UINTN Index; > > + EFI_HTTP_MESSAGE *RequestMsg; > > + EFI_HTTP_REQUEST_DATA *RequestData; > > + UINTN HeaderCount; > > + UINTN HeaderIndex; > > + EFI_HTTP_HEADER *Headers; > > + CHAR8 ContentLengthStr[REDFISH_CONTENT_LENGTH_SIZE]= ; > > + VOID *Content; > > + UINTN ContentLength; > > + BOOLEAN HasContent; > > + BOOLEAN DoContentEncoding; > > + > > + RequestMsg =3D NULL; > > + RequestData =3D NULL; > > + Url =3D NULL; > > + UrlSize =3D 0; > > + Content =3D NULL; > > + ContentLength =3D 0; > > + HeaderCount =3D REDFISH_COMMON_HEADER_SIZE; > > + HeaderIndex =3D 0; > > + Headers =3D NULL; > > + HasContent =3D FALSE; > > + DoContentEncoding =3D FALSE; > > + > > + if ((ServicePrivate =3D=3D NULL) || (IS_EMPTY_STRING (Uri))) { > > + return NULL; > > + } > > + > > + if (Method >=3D HttpMethodMax) { > > + return NULL; > > + } > > + > > + DEBUG ((REDFISH_HTTP_CACHE_DEBUG_REQUEST, "%a: %s\n", __func__, > > Uri)); > > + > > + // > > + // Build full URL for HTTP query. > > + // > > + UrlSize =3D (AsciiStrLen (ServicePrivate->Host) + StrLen (Uri) + 1) = * sizeof > > (CHAR16); > > + Url =3D AllocateZeroPool (UrlSize); > > + if (Url =3D=3D NULL) { > > + return NULL; > > + } > > + > > + UnicodeSPrint (Url, UrlSize, L"%a%s", ServicePrivate->Host, Uri); > > + DEBUG ((REDFISH_HTTP_CACHE_DEBUG_REQUEST, "%a: Url: %s\n", > > __func__, Url)); > > + > > + // > > + // Step 1: build the HTTP headers. > > + // > > + if (!IS_EMPTY_STRING (ServicePrivate->SessionToken) > > || !IS_EMPTY_STRING (ServicePrivate->BasicAuth)) { > > + HeaderCount++; > > + } > > + > > + if ((Request !=3D NULL) && (Request->HeaderCount > 0)) { > > + HeaderCount +=3D Request->HeaderCount; > > + } > > + > > + // > > + // Check and see if we will do content encoding or not > > + // > > + if (!IS_EMPTY_STRING (ContentEncoding)) { > > + if (AsciiStrCmp (ContentEncoding, > > REDFISH_HTTP_CONTENT_ENCODING_NONE) !=3D 0) { > > + DoContentEncoding =3D TRUE; > > + } > > + } > > + > > + if ((Request !=3D NULL) && !IS_EMPTY_STRING (Request->Content)) { > > + HeaderCount +=3D 2; > > + HasContent =3D TRUE; > > + if (DoContentEncoding) { > > + HeaderCount +=3D 1; > > + } > > + } > > + > > + Headers =3D AllocateZeroPool (HeaderCount * sizeof (EFI_HTTP_HEADER)= ); > > + if (Headers =3D=3D NULL) { > > + goto ON_ERROR; > > + } > > + > > + if (!IS_EMPTY_STRING (ServicePrivate->SessionToken)) { > > + Status =3D HttpSetFieldNameAndValue (&Headers[HeaderIndex++], > > HTTP_HEADER_X_AUTH_TOKEN, ServicePrivate->SessionToken); > > + if (EFI_ERROR (Status)) { > > + goto ON_ERROR; > > + } > > + } else if (!IS_EMPTY_STRING (ServicePrivate->BasicAuth)) { > > + Status =3D HttpSetFieldNameAndValue (&Headers[HeaderIndex++], > > HTTP_HEADER_AUTHORIZATION, ServicePrivate->BasicAuth); > > + if (EFI_ERROR (Status)) { > > + goto ON_ERROR; > > + } > > + } > > + > > + if (Request !=3D NULL) { > > + for (Index =3D 0; Index < Request->HeaderCount; Index++) { > > + Status =3D HttpSetFieldNameAndValue (&Headers[HeaderIndex++], > > Request->Headers[Index].FieldName, Request->Headers[Index].FieldValue); > > + if (EFI_ERROR (Status)) { > > + goto ON_ERROR; > > + } > > + } > > + } > > + > > + Status =3D HttpSetFieldNameAndValue (&Headers[HeaderIndex++], > > HTTP_HEADER_HOST, ServicePrivate->HostName); > > + if (EFI_ERROR (Status)) { > > + goto ON_ERROR; > > + } > > + > > + Status =3D HttpSetFieldNameAndValue (&Headers[HeaderIndex++], > > REDFISH_HTTP_HEADER_ODATA_VERSION_STR, > > REDFISH_HTTP_HEADER_ODATA_VERSION_VALUE); > > + if (EFI_ERROR (Status)) { > > + goto ON_ERROR; > > + } > > + > > + Status =3D HttpSetFieldNameAndValue (&Headers[HeaderIndex++], > > HTTP_HEADER_ACCEPT, HTTP_CONTENT_TYPE_APP_JSON); > > + if (EFI_ERROR (Status)) { > > + goto ON_ERROR; > > + } > > + > > + Status =3D HttpSetFieldNameAndValue (&Headers[HeaderIndex++], > > HTTP_HEADER_USER_AGENT, > > REDFISH_HTTP_HEADER_USER_AGENT_VALUE); > > + if (EFI_ERROR (Status)) { > > + goto ON_ERROR; > > + } > > + > > + Status =3D HttpSetFieldNameAndValue (&Headers[HeaderIndex++], > > REDFISH_HTTP_HEADER_CONNECTION_STR, > > REDFISH_HTTP_HEADER_CONNECTION_VALUE); > > + if (EFI_ERROR (Status)) { > > + goto ON_ERROR; > > + } > > + > > + // > > + // Handle content header > > + // > > + if (HasContent) { > > + if (Request->ContentType =3D=3D NULL) { > > + Status =3D HttpSetFieldNameAndValue (&Headers[HeaderIndex++], > > HTTP_HEADER_CONTENT_TYPE, HTTP_CONTENT_TYPE_APP_JSON); > > + if (EFI_ERROR (Status)) { > > + goto ON_ERROR; > > + } > > + } else { > > + Status =3D HttpSetFieldNameAndValue (&Headers[HeaderIndex++], > > HTTP_HEADER_CONTENT_TYPE, Request->ContentType); > > + if (EFI_ERROR (Status)) { > > + goto ON_ERROR; > > + } > > + } > > + > > + if (Request->ContentLength =3D=3D 0) { > > + Request->ContentLength =3D AsciiStrLen (Request->Content); > > + } > > + > > + AsciiSPrint ( > > + ContentLengthStr, > > + sizeof (ContentLengthStr), > > + "%lu", > > + (UINT64)Request->ContentLength > > + ); > > + Status =3D HttpSetFieldNameAndValue (&Headers[HeaderIndex++], > > HTTP_HEADER_CONTENT_LENGTH, ContentLengthStr); > > + if (EFI_ERROR (Status)) { > > + goto ON_ERROR; > > + } > > + > > + // > > + // Encoding > > + // > > + if (DoContentEncoding) { > > + // > > + // We currently only support gzip Content-Encoding. > > + // > > + Status =3D RedfishContentEncode ( > > + ContentEncoding, > > + Request->Content, > > + Request->ContentLength, > > + &Content, > > + &ContentLength > > + ); > > + if (Status =3D=3D EFI_INVALID_PARAMETER) { > > + DEBUG ((DEBUG_ERROR, "%a: Error to encode content.\n", __func_= _)); > > + goto ON_ERROR; > > + } else if (Status =3D=3D EFI_UNSUPPORTED) { > > + DoContentEncoding =3D FALSE; > > + DEBUG ((REDFISH_HTTP_CACHE_DEBUG_REQUEST, "%a: No content > > coding for %a! Use raw data instead.\n", __func__, ContentEncoding)); > > + Status =3D HttpSetFieldNameAndValue (&Headers[HeaderIndex++], > > HTTP_HEADER_CONTENT_ENCODING, > > HTTP_CONTENT_ENCODING_IDENTITY); > > + if (EFI_ERROR (Status)) { > > + goto ON_ERROR; > > + } > > + } else { > > + Status =3D HttpSetFieldNameAndValue (&Headers[HeaderIndex++], > > HTTP_HEADER_CONTENT_ENCODING, HTTP_CONTENT_ENCODING_GZIP); > > + if (EFI_ERROR (Status)) { > > + goto ON_ERROR; > > + } > > + } > > + } > > + > > + // > > + // When the content is from caller, we use our own copy so that we > > properly release it later. > > + // > > + if (!DoContentEncoding) { > > + Content =3D AllocateCopyPool (Request->ContentLength, Request- > > >Content); > > + if (Content =3D=3D NULL) { > > + goto ON_ERROR; > > + } > > + > > + ContentLength =3D Request->ContentLength; > > + } > > + } > > + > > + // > > + // Step 2: build the rest of HTTP request info. > > + // > > + RequestData =3D AllocateZeroPool (sizeof (EFI_HTTP_REQUEST_DATA)); > > + if (RequestData =3D=3D NULL) { > > + goto ON_ERROR; > > + } > > + > > + RequestData->Method =3D Method; > > + RequestData->Url =3D Url; > > + > > + // > > + // Step 3: fill in EFI_HTTP_MESSAGE > > + // > > + RequestMsg =3D AllocateZeroPool (sizeof (EFI_HTTP_MESSAGE)); > > + if (RequestMsg =3D=3D NULL) { > > + goto ON_ERROR; > > + } > > + > > + ASSERT (HeaderIndex =3D=3D HeaderCount); > > + RequestMsg->Data.Request =3D RequestData; > > + RequestMsg->HeaderCount =3D HeaderIndex; > > + RequestMsg->Headers =3D Headers; > > + > > + if (HasContent) { > > + RequestMsg->BodyLength =3D ContentLength; > > + RequestMsg->Body =3D Content; > > + } > > + > > + return RequestMsg; > > + > > +ON_ERROR: > > + > > + if (Headers !=3D NULL) { > > + HttpFreeHeaderFields (Headers, HeaderIndex); > > + } > > + > > + if (RequestData !=3D NULL) { > > + FreePool (RequestData); > > + } > > + > > + if (RequestMsg !=3D NULL) { > > + FreePool (RequestMsg); > > + } > > + > > + if (Url !=3D NULL) { > > + FreePool (Url); > > + } > > + > > + return NULL; > > +} > > + > > +/** > > + This function parse response message from Redfish service, and > > + build Redfish response for caller. It's call responsibility to > > + properly release Redfish response by calling ReleaseRedfishResponse. > > + > > + @param[in] ServicePrivate Pointer to Redfish service private dat= a. > > + @param[in] ResponseMsg Response message from Redfish service. > > + @param[out] RedfishResponse Redfish response data. > > + > > + @retval EFI_SUCCESS Redfish response is returned successfull= y. > > + @retval Others Errors occur. > > + > > +**/ > > +EFI_STATUS > > +ParseResponseMessage ( > > + IN REDFISH_SERVICE_PRIVATE *ServicePrivate, > > + IN EFI_HTTP_MESSAGE *ResponseMsg, > > + OUT REDFISH_RESPONSE *RedfishResponse > > + ) > > +{ > > + EFI_STATUS Status; > > + EDKII_JSON_VALUE JsonData; > > + EFI_HTTP_HEADER *ContentEncodedHeader; > > + VOID *DecodedBody; > > + UINTN DecodedLength; > > + > > + if ((ServicePrivate =3D=3D NULL) || (ResponseMsg =3D=3D NULL) || (Re= dfishResponse > > =3D=3D NULL)) { > > + return EFI_INVALID_PARAMETER; > > + } > > + > > + DEBUG ((REDFISH_HTTP_CACHE_DEBUG_REQUEST, "%a\n", __func__)); > > + > > + // > > + // Initialization > > + // > > + JsonData =3D NULL; > > + RedfishResponse->HeaderCount =3D 0; > > + RedfishResponse->Headers =3D NULL; > > + RedfishResponse->Payload =3D NULL; > > + RedfishResponse->StatusCode =3D NULL; > > + DecodedBody =3D NULL; > > + DecodedLength =3D 0; > > + > > + // > > + // Return the HTTP StatusCode. > > + // > > + if (ResponseMsg->Data.Response !=3D NULL) { > > + DEBUG ((REDFISH_HTTP_CACHE_DEBUG_REQUEST, "%a: status: %d\n", > > __func__, ResponseMsg->Data.Response->StatusCode)); > > + RedfishResponse->StatusCode =3D AllocateCopyPool (sizeof > > (EFI_HTTP_STATUS_CODE), &ResponseMsg->Data.Response->StatusCode); > > + if (RedfishResponse->StatusCode =3D=3D NULL) { > > + DEBUG ((DEBUG_ERROR, "%a: Failed to create status code.\n", > > __func__)); > > + } > > + } > > + > > + // > > + // Return the HTTP headers. > > + // > > + if (ResponseMsg->Headers !=3D NULL) { > > + DEBUG ((REDFISH_HTTP_CACHE_DEBUG_REQUEST, "%a: header count: > > %d\n", __func__, ResponseMsg->HeaderCount)); > > + Status =3D CopyHttpHeaders ( > > + ResponseMsg->Headers, > > + ResponseMsg->HeaderCount, > > + &RedfishResponse->Headers, > > + &RedfishResponse->HeaderCount > > + ); > > + if (EFI_ERROR (Status)) { > > + DEBUG ((DEBUG_ERROR, "%a: Failed to copy HTTP headers: %r\n", > > __func__, Status)); > > + } > > + } > > + > > + // > > + // Return the HTTP body. > > + // > > + if ((ResponseMsg->BodyLength !=3D 0) && (ResponseMsg->Body !=3D NULL= )) { > > + DEBUG ((REDFISH_HTTP_CACHE_DEBUG_REQUEST, "%a: body length: > > %d\n", __func__, ResponseMsg->BodyLength)); > > + // > > + // Check if data is encoded. > > + // > > + ContentEncodedHeader =3D HttpFindHeader (RedfishResponse- > > >HeaderCount, RedfishResponse->Headers, > > HTTP_HEADER_CONTENT_ENCODING); > > + if (ContentEncodedHeader !=3D NULL) { > > + // > > + // The content is encoded. > > + // > > + Status =3D RedfishContentDecode ( > > + ContentEncodedHeader->FieldValue, > > + ResponseMsg->Body, > > + ResponseMsg->BodyLength, > > + &DecodedBody, > > + &DecodedLength > > + ); > > + if (EFI_ERROR (Status)) { > > + DEBUG ((DEBUG_ERROR, "%a: Failed to decompress the response > > content: %r decoding method: %a\n.", __func__, Status, > > ContentEncodedHeader->FieldValue)); > > + goto ON_ERROR; > > + } > > + > > + JsonData =3D JsonLoadBuffer (DecodedBody, DecodedLength, 0, NULL= ); > > + FreePool (DecodedBody); > > + } else { > > + JsonData =3D JsonLoadBuffer (ResponseMsg->Body, ResponseMsg- > > >BodyLength, 0, NULL); > > + } > > + > > + if (!JsonValueIsNull (JsonData)) { > > + RedfishResponse->Payload =3D CreateRedfishPayload (ServicePrivat= e, > > JsonData); > > + if (RedfishResponse->Payload =3D=3D NULL) { > > + DEBUG ((DEBUG_ERROR, "%a: Failed to create payload\n.", __func= __)); > > + } > > + > > + JsonValueFree (JsonData); > > + } else { > > + DEBUG ((DEBUG_ERROR, "%a: No payload available\n", __func__)); > > + } > > + } > > + > > + return EFI_SUCCESS; > > + > > +ON_ERROR: > > + > > + if (RedfishResponse !=3D NULL) { > > + ReleaseRedfishResponse (RedfishResponse); > > + } > > + > > + return Status; > > +} > > + > > +/** > > + This function send Redfish request to Redfish service by calling > > + Rest Ex protocol. > > + > > + @param[in] Service Pointer to Redfish service. > > + @param[in] Uri Uri of Redfish service. > > + @param[in] Method HTTP method. > > + @param[in] Request Request data. This is optional. > > + @param[out] Response Redfish response data. > > + > > + @retval EFI_SUCCESS Request is sent and received successfull= y. > > + @retval Others Errors occur. > > + > > +**/ > > +EFI_STATUS > > +HttpSendReceive ( > > + IN REDFISH_SERVICE Service, > > + IN EFI_STRING Uri, > > + IN EFI_HTTP_METHOD Method, > > + IN REDFISH_REQUEST *Request OPTIONAL, > > + OUT REDFISH_RESPONSE *Response > > + ) > > +{ > > + EFI_STATUS Status; > > + EFI_STATUS RestExStatus; > > + EFI_HTTP_MESSAGE *RequestMsg; > > + EFI_HTTP_MESSAGE ResponseMsg; > > + REDFISH_SERVICE_PRIVATE *ServicePrivate; > > + EFI_HTTP_HEADER *XAuthTokenHeader; > > + CHAR8 *HttpContentEncoding; > > + > > + if ((Service =3D=3D NULL) || IS_EMPTY_STRING (Uri) || (Response =3D= =3D NULL)) { > > + return EFI_INVALID_PARAMETER; > > + } > > + > > + DEBUG ((REDFISH_HTTP_CACHE_DEBUG_REQUEST, "%a: Method: 0x%x > > %s\n", __func__, Method, Uri)); > > + > > + ServicePrivate =3D (REDFISH_SERVICE_PRIVATE *)Service; > > + if (ServicePrivate->Signature !=3D REDFISH_HTTP_SERVICE_SIGNATURE) { > > + DEBUG ((DEBUG_ERROR, "%a: signature check failure\n", __func__)); > > + return EFI_INVALID_PARAMETER; > > + } > > + > > + ZeroMem (&ResponseMsg, sizeof (ResponseMsg)); > > + HttpContentEncoding =3D (CHAR8 *)PcdGetPtr > > (PcdRedfishServiceContentEncoding); > > + > > + RequestMsg =3D BuildRequestMessage (Service, Uri, Method, Request, > > HttpContentEncoding); > > + if (RequestMsg =3D=3D NULL) { > > + DEBUG ((DEBUG_ERROR, "%a: cannot build request message for %s\n", > > __func__, Uri)); > > + return EFI_PROTOCOL_ERROR; > > + } > > + > > + // > > + // call RESTEx to get response from REST service. > > + // > > + RestExStatus =3D ServicePrivate->RestEx->SendReceive (ServicePrivate= - > > >RestEx, RequestMsg, &ResponseMsg); > > + if (EFI_ERROR (RestExStatus)) { > > + DEBUG ((DEBUG_ERROR, "%a: %s SendReceive failure: %r\n", __func__, > > Uri, RestExStatus)); > > + } > > + > > + // > > + // Return status code, headers and payload to caller as much as poss= ible > > even when RestEx returns failure. > > + // > > + Status =3D ParseResponseMessage (ServicePrivate, &ResponseMsg, > > Response); > > + if (EFI_ERROR (Status)) { > > + DEBUG ((DEBUG_ERROR, "%a: %s parse response failure: %r\n", __func= __, > > Uri, Status)); > > + } else { > > + // > > + // Capture session token in header > > + // > > + if ((Method =3D=3D HttpMethodPost) && > > + (Response->StatusCode !=3D NULL) && > > + ((*Response->StatusCode =3D=3D HTTP_STATUS_200_OK) || (*Respon= se- > > >StatusCode =3D=3D HTTP_STATUS_204_NO_CONTENT))) > > + { > > + XAuthTokenHeader =3D HttpFindHeader (ResponseMsg.HeaderCount, > > ResponseMsg.Headers, HTTP_HEADER_X_AUTH_TOKEN); > > + if (XAuthTokenHeader !=3D NULL) { > > + Status =3D UpdateSessionToken (ServicePrivate, XAuthTokenHeade= r- > > >FieldValue); > > + if (EFI_ERROR (Status)) { > > + DEBUG ((DEBUG_ERROR, "%a: update session token failure: %r\n= ", > > __func__, Status)); > > + } > > + } > > + } > > + } > > + > > + // > > + // Release resources > > + // > > + if (RequestMsg !=3D NULL) { > > + ReleaseHttpMessage (RequestMsg, TRUE); > > + FreePool (RequestMsg); > > + } > > + > > + ReleaseHttpMessage (&ResponseMsg, FALSE); > > + > > + return RestExStatus; > > +} > > diff --git a/RedfishPkg/Redfish.fdf.inc b/RedfishPkg/Redfish.fdf.inc > > index 3e5a77766e..5cbe3592fd 100644 > > --- a/RedfishPkg/Redfish.fdf.inc > > +++ b/RedfishPkg/Redfish.fdf.inc > > @@ -6,7 +6,7 @@ > > # to be built in the firmware volume. > > # > > # (C) Copyright 2020-2021 Hewlett Packard Enterprise Development LP > > -# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights > > reserved. > > +# Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights > > reserved. > > # > > # SPDX-License-Identifier: BSD-2-Clause-Patent > > # > > @@ -20,4 +20,5 @@ > > INF RedfishPkg/RedfishConfigHandler/RedfishConfigHandlerDriver.inf > > INF RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.inf > > INF > > MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.inf > > + INF RedfishPkg/RedfishHttpDxe/RedfishHttpDxe.inf > > !endif > > -- > > 2.34.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 (#115781): https://edk2.groups.io/g/devel/message/115781 Mute This Topic: https://groups.io/mt/104463404/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-