]> git.proxmox.com Git - mirror_edk2.git/blame - NetworkPkg/HttpBootDxe/HttpBootSupport.h
NetworkPkg: Fix some typos of "according"
[mirror_edk2.git] / NetworkPkg / HttpBootDxe / HttpBootSupport.h
CommitLineData
d933e70a
JW
1/** @file\r
2 Support functions declaration for UEFI HTTP boot driver.\r
3\r
221463c2 4Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>\r
d933e70a
JW
5This program and the accompanying materials are licensed and made available under \r
6the terms and conditions of the BSD License that accompanies this distribution. \r
7The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php. \r
9 \r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
11WITHOUT 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
27EFI_HANDLE\r
28HttpBootGetNicByIp4Children (\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
41EFI_HANDLE\r
42HttpBootGetNicByIp6Children (\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
54VOID\r
55HttpBootUintnToAscDecWithFormat (\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
68VOID\r
69HttpBootShowIp4Addr (\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
79VOID\r
80HttpBootShowIp6Addr (\r
81 IN EFI_IPv6_ADDRESS *Ip\r
82 );\r
83\r
072289f4
ZL
84/**\r
85 This function is to display the HTTP error status.\r
86\r
87 @param[in] StatusCode The status code value in HTTP message.\r
88\r
89**/\r
90VOID\r
91HttpBootPrintErrorMessage (\r
92 EFI_HTTP_STATUS_CODE StatusCode\r
93 );\r
94\r
d933e70a
JW
95//\r
96// A wrapper structure to hold the HTTP headers.\r
97//\r
98typedef struct {\r
99 UINTN MaxHeaderCount;\r
100 UINTN HeaderCount;\r
101 EFI_HTTP_HEADER *Headers;\r
102} HTTP_IO_HEADER;\r
103\r
104/**\r
105 Create a HTTP_IO_HEADER to hold the HTTP header items.\r
106\r
107 @param[in] MaxHeaderCount The maximun number of HTTP header in this holder.\r
108\r
109 @return A pointer of the HTTP header holder or NULL if failed.\r
110 \r
111**/\r
112HTTP_IO_HEADER *\r
113HttpBootCreateHeader (\r
114 IN UINTN MaxHeaderCount\r
115 );\r
116\r
117/**\r
118 Destroy the HTTP_IO_HEADER and release the resouces. \r
119\r
120 @param[in] HttpIoHeader Point to the HTTP header holder to be destroyed.\r
121\r
122**/\r
123VOID\r
124HttpBootFreeHeader (\r
125 IN HTTP_IO_HEADER *HttpIoHeader\r
126 );\r
127\r
128/**\r
129 Set or update a HTTP header with the field name and corresponding value.\r
130\r
131 @param[in] HttpIoHeader Point to the HTTP header holder.\r
132 @param[in] FieldName Null terminated string which describes a field name. \r
133 @param[in] FieldValue Null terminated string which describes the corresponding field value.\r
134\r
135 @retval EFI_SUCCESS The HTTP header has been set or updated.\r
136 @retval EFI_INVALID_PARAMETER Any input parameter is invalid.\r
137 @retval EFI_OUT_OF_RESOURCES Insufficient resource to complete the operation.\r
138 @retval Other Unexpected error happened.\r
139 \r
140**/\r
141EFI_STATUS\r
142HttpBootSetHeader (\r
143 IN HTTP_IO_HEADER *HttpIoHeader,\r
144 IN CHAR8 *FieldName,\r
145 IN CHAR8 *FieldValue\r
146 );\r
147\r
148//\r
149// HTTP_IO configuration data for IPv4\r
150//\r
151typedef struct {\r
152 EFI_HTTP_VERSION HttpVersion;\r
153 UINT32 RequestTimeOut; // In milliseconds.\r
154 UINT32 ResponseTimeOut; // In milliseconds.\r
155 BOOLEAN UseDefaultAddress;\r
156 EFI_IPv4_ADDRESS LocalIp;\r
157 EFI_IPv4_ADDRESS SubnetMask;\r
158 UINT16 LocalPort;\r
159} HTTP4_IO_CONFIG_DATA;\r
160\r
b659408b
ZL
161//\r
162// HTTP_IO configuration data for IPv6\r
163//\r
164typedef struct {\r
165 EFI_HTTP_VERSION HttpVersion;\r
166 UINT32 RequestTimeOut; // In milliseconds.\r
167 BOOLEAN UseDefaultAddress;\r
168 EFI_IPv6_ADDRESS LocalIp;\r
169 UINT16 LocalPort;\r
170} HTTP6_IO_CONFIG_DATA;\r
171\r
172\r
d933e70a
JW
173//\r
174// HTTP_IO configuration\r
175//\r
176typedef union {\r
177 HTTP4_IO_CONFIG_DATA Config4;\r
b659408b 178 HTTP6_IO_CONFIG_DATA Config6;\r
d933e70a
JW
179} HTTP_IO_CONFIG_DATA;\r
180\r
181//\r
ef422fc5 182// HTTP_IO wrapper of the EFI HTTP service.\r
d933e70a
JW
183//\r
184typedef struct {\r
185 UINT8 IpVersion;\r
186 EFI_HANDLE Image;\r
187 EFI_HANDLE Controller;\r
188 EFI_HANDLE Handle;\r
189 \r
190 EFI_HTTP_PROTOCOL *Http;\r
191\r
192 EFI_HTTP_TOKEN ReqToken;\r
193 EFI_HTTP_MESSAGE ReqMessage;\r
194 EFI_HTTP_TOKEN RspToken;\r
195 EFI_HTTP_MESSAGE RspMessage;\r
196\r
197 BOOLEAN IsTxDone;\r
198 BOOLEAN IsRxDone;\r
7570696c
JW
199\r
200 EFI_EVENT TimeoutEvent;\r
d933e70a
JW
201} HTTP_IO;\r
202\r
203//\r
204// A wrapper structure to hold the received HTTP response data.\r
205//\r
206typedef struct {\r
207 EFI_HTTP_RESPONSE_DATA Response;\r
208 UINTN HeaderCount;\r
209 EFI_HTTP_HEADER *Headers;\r
210 UINTN BodyLength;\r
211 CHAR8 *Body;\r
072289f4 212 EFI_STATUS Status;\r
ef422fc5 213} HTTP_IO_RESPONSE_DATA;\r
d933e70a 214\r
b659408b
ZL
215/**\r
216 Retrieve the host address using the EFI_DNS6_PROTOCOL.\r
217\r
218 @param[in] Private The pointer to the driver's private data.\r
219 @param[in] HostName Pointer to buffer containing hostname.\r
220 @param[out] IpAddress On output, pointer to buffer containing IPv6 address.\r
221\r
222 @retval EFI_SUCCESS Operation succeeded.\r
223 @retval EFI_DEVICE_ERROR An unexpected network error occurred.\r
224 @retval Others Other errors as indicated. \r
225**/\r
226EFI_STATUS\r
227HttpBootDns (\r
228 IN HTTP_BOOT_PRIVATE_DATA *Private,\r
229 IN CHAR16 *HostName,\r
230 OUT EFI_IPv6_ADDRESS *IpAddress \r
231 );\r
232\r
233/**\r
234 Notify the callback function when an event is triggered.\r
235\r
236 @param[in] Event The triggered event.\r
237 @param[in] Context The opaque parameter to the function.\r
238\r
239**/\r
240VOID\r
241EFIAPI\r
242HttpBootCommonNotify (\r
243 IN EFI_EVENT Event,\r
244 IN VOID *Context\r
245 );\r
246\r
d933e70a
JW
247/**\r
248 Create a HTTP_IO to access the HTTP service. It will create and configure\r
249 a HTTP child handle.\r
250\r
251 @param[in] Image The handle of the driver image.\r
252 @param[in] Controller The handle of the controller.\r
253 @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6.\r
254 @param[in] ConfigData The HTTP_IO configuration data.\r
255 @param[out] HttpIo The HTTP_IO.\r
256 \r
257 @retval EFI_SUCCESS The HTTP_IO is created and configured.\r
258 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
259 @retval EFI_UNSUPPORTED One or more of the control options are not\r
260 supported in the implementation.\r
261 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
262 @retval Others Failed to create the HTTP_IO or configure it.\r
263\r
264**/\r
265EFI_STATUS\r
266HttpIoCreateIo (\r
267 IN EFI_HANDLE Image,\r
268 IN EFI_HANDLE Controller,\r
269 IN UINT8 IpVersion,\r
270 IN HTTP_IO_CONFIG_DATA *ConfigData,\r
271 OUT HTTP_IO *HttpIo\r
272 );\r
273\r
274/**\r
275 Destroy the HTTP_IO and release the resouces. \r
276\r
277 @param[in] HttpIo The HTTP_IO which wraps the HTTP service to be destroyed.\r
278\r
279**/\r
280VOID\r
281HttpIoDestroyIo (\r
282 IN HTTP_IO *HttpIo\r
283 );\r
284\r
285/**\r
286 Synchronously send a HTTP REQUEST message to the server.\r
287 \r
288 @param[in] HttpIo The HttpIo wrapping the HTTP service.\r
289 @param[in] Request A pointer to storage such data as URL and HTTP method.\r
290 @param[in] HeaderCount Number of HTTP header structures in Headers list. \r
291 @param[in] Headers Array containing list of HTTP headers.\r
292 @param[in] BodyLength Length in bytes of the HTTP body.\r
293 @param[in] Body Body associated with the HTTP request. \r
294 \r
295 @retval EFI_SUCCESS The HTTP request is trasmitted.\r
296 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
297 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
298 @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.\r
299 @retval Others Other errors as indicated.\r
300\r
301**/\r
302EFI_STATUS\r
303HttpIoSendRequest (\r
304 IN HTTP_IO *HttpIo,\r
305 IN EFI_HTTP_REQUEST_DATA *Request, OPTIONAL\r
306 IN UINTN HeaderCount,\r
307 IN EFI_HTTP_HEADER *Headers, OPTIONAL\r
308 IN UINTN BodyLength,\r
309 IN VOID *Body OPTIONAL\r
310 );\r
311\r
312/**\r
313 Synchronously receive a HTTP RESPONSE message from the server.\r
314 \r
315 @param[in] HttpIo The HttpIo wrapping the HTTP service.\r
316 @param[in] RecvMsgHeader TRUE to receive a new HTTP response (from message header).\r
317 FALSE to continue receive the previous response message.\r
318 @param[out] ResponseData Point to a wrapper of the received response data.\r
319 \r
ef422fc5 320 @retval EFI_SUCCESS The HTTP response is received.\r
d933e70a
JW
321 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
322 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
323 @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.\r
324 @retval Others Other errors as indicated.\r
325\r
326**/\r
327EFI_STATUS\r
328HttpIoRecvResponse (\r
329 IN HTTP_IO *HttpIo,\r
330 IN BOOLEAN RecvMsgHeader,\r
ef422fc5 331 OUT HTTP_IO_RESPONSE_DATA *ResponseData\r
d933e70a
JW
332 );\r
333\r
221463c2
JW
334/**\r
335 This function checks the HTTP(S) URI scheme.\r
336\r
337 @param[in] Uri The pointer to the URI string.\r
338 \r
339 @retval EFI_SUCCESS The URI scheme is valid.\r
340 @retval EFI_INVALID_PARAMETER The URI scheme is not HTTP or HTTPS.\r
341 @retval EFI_ACCESS_DENIED HTTP is disabled and the URI is HTTP.\r
342\r
343**/\r
344EFI_STATUS\r
345HttpBootCheckUriScheme (\r
346 IN CHAR8 *Uri\r
347 );\r
348\r
fa848a40
FS
349/**\r
350 Get the URI address string from the input device path.\r
351\r
352 Caller need to free the buffer in the UriAddress pointer.\r
353 \r
354 @param[in] FilePath Pointer to the device path which contains a URI device path node.\r
73617fa6 355 @param[out] UriAddress The URI address string extract from the device path.\r
fa848a40
FS
356 \r
357 @retval EFI_SUCCESS The URI string is returned.\r
358 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
359\r
360**/\r
361EFI_STATUS\r
362HttpBootParseFilePath (\r
363 IN EFI_DEVICE_PATH_PROTOCOL *FilePath,\r
364 OUT CHAR8 **UriAddress\r
365 );\r
366\r
587d204c
FS
367/**\r
368 This function returns the image type according to server replied HTTP message\r
369 and also the image's URI info.\r
370\r
371 @param[in] Uri The pointer to the image's URI string.\r
372 @param[in] UriParser URI Parse result returned by NetHttpParseUrl(). \r
373 @param[in] HeaderCount Number of HTTP header structures in Headers list. \r
374 @param[in] Headers Array containing list of HTTP headers.\r
375 @param[out] ImageType The image type of the downloaded file.\r
376 \r
377 @retval EFI_SUCCESS The image type is returned in ImageType.\r
378 @retval EFI_INVALID_PARAMETER ImageType, Uri or UriParser is NULL.\r
379 @retval EFI_INVALID_PARAMETER HeaderCount is not zero, and Headers is NULL.\r
380 @retval EFI_NOT_FOUND Failed to identify the image type.\r
381 @retval Others Unexpect error happened.\r
382\r
383**/\r
384EFI_STATUS\r
385HttpBootCheckImageType (\r
386 IN CHAR8 *Uri,\r
387 IN VOID *UriParser,\r
388 IN UINTN HeaderCount,\r
389 IN EFI_HTTP_HEADER *Headers,\r
390 OUT HTTP_BOOT_IMAGE_TYPE *ImageType\r
391 );\r
392\r
393/**\r
394 This function register the RAM disk info to the system.\r
395 \r
396 @param[in] Private The pointer to the driver's private data.\r
397 @param[in] BufferSize The size of Buffer in bytes.\r
398 @param[in] Buffer The base address of the RAM disk.\r
399 @param[in] ImageType The image type of the file in Buffer.\r
400\r
401 @retval EFI_SUCCESS The RAM disk has been registered.\r
402 @retval EFI_NOT_FOUND No RAM disk protocol instances were found.\r
403 @retval EFI_UNSUPPORTED The ImageType is not supported.\r
404 @retval Others Unexpected error happened.\r
405\r
406**/\r
407EFI_STATUS\r
408HttpBootRegisterRamDisk (\r
409 IN HTTP_BOOT_PRIVATE_DATA *Private,\r
410 IN UINTN BufferSize,\r
411 IN VOID *Buffer,\r
412 IN HTTP_BOOT_IMAGE_TYPE ImageType\r
413 );\r
d933e70a 414#endif\r