-/** @file
- Support functions declaration for UEFI HTTP boot driver.
-
-Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
-This program and the accompanying materials are licensed and made available under
-the terms and conditions of the BSD License that accompanies this distribution.
-The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php.
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#ifndef __EFI_HTTP_BOOT_SUPPORT_H__
-#define __EFI_HTTP_BOOT_SUPPORT_H__
-
-/**
- Get the Nic handle using any child handle in the IPv4 stack.
-
- @param[in] ControllerHandle Pointer to child handle over IPv4.
-
- @return NicHandle The pointer to the Nic handle.
- @return NULL Can't find the Nic handle.
-
-**/
-EFI_HANDLE
-HttpBootGetNicByIp4Children (
- IN EFI_HANDLE ControllerHandle
- );
-
-/**
- This function is to convert UINTN to ASCII string with the required formatting.
-
- @param[in] Number Numeric value to be converted.
- @param[in] Buffer The pointer to the buffer for ASCII string.
- @param[in] Length The length of the required format.
-
-**/
-VOID
-HttpBootUintnToAscDecWithFormat (
- IN UINTN Number,
- IN UINT8 *Buffer,
- IN INTN Length
- );
-
-
-/**
- This function is to display the IPv4 address.
-
- @param[in] Ip The pointer to the IPv4 address.
-
-**/
-VOID
-HttpBootShowIp4Addr (
- IN EFI_IPv4_ADDRESS *Ip
- );
-
-//
-// A wrapper structure to hold the HTTP headers.
-//
-typedef struct {
- UINTN MaxHeaderCount;
- UINTN HeaderCount;
- EFI_HTTP_HEADER *Headers;
-} HTTP_IO_HEADER;
-
-/**
- Create a HTTP_IO_HEADER to hold the HTTP header items.
-
- @param[in] MaxHeaderCount The maximun number of HTTP header in this holder.
-
- @return A pointer of the HTTP header holder or NULL if failed.
-
-**/
-HTTP_IO_HEADER *
-HttpBootCreateHeader (
- IN UINTN MaxHeaderCount
- );
-
-/**
- Destroy the HTTP_IO_HEADER and release the resouces.
-
- @param[in] HttpIoHeader Point to the HTTP header holder to be destroyed.
-
-**/
-VOID
-HttpBootFreeHeader (
- IN HTTP_IO_HEADER *HttpIoHeader
- );
-
-/**
- Set or update a HTTP header with the field name and corresponding value.
-
- @param[in] HttpIoHeader Point to the HTTP header holder.
- @param[in] FieldName Null terminated string which describes a field name.
- @param[in] FieldValue Null terminated string which describes the corresponding field value.
-
- @retval EFI_SUCCESS The HTTP header has been set or updated.
- @retval EFI_INVALID_PARAMETER Any input parameter is invalid.
- @retval EFI_OUT_OF_RESOURCES Insufficient resource to complete the operation.
- @retval Other Unexpected error happened.
-
-**/
-EFI_STATUS
-HttpBootSetHeader (
- IN HTTP_IO_HEADER *HttpIoHeader,
- IN CHAR8 *FieldName,
- IN CHAR8 *FieldValue
- );
-
-//
-// HTTP_IO configuration data for IPv4
-//
-typedef struct {
- EFI_HTTP_VERSION HttpVersion;
- UINT32 RequestTimeOut; // In milliseconds.
- UINT32 ResponseTimeOut; // In milliseconds.
- BOOLEAN UseDefaultAddress;
- EFI_IPv4_ADDRESS LocalIp;
- EFI_IPv4_ADDRESS SubnetMask;
- UINT16 LocalPort;
-} HTTP4_IO_CONFIG_DATA;
-
-//
-// HTTP_IO configuration
-//
-typedef union {
- HTTP4_IO_CONFIG_DATA Config4;
-} HTTP_IO_CONFIG_DATA;
-
-//
-// HTTO_IO wrapper of the EFI HTTP service.
-//
-typedef struct {
- UINT8 IpVersion;
- EFI_HANDLE Image;
- EFI_HANDLE Controller;
- EFI_HANDLE Handle;
-
- EFI_HTTP_PROTOCOL *Http;
-
- EFI_HTTP_TOKEN ReqToken;
- EFI_HTTP_MESSAGE ReqMessage;
- EFI_HTTP_TOKEN RspToken;
- EFI_HTTP_MESSAGE RspMessage;
-
- BOOLEAN IsTxDone;
- BOOLEAN IsRxDone;
-} HTTP_IO;
-
-//
-// A wrapper structure to hold the received HTTP response data.
-//
-typedef struct {
- EFI_HTTP_RESPONSE_DATA Response;
- UINTN HeaderCount;
- EFI_HTTP_HEADER *Headers;
- UINTN BodyLength;
- CHAR8 *Body;
-} HTTP_IO_RESOPNSE_DATA;
-
-/**
- Create a HTTP_IO to access the HTTP service. It will create and configure
- a HTTP child handle.
-
- @param[in] Image The handle of the driver image.
- @param[in] Controller The handle of the controller.
- @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6.
- @param[in] ConfigData The HTTP_IO configuration data.
- @param[out] HttpIo The HTTP_IO.
-
- @retval EFI_SUCCESS The HTTP_IO is created and configured.
- @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
- @retval EFI_UNSUPPORTED One or more of the control options are not
- supported in the implementation.
- @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
- @retval Others Failed to create the HTTP_IO or configure it.
-
-**/
-EFI_STATUS
-HttpIoCreateIo (
- IN EFI_HANDLE Image,
- IN EFI_HANDLE Controller,
- IN UINT8 IpVersion,
- IN HTTP_IO_CONFIG_DATA *ConfigData,
- OUT HTTP_IO *HttpIo
- );
-
-/**
- Destroy the HTTP_IO and release the resouces.
-
- @param[in] HttpIo The HTTP_IO which wraps the HTTP service to be destroyed.
-
-**/
-VOID
-HttpIoDestroyIo (
- IN HTTP_IO *HttpIo
- );
-
-/**
- Synchronously send a HTTP REQUEST message to the server.
-
- @param[in] HttpIo The HttpIo wrapping the HTTP service.
- @param[in] Request A pointer to storage such data as URL and HTTP method.
- @param[in] HeaderCount Number of HTTP header structures in Headers list.
- @param[in] Headers Array containing list of HTTP headers.
- @param[in] BodyLength Length in bytes of the HTTP body.
- @param[in] Body Body associated with the HTTP request.
-
- @retval EFI_SUCCESS The HTTP request is trasmitted.
- @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
- @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
- @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.
- @retval Others Other errors as indicated.
-
-**/
-EFI_STATUS
-HttpIoSendRequest (
- IN HTTP_IO *HttpIo,
- IN EFI_HTTP_REQUEST_DATA *Request, OPTIONAL
- IN UINTN HeaderCount,
- IN EFI_HTTP_HEADER *Headers, OPTIONAL
- IN UINTN BodyLength,
- IN VOID *Body OPTIONAL
- );
-
-/**
- Synchronously receive a HTTP RESPONSE message from the server.
-
- @param[in] HttpIo The HttpIo wrapping the HTTP service.
- @param[in] RecvMsgHeader TRUE to receive a new HTTP response (from message header).
- FALSE to continue receive the previous response message.
- @param[out] ResponseData Point to a wrapper of the received response data.
-
- @retval EFI_SUCCESS The HTTP resopnse is received.
- @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
- @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
- @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.
- @retval Others Other errors as indicated.
-
-**/
-EFI_STATUS
-HttpIoRecvResponse (
- IN HTTP_IO *HttpIo,
- IN BOOLEAN RecvMsgHeader,
- OUT HTTP_IO_RESOPNSE_DATA *ResponseData
- );
-
-#endif
+/** @file\r
+ Support functions declaration for UEFI HTTP boot driver.\r
+\r
+Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials are licensed and made available under \r
+the terms and conditions of the BSD License that accompanies this distribution. \r
+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
+**/\r
+\r
+#ifndef __EFI_HTTP_BOOT_SUPPORT_H__\r
+#define __EFI_HTTP_BOOT_SUPPORT_H__\r
+\r
+/**\r
+ Get the Nic handle using any child handle in the IPv4 stack.\r
+\r
+ @param[in] ControllerHandle Pointer to child handle over IPv4.\r
+\r
+ @return NicHandle The pointer to the Nic handle.\r
+ @return NULL Can't find the Nic handle.\r
+\r
+**/\r
+EFI_HANDLE\r
+HttpBootGetNicByIp4Children (\r
+ IN EFI_HANDLE ControllerHandle\r
+ );\r
+\r
+/**\r
+ Get the Nic handle using any child handle in the IPv6 stack.\r
+\r
+ @param[in] ControllerHandle Pointer to child handle over IPv6.\r
+\r
+ @return NicHandle The pointer to the Nic handle.\r
+ @return NULL Can't find the Nic handle.\r
+\r
+**/\r
+EFI_HANDLE\r
+HttpBootGetNicByIp6Children (\r
+ IN EFI_HANDLE ControllerHandle\r
+ );\r
+\r
+/**\r
+ This function is to convert UINTN to ASCII string with the required formatting.\r
+\r
+ @param[in] Number Numeric value to be converted.\r
+ @param[in] Buffer The pointer to the buffer for ASCII string.\r
+ @param[in] Length The length of the required format.\r
+\r
+**/\r
+VOID\r
+HttpBootUintnToAscDecWithFormat (\r
+ IN UINTN Number,\r
+ IN UINT8 *Buffer,\r
+ IN INTN Length\r
+ );\r
+\r
+\r
+/**\r
+ This function is to display the IPv4 address.\r
+\r
+ @param[in] Ip The pointer to the IPv4 address.\r
+\r
+**/\r
+VOID\r
+HttpBootShowIp4Addr (\r
+ IN EFI_IPv4_ADDRESS *Ip\r
+ );\r
+\r
+/**\r
+ This function is to display the IPv6 address.\r
+\r
+ @param[in] Ip The pointer to the IPv6 address.\r
+\r
+**/\r
+VOID\r
+HttpBootShowIp6Addr (\r
+ IN EFI_IPv6_ADDRESS *Ip\r
+ );\r
+\r
+//\r
+// A wrapper structure to hold the HTTP headers.\r
+//\r
+typedef struct {\r
+ UINTN MaxHeaderCount;\r
+ UINTN HeaderCount;\r
+ EFI_HTTP_HEADER *Headers;\r
+} HTTP_IO_HEADER;\r
+\r
+/**\r
+ Create a HTTP_IO_HEADER to hold the HTTP header items.\r
+\r
+ @param[in] MaxHeaderCount The maximun number of HTTP header in this holder.\r
+\r
+ @return A pointer of the HTTP header holder or NULL if failed.\r
+ \r
+**/\r
+HTTP_IO_HEADER *\r
+HttpBootCreateHeader (\r
+ IN UINTN MaxHeaderCount\r
+ );\r
+\r
+/**\r
+ Destroy the HTTP_IO_HEADER and release the resouces. \r
+\r
+ @param[in] HttpIoHeader Point to the HTTP header holder to be destroyed.\r
+\r
+**/\r
+VOID\r
+HttpBootFreeHeader (\r
+ IN HTTP_IO_HEADER *HttpIoHeader\r
+ );\r
+\r
+/**\r
+ Set or update a HTTP header with the field name and corresponding value.\r
+\r
+ @param[in] HttpIoHeader Point to the HTTP header holder.\r
+ @param[in] FieldName Null terminated string which describes a field name. \r
+ @param[in] FieldValue Null terminated string which describes the corresponding field value.\r
+\r
+ @retval EFI_SUCCESS The HTTP header has been set or updated.\r
+ @retval EFI_INVALID_PARAMETER Any input parameter is invalid.\r
+ @retval EFI_OUT_OF_RESOURCES Insufficient resource to complete the operation.\r
+ @retval Other Unexpected error happened.\r
+ \r
+**/\r
+EFI_STATUS\r
+HttpBootSetHeader (\r
+ IN HTTP_IO_HEADER *HttpIoHeader,\r
+ IN CHAR8 *FieldName,\r
+ IN CHAR8 *FieldValue\r
+ );\r
+\r
+//\r
+// HTTP_IO configuration data for IPv4\r
+//\r
+typedef struct {\r
+ EFI_HTTP_VERSION HttpVersion;\r
+ UINT32 RequestTimeOut; // In milliseconds.\r
+ UINT32 ResponseTimeOut; // In milliseconds.\r
+ BOOLEAN UseDefaultAddress;\r
+ EFI_IPv4_ADDRESS LocalIp;\r
+ EFI_IPv4_ADDRESS SubnetMask;\r
+ UINT16 LocalPort;\r
+} HTTP4_IO_CONFIG_DATA;\r
+\r
+//\r
+// HTTP_IO configuration data for IPv6\r
+//\r
+typedef struct {\r
+ EFI_HTTP_VERSION HttpVersion;\r
+ UINT32 RequestTimeOut; // In milliseconds.\r
+ BOOLEAN UseDefaultAddress;\r
+ EFI_IPv6_ADDRESS LocalIp;\r
+ UINT16 LocalPort;\r
+} HTTP6_IO_CONFIG_DATA;\r
+\r
+\r
+//\r
+// HTTP_IO configuration\r
+//\r
+typedef union {\r
+ HTTP4_IO_CONFIG_DATA Config4;\r
+ HTTP6_IO_CONFIG_DATA Config6;\r
+} HTTP_IO_CONFIG_DATA;\r
+\r
+//\r
+// HTTP_IO wrapper of the EFI HTTP service.\r
+//\r
+typedef struct {\r
+ UINT8 IpVersion;\r
+ EFI_HANDLE Image;\r
+ EFI_HANDLE Controller;\r
+ EFI_HANDLE Handle;\r
+ \r
+ EFI_HTTP_PROTOCOL *Http;\r
+\r
+ EFI_HTTP_TOKEN ReqToken;\r
+ EFI_HTTP_MESSAGE ReqMessage;\r
+ EFI_HTTP_TOKEN RspToken;\r
+ EFI_HTTP_MESSAGE RspMessage;\r
+\r
+ BOOLEAN IsTxDone;\r
+ BOOLEAN IsRxDone;\r
+} HTTP_IO;\r
+\r
+//\r
+// A wrapper structure to hold the received HTTP response data.\r
+//\r
+typedef struct {\r
+ EFI_HTTP_RESPONSE_DATA Response;\r
+ UINTN HeaderCount;\r
+ EFI_HTTP_HEADER *Headers;\r
+ UINTN BodyLength;\r
+ CHAR8 *Body;\r
+} HTTP_IO_RESPONSE_DATA;\r
+\r
+/**\r
+ Retrieve the host address using the EFI_DNS6_PROTOCOL.\r
+\r
+ @param[in] Private The pointer to the driver's private data.\r
+ @param[in] HostName Pointer to buffer containing hostname.\r
+ @param[out] IpAddress On output, pointer to buffer containing IPv6 address.\r
+\r
+ @retval EFI_SUCCESS Operation succeeded.\r
+ @retval EFI_DEVICE_ERROR An unexpected network error occurred.\r
+ @retval Others Other errors as indicated. \r
+**/\r
+EFI_STATUS\r
+HttpBootDns (\r
+ IN HTTP_BOOT_PRIVATE_DATA *Private,\r
+ IN CHAR16 *HostName,\r
+ OUT EFI_IPv6_ADDRESS *IpAddress \r
+ );\r
+\r
+/**\r
+ Notify the callback function when an event is triggered.\r
+\r
+ @param[in] Event The triggered event.\r
+ @param[in] Context The opaque parameter to the function.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+HttpBootCommonNotify (\r
+ IN EFI_EVENT Event,\r
+ IN VOID *Context\r
+ );\r
+\r
+/**\r
+ Create a HTTP_IO to access the HTTP service. It will create and configure\r
+ a HTTP child handle.\r
+\r
+ @param[in] Image The handle of the driver image.\r
+ @param[in] Controller The handle of the controller.\r
+ @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6.\r
+ @param[in] ConfigData The HTTP_IO configuration data.\r
+ @param[out] HttpIo The HTTP_IO.\r
+ \r
+ @retval EFI_SUCCESS The HTTP_IO is created and configured.\r
+ @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
+ @retval EFI_UNSUPPORTED One or more of the control options are not\r
+ supported in the implementation.\r
+ @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
+ @retval Others Failed to create the HTTP_IO or configure it.\r
+\r
+**/\r
+EFI_STATUS\r
+HttpIoCreateIo (\r
+ IN EFI_HANDLE Image,\r
+ IN EFI_HANDLE Controller,\r
+ IN UINT8 IpVersion,\r
+ IN HTTP_IO_CONFIG_DATA *ConfigData,\r
+ OUT HTTP_IO *HttpIo\r
+ );\r
+\r
+/**\r
+ Destroy the HTTP_IO and release the resouces. \r
+\r
+ @param[in] HttpIo The HTTP_IO which wraps the HTTP service to be destroyed.\r
+\r
+**/\r
+VOID\r
+HttpIoDestroyIo (\r
+ IN HTTP_IO *HttpIo\r
+ );\r
+\r
+/**\r
+ Synchronously send a HTTP REQUEST message to the server.\r
+ \r
+ @param[in] HttpIo The HttpIo wrapping the HTTP service.\r
+ @param[in] Request A pointer to storage such data as URL and HTTP method.\r
+ @param[in] HeaderCount Number of HTTP header structures in Headers list. \r
+ @param[in] Headers Array containing list of HTTP headers.\r
+ @param[in] BodyLength Length in bytes of the HTTP body.\r
+ @param[in] Body Body associated with the HTTP request. \r
+ \r
+ @retval EFI_SUCCESS The HTTP request is trasmitted.\r
+ @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
+ @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
+ @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.\r
+ @retval Others Other errors as indicated.\r
+\r
+**/\r
+EFI_STATUS\r
+HttpIoSendRequest (\r
+ IN HTTP_IO *HttpIo,\r
+ IN EFI_HTTP_REQUEST_DATA *Request, OPTIONAL\r
+ IN UINTN HeaderCount,\r
+ IN EFI_HTTP_HEADER *Headers, OPTIONAL\r
+ IN UINTN BodyLength,\r
+ IN VOID *Body OPTIONAL\r
+ );\r
+\r
+/**\r
+ Synchronously receive a HTTP RESPONSE message from the server.\r
+ \r
+ @param[in] HttpIo The HttpIo wrapping the HTTP service.\r
+ @param[in] RecvMsgHeader TRUE to receive a new HTTP response (from message header).\r
+ FALSE to continue receive the previous response message.\r
+ @param[out] ResponseData Point to a wrapper of the received response data.\r
+ \r
+ @retval EFI_SUCCESS The HTTP response is received.\r
+ @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
+ @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
+ @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.\r
+ @retval Others Other errors as indicated.\r
+\r
+**/\r
+EFI_STATUS\r
+HttpIoRecvResponse (\r
+ IN HTTP_IO *HttpIo,\r
+ IN BOOLEAN RecvMsgHeader,\r
+ OUT HTTP_IO_RESPONSE_DATA *ResponseData\r
+ );\r
+\r
+#endif\r