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