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 62065740039 for ; Thu, 14 Dec 2023 23:25:19 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=KnsZUo2Ohmiq5guAIRLByf96Hl8PGnnLFDIFU8HztNs=; c=relaxed/simple; d=groups.io; h=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; s=20140610; t=1702596318; v=1; b=JQ0cgQ7WCzBLoQeFwYcNYOk8vNr+tqByS0L4jnFq+DYLGBzDISBOfqzGSC/GoZy1Hrpqxwoc FMJErWVpTqGujH9LBoz6jer41puSdsmNuO6lXZ5hJO9Olfxre9EmbB6J1T60i3lx/abpc7Bx7wW 4J9HdBMqgCv/AzkHPFJlLGFw= X-Received: by 127.0.0.2 with SMTP id 9gVeYY7687511xMCOWvVjHuh; Thu, 14 Dec 2023 15:25:18 -0800 X-Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) by mx.groups.io with SMTP id smtpd.web10.44683.1702596314463002213 for ; Thu, 14 Dec 2023 15:25:14 -0800 X-Received: by mail-lf1-f41.google.com with SMTP id 2adb3069b0e04-50e0d1f9fe6so40037e87.1 for ; Thu, 14 Dec 2023 15:25:14 -0800 (PST) X-Gm-Message-State: GLxJVL3PksktAiXPJI4pcGlCx7686176AA= X-Google-Smtp-Source: AGHT+IE8ysKGk2TleqXJLfkxPP+gmM4BxItYO2tFS2pHaAOlyyGsKVA5M34aBZ9Oi4hKypISoNtRiw== X-Received: by 2002:ac2:5feb:0:b0:50b:e3c1:c99d with SMTP id s11-20020ac25feb000000b0050be3c1c99dmr4052337lfg.61.1702596312620; Thu, 14 Dec 2023 15:25:12 -0800 (PST) X-Received: from localhost.localdomain ([79.164.221.98]) by smtp.gmail.com with ESMTPSA id j24-20020ac24558000000b0050bfe5815e7sm1973119lfm.165.2023.12.14.15.25.11 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 14 Dec 2023 15:25:12 -0800 (PST) From: "Mike Maslenkin" To: devel@edk2.groups.io Cc: abner.chang@amd.com, nicklew@nvidia.com, igork@ami.com, Mike Maslenkin Subject: [edk2-devel] [PATCH v2 14/14] RedfishPkg: RedfishDiscoverDxe: add [] brackets to URI for IPv6 addresses Date: Fri, 15 Dec 2023 02:24:58 +0300 Message-Id: <20231214232458.4636-15-mike.maslenkin@gmail.com> In-Reply-To: <20231214232458.4636-1-mike.maslenkin@gmail.com> References: <20231214232458.4636-1-mike.maslenkin@gmail.com> MIME-Version: 1.0 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,mike.maslenkin@gmail.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=JQ0cgQ7W; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io URI is generated based on the RedfishLocation containing an ASCII string representing the IP address. So, in the case of IPv4 the canonical representation of an IPv4 address was inserted into the resulting Unicode string i.e: "http{,s}://X.X.X.X/". In the case of IPv6, to access resources, the IP address must be specified in brackets, i.e. the resulting string should look like: "http{,s}://[X::X:X:X:X]/". Cc: Abner Chang Cc: Nickle Wang Cc: Igor Kulchytskyy Signed-off-by: Mike Maslenkin --- .../RedfishDiscoverDxe/RedfishDiscoverDxe.c | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c b/RedfishPk= g/RedfishDiscoverDxe/RedfishDiscoverDxe.c index 9d1678c3429e..38eaf4f6decc 100644 --- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c +++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c @@ -715,6 +715,7 @@ DiscoverRedfishHostInterface ( The function initalizes particular strings into EFI_REDFISH_DISCOVERED_I= NFORMATION structure=0D =0D @param[in] Information EFI_REDFISH_DISCOVERED_INFORMATION=0D + @param[in] IsIpv6 Flag indicating IP version 6 protocol = is used=0D @param[in] RedfishVersion Redfish version.=0D @param[in] RedfishLocation Redfish location.=0D @param[in] Uuid Service UUID string.=0D @@ -729,6 +730,7 @@ STATIC VOID=0D InitInformationData (=0D IN EFI_REDFISH_DISCOVERED_INFORMATION *Information,=0D + IN BOOLEAN IsIpv6,=0D IN UINTN *RedfishVersion OPTIONAL,=0D IN CONST CHAR8 *RedfishLocation OPTIONAL,=0D IN CONST CHAR8 *Uuid OPTIONAL,=0D @@ -738,7 +740,8 @@ InitInformationData ( IN CONST CHAR8 *ProductVer OPTIONAL=0D )=0D {=0D - UINTN AllocationSize;=0D + UINTN AllocationSize;=0D + CONST CHAR8 *IpAddress;=0D =0D if (RedfishVersion !=3D NULL) {=0D Information->RedfishVersion =3D *RedfishVersion;=0D @@ -746,10 +749,21 @@ InitInformationData ( }=0D =0D if (RedfishLocation !=3D NULL) {=0D - AllocationSize =3D AsciiStrSize (RedfishLocation) * sizeof (CHA= R16);=0D + AllocationSize =3D AsciiStrSize (RedfishLocation) * sizeof (CHAR16);=0D + IpAddress =3D RedfishLocation;=0D +=0D + if (IsIpv6) {=0D + AllocationSize +=3D 2 * sizeof (CHAR16); // take into account '[' an= d ']'=0D + }=0D +=0D Information->Location =3D AllocatePool (AllocationSize);=0D if (Information->Location !=3D NULL) {=0D - AsciiStrToUnicodeStrS (RedfishLocation, Information->Location, Alloc= ationSize);=0D + if (IsIpv6) {=0D + UnicodeSPrintAsciiFormat (Information->Location, AllocationSize, "= [%a]", IpAddress);=0D + } else {=0D + AsciiStrToUnicodeStrS (RedfishLocation, Information->Location, All= ocationSize);=0D + }=0D +=0D DEBUG ((DEBUG_MANAGEABILITY, "Redfish service location: %s.\n", Info= rmation->Location));=0D } else {=0D DEBUG ((=0D @@ -991,6 +1005,7 @@ AddAndSignalNewRedfishService ( =0D InitInformationData (=0D &DiscoveredInstance->Information,=0D + CheckIsIpVersion6 (NetworkInterface),=0D RedfishVersion,=0D RedfishLocation,=0D Uuid,=0D --=20 2.32.0 (Apple Git-132) -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#112563): https://edk2.groups.io/g/devel/message/112563 Mute This Topic: https://groups.io/mt/103181051/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-