VirtualBox

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

Last change on this file since 105668 was 99404, checked in by vboxsync, 20 months ago

Devices/EFI/FirmwareNew: Update to edk2-stable202302 and make it build, bugref:4643

  • Property svn:eol-style set to native
File size: 17.3 KB
Line 
1/** @file
2 The header files of miscellaneous routines for HttpDxe driver.
3
4Copyright (c) 2015 - 2021, 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// The state of HTTP protocol. It starts from UNCONFIGED.
27//
28#define HTTP_STATE_UNCONFIGED 0
29#define HTTP_STATE_HTTP_CONFIGED 1
30#define HTTP_STATE_TCP_CONFIGED 2
31#define HTTP_STATE_TCP_UNCONFIGED 3
32#define HTTP_STATE_TCP_CONNECTED 4
33#define HTTP_STATE_TCP_CLOSED 5
34
35//
36// TCP configured data.
37//
38#define HTTP_TOS_DEAULT 8
39#define HTTP_TTL_DEAULT 255
40#define HTTP_BUFFER_SIZE_DEAULT 65535
41#define HTTP_MAX_SYN_BACK_LOG 5
42#define HTTP_CONNECTION_TIMEOUT 60
43#define HTTP_DATA_RETRIES 12
44#define HTTP_FIN_TIMEOUT 2
45#define HTTP_KEEP_ALIVE_PROBES 6
46#define HTTP_KEEP_ALIVE_TIME 7200
47#define HTTP_KEEP_ALIVE_INTERVAL 30
48
49#define HTTP_URL_BUFFER_LEN 4096
50
51typedef struct _HTTP_SERVICE {
52 UINT32 Signature;
53 EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;
54 EFI_HANDLE Ip4DriverBindingHandle;
55 EFI_HANDLE Ip6DriverBindingHandle;
56 EFI_HANDLE ControllerHandle;
57 EFI_HANDLE Tcp4ChildHandle;
58 EFI_HANDLE Tcp6ChildHandle;
59 LIST_ENTRY ChildrenList;
60 UINTN ChildrenNumber;
61 INTN State;
62} HTTP_SERVICE;
63
64typedef struct {
65 EFI_TCP4_IO_TOKEN Tx4Token;
66 EFI_TCP4_TRANSMIT_DATA Tx4Data;
67 EFI_TCP6_IO_TOKEN Tx6Token;
68 EFI_TCP6_TRANSMIT_DATA Tx6Data;
69 EFI_TCP4_IO_TOKEN Rx4Token;
70 EFI_TCP4_RECEIVE_DATA Rx4Data;
71 EFI_TCP6_IO_TOKEN Rx6Token;
72 EFI_TCP6_RECEIVE_DATA Rx6Data;
73 BOOLEAN IsTxDone;
74 BOOLEAN IsRxDone;
75 UINTN BodyLen;
76 EFI_HTTP_METHOD Method;
77} HTTP_TCP_TOKEN_WRAP;
78
79typedef struct {
80 EFI_TLS_VERSION Version;
81 EFI_TLS_CONNECTION_END ConnectionEnd;
82 EFI_TLS_VERIFY VerifyMethod;
83 EFI_TLS_VERIFY_HOST VerifyHost;
84 EFI_TLS_SESSION_STATE SessionState;
85} TLS_CONFIG_DATA;
86
87//
88// Callback data for HTTP_PARSER_CALLBACK()
89//
90typedef struct {
91 UINTN ParseDataLength;
92 VOID *ParseData;
93 VOID *Wrap;
94} HTTP_CALLBACK_DATA;
95
96typedef struct _HTTP_PROTOCOL {
97 UINT32 Signature;
98 EFI_HTTP_PROTOCOL Http;
99 EFI_HANDLE Handle;
100 HTTP_SERVICE *Service;
101 LIST_ENTRY Link; // Link to all HTTP instance from the service.
102 BOOLEAN InDestroy;
103 INTN State;
104 EFI_HTTP_METHOD Method;
105
106 UINTN StatusCode;
107
108 EFI_EVENT TimeoutEvent;
109
110 EFI_HANDLE Tcp4ChildHandle;
111 EFI_TCP4_PROTOCOL *Tcp4;
112 EFI_TCP4_CONFIG_DATA Tcp4CfgData;
113 EFI_TCP4_OPTION Tcp4Option;
114
115 EFI_TCP4_CONNECTION_TOKEN Tcp4ConnToken;
116 BOOLEAN IsTcp4ConnDone;
117 EFI_TCP4_CLOSE_TOKEN Tcp4CloseToken;
118 BOOLEAN IsTcp4CloseDone;
119 CHAR8 *RemoteHost;
120 UINT16 RemotePort;
121 EFI_IPv4_ADDRESS RemoteAddr;
122
123 EFI_HANDLE Tcp6ChildHandle;
124 EFI_TCP6_PROTOCOL *Tcp6;
125 EFI_TCP6_CONFIG_DATA Tcp6CfgData;
126 EFI_TCP6_OPTION Tcp6Option;
127
128 EFI_TCP6_CONNECTION_TOKEN Tcp6ConnToken;
129 BOOLEAN IsTcp6ConnDone;
130 EFI_TCP6_CLOSE_TOKEN Tcp6CloseToken;
131 BOOLEAN IsTcp6CloseDone;
132 EFI_IPv6_ADDRESS RemoteIpv6Addr;
133
134 //
135 // Rx4Token or Rx6Token used for receiving HTTP header.
136 //
137 EFI_TCP4_IO_TOKEN Rx4Token;
138 EFI_TCP4_RECEIVE_DATA Rx4Data;
139 EFI_TCP6_IO_TOKEN Rx6Token;
140 EFI_TCP6_RECEIVE_DATA Rx6Data;
141 BOOLEAN IsRxDone;
142
143 CHAR8 **EndofHeader;
144 CHAR8 **HttpHeaders;
145 CHAR8 *CacheBody;
146 CHAR8 *NextMsg;
147 UINTN CacheLen;
148 UINTN CacheOffset;
149
150 //
151 // HTTP message-body parser.
152 //
153 VOID *MsgParser;
154 HTTP_CALLBACK_DATA CallbackData;
155
156 EFI_HTTP_VERSION HttpVersion;
157 UINT32 TimeOutMillisec;
158 BOOLEAN LocalAddressIsIPv6;
159
160 EFI_HTTPv4_ACCESS_POINT IPv4Node;
161 EFI_HTTPv6_ACCESS_POINT Ipv6Node;
162
163 NET_MAP TxTokens;
164 NET_MAP RxTokens;
165
166 CHAR8 *Url;
167
168 //
169 // Https Support
170 //
171 BOOLEAN UseHttps;
172
173 EFI_SERVICE_BINDING_PROTOCOL *TlsSb;
174 EFI_HANDLE TlsChildHandle; /// Tls ChildHandle
175 TLS_CONFIG_DATA TlsConfigData;
176 EFI_TLS_PROTOCOL *Tls;
177 EFI_TLS_CONFIGURATION_PROTOCOL *TlsConfiguration;
178 EFI_TLS_SESSION_STATE TlsSessionState;
179
180 //
181 // TlsTxData used for transmitting TLS related messages.
182 //
183 EFI_TCP4_IO_TOKEN Tcp4TlsTxToken;
184 EFI_TCP4_TRANSMIT_DATA Tcp4TlsTxData;
185 EFI_TCP6_IO_TOKEN Tcp6TlsTxToken;
186 EFI_TCP6_TRANSMIT_DATA Tcp6TlsTxData;
187 BOOLEAN TlsIsTxDone;
188
189 //
190 // TlsRxData used for receiving TLS related messages.
191 //
192 EFI_TCP4_IO_TOKEN Tcp4TlsRxToken;
193 EFI_TCP4_RECEIVE_DATA Tcp4TlsRxData;
194 EFI_TCP6_IO_TOKEN Tcp6TlsRxToken;
195 EFI_TCP6_RECEIVE_DATA Tcp6TlsRxData;
196 BOOLEAN TlsIsRxDone;
197
198 BOOLEAN ConnectionClose;
199} HTTP_PROTOCOL;
200
201typedef struct {
202 EFI_HTTP_TOKEN *HttpToken;
203 HTTP_PROTOCOL *HttpInstance;
204 HTTP_TCP_TOKEN_WRAP TcpWrap;
205} HTTP_TOKEN_WRAP;
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 Initialize 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 against.
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 against.
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 message 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 against.
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 against.
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 cache 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 operation 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/**
612 Send Events via EDKII_HTTP_CALLBACK_PROTOCOL.
613
614 @param[in] Event The event that occurs in the current state.
615 @param[in] EventStatus The Status of Event, EFI_SUCCESS or other errors.
616
617**/
618VOID
619HttpNotify (
620 IN EDKII_HTTP_CALLBACK_EVENT Event,
621 IN EFI_STATUS EventStatus
622 );
623
624#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