]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Include/Protocol/Http.h
MdePkg: Apply uncrustify changes
[mirror_edk2.git] / MdePkg / Include / Protocol / Http.h
index 64b31213a46efd980087281e3ed58a91e1f23346..28e6221593929334ad10441e56bcffeca3cc9ca8 100644 (file)
@@ -4,15 +4,9 @@
   HTTP Service Binding Protocol (HTTPSB)\r
   HTTP Protocol (HTTP)\r
 \r
-  Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
-  (C) Copyright 2015 Hewlett Packard Enterprise Development LP<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
+  Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>\r
+  (C) Copyright 2015-2017 Hewlett Packard Enterprise Development LP<BR>\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
   @par Revision Reference:\r
   This Protocol is introduced in UEFI Specification 2.5\r
@@ -73,7 +67,7 @@ typedef enum {
   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_300_MULTIPLE_CHOICES,\r
   HTTP_STATUS_301_MOVED_PERMANENTLY,\r
   HTTP_STATUS_302_FOUND,\r
   HTTP_STATUS_303_SEE_OTHER,\r
@@ -95,15 +89,16 @@ typedef enum {
   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_415_UNSUPPORTED_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_501_NOT_IMPLEMENTED,\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
+  HTTP_STATUS_505_HTTP_VERSION_NOT_SUPPORTED,\r
+  HTTP_STATUS_308_PERMANENT_REDIRECT\r
 } EFI_HTTP_STATUS_CODE;\r
 \r
 ///\r
@@ -113,24 +108,24 @@ typedef struct {
   ///\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
+  /// to TRUE, LocalAddress and LocalSubnet are ignored.\r
   ///\r
-  BOOLEAN                       UseDefaultAddress;\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
+  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
+  EFI_IPv4_ADDRESS    LocalSubnet;\r
   ///\r
-  /// If UseDefaultAddress is set to FALSE, this defines the local port to be used in\r
+  /// This defines the local port to be used in\r
   /// every TCP connection opened by this instance.\r
   ///\r
-  UINT16                        LocalPort;\r
+  UINT16              LocalPort;\r
 } EFI_HTTPv4_ACCESS_POINT;\r
 \r
 ///\r
@@ -140,45 +135,44 @@ typedef struct {
   ///\r
   /// Local IP address to be used in every TCP connection opened by this instance.\r
   ///\r
-  EFI_IPv6_ADDRESS              LocalAddress;\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
+  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
+  EFI_HTTP_VERSION    HttpVersion;\r
   ///\r
   /// Time out (in milliseconds) when blocking for requests.\r
   ///\r
-  UINT32                             TimeOutMillisec;\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
+  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
+    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
+    EFI_HTTPv6_ACCESS_POINT    *IPv6Node;\r
   } AccessPoint;\r
 } EFI_HTTP_CONFIG_DATA;\r
 \r
@@ -189,14 +183,14 @@ typedef struct {
   ///\r
   /// The HTTP method (e.g. GET, POST) for this HTTP Request.\r
   ///\r
-  EFI_HTTP_METHOD               Method;\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
+  CHAR16             *Url;\r
 } EFI_HTTP_REQUEST_DATA;\r
 \r
 ///\r
@@ -206,7 +200,7 @@ typedef struct {
   ///\r
   /// Response status code returned by the remote host.\r
   ///\r
-  EFI_HTTP_STATUS_CODE          StatusCode;\r
+  EFI_HTTP_STATUS_CODE    StatusCode;\r
 } EFI_HTTP_RESPONSE_DATA;\r
 \r
 ///\r
@@ -217,12 +211,12 @@ typedef struct {
   /// 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
+  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
+  CHAR8    *FieldValue;\r
 } EFI_HTTP_HEADER;\r
 \r
 ///\r
@@ -237,37 +231,36 @@ typedef struct {
     /// 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
+    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
+    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
+  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
+  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
+  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
+  VOID               *Body;\r
 } EFI_HTTP_MESSAGE;\r
 \r
-\r
 ///\r
 /// EFI_HTTP_TOKEN\r
 ///\r
