]>
Commit | Line | Data |
---|---|---|
d933e70a JW |
1 | /** @file\r |
2 | Support functions declaration for UEFI HTTP boot driver.\r | |
3 | \r | |
f75a7f56 | 4 | Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>\r |
97e2b622 | 5 | (C) Copyright 2020 Hewlett-Packard Development Company, L.P.<BR>\r |
ecf98fbc | 6 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
d933e70a JW |
7 | \r |
8 | **/\r | |
9 | \r | |
10 | #ifndef __EFI_HTTP_BOOT_SUPPORT_H__\r | |
11 | #define __EFI_HTTP_BOOT_SUPPORT_H__\r | |
12 | \r | |
13 | /**\r | |
14 | Get the Nic handle using any child handle in the IPv4 stack.\r | |
15 | \r | |
16 | @param[in] ControllerHandle Pointer to child handle over IPv4.\r | |
17 | \r | |
18 | @return NicHandle The pointer to the Nic handle.\r | |
19 | @return NULL Can't find the Nic handle.\r | |
20 | \r | |
21 | **/\r | |
22 | EFI_HANDLE\r | |
23 | HttpBootGetNicByIp4Children (\r | |
24 | IN EFI_HANDLE ControllerHandle\r | |
25 | );\r | |
26 | \r | |
b659408b ZL |
27 | /**\r |
28 | Get the Nic handle using any child handle in the IPv6 stack.\r | |
29 | \r | |
30 | @param[in] ControllerHandle Pointer to child handle over IPv6.\r | |
31 | \r | |
32 | @return NicHandle The pointer to the Nic handle.\r | |
33 | @return NULL Can't find the Nic handle.\r | |
34 | \r | |
35 | **/\r | |
36 | EFI_HANDLE\r | |
37 | HttpBootGetNicByIp6Children (\r | |
38 | IN EFI_HANDLE ControllerHandle\r | |
39 | );\r | |
40 | \r | |
d933e70a JW |
41 | /**\r |
42 | This function is to convert UINTN to ASCII string with the required formatting.\r | |
43 | \r | |
44 | @param[in] Number Numeric value to be converted.\r | |
45 | @param[in] Buffer The pointer to the buffer for ASCII string.\r | |
46 | @param[in] Length The length of the required format.\r | |
47 | \r | |
48 | **/\r | |
49 | VOID\r | |
50 | HttpBootUintnToAscDecWithFormat (\r | |
51 | IN UINTN Number,\r | |
52 | IN UINT8 *Buffer,\r | |
53 | IN INTN Length\r | |
54 | );\r | |
55 | \r | |
56 | \r | |
57 | /**\r | |
58 | This function is to display the IPv4 address.\r | |
59 | \r | |
60 | @param[in] Ip The pointer to the IPv4 address.\r | |
61 | \r | |
62 | **/\r | |
63 | VOID\r | |
64 | HttpBootShowIp4Addr (\r | |
65 | IN EFI_IPv4_ADDRESS *Ip\r | |
66 | );\r | |
67 | \r | |
b659408b ZL |
68 | /**\r |
69 | This function is to display the IPv6 address.\r | |
70 | \r | |
71 | @param[in] Ip The pointer to the IPv6 address.\r | |
72 | \r | |
73 | **/\r | |
74 | VOID\r | |
75 | HttpBootShowIp6Addr (\r | |
76 | IN EFI_IPv6_ADDRESS *Ip\r | |
77 | );\r | |
78 | \r | |
072289f4 ZL |
79 | /**\r |
80 | This function is to display the HTTP error status.\r | |
81 | \r | |
82 | @param[in] StatusCode The status code value in HTTP message.\r | |
83 | \r | |
84 | **/\r | |
85 | VOID\r | |
86 | HttpBootPrintErrorMessage (\r | |
87 | EFI_HTTP_STATUS_CODE StatusCode\r | |
88 | );\r | |
89 | \r | |
d933e70a JW |
90 | //\r |
91 | // A wrapper structure to hold the HTTP headers.\r | |
92 | //\r | |
93 | typedef struct {\r | |
94 | UINTN MaxHeaderCount;\r | |
95 | UINTN HeaderCount;\r | |
96 | EFI_HTTP_HEADER *Headers;\r | |
97 | } HTTP_IO_HEADER;\r | |
98 | \r | |
99 | /**\r | |
100 | Create a HTTP_IO_HEADER to hold the HTTP header items.\r | |
101 | \r | |
c36b7b51 | 102 | @param[in] MaxHeaderCount The maximum number of HTTP header in this holder.\r |
d933e70a JW |
103 | \r |
104 | @return A pointer of the HTTP header holder or NULL if failed.\r | |
f75a7f56 | 105 | \r |
d933e70a JW |
106 | **/\r |
107 | HTTP_IO_HEADER *\r | |
108 | HttpBootCreateHeader (\r | |
109 | IN UINTN MaxHeaderCount\r | |
110 | );\r | |
111 | \r | |
112 | /**\r | |
c36b7b51 | 113 | Destroy the HTTP_IO_HEADER and release the resources.\r |
d933e70a JW |
114 | \r |
115 | @param[in] HttpIoHeader Point to the HTTP header holder to be destroyed.\r | |
116 | \r | |
117 | **/\r | |
118 | VOID\r | |
119 | HttpBootFreeHeader (\r | |
120 | IN HTTP_IO_HEADER *HttpIoHeader\r | |
121 | );\r | |
122 | \r | |
123 | /**\r | |
124 | Set or update a HTTP header with the field name and corresponding value.\r | |
125 | \r | |
126 | @param[in] HttpIoHeader Point to the HTTP header holder.\r | |
f75a7f56 | 127 | @param[in] FieldName Null terminated string which describes a field name.\r |
d933e70a JW |
128 | @param[in] FieldValue Null terminated string which describes the corresponding field value.\r |
129 | \r | |
130 | @retval EFI_SUCCESS The HTTP header has been set or updated.\r | |
131 | @retval EFI_INVALID_PARAMETER Any input parameter is invalid.\r | |
132 | @retval EFI_OUT_OF_RESOURCES Insufficient resource to complete the operation.\r | |
133 | @retval Other Unexpected error happened.\r | |
f75a7f56 | 134 | \r |
d933e70a JW |
135 | **/\r |
136 | EFI_STATUS\r | |
137 | HttpBootSetHeader (\r | |
138 | IN HTTP_IO_HEADER *HttpIoHeader,\r | |
139 | IN CHAR8 *FieldName,\r | |
140 | IN CHAR8 *FieldValue\r | |
141 | );\r | |
142 | \r | |
b659408b ZL |
143 | /**\r |
144 | Retrieve the host address using the EFI_DNS6_PROTOCOL.\r | |
145 | \r | |
146 | @param[in] Private The pointer to the driver's private data.\r | |
147 | @param[in] HostName Pointer to buffer containing hostname.\r | |
148 | @param[out] IpAddress On output, pointer to buffer containing IPv6 address.\r | |
149 | \r | |
150 | @retval EFI_SUCCESS Operation succeeded.\r | |
151 | @retval EFI_DEVICE_ERROR An unexpected network error occurred.\r | |
f75a7f56 | 152 | @retval Others Other errors as indicated.\r |
b659408b ZL |
153 | **/\r |
154 | EFI_STATUS\r | |
155 | HttpBootDns (\r | |
156 | IN HTTP_BOOT_PRIVATE_DATA *Private,\r | |
157 | IN CHAR16 *HostName,\r | |
f75a7f56 | 158 | OUT EFI_IPv6_ADDRESS *IpAddress\r |
b659408b ZL |
159 | );\r |
160 | \r | |
161 | /**\r | |
162 | Notify the callback function when an event is triggered.\r | |
163 | \r | |
164 | @param[in] Event The triggered event.\r | |
165 | @param[in] Context The opaque parameter to the function.\r | |
166 | \r | |
167 | **/\r | |
168 | VOID\r | |
169 | EFIAPI\r | |
170 | HttpBootCommonNotify (\r | |
171 | IN EFI_EVENT Event,\r | |
172 | IN VOID *Context\r | |
173 | );\r | |
174 | \r | |
221463c2 JW |
175 | /**\r |
176 | This function checks the HTTP(S) URI scheme.\r | |
177 | \r | |
178 | @param[in] Uri The pointer to the URI string.\r | |
f75a7f56 | 179 | \r |
221463c2 JW |
180 | @retval EFI_SUCCESS The URI scheme is valid.\r |
181 | @retval EFI_INVALID_PARAMETER The URI scheme is not HTTP or HTTPS.\r | |
182 | @retval EFI_ACCESS_DENIED HTTP is disabled and the URI is HTTP.\r | |
183 | \r | |
184 | **/\r | |
185 | EFI_STATUS\r | |
186 | HttpBootCheckUriScheme (\r | |
187 | IN CHAR8 *Uri\r | |
188 | );\r | |
189 | \r | |
fa848a40 FS |
190 | /**\r |
191 | Get the URI address string from the input device path.\r | |
192 | \r | |
193 | Caller need to free the buffer in the UriAddress pointer.\r | |
f75a7f56 | 194 | \r |
fa848a40 | 195 | @param[in] FilePath Pointer to the device path which contains a URI device path node.\r |
73617fa6 | 196 | @param[out] UriAddress The URI address string extract from the device path.\r |
f75a7f56 | 197 | \r |
fa848a40 FS |
198 | @retval EFI_SUCCESS The URI string is returned.\r |
199 | @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r | |
200 | \r | |
201 | **/\r | |
202 | EFI_STATUS\r | |
203 | HttpBootParseFilePath (\r | |
204 | IN EFI_DEVICE_PATH_PROTOCOL *FilePath,\r | |
205 | OUT CHAR8 **UriAddress\r | |
206 | );\r | |
207 | \r | |
587d204c FS |
208 | /**\r |
209 | This function returns the image type according to server replied HTTP message\r | |
210 | and also the image's URI info.\r | |
211 | \r | |
212 | @param[in] Uri The pointer to the image's URI string.\r | |
f75a7f56 LG |
213 | @param[in] UriParser URI Parse result returned by NetHttpParseUrl().\r |
214 | @param[in] HeaderCount Number of HTTP header structures in Headers list.\r | |
587d204c FS |
215 | @param[in] Headers Array containing list of HTTP headers.\r |
216 | @param[out] ImageType The image type of the downloaded file.\r | |
f75a7f56 | 217 | \r |
587d204c FS |
218 | @retval EFI_SUCCESS The image type is returned in ImageType.\r |
219 | @retval EFI_INVALID_PARAMETER ImageType, Uri or UriParser is NULL.\r | |
220 | @retval EFI_INVALID_PARAMETER HeaderCount is not zero, and Headers is NULL.\r | |
221 | @retval EFI_NOT_FOUND Failed to identify the image type.\r | |
c36b7b51 | 222 | @retval Others Unexpected error happened.\r |
587d204c FS |
223 | \r |
224 | **/\r | |
225 | EFI_STATUS\r | |
226 | HttpBootCheckImageType (\r | |
227 | IN CHAR8 *Uri,\r | |
228 | IN VOID *UriParser,\r | |
229 | IN UINTN HeaderCount,\r | |
230 | IN EFI_HTTP_HEADER *Headers,\r | |
231 | OUT HTTP_BOOT_IMAGE_TYPE *ImageType\r | |
232 | );\r | |
233 | \r | |
234 | /**\r | |
235 | This function register the RAM disk info to the system.\r | |
f75a7f56 | 236 | \r |
587d204c FS |
237 | @param[in] Private The pointer to the driver's private data.\r |
238 | @param[in] BufferSize The size of Buffer in bytes.\r | |
239 | @param[in] Buffer The base address of the RAM disk.\r | |
240 | @param[in] ImageType The image type of the file in Buffer.\r | |
241 | \r | |
242 | @retval EFI_SUCCESS The RAM disk has been registered.\r | |
243 | @retval EFI_NOT_FOUND No RAM disk protocol instances were found.\r | |
244 | @retval EFI_UNSUPPORTED The ImageType is not supported.\r | |
245 | @retval Others Unexpected error happened.\r | |
246 | \r | |
247 | **/\r | |
248 | EFI_STATUS\r | |
249 | HttpBootRegisterRamDisk (\r | |
250 | IN HTTP_BOOT_PRIVATE_DATA *Private,\r | |
251 | IN UINTN BufferSize,\r | |
252 | IN VOID *Buffer,\r | |
253 | IN HTTP_BOOT_IMAGE_TYPE ImageType\r | |
254 | );\r | |
bb4831c0 FS |
255 | \r |
256 | /**\r | |
257 | Indicate if the HTTP status code indicates a redirection.\r | |
f75a7f56 | 258 | \r |
bb4831c0 FS |
259 | @param[in] StatusCode HTTP status code from server.\r |
260 | \r | |
261 | @return TRUE if it's redirection.\r | |
262 | \r | |
263 | **/\r | |
264 | BOOLEAN\r | |
265 | HttpBootIsHttpRedirectStatusCode (\r | |
266 | IN EFI_HTTP_STATUS_CODE StatusCode\r | |
2913ebb2 | 267 | );\r |
d933e70a | 268 | #endif\r |