summaryrefslogtreecommitdiff
path: root/httpboot.c
diff options
context:
space:
mode:
authorSteve Langasek <steve.langasek@canonical.com>2019-02-09 21:28:06 -0800
committerSteve Langasek <steve.langasek@canonical.com>2019-02-09 21:32:44 -0800
commitab4c731c1dd379acd3e95971af57401fb0a650a1 (patch)
tree6a26fb8d0746cbbaa6c2d4b242c73442bcc1df06 /httpboot.c
parent0d63079c7da8e86104ce4bbdae2f6cb8d2ea40c6 (diff)
parent9c12130f9cd2ae11a9336813dd1f1669c0b64ad0 (diff)
downloadefi-boot-shim-debian/15+1533136590.3beb971-1.tar.gz
efi-boot-shim-debian/15+1533136590.3beb971-1.zip
* New upstream release.debian/15+1533136590.3beb971-1
- debian/patches/second-stage-path: dropped; the default loader path now includes an arch suffix. - debian/patches/sbsigntool-no-pesign: dropped; no longer needed. * Drop remaining patches that were not being applied. * Sync packaging from Ubuntu: - debian/copyright: Update upstream source location. - debian/control: add a Build-Depends on libelf-dev. - Enable arm64 build. - debian/patches/fixup_git.patch: don't run git in clean; we're not really in a git tree. - debian/rules, debian/shim.install: use the upstream install target as intended, and move files to the target directory using dh_install. - define RELEASE and COMMIT_ID for the snapshot. - Set ENABLE_HTTPBOOT to enable the HTTP Boot feature. - Update dh_auto_build/dh_auto_clean/dh_auto_install for new upstream options: set MAKELEVEL. - Define an EFI_ARCH variable, and use that for paths to shim. This makes it possible to build a shim for other architectures than amd64. - Set EFIDIR=$distro for dh_auto_install; that will let files be installed in the "right" final directories, and makes boot.csv for us. - Set ENABLE_SHIM_CERT, to keep using ephemeral self-signed certs built at compile-time for MokManager and fallback. - Set ENABLE_SBSIGN, to use sbsign instead of pesign for signing fallback and MokManager.
Diffstat (limited to 'httpboot.c')
-rw-r--r--httpboot.c402
1 files changed, 217 insertions, 185 deletions
diff --git a/httpboot.c b/httpboot.c
index ad01b8df..3622e858 100644
--- a/httpboot.c
+++ b/httpboot.c
@@ -33,19 +33,8 @@
#include <efi.h>
#include <efilib.h>
-#include "str.h"
-#include "Http.h"
-#include "Ip4Config2.h"
-#include "Ip6Config.h"
-extern UINT8 in_protocol;
-
-#define perror(fmt, ...) ({ \
- UINTN __perror_ret = 0; \
- if (!in_protocol) \
- __perror_ret = Print((fmt), ##__VA_ARGS__); \
- __perror_ret; \
- })
+#include "shim.h"
static UINTN
ascii_to_int (CONST CHAR8 *str)
@@ -105,13 +94,16 @@ find_httpboot (EFI_HANDLE device)
{
EFI_DEVICE_PATH *unpacked;
EFI_DEVICE_PATH *Node;
- EFI_DEVICE_PATH *NextNode;
MAC_ADDR_DEVICE_PATH *MacNode;
URI_DEVICE_PATH *UriNode;
UINTN uri_size;
+ BOOLEAN ip_found = FALSE;
+ BOOLEAN ret = FALSE;
- if (!uri)
+ if (uri) {
FreePool(uri);
+ uri = NULL;
+ }
devpath = DevicePathFromHandle(device);
if (!devpath) {
@@ -126,50 +118,60 @@ find_httpboot (EFI_HANDLE device)
}
Node = unpacked;
- /* Traverse the device path to find IPv4()/Uri() or IPv6()/Uri() */
+ /* Traverse the device path to find IPv4()/.../Uri() or
+ * IPv6()/.../Uri() */
while (!IsDevicePathEnd(Node)) {
/* Save the MAC node so we can match the net card later */
if (DevicePathType(Node) == MESSAGING_DEVICE_PATH &&
DevicePathSubType(Node) == MSG_MAC_ADDR_DP) {
MacNode = (MAC_ADDR_DEVICE_PATH *)Node;
- CopyMem(&mac_addr, &MacNode->MacAddress, sizeof(EFI_MAC_ADDRESS));
- }
-
- if (DevicePathType(Node) == MESSAGING_DEVICE_PATH &&
- (DevicePathSubType(Node) == MSG_IPv4_DP ||
- DevicePathSubType(Node) == MSG_IPv6_DP)) {
- /* Save the IP node so we can set up the connection later */
+ CopyMem(&mac_addr, &MacNode->MacAddress,
+ sizeof(EFI_MAC_ADDRESS));
+ } else if (DevicePathType(Node) == MESSAGING_DEVICE_PATH &&
+ (DevicePathSubType(Node) == MSG_IPv4_DP ||
+ DevicePathSubType(Node) == MSG_IPv6_DP)) {
+ /* Save the IP node so we can set up the connection */
+ /* later */
if (DevicePathSubType(Node) == MSG_IPv6_DP) {
- CopyMem(&ip6_node, Node, sizeof(IPv6_DEVICE_PATH));
+ CopyMem(&ip6_node, Node,
+ sizeof(IPv6_DEVICE_PATH));
is_ip6 = TRUE;
} else {
- CopyMem(&ip4_node, Node, sizeof(IPv4_DEVICE_PATH));
+ CopyMem(&ip4_node, Node,
+ sizeof(IPv4_DEVICE_PATH));
is_ip6 = FALSE;
}
- Node = NextDevicePathNode(Node);
+ ip_found = TRUE;
+ } else if (ip_found == TRUE &&
+ (DevicePathType(Node) == MESSAGING_DEVICE_PATH &&
+ DevicePathSubType(Node) == MSG_URI_DP)) {
+ EFI_DEVICE_PATH *NextNode;
+
+ /* Check if the URI node is the last node since the */
+ /* RAMDISK node could be appended, and we don't need */
+ /* to download the second stage loader in that case. */
NextNode = NextDevicePathNode(Node);
- if (DevicePathType(Node) == MESSAGING_DEVICE_PATH &&
- DevicePathSubType(Node) == MSG_URI_DP &&
- IsDevicePathEnd(NextNode)) {
- /* Save the current URI */
- UriNode = (URI_DEVICE_PATH *)Node;
- uri_size = strlena(UriNode->Uri);
- uri = AllocatePool(uri_size + 1);
- if (!uri) {
- perror(L"Failed to allocate uri\n");
- return FALSE;
- }
- CopyMem(uri, UriNode->Uri, uri_size + 1);
- FreePool(unpacked);
- return TRUE;
+ if (!IsDevicePathEnd(NextNode))
+ goto out;
+
+ /* Save the current URI */
+ UriNode = (URI_DEVICE_PATH *)Node;
+ uri_size = strlena(UriNode->Uri);
+ uri = AllocatePool(uri_size + 1);
+ if (!uri) {
+ perror(L"Failed to allocate uri\n");
+ goto out;
}
+ CopyMem(uri, UriNode->Uri, uri_size + 1);
+ ret = TRUE;
+ goto out;
}
Node = NextDevicePathNode(Node);
}
-
+out:
FreePool(unpacked);
- return FALSE;
+ return ret;
}
static EFI_STATUS
@@ -184,6 +186,9 @@ generate_next_uri (CONST CHAR8 *current_uri, CONST CHAR8 *next_loader,
if (strncmpa(current_uri, (CHAR8 *)"http://", 7) == 0) {
ptr = current_uri + 7;
count += 7;
+ } else if (strncmpa(current_uri, (CHAR8 *)"https://", 8) == 0) {
+ ptr = current_uri + 8;
+ count += 8;
} else {
return EFI_INVALID_PARAMETER;
}
@@ -216,6 +221,8 @@ extract_hostname (CONST CHAR8 *url, CHAR8 **hostname)
if (strncmpa(url, (CHAR8 *)"http://", 7) == 0)
start = url + 7;
+ else if (strncmpa(url, (CHAR8 *)"https://", 8) == 0)
+ start = url + 8;
else
return EFI_INVALID_PARAMETER;
@@ -240,7 +247,6 @@ extract_hostname (CONST CHAR8 *url, CHAR8 **hostname)
static EFI_HANDLE
get_nic_handle (EFI_MAC_ADDRESS *mac)
{
- EFI_GUID http_binding_guid = EFI_HTTP_SERVICE_BINDING_PROTOCOL_GUID;
EFI_DEVICE_PATH *unpacked = NULL;
EFI_DEVICE_PATH *Node;
EFI_DEVICE_PATH *temp_path = NULL;
@@ -249,17 +255,14 @@ get_nic_handle (EFI_MAC_ADDRESS *mac)
EFI_HANDLE *buffer;
UINTN NoHandles;
UINTN i;
- EFI_STATUS status;
+ EFI_STATUS efi_status;
/* Get the list of handles that support the HTTP service binding
protocol */
- status = uefi_call_wrapper(BS->LocateHandleBuffer, 5,
- ByProtocol,
- &http_binding_guid,
- NULL,
- &NoHandles,
- &buffer);
- if (EFI_ERROR(status))
+ efi_status = gBS->LocateHandleBuffer(ByProtocol,
+ &EFI_HTTP_BINDING_GUID,
+ NULL, &NoHandles, &buffer);
+ if (EFI_ERROR(efi_status))
return NULL;
for (i = 0; i < NoHandles; i++) {
@@ -296,7 +299,7 @@ out:
}
static BOOLEAN
-is_unspecified_addr (EFI_IPv6_ADDRESS ip6)
+is_unspecified_ip6addr (EFI_IPv6_ADDRESS ip6)
{
UINT8 i;
@@ -308,82 +311,117 @@ is_unspecified_addr (EFI_IPv6_ADDRESS ip6)
return TRUE;
}
+static inline void
+print_ip6_addr(EFI_IPv6_ADDRESS ip6addr)
+{
+ perror(L"%x:%x:%x:%x:%x:%x:%x:%x\n",
+ ip6addr.Addr[0] << 8 | ip6addr.Addr[1],
+ ip6addr.Addr[2] << 8 | ip6addr.Addr[3],
+ ip6addr.Addr[4] << 8 | ip6addr.Addr[5],
+ ip6addr.Addr[6] << 8 | ip6addr.Addr[7],
+ ip6addr.Addr[8] << 8 | ip6addr.Addr[9],
+ ip6addr.Addr[10] << 8 | ip6addr.Addr[11],
+ ip6addr.Addr[12] << 8 | ip6addr.Addr[13],
+ ip6addr.Addr[14] << 8 | ip6addr.Addr[15]);
+}
+
static EFI_STATUS
set_ip6(EFI_HANDLE *nic, IPv6_DEVICE_PATH *ip6node)
{
- EFI_GUID ip6_config_guid = EFI_IP6_CONFIG_PROTOCOL_GUID;
EFI_IP6_CONFIG_PROTOCOL *ip6cfg;
EFI_IP6_CONFIG_MANUAL_ADDRESS ip6;
EFI_IPv6_ADDRESS gateway;
- EFI_STATUS status;
+ EFI_STATUS efi_status;
- status = uefi_call_wrapper(BS->HandleProtocol, 3,
- nic,
- &ip6_config_guid,
- (VOID **)&ip6cfg);
- if (EFI_ERROR (status))
- return status;
+ efi_status = gBS->HandleProtocol(nic, &EFI_IP6_CONFIG_GUID,
+ (VOID **)&ip6cfg);
+ if (EFI_ERROR(efi_status))
+ return efi_status;
ip6.Address = ip6node->LocalIpAddress;
ip6.PrefixLength = ip6node->PrefixLength;
ip6.IsAnycast = FALSE;
- status = uefi_call_wrapper(ip6cfg->SetData, 4,
- ip6cfg,
- Ip6ConfigDataTypeManualAddress,
- sizeof(ip6),
- &ip6);
- if (EFI_ERROR (status))
- return status;
+ efi_status = ip6cfg->SetData(ip6cfg, Ip6ConfigDataTypeManualAddress,
+ sizeof(ip6), &ip6);
+ if (EFI_ERROR(efi_status)) {
+ perror(L"Failed to set IPv6 Address:\nIP: ");
+ print_ip6_addr(ip6.Address);
+ perror(L"Prefix Length: %u\n", ip6.PrefixLength);
+ return efi_status;
+ }
gateway = ip6node->GatewayIpAddress;
- if (is_unspecified_addr(gateway))
+ if (is_unspecified_ip6addr(gateway))
return EFI_SUCCESS;
- status = uefi_call_wrapper(ip6cfg->SetData, 4,
- ip6cfg,
- Ip6ConfigDataTypeGateway,
- sizeof(gateway),
- &gateway);
- if (EFI_ERROR (status))
- return status;
+ efi_status = ip6cfg->SetData(ip6cfg, Ip6ConfigDataTypeGateway,
+ sizeof(gateway), &gateway);
+ if (EFI_ERROR(efi_status)) {
+ perror(L"Failed to set IPv6 Gateway:\nIP: ");
+ print_ip6_addr(gateway);
+ return efi_status;
+ }
return EFI_SUCCESS;
}
+static BOOLEAN
+is_unspecified_ip4addr (EFI_IPv4_ADDRESS ip4)
+{
+ UINT8 i;
+
+ for (i = 0; i<4; i++) {
+ if (ip4.Addr[i] != 0)
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static inline void
+print_ip4_addr(EFI_IPv4_ADDRESS ip4addr)
+{
+ perror(L"%u.%u.%u.%u\n",
+ ip4addr.Addr[0], ip4addr.Addr[1],
+ ip4addr.Addr[2], ip4addr.Addr[3]);
+}
+
static EFI_STATUS
set_ip4(EFI_HANDLE *nic, IPv4_DEVICE_PATH *ip4node)
{
- EFI_GUID ip4_config2_guid = EFI_IP4_CONFIG2_PROTOCOL_GUID;
EFI_IP4_CONFIG2_PROTOCOL *ip4cfg2;
EFI_IP4_CONFIG2_MANUAL_ADDRESS ip4;
EFI_IPv4_ADDRESS gateway;
- EFI_STATUS status;
+ EFI_STATUS efi_status;
- status = uefi_call_wrapper(BS->HandleProtocol, 3,
- nic,
- &ip4_config2_guid,
- (VOID **)&ip4cfg2);
- if (EFI_ERROR (status))
- return status;
+ efi_status = gBS->HandleProtocol(nic, &EFI_IP4_CONFIG2_GUID,
+ (VOID **)&ip4cfg2);
+ if (EFI_ERROR(efi_status))
+ return efi_status;
ip4.Address = ip4node->LocalIpAddress;
ip4.SubnetMask = ip4node->SubnetMask;
- status = uefi_call_wrapper(ip4cfg2->SetData, 4,
- ip4cfg2,
- Ip4Config2DataTypeManualAddress,
- sizeof(ip4),
- &ip4);
- if (EFI_ERROR (status))
- return status;
+ efi_status = ip4cfg2->SetData(ip4cfg2, Ip4Config2DataTypeManualAddress,
+ sizeof(ip4), &ip4);
+ if (EFI_ERROR(efi_status)) {
+ perror(L"Failed to Set IPv4 Address:\nIP: ");
+ print_ip4_addr(ip4.Address);
+ perror(L"Mask: ");
+ print_ip4_addr(ip4.SubnetMask);
+ return efi_status;
+ }
gateway = ip4node->GatewayIpAddress;
- status = uefi_call_wrapper(ip4cfg2->SetData, 4,
- ip4cfg2,
- Ip4Config2DataTypeGateway,
- sizeof(gateway),
- &gateway);
- if (EFI_ERROR (status))
- return status;
+ if (is_unspecified_ip4addr(gateway))
+ return EFI_SUCCESS;
+
+ efi_status = ip4cfg2->SetData(ip4cfg2, Ip4Config2DataTypeGateway,
+ sizeof(gateway), &gateway);
+ if (EFI_ERROR(efi_status)) {
+ perror(L"Failed to Set IPv4 Gateway:\nGateway: ");
+ print_ip4_addr(gateway);
+ return efi_status;
+ }
return EFI_SUCCESS;
}
@@ -418,7 +456,7 @@ configure_http (EFI_HTTP_PROTOCOL *http, BOOLEAN is_ip6)
http_mode.AccessPoint.IPv6Node = &ip6node;
}
- return uefi_call_wrapper(http->Configure, 2, http, &http_mode);
+ return http->Configure(http, &http_mode);
}
static EFI_STATUS
@@ -430,7 +468,7 @@ send_http_request (EFI_HTTP_PROTOCOL *http, CHAR8 *hostname, CHAR8 *uri)
EFI_HTTP_HEADER headers[3];
BOOLEAN request_done;
CHAR16 *Url = NULL;
- EFI_STATUS status;
+ EFI_STATUS efi_status;
EFI_STATUS event_status;
/* Convert the ascii string to the UCS2 string */
@@ -459,35 +497,33 @@ send_http_request (EFI_HTTP_PROTOCOL *http, CHAR8 *hostname, CHAR8 *uri)
tx_token.Message = &tx_message;
tx_token.Event = NULL;
request_done = FALSE;
- status = uefi_call_wrapper(BS->CreateEvent, 5,
- EVT_NOTIFY_SIGNAL,
- TPL_NOTIFY,
- httpnotify,
- &request_done,
- &tx_token.Event);
- if (EFI_ERROR(status)) {
- perror(L"Failed to Create Event for HTTP request: %r\n", status);
+ efi_status = gBS->CreateEvent(EVT_NOTIFY_SIGNAL, TPL_NOTIFY,
+ httpnotify, &request_done,
+ &tx_token.Event);
+ if (EFI_ERROR(efi_status)) {
+ perror(L"Failed to Create Event for HTTP request: %r\n",
+ efi_status);
goto no_event;
}
/* Send out the request */
- status = uefi_call_wrapper(http->Request, 2, http, &tx_token);
- if (EFI_ERROR(status)) {
- perror(L"HTTP request failed: %r\n", status);
+ efi_status = http->Request(http, &tx_token);
+ if (EFI_ERROR(efi_status)) {
+ perror(L"HTTP request failed: %r\n", efi_status);
goto error;
}
/* Wait for the response */
while (!request_done)
- uefi_call_wrapper(http->Poll, 1, http);
+ http->Poll(http);
if (EFI_ERROR(tx_token.Status)) {
perror(L"HTTP request: %r\n", tx_token.Status);
- status = tx_token.Status;
+ efi_status = tx_token.Status;
}
error:
- event_status = uefi_call_wrapper(BS->CloseEvent, 1, tx_token.Event);
+ event_status = gBS->CloseEvent(tx_token.Event);
if (EFI_ERROR(event_status)) {
perror(L"Failed to close Event for HTTP request: %r\n",
event_status);
@@ -497,11 +533,11 @@ no_event:
if (Url)
FreePool(Url);
- return status;
+ return efi_status;
}
static EFI_STATUS
-receive_http_response(EFI_HTTP_PROTOCOL *http, VOID **buffer, UINTN *buf_size)
+receive_http_response(EFI_HTTP_PROTOCOL *http, VOID **buffer, UINT64 *buf_size)
{
EFI_HTTP_TOKEN rx_token;
EFI_HTTP_MESSAGE rx_message;
@@ -510,7 +546,7 @@ receive_http_response(EFI_HTTP_PROTOCOL *http, VOID **buffer, UINTN *buf_size)
BOOLEAN response_done;
UINTN i, downloaded;
CHAR8 rx_buffer[9216];
- EFI_STATUS status;
+ EFI_STATUS efi_status;
EFI_STATUS event_status;
/* Initialize the rx message and buffer */
@@ -525,31 +561,29 @@ receive_http_response(EFI_HTTP_PROTOCOL *http, VOID **buffer, UINTN *buf_size)
rx_token.Message = &rx_message;
rx_token.Event = NULL;
response_done = FALSE;
- status = uefi_call_wrapper(BS->CreateEvent, 5,
- EVT_NOTIFY_SIGNAL,
- TPL_NOTIFY,
- httpnotify,
- &response_done,
- &rx_token.Event);
- if (EFI_ERROR(status)) {
- perror(L"Failed to Create Event for HTTP response: %r\n", status);
+ efi_status = gBS->CreateEvent(EVT_NOTIFY_SIGNAL, TPL_NOTIFY,
+ httpnotify, &response_done,
+ &rx_token.Event);
+ if (EFI_ERROR(efi_status)) {
+ perror(L"Failed to Create Event for HTTP response: %r\n",
+ efi_status);
goto no_event;
}
/* Notify the firmware to receive the HTTP messages */
- status = uefi_call_wrapper(http->Response, 2, http, &rx_token);
- if (EFI_ERROR(status)) {
- perror(L"HTTP response failed: %r\n", status);
+ efi_status = http->Response(http, &rx_token);
+ if (EFI_ERROR(efi_status)) {
+ perror(L"HTTP response failed: %r\n", efi_status);
goto error;
}
/* Wait for the response */
while (!response_done)
- uefi_call_wrapper(http->Poll, 1, http);
+ http->Poll(http);
if (EFI_ERROR(rx_token.Status)) {
perror(L"HTTP response: %r\n", rx_token.Status);
- status = rx_token.Status;
+ efi_status = rx_token.Status;
goto error;
}
@@ -558,7 +592,7 @@ receive_http_response(EFI_HTTP_PROTOCOL *http, VOID **buffer, UINTN *buf_size)
if (http_status != HTTP_STATUS_200_OK) {
perror(L"HTTP Status Code: %d\n",
convert_http_status_code(http_status));
- status = EFI_ABORTED;
+ efi_status = EFI_ABORTED;
goto error;
}
@@ -598,23 +632,23 @@ receive_http_response(EFI_HTTP_PROTOCOL *http, VOID **buffer, UINTN *buf_size)
rx_token.Status = EFI_NOT_READY;
response_done = FALSE;
- status = uefi_call_wrapper(http->Response, 2, http, &rx_token);
- if (EFI_ERROR(status)) {
- perror(L"HTTP response failed: %r\n", status);
+ efi_status = http->Response(http, &rx_token);
+ if (EFI_ERROR(efi_status)) {
+ perror(L"HTTP response failed: %r\n", efi_status);
goto error;
}
while (!response_done)
- uefi_call_wrapper(http->Poll, 1, http);
+ http->Poll(http);
if (EFI_ERROR(rx_token.Status)) {
perror(L"HTTP response: %r\n", rx_token.Status);
- status = rx_token.Status;
+ efi_status = rx_token.Status;
goto error;
}
if (rx_message.BodyLength + downloaded > *buf_size) {
- status = EFI_BAD_BUFFER_SIZE;
+ efi_status = EFI_BAD_BUFFER_SIZE;
goto error;
}
@@ -624,82 +658,79 @@ receive_http_response(EFI_HTTP_PROTOCOL *http, VOID **buffer, UINTN *buf_size)
}
error:
- event_status = uefi_call_wrapper(BS->CloseEvent, 1, rx_token.Event);
+ event_status = gBS->CloseEvent(rx_token.Event);
if (EFI_ERROR(event_status)) {
perror(L"Failed to close Event for HTTP response: %r\n",
event_status);
}
no_event:
- if (EFI_ERROR(status) && *buffer)
+ if (EFI_ERROR(efi_status) && *buffer)
FreePool(*buffer);
- return status;
+ return efi_status;
}
static EFI_STATUS
http_fetch (EFI_HANDLE image, EFI_HANDLE device,
CHAR8 *hostname, CHAR8 *uri, BOOLEAN is_ip6,
- VOID **buffer, UINTN *buf_size)
+ VOID **buffer, UINT64 *buf_size)
{
- EFI_GUID http_binding_guid = EFI_HTTP_SERVICE_BINDING_PROTOCOL_GUID;
- EFI_GUID http_protocol_guid = EFI_HTTP_PROTOCOL_GUID;
EFI_SERVICE_BINDING *service;
EFI_HANDLE http_handle;
EFI_HTTP_PROTOCOL *http;
- EFI_STATUS status;
+ EFI_STATUS efi_status;
EFI_STATUS child_status;
*buffer = NULL;
*buf_size = 0;
/* Open HTTP Service Binding Protocol */
- status = uefi_call_wrapper(BS->OpenProtocol, 6, device,
- &http_binding_guid, (VOID **)&service,
- image, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);
- if (EFI_ERROR (status))
- return status;
+ efi_status = gBS->OpenProtocol(device, &EFI_HTTP_BINDING_GUID,
+ (VOID **) &service, image, NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL);
+ if (EFI_ERROR(efi_status))
+ return efi_status;
/* Create the ChildHandle from the Service Binding */
/* Set the handle to NULL to request a new handle */
http_handle = NULL;
- status = uefi_call_wrapper(service->CreateChild, 2, service,
- &http_handle);
- if (EFI_ERROR (status))
- return status;
+ efi_status = service->CreateChild(service, &http_handle);
+ if (EFI_ERROR(efi_status)) {
+ perror(L"Failed to create the ChildHandle\n");
+ return efi_status;
+ }
/* Get the http protocol */
- status = uefi_call_wrapper(BS->HandleProtocol, 3, http_handle,
- &http_protocol_guid, (VOID **)&http);
- if (EFI_ERROR (status)) {
+ efi_status = gBS->HandleProtocol(http_handle, &EFI_HTTP_PROTOCOL_GUID,
+ (VOID **) &http);
+ if (EFI_ERROR(efi_status)) {
perror(L"Failed to get http\n");
goto error;
}
- status = configure_http(http, is_ip6);
- if (EFI_ERROR (status)) {
- perror(L"Failed to configure http: %r\n", status);
+ efi_status = configure_http(http, is_ip6);
+ if (EFI_ERROR(efi_status)) {
+ perror(L"Failed to configure http: %r\n", efi_status);
goto error;
}
- status = send_http_request(http, hostname, uri);
- if (EFI_ERROR(status)) {
- perror(L"Failed to send HTTP request: %r\n", status);
+ efi_status = send_http_request(http, hostname, uri);
+ if (EFI_ERROR(efi_status)) {
+ perror(L"Failed to send HTTP request: %r\n", efi_status);
goto error;
}
- status = receive_http_response(http, buffer, buf_size);
- if (EFI_ERROR(status)) {
- perror(L"Failed to receive HTTP response: %r\n", status);
+ efi_status = receive_http_response(http, buffer, buf_size);
+ if (EFI_ERROR(efi_status)) {
+ perror(L"Failed to receive HTTP response: %r\n", efi_status);
goto error;
}
error:
- child_status = uefi_call_wrapper(service->DestroyChild, 2, service,
- http_handle);
-
- if (EFI_ERROR(status)) {
- return status;
+ child_status = service->DestroyChild(service, http_handle);
+ if (EFI_ERROR(efi_status)) {
+ return efi_status;
} else if (EFI_ERROR(child_status)) {
return child_status;
}
@@ -708,9 +739,9 @@ error:
}
EFI_STATUS
-httpboot_fetch_buffer (EFI_HANDLE image, VOID **buffer, UINTN *buf_size)
+httpboot_fetch_buffer (EFI_HANDLE image, VOID **buffer, UINT64 *buf_size)
{
- EFI_STATUS status;
+ EFI_STATUS efi_status;
EFI_HANDLE nic;
CHAR8 *next_loader = NULL;
CHAR8 *next_uri = NULL;
@@ -722,16 +753,16 @@ httpboot_fetch_buffer (EFI_HANDLE image, VOID **buffer, UINTN *buf_size)
next_loader = translate_slashes(DEFAULT_LOADER_CHAR);
/* Create the URI for the next loader based on the original URI */
- status = generate_next_uri(uri, next_loader, &next_uri);
- if (EFI_ERROR (status)) {
- perror(L"Next URI: %a, %r\n", next_uri, status);
+ efi_status = generate_next_uri(uri, next_loader, &next_uri);
+ if (EFI_ERROR(efi_status)) {
+ perror(L"Next URI: %a, %r\n", next_uri, efi_status);
goto error;
}
/* Extract the hostname (or IP) from URI */
- status = extract_hostname(uri, &hostname);
- if (EFI_ERROR (status)) {
- perror(L"hostname: %a, %r\n", hostname, status);
+ efi_status = extract_hostname(uri, &hostname);
+ if (EFI_ERROR(efi_status)) {
+ perror(L"hostname: %a, %r\n", hostname, efi_status);
goto error;
}
@@ -739,6 +770,7 @@ httpboot_fetch_buffer (EFI_HANDLE image, VOID **buffer, UINTN *buf_size)
also supports the HTTP service binding protocol */
nic = get_nic_handle(&mac_addr);
if (!nic) {
+ efi_status = EFI_NOT_FOUND;
goto error;
}
@@ -746,19 +778,19 @@ httpboot_fetch_buffer (EFI_HANDLE image, VOID **buffer, UINTN *buf_size)
information in the device path node. We have to set up the
connection on our own for the further operations. */
if (!is_ip6)
- status = set_ip4(nic, &ip4_node);
+ efi_status = set_ip4(nic, &ip4_node);
else
- status = set_ip6(nic, &ip6_node);
- if (EFI_ERROR (status)) {
- perror(L"Failed to set IP for HTTPBoot: %r\n", status);
+ efi_status = set_ip6(nic, &ip6_node);
+ if (EFI_ERROR(efi_status)) {
+ perror(L"Failed to set IP for HTTPBoot: %r\n", efi_status);
goto error;
}
/* Use HTTP protocl to fetch the remote file */
- status = http_fetch (image, nic, hostname, next_uri, is_ip6,
- buffer, buf_size);
- if (EFI_ERROR (status)) {
- perror(L"Failed to fetch image: %r\n", status);
+ efi_status = http_fetch (image, nic, hostname, next_uri, is_ip6,
+ buffer, buf_size);
+ if (EFI_ERROR(efi_status)) {
+ perror(L"Failed to fetch image: %r\n", efi_status);
goto error;
}
@@ -770,5 +802,5 @@ error:
if (hostname)
FreePool(hostname);
- return status;
+ return efi_status;
}