public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Fu, Siyuan" <siyuan.fu@intel.com>
To: "Wu, Jiaxin" <jiaxin.wu@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Ye, Ting" <ting.ye@intel.com>, Laszlo Ersek <lersek@redhat.com>
Subject: Re: [Patch] NetworkPkg/HttpDxe: Stripped square brackets in IPv6 expressed HostName.
Date: Wed, 1 Aug 2018 02:05:51 +0000	[thread overview]
Message-ID: <B1FF2E9001CE9041BD10B825821D5BC58B5BB3D1@SHSMSX103.ccr.corp.intel.com> (raw)
In-Reply-To: <20180801015442.6932-1-Jiaxin.wu@intel.com>

Hi, Jiaxin

The HttpLib already has HttpUrlGetIp6() for this.

BestRegards
Fu Siyuan

> -----Original Message-----
> From: Wu, Jiaxin
> Sent: Wednesday, August 1, 2018 9:55 AM
> To: edk2-devel@lists.01.org
> Cc: Ye, Ting <ting.ye@intel.com>; Fu, Siyuan <siyuan.fu@intel.com>; Laszlo
> Ersek <lersek@redhat.com>; Wu, Jiaxin <jiaxin.wu@intel.com>
> Subject: [Patch] NetworkPkg/HttpDxe: Stripped square brackets in IPv6
> expressed HostName.
> 
> In URI, the colon (:) is used to terminate the HostName path before
> a port number. However, if HostName is expressed as IPv6 format, colon
> characters in IPv6 addresses will conflict with the colon before port
> number. To alleviate this conflict in URI, the IPv6 expressed HostName
> are enclosed in square brackets ([]). To record the real IPv6 HostName,
> square brackets should be stripped.
> 
> Cc: Ye Ting <ting.ye@intel.com>
> Cc: Fu Siyuan <siyuan.fu@intel.com>
> Cc: Laszlo Ersek <lersek@redhat.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
> ---
>  NetworkPkg/HttpDxe/HttpImpl.c | 17 ++++++++++++++---
>  1 file changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/NetworkPkg/HttpDxe/HttpImpl.c b/NetworkPkg/HttpDxe/HttpImpl.c
> index 17deceb395..e05ee9344b 100644
> --- a/NetworkPkg/HttpDxe/HttpImpl.c
> +++ b/NetworkPkg/HttpDxe/HttpImpl.c
> @@ -403,14 +403,25 @@ EfiHttpRequest (
>      Status = HttpParseUrl (Url, (UINT32) AsciiStrLen (Url), FALSE,
> &UrlParser);
>      if (EFI_ERROR (Status)) {
>        goto Error1;
>      }
> 
> -    HostName   = NULL;
> -    Status     = HttpUrlGetHostName (Url, UrlParser, &HostName);
> +    Status = HttpUrlGetHostName (Url, UrlParser, &HostName);
>      if (EFI_ERROR (Status)) {
> -     goto Error1;
> +      goto Error1;
> +    }
> +
> +    if (HttpInstance->LocalAddressIsIPv6 && AsciiStrSize (HostName) > 2
> &&
> +        HostName[0] == '[' && *(HostName + (AsciiStrSize (HostName) - 2))
> == ']') {
> +      //
> +      // HostName format is expressed as IPv6, so, remove '[' and ']'.
> +      //
> +      HostNameSize = AsciiStrSize (HostName) - 2;
> +
> +      CopyMem (HostName, HostName + 1, HostNameSize - 1);
> +
> +      *(HostName + HostNameSize - 1) = '\0';
>      }
> 
>      Status = HttpUrlGetPort (Url, UrlParser, &RemotePort);
>      if (EFI_ERROR (Status)) {
>        if (HttpInstance->UseHttps) {
> --
> 2.17.1.windows.2



  reply	other threads:[~2018-08-01  2:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-01  1:54 [Patch] NetworkPkg/HttpDxe: Stripped square brackets in IPv6 expressed HostName Jiaxin Wu
2018-08-01  2:05 ` Fu, Siyuan [this message]
2018-08-01  2:42   ` Wu, Jiaxin
2018-08-01  3:22     ` Fu, Siyuan
2018-08-01  9:49 ` Laszlo Ersek
2018-08-02  1:24   ` Wu, Jiaxin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=B1FF2E9001CE9041BD10B825821D5BC58B5BB3D1@SHSMSX103.ccr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox