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