]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Protocol/Http.h
MdePkg: Add UEFI2.5 Ramdisk device path definition
[mirror_edk2.git] / MdePkg / Include / Protocol / Http.h
CommitLineData
cff298f4 1/** @file\r
2 This file defines the EFI HTTP Protocol interface. It is split into\r
3 the following two main sections:\r
4 HTTP Service Binding Protocol (HTTPSB)\r
5 HTTP Protocol (HTTP)\r
6\r
7 Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
8 This program and the accompanying materials\r
9 are licensed and made available under the terms and conditions of the BSD License\r
10 which accompanies this distribution. The full text of the license may be found at\r
11 http://opensource.org/licenses/bsd-license.php\r
12\r
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
15\r
16 @par Revision Reference:\r
17 This Protocol is introduced in UEFI Specification 2.5\r
18\r
19**/\r
20\r
21#ifndef __EFI_HTTP_PROTOCOL_H__\r
22#define __EFI_HTTP_PROTOCOL_H__\r
23\r
24#define EFI_HTTP_SERVICE_BINDING_PROTOCOL_GUID \\r
25 { \\r
26 0xbdc8e6af, 0xd9bc, 0x4379, {0xa7, 0x2a, 0xe0, 0xc4, 0xe7, 0x5d, 0xae, 0x1c } \\r
27 }\r
28\r
29#define EFI_HTTP_PROTOCOL_GUID \\r
30 { \\r
31 0x7a59b29b, 0x910b, 0x4171, {0x82, 0x42, 0xa8, 0x5a, 0x0d, 0xf2, 0x5b, 0x5b } \\r
32 }\r
33\r
34typedef struct _EFI_HTTP_PROTOCOL EFI_HTTP_PROTOCOL;\r
35\r
36///\r
37/// EFI_HTTP_VERSION\r
38///\r
39typedef enum {\r
40 HttpVersion10,\r
41 HttpVersion11,\r
42 HttpVersionUnsupported\r
43} EFI_HTTP_VERSION;\r
44\r
45///\r
46/// EFI_HTTP_METHOD\r
47///\r
48typedef enum {\r
49 HttpMethodGet,\r
50 HttpMethodPost,\r
51 HttpMethodPatch,\r
52 HttpMethodOptions,\r
53 HttpMethodConnect,\r
54 HttpMethodHead,\r
55 HttpMethodPut,\r
56 HttpMethodDelete,\r
57 HttpMethodTrace\r
58} EFI_HTTP_METHOD;\r
59\r
60///\r
61/// EFI_HTTP_STATUS_CODE\r
62///\r
63typedef enum {\r
64 HTTP_STATUS_UNSUPPORTED_STATUS = 0,\r
65 HTTP_STATUS_100_CONTINUE,\r
66 HTTP_STATUS_101_SWITCHING_PROTOCOLS,\r
67 HTTP_STATUS_200_OK,\r
68 HTTP_STATUS_201_CREATED,\r
69 HTTP_STATUS_202_ACCEPTED,\r
70 HTTP_STATUS_203_NON_AUTHORITATIVE_INFORMATION,\r
71 HTTP_STATUS_204_NO_CONTENT,\r
72 HTTP_STATUS_205_RESET_CONTENT,\r
73 HTTP_STATUS_206_PARTIAL_CONTENT,\r
74 HTTP_STATUS_300_MULTIPLE_CHIOCES,\r
75 HTTP_STATUS_301_MOVED_PERMANENTLY,\r
76 HTTP_STATUS_302_FOUND,\r
77 HTTP_STATUS_303_SEE_OTHER,\r
78 HTTP_STATUS_304_NOT_MODIFIED,\r
79 HTTP_STATUS_305_USE_PROXY,\r
80 HTTP_STATUS_307_TEMPORARY_REDIRECT,\r
81 HTTP_STATUS_400_BAD_REQUEST,\r
82 HTTP_STATUS_401_UNAUTHORIZED,\r
83 HTTP_STATUS_402_PAYMENT_REQUIRED,\r
84 HTTP_STATUS_403_FORBIDDEN,\r
85 HTTP_STATUS_404_NOT_FOUND,\r
86 HTTP_STATUS_405_METHOD_NOT_ALLOWED,\r
87 HTTP_STATUS_406_NOT_ACCEPTABLE,\r
88 HTTP_STATUS_407_PROXY_AUTHENTICATION_REQUIRED,\r
89 HTTP_STATUS_408_REQUEST_TIME_OUT,\r
90 HTTP_STATUS_409_CONFLICT,\r
91 HTTP_STATUS_410_GONE,\r
92 HTTP_STATUS_411_LENGTH_REQUIRED,\r
93 HTTP_STATUS_412_PRECONDITION_FAILED,\r
94 HTTP_STATUS_413_REQUEST_ENTITY_TOO_LARGE,\r
95 HTTP_STATUS_414_REQUEST_URI_TOO_LARGE,\r
96 HTTP_STATUS_415_UNSUPPORETD_MEDIA_TYPE,\r
97 HTTP_STATUS_416_REQUESTED_RANGE_NOT_SATISFIED,\r
98 HTTP_STATUS_417_EXPECTATION_FAILED,\r
99 HTTP_STATUS_500_INTERNAL_SERVER_ERROR,\r
100 HTTP_STATUS_501_NOT_IMIPLEMENTED,\r
101 HTTP_STATUS_502_BAD_GATEWAY,\r
102 HTTP_STATUS_503_SERVICE_UNAVAILABLE,\r
103 HTTP_STATUS_504_GATEWAY_TIME_OUT,\r
104 HTTP_STATUS_505_HTTP_VERSION_NOT_SUPPORTED\r
105} EFI_HTTP_STATUS_CODE;\r
106\r
107///\r
108/// EFI_HTTPv4_ACCESS_POINT\r
109///\r
110typedef struct {\r
111 ///\r
112 /// Set to TRUE to instruct the EFI HTTP instance to use the default address\r
113 /// information in every TCP connection made by this instance. In addition, when set\r
114 /// to TRUE, LocalAddress, LocalSubnet, and LocalPort are ignored.\r
115 ///\r
116 BOOLEAN UseDefaultAddress;\r
117 ///\r
118 /// If UseDefaultAddress is set to FALSE, this defines the local IP address to be\r
119 /// used in every TCP connection opened by this instance.\r
120 ///\r
121 EFI_IPv4_ADDRESS LocalAddress;\r
122 ///\r
123 /// If UseDefaultAddress is set to FALSE, this defines the local subnet to be used\r
124 /// in every TCP connection opened by this instance.\r
125 ///\r
126 EFI_IPv4_ADDRESS LocalSubnet;\r
127 ///\r
128 /// If UseDefaultAddress is set to FALSE, this defines the local port to be used in\r
129 /// every TCP connection opened by this instance.\r
130 ///\r
131 UINT16 LocalPort;\r
132} EFI_HTTPv4_ACCESS_POINT;\r
133\r
134///\r
135/// EFI_HTTPv6_ACCESS_POINT\r
136///\r
137typedef struct {\r
138 ///\r
139 /// Local IP address to be used in every TCP connection opened by this instance.\r
140 ///\r
141 EFI_IPv6_ADDRESS LocalAddress;\r
142 ///\r
143 /// Local port to be used in every TCP connection opened by this instance.\r
144 ///\r
145 UINT16 LocalPort;\r
146} EFI_HTTPv6_ACCESS_POINT;\r
147\r
148///\r
149/// EFI_HTTP_CONFIG_DATA_ACCESS_POINT\r
150///\r
151\r
152\r
153typedef struct {\r
154 ///\r
155 /// HTTP version that this instance will support.\r
156 ///\r
157 EFI_HTTP_VERSION HttpVersion;\r
158 ///\r
159 /// Time out (in milliseconds) when blocking for requests.\r
160 ///\r
161 UINT32 TimeOutMillisec;\r
162 ///\r
163 /// Defines behavior of EFI DNS and TCP protocols consumed by this instance. If\r
164 /// FALSE, this instance will use EFI_DNS4_PROTOCOL and EFI_TCP4_PROTOCOL. If TRUE,\r
165 /// this instance will use EFI_DNS6_PROTOCOL and EFI_TCP6_PROTOCOL.\r
166 ///\r
167 BOOLEAN LocalAddressIsIPv6;\r
168\r
169 union {\r
170 ///\r
171 /// When LocalAddressIsIPv6 is FALSE, this points to the local address, subnet, and\r
172 /// port used by the underlying TCP protocol.\r
173 ///\r
174 EFI_HTTPv4_ACCESS_POINT *IPv4Node;\r
175 ///\r
176 /// When LocalAddressIsIPv6 is TRUE, this points to the local IPv6 address and port\r
177 /// used by the underlying TCP protocol.\r
178 ///\r
179 EFI_HTTPv6_ACCESS_POINT *IPv6Node;\r
180 } AccessPoint;\r
181} EFI_HTTP_CONFIG_DATA;\r
182\r
183///\r
184/// EFI_HTTP_REQUEST_DATA\r
185///\r
186typedef struct {\r
187 ///\r
188 /// The HTTP method (e.g. GET, POST) for this HTTP Request.\r
189 ///\r
190 EFI_HTTP_METHOD Method;\r
191 ///\r
192 /// The URI of a remote host. From the information in this field, the HTTP instance\r
193 /// will be able to determine whether to use HTTP or HTTPS and will also be able to\r
194 /// determine the port number to use. If no port number is specified, port 80 (HTTP)\r
195 /// is assumed. See RFC 3986 for more details on URI syntax.\r
196 ///\r
197 CHAR16 *Url;\r
198} EFI_HTTP_REQUEST_DATA;\r
199\r
200///\r
201/// EFI_HTTP_RESPONSE_DATA\r
202///\r
203typedef struct {\r
204 ///\r
205 /// Response status code returned by the remote host.\r
206 ///\r
207 EFI_HTTP_STATUS_CODE StatusCode;\r
208} EFI_HTTP_RESPONSE_DATA;\r
209\r
210///\r
211/// EFI_HTTP_HEADER\r
212///\r
213typedef struct {\r
214 ///\r
215 /// Null terminated string which describes a field name. See RFC 2616 Section 14 for\r
216 /// detailed information about field names.\r
217 ///\r
218 CHAR8 *FieldName;\r
219 ///\r
220 /// Null terminated string which describes the corresponding field value. See RFC 2616\r
221 /// Section 14 for detailed information about field values.\r
222 ///\r
223 CHAR8 *FieldValue;\r
224} EFI_HTTP_HEADER;\r
225\r
226///\r
227/// EFI_HTTP_MESSAGE\r
228///\r
229typedef struct {\r
230 ///\r
231 /// HTTP message data.\r
232 ///\r
233 union {\r
234 ///\r
235 /// When the token is used to send a HTTP request, Request is a pointer to storage that\r
236 /// contains such data as URL and HTTP method.\r
237 ///\r
238 EFI_HTTP_REQUEST_DATA *Request;\r
239 ///\r
240 /// When used to await a response, Response points to storage containing HTTP response\r
241 /// status code.\r
242 ///\r
243 EFI_HTTP_RESPONSE_DATA *Response;\r
244 } Data;\r
245 ///\r
246 /// Number of HTTP header structures in Headers list. On request, this count is\r
247 /// provided by the caller. On response, this count is provided by the HTTP driver.\r
248 ///\r
249 UINTN HeaderCount;\r
250 ///\r
251 /// Array containing list of HTTP headers. On request, this array is populated by the\r
252 /// caller. On response, this array is allocated and populated by the HTTP driver. It\r
253 /// is the responsibility of the caller to free this memory on both request and\r
254 /// response.\r
255 ///\r
256 EFI_HTTP_HEADER *Headers;\r
257 ///\r
258 /// Length in bytes of the HTTP body. This can be zero depending on the HttpMethod type.\r
259 ///\r
260 UINTN BodyLength;\r
261 ///\r
262 /// Body associated with the HTTP request or response. This can be NULL depending on\r
263 /// the HttpMethod type.\r
264 ///\r
265 VOID *Body;\r
266} EFI_HTTP_MESSAGE;\r
267\r
268\r
269///\r
270/// EFI_HTTP_TOKEN\r
271///\r
272typedef struct {\r
273 ///\r
274 /// This Event will be signaled after the Status field is updated by the EFI HTTP\r
275 /// Protocol driver. The type of Event must be EFI_NOTIFY_SIGNAL. The Task Priority\r
276 /// Level (TPL) of Event must be lower than or equal to TPL_CALLBACK.\r
277 ///\r
278 EFI_EVENT Event;\r
279 ///\r
280 /// Status will be set to one of the following value if the HTTP request is\r
281 /// successfully sent or if an unexpected error occurs:\r
282 /// EFI_SUCCESS: The HTTP request was successfully sent to the remote host.\r
283 /// EFI_ABORTED: The HTTP request was cancelled by the caller and removed from\r
284 /// the transmit queue.\r
285 /// EFI_TIMEOUT: The HTTP request timed out before reaching the remote host.\r
286 /// EFI_DEVICE_ERROR: An unexpected system or network error occurred.\r
287 ///\r
288 EFI_STATUS Status;\r
289 ///\r
290 /// Pointer to storage containing HTTP message data.\r
291 ///\r
292 EFI_HTTP_MESSAGE *Message;\r
293} EFI_HTTP_TOKEN;\r
294\r
295/**\r
296 Returns the operational parameters for the current HTTP child instance.\r
297\r
298 The GetModeData() function is used to read the current mode data (operational\r
299 parameters) for this HTTP protocol instance.\r
300\r
301 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.\r
302 @param[out] HttpConfigData Point to buffer for operational parameters of this\r
303 HTTP instance.\r
304\r
305 @retval EFI_SUCCESS Operation succeeded.\r
306 @retval EFI_INVALID_PARAMETER This is NULL.\r
307**/\r
308typedef\r
309EFI_STATUS\r
310(EFIAPI * EFI_HTTP_GET_MODE_DATA)(\r
311 IN EFI_HTTP_PROTOCOL *This,\r
312 OUT EFI_HTTP_CONFIG_DATA *HttpConfigData\r
313 );\r
314\r
315/**\r
316 Initialize or brutally reset the operational parameters for this EFI HTTP instance.\r
317\r
318 The Configure() function does the following:\r
319 When HttpConfigData is not NULL Initialize this EFI HTTP instance by configuring\r
320 timeout, local address, port, etc.\r
321 When HttpConfigData is NULL, reset this EFI HTTP instance by closing all active\r
322 connections with remote hosts, canceling all asynchronous tokens, and flush request\r
323 and response buffers without informing the appropriate hosts.\r
324\r
325 Except for GetModeData() and Configure(), No other EFI HTTP function can be executed\r
326 by this instance until the Configure() function is executed and returns successfully.\r
327\r
328 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.\r
329 @param[in] HttpConfigData Pointer to the configure data to configure the instance.\r
330\r
331 @retval EFI_SUCCESS Operation succeeded.\r
332 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
333 This is NULL.\r
334 HttpConfigData->LocalAddressIsIPv6 is FALSE and\r
335 HttpConfigData->IPv4Node is NULL.\r
336 HttpConfigData->LocalAddressIsIPv6 is TRUE and\r
337 HttpConfigData->IPv6Node is NULL.\r
338 @retval EFI_ALREADY_STARTED Reinitialize this HTTP instance without calling\r
339 Configure() with NULL to reset it.\r
340 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
341 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources when\r
342 executing Configure().\r
343 @retval EFI_UNSUPPORTED One or more options in ConfigData are not supported\r
344 in the implementation.\r
345**/\r
346typedef\r
347EFI_STATUS\r
348(EFIAPI * EFI_HTTP_CONFIGURE)(\r
349 IN EFI_HTTP_PROTOCOL *This,\r
350 IN EFI_HTTP_CONFIG_DATA *HttpConfigData\r
351 );\r
352\r
353/**\r
354 The Request() function queues an HTTP request to this HTTP instance, \r
355 similar to Transmit() function in the EFI TCP driver. When the HTTP request is sent\r
356 successfully, or if there is an error, Status in token will be updated and Event will\r
357 be signaled.\r
358\r
359 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.\r
360 @param[in] Token Pointer to storage containing HTTP request token.\r
361\r
362 @retval EFI_SUCCESS Outgoing data was processed.\r
363 @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been started.\r
364 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
365 @retval EFI_TIMEOUT Data was dropped out of the transmit or receive queue.\r
366 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
367 This is NULL.\r
368 Token->Message is NULL.\r
369 Token->Message->Body is not NULL,\r
370 Token->Message->BodyLength is non-zero, and\r
371 Token->Message->Data is NULL, but a previous call to\r
372 Request()has not been completed successfully.\r
373**/\r
374typedef\r
375EFI_STATUS\r
376(EFIAPI *EFI_HTTP_REQUEST) (\r
377 IN EFI_HTTP_PROTOCOL *This,\r
378 IN EFI_HTTP_TOKEN *Token\r
379 );\r
380\r
381/**\r
382 Abort an asynchronous HTTP request or response token.\r
383\r
384 The Cancel() function aborts a pending HTTP request or response transaction. If\r
385 Token is not NULL and the token is in transmit or receive queues when it is being\r
386 cancelled, its Token->Status will be set to EFI_ABORTED and then Token->Event will\r
387 be signaled. If the token is not in one of the queues, which usually means that the\r
388 asynchronous operation has completed, EFI_NOT_FOUND is returned. If Token is NULL,\r
389 all asynchronous tokens issued by Request() or Response() will be aborted.\r
390\r
391 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.\r
392 @param[in] Token Point to storage containing HTTP request or response\r
393 token.\r
394\r
395 @retval EFI_SUCCESS Request and Response queues are successfully flushed.\r
396 @retval EFI_INVALID_PARAMETER This is NULL.\r
397 @retval EFI_NOT_STARTED This instance hasn't been configured.\r
398 @retval EFI_NO_MAPPING When using the default address, configuration (DHCP,\r
399 BOOTP, RARP, etc.) hasn't finished yet.\r
400 @retval EFI_NOT_FOUND The asynchronous request or response token is not\r
401 found.\r
402 @retval EFI_UNSUPPORTED The implementation does not support this function.\r
403**/\r
404typedef\r
405EFI_STATUS\r
406(EFIAPI *EFI_HTTP_CANCEL)(\r
407 IN EFI_HTTP_PROTOCOL *This,\r
408 IN EFI_HTTP_TOKEN *Token\r
409 );\r
410\r
411/**\r
412 The Response() function queues an HTTP response to this HTTP instance, similar to\r
413 Receive() function in the EFI TCP driver. When the HTTP request is sent successfully,\r
414 or if there is an error, Status in token will be updated and Event will be signaled.\r
415\r
416 The HTTP driver will queue a receive token to the underlying TCP instance. When data\r
417 is received in the underlying TCP instance, the data will be parsed and Token will\r
418 be populated with the response data. If the data received from the remote host\r
419 contains an incomplete or invalid HTTP header, the HTTP driver will continue waiting\r
420 (asynchronously) for more data to be sent from the remote host before signaling\r
421 Event in Token.\r
422\r
423 It is the responsibility of the caller to allocate a buffer for Body and specify the\r
424 size in BodyLength. If the remote host provides a response that contains a content\r
425 body, up to BodyLength bytes will be copied from the receive buffer into Body and\r
426 BodyLength will be updated with the amount of bytes received and copied to Body. This\r
427 allows the client to download a large file in chunks instead of into one contiguous\r
428 block of memory. Similar to HTTP request, if Body is not NULL and BodyLength is\r
429 non-zero and all other fields are NULL or 0, the HTTP driver will queue a receive\r
430 token to underlying TCP instance. If data arrives in the receive buffer, up to\r
431 BodyLength bytes of data will be copied to Body. The HTTP driver will then update\r
432 BodyLength with the amount of bytes received and copied to Body.\r
433\r
434 If the HTTP driver does not have an open underlying TCP connection with the host\r
435 specified in the response URL, Request() will return EFI_ACCESS_DENIED. This is\r
436 consistent with RFC 2616 recommendation that HTTP clients should attempt to maintain\r
437 an open TCP connection between client and host.\r
438\r
439 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.\r
440 @param[in] Token Pointer to storage containing HTTP response token.\r
441\r
442 @retval EFI_SUCCESS Allocation succeeded.\r
443 @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been\r
444 initialized.\r
445 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
446 This is NULL.\r
447 Token->Message->Headers is NULL.\r
448 Token->Message is NULL.\r
449 Token->Message->Body is not NULL,\r
450 Token->Message->BodyLength is non-zero, and\r
451 Token->Message->Data is NULL, but a previous call to\r
452 Response() has not been completed successfully.\r
453 @retval EFI_ACCESS_DENIED An open TCP connection is not present with the host\r
454 specified by response URL.\r
455**/\r
456typedef\r
457EFI_STATUS\r
458(EFIAPI *EFI_HTTP_RESPONSE) (\r
459 IN EFI_HTTP_PROTOCOL *This,\r
460 IN EFI_HTTP_TOKEN *Token\r
461 );\r
462\r
463/**\r
464 The Poll() function can be used by network drivers and applications to increase the\r
465 rate that data packets are moved between the communication devices and the transmit\r
466 and receive queues.\r
467\r
468 In some systems, the periodic timer event in the managed network driver may not poll\r
469 the underlying communications device fast enough to transmit and/or receive all data\r
470 packets without missing incoming packets or dropping outgoing packets. Drivers and\r
471 applications that are experiencing packet loss should try calling the Poll() function\r
472 more often.\r
473\r
474 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.\r
475\r
476 @retval EFI_SUCCESS Incoming or outgoing data was processed..\r
477 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred\r
478 @retval EFI_INVALID_PARAMETER This is NULL.\r
479 @retval EFI_NOT_READY No incoming or outgoing data is processed.\r
480**/\r
481typedef\r
482EFI_STATUS\r
483(EFIAPI *EFI_HTTP_POLL) (\r
484 IN EFI_HTTP_PROTOCOL *This\r
485 );\r
486\r
487///\r
488/// The EFI HTTP protocol is designed to be used by EFI drivers and applications to\r
489/// create and transmit HTTP Requests, as well as handle HTTP responses that are\r
490/// returned by a remote host. This EFI protocol uses and relies on an underlying EFI\r
491/// TCP protocol.\r
492///\r
493struct _EFI_HTTP_PROTOCOL {\r
494 EFI_HTTP_GET_MODE_DATA GetModeData;\r
495 EFI_HTTP_CONFIGURE Configure;\r
496 EFI_HTTP_REQUEST Request;\r
497 EFI_HTTP_CANCEL Cancel;\r
498 EFI_HTTP_RESPONSE Response;\r
499 EFI_HTTP_POLL Poll;\r
500};\r
501\r
502extern EFI_GUID gEfiHttpServiceBindingProtocolGuid;\r
503extern EFI_GUID gEfiHttpProtocolGuid;\r
504\r
505#endif\r