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