2 Support functions declaration for UEFI HTTP boot driver.
4 Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials are licensed and made available under
6 the terms and conditions of the BSD License that accompanies this distribution.
7 The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php.
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #ifndef __EFI_HTTP_BOOT_SUPPORT_H__
16 #define __EFI_HTTP_BOOT_SUPPORT_H__
19 Get the Nic handle using any child handle in the IPv4 stack.
21 @param[in] ControllerHandle Pointer to child handle over IPv4.
23 @return NicHandle The pointer to the Nic handle.
24 @return NULL Can't find the Nic handle.
28 HttpBootGetNicByIp4Children (
29 IN EFI_HANDLE ControllerHandle
33 This function is to convert UINTN to ASCII string with the required formatting.
35 @param[in] Number Numeric value to be converted.
36 @param[in] Buffer The pointer to the buffer for ASCII string.
37 @param[in] Length The length of the required format.
41 HttpBootUintnToAscDecWithFormat (
49 This function is to display the IPv4 address.
51 @param[in] Ip The pointer to the IPv4 address.
56 IN EFI_IPv4_ADDRESS
*Ip
60 // A wrapper structure to hold the HTTP headers.
65 EFI_HTTP_HEADER
*Headers
;
69 Create a HTTP_IO_HEADER to hold the HTTP header items.
71 @param[in] MaxHeaderCount The maximun number of HTTP header in this holder.
73 @return A pointer of the HTTP header holder or NULL if failed.
77 HttpBootCreateHeader (
78 IN UINTN MaxHeaderCount
82 Destroy the HTTP_IO_HEADER and release the resouces.
84 @param[in] HttpIoHeader Point to the HTTP header holder to be destroyed.
89 IN HTTP_IO_HEADER
*HttpIoHeader
93 Set or update a HTTP header with the field name and corresponding value.
95 @param[in] HttpIoHeader Point to the HTTP header holder.
96 @param[in] FieldName Null terminated string which describes a field name.
97 @param[in] FieldValue Null terminated string which describes the corresponding field value.
99 @retval EFI_SUCCESS The HTTP header has been set or updated.
100 @retval EFI_INVALID_PARAMETER Any input parameter is invalid.
101 @retval EFI_OUT_OF_RESOURCES Insufficient resource to complete the operation.
102 @retval Other Unexpected error happened.
107 IN HTTP_IO_HEADER
*HttpIoHeader
,
113 // HTTP_IO configuration data for IPv4
116 EFI_HTTP_VERSION HttpVersion
;
117 UINT32 RequestTimeOut
; // In milliseconds.
118 UINT32 ResponseTimeOut
; // In milliseconds.
119 BOOLEAN UseDefaultAddress
;
120 EFI_IPv4_ADDRESS LocalIp
;
121 EFI_IPv4_ADDRESS SubnetMask
;
123 } HTTP4_IO_CONFIG_DATA
;
126 // HTTP_IO configuration
129 HTTP4_IO_CONFIG_DATA Config4
;
130 } HTTP_IO_CONFIG_DATA
;
133 // HTTO_IO wrapper of the EFI HTTP service.
138 EFI_HANDLE Controller
;
141 EFI_HTTP_PROTOCOL
*Http
;
143 EFI_HTTP_TOKEN ReqToken
;
144 EFI_HTTP_MESSAGE ReqMessage
;
145 EFI_HTTP_TOKEN RspToken
;
146 EFI_HTTP_MESSAGE RspMessage
;
153 // A wrapper structure to hold the received HTTP response data.
156 EFI_HTTP_RESPONSE_DATA Response
;
158 EFI_HTTP_HEADER
*Headers
;
161 } HTTP_IO_RESOPNSE_DATA
;
164 Create a HTTP_IO to access the HTTP service. It will create and configure
167 @param[in] Image The handle of the driver image.
168 @param[in] Controller The handle of the controller.
169 @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6.
170 @param[in] ConfigData The HTTP_IO configuration data.
171 @param[out] HttpIo The HTTP_IO.
173 @retval EFI_SUCCESS The HTTP_IO is created and configured.
174 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
175 @retval EFI_UNSUPPORTED One or more of the control options are not
176 supported in the implementation.
177 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
178 @retval Others Failed to create the HTTP_IO or configure it.
184 IN EFI_HANDLE Controller
,
186 IN HTTP_IO_CONFIG_DATA
*ConfigData
,
191 Destroy the HTTP_IO and release the resouces.
193 @param[in] HttpIo The HTTP_IO which wraps the HTTP service to be destroyed.
202 Synchronously send a HTTP REQUEST message to the server.
204 @param[in] HttpIo The HttpIo wrapping the HTTP service.
205 @param[in] Request A pointer to storage such data as URL and HTTP method.
206 @param[in] HeaderCount Number of HTTP header structures in Headers list.
207 @param[in] Headers Array containing list of HTTP headers.
208 @param[in] BodyLength Length in bytes of the HTTP body.
209 @param[in] Body Body associated with the HTTP request.
211 @retval EFI_SUCCESS The HTTP request is trasmitted.
212 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
213 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
214 @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.
215 @retval Others Other errors as indicated.
221 IN EFI_HTTP_REQUEST_DATA
*Request
, OPTIONAL
222 IN UINTN HeaderCount
,
223 IN EFI_HTTP_HEADER
*Headers
, OPTIONAL
225 IN VOID
*Body OPTIONAL
229 Synchronously receive a HTTP RESPONSE message from the server.
231 @param[in] HttpIo The HttpIo wrapping the HTTP service.
232 @param[in] RecvMsgHeader TRUE to receive a new HTTP response (from message header).
233 FALSE to continue receive the previous response message.
234 @param[out] ResponseData Point to a wrapper of the received response data.
236 @retval EFI_SUCCESS The HTTP resopnse is received.
237 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
238 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
239 @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.
240 @retval Others Other errors as indicated.
246 IN BOOLEAN RecvMsgHeader
,
247 OUT HTTP_IO_RESOPNSE_DATA
*ResponseData