iPXE
Http.h
Go to the documentation of this file.
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 FILE_LICENCE ( BSD2_PATENT );
20 
21 #define EFI_HTTP_SERVICE_BINDING_PROTOCOL_GUID \
22  { \
23  0xbdc8e6af, 0xd9bc, 0x4379, {0xa7, 0x2a, 0xe0, 0xc4, 0xe7, 0x5d, 0xae, 0x1c } \
24  }
25 
26 #define EFI_HTTP_PROTOCOL_GUID \
27  { \
28  0x7a59b29b, 0x910b, 0x4171, {0x82, 0x42, 0xa8, 0x5a, 0x0d, 0xf2, 0x5b, 0x5b } \
29  }
30 
32 
33 ///
34 /// EFI_HTTP_VERSION
35 ///
36 typedef enum {
41 
42 ///
43 /// EFI_HTTP_METHOD
44 ///
45 typedef enum {
57 
58 ///
59 /// EFI_HTTP_STATUS_CODE
60 ///
61 typedef enum {
106 
107 ///
108 /// EFI_HTTPv4_ACCESS_POINT
109 ///
110 typedef struct {
111  ///
112  /// Set to TRUE to instruct the EFI HTTP instance to use the default address
113  /// information in every TCP connection made by this instance. In addition, when set
114  /// to TRUE, LocalAddress and LocalSubnet are ignored.
115  ///
117  ///
118  /// If UseDefaultAddress is set to FALSE, this defines the local IP address to be
119  /// used in every TCP connection opened by this instance.
120  ///
122  ///
123  /// If UseDefaultAddress is set to FALSE, this defines the local subnet to be used
124  /// in every TCP connection opened by this instance.
125  ///
127  ///
128  /// This defines the local port to be used in
129  /// every TCP connection opened by this instance.
130  ///
133 
134 ///
135 /// EFI_HTTPv6_ACCESS_POINT
136 ///
137 typedef struct {
138  ///
139  /// Local IP address to be used in every TCP connection opened by this instance.
140  ///
142  ///
143  /// Local port to be used in every TCP connection opened by this instance.
144  ///
147 
148 ///
149 /// EFI_HTTP_CONFIG_DATA_ACCESS_POINT
150 ///
151 
152 typedef struct {
153  ///
154  /// HTTP version that this instance will support.
155  ///
157  ///
158  /// Time out (in milliseconds) when blocking for requests.
159  ///
161  ///
162  /// Defines behavior of EFI DNS and TCP protocols consumed by this instance. If
163  /// FALSE, this instance will use EFI_DNS4_PROTOCOL and EFI_TCP4_PROTOCOL. If TRUE,
164  /// this instance will use EFI_DNS6_PROTOCOL and EFI_TCP6_PROTOCOL.
165  ///
167 
168  union {
169  ///
170  /// When LocalAddressIsIPv6 is FALSE, this points to the local address, subnet, and
171  /// port used by the underlying TCP protocol.
172  ///
174  ///
175  /// When LocalAddressIsIPv6 is TRUE, this points to the local IPv6 address and port
176  /// used by the underlying TCP protocol.
177  ///
179  } AccessPoint;
181 
182 ///
183 /// EFI_HTTP_REQUEST_DATA
184 ///
185 typedef struct {
186  ///
187  /// The HTTP method (e.g. GET, POST) for this HTTP Request.
188  ///
190  ///
191  /// The URI of a remote host. From the information in this field, the HTTP instance
192  /// will be able to determine whether to use HTTP or HTTPS and will also be able to
193  /// determine the port number to use. If no port number is specified, port 80 (HTTP)
194  /// or 443 (HTTPS) is assumed. See RFC 3986 for more details on URI syntax.
195  ///
198 
199 ///
200 /// EFI_HTTP_CONNECT_REQUEST_DATA
201 ///
202 typedef struct {
204  ///
205  /// The URI of an Proxy Host. This field will be NULL if there is no Proxy Host
206  /// in the device path. From the information in this field, the HTTP instance will
207  /// be able to determine whether to use HTTP or HTTPS and will also be able to
208  /// determine the port number to use. If no port number is specified, port 80 (HTTP)
209  /// or 443 (HTTPS) is assumed. See RFC 3986 for more details on URI syntax.
210  ///
213 
214 ///
215 /// EFI_HTTP_RESPONSE_DATA
216 ///
217 typedef struct {
218  ///
219  /// Response status code returned by the remote host.
220  ///
223 
224 ///
225 /// EFI_HTTP_HEADER
226 ///
227 typedef struct {
228  ///
229  /// Null terminated string which describes a field name. See RFC 2616 Section 14 for
230  /// detailed information about field names.
231  ///
233  ///
234  /// Null terminated string which describes the corresponding field value. See RFC 2616
235  /// Section 14 for detailed information about field values.
236  ///
239 
240 ///
241 /// EFI_HTTP_MESSAGE
242 ///
243 typedef struct {
244  ///
245  /// HTTP message data.
246  ///
247  union {
248  ///
249  /// When the token is used to send a HTTP request, Request is a pointer to storage that
250  /// contains such data as URL and HTTP method.
251  ///
253  ///
254  /// When used to await a response, Response points to storage containing HTTP response
255  /// status code.
256  ///
258  } Data;
259  ///
260  /// Number of HTTP header structures in Headers list. On request, this count is
261  /// provided by the caller. On response, this count is provided by the HTTP driver.
262  ///
264  ///
265  /// Array containing list of HTTP headers. On request, this array is populated by the
266  /// caller. On response, this array is allocated and populated by the HTTP driver. It
267  /// is the responsibility of the caller to free this memory on both request and
268  /// response.
269  ///
271  ///
272  /// Length in bytes of the HTTP body. This can be zero depending on the HttpMethod type.
273  ///
275  ///
276  /// Body associated with the HTTP request or response. This can be NULL depending on
277  /// the HttpMethod type.
278  ///
281 
282 ///
283 /// EFI_HTTP_TOKEN
284 ///
285 typedef struct {
286  ///
287  /// This Event will be signaled after the Status field is updated by the EFI HTTP
288  /// Protocol driver. The type of Event must be EFI_NOTIFY_SIGNAL. The Task Priority
289  /// Level (TPL) of Event must be lower than or equal to TPL_CALLBACK.
290  ///
292  ///
293  /// Status will be set to one of the following value if the HTTP request is
294  /// successfully sent or if an unexpected error occurs:
295  /// EFI_SUCCESS: The HTTP request was successfully sent to the remote host.
296  /// EFI_HTTP_ERROR: The response message was successfully received but contains a
297  /// HTTP error. The response status code is returned in token.
298  /// EFI_ABORTED: The HTTP request was cancelled by the caller and removed from
299  /// the transmit queue.
300  /// EFI_TIMEOUT: The HTTP request timed out before reaching the remote host.
301  /// EFI_DEVICE_ERROR: An unexpected system or network error occurred.
302  ///
304  ///
305  /// Pointer to storage containing HTTP message data.
306  ///
309 
310 /**
311  Returns the operational parameters for the current HTTP child instance.
312 
313  The GetModeData() function is used to read the current mode data (operational
314  parameters) for this HTTP protocol instance.
315 
316  @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.
317  @param[out] HttpConfigData Point to buffer for operational parameters of this
318  HTTP instance. It is the responsibility of the caller
319  to allocate the memory for HttpConfigData and
320  HttpConfigData->AccessPoint.IPv6Node/IPv4Node. In fact,
321  it is recommended to allocate sufficient memory to record
322  IPv6Node since it is big enough for all possibilities.
323 
324  @retval EFI_SUCCESS Operation succeeded.
325  @retval EFI_INVALID_PARAMETER This is NULL.
326  HttpConfigData is NULL.
327  HttpConfigData->AccessPoint.IPv4Node or
328  HttpConfigData->AccessPoint.IPv6Node is NULL.
329  @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been started.
330 **/
331 typedef
334  IN EFI_HTTP_PROTOCOL *This,
335  OUT EFI_HTTP_CONFIG_DATA *HttpConfigData
336  );
337 
338 /**
339  Initialize or brutally reset the operational parameters for this EFI HTTP instance.
340 
341  The Configure() function does the following:
342  When HttpConfigData is not NULL Initialize this EFI HTTP instance by configuring
343  timeout, local address, port, etc.
344  When HttpConfigData is NULL, reset this EFI HTTP instance by closing all active
345  connections with remote hosts, canceling all asynchronous tokens, and flush request
346  and response buffers without informing the appropriate hosts.
347 
348  No other EFI HTTP function can be executed by this instance until the Configure()
349  function is executed and returns successfully.
350 
351  @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.
352  @param[in] HttpConfigData Pointer to the configure data to configure the instance.
353 
354  @retval EFI_SUCCESS Operation succeeded.
355  @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
356  This is NULL.
357  HttpConfigData->LocalAddressIsIPv6 is FALSE and
358  HttpConfigData->AccessPoint.IPv4Node is NULL.
359  HttpConfigData->LocalAddressIsIPv6 is TRUE and
360  HttpConfigData->AccessPoint.IPv6Node is NULL.
361  @retval EFI_ALREADY_STARTED Reinitialize this HTTP instance without calling
362  Configure() with NULL to reset it.
363  @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
364  @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources when
365  executing Configure().
366  @retval EFI_UNSUPPORTED One or more options in ConfigData are not supported
367  in the implementation.
368 **/
369 typedef
372  IN EFI_HTTP_PROTOCOL *This,
373  IN EFI_HTTP_CONFIG_DATA *HttpConfigData OPTIONAL
374  );
375 
376 /**
377  The Request() function queues an HTTP request to this HTTP instance,
378  similar to Transmit() function in the EFI TCP driver. When the HTTP request is sent
379  successfully, or if there is an error, Status in token will be updated and Event will
380  be signaled.
381 
382  @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.
383  @param[in] Token Pointer to storage containing HTTP request token.
384 
385  @retval EFI_SUCCESS Outgoing data was processed.
386  @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been started.
387  @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
388  @retval EFI_TIMEOUT Data was dropped out of the transmit or receive queue.
389  @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
390  This is NULL.
391  Token is NULL.
392  Token->Message is NULL.
393  Token->Message->Body is not NULL,
394  Token->Message->BodyLength is non-zero, and
395  Token->Message->Data is NULL, but a previous call to
396  Request()has not been completed successfully.
397  @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources.
398  @retval EFI_UNSUPPORTED The HTTP method is not supported in current implementation.
399 **/
400 typedef
403  IN EFI_HTTP_PROTOCOL *This,
404  IN EFI_HTTP_TOKEN *Token
405  );
406 
407 /**
408  Abort an asynchronous HTTP request or response token.
409 
410  The Cancel() function aborts a pending HTTP request or response transaction. If
411  Token is not NULL and the token is in transmit or receive queues when it is being
412  cancelled, its Token->Status will be set to EFI_ABORTED and then Token->Event will
413  be signaled. If the token is not in one of the queues, which usually means that the
414  asynchronous operation has completed, EFI_NOT_FOUND is returned. If Token is NULL,
415  all asynchronous tokens issued by Request() or Response() will be aborted.
416 
417  @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.
418  @param[in] Token Point to storage containing HTTP request or response
419  token.
420 
421  @retval EFI_SUCCESS Request and Response queues are successfully flushed.
422  @retval EFI_INVALID_PARAMETER This is NULL.
423  @retval EFI_NOT_STARTED This instance hasn't been configured.
424  @retval EFI_NOT_FOUND The asynchronous request or response token is not
425  found.
426  @retval EFI_UNSUPPORTED The implementation does not support this function.
427 **/
428 typedef
431  IN EFI_HTTP_PROTOCOL *This,
432  IN EFI_HTTP_TOKEN *Token
433  );
434 
435 /**
436  The Response() function queues an HTTP response to this HTTP instance, similar to
437  Receive() function in the EFI TCP driver. When the HTTP Response is received successfully,
438  or if there is an error, Status in token will be updated and Event will be signaled.
439 
440  The HTTP driver will queue a receive token to the underlying TCP instance. When data
441  is received in the underlying TCP instance, the data will be parsed and Token will
442  be populated with the response data. If the data received from the remote host
443  contains an incomplete or invalid HTTP header, the HTTP driver will continue waiting
444  (asynchronously) for more data to be sent from the remote host before signaling
445  Event in Token.
446 
447  It is the responsibility of the caller to allocate a buffer for Body and specify the
448  size in BodyLength. If the remote host provides a response that contains a content
449  body, up to BodyLength bytes will be copied from the receive buffer into Body and
450  BodyLength will be updated with the amount of bytes received and copied to Body. This
451  allows the client to download a large file in chunks instead of into one contiguous
452  block of memory. Similar to HTTP request, if Body is not NULL and BodyLength is
453  non-zero and all other fields are NULL or 0, the HTTP driver will queue a receive
454  token to underlying TCP instance. If data arrives in the receive buffer, up to
455  BodyLength bytes of data will be copied to Body. The HTTP driver will then update
456  BodyLength with the amount of bytes received and copied to Body.
457 
458  If the HTTP driver does not have an open underlying TCP connection with the host
459  specified in the response URL, Request() will return EFI_ACCESS_DENIED. This is
460  consistent with RFC 2616 recommendation that HTTP clients should attempt to maintain
461  an open TCP connection between client and host.
462 
463  @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.
464  @param[in] Token Pointer to storage containing HTTP response token.
465 
466  @retval EFI_SUCCESS Allocation succeeded.
467  @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been
468  initialized.
469  @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
470  This is NULL.
471  Token is NULL.
472  Token->Message->Headers is NULL.
473  Token->Message is NULL.
474  Token->Message->Body is not NULL,
475  Token->Message->BodyLength is non-zero, and
476  Token->Message->Data is NULL, but a previous call to
477  Response() has not been completed successfully.
478  @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources.
479  @retval EFI_ACCESS_DENIED An open TCP connection is not present with the host
480  specified by response URL.
481 **/
482 typedef
485  IN EFI_HTTP_PROTOCOL *This,
486  IN EFI_HTTP_TOKEN *Token
487  );
488 
489 /**
490  The Poll() function can be used by network drivers and applications to increase the
491  rate that data packets are moved between the communication devices and the transmit
492  and receive queues.
493 
494  In some systems, the periodic timer event in the managed network driver may not poll
495  the underlying communications device fast enough to transmit and/or receive all data
496  packets without missing incoming packets or dropping outgoing packets. Drivers and
497  applications that are experiencing packet loss should try calling the Poll() function
498  more often.
499 
500  @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.
501 
502  @retval EFI_SUCCESS Incoming or outgoing data was processed..
503  @retval EFI_DEVICE_ERROR An unexpected system or network error occurred
504  @retval EFI_INVALID_PARAMETER This is NULL.
505  @retval EFI_NOT_READY No incoming or outgoing data is processed.
506  @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been started.
507 **/
508 typedef
511  IN EFI_HTTP_PROTOCOL *This
512  );
513 
514 ///
515 /// The EFI HTTP protocol is designed to be used by EFI drivers and applications to
516 /// create and transmit HTTP Requests, as well as handle HTTP responses that are
517 /// returned by a remote host. This EFI protocol uses and relies on an underlying EFI
518 /// TCP protocol.
519 ///
527 };
528 
531 
532 #endif
EFI_STATUS(EFIAPI * EFI_HTTP_RESPONSE)(IN EFI_HTTP_PROTOCOL *This, IN EFI_HTTP_TOKEN *Token)
The Response() function queues an HTTP response to this HTTP instance, similar to Receive() function ...
Definition: Http.h:484
#define OPTIONAL
Passing the datum to the function is optional, and a NULL is passed if the value is not supplied.
Definition: Base.h:292
BOOLEAN UseDefaultAddress
Set to TRUE to instruct the EFI HTTP instance to use the default address information in every TCP con...
Definition: Http.h:116
EFI_HTTPv4_ACCESS_POINT * IPv4Node
When LocalAddressIsIPv6 is FALSE, this points to the local address, subnet, and port used by the unde...
Definition: Http.h:173
UINT16 LocalPort
This defines the local port to be used in every TCP connection opened by this instance.
Definition: Http.h:131
EFI_HTTP_REQUEST_DATA * Request
When the token is used to send a HTTP request, Request is a pointer to storage that contains such dat...
Definition: Http.h:252
128 bit buffer containing a unique identifier value.
Definition: Base.h:215
Definition: efi.h:62
unsigned char BOOLEAN
EFI_IPv4_ADDRESS LocalSubnet
If UseDefaultAddress is set to FALSE, this defines the local subnet to be used in every TCP connectio...
Definition: Http.h:126
EFI_HTTP_VERSION
EFI_HTTP_VERSION.
Definition: Http.h:36
CHAR8 * FieldValue
Null terminated string which describes the corresponding field value.
Definition: Http.h:237
EFI_HTTP_REQUEST_DATA.
Definition: Http.h:185
unsigned int UINT32
Definition: ProcessorBind.h:98
EFI_HTTP_REQUEST Request
Definition: Http.h:523
CHAR8 * FieldName
Null terminated string which describes a field name.
Definition: Http.h:232
unsigned short CHAR16
EFI_HTTP_REQUEST_DATA Base
Definition: Http.h:203
The EFI HTTP protocol is designed to be used by EFI drivers and applications to create and transmit H...
Definition: Http.h:520
EFI_IPv6_ADDRESS LocalAddress
Local IP address to be used in every TCP connection opened by this instance.
Definition: Http.h:141
EFI_HTTP_POLL Poll
Definition: Http.h:526
FILE_LICENCE(BSD2_PATENT)
EFI_STATUS(EFIAPI * EFI_HTTP_REQUEST)(IN EFI_HTTP_PROTOCOL *This, IN EFI_HTTP_TOKEN *Token)
The Request() function queues an HTTP request to this HTTP instance, similar to Transmit() function i...
Definition: Http.h:402
EFI_HTTP_HEADER.
Definition: Http.h:227
EFI_HTTP_TOKEN.
Definition: Http.h:285
#define OUT
Definition: mlx_utils.h:29
CHAR16 * Url
The URI of a remote host.
Definition: Http.h:196
16-byte buffer.
Definition: Base.h:232
EFI_HTTP_STATUS_CODE
EFI_HTTP_STATUS_CODE.
Definition: Http.h:61
EFI_STATUS(EFIAPI * EFI_HTTP_CONFIGURE)(IN EFI_HTTP_PROTOCOL *This, IN EFI_HTTP_CONFIG_DATA *HttpConfigData OPTIONAL)
Initialize or brutally reset the operational parameters for this EFI HTTP instance.
Definition: Http.h:371
EFI_GUID gEfiHttpProtocolGuid
4-byte buffer.
Definition: Base.h:225
EFI_HTTP_GET_MODE_DATA GetModeData
Definition: Http.h:521
unsigned short UINT16
EFI_STATUS(EFIAPI * EFI_HTTP_GET_MODE_DATA)(IN EFI_HTTP_PROTOCOL *This, OUT EFI_HTTP_CONFIG_DATA *HttpConfigData)
Returns the operational parameters for the current HTTP child instance.
Definition: Http.h:333
EFI_HTTP_STATUS_CODE StatusCode
Response status code returned by the remote host.
Definition: Http.h:221
#define EFIAPI
UINT16 LocalPort
Local port to be used in every TCP connection opened by this instance.
Definition: Http.h:145
EFI_HTTP_RESPONSE_DATA * Response
When used to await a response, Response points to storage containing HTTP response status code.
Definition: Http.h:257
EFI_HTTP_CONFIG_DATA_ACCESS_POINT.
Definition: Http.h:152
UINTN BodyLength
Length in bytes of the HTTP body.
Definition: Http.h:274
EFI_STATUS Status
Status will be set to one of the following value if the HTTP request is successfully sent or if an un...
Definition: Http.h:303
EFI_EVENT Event
This Event will be signaled after the Status field is updated by the EFI HTTP Protocol driver.
Definition: Http.h:291
UINT64 UINTN
Unsigned value of native width.
EFI_HTTP_CANCEL Cancel
Definition: Http.h:524
EFI_HTTP_RESPONSE_DATA.
Definition: Http.h:217
#define VOID
Undeclared type.
Definition: Base.h:271
EFI_HTTP_METHOD
EFI_HTTP_METHOD.
Definition: Http.h:45
EFI_IPv4_ADDRESS LocalAddress
If UseDefaultAddress is set to FALSE, this defines the local IP address to be used in every TCP conne...
Definition: Http.h:121
BOOLEAN LocalAddressIsIPv6
Defines behavior of EFI DNS and TCP protocols consumed by this instance.
Definition: Http.h:166
#define IN
Definition: mlx_utils.h:28
EFI_HTTP_RESPONSE Response
Definition: Http.h:525
EFI_HTTPv6_ACCESS_POINT.
Definition: Http.h:137
EFI_HTTP_MESSAGE.
Definition: Http.h:243
char CHAR8
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:31
EFI_HTTP_CONNECT_REQUEST_DATA.
Definition: Http.h:202
EFI_HTTPv4_ACCESS_POINT.
Definition: Http.h:110
EFI_HTTP_MESSAGE * Message
Pointer to storage containing HTTP message data.
Definition: Http.h:307
EFI_HTTPv6_ACCESS_POINT * IPv6Node
When LocalAddressIsIPv6 is TRUE, this points to the local IPv6 address and port used by the underlyin...
Definition: Http.h:178
EFI_HTTP_CONFIGURE Configure
Definition: Http.h:522
EFI_HTTP_HEADER * Headers
Array containing list of HTTP headers.
Definition: Http.h:270
EFI_HTTP_VERSION HttpVersion
HTTP version that this instance will support.
Definition: Http.h:156
EFI_STATUS(EFIAPI * EFI_HTTP_CANCEL)(IN EFI_HTTP_PROTOCOL *This, IN EFI_HTTP_TOKEN *Token)
Abort an asynchronous HTTP request or response token.
Definition: Http.h:430
EFI_STATUS(EFIAPI * EFI_HTTP_POLL)(IN EFI_HTTP_PROTOCOL *This)
The Poll() function can be used by network drivers and applications to increase the rate that data pa...
Definition: Http.h:510
UINTN HeaderCount
Number of HTTP header structures in Headers list.
Definition: Http.h:263
CHAR16 * ProxyUrl
The URI of an Proxy Host.
Definition: Http.h:211
VOID * Body
Body associated with the HTTP request or response.
Definition: Http.h:279
EFI_GUID gEfiHttpServiceBindingProtocolGuid
UINT32 TimeOutMillisec
Time out (in milliseconds) when blocking for requests.
Definition: Http.h:160
EFI_HTTP_METHOD Method
The HTTP method (e.g.
Definition: Http.h:189