]> git.proxmox.com Git - mirror_edk2.git/blob - NetworkPkg/HttpDxe/HttpImpl.h
NetworkPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / NetworkPkg / HttpDxe / HttpImpl.h
1 /** @file
2 The header files of implementation of EFI_HTTP_PROTOCOL protocol interfaces.
3
4 Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>
5 (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
6
7 SPDX-License-Identifier: BSD-2-Clause-Patent
8
9 **/
10
11 #ifndef __EFI_HTTP_IMPL_H__
12 #define __EFI_HTTP_IMPL_H__
13
14 #define HTTP_DEFAULT_PORT 80
15 #define HTTP_END_OF_HDR_STR "\r\n\r\n"
16 #define HTTP_CRLF_STR "\r\n"
17 #define HTTP_VERSION_STR HTTP_VERSION
18 #define HTTP_VERSION_CRLF_STR " HTTP/1.1\r\n"
19 #define HTTP_ERROR_OR_NOT_SUPPORT_STATUS_CODE 300
20
21
22 /**
23 Returns the operational parameters for the current HTTP child instance.
24
25 The GetModeData() function is used to read the current mode data (operational
26 parameters) for this HTTP protocol instance.
27
28 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.
29 @param[out] HttpConfigData Point to buffer for operational parameters of this
30 HTTP instance. It is the responsibility of the caller
31 to allocate the memory for HttpConfigData and
32 HttpConfigData->AccessPoint.IPv6Node/IPv4Node. In fact,
33 it is recommended to allocate sufficient memory to record
34 IPv6Node since it is big enough for all possibilities.
35
36 @retval EFI_SUCCESS Operation succeeded.
37 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
38 This is NULL.
39 HttpConfigData is NULL.
40 HttpConfigData->AccessPoint.IPv4Node or
41 HttpConfigData->AccessPoint.IPv6Node is NULL.
42 @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been started.
43
44 **/
45 EFI_STATUS
46 EFIAPI
47 EfiHttpGetModeData (
48 IN EFI_HTTP_PROTOCOL *This,
49 OUT EFI_HTTP_CONFIG_DATA *HttpConfigData
50 );
51
52 /**
53 Initialize or brutally reset the operational parameters for this EFI HTTP instance.
54
55 The Configure() function does the following:
56 When HttpConfigData is not NULL Initialize this EFI HTTP instance by configuring
57 timeout, local address, port, etc.
58 When HttpConfigData is NULL, reset this EFI HTTP instance by closing all active
59 connections with remote hosts, canceling all asynchronous tokens, and flush request
60 and response buffers without informing the appropriate hosts.
61
62 No other EFI HTTP function can be executed by this instance until the Configure()
63 function is executed and returns successfully.
64
65 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.
66 @param[in] HttpConfigData Pointer to the configure data to configure the instance.
67
68 @retval EFI_SUCCESS Operation succeeded.
69 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
70 This is NULL.
71 HttpConfigData->LocalAddressIsIPv6 is FALSE and
72 HttpConfigData->AccessPoint.IPv4Node is NULL.
73 HttpConfigData->LocalAddressIsIPv6 is TRUE and
74 HttpConfigData->AccessPoint.IPv6Node is NULL.
75 @retval EFI_ALREADY_STARTED Reinitialize this HTTP instance without calling
76 Configure() with NULL to reset it.
77 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
78 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources when
79 executing Configure().
80 @retval EFI_UNSUPPORTED One or more options in ConfigData are not supported
81 in the implementation.
82 **/
83 EFI_STATUS
84 EFIAPI
85 EfiHttpConfigure (
86 IN EFI_HTTP_PROTOCOL *This,
87 IN EFI_HTTP_CONFIG_DATA *HttpConfigData
88 );
89
90 /**
91 The Request() function queues an HTTP request to this HTTP instance.
92
93 Similar to Transmit() function in the EFI TCP driver. When the HTTP request is sent
94 successfully, or if there is an error, Status in token will be updated and Event will
95 be signaled.
96
97 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.
98 @param[in] Token Pointer to storage containing HTTP request token.
99
100 @retval EFI_SUCCESS Outgoing data was processed.
101 @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been started.
102 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
103 @retval EFI_TIMEOUT Data was dropped out of the transmit or receive queue.
104 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources.
105 @retval EFI_UNSUPPORTED The HTTP method is not supported in current
106 implementation.
107 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
108 This is NULL.
109 Token is NULL.
110 Token->Message is NULL.
111 Token->Message->Body is not NULL,
112 Token->Message->BodyLength is non-zero, and
113 Token->Message->Data is NULL, but a previous call to
114 Request()has not been completed successfully.
115 **/
116 EFI_STATUS
117 EFIAPI
118 EfiHttpRequest (
119 IN EFI_HTTP_PROTOCOL *This,
120 IN EFI_HTTP_TOKEN *Token
121 );
122
123 /**
124 Abort an asynchronous HTTP request or response token.
125
126 The Cancel() function aborts a pending HTTP request or response transaction. If
127 Token is not NULL and the token is in transmit or receive queues when it is being
128 cancelled, its Token->Status will be set to EFI_ABORTED and then Token->Event will
129 be signaled. If the token is not in one of the queues, which usually means that the
130 asynchronous operation has completed, EFI_NOT_FOUND is returned. If Token is NULL,
131 all asynchronous tokens issued by Request() or Response() will be aborted.
132
133 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.
134 @param[in] Token Point to storage containing HTTP request or response
135 token.
136
137 @retval EFI_SUCCESS Request and Response queues are successfully flushed.
138 @retval EFI_INVALID_PARAMETER This is NULL.
139 @retval EFI_NOT_STARTED This instance hasn't been configured.
140 @retval EFI_NOT_FOUND The asynchronous request or response token is not
141 found.
142 @retval EFI_UNSUPPORTED The implementation does not support this function.
143 **/
144 EFI_STATUS
145 EFIAPI
146 EfiHttpCancel (
147 IN EFI_HTTP_PROTOCOL *This,
148 IN EFI_HTTP_TOKEN *Token
149 );
150
151 /**
152 The Response() function queues an HTTP response to this HTTP instance, similar to
153 Receive() function in the EFI TCP driver. When the HTTP response is received successfully,
154 or if there is an error, Status in token will be updated and Event will be signaled.
155
156 The HTTP driver will queue a receive token to the underlying TCP instance. When data
157 is received in the underlying TCP instance, the data will be parsed and Token will
158 be populated with the response data. If the data received from the remote host
159 contains an incomplete or invalid HTTP header, the HTTP driver will continue waiting
160 (asynchronously) for more data to be sent from the remote host before signaling
161 Event in Token.
162
163 It is the responsibility of the caller to allocate a buffer for Body and specify the
164 size in BodyLength. If the remote host provides a response that contains a content
165 body, up to BodyLength bytes will be copied from the receive buffer into Body and
166 BodyLength will be updated with the amount of bytes received and copied to Body. This
167 allows the client to download a large file in chunks instead of into one contiguous
168 block of memory. Similar to HTTP request, if Body is not NULL and BodyLength is
169 non-zero and all other fields are NULL or 0, the HTTP driver will queue a receive
170 token to underlying TCP instance. If data arrives in the receive buffer, up to
171 BodyLength bytes of data will be copied to Body. The HTTP driver will then update
172 BodyLength with the amount of bytes received and copied to Body.
173
174 If the HTTP driver does not have an open underlying TCP connection with the host
175 specified in the response URL, Request() will return EFI_ACCESS_DENIED. This is
176 consistent with RFC 2616 recommendation that HTTP clients should attempt to maintain
177 an open TCP connection between client and host.
178
179 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.
180 @param[in] Token Pointer to storage containing HTTP response token.
181
182 @retval EFI_SUCCESS Allocation succeeded.
183 @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been
184 initialized.
185 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
186 This is NULL.
187 Token is NULL.
188 Token->Message->Headers is NULL.
189 Token->Message is NULL.
190 Token->Message->Body is not NULL,
191 Token->Message->BodyLength is non-zero, and
192 Token->Message->Data is NULL, but a previous call to
193 Response() has not been completed successfully.
194 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources.
195 @retval EFI_ACCESS_DENIED An open TCP connection is not present with the host
196 specified by response URL.
197 **/
198 EFI_STATUS
199 EFIAPI
200 EfiHttpResponse (
201 IN EFI_HTTP_PROTOCOL *This,
202 IN EFI_HTTP_TOKEN *Token
203 );
204
205 /**
206 The Poll() function can be used by network drivers and applications to increase the
207 rate that data packets are moved between the communication devices and the transmit
208 and receive queues.
209
210 In some systems, the periodic timer event in the managed network driver may not poll
211 the underlying communications device fast enough to transmit and/or receive all data
212 packets without missing incoming packets or dropping outgoing packets. Drivers and
213 applications that are experiencing packet loss should try calling the Poll() function
214 more often.
215
216 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.
217
218 @retval EFI_SUCCESS Incoming or outgoing data was processed.
219 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
220 @retval EFI_INVALID_PARAMETER This is NULL.
221 @retval EFI_NOT_READY No incoming or outgoing data is processed.
222 @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been started.
223
224 **/
225 EFI_STATUS
226 EFIAPI
227 EfiHttpPoll (
228 IN EFI_HTTP_PROTOCOL *This
229 );
230
231 extern EFI_HTTP_PROTOCOL mEfiHttpTemplate;
232
233 #endif