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