From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-002e3701.pphosted.com (mx0a-002e3701.pphosted.com [148.163.147.86]) by mx.groups.io with SMTP id smtpd.web09.3391.1653456635848006695 for ; Tue, 24 May 2022 22:30:36 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@hpe.com header.s=pps0720 header.b=G/nFwpbW; 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.147.86, mailfrom: prvs=01442dc6a1=abner.chang@hpe.com) Received: from pps.filterd (m0150242.ppops.net [127.0.0.1]) by mx0a-002e3701.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 24P1WA40022088 for ; Wed, 25 May 2022 05:30:35 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=Wu9ShAsKmg1TOvPyvj6evPQ39fbL1AZKF4FhRd1NVy0=; b=G/nFwpbWklPlYguMr4Nw6aK9ou8UU8NNcpUIT1Q8WykoaOqHweCBt7sSIQwSHdO82g8L 5c98PZaEfyM7zWf8OEZHYoDhpyRnqlzB4bdss9JqlBYMMV4IX6wZ8vPxI3c/AIONPbu/ Imp9bqTnlYbBcXs9/yjCaj3TzEd8ZVzmogxVRImbqUBmDr/xCviGHgktfvSCp1oiSfbr wGjJpYDs4J85bgT1fnTyVijALqiwZus7w7Sq/20jxhM6S/MtVptQVLHsCg17QCgCg5Yt JJWd+1CV/bl6O1HCBC6vYoZw4+k1kFvyLdFy7brWWZg9WEo9ug1nJ/hxunbxD6EEviPj /Q== Received: from p1lg14880.it.hpe.com (p1lg14880.it.hpe.com [16.230.97.201]) by mx0a-002e3701.pphosted.com (PPS) with ESMTPS id 3g93vav95q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 25 May 2022 05:30:34 +0000 Received: from p1wg14924.americas.hpqcorp.net (unknown [10.119.18.113]) (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 44D048005D6 for ; Wed, 25 May 2022 05:30:34 +0000 (UTC) Received: from p1wg14925.americas.hpqcorp.net (10.119.18.114) by p1wg14924.americas.hpqcorp.net (10.119.18.113) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.15; Tue, 24 May 2022 17:30:01 -1200 Received: from P1WG14918.americas.hpqcorp.net (16.230.19.121) by p1wg14925.americas.hpqcorp.net (10.119.18.114) 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, 24 May 2022 17:30:01 -1200 Received: from NAM10-BN7-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, 25 May 2022 05:29:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AGcS3QXxrrDRnVK+NSpt96QTb5lRV6qtoTDCj7TFqQp8QLlv/vesrOmhKyefmb7dgg2OMoYgMYY3m/rZNz59BS0JaWSqSLW+rR45nExcYEIwGiA7CpHq2rjD6fOxw0LfuU9OHqPStFq/6TDUiJx49bzewrQNNiNH2+ZcfofDmuBG32vvfJgKhxbDS3v902UCy8BoO2oxRKyhkZf1mDI72duZ2cVAnbTEvhWtgpTnX3RitUiEvFHzvFYZZaBGkaxHnvZIj7Hj0Xd60vzW4ijVRu82qrmxkD7vHyeEykU36/rSitYLqQVQuvSm7j8iKdKpVvmP1jgVi2ifkb+y6GDZJQ== 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=Wu9ShAsKmg1TOvPyvj6evPQ39fbL1AZKF4FhRd1NVy0=; b=MVsoUXjYAmt0ONeaMLlXIN5hQ1I4riSIsxQ3KlW2IZX4qVD4ZjC63SMrCh7zzCUJRSu/O2sd7v01HaUTHv4/8fgu8qbkj5wmVYawZ1N+5ZxNWk8udzoIj+1M9d1/BgLrflQTUoARRZYAjP4MYGwuRJ62kF+mLOS9pMokXnu7EyeMYmonAJly9oGRRtjyURSqgdVVBHhNrGXNq1FBFNlVZI11o6B5XnqaUcdN0cQluaShsNEgQm9hkT/XXBo4Eojorfrg+hGH0cac6piTF2ZMEFjErz5Xql3kAJlbw3uQTMW2cakutCUPjMB71eChO8G8+zuOZpSRd686entyMi3IMQ== 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 DM4PR84MB1808.NAMPRD84.PROD.OUTLOOK.COM (2603:10b6:8:4f::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5273.23; Wed, 25 May 2022 05:29:50 +0000 Received: from PH0PR84MB1647.NAMPRD84.PROD.OUTLOOK.COM ([fe80::94de:c9c9:b94f:52a9]) by PH0PR84MB1647.NAMPRD84.PROD.OUTLOOK.COM ([fe80::94de:c9c9:b94f:52a9%7]) with mapi id 15.20.5293.013; Wed, 25 May 2022 05:29:50 +0000 From: "Abner Chang" To: "Wang, Nickle (Server BIOS)" , "devel@edk2.groups.io" Subject: Re: [edk2-staging][PATCH v2 2/3] edk2-staging/RedfishClientPkg: Introduce Redfish version library Thread-Topic: [edk2-staging][PATCH v2 2/3] edk2-staging/RedfishClientPkg: Introduce Redfish version library Thread-Index: AQHYb+WR4CcMIeGBbk2Cy03alsQdBa0vERSw Date: Wed, 25 May 2022 05:29:50 +0000 Message-ID: References: <20220525031406.1230-1-nickle.wang@hpe.com> In-Reply-To: <20220525031406.1230-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: 4105e72e-3579-407e-bf32-08da3e0f9713 x-ms-traffictypediagnostic: DM4PR84MB1808: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: jw1TLJoDHPm6N0lKlQDw4Iin7Py3i81OxOlfmTnaizCp4WP6WSBWvhT1DVBWClsTPf2rtOls9JGTgsbJqhUYr+UxuPVNsLw+VMoFAeWp5KjIoaoQog8nyYrINherA7hviamsOPV/9J37jTmHvSdmItoB5YSA+oyLMIgsSqcFtnnXYJTN0LZaIC3yVlnhyuk2fjG7xUZ2SYK1RF+rdKgTsrQeFsxvfi7mhTsgFWFSsjLH5Xi0qDAc+A0OXlAevFph9PDp8yc9M2/l5+RLcOr0xoOgeAdM4MjMXhXKTcNb36UTblPi7oLCCqjypfywucVdlT4wINf7bd3bp8MJYTSb35E2ESx9oN53427HP9NY5x4REJXEAVO1dGJsAXnuBq0gULqDmog2uCEaMhnalHmsGnHdZCZosaDkAkrd0KWppU9LCBVhxK8+nmuJFZm+syYR9yoSlc6Cdk1vcdoswQnj/yROnjW6gjWT5MiJ1DTuiYxQyGyKCF8hijsKbEcTIg4YsLx24/boNfTGFtUO3JcKXAleF/mEQezAEv7ThdLpPsSZFDcJDE++9yOqM9KjM3jmkmWn9bOEGNzGICHuU0o4VvTDl7/w4sfKLf/wJL63NQUPIss00T6CdEB5qPOYysH9pJVufINPR8mI1ZW+A2nf7/MHvUGSIomH6kprP5g8/VOLyMXWRtYryVi76bQHO/S4NY6bqD8cJBxWwSN/k2g+xw== 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)(9686003)(508600001)(66556008)(6506007)(7696005)(26005)(52536014)(30864003)(53546011)(8936002)(33656002)(8676002)(71200400001)(38070700005)(38100700002)(82960400001)(86362001)(66946007)(66446008)(64756008)(66476007)(110136005)(122000001)(186003)(2906002)(76116006)(55016003)(316002)(83380400001)(5660300002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?0/WVAMsamcw4NH3CBYN6XCoRhmNMfKIYYgTDYWSSr/t5v0BujVKElwCZt2ZC?= =?us-ascii?Q?mDLZQ1YT9ctcUK1LfTOJgWPUYuChsOfPwo/Fw968mjtDTQEo0GMFNxsmA2v9?= =?us-ascii?Q?JWuX95YhhgqE/cwN+fuIEYVG+UpxlcmCrDOIr49EObfZmiVZM66ZdgxhudWE?= =?us-ascii?Q?DLkWoHJ9x2s1ITyb6UyzPGAIehQt3ELi2y+CHss8Asy0eBi9gcOqs0PcXoc2?= =?us-ascii?Q?gXlrYkVirT25ohlw43CvgSHNEonrynr+oc6OF6rxiLKIVOjpHl7cCbmmSQfs?= =?us-ascii?Q?d17Xvmen6PbeiHbz3g4gvLPbLauYfEW8ZJGlSuf7z3auwKxe/6B9hdor2tVg?= =?us-ascii?Q?5wsB8zcJ/qMt+grmf0JIuBquvHbCzHXzprOxaEtoB8m+mh+kn71ECFGJrN9l?= =?us-ascii?Q?lkaifoyH9OLuZ0tjsJz8s99CMzjfeNXPKq70UzvdcKl99Cy3qhR5QX2bkmKf?= =?us-ascii?Q?KnUDciXGDPh7Wni9gS5cIpNhOyVno+YC96+61YR+y9zKfmDROwGvl3in6Qp4?= =?us-ascii?Q?JuaspEO7MFrv02RHYa3jrUjrlNoI/x3bTG/2S43Cos6iV0FC2TIP0ZYI+e+0?= =?us-ascii?Q?iIwiHnBWjr5g61VG9aNZnC+tyMu07bi+HetoDAw80/YLA5Q5qlSuiY6ww596?= =?us-ascii?Q?NW47AnBY/hXNTsq/3emc6l8/iFT6N78+fRDgB8e4bOzrRNAHrFqIIs2rntJ5?= =?us-ascii?Q?TieRfAV36R7QRriAtAm+8lAoCFCe+vlh/EjRdWvcpAeGyvR2WDmip+qggLHK?= =?us-ascii?Q?xzJb2444y3n3zz7X3cnIpbteZ0N8KcLqdrNal1X7gyRyTlUd3zCn5XUyEOm+?= =?us-ascii?Q?adbPGoBdkID2OP/vBDCPHuueKe52Fhxxgz0Y2xGF+WXZTdn4y8ThFDmO7ptr?= =?us-ascii?Q?SV+HV84HtMdDR8otkvs2e/FpFTSwcbZSmSBNSXzeKooKhj57qqFY7oXUQPNL?= =?us-ascii?Q?6NsSG37sCYHyWuTsp9niZembXIyWH5QM8vQokkbyWzq7zR6r6skuvVTW8/Ge?= =?us-ascii?Q?gkSJLsdk6hsES8ecyskrKB8jULzuxjXTXvXmtw7PELx2UpVN7DyJhnwTIrxy?= =?us-ascii?Q?xCa4a1LnmBFdrU3xwv/wsG7P8ajq9lW4Lk7eohY6TCY2hwVhLwutvOoGmYFc?= =?us-ascii?Q?G9itSNiFtAwfN/1JkNPJBHCvOU7KmUFhDkULPXlTrwvcdlhjK0fK6i0JmbyP?= =?us-ascii?Q?/LrCo63t0lkEQF0lM6FyDjTm7uWXpIbxwINY5oF+6TNXsNF9yQBouAYDBJ+U?= =?us-ascii?Q?lzHS9qxszoBSVW1ZQC2lVNPlo7iKKYYORtUZHbZA7hngP7l2FywfhesOaYrJ?= =?us-ascii?Q?ucjIqFzOC9Xni8XxuAagjgTSilnDspKHvEctSPFiv1tRBPXbsA5QhPru5EMF?= =?us-ascii?Q?kxWZjG9Tvv4zhoZuuwbbjT1sPrvbNr3X01vRz01yFk4NCCINSmHG3Fca5z5l?= =?us-ascii?Q?GKNluX37fv0Kza7qO1QJVWIp6DT6Kh8Ypt0qtQ6rJi1PrtdFmRf4fYJZeAAG?= =?us-ascii?Q?GQG1DrWUoK0J7hO/jlvaZMewGtpWnIh+JY/Q4fju48jyRTB98M4pnDr9PIer?= =?us-ascii?Q?UPqiVGHz/95Yuzshvkd4YpdFD76CNBI3qeErtY7pltwoJEStOPR6sgN8umeC?= =?us-ascii?Q?AdGe2iRJhCBiJXrcOFlT8+iyES0Z7+2yMTYCgS5C0x/ahIjJTvxfPoD3fpcd?= =?us-ascii?Q?DE2SEg4ehaIFighlC5NOa6LfmLuk87zXwgfIElfl+dUM89K1on3oFx9ouMyg?= =?us-ascii?Q?F2wMKN/UVA=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: 4105e72e-3579-407e-bf32-08da3e0f9713 X-MS-Exchange-CrossTenant-originalarrivaltime: 25 May 2022 05:29:50.6120 (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: 3PgI9Q4uln3mUPifOdP36esGX6IfYOqRXeP/fiGqetbH3XieD9XZFzkIwPw4njXKIoHpl17u3j9l+tHAHgSumQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR84MB1808 X-OriginatorOrg: hpe.com X-Proofpoint-ORIG-GUID: YhfW1HUqv8CJoLP1m8SMjTTJa9eCK1mK X-Proofpoint-GUID: YhfW1HUqv8CJoLP1m8SMjTTJa9eCK1mK 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-25_01,2022-05-23_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 malwarescore=0 phishscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 bulkscore=0 impostorscore=0 clxscore=1015 suspectscore=0 mlxscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2205250028 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Abner Chang > -----Original Message----- > From: Wang, Nickle (Server BIOS) > Sent: Wednesday, May 25, 2022 11:14 AM > To: devel@edk2.groups.io > Cc: Wang, Nickle (Server BIOS) ; Chang, Abner (HPS > SW/FW Technologist) > Subject: [edk2-staging][PATCH v2 2/3] 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 | 211 ++++++++++++++++++ > .../RedfishVersionLib/RedfishVersionLib.inf | 44 ++++ > RedfishClientPkg/RedfishClientLibs.dsc.inc | 1 + > RedfishClientPkg/RedfishClientPkg.dec | 4 +- > 6 files changed, 305 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..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. >=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..0fe2dd1bd0 > --- /dev/null > +++ b/RedfishClientPkg/Library/RedfishVersionLib/RedfishVersionLib.c > @@ -0,0 +1,211 @@ > +/** @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 > + // >=20 > + // According to Redfish specification "Protocol version" seciton, >=20 > + // GET operation on /redfish resource shall return protocol version >=20 > + // like below: >=20 > + // { >=20 > + // "v1": "/redfish/v1/" >=20 > + // } >=20 > + // >=20 > + if (JsonValueIsString (Value)) { >=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..61e65e3eca > --- /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 > + JsonLib >=20 > + PcdLib >=20 > + RedfishLib >=20 > + MemoryAllocationLib >=20 > + >=20 > +[Protocols] >=20 > + >=20 > +[Pcd] >=20 > + gEfiRedfishClientPkgTokenSpaceGuid.PcdDefaultRedfishVersion >=20 > + >=20 > diff --git a/RedfishClientPkg/RedfishClientLibs.dsc.inc > b/RedfishClientPkg/RedfishClientLibs.dsc.inc > index 91e5de4296..4f7a8b21f0 100644 > --- a/RedfishClientPkg/RedfishClientLibs.dsc.inc > +++ b/RedfishClientPkg/RedfishClientLibs.dsc.inc > @@ -28,3 +28,4 @@ >=20 > RedfishContentCodingLib|RedfishPkg/Library/RedfishContentCodingLibNull/ > RedfishContentCodingLibNull.inf >=20 >=20 > ConverterCommonLib|RedfishClientPkg/ConverterLib/edk2library/Converte > rCommonLib/ConverterCommonLib.inf >=20 >=20 > RedfishEventLib|RedfishClientPkg/Library/RedfishEventLib/RedfishEventLib.= i > nf >=20 > + > RedfishVersionLib|RedfishClientPkg/Library/RedfishVersionLib/RedfishVersi > onLib.inf >=20 > diff --git a/RedfishClientPkg/RedfishClientPkg.dec > b/RedfishClientPkg/RedfishClientPkg.dec > index 56e542f03c..f746b0ec30 100644 > --- a/RedfishClientPkg/RedfishClientPkg.dec > +++ b/RedfishClientPkg/RedfishClientPkg.dec > @@ -22,6 +22,7 @@ > [LibraryClasses] >=20 > RedfishFeatureUtilityLib|Include/Library/RedfishFeatureUtilityLib.h >=20 > RedfishEventLib|Include/Library/RedfishEventLib.h >=20 > + RedfishVersionLib|Include/Library/RedfishVersionLib.h >=20 >=20 >=20 > [LibraryClasses.Common.Private] >=20 > ## @libraryclass Redfish Helper Library >=20 > @@ -52,4 +53,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