]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Protocol/Tcp4.h
Reviewed the code comments in the Include/Protocol directory for typos, grammar issue...
[mirror_edk2.git] / MdePkg / Include / Protocol / Tcp4.h
1 /** @file
2 EFI TCPv4 Protocol Definition
3 The EFI TCPv4 Service Binding Protocol is used to locate EFI TCPv4 Protocol drivers to create
4 and destroy child of the driver to communicate with other host using TCP protocol.
5 The EFI TCPv4 Protocol provides services to send and receive data stream.
6
7 Copyright (c) 2006 - 2008, Intel Corporation
8 All rights reserved. This program and the accompanying materials
9 are licensed and made available under the terms and conditions of the BSD License
10 which accompanies this distribution. The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php
12
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15
16 **/
17
18 #ifndef __EFI_TCP4_PROTOCOL_H__
19 #define __EFI_TCP4_PROTOCOL_H__
20
21 #include <Protocol/Ip4.h>
22
23 #define EFI_TCP4_SERVICE_BINDING_PROTOCOL_GUID \
24 { \
25 0x00720665, 0x67EB, 0x4a99, {0xBA, 0xF7, 0xD3, 0xC3, 0x3A, 0x1C, 0x7C, 0xC9 } \
26 }
27
28 #define EFI_TCP4_PROTOCOL_GUID \
29 { \
30 0x65530BC7, 0xA359, 0x410f, {0xB0, 0x10, 0x5A, 0xAD, 0xC7, 0xEC, 0x2B, 0x62 } \
31 }
32
33 typedef struct _EFI_TCP4_PROTOCOL EFI_TCP4_PROTOCOL;
34
35 typedef struct {
36 EFI_HANDLE InstanceHandle;
37 EFI_IPv4_ADDRESS LocalAddress;
38 UINT16 LocalPort;
39 EFI_IPv4_ADDRESS RemoteAddress;
40 UINT16 RemotePort;
41 } EFI_TCP4_SERVICE_POINT;
42
43 typedef struct {
44 EFI_HANDLE DriverHandle;
45 UINT32 ServiceCount;
46 EFI_TCP4_SERVICE_POINT Services[1];
47 } EFI_TCP4_VARIABLE_DATA;
48
49 typedef struct {
50 BOOLEAN UseDefaultAddress;
51 EFI_IPv4_ADDRESS StationAddress;
52 EFI_IPv4_ADDRESS SubnetMask;
53 UINT16 StationPort;
54 EFI_IPv4_ADDRESS RemoteAddress;
55 UINT16 RemotePort;
56 BOOLEAN ActiveFlag;
57 } EFI_TCP4_ACCESS_POINT;
58
59 typedef struct {
60 UINT32 ReceiveBufferSize;
61 UINT32 SendBufferSize;
62 UINT32 MaxSynBackLog;
63 UINT32 ConnectionTimeout;
64 UINT32 DataRetries;
65 UINT32 FinTimeout;
66 UINT32 TimeWaitTimeout;
67 UINT32 KeepAliveProbes;
68 UINT32 KeepAliveTime;
69 UINT32 KeepAliveInterval;
70 BOOLEAN EnableNagle;
71 BOOLEAN EnableTimeStamp;
72 BOOLEAN EnableWindowScaling;
73 BOOLEAN EnableSelectiveAck;
74 BOOLEAN EnablePathMtuDiscovery;
75 } EFI_TCP4_OPTION;
76
77 typedef struct {
78 //
79 // I/O parameters
80 //
81 UINT8 TypeOfService;
82 UINT8 TimeToLive;
83
84 //
85 // Access Point
86 //
87 EFI_TCP4_ACCESS_POINT AccessPoint;
88
89 //
90 // TCP Control Options
91 //
92 EFI_TCP4_OPTION *ControlOption;
93 } EFI_TCP4_CONFIG_DATA;
94
95 ///
96 /// TCP4 connnection state
97 ///
98 typedef enum {
99 Tcp4StateClosed = 0,
100 Tcp4StateListen = 1,
101 Tcp4StateSynSent = 2,
102 Tcp4StateSynReceived = 3,
103 Tcp4StateEstablished = 4,
104 Tcp4StateFinWait1 = 5,
105 Tcp4StateFinWait2 = 6,
106 Tcp4StateClosing = 7,
107 Tcp4StateTimeWait = 8,
108 Tcp4StateCloseWait = 9,
109 Tcp4StateLastAck = 10
110 } EFI_TCP4_CONNECTION_STATE;
111
112 typedef struct {
113 EFI_EVENT Event;
114 EFI_STATUS Status;
115 } EFI_TCP4_COMPLETION_TOKEN;
116
117 typedef struct {
118 EFI_TCP4_COMPLETION_TOKEN CompletionToken;
119 } EFI_TCP4_CONNECTION_TOKEN;
120
121 typedef struct {
122 EFI_TCP4_COMPLETION_TOKEN CompletionToken;
123 EFI_HANDLE NewChildHandle;
124 } EFI_TCP4_LISTEN_TOKEN;
125
126 typedef struct {
127 UINT32 FragmentLength;
128 VOID *FragmentBuffer;
129 } EFI_TCP4_FRAGMENT_DATA;
130
131 typedef struct {
132 BOOLEAN UrgentFlag;
133 UINT32 DataLength;
134 UINT32 FragmentCount;
135 EFI_TCP4_FRAGMENT_DATA FragmentTable[1];
136 } EFI_TCP4_RECEIVE_DATA;
137
138 typedef struct {
139 BOOLEAN Push;
140 BOOLEAN Urgent;
141 UINT32 DataLength;
142 UINT32 FragmentCount;
143 EFI_TCP4_FRAGMENT_DATA FragmentTable[1];
144 } EFI_TCP4_TRANSMIT_DATA;
145
146 typedef struct {
147 EFI_TCP4_COMPLETION_TOKEN CompletionToken;
148 union {
149 EFI_TCP4_RECEIVE_DATA *RxData;
150 EFI_TCP4_TRANSMIT_DATA *TxData;
151 } Packet;
152 } EFI_TCP4_IO_TOKEN;
153
154 typedef struct {
155 EFI_TCP4_COMPLETION_TOKEN CompletionToken;
156 BOOLEAN AbortOnClose;
157 } EFI_TCP4_CLOSE_TOKEN;
158
159 //
160 // Interface definition for TCP4 protocol
161 //
162
163 /**
164 Get the current operational status.
165
166 @param This Pointer to the EFI_TCP4_PROTOCOL instance.
167 @param Tcp4State Pointer to the buffer to receive the current TCP state.
168 @param Tcp4ConfigData Pointer to the buffer to receive the current TCP configuration.
169 @param Ip4ModeData Pointer to the buffer to receive the current IPv4 configuration
170 data used by the TCPv4 instance.
171 @param MnpConfigData Pointer to the buffer to receive the current MNP configuration
172 data used indirectly by the TCPv4 instance.
173 @param SnpModeData Pointer to the buffer to receive the current SNP configuration
174 data used indirectly by the TCPv4 instance.
175
176 @retval EFI_SUCCESS The mode data was read.
177 @retval EFI_INVALID_PARAMETER This is NULL.
178 @retval EFI_NOT_STARTED No configuration data is available because this instance hasn't
179 been started.
180
181 **/
182 typedef
183 EFI_STATUS
184 (EFIAPI *EFI_TCP4_GET_MODE_DATA)(
185 IN CONST EFI_TCP4_PROTOCOL *This,
186 OUT EFI_TCP4_CONNECTION_STATE *Tcp4State OPTIONAL,
187 OUT EFI_TCP4_CONFIG_DATA *Tcp4ConfigData OPTIONAL,
188 OUT EFI_IP4_MODE_DATA *Ip4ModeData OPTIONAL,
189 OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,
190 OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL
191 );
192
193 /**
194 Initialize or brutally reset the operational parameters for this EFI TCPv4 instance.
195
196 @param This Pointer to the EFI_TCP4_PROTOCOL instance.
197 @param Tcp4ConfigData Pointer to the configure data to configure the instance.
198
199 @retval EFI_SUCCESS The operational settings are set, changed, or reset
200 successfully.
201 @retval EFI_INVALID_PARAMETER Some parameter is invalid.
202 @retval EFI_NO_MAPPING When using a default address, configuration (through
203 DHCP, BOOTP, RARP, etc.) is not finished yet.
204 @retval EFI_ACCESS_DENIED Configuring TCP instance when it is configured without
205 calling Configure() with NULL to reset it.
206 @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.
207 @retval EFI_UNSUPPORTED One or more of the control options are not supported in
208 the implementation.
209 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources when
210 executing Configure().
211
212 **/
213 typedef
214 EFI_STATUS
215 (EFIAPI *EFI_TCP4_CONFIGURE)(
216 IN EFI_TCP4_PROTOCOL *This,
217 IN EFI_TCP4_CONFIG_DATA *TcpConfigData OPTIONAL
218 );
219
220
221 /**
222 Add or delete a route entry to the route table
223
224 @param This Pointer to the EFI_TCP4_PROTOCOL instance.
225 @param DeleteRoute Set it to TRUE to delete this route from the routing table. Set it to
226 FALSE to add this route to the routing table.
227 DestinationAddress and SubnetMask are used as the
228 keywords to search route entry.
229 @param SubnetAddress The destination network.
230 @param SubnetMask The subnet mask of the destination network.
231 @param GatewayAddress The gateway address for this route. It must be on the same
232 subnet with the station address unless a direct route is specified.
233
234 @retval EFI_SUCCESS The operation completed successfully.
235 @retval EFI_NOT_STARTED The EFI TCPv4 Protocol instance has not been configured.
236 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,
237 RARP, etc.) is not finished yet.
238 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
239 - This is NULL.
240 - SubnetAddress is NULL.
241 - SubnetMask is NULL.
242 - GatewayAddress is NULL.
243 - *SubnetAddress is not NULL a valid subnet address.
244 - *SubnetMask is not a valid subnet mask.
245 - *GatewayAddress is not a valid unicast IP address or it
246 is not in the same subnet.
247 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resources to add the entry to the
248 routing table.
249 @retval EFI_NOT_FOUND This route is not in the routing table.
250 @retval EFI_ACCESS_DENIED The route is already defined in the routing table.
251 @retval EFI_UNSUPPORTED The TCP driver does not support this operation.
252
253 **/
254 typedef
255 EFI_STATUS
256 (EFIAPI *EFI_TCP4_ROUTES)(
257 IN EFI_TCP4_PROTOCOL *This,
258 IN BOOLEAN DeleteRoute,
259 IN EFI_IPv4_ADDRESS *SubnetAddress,
260 IN EFI_IPv4_ADDRESS *SubnetMask,
261 IN EFI_IPv4_ADDRESS *GatewayAddress
262 );
263
264 /**
265 Initiate a nonblocking TCP connection request for an active TCP instance.
266
267 @param This Pointer to the EFI_TCP4_PROTOCOL instance.
268 @param ConnectionToken Pointer to the connection token to return when the TCP three
269 way handshake finishes.
270
271 @retval EFI_SUCCESS The connection request is successfully initiated and the state
272 - of this TCPv4 instance has been changed to
273 - Tcp4StateSynSent.
274 @retval EFI_NOT_STARTED This EFI TCPv4 Protocol instance has not been configured.
275 @retval EFI_ACCESS_DENIED One or more of the following conditions are TRUE:
276 - This instance is not configured as an active one.
277 - This instance is not in Tcp4StateClosed state.
278 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
279 - This is NULL.
280 - ConnectionToken is NULL.
281 - ConnectionToken->CompletionToken.Event is NULL.
282 @retval EFI_OUT_OF_RESOURCES The driver can't allocate enough resources to initiate the activeopen.
283 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
284
285 **/
286 typedef
287 EFI_STATUS
288 (EFIAPI *EFI_TCP4_CONNECT)(
289 IN EFI_TCP4_PROTOCOL *This,
290 IN EFI_TCP4_CONNECTION_TOKEN *ConnectionToken
291 );
292
293
294 /**
295 Listen on the passive instance to accept an incoming connection request. This is a nonblocking operation.
296
297 @param This Pointer to the EFI_TCP4_PROTOCOL instance.
298 @param ListenToken Pointer to the listen token to return when operation finishes.
299
300 @retval EFI_SUCCESS The listen token has been queued successfully.
301 @retval EFI_NOT_STARTED This EFI TCPv4 Protocol instance has not been configured.
302 @retval EFI_ACCESS_DENIED One or more of the following are TRUE:
303 - This instance is not a passive instance.
304 - This instance is not in Tcp4StateListen state.
305 - The same listen token has already existed in the listen
306 token queue of this TCP instance.
307 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
308 - This is NULL.
309 - ListenToken is NULL.
310 - ListentToken->CompletionToken.Event is NULL.
311 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resources to finish the operation.
312 @retval EFI_DEVICE_ERROR Any unexpected error not covered by another error.
313
314 **/
315 typedef
316 EFI_STATUS
317 (EFIAPI *EFI_TCP4_ACCEPT)(
318 IN EFI_TCP4_PROTOCOL *This,
319 IN EFI_TCP4_LISTEN_TOKEN *ListenToken
320 );
321
322 /**
323 Queues outgoing data into the transmit queue.
324
325 @param This Pointer to the EFI_TCP4_PROTOCOL instance.
326 @param Token Pointer to the completion token to queue to the transmit queue.
327
328 @retval EFI_SUCCESS The data has been queued for transmission.
329 @retval EFI_NOT_STARTED This EFI TCPv4 Protocol instance has not been configured.
330 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,
331 RARP, etc.) is not finished yet.
332 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
333 - This is NULL.
334 - Token is NULL.
335 - Token->CompletionToken.Event is NULL.
336 - Token->Packet.TxData is NULL L.
337 - Token->Packet.FragmentCount is zero.
338 - Token->Packet.DataLength is not equal to the sum of fragment lengths.
339 @retval EFI_ACCESS_DENIED One or more of the following conditions is TRUE:
340 - A transmit completion token with the same Token->CompletionToken.Event
341 was already in the transmission queue.
342 - The current instance is in Tcp4StateClosed state.
343 - The current instance is a passive one and it is in
344 Tcp4StateListen state.
345 - User has called Close() to disconnect this connection.
346 @retval EFI_NOT_READY The completion token could not be queued because the
347 transmit queue is full.
348 @retval EFI_OUT_OF_RESOURCES Could not queue the transmit data because of resource
349 shortage.
350 @retval EFI_NETWORK_UNREACHABLE There is no route to the destination network or address.
351
352 **/
353 typedef
354 EFI_STATUS
355 (EFIAPI *EFI_TCP4_TRANSMIT)(
356 IN EFI_TCP4_PROTOCOL *This,
357 IN EFI_TCP4_IO_TOKEN *Token
358 );
359
360
361 /**
362 Places an asynchronous receive request into the receiving queue.
363
364 @param This Pointer to the EFI_TCP4_PROTOCOL instance.
365 @param Token Pointer to a token that is associated with the receive data
366 descriptor.
367
368 @retval EFI_SUCCESS The receive completion token was cached.
369 @retval EFI_NOT_STARTED This EFI TCPv4 Protocol instance has not been configured.
370 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP, RARP,
371 etc.) is not finished yet.
372 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
373 - This is NULL.
374 - Token is NULL.
375 - Token->CompletionToken.Event is NULL.
376 - Token->Packet.RxData is NULL.
377 - Token->Packet.RxData->DataLength is 0.
378 - The Token->Packet.RxData->DataLength is not
379 the sum of all FragmentBuffer length in FragmentTable.
380 @retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued due to a lack of
381 system resources (usually memory).
382 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
383 @retval EFI_ACCESS_DENIED One or more of the following conditions is TRUE:
384 - A receive completion token with the same Token-
385 >CompletionToken.Event was already in the receive
386 queue.
387 - The current instance is in Tcp4StateClosed state.
388 - The current instance is a passive one and it is in
389 Tcp4StateListen state.
390 - User has called Close() to disconnect this connection.
391 @retval EFI_CONNECTION_FIN The communication peer has closed the connection and there is
392 no buffered data in the receive buffer of this instance.
393 @retval EFI_NOT_READY The receive request could not be queued because the receive queue is full.
394
395 **/
396 typedef
397 EFI_STATUS
398 (EFIAPI *EFI_TCP4_RECEIVE)(
399 IN EFI_TCP4_PROTOCOL *This,
400 IN EFI_TCP4_IO_TOKEN *Token
401 );
402
403 /**
404 Disconnecting a TCP connection gracefully or reset a TCP connection. This function is a
405 nonblocking operation.
406
407 @param This Pointer to the EFI_TCP4_PROTOCOL instance.
408 @param CloseToken Pointer to the close token to return when operation finishes.
409
410 @retval EFI_SUCCESS The Close() is called successfully.
411 @retval EFI_NOT_STARTED This EFI TCPv4 Protocol instance has not been configured.
412 @retval EFI_ACCESS_DENIED One or more of the following are TRUE:
413 - Configure() has been called with
414 TcpConfigData set to NULL and this function has
415 not returned.
416 - Previous Close() call on this instance has not
417 finished.
418 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
419 - This is NULL.
420 - CloseToken is NULL.
421 - CloseToken->CompletionToken.Event is NULL.
422 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resources to finish the operation.
423 @retval EFI_DEVICE_ERROR Any unexpected error not covered by another error.
424
425 **/
426 typedef
427 EFI_STATUS
428 (EFIAPI *EFI_TCP4_CLOSE)(
429 IN EFI_TCP4_PROTOCOL *This,
430 IN EFI_TCP4_CLOSE_TOKEN *CloseToken
431 );
432
433 /**
434 Abort an asynchronous connection, listen, transmission or receive request.
435
436 @param This Pointer to the EFI_TCP4_PROTOCOL instance.
437 @param Token Pointer to a token that has been issued by
438 EFI_TCP4_PROTOCOL.Connect(),
439 EFI_TCP4_PROTOCOL.Accept(),
440 EFI_TCP4_PROTOCOL.Transmit() or
441 EFI_TCP4_PROTOCOL.Receive(). If NULL, all pending
442 tokens issued by above four functions will be aborted. Type
443 EFI_TCP4_COMPLETION_TOKEN is defined in
444 EFI_TCP4_PROTOCOL.Connect().
445
446 @retval EFI_SUCCESS Incoming or outgoing data was processed.
447 @retval EFI_INVALID_PARAMETER This is NULL.
448 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
449 @retval EFI_NOT_READY No incoming or outgoing data is processed.
450 @retval EFI_TIMEOUT Data was dropped out of the transmission or receive queue.
451 Consider increasing the polling rate.
452
453 **/
454 typedef
455 EFI_STATUS
456 (EFIAPI *EFI_TCP4_CANCEL)(
457 IN EFI_TCP4_PROTOCOL *This,
458 IN EFI_TCP4_COMPLETION_TOKEN *Token OPTIONAL
459 );
460
461
462 /**
463 Poll to receive incoming data and transmit outgoing segments.
464
465 @param This Pointer to the EFI_TCP4_PROTOCOL instance.
466
467 @retval EFI_SUCCESS Incoming or outgoing data was processed.
468 @retval EFI_INVALID_PARAMETER This is NULL.
469 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
470 @retval EFI_NOT_READY No incoming or outgoing data is processed.
471 @retval EFI_TIMEOUT Data was dropped out of the transmission or receive queue.
472 Consider increasing the polling rate.
473
474 **/
475 typedef
476 EFI_STATUS
477 (EFIAPI *EFI_TCP4_POLL)(
478 IN EFI_TCP4_PROTOCOL *This
479 );
480
481 ///
482 /// The EFI_TCP4_PROTOCOL defines the EFI TCPv4 Protocol child to be used by
483 /// any network drivers or applications to send or receive data stream.
484 /// It can either listen on a specified port as a service or actively connected
485 /// to remote peer as a client. Each instance has its own independent settings,
486 /// such as the routing table.
487 ///
488 struct _EFI_TCP4_PROTOCOL {
489 EFI_TCP4_GET_MODE_DATA GetModeData;
490 EFI_TCP4_CONFIGURE Configure;
491 EFI_TCP4_ROUTES Routes;
492 EFI_TCP4_CONNECT Connect;
493 EFI_TCP4_ACCEPT Accept;
494 EFI_TCP4_TRANSMIT Transmit;
495 EFI_TCP4_RECEIVE Receive;
496 EFI_TCP4_CLOSE Close;
497 EFI_TCP4_CANCEL Cancel;
498 EFI_TCP4_POLL Poll;
499 };
500
501 #define EFI_CONNECTION_FIN EFIERR (104)
502 #define EFI_CONNECTION_RESET EFIERR (105)
503 #define EFI_CONNECTION_REFUSED EFIERR (106)
504
505 extern EFI_GUID gEfiTcp4ServiceBindingProtocolGuid;
506 extern EFI_GUID gEfiTcp4ProtocolGuid;
507
508 #endif