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 30CB4D8100D for ; Fri, 12 Jan 2024 03:27:07 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=ZkZ7TUlwNxyEuvoKzuK0Gtw04aYinWVaGtDMZgN4uWE=; 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=D4EnB40SgdmteqztaIm/uXqSowgHqROSZ93r5JpkaC2FbNwQWzJ6y5znhdCcSfG+BrhF+moY 64kUUlO70nGoNKlzLxzgfAwNAMrb6U2gOle08YFkELyHQMpFLdEuHM7f+K1saZgFmg8cSZHA3ru h886iVISN1NyeGWUf80FqWUU= X-Received: by 127.0.0.2 with SMTP id LSZ3YY7687511xdVfOuzWieT; Thu, 11 Jan 2024 19:27:05 -0800 X-Received: from NAM10-MW2-obe.outbound.protection.outlook.com (NAM10-MW2-obe.outbound.protection.outlook.com [40.107.94.44]) by mx.groups.io with SMTP id smtpd.web10.11648.1705030025409722886 for ; Thu, 11 Jan 2024 19:27:05 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A6aZQQWmR/lqhOsMvPAWxHuzcJwt/V3eBMm8Mgvea5P5kG5k5bmMTBnhPoLeSsxeX3Mdr9ADW8kTDHCufQfEW9Lx9WPTgYS93KAK9z/uHygVwPixUfF8QarSi/vCHMyb2cSLZul9ykaA0Nm5eIeaEmG4xzOy+w+iCA0azTqOazUo/Jk2km1pwqAneNilm2Uh0VvNt2LLw8VC9nDFGA9xY1VFiHOBxonMF3S1CvE4mPxDPUzMM0OkcezK9wIc0NfvFN6UAOcLpqKMjWuKcphLacSFKL29Yo75mC+TS1jOpby2G28gLPFDqzLHdoEl79IiHsLNZq3/zc99gNgxIE+ZQg== 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=jHoWrohgh723ZFnQPvu2+bBogIwMU1QSWUYUkqHzKkk=; b=oNsXMZwieYcaWgq4GPZZqYJ8Fmt2d6eTgc0Dhkpn1xBXZyojFr30IXbwHIuls2iTFqmTJUU9dYOOCQ7Yex6z3GYyZno6FsxpK2SsXiIShRBdbtYHqa/LktspMpWyU/KvlCvwDWSoBgnIncYZXOzepImOMudXgRAJUUR+PgNx6iGgltK9aAxuTXm6krcTVfZiRaiqw09MZjiNImgUVC+w36bp9oWY+4goEUw1SF+SuMetghPYszYh88bn+ATkLB1gxk57EBn9wXtGOHKbQtMc0bXH0RM4utjWKTO96mQL6olG6bTrH0nk/fh90b8r8DNBvfmIRrpO4VVa/z5NVrTYeA== 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 BLAPR05CA0017.namprd05.prod.outlook.com (2603:10b6:208:36e::29) by BY5PR12MB4901.namprd12.prod.outlook.com (2603:10b6:a03:1c5::11) 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:03 +0000 X-Received: from BL6PEPF0001AB57.namprd02.prod.outlook.com (2603:10b6:208:36e:cafe::13) by BLAPR05CA0017.outlook.office365.com (2603:10b6:208:36e::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.13 via Frontend Transport; Fri, 12 Jan 2024 03:27:02 +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 BL6PEPF0001AB57.mail.protection.outlook.com (10.167.241.9) 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:02 +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:27:01 -0600 From: "Chang, Abner via groups.io" To: CC: Nickle Wang , Igor Kulchytskyy Subject: [edk2-devel] [edk2-redfish-client][PATCH 3/3] RedfishClientPkg/ConverterLib: Function to remove Redfish unchangeable properties Date: Fri, 12 Jan 2024 11:26:22 +0800 Message-ID: <20240112032622.274-3-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: BL6PEPF0001AB57:EE_|BY5PR12MB4901:EE_ X-MS-Office365-Filtering-Correlation-Id: ccf58f65-a0e7-447f-08b1-08dc131e57e1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: sz9hfN17JoLDSvkou19TAEaK3a2acvo34jJdd2v4igiy02GqwrysvtuoZwGR8Q7EZ601Cbul2lEBQyg6riJ1bxVcw29vzm7GnrYhx3oITPBdx+0sS5Ss2qxcuRR53cdUut3xO9FHx9x5htYSJ+bDwdy1fk28kUCXnCXCGbmZMo9NXy0Tq4XOIe7xpBqK4Rmztob3/dG4Uh1jb/7RxlsrfVVuKWuG4FZa+TBNqvTHg0JLjMkHg+VQ9mz4lraOM75snPVgDIhTdGy1mJH2gXJk3TIGXuF0nmUrB7XFMVCHO0++Uq/7hO7z5p/rts2sVDsriN9j/4gayys/MWDnc0Pp01r47BWnvBZu7/mQbwDUfcdx6R62V/8Wa6v/cORPwicD+g0OE9Sa2Eh+3rda7xmcmZeaPlSq2X4E2yKRRWdrjfPYEq9/g14MkYqxJ0eokOIf4UoCXcyVbH1YW1bUDzkAyscJPztMcwUcDBJGa3n8U1r0NEOG4LR1mo9XVlmw1DG8dfnRXLqSNVIBNo1n4hoHFT1awYKD0atRSorJc+5z3e8y89VW23VORvLXADjYgdKKpqrzl7u8o5pX/9zQRQmtevIQyfLv4iO4pt2B242R/hbz3VhTTWKTL5QOm7bitaLKafJPW/XezjKfv56H7yiq5CWzQtaVvmI45D5bvcVCH9iXzCqBwWW3VYD8KTNR6voSMEzuH/Dx+ej+GWRnhWQQSjmCx6MfK4yu0QemIICFLcWZZpR0fUFEAkRov6CeWnmd9srAGz41DEJCETX3PKBEMg== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2024 03:27:02.3611 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ccf58f65-a0e7-447f-08b1-08dc131e57e1 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: BL6PEPF0001AB57.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4901 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: 2Ywz8YaSHtQGhmU4eqmflBR5x7686176AA= 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=D4EnB40S; 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 Update RedfishCsCommon.c to add a function to remove Redfish unchangeable properties. Signed-off-by: Abner Chang Cc: Nickle Wang Cc: Igor Kulchytskyy --- .../ConverterLib/include/RedfishCsCommon.h | 20 +++++++ .../ConverterLib/src/RedfishCsCommon.c | 55 +++++++++++++++++++ 2 files changed, 75 insertions(+) diff --git a/RedfishClientPkg/ConverterLib/include/RedfishCsCommon.h b/Redf= ishClientPkg/ConverterLib/include/RedfishCsCommon.h index e454ab0b73..f5278015aa 100644 --- a/RedfishClientPkg/ConverterLib/include/RedfishCsCommon.h +++ b/RedfishClientPkg/ConverterLib/include/RedfishCsCommon.h @@ -104,6 +104,26 @@ DestoryCsMemory ( RedfishCS_void *rootCs ); =20 +/** + This function removes the unchangeable Redfish properties from JSON raw = text + The content in JsonString is left unmodified, the caller has to give eno= ungh + memory pointed by NewJsonBuffer in the size of BufferSize. + + JsonString Input JSON raw string + NewJsonBuffer Pointer to memory for the updated JSON raw string in + size of BuufferSize. + BuufferSize The buffer size of NewJsonBuffer + + Return RedfishCS_status. + +**/ +RedfishCS_status +RemoveUnchangeableProperties ( + RedfishCS_char *JsonString, + RedfishCS_char *NewJsonBuffer, + RedfishCS_uint32 BuufferSize + ); + typedef struct _RedfishCS_char_Array RedfishCS_char_Array; typedef struct _RedfishCS_int64_Array RedfishCS_int64_Array; typedef struct _RedfishCS_bool_Array RedfishCS_bool_Array; diff --git a/RedfishClientPkg/ConverterLib/src/RedfishCsCommon.c b/RedfishC= lientPkg/ConverterLib/src/RedfishCsCommon.c index fd31e5296b..c6996d7d5d 100644 --- a/RedfishClientPkg/ConverterLib/src/RedfishCsCommon.c +++ b/RedfishClientPkg/ConverterLib/src/RedfishCsCommon.c @@ -1461,3 +1461,58 @@ CsEmptyPropLinkToJson ( =20 return RedfishCS_status_success; } + +/** + This function removes the unchangeable Redfish properties from JSON raw = text + The content in JsonString is left unmodified, the caller has to give eno= ungh + memory pointed by NewJsonBuffer in the size of BufferSize. + + JsonString Input JSON raw string + NewJsonBuffer Pointer to memory for the updated JSON raw string in + size of BuufferSize. + BuufferSize The buffer size of NewJsonBuffer + + Return RedfishCS_status. + +**/ +RedfishCS_status +RemoveUnchangeableProperties ( + RedfishCS_char *JsonString, + RedfishCS_char *NewJsonBuffer, + RedfishCS_uint32 BuufferSize + ) +{ + json_t *JsonObj; + RedfishCS_char *TempChar; + RedfishCS_status Status; + + if ((JsonString =3D=3D NULL) || (NewJsonBuffer =3D=3D NULL)) { + return RedfishCS_status_invalid_parameter; + } + + JsonObj =3D json_loads (JsonString, 0, NULL); + if (JsonObj =3D=3D NULL) { + return RedfishCS_status_unknown_error; + } + + json_object_del (JsonObj, "@odata.type"); + json_object_del (JsonObj, "@odata.id"); + json_object_del (JsonObj, "Id"); + json_object_del (JsonObj, "Name"); + + TempChar =3D json_dumps ((json_t *)JsonObj, JSON_INDENT (2)); + if (TempChar !=3D NULL) { + if ((strlen (TempChar) + 1) > BuufferSize) { + Status =3D RedfishCS_status_insufficient_memory; + } else { + memcpy (NewJsonBuffer, TempChar, strlen (TempChar) + 1); + free (TempChar); + Status =3D RedfishCS_status_success; + } + } else { + Status =3D RedfishCS_status_unknown_error; + } + json_decref(JsonObj); + return Status; +} + --=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 (#113649): https://edk2.groups.io/g/devel/message/113649 Mute This Topic: https://groups.io/mt/103676920/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-