summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAdriano Cordova <[email protected]>2024-12-04 00:05:24 -0300
committerHeinrich Schuchardt <[email protected]>2024-12-04 12:24:38 +0100
commit5a5c5bf40a0ea479426ad3f5c0cbc5afa675786f (patch)
tree938f403dcc3401b1ccf24d80a4e566c2c42df987 /include
parente55a4acb54e807c6411c4f6ab914fa2b3f55784e (diff)
efi_loader: net: add support to send http requests and parse http headers
Add network-stack agnostic way to send an http request and parse http headers from efi drivers. This uses wget as a backend and communicates with it via efi_wget_info. The function efi_net_do_request allocates a buffer on behalf of an efi application using efi_alloc and passes it to wget to receive the data. If the method is GET and the buffer is too small, it re-allocates the buffer based on the last received Content-Length header and tries again. If the method is HEAD it just issues one request. So issuing a HEAD request (to update Content-Length) and then a GET request is preferred but not required. The function efi_net_parse_headers parses a raw buffer containing an http header into an array of EFI specific 'http_header' structs. Signed-off-by: Adriano Cordova <[email protected]> Reviewed-by: Heinrich Schuchardt <[email protected]>
Diffstat (limited to 'include')
-rw-r--r--include/efi_loader.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/include/efi_loader.h b/include/efi_loader.h
index 0da0248db46..b6f865ca769 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -16,6 +16,7 @@
#include <image.h>
#include <pe.h>
#include <linux/list.h>
+#include <linux/sizes.h>
#include <linux/oid_registry.h>
struct blk_desc;
@@ -136,6 +137,18 @@ void efi_net_get_addr(struct efi_ipv4_address *ip,
void efi_net_set_addr(struct efi_ipv4_address *ip,
struct efi_ipv4_address *mask,
struct efi_ipv4_address *gw);
+efi_status_t efi_net_do_request(u8 *url, enum efi_http_method method, void **buffer,
+ u32 *status_code, ulong *file_size, char *headers_buffer);
+#define MAX_HTTP_HEADERS_SIZE SZ_64K
+#define MAX_HTTP_HEADERS 100
+#define MAX_HTTP_HEADER_NAME 128
+#define MAX_HTTP_HEADER_VALUE 512
+struct http_header {
+ uchar name[MAX_HTTP_HEADER_NAME];
+ uchar value[MAX_HTTP_HEADER_VALUE];
+};
+
+void efi_net_parse_headers(ulong *num_headers, struct http_header *headers);
#else
static inline void efi_net_get_dp(struct efi_device_path **dp) { }
static inline void efi_net_get_addr(struct efi_ipv4_address *ip,