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