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