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