public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Adriano Cordova <adrianox@gmail.com>
To: u-boot@lists.denx.de
Cc: joe.hershberger@ni.com, rfried.dev@gmail.com,
	jerome.forissier@linaro.org, xypron.glpk@gmx.de,
	ilias.apalodimas@linaro.org, Adriano Cordova <adrianox@gmail.com>
Subject: [PATCH v2 3/7] net: wget: Add interface to issue wget_requests using wget_http_info
Date: Mon, 11 Nov 2024 18:08:57 -0300	[thread overview]
Message-ID: <20241111210901.560691-4-adrianox@gmail.com> (raw)
In-Reply-To: <20241111210901.560691-1-adrianox@gmail.com>

Declare and define a global default struct wget_http_info
and an interface to issue wget requests providing a custom
struct wget_http_info. This code is common to legacy wget
and lwip wget. The idea is that the command wget should use
the default wget_http_info and other internal u-boot code
can call wget_request with their own wget_http_info struct.

Signed-off-by: Adriano Cordova <adrianox@gmail.com>
---

Changes in v2:
- Instead of having a single global wget_http_info struct, let
  the user of wget (e.g. the efi code) provide an instance of
  wget_http_info to wget with the desired parameters. This lets
  the user cache the wget paramenters in their wget_http_info
  struct as desired (e.g. the content length from a HEAD request
  to a subsequent GET request, see the next efi patch). 
  If none is provided, wget uses default_wget_info.
- Add wget_request to trigger a wget request with a custom
  wget_http_info struct.

 include/net-common.h |  4 ++++
 net/net-common.c     | 14 ++++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/include/net-common.h b/include/net-common.h
index 8985b81c2d..1efb0db9ff 100644
--- a/include/net-common.h
+++ b/include/net-common.h
@@ -554,4 +554,8 @@ struct wget_http_info {
 	char *headers;
 };
 
+extern struct wget_http_info default_wget_info;
+extern struct wget_http_info *wget_info;
+int wget_request(ulong dst_addr, char *uri, struct wget_http_info *info);
+
 #endif /* __NET_COMMON_H__ */
diff --git a/net/net-common.c b/net/net-common.c
index a7f767d5e9..45288fe5f8 100644
--- a/net/net-common.c
+++ b/net/net-common.c
@@ -1,4 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0
+#include <net-common.h>
 
 void copy_filename(char *dst, const char *src, int size)
 {
@@ -11,3 +12,16 @@ void copy_filename(char *dst, const char *src, int size)
 		*dst++ = *src++;
 	*dst = '\0';
 }
+
+struct wget_http_info default_wget_info = {
+	.method = WGET_HTTP_METHOD_GET,
+	.set_bootdev = true,
+};
+
+struct wget_http_info *wget_info;
+
+int wget_request(ulong dst_addr, char *uri, struct wget_http_info *info)
+{
+	wget_info = info ? info : &default_wget_info;
+	return wget_with_dns(dst_addr, uri);
+}
-- 
2.43.0


  parent reply	other threads:[~2024-11-12  2:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-11 21:08 [PATCH v2 0/7] wget: Expose wget to applications Adriano Cordova
2024-11-11 21:08 ` [PATCH v2 1/7] net: Kconfig: add CONFIG_WGET symbol Adriano Cordova
2024-11-16 20:33   ` Heinrich Schuchardt
2024-11-11 21:08 ` [PATCH v2 2/7] net: wget: add definition of struct wget_http_info Adriano Cordova
2024-11-16 20:29   ` Heinrich Schuchardt
2024-11-11 21:08 ` Adriano Cordova [this message]
2024-11-11 21:08 ` [PATCH v2 4/7] net: wget: integrate struct wget_info into legacy wget code Adriano Cordova
2024-11-11 21:08 ` [PATCH v2 5/7] net: wget: make wget_with_dns return value compatible with its lwip version Adriano Cordova
2024-11-11 21:09 ` [PATCH v2 6/7] net/lwip: wget: put server_name and port into wget_ctx Adriano Cordova
2024-11-11 21:09 ` [PATCH v2 7/7] net/lwip: wget: integrate struct wget_info into wget code Adriano Cordova

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-all 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=20241111210901.560691-4-adrianox@gmail.com \
    --to=adrianox@gmail.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=jerome.forissier@linaro.org \
    --cc=joe.hershberger@ni.com \
    --cc=rfried.dev@gmail.com \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.de \
    /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