VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/HttpDxe/HttpProto.h@ 80721

Last change on this file since 80721 was 80721, checked in by vboxsync, 5 years ago

Devices/EFI/FirmwareNew: Start upgrade process to edk2-stable201908 (compiles on Windows and works to some extent), bugref:4643

  • Property svn:eol-style set to native
File size: 17.1 KB
Line 
1/** @file
2 The header files of miscellaneous routines for HttpDxe driver.
3
4Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>
5(C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
6SPDX-License-Identifier: BSD-2-Clause-Patent
7
8**/
9
10#ifndef __EFI_HTTP_PROTO_H__
11#define __EFI_HTTP_PROTO_H__
12
13#define DEF_BUF_LEN 2048
14
15#define HTTP_SERVICE_SIGNATURE SIGNATURE_32('H', 't', 't', 'S')
16
17#define HTTP_SERVICE_FROM_PROTOCOL(a) \
18 CR ( \
19 (a), \
20 HTTP_SERVICE, \
21 ServiceBinding, \
22 HTTP_SERVICE_SIGNATURE \
23 )
24
25
26//
27// The state of HTTP protocol. It starts from UNCONFIGED.
28//
29#define HTTP_STATE_UNCONFIGED 0
30#define HTTP_STATE_HTTP_CONFIGED 1
31#define HTTP_STATE_TCP_CONFIGED 2
32#define HTTP_STATE_TCP_UNCONFIGED 3
33#define HTTP_STATE_TCP_CONNECTED 4
34#define HTTP_STATE_TCP_CLOSED 5
35
36//
37// TCP configured data.
38//
39#define HTTP_TOS_DEAULT 8
40#define HTTP_TTL_DEAULT 255
41#define HTTP_BUFFER_SIZE_DEAULT 65535
42#define HTTP_MAX_SYN_BACK_LOG 5
43#define HTTP_CONNECTION_TIMEOUT 60
44#define HTTP_RESPONSE_TIMEOUT 5
45#define HTTP_DATA_RETRIES 12
46#define HTTP_FIN_TIMEOUT 2
47#define HTTP_KEEP_ALIVE_PROBES 6
48#define HTTP_KEEP_ALIVE_TIME 7200
49#define HTTP_KEEP_ALIVE_INTERVAL 30
50
51#define HTTP_URL_BUFFER_LEN 4096
52
53typedef struct _HTTP_SERVICE {
54 UINT32 Signature;
55 EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;
56 EFI_HANDLE Ip4DriverBindingHandle;
57 EFI_HANDLE Ip6DriverBindingHandle;
58 EFI_HANDLE ControllerHandle;
59 EFI_HANDLE Tcp4ChildHandle;
60 EFI_HANDLE Tcp6ChildHandle;
61 LIST_ENTRY ChildrenList;
62 UINTN ChildrenNumber;
63 INTN State;
64} HTTP_SERVICE;
65
66typedef struct {
67 EFI_TCP4_IO_TOKEN Tx4Token;
68 EFI_TCP4_TRANSMIT_DATA Tx4Data;
69 EFI_TCP6_IO_TOKEN Tx6Token;
70 EFI_TCP6_TRANSMIT_DATA Tx6Data;
71 EFI_TCP4_IO_TOKEN Rx4Token;
72 EFI_TCP4_RECEIVE_DATA Rx4Data;
73 EFI_TCP6_IO_TOKEN Rx6Token;
74 EFI_TCP6_RECEIVE_DATA Rx6Data;
75 BOOLEAN IsTxDone;
76 BOOLEAN IsRxDone;
77 UINTN BodyLen;
78 EFI_HTTP_METHOD Method;
79} HTTP_TCP_TOKEN_WRAP;
80
81typedef struct {
82 EFI_TLS_VERSION Version;
83 EFI_TLS_CONNECTION_END ConnectionEnd;
84 EFI_TLS_VERIFY VerifyMethod;
85 EFI_TLS_SESSION_STATE SessionState;
86} TLS_CONFIG_DATA;
87
88//
89// Callback data for HTTP_PARSER_CALLBACK()
90//
91typedef struct {
92 UINTN ParseDataLength;
93 VOID *ParseData;
94 VOID *Wrap;
95} HTTP_CALLBACK_DATA;
96
97typedef struct _HTTP_PROTOCOL {
98 UINT32 Signature;
99 EFI_HTTP_PROTOCOL Http;
100 EFI_HANDLE Handle;
101 HTTP_SERVICE *Service;
102 LIST_ENTRY Link; // Link to all HTTP instance from the service.
103 BOOLEAN InDestroy;
104 INTN State;
105 EFI_HTTP_METHOD Method;
106
107 UINTN StatusCode;
108
109 EFI_EVENT TimeoutEvent;
110
111 EFI_HANDLE Tcp4ChildHandle;
112 EFI_TCP4_PROTOCOL *Tcp4;
113 EFI_TCP4_CONFIG_DATA Tcp4CfgData;
114 EFI_TCP4_OPTION Tcp4Option;
115
116 EFI_TCP4_CONNECTION_TOKEN Tcp4ConnToken;
117 BOOLEAN IsTcp4ConnDone;
118 EFI_TCP4_CLOSE_TOKEN Tcp4CloseToken;
119 BOOLEAN IsTcp4CloseDone;
120 CHAR8 *RemoteHost;
121 UINT16 RemotePort;
122 EFI_IPv4_ADDRESS RemoteAddr;
123
124 EFI_HANDLE Tcp6ChildHandle;
125 EFI_TCP6_PROTOCOL *Tcp6;
126 EFI_TCP6_CONFIG_DATA Tcp6CfgData;
127 EFI_TCP6_OPTION Tcp6Option;
128
129 EFI_TCP6_CONNECTION_TOKEN Tcp6ConnToken;
130 BOOLEAN IsTcp6ConnDone;
131 EFI_TCP6_CLOSE_TOKEN Tcp6CloseToken;
132 BOOLEAN IsTcp6CloseDone;
133 EFI_IPv6_ADDRESS RemoteIpv6Addr;
134
135 //
136 // Rx4Token or Rx6Token used for receiving HTTP header.
137 //
138 EFI_TCP4_IO_TOKEN Rx4Token;
139 EFI_TCP4_RECEIVE_DATA Rx4Data;
140 EFI_TCP6_IO_TOKEN Rx6Token;
141 EFI_TCP6_RECEIVE_DATA Rx6Data;
142 BOOLEAN IsRxDone;
143
144 CHAR8 **EndofHeader;
145 CHAR8 **HttpHeaders;
146 CHAR8 *CacheBody;
147 CHAR8 *NextMsg;
148 UINTN CacheLen;
149 UINTN CacheOffset;
150
151 //
152 // HTTP message-body parser.
153 //
154 VOID *MsgParser;
155 HTTP_CALLBACK_DATA CallbackData;
156
157 EFI_HTTP_VERSION HttpVersion;
158 UINT32 TimeOutMillisec;
159 BOOLEAN LocalAddressIsIPv6;
160
161 EFI_HTTPv4_ACCESS_POINT IPv4Node;
162 EFI_HTTPv6_ACCESS_POINT Ipv6Node;
163
164 NET_MAP TxTokens;
165 NET_MAP RxTokens;
166
167 CHAR8 *Url;
168
169 //
170 // Https Support
171 //
172 BOOLEAN UseHttps;
173
174 EFI_SERVICE_BINDING_PROTOCOL *TlsSb;
175 EFI_HANDLE TlsChildHandle; /// Tls ChildHandle
176 TLS_CONFIG_DATA TlsConfigData;
177 EFI_TLS_PROTOCOL *Tls;
178 EFI_TLS_CONFIGURATION_PROTOCOL *TlsConfiguration;
179 EFI_TLS_SESSION_STATE TlsSessionState;
180
181 //
182 // TlsTxData used for transmitting TLS related messages.
183 //
184 EFI_TCP4_IO_TOKEN Tcp4TlsTxToken;
185 EFI_TCP4_TRANSMIT_DATA Tcp4TlsTxData;
186 EFI_TCP6_IO_TOKEN Tcp6TlsTxToken;
187 EFI_TCP6_TRANSMIT_DATA Tcp6TlsTxData;
188 BOOLEAN TlsIsTxDone;
189
190 //
191 // TlsRxData used for receiving TLS related messages.
192 //
193 EFI_TCP4_IO_TOKEN Tcp4TlsRxToken;
194 EFI_TCP4_RECEIVE_DATA Tcp4TlsRxData;
195 EFI_TCP6_IO_TOKEN Tcp6TlsRxToken;
196 EFI_TCP6_RECEIVE_DATA Tcp6TlsRxData;
197 BOOLEAN TlsIsRxDone;
198} HTTP_PROTOCOL;
199
200typedef struct {
201 EFI_HTTP_TOKEN *HttpToken;
202 HTTP_PROTOCOL *HttpInstance;
203 HTTP_TCP_TOKEN_WRAP TcpWrap;
204} HTTP_TOKEN_WRAP;
205
206
207#define HTTP_PROTOCOL_SIGNATURE SIGNATURE_32('H', 't', 't', 'P')
208
209#define HTTP_INSTANCE_FROM_PROTOCOL(a) \
210 CR ( \
211 (a), \
212 HTTP_PROTOCOL, \
213 Http, \
214 HTTP_PROTOCOL_SIGNATURE \
215 )
216
217/**
218 The common notify function used in HTTP driver.
219
220 @param[in] Event The event signaled.
221 @param[in] Context The context.
222
223**/
224VOID
225EFIAPI
226HttpCommonNotify (
227 IN EFI_EVENT Event,
228 IN VOID *Context
229 );
230
231/**
232 Create events for the TCP connection token and TCP close token.
233
234 @param[in] HttpInstance Pointer to HTTP_PROTOCOL structure.
235
236 @retval EFI_SUCCESS The events are created successfully.
237 @retval others Other error as indicated.
238
239**/
240EFI_STATUS
241HttpCreateTcpConnCloseEvent (
242 IN HTTP_PROTOCOL *HttpInstance
243 );
244
245/**
246 Close events in the TCP connection token and TCP close token.
247
248 @param[in] HttpInstance Pointer to HTTP_PROTOCOL structure.
249
250**/
251VOID
252HttpCloseTcpConnCloseEvent (
253 IN HTTP_PROTOCOL *HttpInstance
254 );
255
256/**
257 Create event for the TCP transmit token.
258
259 @param[in] Wrap Point to HTTP token's wrap data.
260
261 @retval EFI_SUCCESS The events is created successfully.
262 @retval others Other error as indicated.
263
264**/
265EFI_STATUS
266HttpCreateTcpTxEvent (
267 IN HTTP_TOKEN_WRAP *Wrap
268 );
269
270/**
271 Create event for the TCP receive token which is used to receive HTTP header.
272
273 @param[in] HttpInstance Pointer to HTTP_PROTOCOL structure.
274
275 @retval EFI_SUCCESS The events is created successfully.
276 @retval others Other error as indicated.
277
278**/
279EFI_STATUS
280HttpCreateTcpRxEventForHeader (
281 IN HTTP_PROTOCOL *HttpInstance
282 );
283
284/**
285 Create event for the TCP receive token which is used to receive HTTP body.
286
287 @param[in] Wrap Point to HTTP token's wrap data.
288
289 @retval EFI_SUCCESS The events is created successfully.
290 @retval others Other error as indicated.
291
292**/
293EFI_STATUS
294HttpCreateTcpRxEvent (
295 IN HTTP_TOKEN_WRAP *Wrap
296 );
297
298/**
299 Close Events for Tcp Receive Tokens for HTTP body and HTTP header.
300
301 @param[in] Wrap Pointer to HTTP token's wrap data.
302
303**/
304VOID
305HttpCloseTcpRxEvent (
306 IN HTTP_TOKEN_WRAP *Wrap
307 );
308
309/**
310 Intiialize the HTTP_PROTOCOL structure to the unconfigured state.
311
312 @param[in, out] HttpInstance Pointer to HTTP_PROTOCOL structure.
313 @param[in] IpVersion Indicate us TCP4 protocol or TCP6 protocol.
314
315 @retval EFI_SUCCESS HTTP_PROTOCOL structure is initialized successfully.
316 @retval Others Other error as indicated.
317
318**/
319EFI_STATUS
320HttpInitProtocol (
321 IN OUT HTTP_PROTOCOL *HttpInstance,
322 IN BOOLEAN IpVersion
323 );
324
325/**
326 Clean up the HTTP child, release all the resources used by it.
327
328 @param[in] HttpInstance The HTTP child to clean up.
329
330**/
331VOID
332HttpCleanProtocol (
333 IN HTTP_PROTOCOL *HttpInstance
334 );
335
336/**
337 Establish TCP connection with HTTP server.
338
339 @param[in] HttpInstance The HTTP instance private data.
340
341 @retval EFI_SUCCESS The TCP connection is established.
342 @retval Others Other error as indicated.
343
344**/
345EFI_STATUS
346HttpCreateConnection (
347 IN HTTP_PROTOCOL *HttpInstance
348 );
349
350/**
351 Close existing TCP connection.
352
353 @param[in] HttpInstance The HTTP instance private data.
354
355 @retval EFI_SUCCESS The TCP connection is closed.
356 @retval Others Other error as indicated.
357
358**/
359EFI_STATUS
360HttpCloseConnection (
361 IN HTTP_PROTOCOL *HttpInstance
362 );
363
364/**
365 Configure TCP4 protocol child.
366
367 @param[in] HttpInstance The HTTP instance private data.
368 @param[in] Wrap The HTTP token's wrap data.
369
370 @retval EFI_SUCCESS The TCP4 protocol child is configured.
371 @retval Others Other error as indicated.
372
373**/
374EFI_STATUS
375HttpConfigureTcp4 (
376 IN HTTP_PROTOCOL *HttpInstance,
377 IN HTTP_TOKEN_WRAP *Wrap
378 );
379
380/**
381 Configure TCP6 protocol child.
382
383 @param[in] HttpInstance The HTTP instance private data.
384 @param[in] Wrap The HTTP token's wrap data.
385
386 @retval EFI_SUCCESS The TCP6 protocol child is configured.
387 @retval Others Other error as indicated.
388
389**/
390EFI_STATUS
391HttpConfigureTcp6 (
392 IN HTTP_PROTOCOL *HttpInstance,
393 IN HTTP_TOKEN_WRAP *Wrap
394 );
395
396/**
397 Check existing TCP connection, if in error state, recover TCP4 connection. Then,
398 connect one TLS session if required.
399
400 @param[in] HttpInstance The HTTP instance private data.
401
402 @retval EFI_SUCCESS The TCP connection is established.
403 @retval EFI_NOT_READY TCP4 protocol child is not created or configured.
404 @retval Others Other error as indicated.
405
406**/
407EFI_STATUS
408HttpConnectTcp4 (
409 IN HTTP_PROTOCOL *HttpInstance
410 );
411
412/**
413 Check existing TCP connection, if in error state, recover TCP6 connection. Then,
414 connect one TLS session if required.
415
416 @param[in] HttpInstance The HTTP instance private data.
417
418 @retval EFI_SUCCESS The TCP connection is established.
419 @retval EFI_NOT_READY TCP6 protocol child is not created or configured.
420 @retval Others Other error as indicated.
421
422**/
423EFI_STATUS
424HttpConnectTcp6 (
425 IN HTTP_PROTOCOL *HttpInstance
426 );
427
428/**
429 Send the HTTP or HTTPS message through TCP4 or TCP6.
430
431 @param[in] HttpInstance The HTTP instance private data.
432 @param[in] Wrap The HTTP token's wrap data.
433 @param[in] TxString Buffer containing the HTTP message string.
434 @param[in] TxStringLen Length of the HTTP message string in bytes.
435
436 @retval EFI_SUCCESS The HTTP message is queued into TCP transmit queue.
437 @retval Others Other error as indicated.
438
439**/
440EFI_STATUS
441HttpTransmitTcp (
442 IN HTTP_PROTOCOL *HttpInstance,
443 IN HTTP_TOKEN_WRAP *Wrap,
444 IN UINT8 *TxString,
445 IN UINTN TxStringLen
446 );
447
448/**
449 Check whether the user's token or event has already
450 been enqueue on HTTP Tx or Rx Token list.
451
452 @param[in] Map The container of either user's transmit or receive
453 token.
454 @param[in] Item Current item to check against.
455 @param[in] Context The Token to check againist.
456
457 @retval EFI_ACCESS_DENIED The token or event has already been enqueued in IP
458 @retval EFI_SUCCESS The current item isn't the same token/event as the
459 context.
460
461**/
462EFI_STATUS
463EFIAPI
464HttpTokenExist (
465 IN NET_MAP *Map,
466 IN NET_MAP_ITEM *Item,
467 IN VOID *Context
468 );
469
470/**
471 Check whether the HTTP message associated with TxToken or Tx6Token is already sent out.
472
473 @param[in] Map The container of TxToken.
474 @param[in] Item Current item to check against.
475 @param[in] Context The Token to check againist.
476
477 @retval EFI_NOT_READY The HTTP message is still queued in the list.
478 @retval EFI_SUCCESS The HTTP message has been sent out.
479
480**/
481EFI_STATUS
482EFIAPI
483HttpTcpNotReady (
484 IN NET_MAP *Map,
485 IN NET_MAP_ITEM *Item,
486 IN VOID *Context
487 );
488
489/**
490 Initialize Http session.
491
492 @param[in] HttpInstance The HTTP instance private data.
493 @param[in] Wrap The HTTP token's wrap data.
494 @param[in] Configure The Flag indicates whether need to initialize session.
495 @param[in] TlsConfigure The Flag indicates whether it's the new Tls session.
496
497 @retval EFI_SUCCESS The initialization of session is done.
498 @retval Others Other error as indicated.
499
500**/
501EFI_STATUS
502HttpInitSession (
503 IN HTTP_PROTOCOL *HttpInstance,
504 IN HTTP_TOKEN_WRAP *Wrap,
505 IN BOOLEAN Configure,
506 IN BOOLEAN TlsConfigure
507 );
508
509/**
510 Transmit the HTTP or HTTPS mssage by processing the associated HTTP token.
511
512 @param[in] Map The container of TxToken or Tx6Token.
513 @param[in] Item Current item to check against.
514 @param[in] Context The Token to check againist.
515
516 @retval EFI_OUT_OF_RESOURCES Failed to allocate resources.
517 @retval EFI_SUCCESS The HTTP message is queued into TCP transmit
518 queue.
519
520**/
521EFI_STATUS
522EFIAPI
523HttpTcpTransmit (
524 IN NET_MAP *Map,
525 IN NET_MAP_ITEM *Item,
526 IN VOID *Context
527 );
528
529/**
530 Receive the HTTP response by processing the associated HTTP token.
531
532 @param[in] Map The container of Rx4Token or Rx6Token.
533 @param[in] Item Current item to check against.
534 @param[in] Context The Token to check againist.
535
536 @retval EFI_SUCCESS The HTTP response is queued into TCP receive
537 queue.
538 @retval Others Other error as indicated.
539
540**/
541EFI_STATUS
542EFIAPI
543HttpTcpReceive (
544 IN NET_MAP *Map,
545 IN NET_MAP_ITEM *Item,
546 IN VOID *Context
547 );
548
549/**
550 Receive the HTTP header by processing the associated HTTP token.
551
552 @param[in] HttpInstance The HTTP instance private data.
553 @param[in, out] SizeofHeaders The HTTP header length.
554 @param[in, out] BufferSize The size of buffer to cacahe the header message.
555 @param[in] Timeout The time to wait for receiving the header packet.
556
557 @retval EFI_SUCCESS The HTTP header is received.
558 @retval Others Other errors as indicated.
559
560**/
561EFI_STATUS
562HttpTcpReceiveHeader (
563 IN HTTP_PROTOCOL *HttpInstance,
564 IN OUT UINTN *SizeofHeaders,
565 IN OUT UINTN *BufferSize,
566 IN EFI_EVENT Timeout
567 );
568
569/**
570 Receive the HTTP body by processing the associated HTTP token.
571
572 @param[in] Wrap The HTTP token's wrap data.
573 @param[in] HttpMsg The HTTP message data.
574
575 @retval EFI_SUCCESS The HTTP body is received.
576 @retval Others Other error as indicated.
577
578**/
579EFI_STATUS
580HttpTcpReceiveBody (
581 IN HTTP_TOKEN_WRAP *Wrap,
582 IN EFI_HTTP_MESSAGE *HttpMsg
583 );
584
585/**
586 Clean up Tcp Tokens while the Tcp transmission error occurs.
587
588 @param[in] Wrap Pointer to HTTP token's wrap data.
589
590**/
591VOID
592HttpTcpTokenCleanup (
593 IN HTTP_TOKEN_WRAP *Wrap
594 );
595
596/**
597 The work function of EfiHttpResponse().
598
599 @param[in] Wrap Pointer to HTTP token's wrap data.
600
601 @retval EFI_SUCCESS Allocation succeeded.
602 @retval EFI_OUT_OF_RESOURCES Failed to complete the opration due to lack of resources.
603 @retval EFI_NOT_READY Can't find a corresponding TxToken.
604
605**/
606EFI_STATUS
607HttpResponseWorker (
608 IN HTTP_TOKEN_WRAP *Wrap
609 );
610
611#endif
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette