Merge tag 'efi-next-2024-11-18' of https://source.denx.de/u-boot/custodians/u-boot-efi into next

CI: https://source.denx.de/u-boot/custodians/u-boot-efi/-/pipelines/23430

- Prepare for implementing the EFI_HTTP_PROTOCOL:
  - Make wget functionality callable even if the wget command is not
    built (add CONFIG_WGET symbol).
  - Ensure that wget_with_dns() works the same with the old network
    stack and with lwIP.
  - Put server_name and port into wget_ctx.
  - Integrate struct wget_info into wget code.
  - Move ip_to_string to lib/net_utils.c
This commit is contained in:
Tom Rini
2024-11-18 10:46:06 -06:00
12 changed files with 217 additions and 55 deletions

View File

@@ -8,6 +8,7 @@
#include <env.h>
#include <hexdump.h>
#include <linux/if_ether.h>
#include <linux/sizes.h>
#include <linux/types.h>
#include <rand.h>
#include <time.h>
@@ -425,6 +426,16 @@ void string_to_enetaddr(const char *addr, uint8_t *enetaddr);
*/
struct in_addr string_to_ip(const char *s);
/**
* ip_to_string() - Convert a string to ip address
*
* Implemented in lib/net_utils.c (built unconditionally)
*
* @x: Input ip to parse
* @s: string containing the parsed ip address
*/
void ip_to_string(struct in_addr x, char *s);
/* copy a filename (allow for "..." notation, limit length) */
void copy_filename(char *dst, const char *src, int size);
@@ -494,7 +505,7 @@ int do_tftpb(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
*
* @dst_addr: destination address to download the file
* @uri: uri string of target file of wget
* Return: downloaded file size, negative if failed
* Return: zero on success, negative if failed
*/
int wget_with_dns(ulong dst_addr, char *uri);
/**
@@ -506,4 +517,55 @@ int wget_with_dns(ulong dst_addr, char *uri);
bool wget_validate_uri(char *uri);
//int do_wget(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]);
/**
* enum wget_http_method - http method
*/
enum wget_http_method {
WGET_HTTP_METHOD_GET,
WGET_HTTP_METHOD_POST,
WGET_HTTP_METHOD_PATCH,
WGET_HTTP_METHOD_OPTIONS,
WGET_HTTP_METHOD_CONNECT,
WGET_HTTP_METHOD_HEAD,
WGET_HTTP_METHOD_PUT,
WGET_HTTP_METHOD_DELETE,
WGET_HTTP_METHOD_TRACE,
WGET_HTTP_METHOD_MAX
};
/**
* define MAX_HTTP_HEADERS_SIZE - maximum headers buffer size
*
* When receiving http headers, wget fills a buffer with up
* to MAX_HTTP_HEADERS_SIZE bytes of header information.
*/
#define MAX_HTTP_HEADERS_SIZE SZ_64K
/**
* struct wget_http_info - wget parameters
* @method: HTTP Method. Filled by client.
* @status_code: HTTP status code. Filled by wget.
* @file_size: download size. Filled by wget.
* @buffer_size: size of client-provided buffer. Filled by client.
* @set_bootdev: set boot device with download. Filled by client.
* @check_buffer_size: check download does not exceed buffer size.
* Filled by client.
* @hdr_cont_len: content length according to headers. Filled by wget
* @headers: buffer for headers. Filled by wget.
*/
struct wget_http_info {
enum wget_http_method method;
u32 status_code;
ulong file_size;
ulong buffer_size;
bool set_bootdev;
bool check_buffer_size;
u32 hdr_cont_len;
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__ */

View File

@@ -16,15 +16,6 @@ void net_lwip_remove_netif(struct netif *netif);
struct netif *net_lwip_get_netif(void);
int net_lwip_rx(struct udevice *udev, struct netif *netif);
/**
* wget_with_dns() - runs dns host IP address resulution before wget
*
* @dst_addr: destination address to download the file
* @uri: uri string of target file of wget
* Return: downloaded file size, negative if failed
*/
int wget_with_dns(ulong dst_addr, char *uri);
/**
* wget_validate_uri() - varidate the uri
*