@@ -277,21 +270,23 @@ typedef struct {
   /// 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
+  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_HTTP_ERROR:   The response message was successfully received but contains a\r
+  ///                     HTTP error. The response status code is returned in token.\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
+  EFI_STATUS          Status;\r
   ///\r
   /// Pointer to storage containing HTTP message data.\r
   ///\r
-  EFI_HTTP_MESSAGE              *Message;\r
+  EFI_HTTP_MESSAGE    *Message;\r
 } EFI_HTTP_TOKEN;\r
 \r
 /**\r
@@ -302,14 +297,22 @@ typedef struct {
 \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
+                                  HTTP instance. It is the responsibility of the caller\r
+                                  to allocate the memory for HttpConfigData and\r
+                                  HttpConfigData->AccessPoint.IPv6Node/IPv4Node. In fact,\r
+                                  it is recommended to allocate sufficient memory to record\r
+                                  IPv6Node since it is big enough for all possibilities.\r
 \r
   @retval EFI_SUCCESS             Operation succeeded.\r
   @retval EFI_INVALID_PARAMETER   This is NULL.\r
+                                  HttpConfigData is NULL.\r
+                                  HttpConfigData->AccessPoint.IPv4Node or\r
+                                  HttpConfigData->AccessPoint.IPv6Node is NULL.\r
+  @retval EFI_NOT_STARTED         This EFI HTTP Protocol instance has not been started.\r
 **/\r
 typedef\r
 EFI_STATUS\r
-(EFIAPI * EFI_HTTP_GET_MODE_DATA)(\r
+(EFIAPI *EFI_HTTP_GET_MODE_DATA)(\r
   IN  EFI_HTTP_PROTOCOL         *This,\r
   OUT EFI_HTTP_CONFIG_DATA      *HttpConfigData\r
   );\r
@@ -324,8 +327,8 @@ EFI_STATUS
   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
+  No other EFI HTTP function can be executed by this instance until the Configure()\r
+  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
@@ -334,9 +337,9 @@ EFI_STATUS
   @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->AccessPoint.IPv4Node is NULL.\r
                                   HttpConfigData->LocalAddressIsIPv6 is TRUE and\r
-                                  HttpConfigData->IPv6Node is NULL.\r
+                                  HttpConfigData->AccessPoint.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
@@ -347,13 +350,13 @@ EFI_STATUS
 **/\r
 typedef\r
 EFI_STATUS\r
-(EFIAPI * EFI_HTTP_CONFIGURE)(\r
+(EFIAPI *EFI_HTTP_CONFIGURE)(\r
   IN  EFI_HTTP_PROTOCOL         *This,\r
-  IN  EFI_HTTP_CONFIG_DATA      *HttpConfigData\r
+  IN  EFI_HTTP_CONFIG_DATA      *HttpConfigData OPTIONAL\r
   );\r
 \r
 /**\r
-  The Request() function queues an HTTP request to this HTTP instance, \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
@@ -367,15 +370,18 @@ EFI_STATUS
   @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 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
+  @retval EFI_OUT_OF_RESOURCES    Could not allocate enough system resources.\r
+  @retval EFI_UNSUPPORTED         The HTTP method is not supported in current implementation.\r
 **/\r
 typedef\r
 EFI_STATUS\r
-(EFIAPI *EFI_HTTP_REQUEST) (\r
+(EFIAPI *EFI_HTTP_REQUEST)(\r
   IN  EFI_HTTP_PROTOCOL         *This,\r
   IN  EFI_HTTP_TOKEN            *Token\r
   );\r
@@ -397,8 +403,6 @@ EFI_STATUS
   @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
@@ -412,7 +416,7 @@ EFI_STATUS
 \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
+  Receive() function in the EFI TCP driver. When the HTTP Response is received 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
@@ -446,18 +450,20 @@ EFI_STATUS
                                   initialized.\r
   @retval EFI_INVALID_PARAMETER   One or more of the following conditions is TRUE:\r
                                   This is NULL.\r
+                                  Token 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_OUT_OF_RESOURCES    Could not allocate enough system resources.\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
+(EFIAPI *EFI_HTTP_RESPONSE)(\r
   IN  EFI_HTTP_PROTOCOL         *This,\r
   IN  EFI_HTTP_TOKEN            *Token\r
   );\r
@@ -479,10 +485,11 @@ EFI_STATUS
   @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
+  @retval EFI_NOT_STARTED         This EFI HTTP Protocol instance has not been started.\r
 **/\r
 typedef\r
 EFI_STATUS\r
-(EFIAPI *EFI_HTTP_POLL) (\r
+(EFIAPI *EFI_HTTP_POLL)(\r
   IN  EFI_HTTP_PROTOCOL         *This\r
   );\r
 \r
@@ -493,15 +500,15 @@ EFI_STATUS
 /// 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
+  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
+extern EFI_GUID  gEfiHttpServiceBindingProtocolGuid;\r
+extern EFI_GUID  gEfiHttpProtocolGuid;\r
 \r
 #endif\r