]> git.proxmox.com Git - mirror_edk2.git/blame - NetworkPkg/HttpBootDxe/HttpBootSupport.h
NetworkPkg/DxeHttpLib: Migrate HTTP header manipulation APIs
[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
f75a7f56 4Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>\r
97e2b622 5(C) Copyright 2020 Hewlett-Packard Development Company, L.P.<BR>\r
ecf98fbc 6SPDX-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
22EFI_HANDLE\r
23HttpBootGetNicByIp4Children (\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
36EFI_HANDLE\r
37HttpBootGetNicByIp6Children (\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
49VOID\r
50HttpBootUintnToAscDecWithFormat (\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
63VOID\r
64HttpBootShowIp4Addr (\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
74VOID\r
75HttpBootShowIp6Addr (\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
85VOID\r
86HttpBootPrintErrorMessage (\r
87 EFI_HTTP_STATUS_CODE StatusCode\r
88 );\r
89\r
b659408b
ZL
90/**\r
91 Retrieve the host address using the EFI_DNS6_PROTOCOL.\r
92\r
93 @param[in] Private The pointer to the driver's private data.\r
94 @param[in] HostName Pointer to buffer containing hostname.\r
95 @param[out] IpAddress On output, pointer to buffer containing IPv6 address.\r
96\r
97 @retval EFI_SUCCESS Operation succeeded.\r
98 @retval EFI_DEVICE_ERROR An unexpected network error occurred.\r
f75a7f56 99 @retval Others Other errors as indicated.\r
b659408b
ZL
100**/\r
101EFI_STATUS\r
102HttpBootDns (\r
103 IN HTTP_BOOT_PRIVATE_DATA *Private,\r
104 IN CHAR16 *HostName,\r
f75a7f56 105 OUT EFI_IPv6_ADDRESS *IpAddress\r
b659408b
ZL
106 );\r
107\r
108/**\r
109 Notify the callback function when an event is triggered.\r
110\r
111 @param[in] Event The triggered event.\r
112 @param[in] Context The opaque parameter to the function.\r
113\r
114**/\r
115VOID\r
116EFIAPI\r
117HttpBootCommonNotify (\r
118 IN EFI_EVENT Event,\r
119 IN VOID *Context\r
120 );\r
121\r
221463c2
JW
122/**\r
123 This function checks the HTTP(S) URI scheme.\r
124\r
125 @param[in] Uri The pointer to the URI string.\r
f75a7f56 126\r
221463c2
JW
127 @retval EFI_SUCCESS The URI scheme is valid.\r
128 @retval EFI_INVALID_PARAMETER The URI scheme is not HTTP or HTTPS.\r
129 @retval EFI_ACCESS_DENIED HTTP is disabled and the URI is HTTP.\r
130\r
131**/\r
132EFI_STATUS\r
133HttpBootCheckUriScheme (\r
134 IN CHAR8 *Uri\r
135 );\r
136\r
fa848a40
FS
137/**\r
138 Get the URI address string from the input device path.\r
139\r
140 Caller need to free the buffer in the UriAddress pointer.\r
f75a7f56 141\r
fa848a40 142 @param[in] FilePath Pointer to the device path which contains a URI device path node.\r
73617fa6 143 @param[out] UriAddress The URI address string extract from the device path.\r
f75a7f56 144\r
fa848a40
FS
145 @retval EFI_SUCCESS The URI string is returned.\r
146 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
147\r
148**/\r
149EFI_STATUS\r
150HttpBootParseFilePath (\r
151 IN EFI_DEVICE_PATH_PROTOCOL *FilePath,\r
152 OUT CHAR8 **UriAddress\r
153 );\r
154\r
587d204c
FS
155/**\r
156 This function returns the image type according to server replied HTTP message\r
157 and also the image's URI info.\r
158\r
159 @param[in] Uri The pointer to the image's URI string.\r
f75a7f56
LG
160 @param[in] UriParser URI Parse result returned by NetHttpParseUrl().\r
161 @param[in] HeaderCount Number of HTTP header structures in Headers list.\r
587d204c
FS
162 @param[in] Headers Array containing list of HTTP headers.\r
163 @param[out] ImageType The image type of the downloaded file.\r
f75a7f56 164\r
587d204c
FS
165 @retval EFI_SUCCESS The image type is returned in ImageType.\r
166 @retval EFI_INVALID_PARAMETER ImageType, Uri or UriParser is NULL.\r
167 @retval EFI_INVALID_PARAMETER HeaderCount is not zero, and Headers is NULL.\r
168 @retval EFI_NOT_FOUND Failed to identify the image type.\r
c36b7b51 169 @retval Others Unexpected error happened.\r
587d204c
FS
170\r
171**/\r
172EFI_STATUS\r
173HttpBootCheckImageType (\r
174 IN CHAR8 *Uri,\r
175 IN VOID *UriParser,\r
176 IN UINTN HeaderCount,\r
177 IN EFI_HTTP_HEADER *Headers,\r
178 OUT HTTP_BOOT_IMAGE_TYPE *ImageType\r
179 );\r
180\r
181/**\r
182 This function register the RAM disk info to the system.\r
f75a7f56 183\r
587d204c
FS
184 @param[in] Private The pointer to the driver's private data.\r
185 @param[in] BufferSize The size of Buffer in bytes.\r
186 @param[in] Buffer The base address of the RAM disk.\r
187 @param[in] ImageType The image type of the file in Buffer.\r
188\r
189 @retval EFI_SUCCESS The RAM disk has been registered.\r
190 @retval EFI_NOT_FOUND No RAM disk protocol instances were found.\r
191 @retval EFI_UNSUPPORTED The ImageType is not supported.\r
192 @retval Others Unexpected error happened.\r
193\r
194**/\r
195EFI_STATUS\r
196HttpBootRegisterRamDisk (\r
197 IN HTTP_BOOT_PRIVATE_DATA *Private,\r
198 IN UINTN BufferSize,\r
199 IN VOID *Buffer,\r
200 IN HTTP_BOOT_IMAGE_TYPE ImageType\r
201 );\r
bb4831c0
FS
202\r
203/**\r
204 Indicate if the HTTP status code indicates a redirection.\r
f75a7f56 205\r
bb4831c0
FS
206 @param[in] StatusCode HTTP status code from server.\r
207\r
208 @return TRUE if it's redirection.\r
209\r
210**/\r
211BOOLEAN\r
212HttpBootIsHttpRedirectStatusCode (\r
213 IN EFI_HTTP_STATUS_CODE StatusCode\r
2913ebb2 214 );\r
d933e70a 215#endif\r