2 The header files of miscellaneous routines for HttpDxe driver.
4 Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #ifndef __EFI_HTTP_PROTO_H__
16 #define __EFI_HTTP_PROTO_H__
18 #define DEF_BUF_LEN 2048
20 #define HTTP_SERVICE_SIGNATURE SIGNATURE_32('H', 't', 't', 'S')
22 #define HTTP_SERVICE_FROM_PROTOCOL(a) \
27 HTTP_SERVICE_SIGNATURE \
31 // The state of HTTP protocol. It starts from UNCONFIGED.
33 #define HTTP_STATE_UNCONFIGED 0
34 #define HTTP_STATE_HTTP_CONFIGED 1
35 #define HTTP_STATE_TCP_CONFIGED 2
36 #define HTTP_STATE_TCP_UNCONFIGED 3
37 #define HTTP_STATE_TCP_CONNECTED 4
38 #define HTTP_STATE_TCP_CLOSED 5
41 // TCP configured data.
43 #define HTTP_TOS_DEAULT 8
44 #define HTTP_TTL_DEAULT 255
45 #define HTTP_BUFFER_SIZE_DEAULT 65535
46 #define HTTP_MAX_SYN_BACK_LOG 5
47 #define HTTP_CONNECTION_TIMEOUT 60
48 #define HTTP_DATA_RETRIES 12
49 #define HTTP_FIN_TIMEOUT 2
50 #define HTTP_KEEP_ALIVE_PROBES 6
51 #define HTTP_KEEP_ALIVE_TIME 7200
52 #define HTTP_KEEP_ALIVE_INTERVAL 30
54 typedef struct _HTTP_SERVICE
{
56 EFI_SERVICE_BINDING_PROTOCOL ServiceBinding
;
57 EFI_HANDLE ImageHandle
;
58 EFI_HANDLE ControllerHandle
;
59 LIST_ENTRY ChildrenList
;
61 EFI_HANDLE TcpChildHandle
;
66 EFI_TCP4_IO_TOKEN TxToken
;
67 EFI_TCP4_TRANSMIT_DATA TxData
;
69 EFI_TCP4_IO_TOKEN RxToken
;
70 EFI_TCP4_RECEIVE_DATA RxData
;
73 EFI_HTTP_METHOD Method
;
74 } HTTP_TCP_TOKEN_WRAP
;
76 typedef struct _HTTP_PROTOCOL
{
78 EFI_HTTP_PROTOCOL Http
;
80 HTTP_SERVICE
*Service
;
81 LIST_ENTRY Link
; // Link to all HTTP instance from the service.
85 EFI_HANDLE TcpChildHandle
;
86 EFI_TCP4_PROTOCOL
*Tcp4
;
87 EFI_TCP4_CONFIG_DATA Tcp4CfgData
;
88 EFI_TCP4_OPTION Tcp4Option
;
90 EFI_TCP4_CONNECTION_TOKEN ConnToken
;
92 EFI_TCP4_CLOSE_TOKEN CloseToken
;
97 EFI_IPv4_ADDRESS RemoteAddr
;
99 // RxToken used for receiving HTTP header.
101 EFI_TCP4_IO_TOKEN RxToken
;
102 EFI_TCP4_RECEIVE_DATA RxData
;
111 // HTTP message-body parser.
115 EFI_HTTP_VERSION HttpVersion
;
116 UINT32 TimeOutMillisec
;
117 BOOLEAN LocalAddressIsIPv6
;
119 EFI_HTTPv4_ACCESS_POINT IPv4Node
;
126 EFI_HTTP_TOKEN
*HttpToken
;
127 HTTP_PROTOCOL
*HttpInstance
;
128 HTTP_TCP_TOKEN_WRAP TcpWrap
;
132 #define HTTP_PROTOCOL_SIGNATURE SIGNATURE_32('H', 't', 't', 'P')
134 #define HTTP_INSTANCE_FROM_PROTOCOL(a) \
139 HTTP_PROTOCOL_SIGNATURE \
143 The common notify function used in HTTP driver.
145 @param[in] Event The event signaled.
146 @param[in] Context The context.
157 Create events for the TCP4 connection token and TCP4 close token.
159 @param[in] HttpInstance Pointer to HTTP_PROTOCOL structure.
161 @retval EFI_SUCCESS The events are created successfully.
162 @retval others Other error as indicated.
166 HttpCreateTcp4ConnCloseEvent (
167 IN HTTP_PROTOCOL
*HttpInstance
171 Close events in the TCP4 connection token and TCP4 close token.
173 @param[in] HttpInstance Pointer to HTTP_PROTOCOL structure.
177 HttpCloseTcp4ConnCloseEvent (
178 IN HTTP_PROTOCOL
*HttpInstance
182 Create event for the TCP4 transmit token.
184 @param[in] Wrap Point to HTTP token's wrap data.
186 @retval EFI_SUCCESS The events is created successfully.
187 @retval others Other error as indicated.
191 HttpCreateTcp4TxEvent (
192 IN HTTP_TOKEN_WRAP
*Wrap
196 Create event for the TCP4 receive token which is used to receive HTTP header.
198 @param[in] HttpInstance Pointer to HTTP_PROTOCOL structure.
200 @retval EFI_SUCCESS The events is created successfully.
201 @retval others Other error as indicated.
205 HttpCreateTcp4RxEventForHeader (
206 IN HTTP_PROTOCOL
*HttpInstance
210 Create event for the TCP4 receive token which is used to receive HTTP body.
212 @param[in] Wrap Point to HTTP token's wrap data.
214 @retval EFI_SUCCESS The events is created successfully.
215 @retval others Other error as indicated.
219 HttpCreateTcp4RxEvent (
220 IN HTTP_TOKEN_WRAP
*Wrap
224 Intiialize the HTTP_PROTOCOL structure to the unconfigured state.
226 @param[in] HttpSb The HTTP service private instance.
227 @param[in, out] HttpInstance Pointer to HTTP_PROTOCOL structure.
229 @retval EFI_SUCCESS HTTP_PROTOCOL structure is initialized successfully.
230 @retval Others Other error as indicated.
235 IN HTTP_SERVICE
*HttpSb
,
236 IN OUT HTTP_PROTOCOL
*HttpInstance
240 Clean up the HTTP child, release all the resources used by it.
242 @param[in] HttpInstance The HTTP child to clean up.
247 IN HTTP_PROTOCOL
*HttpInstance
251 Establish TCP connection with HTTP server.
253 @param[in] HttpInstance The HTTP instance private data.
255 @retval EFI_SUCCESS The TCP connection is established.
256 @retval Others Other error as indicated.
260 HttpCreateConnection (
261 IN HTTP_PROTOCOL
*HttpInstance
265 Close existing TCP connection.
267 @param[in] HttpInstance The HTTP instance private data.
269 @retval EFI_SUCCESS The TCP connection is closed.
270 @retval Others Other error as indicated.
274 HttpCloseConnection (
275 IN HTTP_PROTOCOL
*HttpInstance
279 Configure TCP4 protocol child.
281 @param[in] HttpInstance The HTTP instance private data.
282 @param[in] Wrap The HTTP token's wrap data.
284 @retval EFI_SUCCESS The TCP4 protocol child is configured.
285 @retval Others Other error as indicated.
290 IN HTTP_PROTOCOL
*HttpInstance
,
291 IN HTTP_TOKEN_WRAP
*Wrap
295 Check existing TCP connection, if in error state, receover TCP4 connection.
297 @param[in] HttpInstance The HTTP instance private data.
299 @retval EFI_SUCCESS The TCP connection is established.
300 @retval EFI_NOT_READY TCP4 protocol child is not created or configured.
301 @retval Others Other error as indicated.
306 IN HTTP_PROTOCOL
*HttpInstance
310 Send the HTTP message through TCP4.
312 @param[in] HttpInstance The HTTP instance private data.
313 @param[in] Wrap The HTTP token's wrap data.
314 @param[in] TxString Buffer containing the HTTP message string.
315 @param[in] TxStringLen Length of the HTTP message string in bytes.
317 @retval EFI_SUCCESS The HTTP message is queued into TCP transmit queue.
318 @retval Others Other error as indicated.
323 IN HTTP_PROTOCOL
*HttpInstance
,
324 IN HTTP_TOKEN_WRAP
*Wrap
,
330 Translate the status code in HTTP message to EFI_HTTP_STATUS_CODE defined
331 in UEFI 2.5 specification.
333 @param[in] StatusCode The status code value in HTTP message.
335 @return Value defined in EFI_HTTP_STATUS_CODE .
339 HttpMappingToStatusCode (
344 Check whether the user's token or event has already
345 been enqueue on HTTP TxToken or RxToken list.
347 @param[in] Map The container of either user's transmit or receive
349 @param[in] Item Current item to check against.
350 @param[in] Context The Token to check againist.
352 @retval EFI_ACCESS_DENIED The token or event has already been enqueued in IP
353 @retval EFI_SUCCESS The current item isn't the same token/event as the
361 IN NET_MAP_ITEM
*Item
,
366 Check whether the HTTP message associated with TxToken is already sent out.
368 @param[in] Map The container of TxToken.
369 @param[in] Item Current item to check against.
370 @param[in] Context The Token to check againist.
372 @retval EFI_NOT_READY The HTTP message is still queued in the list.
373 @retval EFI_SUCCESS The HTTP message has been sent out.
380 IN NET_MAP_ITEM
*Item
,
385 Transmit the HTTP mssage by processing the associated HTTP token.
387 @param[in] Map The container of TxToken.
388 @param[in] Item Current item to check against.
389 @param[in] Context The Token to check againist.
391 @retval EFI_OUT_OF_RESOURCES Failed to allocate resources.
392 @retval EFI_SUCCESS The HTTP message is queued into TCP transmit
400 IN NET_MAP_ITEM
*Item
,
405 Receive the HTTP response by processing the associated HTTP token.
407 @param[in] Map The container of RxToken.
408 @param[in] Item Current item to check against.
409 @param[in] Context The Token to check againist.
411 @retval EFI_SUCCESS The HTTP response is queued into TCP receive
413 @retval Others Other error as indicated.
420 IN NET_MAP_ITEM
*Item
,
425 Generate HTTP request string.
427 @param[in] HttpInstance Pointer to HTTP_PROTOCOL structure.
428 @param[in] Message Pointer to storage containing HTTP message data.
429 @param[in] Url The URL of a remote host.
431 @return Pointer to the created HTTP request string.
432 @return NULL if any error occured.
436 HttpGenRequestString (
437 IN HTTP_PROTOCOL
*HttpInstance
,
438 IN EFI_HTTP_MESSAGE
*Message
,
443 The work function of EfiHttpResponse().
445 @param[in] Wrap Pointer to HTTP token's wrap data.
447 @retval EFI_SUCCESS Allocation succeeded.
448 @retval EFI_OUT_OF_RESOURCES Failed to complete the opration due to lack of resources.
449 @retval EFI_NOT_READY Can't find a corresponding TxToken.
454 IN HTTP_TOKEN_WRAP
*Wrap