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 9656DD80144 for ; Fri, 12 Jan 2024 03:27:06 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=CcNODuhuYFZ9fuxbRfD07ZzWoY577QlIDAdA8by7fMQ=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:Received-SPF:From:To:CC:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20140610; t=1705030025; v=1; b=OBgZco7/BC+J/cJ0A5L4BA4RoQc3YaNHzJR24UaoE9rfZF5Idkk4T+DPKnqYX9Hne+cfcXbe QEPT75zPXoIwGOHQp7wI/j/6wVuv2Hwj2noGkEICzIOMAOToCOhNDPnVPITjVPEOsW3KkO4gxi7 T/5d9pEg8BQYppLzM5lFVr20= X-Received: by 127.0.0.2 with SMTP id wJAfYY7687511xC29xmqdREA; Thu, 11 Jan 2024 19:27:05 -0800 X-Received: from NAM11-BN8-obe.outbound.protection.outlook.com (NAM11-BN8-obe.outbound.protection.outlook.com [40.107.236.40]) by mx.groups.io with SMTP id smtpd.web10.11646.1705030024510341373 for ; Thu, 11 Jan 2024 19:27:04 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g1QsE5JM5tE+a3ObITYN2krJlOJftQMRtpaeWcBbHKkdRZIc8CI2hVe6roLradUL0Oeleq/gl+hzJBl7AGRTykyekBEIZQl71eEeoGBL8/dUYnImMiY1y8zvdYSMCKBOGW//x2x/tOJmym4vlzhx2aK0nImzk4ta3lBu1cT1H9tpD7Qi5GXsuR+VdYSciIaVeKOxgDUHyNmMUwoAHnoVqTz38VXKYB7bbAJ1CtWhFsqBWZSE4hpgOtD/8FIyvtVhR0BtE0bn5RVcH3I6FsawNHswjoJtahoyvsBXrWTXC7tq95LKeykuupDEbn460ikLHmdQ9B0oe9m0PrKg9aeWPQ== 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=2IjxUSIL+cjzjkIDCFgy7bmmak9xFL+1tGQWNJcX8Zo=; b=CPYk9OuYzJMS2qPuqN0NE131JF9Yy5NqSsE96MwKeW1/pF5sEnFAXdYtcx7C7dtkaxvHxUB7ugaFoe3z85jZilP1mY1N4QFZM8suBSpT1bGrUo3bpMf0m/c75Kj8Gwvgp+BnzwvTr59L3m+uKpPrsRerRYx6tnHO2ltWXmtUSSt/XIgyMmcJNObcLiJBe6KN3EjOa9P6l6zcB7tE93wKDBnZvGRUzpWrkZhrFBOBzWbRA9ASR3weECc9xtTjbOeRg4KNrWPX0ghMsz6mcdKCCmPmFydLyEgcoT0hYiOX3vLKhGKLfKUmNQJnNTZ+Nm3FqP9FMYPsQTauUUdMkBiRkw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) X-Received: from BL6PEPF00013E00.NAMP222.PROD.OUTLOOK.COM (2603:10b6:22e:400:0:1001:0:1a) by DM4PR12MB5104.namprd12.prod.outlook.com (2603:10b6:5:393::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7181.21; Fri, 12 Jan 2024 03:27:01 +0000 X-Received: from BL6PEPF0001AB58.namprd02.prod.outlook.com (2a01:111:f403:f902::1) by BL6PEPF00013E00.outlook.office365.com (2603:1036:903:4::4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.34 via Frontend Transport; Fri, 12 Jan 2024 03:27:01 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C X-Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF0001AB58.mail.protection.outlook.com (10.167.241.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7181.14 via Frontend Transport; Fri, 12 Jan 2024 03:27:00 +0000 X-Received: from TPE-L1-ABNCHANG.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Thu, 11 Jan 2024 21:26:59 -0600 From: "Chang, Abner via groups.io" To: CC: Nickle Wang , Igor Kulchytskyy Subject: [edk2-devel] [edk2-redfish-client][PATCH 2/3] RedfishClientPkg/RedfishFeatureUtilityLib: Add two helper functions Date: Fri, 12 Jan 2024 11:26:21 +0800 Message-ID: <20240112032622.274-2-abner.chang@amd.com> In-Reply-To: <20240112032622.274-1-abner.chang@amd.com> References: <20240112032622.274-1-abner.chang@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB58:EE_|DM4PR12MB5104:EE_ X-MS-Office365-Filtering-Correlation-Id: dd950f89-dc37-4a11-4c74-08dc131e570e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: tB9x47WLSaI1VKnSByU+J3ARcTfSZ1091AtZc9RAtHH+i3Lbm74kG/WxV87gEN5MyRd/Ahz7qBmPZ+2+VgQAD4Q4apmYgGZqNh5QXgNPIWJHsUH+CQcovdxneQkEIH0z4GwF9uWtMHbu2/aOexafkmf3WUy0470/T0k2cFBnukr5ZX1PqK6hB9KI3OIRGOiK9Z6gG0fmVlSoJnKkfTof7hXPG830s0knpXSSHC09/ttopSCPolFgND9QbOxoJIb8WQMHYx8fYvu/AG8MaeeFwWFT4I1/mJXJZws60Y7TwEj8VbbrzfAQugB2GniwCVx+xI61LBb62wrr3iZ0HKQD3K4T83YsZpheY5eE3jHKYefbkYmwrufcHD9dL9D2aPjTYgvt9jq+sSQcZxOMhtnUmd+EMHgNbG6QYjKiXOFQ90wxVG631PBe+a479KIhtE4nSMGWYXq6KQ29nxoUZrbNfnwrJ9+x3KkjyULZGDS6PlhHn8cUpJf3ohq+2zBrKGk3Ke4TqcKSRcAN7qunF23LnAD8Qhg7D5taj20hoyzGsNt1tLOOrR2GYWWWbxonP1LLn6lIHN94O9ghhoAX+C265+8h1lKAY/cn+uY45IdLA7nDEOe1dsFbYuM5kGxKIJ8qPI8277hPTQqoqE2rlwLNJsfHtwa1MBSXonfg9otqYKfDKZRPuA3VKIG1afqZiAj3RC65L+tb4uZLV8ALsnL3GRUigmWsatZ8PxKzKeWuw2SeekCfRjkibb1DiOXndtDFSCnx0dQBqRdUU+RRpAZ5YQ== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2024 03:27:00.9800 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dd950f89-dc37-4a11-4c74-08dc131e570e X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB58.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5104 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,abner.chang@amd.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 5dnlqRiLd22hL0CPhMS6m6v0x7686176AA= Content-Transfer-Encoding: quoted-printable Content-Type: text/plain X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b="OBgZco7/"; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=none; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}") From: Abner Chang - Add RedfishRemoveUnchangeableProperties () to remove unchangeable Redfish properties such as @OData.id. - Add DestoryRedfishCharArray () to free Redfish string array. Signed-off-by: Abner Chang Cc: Nickle Wang Cc: Igor Kulchytskyy --- .../RedfishFeatureUtilityLib.inf | 1 + .../Library/RedfishFeatureUtilityLib.h | 35 ++++++++ .../RedfishFeatureUtilityLib.c | 79 +++++++++++++++++++ 3 files changed, 115 insertions(+) diff --git a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatu= reUtilityLib.inf b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/Redfis= hFeatureUtilityLib.inf index 63330c8e9d..d8f3da3732 100644 --- a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtili= tyLib.inf +++ b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtili= tyLib.inf @@ -37,6 +37,7 @@ [LibraryClasses] BaseLib BaseMemoryLib + ConverterCommonLib DebugLib MemoryAllocationLib RedfishLib diff --git a/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h b/= RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h index 0f8aede5c4..1b6d3f4cf8 100644 --- a/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h +++ b/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h @@ -821,6 +821,23 @@ AddRedfishCharArray ( IN UINTN ArraySize ); =20 +/** + + Destroy Redfish string array + + @param[in] Head The head of string array. + @param[in] ArraySize The size of StringArray. + + @retval EFI_SUCCESS String array is destroyed successfully. + @retval Others Error happens + +**/ +EFI_STATUS +DestoryRedfishCharArray ( + IN RedfishCS_char_Array *Head, + IN UINTN ArraySize + ); + /** =20 Create numeric array and append to array node in Redfish JSON convert fo= rmat. @@ -1024,4 +1041,22 @@ ValidateRedfishStringArrayValues ( OUT BOOLEAN *ValueChanged ); =20 +/** + This function removes the unchangeable Redfish properties from input Jso= nString. + New JSON string is returned in JsonString and the memory of original poi= nter to input + JsonString was freed. Caller is responsible to free the memory pointed b= y output + JsonString. + + @param[in,out] JsonString On input, this is the pointer to original JS= ON string. + On output, this is the new pointer to the up= dated JSON string. + + @retval EFI_SUCCESS The unchangeable Redfish properties were removed f= rom original JSON string. + @retval Others There are problems to remove unchangeable Redfish = properties. + +**/ +EFI_STATUS +RedfishRemoveUnchangeableProperties ( + IN OUT CHAR8 **JsonString + ); + #endif diff --git a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatu= reUtilityLib.c b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishF= eatureUtilityLib.c index aa723264e8..b16a811bb1 100644 --- a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtili= tyLib.c +++ b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtili= tyLib.c @@ -3412,6 +3412,40 @@ AddRedfishCharArray ( return EFI_SUCCESS; } =20 +/** + + Destroy Redfish string array + + @param[in] Head The head of string array. + @param[in] ArraySize The size of StringArray. + + @retval EFI_SUCCESS String array is destroyed successfully. + @retval Others Error happens + +**/ +EFI_STATUS +DestoryRedfishCharArray ( + IN RedfishCS_char_Array *Head, + IN UINTN ArraySize + ) +{ + UINTN Index; + RedfishCS_char_Array *NextPointer; + + if ((Head =3D=3D NULL) || (ArraySize =3D=3D 0)) { + return EFI_INVALID_PARAMETER; + } + + for (Index =3D 0; Index < ArraySize; Index++) { + NextPointer =3D Head->Next; + if (Head !=3D NULL) { + FreePool (Head); + } + Head =3D NextPointer; + } + return EFI_SUCCESS; +} + /** =20 Create numeric array and append to array node in Redfish JSON convert fo= rmat. @@ -3935,6 +3969,51 @@ ValidateRedfishStringArrayValues ( return EFI_SUCCESS; } =20 +/** + This function removes the unchangeable Redfish properties from input Jso= nString. + New JSON string is returned in JsonString and the memory of original poi= nter to input + JsonString was freed. Caller is responsible to free the memory pointed b= y output + JsonString. + + @param[in,out] JsonString On input, this is the pointer to original JS= ON string. + On output, this is the new pointer to the up= dated JSON string. + + @retval EFI_SUCCESS The unchangeable Redfish properties were removed f= rom original JSON string. + @retval Others There are problems to remove unchangeable Redfish = properties. + +**/ +EFI_STATUS +RedfishRemoveUnchangeableProperties ( + IN OUT CHAR8 **JsonString + ) +{ + RedfishCS_status Status; + CHAR8 *UpdatedJsonString; + + if ((JsonString =3D=3D NULL) || (*JsonString =3D=3D NULL)) { + return EFI_INVALID_PARAMETER; + } + + UpdatedJsonString =3D AllocateZeroPool (AsciiStrSize (*JsonString)); + if (UpdatedJsonString =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a: Insufficient memory for UpdatedJsonString.\n= ", __func__)); + return EFI_OUT_OF_RESOURCES; + } + + Status =3D RemoveUnchangeableProperties ( + (RedfishCS_char *)*JsonString, + (RedfishCS_char *)UpdatedJsonString, + (RedfishCS_uint32)AsciiStrSize (*JsonString) + ); + if (Status !=3D RedfishCS_status_success) { + return EFI_DEVICE_ERROR; + } + + FreePool (*JsonString); + *JsonString =3D UpdatedJsonString; + return EFI_SUCCESS; +} + /** =20 Install Boot Maintenance Manager Menu driver. --=20 2.37.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#113648): https://edk2.groups.io/g/devel/message/113648 Mute This Topic: https://groups.io/mt/103676919/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-