From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (NAM04-DM6-obe.outbound.protection.outlook.com [40.107.102.56]) by mx.groups.io with SMTP id smtpd.web09.1767.1658799992100780274 for ; Mon, 25 Jul 2022 18:46:32 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amd.com header.s=selector1 header.b=5EwcGGBv; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: amd.com, ip: 40.107.102.56, mailfrom: abner.chang@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=e/GYxUeFVdxlOS8eY4rGEiN3RBNDGIIdhAuojvpDGjFtqEMe9BMQydOkkfmpHhG/n9IyZsHLK+hQ+3KtID1auRKs2pWPVdE0MgI24fXqWQuq9BvYAYo8aM4mweWftcvK5HTkMAqGK6AjB6fnJmAQX9gBXQREbDCTxk2t+8FFBef4WLx5snxj5cFtkWm7OZhvU6qZ9m9cRUJhToPzBP7yTWZjY0KwkAI6fkJXcch79tn3kNXEo2XJu5Y1PHGVB8TW3A1995GzwyCirYnJXiEWwjj5MYfAIbPPEDGs3RNldRJjW8AV3gjmR7sh9ka2PJ2qlE1Qyv8md9lFimIetw0j4A== 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=Kjws0hdjKhISaEiLcAAzS3tSQfzITow5becEGp7w9E0=; b=FiJgXjcDpPRM/QJ3zEol5pauKtF+eVoWFufvIy0Snmlln8ijMB8KWQA+ESgYmVkbACAoFLJbJxMgK1J4JYgNh4BxE0O4klWahpjtGgn1T41c93BlZrAj46USnEblCBfNK2pR31EPQhMVREWlRvN74g4L+tQa8Fh6u0BzoTmNMqIhdq0bamtY0oeGwVqfCKIIh5okD5vmtwX3BqlGek1mvKBP7k0rBHs8sy2Gm3s5NJGn4dd3UsZGypnktWgtIIpzEwRZIQNteIFOs8dYrAovg5Z3edn62oVQOvkS9IN48AJ0DRFFLsi8RkOXE5eh/hxGUvkFUbXe5idTP3KgkhD7gQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Kjws0hdjKhISaEiLcAAzS3tSQfzITow5becEGp7w9E0=; b=5EwcGGBvHPru+VdorDggCu3/htQ3lJailXE+y6n/+dbbx2/g/Q+pM3QdMTbLZ2zLk7LqDGNRlf58iwAU6vKjVUZgl7epFfAdrDjUQA/3VA26+B/4HQ8ml3vCLoWum7f4DMFk0hV/fBdarSCxbDGEi2Xoaac5TiU4VVVoGYha8Ac= Received: from MN2PR12MB3966.namprd12.prod.outlook.com (2603:10b6:208:165::18) by CY4PR12MB1767.namprd12.prod.outlook.com (2603:10b6:903:121::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.21; Tue, 26 Jul 2022 01:46:29 +0000 Received: from MN2PR12MB3966.namprd12.prod.outlook.com ([fe80::605a:11f4:fc16:8b06]) by MN2PR12MB3966.namprd12.prod.outlook.com ([fe80::605a:11f4:fc16:8b06%5]) with mapi id 15.20.5458.024; Tue, 26 Jul 2022 01:46:28 +0000 From: "Chang, Abner" To: Nickle Wang , "devel@edk2.groups.io" CC: "Yang, Atom" , Nick Ramirez Subject: Re: [edk2-staging][PATCH v2 02/15] edk2-staging/RedfishClientPkg: Introduce Redfish version library Thread-Topic: [edk2-staging][PATCH v2 02/15] edk2-staging/RedfishClientPkg: Introduce Redfish version library Thread-Index: AQHYn8boHPZnUnRN0kGj0VN6BW7C4q2P42Vw Date: Tue, 26 Jul 2022 01:46:28 +0000 Message-ID: References: <20220725013555.926-1-nickle.wang@hpe.com> <20220725013555.926-3-nickle.wang@hpe.com> In-Reply-To: <20220725013555.926-3-nickle.wang@hpe.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Enabled=true; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SetDate=2022-07-26T01:46:27Z; 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_SiteId=3dd8961f-e488-4e60-8e11-a82d994e183d; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ActionId=2d10ef53-abb6-433e-82aa-a8b5839a5448; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ContentBits=1 authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: be510b38-fa3b-4452-8c85-08da6ea8a8a0 x-ms-traffictypediagnostic: CY4PR12MB1767:EE_ x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: KHtlS0hdgjZLrIIK10N/17qe2ktqZ8G8pofzSh3cYkKumnL1Pl+tl5wuXz0LmgmcXGzwdz2COaChny0BPeeHF0bm9So6zG0vj3uZKZJSVPI56JwulYNs9IFozDSrGC/51XIOfGrnjQ2D9UYQkIzjRzQ1DDChPL5u7wEsxlcsUWwfsYFALsY7SLUiqBDvdue38piRlK310eoPV4PyG+dwjUXJD6pJ3oBwzo5wZyyoAG6LSjR81YNWZRIcO83u95HtBqV8YHQ262+PibgXBas4HsSs+3D29PKsmOhntVvQGCPkC40nJtCbcQkA/WFict3uYKH2khUBxTr857/WM2qU5SqHH/fBYaCnAiWsYzSfTdJizvuqlNMmWlt0wMb94OWXruwebZ4AGZsOYTw/EKMrR9iObMAnt4FCxv03Xpz4cXkCZtCl3E6Scun/KhmwZwitz+MJ09ypwVCkoUnX0CqJqK+iu9sCKVx8ctl7DNeQzdR7fSP4tCiUiiIaY7IxtBlIE5s7tG54MtigZzPKpzIlrXCAL+qVprhGjWNZcj9e3r1z+kc5XA6cvRj2AqFrbabVb5X5nMFlzmvi0MiQvQVF2zGQTGRYsIj5N4qdBTOA3jn72H4Uj+g1YFcxnFa+KfRl1e72EnUXVYkllJvIRGgy+Som42QB/FzcM5zLTVfMAGmtjkSzPBtOm1R0rg4YFYXadsOjrmNUZerX2wUHMfAA4qXYfEYVNdvvyOd7HIvMWwrQQHb1T8e02fy0iozuIgOY8uRPUZnYE2+GPfZ25wCxhQ72Pv+Z4F+/Ign4nLlKzVF5kzG7wCmcp7uQbCj3qkt3 x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN2PR12MB3966.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(346002)(366004)(39860400002)(376002)(396003)(136003)(122000001)(33656002)(8936002)(86362001)(38070700005)(52536014)(186003)(9686003)(7696005)(6506007)(83380400001)(38100700002)(53546011)(54906003)(41300700001)(110136005)(71200400001)(316002)(296002)(66476007)(76116006)(66946007)(55016003)(30864003)(64756008)(66446008)(66556008)(8676002)(4326008)(478600001)(2906002)(5660300002);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?BUa+7fHcbQIZ9NRopCgbQbImFEuyz6K0crMtMnhTG8bndYA09MWKtZbPITyH?= =?us-ascii?Q?zk9o13kTZJz4TNfk2j8guYi7c96RSWIyMxZAArdSqc5/3FQh9UPly+msgbjK?= =?us-ascii?Q?5GpKV7nW9aA1EXOpn6kCHiIfiiTqSIuFzLSjsjI/Emq7PeTKlHOyB22A/+oI?= =?us-ascii?Q?3tzSJwW86FxOxF2Au5DGTlNVY9IEzVYxoE1qR8CvlSgYKpgE8Oet3BXAiJJD?= =?us-ascii?Q?AnV2z2kcV43z0QCjKRjxVRZqpfVf7zvoOLIdB4F0fLP8m8XOVDVjpjyXBGWq?= =?us-ascii?Q?VgwQHCahH1Be931xUa+S1fwR1HCFA/hRF8vD0se+eVj7iKcpp7fpRO2PTrpw?= =?us-ascii?Q?dRpxr6Z85wGw+cEmYh8+c8tHIJYMsM5XgYxhFnFCY/pT15k6FsSbocNsofRt?= =?us-ascii?Q?4czCRJBPFmMStyO9ZRpegZO8UBcWZMVzKLLLPZ6euXcuAmf67Am2BRFfUXB2?= =?us-ascii?Q?RtavEAmeJpHtdQoZbtT5XEqb3Ol3SMXEy4EE7wYCkn96V5bFP2aWrVoB7TaD?= =?us-ascii?Q?QHbvGl+dKrnIpwJue/PbBj0act3aOt1E9Lkc8JleiJH9CBFUWjNwdGOmE3o6?= =?us-ascii?Q?gqyW3bKGdnmmBhdEyTQV3UALDE8Cm/Pva7vJAGzYP8IXiHpK9drY7K7y54oN?= =?us-ascii?Q?QefaAbpaOeDuCakA/FilFtVp0IpzLZvd/x+Vpnv09UgIxvr5TMNV4Ah/k7/p?= =?us-ascii?Q?TMN08Bo9p801BGxHy/6NTvHN2ceWICfHMZGfjMqBfB24Nl78peDrVLWIWMhp?= =?us-ascii?Q?sCbyHEu3tb9zjgTSIj/D5PYgh1qINw16juOB69jY6RGx4x5ttlrvkcsnkGj/?= =?us-ascii?Q?4+VU7XhW736PGTroBD1FlKLZPF4sZd8e9iVw04OzoC2eKP5bMe2C0jm81V1W?= =?us-ascii?Q?NcXFP1xONPFPhIQ2ZbLQXjsrpYWxk4HA5Sfz1IpxS89bMZ99qdEHcuKNaJLV?= =?us-ascii?Q?ntb+I3GfkQKK1V40Qme99HYZXo7QE68aW5M2sFEBMErgb8bXByC40Tg7h9gV?= =?us-ascii?Q?wWlwXGP42r3wYDBJT3wNLlycgPsZ4KFBuqjbCZvv8HqNL30l1r9tnTcLONks?= =?us-ascii?Q?yBsIqpqZ9RGyupGsaD/lEOA0HmwMuZff8StsjlP/oQp3GG4XUPrAUf66yhMO?= =?us-ascii?Q?XiECkO7BZRHL2AXsxUjsUJZUxJrmbzwAOFMVUwbQz4i3MU/BThQqZAL1DibM?= =?us-ascii?Q?51YsXVglncfJR0DIBffx/vd3fwjfB9Ga7tlDtzauar9oE1DMpt5KvBQWdtWd?= =?us-ascii?Q?jCBGsOr2wDSZsE7GgWzYJ6TlGmYUYjQBfq1FbePNnMoPYeUVp8bE9QW6tBli?= =?us-ascii?Q?ZznYpuLAjT9SnET8bBz2l/M4DO3aLPe8t4byJfCFuWmac6xzng68QrgETUdo?= =?us-ascii?Q?hVjvgiMX9v3kM0qYsCnNci4kOvImieQrpGiLvJgsdp1dumNXP5Zb7+1knseT?= =?us-ascii?Q?lNtTKoRCmw4HXPdJoA9zVsSKZvzjUtKA94yOcsCaeKbWciIEb8MVR/bNkarw?= =?us-ascii?Q?ZbhCrs/FZ6yaYcU3xrnVE/9bkEpd4YHExzT7sLV2NCfgOfZHoXLrRZcbH/qN?= =?us-ascii?Q?hilGUT5G4AqpvmP8iOQ+0JcYNZoE2Bfb2Ikmoi5DAKfqR6VNIW6IVS0AnUP3?= =?us-ascii?Q?LAyHr+p+xMPSUMkMSkMtgOyNg7EZ+AzFOoiqov3QMh3u?= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MN2PR12MB3966.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: be510b38-fa3b-4452-8c85-08da6ea8a8a0 X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Jul 2022 01:46:28.8845 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 3u7XhcoiTwqzvMkSJDBrzoJJI+jF7/iSkm5TlIXPWy4ammyn/TVsaAFe3Z4AaqBbDrFDM5x+5CEfyF88dOfj4Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1767 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable [AMD Official Use Only - General] Reviewed-by: Abner Chang > -----Original Message----- > From: Nickle Wang > Sent: Monday, July 25, 2022 9:36 AM > To: devel@edk2.groups.io > Cc: Chang, Abner ; Yang, Atom > ; Nick Ramirez > Subject: [edk2-staging][PATCH v2 02/15] edk2-staging/RedfishClientPkg: > Introduce Redfish version library >=20 > [CAUTION: External Email] >=20 > Add RedfishVersionLib in order to get Redfish version hosted at BMC. > When there is trouble to get Redfish support version, the default version= is > retrieved from pre-defined PCD value. >=20 > Signed-off-by: Nickle Wang > Cc: Abner Chang > Cc: Yang Atom > Cc: Nick Ramirez > --- > .../Include/Library/RedfishVersionLib.h | 30 +++ > RedfishClientPkg/Include/RedfishBase.h | 21 ++ > .../RedfishVersionLib/RedfishVersionLib.c | 203 ++++++++++++++++++ > .../RedfishVersionLib/RedfishVersionLib.inf | 50 +++++ > RedfishClientPkg/RedfishClientLibs.dsc.inc | 1 + > RedfishClientPkg/RedfishClientPkg.dec | 4 +- > 6 files changed, 308 insertions(+), 1 deletion(-) create mode 100644 > RedfishClientPkg/Include/Library/RedfishVersionLib.h > create mode 100644 RedfishClientPkg/Include/RedfishBase.h > create mode 100644 > RedfishClientPkg/Library/RedfishVersionLib/RedfishVersionLib.c > create mode 100644 > RedfishClientPkg/Library/RedfishVersionLib/RedfishVersionLib.inf >=20 > diff --git a/RedfishClientPkg/Include/Library/RedfishVersionLib.h > b/RedfishClientPkg/Include/Library/RedfishVersionLib.h > new file mode 100644 > index 0000000000..319f22bd37 > --- /dev/null > +++ b/RedfishClientPkg/Include/Library/RedfishVersionLib.h > @@ -0,0 +1,30 @@ > +/** @file > + This file defines the Redfish version Library interface. > + > + (C) Copyright 2022 Hewlett Packard Enterprise Development LP
> + > + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#ifndef REDFISH_VERSION_LIB_H_ > +#define REDFISH_VERSION_LIB_H_ > + > +/** > + Query HTTP request to BMC with given redfish service and return > +redfish > + version information. If there is troulbe to get Redfish version on > +BMC, > + The value of PcdDefaultRedfishVersion is returned. > + > + It's call responsibility to release returned buffer. > + > + @param[in] Service Redfish service instance > + > + @retval EFI_STRING Redfish version string. NULL while error occurs. > + > +**/ > +EFI_STRING > +RedfishGetVersion ( > + IN REDFISH_SERVICE *Service > + ); > + > +#endif > diff --git a/RedfishClientPkg/Include/RedfishBase.h > b/RedfishClientPkg/Include/RedfishBase.h > new file mode 100644 > index 0000000000..cf320bb0eb > --- /dev/null > +++ b/RedfishClientPkg/Include/RedfishBase.h > @@ -0,0 +1,21 @@ > +/** @file > + Redfish base header file. > + > + (C) Copyright 2022 Hewlett Packard Enterprise Development LP
> + > + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#ifndef EFI_REDFISH_BASE_H_ > +#define EFI_REDFISH_BASE_H_ > + > +#define IS_EMPTY_STRING(a) ((a) =3D=3D NULL || (a)[0] =3D=3D '\0') > +#define REDFISH_DEBUG_TRACE DEBUG_INFO > + > +/// > +/// This GUID is used for an EFI Variable that stores the Redfish data. > +/// > +EFI_GUID mRedfishVariableGuid =3D {0x91c46a3d, 0xed1a, 0x477b, {0xa5, > +0x33, 0x87, 0x2d, 0xcd, 0xb0, 0xfc, 0xc1}}; > + > +#endif > diff --git a/RedfishClientPkg/Library/RedfishVersionLib/RedfishVersionLib= .c > b/RedfishClientPkg/Library/RedfishVersionLib/RedfishVersionLib.c > new file mode 100644 > index 0000000000..0a2ace7726 > --- /dev/null > +++ b/RedfishClientPkg/Library/RedfishVersionLib/RedfishVersionLib.c > @@ -0,0 +1,203 @@ > +/** @file > + Redfish version library implementation > + > + (C) Copyright 2022 Hewlett Packard Enterprise Development LP
> + > + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include #include > + > + > +#define REDFISH_VERSION_DEFAULT_STRING L"v1" > +#define REDFISH_ROOT_URI "/redfish" > + > +REDFISH_SERVICE *mCacheService; > +EFI_STRING mVersionCache; > +UINTN mVersionStringSize; > + > +/** > + Cache the redfish service version for later use so we don't have to > +query > + HTTP request everytime. > + > + @param[in] Service Redfish service instance > + @param[in] Version Version string to cache > + > + @retval EFI_SUCCESS Version is saved in cache successfully. > + @retval Others > + > +**/ > +EFI_STATUS > +CacheVersion ( > + IN REDFISH_SERVICE *Service, > + IN EFI_STRING Version > + ) > +{ > + if (Service =3D=3D NULL || IS_EMPTY_STRING (Version)) { > + return EFI_INVALID_PARAMETER; > + } > + > + if (mCacheService =3D=3D Service) { > + return EFI_ALREADY_STARTED; > + } > + > + mCacheService =3D Service; > + if (mVersionCache !=3D NULL) { > + FreePool (mVersionCache); > + } > + > + mVersionStringSize =3D StrSize (Version); mVersionCache =3D > + AllocateCopyPool (mVersionStringSize, Version); if (mVersionCache =3D= =3D > + NULL) { > + mCacheService =3D NULL; > + return EFI_OUT_OF_RESOURCES; > + } > + > + return EFI_SUCCESS; > +} > + > +/** > + Query HTTP request to BMC with given redfish service and return > +redfish > + version information. If there is troulbe to get Redfish version on > +BMC, > + The value of PcdDefaultRedfishVersion is returned. > + > + It's call responsibility to release returned buffer. > + > + @param[in] Service Redfish service instance > + > + @retval EFI_STRING Redfish version string. NULL while error occurs. > + > +**/ > +EFI_STRING > +RedfishGetVersion ( > + IN REDFISH_SERVICE *Service > + ) > +{ > + EFI_STATUS Status; > + EFI_STRING VersionString; > + REDFISH_RESPONSE Response; > + EDKII_JSON_VALUE JsonValue; > + EDKII_JSON_VALUE N; > + CHAR8 *Key; > + EDKII_JSON_VALUE Value; > + > + VersionString =3D NULL; > + > + if (Service =3D=3D NULL) { > + goto ON_ERROR; > + } > + > + // > + // Use cache to prevent HTTP connection. > + // > + if (Service =3D=3D mCacheService) { > + return AllocateCopyPool (mVersionStringSize, mVersionCache); } > + > + // > + // Get resource from redfish service. > + // > + Status =3D RedfishGetByUri ( > + Service, > + REDFISH_ROOT_URI, > + &Response > + ); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a, RedfishGetByService to %a failed: %r\n", > __FUNCTION__, REDFISH_ROOT_URI, Status)); > + if (Response.Payload !=3D NULL) { > + RedfishDumpPayload (Response.Payload); > + RedfishFreeResponse ( > + NULL, > + 0, > + NULL, > + Response.Payload > + ); > + Response.Payload =3D NULL; > + } > + > + goto ON_ERROR; > + } > + > + JsonValue =3D RedfishJsonInPayload (Response.Payload); if (JsonValue > + =3D=3D NULL || !JsonValueIsObject (JsonValue)) { > + goto ON_ERROR; > + } > + > + EDKII_JSON_OBJECT_FOREACH_SAFE (JsonValue, N, Key, Value) { > + if (Key[0] =3D=3D 'v' && JsonValueIsString (Value)) { > + VersionString =3D JsonValueGetUnicodeString (Value); > + break; > + } > + } > + > + if (VersionString !=3D NULL) { > + CacheVersion (Service, VersionString); > + return VersionString; > + } > + > +ON_ERROR: > + > + VersionString =3D (CHAR16 *)PcdGetPtr (PcdDefaultRedfishVersion); if > + (VersionString =3D=3D NULL) { > + VersionString =3D REDFISH_VERSION_DEFAULT_STRING; } > + > + return AllocateCopyPool (StrSize (VersionString), VersionString); } > + > +/** > + > + Initial redfish version library instace. > + > + @param[in] ImageHandle The image handle. > + @param[in] SystemTable The system table. > + > + @retval EFI_SUCEESS Install Boot manager menu success. > + @retval Other Return error status. > + > +**/ > +EFI_STATUS > +EFIAPI > +RedfishVersionLibConstructor ( > + IN EFI_HANDLE ImageHandle, > + IN EFI_SYSTEM_TABLE *SystemTable > + ) > +{ > + mCacheService =3D NULL; > + mVersionCache =3D NULL; > + mVersionStringSize =3D 0; > + > + return EFI_SUCCESS; > +} > + > + > +/** > + Release allocated resource. > + > + @param[in] ImageHandle Handle that identifies the image to be un= loaded. > + @param[in] SystemTable The system table. > + > + @retval EFI_SUCCESS The image has been unloaded. > + > +**/ > +EFI_STATUS > +EFIAPI > +RedfishVersionLibDestructor ( > + IN EFI_HANDLE ImageHandle, > + IN EFI_SYSTEM_TABLE *SystemTable > + ) > +{ > + if (mVersionCache !=3D NULL) { > + FreePool (mVersionCache); > + } > + > + return EFI_SUCCESS; > +} > diff --git a/RedfishClientPkg/Library/RedfishVersionLib/RedfishVersionLib= .inf > b/RedfishClientPkg/Library/RedfishVersionLib/RedfishVersionLib.inf > new file mode 100644 > index 0000000000..34d13d64f1 > --- /dev/null > +++ b/RedfishClientPkg/Library/RedfishVersionLib/RedfishVersionLib.inf > @@ -0,0 +1,50 @@ > +## @file > +# > +# (C) Copyright 2022 Hewlett Packard Enterprise Development LP
# # > +SPDX-License-Identifier: BSD-2-Clause-Patent # ## > + > +[Defines] > + INF_VERSION =3D 0x00010006 > + BASE_NAME =3D RedfishVersionLib > + FILE_GUID =3D 396A7508-B611-49F7-9C81-DAD96B526B6= 1 > + MODULE_TYPE =3D DXE_DRIVER > + VERSION_STRING =3D 1.0 > + LIBRARY_CLASS =3D RedfishVersionLib| DXE_DRIVER > + CONSTRUCTOR =3D RedfishVersionLibConstructor > + DESTRUCTOR =3D RedfishVersionLibDestructor > + > +# > +# VALID_ARCHITECTURES =3D IA32 X64 EBC > +# > + > +[Sources] > + RedfishVersionLib.c > + > +[Packages] > + MdePkg/MdePkg.dec > + MdeModulePkg/MdeModulePkg.dec > + RedfishPkg/RedfishPkg.dec > + RedfishClientPkg/RedfishClientPkg.dec > + > +[LibraryClasses] > + BaseLib > + DebugLib > + MemoryAllocationLib > + PcdLib > + RedfishLib > + JsonLib > + > +[Protocols] > + > +[Pcd] > + gEfiRedfishClientPkgTokenSpaceGuid.PcdDefaultRedfishVersion > + > +[BuildOptions] > + # > + # NOTE: /wd4706 disables the following Visual Studio compiler warning = in > Jansson: > + # "C4706: assignment within conditional expression" > + # > + MSFT:*_*_*_CC_FLAGS =3D /wd4706 > diff --git a/RedfishClientPkg/RedfishClientLibs.dsc.inc > b/RedfishClientPkg/RedfishClientLibs.dsc.inc > index ce1c27d884..1cf0406912 100644 > --- a/RedfishClientPkg/RedfishClientLibs.dsc.inc > +++ b/RedfishClientPkg/RedfishClientLibs.dsc.inc > @@ -29,3 +29,4 @@ >=20 > ConverterCommonLib|RedfishClientPkg/ConverterLib/edk2library/ConverterCo > mmonLib/ConverterCommonLib.inf >=20 > RedfishEventLib|RedfishClientPkg/Library/RedfishEventLib/RedfishEventL= ib.inf > + > + RedfishVersionLib|RedfishClientPkg/Library/RedfishVersionLib/RedfishVe > + rsionLib.inf > diff --git a/RedfishClientPkg/RedfishClientPkg.dec > b/RedfishClientPkg/RedfishClientPkg.dec > index 39b2f5baf8..2ce51d14af 100644 > --- a/RedfishClientPkg/RedfishClientPkg.dec > +++ b/RedfishClientPkg/RedfishClientPkg.dec > @@ -22,6 +22,7 @@ > [LibraryClasses] > RedfishFeatureUtilityLib|Include/Library/RedfishFeatureUtilityLib.h > RedfishEventLib|Include/Library/RedfishEventLib.h > + RedfishVersionLib|Include/Library/RedfishVersionLib.h >=20 > [LibraryClasses.Common.Private] > ## @libraryclass Redfish Helper Library @@ -52,4 +53,5 @@ > # { 0x7CE88FB3, 0x4BD7, 0x4679, { 0x87, 0xA8, 0xA8, 0xD8, 0xDE, 0xE5, = 0x0D, > 0x2B }} > # >=20 > gEfiRedfishClientPkgTokenSpaceGuid.PcdEdkIIRedfishFeatureDriverStartupEve= nt > Guid|{0xB3, 0x8F, 0xE8, 0x7C, 0xD7, 0x4B, 0x79, 0x46, 0x87, 0xA8, 0xA8, 0= xD8, > 0xDE, 0xE5, 0x0D, 0x2B}|VOID*|0x10000003 > - > + ## Default Redfish version string > + > + gEfiRedfishClientPkgTokenSpaceGuid.PcdDefaultRedfishVersion|L"v1"|VOID > + *|0x10000004 > -- > 2.32.0.windows.2