grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 1/4] Allow non-default ports for HTTP requests


From: Andrei Borzenkov
Subject: Re: [PATCH 1/4] Allow non-default ports for HTTP requests
Date: Sun, 29 Jan 2017 09:50:54 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0

24.01.2017 03:35, Matthew Garrett пишет:
> Add support for passing ports in HTTP requests. This takes the form of:
> (http,serverip:portnum)/file
> ---
>  grub-core/net/http.c |  8 ++++++--
>  grub-core/net/net.c  | 10 +++++++++-
>  include/grub/net.h   |  1 +
>  3 files changed, 16 insertions(+), 3 deletions(-)
> 
> diff --git a/grub-core/net/http.c b/grub-core/net/http.c
> index 5aa4ad3..389a78e 100644
> --- a/grub-core/net/http.c
> +++ b/grub-core/net/http.c
> @@ -309,7 +309,7 @@ http_establish (struct grub_file *file, grub_off_t 
> offset, int initial)
>  {
>    http_data_t data = file->data;
>    grub_uint8_t *ptr;
> -  int i;
> +  int i, port;
>    struct grub_net_buff *nb;
>    grub_err_t err;
>  
> @@ -390,8 +390,12 @@ http_establish (struct grub_file *file, grub_off_t 
> offset, int initial)
>    grub_netbuff_put (nb, 2);
>    grub_memcpy (ptr, "\r\n", 2);
>  
> +  if (file->device->net->port)

0 is valid port number (at least I am not aware of any RFC that
prohibits its use).

> +    port = file->device->net->port;
> +  else
> +    port = HTTP_PORT;
>    data->sock = grub_net_tcp_open (file->device->net->server,
> -                               HTTP_PORT, http_receive,
> +                               port, http_receive,
>                                 http_err, http_err,
>                                 file);
>    if (!data->sock)
> diff --git a/grub-core/net/net.c b/grub-core/net/net.c
> index 10773fc..585f4f7 100644
> --- a/grub-core/net/net.c
> +++ b/grub-core/net/net.c
> @@ -1261,7 +1261,7 @@ grub_net_open_real (const char *name)
>    grub_net_app_level_t proto;
>    const char *protname, *server;
>    grub_size_t protnamelen;
> -  int try;
> +  int try, port = 0;
>  
>    if (grub_strncmp (name, "pxe:", sizeof ("pxe:") - 1) == 0)
>      {
> @@ -1278,7 +1278,14 @@ grub_net_open_real (const char *name)
>    else
>      {
>        const char *comma;
> +      char *colon;
>        comma = grub_strchr (name, ',');
> +      colon = grub_strchr (name, ':');

This conflicts with IPv6 addresses. Similar patches were already posted.
I suggested using (proto,server,port). This also allows empty server and
still using non-standard port.

More general at some point we should hit authentication, and so may need
to stuff user/password there. So we need to come up with extensible
framework.

Putting everything in "server" string may work, but then we need to
support IPv6 literals here - [fe80::1]:444 - at least, this is the only
way to use server:port I see. Also, we probably need to support escaping
of colons. Finally, speaking about user/password, we may need to support

user:address@hidden::1]:456

May be using (net,proto=http,server=xxx,port=yyy,user=uuu,...) which
allows adding arbitrary keywords at any time.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]