All of lore.kernel.org
 help / color / mirror / Atom feed
* Misc network boot patches
@ 2017-01-24  0:35 Matthew Garrett
  2017-01-24  0:35 ` [PATCH 1/4] Allow non-default ports for HTTP requests Matthew Garrett
                   ` (3 more replies)
  0 siblings, 4 replies; 26+ messages in thread
From: Matthew Garrett @ 2017-01-24  0:35 UTC (permalink / raw)
  To: grub-devel

Various patches that we're using to support network boot in our setup. Only
number 3 is a bugfix.



^ permalink raw reply	[flat|nested] 26+ messages in thread
* [PATCH 1/4] Allow non-default ports for HTTP requests
@ 2017-01-23 23:45 Matthew Garrett
  2017-01-23 23:45 ` [PATCH 3/4] Don't allocate a new address buffer if we receive multiple DNS responses Matthew Garrett
  0 siblings, 1 reply; 26+ messages in thread
From: Matthew Garrett @ 2017-01-23 23:45 UTC (permalink / raw)
  To: grub-devel; +Cc: 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)
+    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, ':');
+      if (colon)
+	{
+	  port = (int) grub_strtol(colon+1, NULL, 10);
+	  *colon = '\0';
+	}
       if (comma)
 	{
 	  protnamelen = comma - name;
@@ -1310,6 +1317,7 @@ grub_net_open_real (const char *name)
 	    if (!ret)
 	      return NULL;
 	    ret->protocol = proto;
+	    ret->port = port;
 	    ret->server = grub_strdup (server);
 	    if (!ret->server)
 	      {
diff --git a/include/grub/net.h b/include/grub/net.h
index 2192fa1..c517509 100644
--- a/include/grub/net.h
+++ b/include/grub/net.h
@@ -276,6 +276,7 @@ typedef struct grub_net
   grub_fs_t fs;
   int eof;
   int stall;
+  int port;
 } *grub_net_t;
 
 extern grub_net_t (*EXPORT_VAR (grub_net_open)) (const char *name);
-- 
2.9.3



^ permalink raw reply related	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2017-01-29  6:51 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-24  0:35 Misc network boot patches Matthew Garrett
2017-01-24  0:35 ` [PATCH 1/4] Allow non-default ports for HTTP requests Matthew Garrett
2017-01-29  6:50   ` Andrei Borzenkov
2017-01-24  0:35 ` [PATCH 2/4] Send a user class identifier in bootp requests and tag it as DHCP discover Matthew Garrett
2017-01-24  6:09   ` Michael Marineau
2017-01-24  0:36 ` [PATCH 3/4] Don't allocate a new address buffer if we receive multiple DNS responses Matthew Garrett
2017-01-24  3:55   ` Andrei Borzenkov
2017-01-24 20:52     ` Matthew Garrett
2017-01-24  0:36 ` [PATCH 4/4] Allow protocol to be separated from host with a semicolon Matthew Garrett
2017-01-24  4:02   ` Andrei Borzenkov
2017-01-24 20:50     ` Matthew Garrett
2017-01-25  3:48       ` Andrei Borzenkov
2017-01-25  4:06         ` Matthew Garrett
2017-01-25  4:15           ` Andrei Borzenkov
2017-01-25  4:25             ` Matthew Garrett
2017-01-25  6:56               ` Andrei Borzenkov
2017-01-25  7:16                 ` Matthew Garrett
2017-01-25  7:37                   ` Andrei Borzenkov
2017-01-25  9:00                     ` Matthew Garrett
2017-01-25  6:18       ` Michael Chang
2017-01-25  6:21         ` Matthew Garrett
2017-01-25  8:35           ` Michael Chang
2017-01-25  9:02             ` Matthew Garrett
2017-01-25 17:30       ` Andrei Borzenkov
2017-01-25 23:33         ` Matthew Garrett
  -- strict thread matches above, loose matches on Subject: below --
2017-01-23 23:45 [PATCH 1/4] Allow non-default ports for HTTP requests Matthew Garrett
2017-01-23 23:45 ` [PATCH 3/4] Don't allocate a new address buffer if we receive multiple DNS responses Matthew Garrett

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.