]> git.proxmox.com Git - mirror_edk2.git/blame - NetworkPkg/HttpDxe/HttpImpl.h
MdeModulePkg: Add submitted callback test case in DriverSample
[mirror_edk2.git] / NetworkPkg / HttpDxe / HttpImpl.h
CommitLineData
47f51a06
YT
1/** @file\r
2 The header files of implementation of EFI_HTTP_PROTOCOL protocol interfaces.\r
3\r
072289f4 4 Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>\r
47f51a06
YT
5\r
6 This program and the accompanying materials\r
7 are licensed and made available under the terms and conditions of the BSD License\r
8 which accompanies this distribution. The full text of the license may be found at\r
9 http://opensource.org/licenses/bsd-license.php.\r
10\r
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
16#ifndef __EFI_HTTP_IMPL_H__\r
17#define __EFI_HTTP_IMPL_H__\r
18\r
19#define HTTP_DEFAULT_PORT 80\r
20#define HTTP_END_OF_HDR_STR "\r\n\r\n"\r
21#define HTTP_CRLF_STR "\r\n"\r
22#define HTTP_VERSION_STR "HTTP/1.1"\r
23#define HTTP_VERSION_CRLF_STR " HTTP/1.1\r\n"\r
24#define HTTP_GET_STR "GET "\r
25#define HTTP_HEAD_STR "HEAD "\r
072289f4
ZL
26#define HTTP_ERROR_OR_NOT_SUPPORT_STATUS_CODE 300\r
27\r
47f51a06
YT
28//\r
29// Connect method has maximum length according to EFI_HTTP_METHOD defined in\r
30// UEFI2.5 spec so use this.\r
31//\r
32#define HTTP_MAXIMUM_METHOD_LEN sizeof ("CONNECT")\r
33\r
34/**\r
35 Returns the operational parameters for the current HTTP child instance.\r
36\r
37 The GetModeData() function is used to read the current mode data (operational\r
38 parameters) for this HTTP protocol instance.\r
39\r
40 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.\r
41 @param[out] HttpConfigData Point to buffer for operational parameters of this\r
42 HTTP instance.\r
43\r
44 @retval EFI_SUCCESS Operation succeeded.\r
45 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
46 This is NULL.\r
47 HttpConfigData is NULL.\r
f0ab5a81
ZL
48 HttpInstance->LocalAddressIsIPv6 is FALSE and\r
49 HttpConfigData->IPv4Node is NULL.\r
50 HttpInstance->LocalAddressIsIPv6 is TRUE and\r
51 HttpConfigData->IPv6Node is NULL.\r
52 @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been started.\r
47f51a06
YT
53\r
54**/\r
55EFI_STATUS\r
56EFIAPI\r
57EfiHttpGetModeData (\r
58 IN EFI_HTTP_PROTOCOL *This,\r
59 OUT EFI_HTTP_CONFIG_DATA *HttpConfigData\r
60 );\r
61\r
62/**\r
63 Initialize or brutally reset the operational parameters for this EFI HTTP instance.\r
64\r
65 The Configure() function does the following:\r
66 When HttpConfigData is not NULL Initialize this EFI HTTP instance by configuring\r
67 timeout, local address, port, etc.\r
68 When HttpConfigData is NULL, reset this EFI HTTP instance by closing all active\r
69 connections with remote hosts, canceling all asynchronous tokens, and flush request\r
70 and response buffers without informing the appropriate hosts.\r
71\r
f0ab5a81
ZL
72 No other EFI HTTP function can be executed by this instance until the Configure() \r
73 function is executed and returns successfully.\r
47f51a06
YT
74\r
75 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.\r
76 @param[in] HttpConfigData Pointer to the configure data to configure the instance.\r
77\r
78 @retval EFI_SUCCESS Operation succeeded.\r
79 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
80 This is NULL.\r
f0ab5a81 81 HttpConfigData is NULL.\r
47f51a06
YT
82 HttpConfigData->LocalAddressIsIPv6 is FALSE and\r
83 HttpConfigData->IPv4Node is NULL.\r
84 HttpConfigData->LocalAddressIsIPv6 is TRUE and\r
85 HttpConfigData->IPv6Node is NULL.\r
86 @retval EFI_ALREADY_STARTED Reinitialize this HTTP instance without calling\r
87 Configure() with NULL to reset it.\r
88 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
89 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources when\r
90 executing Configure().\r
91 @retval EFI_UNSUPPORTED One or more options in ConfigData are not supported\r
92 in the implementation.\r
93**/\r
94EFI_STATUS\r
95EFIAPI\r
96EfiHttpConfigure (\r
97 IN EFI_HTTP_PROTOCOL *This,\r
98 IN EFI_HTTP_CONFIG_DATA *HttpConfigData\r
99 );\r
100\r
101/**\r
102 The Request() function queues an HTTP request to this HTTP instance.\r
103\r
104 Similar to Transmit() function in the EFI TCP driver. When the HTTP request is sent\r
105 successfully, or if there is an error, Status in token will be updated and Event will\r
106 be signaled.\r
107\r
108 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.\r
109 @param[in] Token Pointer to storage containing HTTP request token.\r
110\r
111 @retval EFI_SUCCESS Outgoing data was processed.\r
112 @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been started.\r
113 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
114 @retval EFI_TIMEOUT Data was dropped out of the transmit or receive queue.\r
115 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources.\r
116 @retval EFI_UNSUPPORTED The HTTP method is not supported in current\r
117 implementation.\r
118 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
119 This is NULL.\r
f0ab5a81 120 Token is NULL.\r
47f51a06
YT
121 Token->Message is NULL.\r
122 Token->Message->Body is not NULL,\r
123 Token->Message->BodyLength is non-zero, and\r
124 Token->Message->Data is NULL, but a previous call to\r
125 Request()has not been completed successfully.\r
126**/\r
127EFI_STATUS\r
128EFIAPI\r
129EfiHttpRequest (\r
130 IN EFI_HTTP_PROTOCOL *This,\r
131 IN EFI_HTTP_TOKEN *Token\r
132 );\r
133\r
134/**\r
135 Abort an asynchronous HTTP request or response token.\r
136\r
137 The Cancel() function aborts a pending HTTP request or response transaction. If\r
138 Token is not NULL and the token is in transmit or receive queues when it is being\r
139 cancelled, its Token->Status will be set to EFI_ABORTED and then Token->Event will\r
140 be signaled. If the token is not in one of the queues, which usually means that the\r
141 asynchronous operation has completed, EFI_NOT_FOUND is returned. If Token is NULL,\r
142 all asynchronous tokens issued by Request() or Response() will be aborted.\r
143\r
144 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.\r
145 @param[in] Token Point to storage containing HTTP request or response\r
146 token.\r
147\r
148 @retval EFI_SUCCESS Request and Response queues are successfully flushed.\r
149 @retval EFI_INVALID_PARAMETER This is NULL.\r
150 @retval EFI_NOT_STARTED This instance hasn't been configured.\r
47f51a06
YT
151 @retval EFI_NOT_FOUND The asynchronous request or response token is not\r
152 found.\r
153 @retval EFI_UNSUPPORTED The implementation does not support this function.\r
154**/\r
155EFI_STATUS\r
156EFIAPI\r
157EfiHttpCancel (\r
158 IN EFI_HTTP_PROTOCOL *This,\r
159 IN EFI_HTTP_TOKEN *Token\r
160 );\r
161\r
162/**\r
163 The Response() function queues an HTTP response to this HTTP instance, similar to\r
f0ab5a81 164 Receive() function in the EFI TCP driver. When the HTTP response is received successfully,\r
47f51a06
YT
165 or if there is an error, Status in token will be updated and Event will be signaled.\r
166\r
167 The HTTP driver will queue a receive token to the underlying TCP instance. When data\r
168 is received in the underlying TCP instance, the data will be parsed and Token will\r
169 be populated with the response data. If the data received from the remote host\r
170 contains an incomplete or invalid HTTP header, the HTTP driver will continue waiting\r
171 (asynchronously) for more data to be sent from the remote host before signaling\r
172 Event in Token.\r
173\r
174 It is the responsibility of the caller to allocate a buffer for Body and specify the\r
175 size in BodyLength. If the remote host provides a response that contains a content\r
176 body, up to BodyLength bytes will be copied from the receive buffer into Body and\r
177 BodyLength will be updated with the amount of bytes received and copied to Body. This\r
178 allows the client to download a large file in chunks instead of into one contiguous\r
179 block of memory. Similar to HTTP request, if Body is not NULL and BodyLength is\r
180 non-zero and all other fields are NULL or 0, the HTTP driver will queue a receive\r
181 token to underlying TCP instance. If data arrives in the receive buffer, up to\r
182 BodyLength bytes of data will be copied to Body. The HTTP driver will then update\r
183 BodyLength with the amount of bytes received and copied to Body.\r
184\r
185 If the HTTP driver does not have an open underlying TCP connection with the host\r
186 specified in the response URL, Request() will return EFI_ACCESS_DENIED. This is\r
187 consistent with RFC 2616 recommendation that HTTP clients should attempt to maintain\r
188 an open TCP connection between client and host.\r
189\r
190 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.\r
191 @param[in] Token Pointer to storage containing HTTP response token.\r
192\r
193 @retval EFI_SUCCESS Allocation succeeded.\r
194 @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been\r
195 initialized.\r
196 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
197 This is NULL.\r
198 Token is NULL.\r
199 Token->Message->Headers is NULL.\r
200 Token->Message is NULL.\r
201 Token->Message->Body is not NULL,\r
202 Token->Message->BodyLength is non-zero, and\r
203 Token->Message->Data is NULL, but a previous call to\r
204 Response() has not been completed successfully.\r
205 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources.\r
206 @retval EFI_ACCESS_DENIED An open TCP connection is not present with the host\r
207 specified by response URL.\r
208**/\r
209EFI_STATUS\r
210EFIAPI\r
211EfiHttpResponse (\r
212 IN EFI_HTTP_PROTOCOL *This,\r
213 IN EFI_HTTP_TOKEN *Token\r
214 );\r
215\r
216/**\r
217 The Poll() function can be used by network drivers and applications to increase the\r
218 rate that data packets are moved between the communication devices and the transmit\r
219 and receive queues.\r
220\r
221 In some systems, the periodic timer event in the managed network driver may not poll\r
222 the underlying communications device fast enough to transmit and/or receive all data\r
223 packets without missing incoming packets or dropping outgoing packets. Drivers and\r
224 applications that are experiencing packet loss should try calling the Poll() function\r
225 more often.\r
226\r
227 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.\r
228\r
229 @retval EFI_SUCCESS Incoming or outgoing data was processed.\r
230 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
231 @retval EFI_INVALID_PARAMETER This is NULL.\r
232 @retval EFI_NOT_READY No incoming or outgoing data is processed.\r
233 @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been started.\r
234\r
235**/\r
236EFI_STATUS\r
237EFIAPI\r
238EfiHttpPoll (\r
239 IN EFI_HTTP_PROTOCOL *This\r
240 );\r
241\r
242extern EFI_HTTP_PROTOCOL mEfiHttpTemplate;\r
243\r
244#endif\r