TianoCore EDK2 master
Loading...
Searching...
No Matches
HttpProto.h
Go to the documentation of this file.
1
11#ifndef __EFI_HTTP_PROTO_H__
12#define __EFI_HTTP_PROTO_H__
13
14#define DEF_BUF_LEN 2048
15
16#define HTTP_SERVICE_SIGNATURE SIGNATURE_32('H', 't', 't', 'S')
17
18#define HTTP_SERVICE_FROM_PROTOCOL(a) \
19 CR ( \
20 (a), \
21 HTTP_SERVICE, \
22 ServiceBinding, \
23 HTTP_SERVICE_SIGNATURE \
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 0x200000
42#define HTTP_MAX_SYN_BACK_LOG 5
43#define HTTP_CONNECTION_TIMEOUT 60
44#define HTTP_DATA_RETRIES 12
45#define HTTP_FIN_TIMEOUT 2
46#define HTTP_KEEP_ALIVE_PROBES 6
47#define HTTP_KEEP_ALIVE_TIME 7200
48#define HTTP_KEEP_ALIVE_INTERVAL 30
49
50#define HTTP_URL_BUFFER_LEN 4096
51
52typedef struct _HTTP_SERVICE {
53 UINT32 Signature;
54 EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;
55 EFI_HANDLE Ip4DriverBindingHandle;
56 EFI_HANDLE Ip6DriverBindingHandle;
57 EFI_HANDLE ControllerHandle;
58 EFI_HANDLE Tcp4ChildHandle;
59 EFI_HANDLE Tcp6ChildHandle;
60 LIST_ENTRY ChildrenList;
61 UINTN ChildrenNumber;
62 INTN State;
64
65typedef struct {
66 EFI_TCP4_IO_TOKEN Tx4Token;
68 EFI_TCP6_IO_TOKEN Tx6Token;
70 EFI_TCP4_IO_TOKEN Rx4Token;
72 EFI_TCP6_IO_TOKEN Rx6Token;
74 BOOLEAN IsTxDone;
75 BOOLEAN IsRxDone;
76 UINTN BodyLen;
77 EFI_HTTP_METHOD Method;
79
80typedef struct {
81 EFI_TLS_VERSION Version;
82 EFI_TLS_CONNECTION_END ConnectionEnd;
83 EFI_TLS_VERIFY VerifyMethod;
84 EFI_TLS_VERIFY_HOST VerifyHost;
85 EFI_TLS_SESSION_STATE SessionState;
87
88//
89// Callback data for HTTP_PARSER_CALLBACK()
90//
91typedef struct {
92 UINTN ParseDataLength;
93 VOID *ParseData;
94 VOID *Wrap;
96
97typedef struct _HTTP_PROTOCOL {
98 UINT32 Signature;
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
163
164 NET_MAP TxTokens;
165 NET_MAP RxTokens;
166
167 CHAR8 *Url;
168 UINTN UrlLen;
169
170 //
171 // Https Support
172 //
173 BOOLEAN UseHttps;
174
176 BOOLEAN TlsAlreadyCreated;
177 TLS_CONFIG_DATA TlsConfigData;
178 EFI_TLS_PROTOCOL *Tls;
179 EFI_TLS_CONFIGURATION_PROTOCOL *TlsConfiguration;
180 EFI_TLS_SESSION_STATE TlsSessionState;
181
182 //
183 // TlsTxData used for transmitting TLS related messages.
184 //
185 EFI_TCP4_IO_TOKEN Tcp4TlsTxToken;
186 EFI_TCP4_TRANSMIT_DATA Tcp4TlsTxData;
187 EFI_TCP6_IO_TOKEN Tcp6TlsTxToken;
188 EFI_TCP6_TRANSMIT_DATA Tcp6TlsTxData;
189 BOOLEAN TlsIsTxDone;
190
191 //
192 // TlsRxData used for receiving TLS related messages.
193 //
194 EFI_TCP4_IO_TOKEN Tcp4TlsRxToken;
195 EFI_TCP4_RECEIVE_DATA Tcp4TlsRxData;
196 EFI_TCP6_IO_TOKEN Tcp6TlsRxToken;
197 EFI_TCP6_RECEIVE_DATA Tcp6TlsRxData;
198 BOOLEAN TlsIsRxDone;
199
200 BOOLEAN ConnectionClose;
202
203typedef struct {
204 EFI_HTTP_TOKEN *HttpToken;
205 HTTP_PROTOCOL *HttpInstance;
206 HTTP_TCP_TOKEN_WRAP TcpWrap;
208
209#define HTTP_PROTOCOL_SIGNATURE SIGNATURE_32('H', 't', 't', 'P')
210
211#define HTTP_INSTANCE_FROM_PROTOCOL(a) \
212 CR ( \
213 (a), \
214 HTTP_PROTOCOL, \
215 Http, \
216 HTTP_PROTOCOL_SIGNATURE \
217 )
218
226VOID
227EFIAPI
229 IN EFI_EVENT Event,
230 IN VOID *Context
231 );
232
244 IN HTTP_PROTOCOL *HttpInstance
245 );
246
253VOID
255 IN HTTP_PROTOCOL *HttpInstance
256 );
257
269 IN HTTP_TOKEN_WRAP *Wrap
270 );
271
283 IN HTTP_PROTOCOL *HttpInstance
284 );
285
297 IN HTTP_TOKEN_WRAP *Wrap
298 );
299
306VOID
308 IN HTTP_TOKEN_WRAP *Wrap
309 );
310
323 IN OUT HTTP_PROTOCOL *HttpInstance,
324 IN BOOLEAN IpVersion
325 );
326
333VOID
335 IN HTTP_PROTOCOL *HttpInstance
336 );
337
349 IN HTTP_PROTOCOL *HttpInstance
350 );
351
363 IN HTTP_PROTOCOL *HttpInstance
364 );
365
378 IN HTTP_PROTOCOL *HttpInstance,
379 IN HTTP_TOKEN_WRAP *Wrap
380 );
381
394 IN HTTP_PROTOCOL *HttpInstance,
395 IN HTTP_TOKEN_WRAP *Wrap
396 );
397
411 IN HTTP_PROTOCOL *HttpInstance
412 );
413
427 IN HTTP_PROTOCOL *HttpInstance
428 );
429
444 IN HTTP_PROTOCOL *HttpInstance,
445 IN HTTP_TOKEN_WRAP *Wrap,
446 IN UINT8 *TxString,
447 IN UINTN TxStringLen
448 );
449
465EFIAPI
467 IN NET_MAP *Map,
468 IN NET_MAP_ITEM *Item,
469 IN VOID *Context
470 );
471
484EFIAPI
486 IN NET_MAP *Map,
487 IN NET_MAP_ITEM *Item,
488 IN VOID *Context
489 );
490
505 IN HTTP_PROTOCOL *HttpInstance,
506 IN HTTP_TOKEN_WRAP *Wrap,
507 IN BOOLEAN Configure,
508 IN BOOLEAN TlsConfigure
509 );
510
524EFIAPI
526 IN NET_MAP *Map,
527 IN NET_MAP_ITEM *Item,
528 IN VOID *Context
529 );
530
544EFIAPI
546 IN NET_MAP *Map,
547 IN NET_MAP_ITEM *Item,
548 IN VOID *Context
549 );
550
565 IN HTTP_PROTOCOL *HttpInstance,
566 IN OUT UINTN *SizeofHeaders,
567 IN OUT UINTN *BufferSize,
568 IN EFI_EVENT Timeout
569 );
570
583 IN HTTP_TOKEN_WRAP *Wrap,
584 IN EFI_HTTP_MESSAGE *HttpMsg
585 );
586
593VOID
595 IN HTTP_TOKEN_WRAP *Wrap
596 );
597
610 IN HTTP_TOKEN_WRAP *Wrap
611 );
612
620VOID
623 IN EFI_STATUS EventStatus
624 );
625
626#endif
UINT64 UINTN
INT64 INTN
EDKII_HTTP_CALLBACK_EVENT
Definition: HttpCallback.h:22
VOID HttpTcpTokenCleanup(IN HTTP_TOKEN_WRAP *Wrap)
Definition: HttpProto.c:2147
EFI_STATUS HttpConfigureTcp4(IN HTTP_PROTOCOL *HttpInstance, IN HTTP_TOKEN_WRAP *Wrap)
Definition: HttpProto.c:1048
EFI_STATUS HttpCreateTcpRxEvent(IN HTTP_TOKEN_WRAP *Wrap)
Definition: HttpProto.c:524
EFI_STATUS HttpInitSession(IN HTTP_PROTOCOL *HttpInstance, IN HTTP_TOKEN_WRAP *Wrap, IN BOOLEAN Configure, IN BOOLEAN TlsConfigure)
Definition: HttpProto.c:1407
EFI_STATUS HttpCreateTcpConnCloseEvent(IN HTTP_PROTOCOL *HttpInstance)
Definition: HttpProto.c:292
EFI_STATUS EFIAPI HttpTokenExist(IN NET_MAP *Map, IN NET_MAP_ITEM *Item, IN VOID *Context)
Definition: HttpProto.c:1659
EFI_STATUS HttpInitProtocol(IN OUT HTTP_PROTOCOL *HttpInstance, IN BOOLEAN IpVersion)
Definition: HttpProto.c:617
VOID HttpCleanProtocol(IN HTTP_PROTOCOL *HttpInstance)
Definition: HttpProto.c:820
EFI_STATUS HttpConnectTcp4(IN HTTP_PROTOCOL *HttpInstance)
Definition: HttpProto.c:1221
EFI_STATUS HttpTcpReceiveBody(IN HTTP_TOKEN_WRAP *Wrap, IN EFI_HTTP_MESSAGE *HttpMsg)
Definition: HttpProto.c:2087
EFI_STATUS HttpConnectTcp6(IN HTTP_PROTOCOL *HttpInstance)
Definition: HttpProto.c:1313
VOID EFIAPI HttpCommonNotify(IN EFI_EVENT Event, IN VOID *Context)
Definition: HttpProto.c:22
EFI_STATUS EFIAPI HttpTcpReceive(IN NET_MAP *Map, IN NET_MAP_ITEM *Item, IN VOID *Context)
Definition: HttpProto.c:1797
EFI_STATUS HttpCloseConnection(IN HTTP_PROTOCOL *HttpInstance)
Definition: HttpProto.c:1001
EFI_STATUS HttpCreateConnection(IN HTTP_PROTOCOL *HttpInstance)
Definition: HttpProto.c:943
VOID HttpNotify(IN EDKII_HTTP_CALLBACK_EVENT Event, IN EFI_STATUS EventStatus)
Definition: HttpProto.c:2213
EFI_STATUS HttpResponseWorker(IN HTTP_TOKEN_WRAP *Wrap)
Definition: HttpImpl.c:966
EFI_STATUS EFIAPI HttpTcpTransmit(IN NET_MAP *Map, IN NET_MAP_ITEM *Item, IN VOID *Context)
Definition: HttpProto.c:1722
EFI_STATUS HttpTransmitTcp(IN HTTP_PROTOCOL *HttpInstance, IN HTTP_TOKEN_WRAP *Wrap, IN UINT8 *TxString, IN UINTN TxStringLen)
Definition: HttpProto.c:1483
EFI_STATUS HttpTcpReceiveHeader(IN HTTP_PROTOCOL *HttpInstance, IN OUT UINTN *SizeofHeaders, IN OUT UINTN *BufferSize, IN EFI_EVENT Timeout)
Definition: HttpProto.c:1822
EFI_STATUS HttpCreateTcpRxEventForHeader(IN HTTP_PROTOCOL *HttpInstance)
Definition: HttpProto.c:473
EFI_STATUS EFIAPI HttpTcpNotReady(IN NET_MAP *Map, IN NET_MAP_ITEM *Item, IN VOID *Context)
Definition: HttpProto.c:1691
VOID HttpCloseTcpConnCloseEvent(IN HTTP_PROTOCOL *HttpInstance)
Definition: HttpProto.c:374
EFI_STATUS HttpCreateTcpTxEvent(IN HTTP_TOKEN_WRAP *Wrap)
Definition: HttpProto.c:413
VOID HttpCloseTcpRxEvent(IN HTTP_TOKEN_WRAP *Wrap)
Definition: HttpProto.c:576
EFI_STATUS HttpConfigureTcp6(IN HTTP_PROTOCOL *HttpInstance, IN HTTP_TOKEN_WRAP *Wrap)
Definition: HttpProto.c:1137
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
EFI_HTTP_VERSION
Definition: Http.h:34
EFI_HTTP_METHOD
Definition: Http.h:43
EFI_TLS_SESSION_STATE
Definition: Tls.h:274
UINT32 EFI_TLS_VERIFY
Definition: Tls.h:166
EFI_TLS_CONNECTION_END
Definition: Tls.h:124
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_EVENT
Definition: UefiBaseType.h:37
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33