From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-002e3701.pphosted.com (mx0b-002e3701.pphosted.com [148.163.143.35]) by mx.groups.io with SMTP id smtpd.web08.901.1652846148660601849 for ; Tue, 17 May 2022 20:55:49 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@hpe.com header.s=pps0720 header.b=IXJ4QttT; spf=permerror, err=parse error for token &{10 18 %{ir}.%{v}.%{d}.spf.has.pphosted.com}: invalid domain name (domain: hpe.com, ip: 148.163.143.35, mailfrom: prvs=0137e89ecd=abner.chang@hpe.com) Received: from pps.filterd (m0148664.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 24I371dH009896 for ; Wed, 18 May 2022 03:55:47 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hpe.com; h=from : to : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=pps0720; bh=sVkI2ERJllcMAwOqI2LqCY8T/NIJhbUvzxn0pLBDPWk=; b=IXJ4QttT2gP2nhAmGheWZKn/d6sqg4OypjtZMkO6jSM3ehVu1J2SDNeIkIwGg4mvyKLh tJto7yzvwUArpSKaMzAoLcDby5ESL3BnbqDMVHCkFqSTuFWWVUQNMjIWwwLYMUOu8gC0 YFhcqEo6AB/4c8uxuNtiACSdKgRog6Ilqrd1mG1yILRue1I5BRw9/AdYhMf9V9Enex/X UUpg/Z88eAPQQa9C+Vv+899YPFwJPg0qWZF968K8p7SuXqgtU4zj0sziBKO37Gx7YpMn tXLafoPQIhrACqk6L/vVZ+tcrczmUu3WV4BobKiWLb6cZ/lrlkqM1MPRulad6v8OTtj1 rg== Received: from p1lg14880.it.hpe.com (p1lg14880.it.hpe.com [16.230.97.201]) by mx0b-002e3701.pphosted.com (PPS) with ESMTPS id 3g4rkcgmry-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 18 May 2022 03:55:47 +0000 Received: from p1wg14923.americas.hpqcorp.net (unknown [10.119.18.111]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by p1lg14880.it.hpe.com (Postfix) with ESMTPS id 91D6D80037C for ; Wed, 18 May 2022 03:55:46 +0000 (UTC) Received: from p1wg14928.americas.hpqcorp.net (10.119.18.116) by p1wg14923.americas.hpqcorp.net (10.119.18.111) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.15; Tue, 17 May 2022 15:55:16 -1200 Received: from p1wg14927.americas.hpqcorp.net (10.119.18.117) by p1wg14928.americas.hpqcorp.net (10.119.18.116) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.15; Tue, 17 May 2022 15:55:16 -1200 Received: from P1WG14918.americas.hpqcorp.net (16.230.19.121) by p1wg14927.americas.hpqcorp.net (10.119.18.117) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.15 via Frontend Transport; Tue, 17 May 2022 15:55:16 -1200 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (192.58.206.38) by edge.it.hpe.com (16.230.19.121) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.15; Wed, 18 May 2022 03:55:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J3pxl8HM5jv6VeSloaNF3vPY5sOTPsUnD9SoMyzEwSVB6F2UiMuWlLA35Z+BSyYTrgDadYtBr340d1mHYWfvYOHQ5tPOo12azDaC7N9iPcz7dQ1yJMYUAFkTDJylV0T1WhchxAKPzV65xWRifNP5DjebxGj4krjSm7ZuF9HmUJ9K3xKkOonNnqwkoWPP2lgc0TzHfvvZnmwo5BfiTBM1/VtjXuhSucMvcu4cvbKAJGmFxJs9P2+3hzXWUTlOY13gNtNtP+EaJh//jJTs78L5/y/1OMescv3OUqxrBOk2lwk7GCDyKQe5LU5dKbXOUgqEL000cF5fkqag7g78PHkK8w== 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=sVkI2ERJllcMAwOqI2LqCY8T/NIJhbUvzxn0pLBDPWk=; b=SvRmHz+L5RcVLOiY1ed3SmL+DScPkLwB6QLV0zIiWs5hVzPwtzyTMneLYBLArNFZu+U/66JnyE0TSw2yoNyrCeqxSQ3Xu/9mtWvDnS8x7OJOebabt+6udmJRVCv+BUkfzW0T15o1UiYOR+M1bO0tpx4U3nxqdrRrsx4qkXMDS5MMIPjQUfHdnbJw09jrGMC8zFXU/6laBj5WittLcmZfVYl0w2yOvw0eGn0EKslN6mUCttAPbHiRRN74vX5eSmUfgip+ccQbE4S5T7zAOmTgZIWJZYCiTydWm45VhS5PI+HOZJ6QgddQXCIGoYKJmz0t1jsBNBCdD88PB635qs2VyQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=hpe.com; dmarc=pass action=none header.from=hpe.com; dkim=pass header.d=hpe.com; arc=none Received: from PH0PR84MB1647.NAMPRD84.PROD.OUTLOOK.COM (2603:10b6:510:173::6) by IA1PR84MB3082.NAMPRD84.PROD.OUTLOOK.COM (2603:10b6:208:3ee::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5250.18; Wed, 18 May 2022 03:55:14 +0000 Received: from PH0PR84MB1647.NAMPRD84.PROD.OUTLOOK.COM ([fe80::ccc7:75d5:2ce1:9b5a]) by PH0PR84MB1647.NAMPRD84.PROD.OUTLOOK.COM ([fe80::ccc7:75d5:2ce1:9b5a%9]) with mapi id 15.20.5250.018; Wed, 18 May 2022 03:55:14 +0000 From: "Abner Chang" To: "Wang, Nickle (Server BIOS)" , "devel@edk2.groups.io" Subject: Re: [edk2-staging][PATCH] edk2-staging/RedfishClientPkg: Introduce Redfish version library Thread-Topic: [edk2-staging][PATCH] edk2-staging/RedfishClientPkg: Introduce Redfish version library Thread-Index: AQHYaaz9DpbrPVgtLkKAKh0h3aGava0j/cVA Date: Wed, 18 May 2022 03:55:14 +0000 Message-ID: References: <20220517035856.1850-1-nickle.wang@hpe.com> In-Reply-To: <20220517035856.1850-1-nickle.wang@hpe.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: f881a68d-3b9c-474c-4f11-08da388236cf x-ms-traffictypediagnostic: IA1PR84MB3082:EE_ x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: dt10RTe5wZfs7LtiQKuZC5E3D/1A5iY4ENtVJD36JGuckOonex63rpKYIMo5tMDGN5tPv7IV/6d4+DQ/J/vXDuDQvKTbRaAGTk4hgQUKSZIIenDTHWvKqP04vA8UPaF1BjbENZhdlNKwz8qUcUTrsTTqCW1ea74XYqTg9pmpb6p5ZL+PBj7FO+H6q6NQJcHTBInxtL/PQ/f4hgwizg12JNhtTdIVN/UbyATTEizc5jqFQdO3Hycsr20QTsopdutOmTu5fzO2Uvc3LZdqSPbRJ+9xNwZZz027/5hOVTvP1z42sLXhRpxXRnOLl22NH2D6zJGSz5ZgldZFDuiadX5AqhO9g96M/sxvN18QLn/nhl+FHLVq8bA4ahck9kfjPuuGmstrJEdfryeEaANCGZdB0quqzqmtVwA7PymoskRP7Y6JR7M0DoL7A/cGD52IdkbZtCfQDBCFuB3p6Fera1qqKxF2Q0K5FZvg+ozGlGQczuDjbH5/duy7RDk5QQ0c/N950IVU8eOPjjF95tLueXgT/TGX3GbMuKY2jPZSR/Bb0myKyBHw/8wl57NWhzdE50NLh+uqZX6J10ydEe86JwUt7jFAvq8IB/ggYqVQP6K7GKdaOAg+t14dQcAXXjh1w1FmQjbytpmB5MwLCzoZ2gttpdaOVZXJ1c2yAyQ5yepCgd9O9P4FJwkXrsgBdZ+KeI/Fn6PGcGnE2TBs+hARIwT+Jw== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR84MB1647.NAMPRD84.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230001)(366004)(186003)(7696005)(38070700005)(5660300002)(86362001)(30864003)(508600001)(6506007)(53546011)(8936002)(55016003)(64756008)(52536014)(66946007)(82960400001)(83380400001)(110136005)(316002)(66446008)(8676002)(76116006)(66556008)(71200400001)(33656002)(66476007)(26005)(122000001)(2906002)(9686003)(38100700002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?yltXpnKlgS4JCBeO2psjAlGI7LBzftxNwKj5vJxxOL5V9RqIBEd3ILd9MtW/?= =?us-ascii?Q?AK1I8//F9dZaOU5WGG7bUhDjfnwqfJFnxsrVLmfqzEV3v8JmldmdmMv8uIwR?= =?us-ascii?Q?xbEUsKalWWSNd0vI6Ge2mtyzHSmGz6Rxi0fhW+g7jVj0wIxDTKr0LQLkNJgU?= =?us-ascii?Q?4Hod/g7jseMrN75ajoFuyemQNQnFvnxJ3/IVZFcte8eV9l3GuLItKqABujwr?= =?us-ascii?Q?mz4OGwsdw2obonvSpm6b7VQhnCdp3/o2DwC1ehM39jJd3zmnh/duJnXTjNXr?= =?us-ascii?Q?e/dhCcub3G4degQBVWdZBozYIwSOaTGAPnnuCiICWR6034xjj4Yw1y0C1bgD?= =?us-ascii?Q?6oRAv/m5pAeOK1VnPwI5jY/xwJPtP7UwZDjTc8RYde6YrYaD+IqPur4lVDQ+?= =?us-ascii?Q?Uknph9aP6JNhTbEiDPkoY64OIcJzd2dpUCN74DINmyB/5kT6TPCOG/7sln98?= =?us-ascii?Q?Bstm3jGoM56n31dt+xSDTMF6Bn2G8h1KQudHwJotN8djZSgRgEf5CqBwllKA?= =?us-ascii?Q?RLm30LZ27XeRJuFnvuH1iebW0bD6wjfEWLtVkysOEamlKFF9wJRuNKn6Ctfp?= =?us-ascii?Q?SmjbeXPRWYCon6aFjHYUV7LgSpiMvDPkk2JUpoKapieyqpi+zVW477pBeQ4H?= =?us-ascii?Q?wgBrlPPmZXcBNFJfGdRRcLVdWnUNIaXigyNJ5kw+HxiMd8dY6t5zcWMhNzpt?= =?us-ascii?Q?celroaXOxT3TIs5CuRM8he86pKk39ysvKXUDObTAqO8eSojAA4UhgXtoJKJg?= =?us-ascii?Q?tALoyxSBep3rjK2RypdoJ4PjrEvuv4kboAgvAB8juH/y6zGB4XimXD3cDJTn?= =?us-ascii?Q?ctRojCOck3CUtVwSTli07GgK9OByHksWtbOzrFbnHy7N0eWoY0hFFzjY6uUQ?= =?us-ascii?Q?OHjgbMvDOzcBEkAjcN132PWCHp5BaHfFsUoDlHfQ4beu08E6IjZAcsDThP//?= =?us-ascii?Q?xhIHB+rmUBPpd3rpFDdg3tS+B9HHJeRw5XALxsBe8qVzTcaXRoeec/E6a68Y?= =?us-ascii?Q?LUPfC44vnyZkEM3923CnFOCwlmhIfxlTvNBIS7QNYV/glA+OpmAS+l4+3xY7?= =?us-ascii?Q?gIn86ncAyrbYZgJTPryuSabT+uG0aC28gA4usqU5odM8wiQUXvVpIy0feRy3?= =?us-ascii?Q?DFvUraMc63S5QIf2n39JLiRiKgRLqetb65FrUVXGdVhL6TCVQA6RvapCqv65?= =?us-ascii?Q?qr8oOze6K/GOJncV3aBDDb7v938kxiEVDyuZTKi38gSER9wsO1Xi3DHFMxvV?= =?us-ascii?Q?7Lo4PLcK28rkfbrjJUtRS1ORCxM07wpub5svL/3sG0Z+w+dayaHj7oCVw9Ih?= =?us-ascii?Q?G/B6bUdRNxxRFLFaneZk8QnTK2e+mk4yvO8p4k0INU6+jfI9NOlRNRky9P4x?= =?us-ascii?Q?68Een4J5n5nUb11O46I0RE52YuSAPK02625IJlCyL8jViCxJxFyio6YraaRb?= =?us-ascii?Q?wg6Zv5aGuvH4WPHXJsadEXP0KM1fs1IQkC/zjIowK40oc7h2jNUcvS4YPFL3?= =?us-ascii?Q?Gpm9DJ30BXqWeQzuDyu11tFVjx+YQ7VYtOlvQBv7YM4x5PwBCMyTqjY47NVF?= =?us-ascii?Q?ioeQNcW0SrUvBXKSKJzBs+Ym+PzTW1XZhDHSe2dSHVQ7JGDPJrDEn2SSaw/s?= =?us-ascii?Q?KScf/skIURawil5d5aOhL3zgm9Qgt3fp4o/0XFIB6GF3ldMSd2bzMHmTOof+?= =?us-ascii?Q?yh8irHjKD//DkgZfcoUzz0vMuHpvL3Y5bwcq63KRGvFHsPXNxz2FlgoGAhtm?= =?us-ascii?Q?Z2vXVkei4Q=3D=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PH0PR84MB1647.NAMPRD84.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-Network-Message-Id: f881a68d-3b9c-474c-4f11-08da388236cf X-MS-Exchange-CrossTenant-originalarrivaltime: 18 May 2022 03:55:14.2650 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 105b2061-b669-4b31-92ac-24d304d195dc X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: zZt7fnokwcYj6JkGFXWEEVq/hsyZLggmRDAAEta6xilXdUIsH2apiGyxLyCsmJFCn2bBy5wgtWHGx7LnRYq8dA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR84MB3082 X-OriginatorOrg: hpe.com X-Proofpoint-ORIG-GUID: zYbLPRuNgAYo1wPAphR1daNg2RjtRBhN X-Proofpoint-GUID: zYbLPRuNgAYo1wPAphR1daNg2RjtRBhN X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-18_01,2022-05-17_02,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 adultscore=0 mlxscore=0 priorityscore=1501 mlxlogscore=999 clxscore=1015 bulkscore=0 spamscore=0 lowpriorityscore=0 phishscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2205180022 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable > -----Original Message----- > From: Wang, Nickle (Server BIOS) > Sent: Tuesday, May 17, 2022 11:59 AM > To: devel@edk2.groups.io > Cc: Wang, Nickle (Server BIOS) ; Chang, Abner (HPS > SW/FW Technologist) > Subject: [edk2-staging][PATCH] edk2-staging/RedfishClientPkg: Introduce > Redfish version library >=20 > Add RedfishVersionLib to Redfish client package. This library provides > interface for Redfish feature drivers to get Redfish version on BMC. >=20 > Signed-off-by: Nickle Wang > Cc: Abner Chang > --- > .../Include/Library/RedfishVersionLib.h | 30 +++ > RedfishClientPkg/Include/RedfishBase.h | 16 ++ > .../RedfishVersionLib/RedfishVersionLib.c | 203 ++++++++++++++++++ > .../RedfishVersionLib/RedfishVersionLib.inf | 44 ++++ > RedfishClientPkg/RedfishClientLibs.dsc.inc | 2 +- > RedfishClientPkg/RedfishClientPkg.dec | 6 +- > 6 files changed, 298 insertions(+), 3 deletions(-) > 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..5076c2ce9f > --- /dev/null > +++ b/RedfishClientPkg/Include/Library/RedfishVersionLib.h > @@ -0,0 +1,30 @@ > +/** @file >=20 > + This file defines the Redfish version library interface. >=20 > + >=20 > + (C) Copyright 2022 Hewlett Packard Enterprise Development LP
>=20 > + >=20 > + SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > + >=20 > +**/ >=20 > + >=20 > +#ifndef REDFISH_VERSION_LIB_H_ >=20 > +#define REDFISH_VERSION_LIB_H_ >=20 > + >=20 > +/** >=20 > + Query HTTP request to BMC with given redfish service and return redfis= h >=20 > + version information. If there is troulbe to get Redfish version on BMC= , >=20 > + The value of PcdDefaultRedfishVersion is returned. >=20 > + >=20 > + It's call responsibility to release returned buffer. It's caller's responsibility to release the returned buffer. >=20 > + >=20 > + @param[in] Service Redfish service instance >=20 > + >=20 > + @retval EFI_STRING Redfish version string. NULL while error occurs. >=20 > + >=20 > +**/ >=20 > +EFI_STRING >=20 > +RedfishGetVersion ( >=20 > + IN REDFISH_SERVICE *Service >=20 > + ); >=20 > + >=20 > +#endif >=20 > diff --git a/RedfishClientPkg/Include/RedfishBase.h > b/RedfishClientPkg/Include/RedfishBase.h > new file mode 100644 > index 0000000000..60d585c54a > --- /dev/null > +++ b/RedfishClientPkg/Include/RedfishBase.h > @@ -0,0 +1,16 @@ > +/** @file >=20 > + Redfish base header file. >=20 > + >=20 > + (C) Copyright 2022 Hewlett Packard Enterprise Development LP
>=20 > + >=20 > + SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > + >=20 > +**/ >=20 > + >=20 > +#ifndef EFI_REDFISH_BASE_H_ >=20 > +#define EFI_REDFISH_BASE_H_ >=20 > + >=20 > +#define IS_EMPTY_STRING(a) ((a) =3D=3D NULL || (a)[0] =3D=3D '\0') >=20 > +#define REDFISH_DEBUG_TRACE DEBUG_VERBOSE >=20 > + >=20 > +#endif >=20 > 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 >=20 > + Redfish version library implementation >=20 > + >=20 > + (C) Copyright 2022 Hewlett Packard Enterprise Development LP
>=20 > + >=20 > + SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > + >=20 > +**/ >=20 > + >=20 > +#include >=20 > +#include >=20 > +#include >=20 > +#include >=20 > +#include >=20 > +#include >=20 > +#include >=20 > +#include >=20 > +#include >=20 > + >=20 > +#define REDFISH_VERSION_DEFAULT_STRING L"v1" >=20 > +#define REDFISH_ROOT_URI "/redfish" >=20 > + >=20 > +REDFISH_SERVICE *mCacheService; >=20 > +EFI_STRING mVersionCache; >=20 > +UINTN mVersionStringSize; >=20 > + >=20 > +/** >=20 > + Cache the redfish service version for later use so we don't have to qu= ery >=20 > + HTTP request everytime. >=20 > + >=20 > + @param[in] Service Redfish service instance >=20 > + @param[in] Version Version string to cache >=20 > + >=20 > + @retval EFI_SUCCESS Version is saved in cache successfully. >=20 > + @retval Others >=20 > + >=20 > +**/ >=20 > +EFI_STATUS >=20 > +CacheVersion ( >=20 > + IN REDFISH_SERVICE *Service, >=20 > + IN EFI_STRING Version >=20 > + ) >=20 > +{ >=20 > + if (Service =3D=3D NULL || IS_EMPTY_STRING (Version)) { >=20 > + return EFI_INVALID_PARAMETER; >=20 > + } >=20 > + >=20 > + if (mCacheService =3D=3D Service) { >=20 > + return EFI_ALREADY_STARTED; >=20 > + } >=20 > + >=20 > + mCacheService =3D Service; >=20 > + if (mVersionCache !=3D NULL) { >=20 > + FreePool (mVersionCache); >=20 > + } >=20 > + >=20 > + mVersionStringSize =3D StrSize (Version); >=20 > + mVersionCache =3D AllocateCopyPool (mVersionStringSize, Version); >=20 > + if (mVersionCache =3D=3D NULL) { >=20 > + mCacheService =3D NULL; >=20 > + return EFI_OUT_OF_RESOURCES; >=20 > + } >=20 > + >=20 > + return EFI_SUCCESS; >=20 > +} >=20 > + >=20 > +/** >=20 > + Query HTTP request to BMC with given redfish service and return redfis= h >=20 > + version information. If there is troulbe to get Redfish version on BMC= , >=20 > + The value of PcdDefaultRedfishVersion is returned. >=20 > + >=20 > + It's call responsibility to release returned buffer. >=20 > + >=20 > + @param[in] Service Redfish service instance >=20 > + >=20 > + @retval EFI_STRING Redfish version string. NULL while error occurs. >=20 > + >=20 > +**/ >=20 > +EFI_STRING >=20 > +RedfishGetVersion ( >=20 > + IN REDFISH_SERVICE *Service >=20 > + ) >=20 > +{ >=20 > + EFI_STATUS Status; >=20 > + EFI_STRING VersionString; >=20 > + REDFISH_RESPONSE Response; >=20 > + EDKII_JSON_VALUE JsonValue; >=20 > + EDKII_JSON_VALUE N; >=20 > + CHAR8 *Key; >=20 > + EDKII_JSON_VALUE Value; >=20 > + >=20 > + VersionString =3D NULL; >=20 > + >=20 > + if (Service =3D=3D NULL) { >=20 > + goto ON_ERROR; >=20 > + } >=20 > + >=20 > + // >=20 > + // Use cache to prevent HTTP connection. >=20 > + // >=20 > + if (Service =3D=3D mCacheService) { >=20 > + return AllocateCopyPool (mVersionStringSize, mVersionCache); >=20 > + } >=20 > + >=20 > + // >=20 > + // Get resource from redfish service. >=20 > + // >=20 > + Status =3D RedfishGetByUri ( >=20 > + Service, >=20 > + REDFISH_ROOT_URI, >=20 > + &Response >=20 > + ); >=20 > + if (EFI_ERROR (Status)) { >=20 > + DEBUG ((DEBUG_ERROR, "%a, RedfishGetByService to %a failed: %r\n", > __FUNCTION__, REDFISH_ROOT_URI, Status)); >=20 > + if (Response.Payload !=3D NULL) { >=20 > + RedfishDumpPayload (Response.Payload); >=20 > + RedfishFreeResponse ( >=20 > + NULL, >=20 > + 0, >=20 > + NULL, >=20 > + Response.Payload >=20 > + ); >=20 > + Response.Payload =3D NULL; >=20 > + } >=20 > + >=20 > + goto ON_ERROR; >=20 > + } >=20 > + >=20 > + JsonValue =3D RedfishJsonInPayload (Response.Payload); >=20 > + if (JsonValue =3D=3D NULL || !JsonValueIsObject (JsonValue)) { >=20 > + goto ON_ERROR; >=20 > + } >=20 > + >=20 > + EDKII_JSON_OBJECT_FOREACH_SAFE (JsonValue, N, Key, Value) { >=20 > + if (Key[0] =3D=3D 'v' && JsonValueIsString (Value)) { We can just check the JSON type for the property is a string type per to th= e Redfish spec. Please also have comment to elaborate on the rational of th= is code block.=20 Thanks Abner >=20 > + VersionString =3D JsonValueGetUnicodeString (Value); >=20 > + break; >=20 > + } >=20 > + } >=20 > + >=20 > + if (VersionString !=3D NULL) { >=20 > + CacheVersion (Service, VersionString); >=20 > + return VersionString; >=20 > + } >=20 > + >=20 > +ON_ERROR: >=20 > + >=20 > + VersionString =3D (CHAR16 *)PcdGetPtr (PcdDefaultRedfishVersion); >=20 > + if (VersionString =3D=3D NULL) { >=20 > + VersionString =3D REDFISH_VERSION_DEFAULT_STRING; >=20 > + } >=20 > + >=20 > + return AllocateCopyPool (StrSize (VersionString), VersionString); >=20 > +} >=20 > + >=20 > +/** >=20 > + >=20 > + Initial redfish version library instace. >=20 > + >=20 > + @param[in] ImageHandle The image handle. >=20 > + @param[in] SystemTable The system table. >=20 > + >=20 > + @retval EFI_SUCEESS Install Boot manager menu success. >=20 > + @retval Other Return error status. >=20 > + >=20 > +**/ >=20 > +EFI_STATUS >=20 > +EFIAPI >=20 > +RedfishVersionLibConstructor ( >=20 > + IN EFI_HANDLE ImageHandle, >=20 > + IN EFI_SYSTEM_TABLE *SystemTable >=20 > + ) >=20 > +{ >=20 > + mCacheService =3D NULL; >=20 > + mVersionCache =3D NULL; >=20 > + mVersionStringSize =3D 0; >=20 > + >=20 > + return EFI_SUCCESS; >=20 > +} >=20 > + >=20 > + >=20 > +/** >=20 > + Release allocated resource. >=20 > + >=20 > + @param[in] ImageHandle Handle that identifies the image to be > unloaded. >=20 > + @param[in] SystemTable The system table. >=20 > + >=20 > + @retval EFI_SUCCESS The image has been unloaded. >=20 > + >=20 > +**/ >=20 > +EFI_STATUS >=20 > +EFIAPI >=20 > +RedfishVersionLibDestructor ( >=20 > + IN EFI_HANDLE ImageHandle, >=20 > + IN EFI_SYSTEM_TABLE *SystemTable >=20 > + ) >=20 > +{ >=20 > + if (mVersionCache !=3D NULL) { >=20 > + FreePool (mVersionCache); >=20 > + } >=20 > + >=20 > + return EFI_SUCCESS; >=20 > +} >=20 > diff --git a/RedfishClientPkg/Library/RedfishVersionLib/RedfishVersionLib= .inf > b/RedfishClientPkg/Library/RedfishVersionLib/RedfishVersionLib.inf > new file mode 100644 > index 0000000000..fcc88a4357 > --- /dev/null > +++ b/RedfishClientPkg/Library/RedfishVersionLib/RedfishVersionLib.inf > @@ -0,0 +1,44 @@ > +## @file >=20 > +# >=20 > +# (C) Copyright 2022 Hewlett Packard Enterprise Development LP
>=20 > +# >=20 > +# SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > +# >=20 > +## >=20 > + >=20 > +[Defines] >=20 > + INF_VERSION =3D 0x00010006 >=20 > + BASE_NAME =3D RedfishVersionLib >=20 > + FILE_GUID =3D 396A7508-B611-49F7-9C81-DAD96B526B6= 1 >=20 > + MODULE_TYPE =3D DXE_DRIVER >=20 > + VERSION_STRING =3D 1.0 >=20 > + LIBRARY_CLASS =3D RedfishVersionLib| DXE_DRIVER >=20 > + CONSTRUCTOR =3D RedfishVersionLibConstructor >=20 > + DESTRUCTOR =3D RedfishVersionLibDestructor >=20 > + >=20 > +# >=20 > +# VALID_ARCHITECTURES =3D IA32 X64 EBC >=20 > +# >=20 > + >=20 > +[Sources] >=20 > + RedfishVersionLib.c >=20 > + >=20 > +[Packages] >=20 > + MdePkg/MdePkg.dec >=20 > + MdeModulePkg/MdeModulePkg.dec >=20 > + RedfishPkg/RedfishPkg.dec >=20 > + RedfishClientPkg/RedfishClientPkg.dec >=20 > + >=20 > +[LibraryClasses] >=20 > + BaseLib >=20 > + DebugLib >=20 > + MemoryAllocationLib >=20 > + PcdLib >=20 > + RedfishLib >=20 > + JsonLib Please having these libraries in the order of alphabet. >=20 > + >=20 > +[Protocols] >=20 > + >=20 > +[Pcd] >=20 > + gEfiRedfishClientPkgTokenSpaceGuid.PcdDefaultRedfishVersion >=20 > + >=20 > diff --git a/RedfishClientPkg/RedfishClientLibs.dsc.inc > b/RedfishClientPkg/RedfishClientLibs.dsc.inc > index 5467acedd0..386d4d9cbb 100644 > --- a/RedfishClientPkg/RedfishClientLibs.dsc.inc > +++ b/RedfishClientPkg/RedfishClientLibs.dsc.inc > @@ -27,4 +27,4 @@ >=20 > RedfishPlatformConfigLib|RedfishPkg/Library/RedfishPlatformConfigLib/Red > fishPlatformConfigLib.inf >=20 >=20 > RedfishContentCodingLib|RedfishPkg/Library/RedfishContentCodingLibNull/ > RedfishContentCodingLibNull.inf >=20 >=20 > ConverterCommonLib|RedfishClientPkg/ConverterLib/edk2library/Converte > rCommonLib/ConverterCommonLib.inf >=20 > - >=20 > + > RedfishVersionLib|RedfishClientPkg/Library/RedfishVersionLib/RedfishVersi > onLib.inf >=20 > diff --git a/RedfishClientPkg/RedfishClientPkg.dec > b/RedfishClientPkg/RedfishClientPkg.dec > index 09df062dd3..b22f121e96 100644 > --- a/RedfishClientPkg/RedfishClientPkg.dec > +++ b/RedfishClientPkg/RedfishClientPkg.dec > @@ -1,7 +1,7 @@ > ## @file >=20 > # Redfish Client Package >=20 > # >=20 > -# (C) Copyright 2021 Hewlett Packard Enterprise Development LP
>=20 > +# (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
>=20 > # >=20 > # SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > ## >=20 > @@ -21,6 +21,7 @@ >=20 >=20 > [LibraryClasses] >=20 > RedfishFeatureUtilityLib|Include/Library/RedfishFeatureUtilityLib.h >=20 > + RedfishVersionLib|Include/Library/RedfishVersionLib.h >=20 >=20 >=20 > [LibraryClasses.Common.Private] >=20 > ## @libraryclass Redfish Helper Library >=20 > @@ -47,4 +48,5 @@ > # { 0x7CE88FB3, 0x4BD7, 0x4679, { 0x87, 0xA8, 0xA8, 0xD8, 0xDE, 0xE5, = 0x0D, > 0x2B }} >=20 > # >=20 >=20 > gEfiRedfishClientPkgTokenSpaceGuid.PcdEdkIIRedfishFeatureDriverStartupE > ventGuid|{0xB3, 0x8F, 0xE8, 0x7C, 0xD7, 0x4B, 0x79, 0x46, 0x87, 0xA8, 0xA= 8, > 0xD8, 0xDE, 0xE5, 0x0D, 0x2B}|VOID*|0x10000003 >=20 > - >=20 > + ## Default Redfish version string >=20 > + > gEfiRedfishClientPkgTokenSpaceGuid.PcdDefaultRedfishVersion|L"v1"|VOID > *|0x10000004 >=20 > -- > 2.32.0.windows.2