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