+/** @file\r
+ This file defines the EFI HTTP Protocol interface. It is split into\r
+ the following two main sections:\r
+ HTTP Service Binding Protocol (HTTPSB)\r
+ HTTP Protocol (HTTP)\r
+\r
+ Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
+ This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+ @par Revision Reference:\r
+ This Protocol is introduced in UEFI Specification 2.5\r
+\r
+**/\r
+\r
+#ifndef __EFI_HTTP_PROTOCOL_H__\r
+#define __EFI_HTTP_PROTOCOL_H__\r
+\r
+#define EFI_HTTP_SERVICE_BINDING_PROTOCOL_GUID \\r
+ { \\r
+ 0xbdc8e6af, 0xd9bc, 0x4379, {0xa7, 0x2a, 0xe0, 0xc4, 0xe7, 0x5d, 0xae, 0x1c } \\r
+ }\r
+\r
+#define EFI_HTTP_PROTOCOL_GUID \\r
+ { \\r
+ 0x7a59b29b, 0x910b, 0x4171, {0x82, 0x42, 0xa8, 0x5a, 0x0d, 0xf2, 0x5b, 0x5b } \\r
+ }\r
+\r
+typedef struct _EFI_HTTP_PROTOCOL EFI_HTTP_PROTOCOL;\r
+\r
+///\r
+/// EFI_HTTP_VERSION\r
+///\r
+typedef enum {\r
+ HttpVersion10,\r
+ HttpVersion11,\r
+ HttpVersionUnsupported\r
+} EFI_HTTP_VERSION;\r
+\r
+///\r
+/// EFI_HTTP_METHOD\r
+///\r
+typedef enum {\r
+ HttpMethodGet,\r
+ HttpMethodPost,\r
+ HttpMethodPatch,\r
+ HttpMethodOptions,\r
+ HttpMethodConnect,\r
+ HttpMethodHead,\r
+ HttpMethodPut,\r
+ HttpMethodDelete,\r
+ HttpMethodTrace\r
+} EFI_HTTP_METHOD;\r
+\r
+///\r
+/// EFI_HTTP_STATUS_CODE\r
+///\r
+typedef enum {\r
+ HTTP_STATUS_UNSUPPORTED_STATUS = 0,\r
+ HTTP_STATUS_100_CONTINUE,\r
+ HTTP_STATUS_101_SWITCHING_PROTOCOLS,\r
+ HTTP_STATUS_200_OK,\r
+ HTTP_STATUS_201_CREATED,\r
+ HTTP_STATUS_202_ACCEPTED,\r
+ HTTP_STATUS_203_NON_AUTHORITATIVE_INFORMATION,\r
+ HTTP_STATUS_204_NO_CONTENT,\r
+ HTTP_STATUS_205_RESET_CONTENT,\r
+ HTTP_STATUS_206_PARTIAL_CONTENT,\r
+ HTTP_STATUS_300_MULTIPLE_CHIOCES,\r
+ HTTP_STATUS_301_MOVED_PERMANENTLY,\r
+ HTTP_STATUS_302_FOUND,\r
+ HTTP_STATUS_303_SEE_OTHER,\r
+ HTTP_STATUS_304_NOT_MODIFIED,\r
+ HTTP_STATUS_305_USE_PROXY,\r
+ HTTP_STATUS_307_TEMPORARY_REDIRECT,\r
+ HTTP_STATUS_400_BAD_REQUEST,\r
+ HTTP_STATUS_401_UNAUTHORIZED,\r
+ HTTP_STATUS_402_PAYMENT_REQUIRED,\r
+ HTTP_STATUS_403_FORBIDDEN,\r
+ HTTP_STATUS_404_NOT_FOUND,\r
+ HTTP_STATUS_405_METHOD_NOT_ALLOWED,\r
+ HTTP_STATUS_406_NOT_ACCEPTABLE,\r
+ HTTP_STATUS_407_PROXY_AUTHENTICATION_REQUIRED,\r
+ HTTP_STATUS_408_REQUEST_TIME_OUT,\r
+ HTTP_STATUS_409_CONFLICT,\r
+ HTTP_STATUS_410_GONE,\r
+ HTTP_STATUS_411_LENGTH_REQUIRED,\r
+ HTTP_STATUS_412_PRECONDITION_FAILED,\r
+ HTTP_STATUS_413_REQUEST_ENTITY_TOO_LARGE,\r
+ HTTP_STATUS_414_REQUEST_URI_TOO_LARGE,\r
+ HTTP_STATUS_415_UNSUPPORETD_MEDIA_TYPE,\r
+ HTTP_STATUS_416_REQUESTED_RANGE_NOT_SATISFIED,\r
+ HTTP_STATUS_417_EXPECTATION_FAILED,\r
+ HTTP_STATUS_500_INTERNAL_SERVER_ERROR,\r
+ HTTP_STATUS_501_NOT_IMIPLEMENTED,\r
+ HTTP_STATUS_502_BAD_GATEWAY,\r
+ HTTP_STATUS_503_SERVICE_UNAVAILABLE,\r
+ HTTP_STATUS_504_GATEWAY_TIME_OUT,\r
+ HTTP_STATUS_505_HTTP_VERSION_NOT_SUPPORTED\r
+} EFI_HTTP_STATUS_CODE;\r
+\r
+///\r
+/// EFI_HTTPv4_ACCESS_POINT\r
+///\r
+typedef struct {\r
+ ///\r
+ /// Set to TRUE to instruct the EFI HTTP instance to use the default address\r
+ /// information in every TCP connection made by this instance. In addition, when set\r
+ /// to TRUE, LocalAddress, LocalSubnet, and LocalPort are ignored.\r
+ ///\r
+ BOOLEAN UseDefaultAddress;\r
+ ///\r
+ /// If UseDefaultAddress is set to FALSE, this defines the local IP address to be\r
+ /// used in every TCP connection opened by this instance.\r
+ ///\r
+ EFI_IPv4_ADDRESS LocalAddress;\r
+ ///\r
+ /// If UseDefaultAddress is set to FALSE, this defines the local subnet to be used\r
+ /// in every TCP connection opened by this instance.\r
+ ///\r
+ EFI_IPv4_ADDRESS LocalSubnet;\r
+ ///\r
+ /// If UseDefaultAddress is set to FALSE, this defines the local port to be used in\r
+ /// every TCP connection opened by this instance.\r
+ ///\r
+ UINT16 LocalPort;\r
+} EFI_HTTPv4_ACCESS_POINT;\r
+\r
+///\r
+/// EFI_HTTPv6_ACCESS_POINT\r
+///\r
+typedef struct {\r
+ ///\r
+ /// Local IP address to be used in every TCP connection opened by this instance.\r
+ ///\r
+ EFI_IPv6_ADDRESS LocalAddress;\r
+ ///\r
+ /// Local port to be used in every TCP connection opened by this instance.\r
+ ///\r
+ UINT16 LocalPort;\r
+} EFI_HTTPv6_ACCESS_POINT;\r
+\r
+///\r
+/// EFI_HTTP_CONFIG_DATA_ACCESS_POINT\r
+///\r
+\r
+\r
+typedef struct {\r
+ ///\r
+ /// HTTP version that this instance will support.\r
+ ///\r
+ EFI_HTTP_VERSION HttpVersion;\r
+ ///\r
+ /// Time out (in milliseconds) when blocking for requests.\r
+ ///\r
+ UINT32 TimeOutMillisec;\r
+ ///\r
+ /// Defines behavior of EFI DNS and TCP protocols consumed by this instance. If\r
+ /// FALSE, this instance will use EFI_DNS4_PROTOCOL and EFI_TCP4_PROTOCOL. If TRUE,\r
+ /// this instance will use EFI_DNS6_PROTOCOL and EFI_TCP6_PROTOCOL.\r
+ ///\r
+ BOOLEAN LocalAddressIsIPv6;\r
+\r
+ union {\r
+ ///\r
+ /// When LocalAddressIsIPv6 is FALSE, this points to the local address, subnet, and\r
+ /// port used by the underlying TCP protocol.\r
+ ///\r
+ EFI_HTTPv4_ACCESS_POINT *IPv4Node;\r
+ ///\r
+ /// When LocalAddressIsIPv6 is TRUE, this points to the local IPv6 address and port\r
+ /// used by the underlying TCP protocol.\r
+ ///\r
+ EFI_HTTPv6_ACCESS_POINT *IPv6Node;\r
+ } AccessPoint;\r
+} EFI_HTTP_CONFIG_DATA;\r
+\r
+///\r
+/// EFI_HTTP_REQUEST_DATA\r
+///\r
+typedef struct {\r
+ ///\r
+ /// The HTTP method (e.g. GET, POST) for this HTTP Request.\r
+ ///\r
+ EFI_HTTP_METHOD Method;\r
+ ///\r
+ /// The URI of a remote host. From the information in this field, the HTTP instance\r
+ /// will be able to determine whether to use HTTP or HTTPS and will also be able to\r
+ /// determine the port number to use. If no port number is specified, port 80 (HTTP)\r
+ /// is assumed. See RFC 3986 for more details on URI syntax.\r
+ ///\r
+ CHAR16 *Url;\r
+} EFI_HTTP_REQUEST_DATA;\r
+\r
+///\r
+/// EFI_HTTP_RESPONSE_DATA\r
+///\r
+typedef struct {\r
+ ///\r
+ /// Response status code returned by the remote host.\r
+ ///\r
+ EFI_HTTP_STATUS_CODE StatusCode;\r
+} EFI_HTTP_RESPONSE_DATA;\r
+\r
+///\r
+/// EFI_HTTP_HEADER\r
+///\r
+typedef struct {\r
+ ///\r
+ /// Null terminated string which describes a field name. See RFC 2616 Section 14 for\r
+ /// detailed information about field names.\r
+ ///\r
+ CHAR8 *FieldName;\r
+ ///\r
+ /// Null terminated string which describes the corresponding field value. See RFC 2616\r
+ /// Section 14 for detailed information about field values.\r
+ ///\r
+ CHAR8 *FieldValue;\r
+} EFI_HTTP_HEADER;\r
+\r
+///\r
+/// EFI_HTTP_MESSAGE\r
+///\r
+typedef struct {\r
+ ///\r
+ /// HTTP message data.\r
+ ///\r
+ union {\r
+ ///\r
+ /// When the token is used to send a HTTP request, Request is a pointer to storage that\r
+ /// contains such data as URL and HTTP method.\r
+ ///\r
+ EFI_HTTP_REQUEST_DATA *Request;\r
+ ///\r
+ /// When used to await a response, Response points to storage containing HTTP response\r
+ /// status code.\r
+ ///\r
+ EFI_HTTP_RESPONSE_DATA *Response;\r
+ } Data;\r
+ ///\r
+ /// Number of HTTP header structures in Headers list. On request, this count is\r
+ /// provided by the caller. On response, this count is provided by the HTTP driver.\r
+ ///\r
+ UINTN HeaderCount;\r
+ ///\r
+ /// Array containing list of HTTP headers. On request, this array is populated by the\r
+ /// caller. On response, this array is allocated and populated by the HTTP driver. It\r
+ /// is the responsibility of the caller to free this memory on both request and\r
+ /// response.\r
+ ///\r
+ EFI_HTTP_HEADER *Headers;\r
+ ///\r
+ /// Length in bytes of the HTTP body. This can be zero depending on the HttpMethod type.\r
+ ///\r
+ UINTN BodyLength;\r
+ ///\r
+ /// Body associated with the HTTP request or response. This can be NULL depending on\r
+ /// the HttpMethod type.\r
+ ///\r
+ VOID *Body;\r
+} EFI_HTTP_MESSAGE;\r
+\r
+\r
+///\r
+/// EFI_HTTP_TOKEN\r
+///\r
+typedef struct {\r
+ ///\r
+ /// This Event will be signaled after the Status field is updated by the EFI HTTP\r
+ /// Protocol driver. The type of Event must be EFI_NOTIFY_SIGNAL. The Task Priority\r
+ /// Level (TPL) of Event must be lower than or equal to TPL_CALLBACK.\r
+ ///\r
+ EFI_EVENT Event;\r
+ ///\r
+ /// Status will be set to one of the following value if the HTTP request is\r
+ /// successfully sent or if an unexpected error occurs:\r
+ /// EFI_SUCCESS: The HTTP request was successfully sent to the remote host.\r
+ /// EFI_ABORTED: The HTTP request was cancelled by the caller and removed from\r
+ /// the transmit queue.\r
+ /// EFI_TIMEOUT: The HTTP request timed out before reaching the remote host.\r
+ /// EFI_DEVICE_ERROR: An unexpected system or network error occurred.\r
+ ///\r
+ EFI_STATUS Status;\r
+ ///\r
+ /// Pointer to storage containing HTTP message data.\r
+ ///\r
+ EFI_HTTP_MESSAGE *Message;\r
+} EFI_HTTP_TOKEN;\r
+\r
+/**\r
+ Returns the operational parameters for the current HTTP child instance.\r
+\r
+ The GetModeData() function is used to read the current mode data (operational\r
+ parameters) for this HTTP protocol instance.\r
+\r
+ @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.\r
+ @param[out] HttpConfigData Point to buffer for operational parameters of this\r
+ HTTP instance.\r
+\r
+ @retval EFI_SUCCESS Operation succeeded.\r
+ @retval EFI_INVALID_PARAMETER This is NULL.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI * EFI_HTTP_GET_MODE_DATA)(\r
+ IN EFI_HTTP_PROTOCOL *This,\r
+ OUT EFI_HTTP_CONFIG_DATA *HttpConfigData\r
+ );\r
+\r
+/**\r
+ Initialize or brutally reset the operational parameters for this EFI HTTP instance.\r
+\r
+ The Configure() function does the following:\r
+ When HttpConfigData is not NULL Initialize this EFI HTTP instance by configuring\r
+ timeout, local address, port, etc.\r
+ When HttpConfigData is NULL, reset this EFI HTTP instance by closing all active\r
+ connections with remote hosts, canceling all asynchronous tokens, and flush request\r
+ and response buffers without informing the appropriate hosts.\r
+\r
+ Except for GetModeData() and Configure(), No other EFI HTTP function can be executed\r
+ by this instance until the Configure() function is executed and returns successfully.\r
+\r
+ @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.\r
+ @param[in] HttpConfigData Pointer to the configure data to configure the instance.\r
+\r
+ @retval EFI_SUCCESS Operation succeeded.\r
+ @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
+ This is NULL.\r
+ HttpConfigData->LocalAddressIsIPv6 is FALSE and\r
+ HttpConfigData->IPv4Node is NULL.\r
+ HttpConfigData->LocalAddressIsIPv6 is TRUE and\r
+ HttpConfigData->IPv6Node is NULL.\r
+ @retval EFI_ALREADY_STARTED Reinitialize this HTTP instance without calling\r
+ Configure() with NULL to reset it.\r
+ @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
+ @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources when\r
+ executing Configure().\r
+ @retval EFI_UNSUPPORTED One or more options in ConfigData are not supported\r
+ in the implementation.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI * EFI_HTTP_CONFIGURE)(\r
+ IN EFI_HTTP_PROTOCOL *This,\r
+ IN EFI_HTTP_CONFIG_DATA *HttpConfigData\r
+ );\r
+\r
+/**\r
+ The Request() function queues an HTTP request to this HTTP instance, \r
+ similar to Transmit() function in the EFI TCP driver. When the HTTP request is sent\r
+ successfully, or if there is an error, Status in token will be updated and Event will\r
+ be signaled.\r
+\r
+ @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.\r
+ @param[in] Token Pointer to storage containing HTTP request token.\r
+\r
+ @retval EFI_SUCCESS Outgoing data was processed.\r
+ @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been started.\r
+ @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
+ @retval EFI_TIMEOUT Data was dropped out of the transmit or receive queue.\r
+ @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
+ This is NULL.\r
+ Token->Message is NULL.\r
+ Token->Message->Body is not NULL,\r
+ Token->Message->BodyLength is non-zero, and\r
+ Token->Message->Data is NULL, but a previous call to\r
+ Request()has not been completed successfully.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HTTP_REQUEST) (\r
+ IN EFI_HTTP_PROTOCOL *This,\r
+ IN EFI_HTTP_TOKEN *Token\r
+ );\r
+\r
+/**\r
+ Abort an asynchronous HTTP request or response token.\r
+\r
+ The Cancel() function aborts a pending HTTP request or response transaction. If\r
+ Token is not NULL and the token is in transmit or receive queues when it is being\r
+ cancelled, its Token->Status will be set to EFI_ABORTED and then Token->Event will\r
+ be signaled. If the token is not in one of the queues, which usually means that the\r
+ asynchronous operation has completed, EFI_NOT_FOUND is returned. If Token is NULL,\r
+ all asynchronous tokens issued by Request() or Response() will be aborted.\r
+\r
+ @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.\r
+ @param[in] Token Point to storage containing HTTP request or response\r
+ token.\r
+\r
+ @retval EFI_SUCCESS Request and Response queues are successfully flushed.\r
+ @retval EFI_INVALID_PARAMETER This is NULL.\r
+ @retval EFI_NOT_STARTED This instance hasn't been configured.\r
+ @retval EFI_NO_MAPPING When using the default address, configuration (DHCP,\r
+ BOOTP, RARP, etc.) hasn't finished yet.\r
+ @retval EFI_NOT_FOUND The asynchronous request or response token is not\r
+ found.\r
+ @retval EFI_UNSUPPORTED The implementation does not support this function.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HTTP_CANCEL)(\r
+ IN EFI_HTTP_PROTOCOL *This,\r
+ IN EFI_HTTP_TOKEN *Token\r
+ );\r
+\r
+/**\r
+ The Response() function queues an HTTP response to this HTTP instance, similar to\r
+ Receive() function in the EFI TCP driver. When the HTTP request is sent successfully,\r
+ or if there is an error, Status in token will be updated and Event will be signaled.\r
+\r
+ The HTTP driver will queue a receive token to the underlying TCP instance. When data\r
+ is received in the underlying TCP instance, the data will be parsed and Token will\r
+ be populated with the response data. If the data received from the remote host\r
+ contains an incomplete or invalid HTTP header, the HTTP driver will continue waiting\r
+ (asynchronously) for more data to be sent from the remote host before signaling\r
+ Event in Token.\r
+\r
+ It is the responsibility of the caller to allocate a buffer for Body and specify the\r
+ size in BodyLength. If the remote host provides a response that contains a content\r
+ body, up to BodyLength bytes will be copied from the receive buffer into Body and\r
+ BodyLength will be updated with the amount of bytes received and copied to Body. This\r
+ allows the client to download a large file in chunks instead of into one contiguous\r
+ block of memory. Similar to HTTP request, if Body is not NULL and BodyLength is\r
+ non-zero and all other fields are NULL or 0, the HTTP driver will queue a receive\r
+ token to underlying TCP instance. If data arrives in the receive buffer, up to\r
+ BodyLength bytes of data will be copied to Body. The HTTP driver will then update\r
+ BodyLength with the amount of bytes received and copied to Body.\r
+\r
+ If the HTTP driver does not have an open underlying TCP connection with the host\r
+ specified in the response URL, Request() will return EFI_ACCESS_DENIED. This is\r
+ consistent with RFC 2616 recommendation that HTTP clients should attempt to maintain\r
+ an open TCP connection between client and host.\r
+\r
+ @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.\r
+ @param[in] Token Pointer to storage containing HTTP response token.\r
+\r
+ @retval EFI_SUCCESS Allocation succeeded.\r
+ @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been\r
+ initialized.\r
+ @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
+ This is NULL.\r
+ Token->Message->Headers is NULL.\r
+ Token->Message is NULL.\r
+ Token->Message->Body is not NULL,\r
+ Token->Message->BodyLength is non-zero, and\r
+ Token->Message->Data is NULL, but a previous call to\r
+ Response() has not been completed successfully.\r
+ @retval EFI_ACCESS_DENIED An open TCP connection is not present with the host\r
+ specified by response URL.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HTTP_RESPONSE) (\r
+ IN EFI_HTTP_PROTOCOL *This,\r
+ IN EFI_HTTP_TOKEN *Token\r
+ );\r
+\r
+/**\r
+ The Poll() function can be used by network drivers and applications to increase the\r
+ rate that data packets are moved between the communication devices and the transmit\r
+ and receive queues.\r
+\r
+ In some systems, the periodic timer event in the managed network driver may not poll\r
+ the underlying communications device fast enough to transmit and/or receive all data\r
+ packets without missing incoming packets or dropping outgoing packets. Drivers and\r
+ applications that are experiencing packet loss should try calling the Poll() function\r
+ more often.\r
+\r
+ @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.\r
+\r
+ @retval EFI_SUCCESS Incoming or outgoing data was processed..\r
+ @retval EFI_DEVICE_ERROR An unexpected system or network error occurred\r
+ @retval EFI_INVALID_PARAMETER This is NULL.\r
+ @retval EFI_NOT_READY No incoming or outgoing data is processed.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HTTP_POLL) (\r
+ IN EFI_HTTP_PROTOCOL *This\r
+ );\r
+\r
+///\r
+/// The EFI HTTP protocol is designed to be used by EFI drivers and applications to\r
+/// create and transmit HTTP Requests, as well as handle HTTP responses that are\r
+/// returned by a remote host. This EFI protocol uses and relies on an underlying EFI\r
+/// TCP protocol.\r
+///\r
+struct _EFI_HTTP_PROTOCOL {\r
+ EFI_HTTP_GET_MODE_DATA GetModeData;\r
+ EFI_HTTP_CONFIGURE Configure;\r
+ EFI_HTTP_REQUEST Request;\r
+ EFI_HTTP_CANCEL Cancel;\r
+ EFI_HTTP_RESPONSE Response;\r
+ EFI_HTTP_POLL Poll;\r
+};\r
+\r
+extern EFI_GUID gEfiHttpServiceBindingProtocolGuid;\r
+extern EFI_GUID gEfiHttpProtocolGuid;\r
+\r
+#endif\r