TianoCore EDK2 master
|
#include "Http.h"
Go to the source code of this file.
Macros | |
#define | IP4_CONFIG2_INTERFACE_INFO_NAME_LENGTH 32 |
#define | HTTP_PROGRESS_SLIDER_STEPS ((sizeof (HTTP_PROGR_FRAME) / sizeof (CHAR16)) - 3) |
#define | HTTP_PROGRESS_MESSAGE_SIZE ((sizeof (HTTP_PROGR_FRAME) / sizeof (CHAR16)) + 12) |
#define | DEFAULT_BUF_SIZE SIZE_32KB |
#define | MAX_BUF_SIZE SIZE_4MB |
#define | MIN_PARAM_COUNT 2 |
#define | MAX_PARAM_COUNT 4 |
#define | NEED_REDIRECTION(Code) |
#define | CLOSE_HTTP_HANDLE(ControllerHandle, HttpChildHandle) |
#define | USER_AGENT_HDR "Mozilla/5.0 (EDK2; Linux) Gecko/20100101 Firefox/79.0" |
#define | TIMER_MAX_TIMEOUT_S 10 |
#define | DEFAULT_HTML_FILE L"index.html" |
#define | DEFAULT_HTTP_PROTO L"http" |
#define | HTTP_PROGRESS_DEL L"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b" |
#define | HTTP_KB L"\b\b\b\b\b\b\b\b\b\b" |
#define | HTTP_PROGR_FRAME L"[ ]" |
#define | PRINT_HII(token, ...) |
#define | PRINT_HII_APP(token, value) PRINT_HII (token, HTTP_APP_NAME, value) |
#define | EPOCH_JULIAN_DATE 2440588 |
#define | SEC_PER_MIN ((UINTN) 60) |
#define | SEC_PER_HOUR ((UINTN) 3600) |
#define | SEC_PER_DAY ((UINTN) 86400) |
Enumerations | |
enum | HDR_TYPE { HdrHost , HdrConn , HdrAgent , HdrMax } |
Variables | |
STATIC CONST CHAR16 * | ErrStatusDesc [] |
STATIC CONST SHELL_PARAM_ITEM | ParamList [] |
STATIC SHELL_FILE_HANDLE | mFileHandle = NULL |
STATIC CONST CHAR16 * | mLocalFilePath |
STATIC BOOLEAN | gRequestCallbackComplete = FALSE |
STATIC BOOLEAN | gResponseCallbackComplete = FALSE |
STATIC BOOLEAN | gHttpError |
EFI_HII_HANDLE | mHttpHiiHandle |
The implementation for the 'http' Shell command.
Copyright (c) 2015, ARM Ltd. All rights reserved.
Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
(C) Copyright 2015 Hewlett Packard Enterprise Development LP
Copyright (c) 2020, Broadcom. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file Http.c.
#define CLOSE_HTTP_HANDLE | ( | ControllerHandle, | |
HttpChildHandle | |||
) |
#define HTTP_PROGRESS_DEL L"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b" |
#define HTTP_PROGRESS_MESSAGE_SIZE ((sizeof (HTTP_PROGR_FRAME) / sizeof (CHAR16)) + 12) |
#define HTTP_PROGRESS_SLIDER_STEPS ((sizeof (HTTP_PROGR_FRAME) / sizeof (CHAR16)) - 3) |
#define NEED_REDIRECTION | ( | Code | ) |
#define PRINT_HII | ( | token, | |
... | |||
) |
#define PRINT_HII_APP | ( | token, | |
value | |||
) | PRINT_HII (token, HTTP_APP_NAME, value) |
#define USER_AGENT_HDR "Mozilla/5.0 (EDK2; Linux) Gecko/20100101 Firefox/79.0" |
STATIC VOID CloseProtocolAndDestroyServiceChild | ( | IN EFI_HANDLE | ControllerHandle, |
IN EFI_GUID * | ServiceBindingProtocolGuid, | ||
IN EFI_GUID * | ProtocolGuid, | ||
IN EFI_HANDLE | ChildHandle | ||
) |
Close the protocol identified by its GUID on the child handle of the service identified by its service binding protocol GUID, then destroy the child handle.
STATIC EFI_STATUS CreateServiceChildAndOpenProtocol | ( | IN EFI_HANDLE | ControllerHandle, |
IN EFI_GUID * | ServiceBindingProtocolGuid, | ||
IN EFI_GUID * | ProtocolGuid, | ||
OUT EFI_HANDLE * | ChildHandle, | ||
OUT VOID ** | Interface | ||
) |
Create a child for the service identified by its service binding protocol GUID and get from the child the interface of the protocol identified by its GUID.
[in] | ControllerHandle | Controller handle. |
[in] | ServiceBindingProtocolGuid | Service binding protocol GUID of the service to be created. |
[in] | ProtocolGuid | GUID of the protocol to be open. |
[out] | ChildHandle | Address where the handler of the created child is returned. NULL is returned in case of error. |
[out] | Interface | Address where a pointer to the protocol interface is returned in case of success. |
EFI_SUCCESS | The child was created and the protocol opened. |
Others | Either the creation of the child or the opening of the protocol failed. |
Create a child for the service identified by its service binding protocol GUID and get from the child the interface of the protocol identified by its GUID.
[in] | ControllerHandle | Controller handle. |
[in] | ServiceBindingProtocolGuid | Service binding protocol GUID of the service to be created. |
[in] | ProtocolGuid | GUID of the protocol to be open. |
[out] | ChildHandle | Address where the handler of the created child is returned. NULL is returned in case of error. |
[out] | Interface | Address where a pointer to the protocol interface is returned in case of success. |
STATIC EFI_STATUS DownloadFile | ( | IN HTTP_DOWNLOAD_CONTEXT * | Context, |
IN EFI_HANDLE | ControllerHandle, | ||
IN CHAR16 * | NicName | ||
) |
Worker function that download the data of a file from an HTTP server given the path of the file and its size.
[in] | Context | A pointer to the download context. |
EFI_SUCCESS | The file was downloaded. |
EFI_OUT_OF_RESOURCES | A memory allocation failed. |
Others | The downloading of the file from the server failed. |
Worker function that downloads the data of a file from an HTTP server given the path of the file and its size.
[in] | Context | A pointer to the HTTP download context. |
[in] | ControllerHandle | The handle of the network interface controller |
[in] | NicName | NIC name |
EFI_SUCCESS | The file was downloaded. |
EFI_OUT_OF_RESOURCES | A memory allocation failed. #return EFI_HTTP_ERROR The server returned a valid HTTP error. Examine the mLocalFilePath file to get error body. |
Others | The downloading of the file from the server failed. |
STATIC EFI_STATUS GetNicName | ( | IN EFI_HANDLE | ControllerHandle, |
IN UINTN | NicNumber, | ||
OUT CHAR16 * | NicName | ||
) |
Get the name of the NIC.
[in] | ControllerHandle | The network physical device handle. |
[in] | NicNumber | The network physical device number. |
[out] | NicName | Address where to store the NIC name. The memory area has to be at least IP4_CONFIG2_INTERFACE_INFO_NAME_LENGTH double byte wide. |
EFI_SUCCESS | The name of the NIC was returned. |
Others | The creation of the child for the Managed Network Service failed or the opening of the Managed Network Protocol failed or the operational parameters for the Managed Network Protocol could not be read. |
Get the name of the NIC.
[in] | ControllerHandle | The network physical device handle. |
[in] | NicNumber | The network physical device number. |
[out] | NicName | Address where to store the NIC name. The memory area has to be at least IP4_CONFIG2_INTERFACE_INFO_NAME_LENGTH double byte wide. |
STATIC EFI_STATUS GetResponse | ( | IN HTTP_DOWNLOAD_CONTEXT * | Context, |
IN CHAR16 * | DownloadUrl | ||
) |
Get HTTP server response and collect the whole body as a file. Set appropriate status in Context (REQ_OK, REQ_REPEAT, REQ_ERROR). Note that even if HTTP server returns an error code, it might send the body as well. This body will be collected in the resultant file.
[in] | Context | A pointer to the HTTP download context. |
[in] | DownloadUrl | A pointer to the fully qualified URL to download. |
EFI_SUCCESS | Valid file. Body successfully collected. |
EFI_HTTP_ERROR | Response is a valid HTTP response, but the HTTP server indicated an error (HTTP code >= 400). Response body MAY contain full HTTP server response. |
Others | Error getting the reponse from the HTTP server. Response body is not collected. |
EFI_HII_HANDLE InitializeHiiPackage | ( | IN EFI_HANDLE | ImageHandle | ) |
STATIC EFI_STATUS EFIAPI ParseMsg | ( | IN HTTP_BODY_PARSE_EVENT | EventType, |
IN CHAR8 * | Data, | ||
IN UINTN | Length, | ||
IN VOID * | Context | ||
) |
Message parser callback. Save a portion of HTTP body.
[in] | EventType | Type of event. Can be either OnComplete or OnData. |
[in] | Data | A pointer to the buffer with data. |
[in] | Length | Data length of this portion. |
[in] | Context | A pointer to the HTTP download context. |
EFI_SUCCESS | The portion was processed successfully. |
Other | Error returned by SavePortion. |
SHELL_STATUS RunHttp | ( | IN EFI_HANDLE | ImageHandle, |
IN EFI_SYSTEM_TABLE * | SystemTable | ||
) |
Function for 'http' command.
[in] | ImageHandle | Handle to the Image (NULL if Internal). |
[in] | SystemTable | Pointer to the System Table (NULL if Internal). |
SHELL_SUCCESS | The 'http' command completed successfully. |
SHELL_ABORTED | The Shell Library initialization failed. |
SHELL_INVALID_PARAMETER | At least one of the command's arguments is not valid. |
SHELL_OUT_OF_RESOURCES | A memory allocation failed. |
SHELL_NOT_FOUND | Network Interface Card not found. |
SHELL_UNSUPPORTED | Command was valid, but the server returned a status code indicating some error. Examine the file requested for error body. |
STATIC EFI_STATUS EFIAPI SavePortion | ( | IN HTTP_DOWNLOAD_CONTEXT * | Context, |
IN UINTN | DownloadLen, | ||
IN CHAR8 * | Buffer | ||
) |
Update the progress of a file download This procedure is called each time a new HTTP body portion is received.
[in] | Context | HTTP download context. |
[in] | DownloadLen | Portion size, in bytes. |
[in] | Buffer | The pointer to the parsed buffer. |
EFI_SUCCESS | Portion saved. |
Other | Error saving the portion. |
STATIC EFI_STATUS SendRequest | ( | IN HTTP_DOWNLOAD_CONTEXT * | Context, |
IN CHAR16 * | DownloadUrl | ||
) |
Generate and send a request to the http server.
[in] | Context | HTTP download context. |
[in] | DownloadUrl | Fully qualified URL to be downloaded. |
EFI_SUCCESS | Request has been sent successfully. |
EFI_INVALID_PARAMETER | Invalid URL. |
EFI_OUT_OF_RESOURCES | Out of memory. |
EFI_DEVICE_ERROR | If HTTPS is used, this probably means that TLS support either was not installed or not configured. |
Others | Error sending the request. |
STATIC EFI_STATUS SetHostURI | ( | IN CHAR8 * | Location, |
IN HTTP_DOWNLOAD_CONTEXT * | Context, | ||
IN CHAR16 * | DownloadUrl | ||
) |
Replace the original Host and Uri with Host and Uri returned by the HTTP server in 'Location' header (redirection).
[in] | Location | A pointer to the 'Location' string provided by HTTP server. |
[in] | Context | A pointer to HTTP download context. |
[in] | DownloadUrl | Fully qualified HTTP URL. |
EFI_SUCCESS | Host and Uri were successfully set. |
EFI_OUT_OF_RESOURCES | Error setting Host or Uri. |
Check and convert the UINT16 option values of the 'http' command.
[in] | ValueStr | Value as an Unicode encoded string. |
[out] | Value | UINT16 value. |
TRUE | The value was returned. |
FALSE | A parsing error occured. |
Check and convert the UINT16 option values of the 'http' command
[in] | ValueStr | Value as an Unicode encoded string |
[out] | Value | UINT16 value |
TRUE | The value was returned. |
FALSE | A parsing error occured. |
Check and convert the UINT16 option values of the 'tftp' command
[in] | ValueStr | Value as an Unicode encoded string |
[out] | Value | UINT16 value |
STATIC EFI_STATUS TrimSpaces | ( | IN CHAR16 * | String | ) |
STATIC EFI_STATUS WaitForCompletion | ( | IN HTTP_DOWNLOAD_CONTEXT * | Context, |
IN OUT BOOLEAN * | CallBackComplete | ||
) |
Wait until operation completes. Completion is indicated by setting of an appropriate variable.
[in] | Context | A pointer to the HTTP download context. |
[in,out] | CallBackComplete | A pointer to the callback completion variable set by the callback. |
EFI_SUCCESS | Callback signalled completion. |
EFI_TIMEOUT | Timed out waiting for completion. |
Others | Error waiting for completion. |
EFI_HII_HANDLE mHttpHiiHandle |
STATIC CONST SHELL_PARAM_ITEM ParamList[] |