]> git.proxmox.com Git - mirror_edk2.git/blame - NetworkPkg/HttpBootDxe/HttpBootSupport.h
NetworkPkg: Update cache management in HTTP boot driver.
[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
4Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
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
32/**\r
33 This function is to convert UINTN to ASCII string with the required formatting.\r
34\r
35 @param[in] Number Numeric value to be converted.\r
36 @param[in] Buffer The pointer to the buffer for ASCII string.\r
37 @param[in] Length The length of the required format.\r
38\r
39**/\r
40VOID\r
41HttpBootUintnToAscDecWithFormat (\r
42 IN UINTN Number,\r
43 IN UINT8 *Buffer,\r
44 IN INTN Length\r
45 );\r
46\r
47\r
48/**\r
49 This function is to display the IPv4 address.\r
50\r
51 @param[in] Ip The pointer to the IPv4 address.\r
52\r
53**/\r
54VOID\r
55HttpBootShowIp4Addr (\r
56 IN EFI_IPv4_ADDRESS *Ip\r
57 );\r
58\r
59//\r
60// A wrapper structure to hold the HTTP headers.\r
61//\r
62typedef struct {\r
63 UINTN MaxHeaderCount;\r
64 UINTN HeaderCount;\r
65 EFI_HTTP_HEADER *Headers;\r
66} HTTP_IO_HEADER;\r
67\r
68/**\r
69 Create a HTTP_IO_HEADER to hold the HTTP header items.\r
70\r
71 @param[in] MaxHeaderCount The maximun number of HTTP header in this holder.\r
72\r
73 @return A pointer of the HTTP header holder or NULL if failed.\r
74 \r
75**/\r
76HTTP_IO_HEADER *\r
77HttpBootCreateHeader (\r
78 IN UINTN MaxHeaderCount\r
79 );\r
80\r
81/**\r
82 Destroy the HTTP_IO_HEADER and release the resouces. \r
83\r
84 @param[in] HttpIoHeader Point to the HTTP header holder to be destroyed.\r
85\r
86**/\r
87VOID\r
88HttpBootFreeHeader (\r
89 IN HTTP_IO_HEADER *HttpIoHeader\r
90 );\r
91\r
92/**\r
93 Set or update a HTTP header with the field name and corresponding value.\r
94\r
95 @param[in] HttpIoHeader Point to the HTTP header holder.\r
96 @param[in] FieldName Null terminated string which describes a field name. \r
97 @param[in] FieldValue Null terminated string which describes the corresponding field value.\r
98\r
99 @retval EFI_SUCCESS The HTTP header has been set or updated.\r
100 @retval EFI_INVALID_PARAMETER Any input parameter is invalid.\r
101 @retval EFI_OUT_OF_RESOURCES Insufficient resource to complete the operation.\r
102 @retval Other Unexpected error happened.\r
103 \r
104**/\r
105EFI_STATUS\r
106HttpBootSetHeader (\r
107 IN HTTP_IO_HEADER *HttpIoHeader,\r
108 IN CHAR8 *FieldName,\r
109 IN CHAR8 *FieldValue\r
110 );\r
111\r
112//\r
113// HTTP_IO configuration data for IPv4\r
114//\r
115typedef struct {\r
116 EFI_HTTP_VERSION HttpVersion;\r
117 UINT32 RequestTimeOut; // In milliseconds.\r
118 UINT32 ResponseTimeOut; // In milliseconds.\r
119 BOOLEAN UseDefaultAddress;\r
120 EFI_IPv4_ADDRESS LocalIp;\r
121 EFI_IPv4_ADDRESS SubnetMask;\r
122 UINT16 LocalPort;\r
123} HTTP4_IO_CONFIG_DATA;\r
124\r
125//\r
126// HTTP_IO configuration\r
127//\r
128typedef union {\r
129 HTTP4_IO_CONFIG_DATA Config4;\r
130} HTTP_IO_CONFIG_DATA;\r
131\r
132//\r
133// HTTO_IO wrapper of the EFI HTTP service.\r
134//\r
135typedef struct {\r
136 UINT8 IpVersion;\r
137 EFI_HANDLE Image;\r
138 EFI_HANDLE Controller;\r
139 EFI_HANDLE Handle;\r
140 \r
141 EFI_HTTP_PROTOCOL *Http;\r
142\r
143 EFI_HTTP_TOKEN ReqToken;\r
144 EFI_HTTP_MESSAGE ReqMessage;\r
145 EFI_HTTP_TOKEN RspToken;\r
146 EFI_HTTP_MESSAGE RspMessage;\r
147\r
148 BOOLEAN IsTxDone;\r
149 BOOLEAN IsRxDone;\r
150} HTTP_IO;\r
151\r
152//\r
153// A wrapper structure to hold the received HTTP response data.\r
154//\r
155typedef struct {\r
156 EFI_HTTP_RESPONSE_DATA Response;\r
157 UINTN HeaderCount;\r
158 EFI_HTTP_HEADER *Headers;\r
159 UINTN BodyLength;\r
160 CHAR8 *Body;\r
161} HTTP_IO_RESOPNSE_DATA;\r
162\r
163/**\r
164 Create a HTTP_IO to access the HTTP service. It will create and configure\r
165 a HTTP child handle.\r
166\r
167 @param[in] Image The handle of the driver image.\r
168 @param[in] Controller The handle of the controller.\r
169 @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6.\r
170 @param[in] ConfigData The HTTP_IO configuration data.\r
171 @param[out] HttpIo The HTTP_IO.\r
172 \r
173 @retval EFI_SUCCESS The HTTP_IO is created and configured.\r
174 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
175 @retval EFI_UNSUPPORTED One or more of the control options are not\r
176 supported in the implementation.\r
177 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
178 @retval Others Failed to create the HTTP_IO or configure it.\r
179\r
180**/\r
181EFI_STATUS\r
182HttpIoCreateIo (\r
183 IN EFI_HANDLE Image,\r
184 IN EFI_HANDLE Controller,\r
185 IN UINT8 IpVersion,\r
186 IN HTTP_IO_CONFIG_DATA *ConfigData,\r
187 OUT HTTP_IO *HttpIo\r
188 );\r
189\r
190/**\r
191 Destroy the HTTP_IO and release the resouces. \r
192\r
193 @param[in] HttpIo The HTTP_IO which wraps the HTTP service to be destroyed.\r
194\r
195**/\r
196VOID\r
197HttpIoDestroyIo (\r
198 IN HTTP_IO *HttpIo\r
199 );\r
200\r
201/**\r
202 Synchronously send a HTTP REQUEST message to the server.\r
203 \r
204 @param[in] HttpIo The HttpIo wrapping the HTTP service.\r
205 @param[in] Request A pointer to storage such data as URL and HTTP method.\r
206 @param[in] HeaderCount Number of HTTP header structures in Headers list. \r
207 @param[in] Headers Array containing list of HTTP headers.\r
208 @param[in] BodyLength Length in bytes of the HTTP body.\r
209 @param[in] Body Body associated with the HTTP request. \r
210 \r
211 @retval EFI_SUCCESS The HTTP request is trasmitted.\r
212 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
213 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
214 @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.\r
215 @retval Others Other errors as indicated.\r
216\r
217**/\r
218EFI_STATUS\r
219HttpIoSendRequest (\r
220 IN HTTP_IO *HttpIo,\r
221 IN EFI_HTTP_REQUEST_DATA *Request, OPTIONAL\r
222 IN UINTN HeaderCount,\r
223 IN EFI_HTTP_HEADER *Headers, OPTIONAL\r
224 IN UINTN BodyLength,\r
225 IN VOID *Body OPTIONAL\r
226 );\r
227\r
228/**\r
229 Synchronously receive a HTTP RESPONSE message from the server.\r
230 \r
231 @param[in] HttpIo The HttpIo wrapping the HTTP service.\r
232 @param[in] RecvMsgHeader TRUE to receive a new HTTP response (from message header).\r
233 FALSE to continue receive the previous response message.\r
234 @param[out] ResponseData Point to a wrapper of the received response data.\r
235 \r
236 @retval EFI_SUCCESS The HTTP resopnse is received.\r
237 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
238 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
239 @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.\r
240 @retval Others Other errors as indicated.\r
241\r
242**/\r
243EFI_STATUS\r
244HttpIoRecvResponse (\r
245 IN HTTP_IO *HttpIo,\r
246 IN BOOLEAN RecvMsgHeader,\r
247 OUT HTTP_IO_RESOPNSE_DATA *ResponseData\r
248 );\r
249\r
250#endif\r