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