]>
Commit | Line | Data |
---|---|---|
d933e70a JW |
1 | /** @file\r |
2 | Support functions declaration for UEFI HTTP boot driver.\r | |
3 | \r | |
4 | Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r | |
5 | This program and the accompanying materials are licensed and made available under \r | |
6 | the terms and conditions of the BSD License that accompanies this distribution. \r | |
7 | The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php. \r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
13 | **/\r | |
14 | \r | |
15 | #ifndef __EFI_HTTP_BOOT_SUPPORT_H__\r | |
16 | #define __EFI_HTTP_BOOT_SUPPORT_H__\r | |
17 | \r | |
18 | /**\r | |
19 | Get the Nic handle using any child handle in the IPv4 stack.\r | |
20 | \r | |
21 | @param[in] ControllerHandle Pointer to child handle over IPv4.\r | |
22 | \r | |
23 | @return NicHandle The pointer to the Nic handle.\r | |
24 | @return NULL Can't find the Nic handle.\r | |
25 | \r | |
26 | **/\r | |
27 | EFI_HANDLE\r | |
28 | HttpBootGetNicByIp4Children (\r | |
29 | IN EFI_HANDLE ControllerHandle\r | |
30 | );\r | |
31 | \r | |
b659408b ZL |
32 | /**\r |
33 | Get the Nic handle using any child handle in the IPv6 stack.\r | |
34 | \r | |
35 | @param[in] ControllerHandle Pointer to child handle over IPv6.\r | |
36 | \r | |
37 | @return NicHandle The pointer to the Nic handle.\r | |
38 | @return NULL Can't find the Nic handle.\r | |
39 | \r | |
40 | **/\r | |
41 | EFI_HANDLE\r | |
42 | HttpBootGetNicByIp6Children (\r | |
43 | IN EFI_HANDLE ControllerHandle\r | |
44 | );\r | |
45 | \r | |
d933e70a JW |
46 | /**\r |
47 | This function is to convert UINTN to ASCII string with the required formatting.\r | |
48 | \r | |
49 | @param[in] Number Numeric value to be converted.\r | |
50 | @param[in] Buffer The pointer to the buffer for ASCII string.\r | |
51 | @param[in] Length The length of the required format.\r | |
52 | \r | |
53 | **/\r | |
54 | VOID\r | |
55 | HttpBootUintnToAscDecWithFormat (\r | |
56 | IN UINTN Number,\r | |
57 | IN UINT8 *Buffer,\r | |
58 | IN INTN Length\r | |
59 | );\r | |
60 | \r | |
61 | \r | |
62 | /**\r | |
63 | This function is to display the IPv4 address.\r | |
64 | \r | |
65 | @param[in] Ip The pointer to the IPv4 address.\r | |
66 | \r | |
67 | **/\r | |
68 | VOID\r | |
69 | HttpBootShowIp4Addr (\r | |
70 | IN EFI_IPv4_ADDRESS *Ip\r | |
71 | );\r | |
72 | \r | |
b659408b ZL |
73 | /**\r |
74 | This function is to display the IPv6 address.\r | |
75 | \r | |
76 | @param[in] Ip The pointer to the IPv6 address.\r | |
77 | \r | |
78 | **/\r | |
79 | VOID\r | |
80 | HttpBootShowIp6Addr (\r | |
81 | IN EFI_IPv6_ADDRESS *Ip\r | |
82 | );\r | |
83 | \r | |
d933e70a JW |
84 | //\r |
85 | // A wrapper structure to hold the HTTP headers.\r | |
86 | //\r | |
87 | typedef struct {\r | |
88 | UINTN MaxHeaderCount;\r | |
89 | UINTN HeaderCount;\r | |
90 | EFI_HTTP_HEADER *Headers;\r | |
91 | } HTTP_IO_HEADER;\r | |
92 | \r | |
93 | /**\r | |
94 | Create a HTTP_IO_HEADER to hold the HTTP header items.\r | |
95 | \r | |
96 | @param[in] MaxHeaderCount The maximun number of HTTP header in this holder.\r | |
97 | \r | |
98 | @return A pointer of the HTTP header holder or NULL if failed.\r | |
99 | \r | |
100 | **/\r | |
101 | HTTP_IO_HEADER *\r | |
102 | HttpBootCreateHeader (\r | |
103 | IN UINTN MaxHeaderCount\r | |
104 | );\r | |
105 | \r | |
106 | /**\r | |
107 | Destroy the HTTP_IO_HEADER and release the resouces. \r | |
108 | \r | |
109 | @param[in] HttpIoHeader Point to the HTTP header holder to be destroyed.\r | |
110 | \r | |
111 | **/\r | |
112 | VOID\r | |
113 | HttpBootFreeHeader (\r | |
114 | IN HTTP_IO_HEADER *HttpIoHeader\r | |
115 | );\r | |
116 | \r | |
117 | /**\r | |
118 | Set or update a HTTP header with the field name and corresponding value.\r | |
119 | \r | |
120 | @param[in] HttpIoHeader Point to the HTTP header holder.\r | |
121 | @param[in] FieldName Null terminated string which describes a field name. \r | |
122 | @param[in] FieldValue Null terminated string which describes the corresponding field value.\r | |
123 | \r | |
124 | @retval EFI_SUCCESS The HTTP header has been set or updated.\r | |
125 | @retval EFI_INVALID_PARAMETER Any input parameter is invalid.\r | |
126 | @retval EFI_OUT_OF_RESOURCES Insufficient resource to complete the operation.\r | |
127 | @retval Other Unexpected error happened.\r | |
128 | \r | |
129 | **/\r | |
130 | EFI_STATUS\r | |
131 | HttpBootSetHeader (\r | |
132 | IN HTTP_IO_HEADER *HttpIoHeader,\r | |
133 | IN CHAR8 *FieldName,\r | |
134 | IN CHAR8 *FieldValue\r | |
135 | );\r | |
136 | \r | |
137 | //\r | |
138 | // HTTP_IO configuration data for IPv4\r | |
139 | //\r | |
140 | typedef struct {\r | |
141 | EFI_HTTP_VERSION HttpVersion;\r | |
142 | UINT32 RequestTimeOut; // In milliseconds.\r | |
143 | UINT32 ResponseTimeOut; // In milliseconds.\r | |
144 | BOOLEAN UseDefaultAddress;\r | |
145 | EFI_IPv4_ADDRESS LocalIp;\r | |
146 | EFI_IPv4_ADDRESS SubnetMask;\r | |
147 | UINT16 LocalPort;\r | |
148 | } HTTP4_IO_CONFIG_DATA;\r | |
149 | \r | |
b659408b ZL |
150 | //\r |
151 | // HTTP_IO configuration data for IPv6\r | |
152 | //\r | |
153 | typedef struct {\r | |
154 | EFI_HTTP_VERSION HttpVersion;\r | |
155 | UINT32 RequestTimeOut; // In milliseconds.\r | |
156 | BOOLEAN UseDefaultAddress;\r | |
157 | EFI_IPv6_ADDRESS LocalIp;\r | |
158 | UINT16 LocalPort;\r | |
159 | } HTTP6_IO_CONFIG_DATA;\r | |
160 | \r | |
161 | \r | |
d933e70a JW |
162 | //\r |
163 | // HTTP_IO configuration\r | |
164 | //\r | |
165 | typedef union {\r | |
166 | HTTP4_IO_CONFIG_DATA Config4;\r | |
b659408b | 167 | HTTP6_IO_CONFIG_DATA Config6;\r |
d933e70a JW |
168 | } HTTP_IO_CONFIG_DATA;\r |
169 | \r | |
170 | //\r | |
171 | // HTTO_IO wrapper of the EFI HTTP service.\r | |
172 | //\r | |
173 | typedef struct {\r | |
174 | UINT8 IpVersion;\r | |
175 | EFI_HANDLE Image;\r | |
176 | EFI_HANDLE Controller;\r | |
177 | EFI_HANDLE Handle;\r | |
178 | \r | |
179 | EFI_HTTP_PROTOCOL *Http;\r | |
180 | \r | |
181 | EFI_HTTP_TOKEN ReqToken;\r | |
182 | EFI_HTTP_MESSAGE ReqMessage;\r | |
183 | EFI_HTTP_TOKEN RspToken;\r | |
184 | EFI_HTTP_MESSAGE RspMessage;\r | |
185 | \r | |
186 | BOOLEAN IsTxDone;\r | |
187 | BOOLEAN IsRxDone;\r | |
188 | } HTTP_IO;\r | |
189 | \r | |
190 | //\r | |
191 | // A wrapper structure to hold the received HTTP response data.\r | |
192 | //\r | |
193 | typedef struct {\r | |
194 | EFI_HTTP_RESPONSE_DATA Response;\r | |
195 | UINTN HeaderCount;\r | |
196 | EFI_HTTP_HEADER *Headers;\r | |
197 | UINTN BodyLength;\r | |
198 | CHAR8 *Body;\r | |
199 | } HTTP_IO_RESOPNSE_DATA;\r | |
200 | \r | |
b659408b ZL |
201 | /**\r |
202 | Retrieve the host address using the EFI_DNS6_PROTOCOL.\r | |
203 | \r | |
204 | @param[in] Private The pointer to the driver's private data.\r | |
205 | @param[in] HostName Pointer to buffer containing hostname.\r | |
206 | @param[out] IpAddress On output, pointer to buffer containing IPv6 address.\r | |
207 | \r | |
208 | @retval EFI_SUCCESS Operation succeeded.\r | |
209 | @retval EFI_DEVICE_ERROR An unexpected network error occurred.\r | |
210 | @retval Others Other errors as indicated. \r | |
211 | **/\r | |
212 | EFI_STATUS\r | |
213 | HttpBootDns (\r | |
214 | IN HTTP_BOOT_PRIVATE_DATA *Private,\r | |
215 | IN CHAR16 *HostName,\r | |
216 | OUT EFI_IPv6_ADDRESS *IpAddress \r | |
217 | );\r | |
218 | \r | |
219 | /**\r | |
220 | Notify the callback function when an event is triggered.\r | |
221 | \r | |
222 | @param[in] Event The triggered event.\r | |
223 | @param[in] Context The opaque parameter to the function.\r | |
224 | \r | |
225 | **/\r | |
226 | VOID\r | |
227 | EFIAPI\r | |
228 | HttpBootCommonNotify (\r | |
229 | IN EFI_EVENT Event,\r | |
230 | IN VOID *Context\r | |
231 | );\r | |
232 | \r | |
d933e70a JW |
233 | /**\r |
234 | Create a HTTP_IO to access the HTTP service. It will create and configure\r | |
235 | a HTTP child handle.\r | |
236 | \r | |
237 | @param[in] Image The handle of the driver image.\r | |
238 | @param[in] Controller The handle of the controller.\r | |
239 | @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6.\r | |
240 | @param[in] ConfigData The HTTP_IO configuration data.\r | |
241 | @param[out] HttpIo The HTTP_IO.\r | |
242 | \r | |
243 | @retval EFI_SUCCESS The HTTP_IO is created and configured.\r | |
244 | @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r | |
245 | @retval EFI_UNSUPPORTED One or more of the control options are not\r | |
246 | supported in the implementation.\r | |
247 | @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r | |
248 | @retval Others Failed to create the HTTP_IO or configure it.\r | |
249 | \r | |
250 | **/\r | |
251 | EFI_STATUS\r | |
252 | HttpIoCreateIo (\r | |
253 | IN EFI_HANDLE Image,\r | |
254 | IN EFI_HANDLE Controller,\r | |
255 | IN UINT8 IpVersion,\r | |
256 | IN HTTP_IO_CONFIG_DATA *ConfigData,\r | |
257 | OUT HTTP_IO *HttpIo\r | |
258 | );\r | |
259 | \r | |
260 | /**\r | |
261 | Destroy the HTTP_IO and release the resouces. \r | |
262 | \r | |
263 | @param[in] HttpIo The HTTP_IO which wraps the HTTP service to be destroyed.\r | |
264 | \r | |
265 | **/\r | |
266 | VOID\r | |
267 | HttpIoDestroyIo (\r | |
268 | IN HTTP_IO *HttpIo\r | |
269 | );\r | |
270 | \r | |
271 | /**\r | |
272 | Synchronously send a HTTP REQUEST message to the server.\r | |
273 | \r | |
274 | @param[in] HttpIo The HttpIo wrapping the HTTP service.\r | |
275 | @param[in] Request A pointer to storage such data as URL and HTTP method.\r | |
276 | @param[in] HeaderCount Number of HTTP header structures in Headers list. \r | |
277 | @param[in] Headers Array containing list of HTTP headers.\r | |
278 | @param[in] BodyLength Length in bytes of the HTTP body.\r | |
279 | @param[in] Body Body associated with the HTTP request. \r | |
280 | \r | |
281 | @retval EFI_SUCCESS The HTTP request is trasmitted.\r | |
282 | @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r | |
283 | @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r | |
284 | @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.\r | |
285 | @retval Others Other errors as indicated.\r | |
286 | \r | |
287 | **/\r | |
288 | EFI_STATUS\r | |
289 | HttpIoSendRequest (\r | |
290 | IN HTTP_IO *HttpIo,\r | |
291 | IN EFI_HTTP_REQUEST_DATA *Request, OPTIONAL\r | |
292 | IN UINTN HeaderCount,\r | |
293 | IN EFI_HTTP_HEADER *Headers, OPTIONAL\r | |
294 | IN UINTN BodyLength,\r | |
295 | IN VOID *Body OPTIONAL\r | |
296 | );\r | |
297 | \r | |
298 | /**\r | |
299 | Synchronously receive a HTTP RESPONSE message from the server.\r | |
300 | \r | |
301 | @param[in] HttpIo The HttpIo wrapping the HTTP service.\r | |
302 | @param[in] RecvMsgHeader TRUE to receive a new HTTP response (from message header).\r | |
303 | FALSE to continue receive the previous response message.\r | |
304 | @param[out] ResponseData Point to a wrapper of the received response data.\r | |
305 | \r | |
306 | @retval EFI_SUCCESS The HTTP resopnse is received.\r | |
307 | @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r | |
308 | @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r | |
309 | @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.\r | |
310 | @retval Others Other errors as indicated.\r | |
311 | \r | |
312 | **/\r | |
313 | EFI_STATUS\r | |
314 | HttpIoRecvResponse (\r | |
315 | IN HTTP_IO *HttpIo,\r | |
316 | IN BOOLEAN RecvMsgHeader,\r | |
317 | OUT HTTP_IO_RESOPNSE_DATA *ResponseData\r | |
318 | );\r | |
319 | \r | |
320 | #endif\r |