]> git.proxmox.com Git - mirror_edk2.git/blob - NetworkPkg/TcpDxe/TcpMain.h
NetworkPkg: Support TCP Cancel function
[mirror_edk2.git] / NetworkPkg / TcpDxe / TcpMain.h
1 /** @file
2 Declaration of protocol interfaces in EFI_TCP4_PROTOCOL and EFI_TCP6_PROTOCOL.
3 It is the common head file for all Tcp*.c in TCP driver.
4
5 Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
6
7 This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php.
11
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14
15 **/
16
17 #ifndef _TCP_MAIN_H_
18 #define _TCP_MAIN_H_
19
20 #include <Protocol/ServiceBinding.h>
21 #include <Protocol/DriverBinding.h>
22 #include <Library/IpIoLib.h>
23 #include <Library/DevicePathLib.h>
24 #include <Library/PrintLib.h>
25
26 #include "Socket.h"
27 #include "TcpProto.h"
28 #include "TcpDriver.h"
29 #include "TcpFunc.h"
30
31 extern UINT16 mTcp4RandomPort;
32 extern UINT16 mTcp6RandomPort;
33 extern CHAR16 *mTcpStateName[];
34 extern EFI_COMPONENT_NAME_PROTOCOL gTcpComponentName;
35 extern EFI_COMPONENT_NAME2_PROTOCOL gTcpComponentName2;
36 extern EFI_UNICODE_STRING_TABLE *gTcpControllerNameTable;
37
38 extern LIST_ENTRY mTcpRunQue;
39 extern LIST_ENTRY mTcpListenQue;
40 extern TCP_SEQNO mTcpGlobalIss;
41 extern UINT32 mTcpTick;
42
43 ///
44 /// 30 seconds.
45 ///
46 #define TCP6_KEEP_NEIGHBOR_TIME 30
47 ///
48 /// 5 seconds, since 1 tick equals 200ms.
49 ///
50 #define TCP6_REFRESH_NEIGHBOR_TICK 25
51
52 #define TCP_EXPIRE_TIME 65535
53
54 ///
55 /// The implementation selects the initial send sequence number and the unit to
56 /// be added when it is increased.
57 ///
58 #define TCP_BASE_ISS 0x4d7e980b
59 #define TCP_ISS_INCREMENT_1 2048
60 #define TCP_ISS_INCREMENT_2 100
61
62 typedef union {
63 EFI_TCP4_CONFIG_DATA Tcp4CfgData;
64 EFI_TCP6_CONFIG_DATA Tcp6CfgData;
65 } TCP_CONFIG_DATA;
66
67 typedef union {
68 EFI_TCP4_ACCESS_POINT Tcp4Ap;
69 EFI_TCP6_ACCESS_POINT Tcp6Ap;
70 } TCP_ACCESS_POINT;
71
72 typedef struct _TCP4_MODE_DATA {
73 EFI_TCP4_CONNECTION_STATE *Tcp4State;
74 EFI_TCP4_CONFIG_DATA *Tcp4ConfigData;
75 EFI_IP4_MODE_DATA *Ip4ModeData;
76 EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData;
77 EFI_SIMPLE_NETWORK_MODE *SnpModeData;
78 } TCP4_MODE_DATA;
79
80 typedef struct _TCP6_MODE_DATA {
81 EFI_TCP6_CONNECTION_STATE *Tcp6State;
82 EFI_TCP6_CONFIG_DATA *Tcp6ConfigData;
83 EFI_IP6_MODE_DATA *Ip6ModeData;
84 EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData;
85 EFI_SIMPLE_NETWORK_MODE *SnpModeData;
86 } TCP6_MODE_DATA;
87
88 typedef struct _TCP4_ROUTE_INFO {
89 BOOLEAN DeleteRoute;
90 EFI_IPv4_ADDRESS *SubnetAddress;
91 EFI_IPv4_ADDRESS *SubnetMask;
92 EFI_IPv4_ADDRESS *GatewayAddress;
93 } TCP4_ROUTE_INFO;
94
95 typedef struct {
96 EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
97 UINTN NumberOfChildren;
98 EFI_HANDLE *ChildHandleBuffer;
99 } TCP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT;
100
101 //
102 // EFI_TCP4_PROTOCOL definitions.
103 //
104
105 /**
106 Get the current operational status.
107
108 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
109 @param[out] Tcp4State Pointer to the buffer to receive the current TCP
110 state. Optional parameter that may be NULL.
111 @param[out] Tcp4ConfigData Pointer to the buffer to receive the current TCP
112 configuration. Optional parameter that may be NULL.
113 @param[out] Ip4ModeData Pointer to the buffer to receive the current
114 IPv4 configuration. Optional parameter that may be NULL.
115 @param[out] MnpConfigData Pointer to the buffer to receive the current MNP
116 configuration data indirectly used by the TCPv4
117 Instance. Optional parameter that may be NULL.
118 @param[out] SnpModeData Pointer to the buffer to receive the current SNP
119 configuration data indirectly used by the TCPv4
120 Instance. Optional parameter that may be NULL.
121
122 @retval EFI_SUCCESS The mode data was read.
123 @retval EFI_NOT_STARTED No configuration data is available because this
124 instance hasn't been started.
125 @retval EFI_INVALID_PARAMETER This is NULL.
126
127 **/
128 EFI_STATUS
129 EFIAPI
130 Tcp4GetModeData (
131 IN EFI_TCP4_PROTOCOL *This,
132 OUT EFI_TCP4_CONNECTION_STATE *Tcp4State OPTIONAL,
133 OUT EFI_TCP4_CONFIG_DATA *Tcp4ConfigData OPTIONAL,
134 OUT EFI_IP4_MODE_DATA *Ip4ModeData OPTIONAL,
135 OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,
136 OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL
137 );
138
139 /**
140 Initialize or brutally reset the operational parameters for
141 this EFI TCPv4 instance.
142
143 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
144 @param[in] TcpConfigData Pointer to the configure data to configure the
145 instance. Optional parameter that may be NULL.
146
147 @retval EFI_SUCCESS The operational settings are set, changed, or
148 reset successfully.
149 @retval EFI_NO_MAPPING When using a default address, configuration
150 (through DHCP, BOOTP, RARP, etc.) is not
151 finished.
152 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
153 @retval EFI_ACCESS_DENIED Configuring the TCP instance when it is already
154 configured.
155 @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.
156 @retval EFI_UNSUPPORTED One or more of the control options are not
157 supported in the implementation.
158 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources.
159
160 **/
161 EFI_STATUS
162 EFIAPI
163 Tcp4Configure (
164 IN EFI_TCP4_PROTOCOL * This,
165 IN EFI_TCP4_CONFIG_DATA * TcpConfigData OPTIONAL
166 );
167
168 /**
169 Add or delete routing entries.
170
171 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
172 @param[in] DeleteRoute If TRUE, delete the specified route from routing
173 table; if FALSE, add the specified route to
174 routing table.
175 @param[in] SubnetAddress The destination network.
176 @param[in] SubnetMask The subnet mask for the destination network.
177 @param[in] GatewayAddress The gateway address for this route.
178
179 @retval EFI_SUCCESS The operation completed successfully.
180 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance has not been
181 configured.
182 @retval EFI_NO_MAPPING When using a default address, configuration
183 (through DHCP, BOOTP, RARP, etc.) is not
184 finished.
185 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
186 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resources to add the
187 entry to the routing table.
188 @retval EFI_NOT_FOUND This route is not in the routing table.
189 @retval EFI_ACCESS_DENIED This route is already in the routing table.
190 @retval EFI_UNSUPPORTED The TCP driver does not support this operation.
191
192 **/
193 EFI_STATUS
194 EFIAPI
195 Tcp4Routes (
196 IN EFI_TCP4_PROTOCOL *This,
197 IN BOOLEAN DeleteRoute,
198 IN EFI_IPv4_ADDRESS *SubnetAddress,
199 IN EFI_IPv4_ADDRESS *SubnetMask,
200 IN EFI_IPv4_ADDRESS *GatewayAddress
201 );
202
203 /**
204 Initiate a nonblocking TCP connection request for an active TCP instance.
205
206 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
207 @param[in] ConnectionToken Pointer to the connection token to return when
208 the TCP three way handshake finishes.
209
210 @retval EFI_SUCCESS The connection request is successfully
211 initiated.
212 @retval EFI_NOT_STARTED This EFI_TCP4_PROTOCOL instance hasn't been
213 configured.
214 @retval EFI_ACCESS_DENIED The instance is not configured as an active one
215 or it is not in Tcp4StateClosed state.
216 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
217 @retval EFI_OUT_OF_RESOURCES The driver can't allocate enough resources to
218 initiate the active open.
219 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
220
221 **/
222 EFI_STATUS
223 EFIAPI
224 Tcp4Connect (
225 IN EFI_TCP4_PROTOCOL *This,
226 IN EFI_TCP4_CONNECTION_TOKEN *ConnectionToken
227 );
228
229 /**
230 Listen on the passive instance to accept an incoming connection request.
231
232 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
233 @param[in] ListenToken Pointer to the listen token to return when
234 operation finishes.
235
236 @retval EFI_SUCCESS The listen token has been queued successfully.
237 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been
238 configured.
239 @retval EFI_ACCESS_DENIED The instatnce is not a passive one or it is not
240 in Tcp4StateListen state, or a same listen token
241 has already existed in the listen token queue of
242 this TCP instance.
243 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
244 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resources to finish
245 the operation.
246 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
247
248 **/
249 EFI_STATUS
250 EFIAPI
251 Tcp4Accept (
252 IN EFI_TCP4_PROTOCOL *This,
253 IN EFI_TCP4_LISTEN_TOKEN *ListenToken
254 );
255
256 /**
257 Queues outgoing data into the transmit queue
258
259 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance
260 @param[in] Token Pointer to the completion token to queue to the
261 transmit queue
262
263 @retval EFI_SUCCESS The data has been queued for transmission
264 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been
265 configured.
266 @retval EFI_NO_MAPPING When using a default address, configuration
267 (DHCP, BOOTP, RARP, etc.) is not finished yet.
268 @retval EFI_INVALID_PARAMETER One or more parameters are invalid
269 @retval EFI_ACCESS_DENIED One or more of the following conditions is TRUE:
270 * A transmit completion token with the same
271 Token-> CompletionToken.Event was already in the
272 transmission queue. * The current instance is in
273 Tcp4StateClosed state * The current instance is
274 a passive one and it is in Tcp4StateListen
275 state. * User has called Close() to disconnect
276 this connection.
277 @retval EFI_NOT_READY The completion token could not be queued because
278 the transmit queue is full.
279 @retval EFI_OUT_OF_RESOURCES Could not queue the transmit data because of a
280 resource shortage.
281 @retval EFI_NETWORK_UNREACHABLE There is no route to the destination network or
282 address.
283
284 **/
285 EFI_STATUS
286 EFIAPI
287 Tcp4Transmit (
288 IN EFI_TCP4_PROTOCOL *This,
289 IN EFI_TCP4_IO_TOKEN *Token
290 );
291
292 /**
293 Place an asynchronous receive request into the receiving queue.
294
295 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
296 @param[in] Token Pointer to a token that is associated with the
297 receive data descriptor.
298
299 @retval EFI_SUCCESS The receive completion token was cached.
300 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been
301 configured.
302 @retval EFI_NO_MAPPING When using a default address, configuration
303 (DHCP, BOOTP, RARP, etc.) is not finished yet.
304 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
305 @retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued
306 due to a lack of system resources.
307 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
308 @retval EFI_ACCESS_DENIED One or more of the following conditions is TRUE:
309 * A receive completion token with the same
310 Token->CompletionToken.Event was already in the
311 receive queue. * The current instance is in
312 Tcp4StateClosed state. * The current instance is
313 a passive one and it is in Tcp4StateListen
314 state. * User has called Close() to disconnect
315 this connection.
316 @retval EFI_CONNECTION_FIN The communication peer has closed the connection
317 and there is no buffered data in the receive
318 buffer of this instance.
319 @retval EFI_NOT_READY The receive request could not be queued because
320 the receive queue is full.
321
322 **/
323 EFI_STATUS
324 EFIAPI
325 Tcp4Receive (
326 IN EFI_TCP4_PROTOCOL *This,
327 IN EFI_TCP4_IO_TOKEN *Token
328 );
329
330 /**
331 Disconnecting a TCP connection gracefully or reset a TCP connection.
332
333 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
334 @param[in] CloseToken Pointer to the close token to return when
335 operation finishes.
336
337 @retval EFI_SUCCESS The operation completed successfully.
338 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been
339 configured.
340 @retval EFI_ACCESS_DENIED One or more of the following are TRUE: *
341 Configure() has been called with TcpConfigData
342 set to NULL and this function has not returned.
343 * Previous Close() call on this instance has not
344 finished.
345 @retval EFI_INVALID_PARAMETER One ore more parameters are invalid.
346 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resources to finish the
347 operation.
348 @retval EFI_DEVICE_ERROR Any unexpected error not belonging to the error
349 categories given above.
350
351 **/
352 EFI_STATUS
353 EFIAPI
354 Tcp4Close (
355 IN EFI_TCP4_PROTOCOL *This,
356 IN EFI_TCP4_CLOSE_TOKEN *CloseToken
357 );
358
359 /**
360 Abort an asynchronous connection, listen, transmission or receive request.
361
362 @param This The pointer to the EFI_TCP4_PROTOCOL instance.
363 @param Token The pointer to a token that has been issued by
364 EFI_TCP4_PROTOCOL.Connect(),
365 EFI_TCP4_PROTOCOL.Accept(),
366 EFI_TCP4_PROTOCOL.Transmit() or
367 EFI_TCP4_PROTOCOL.Receive(). If NULL, all pending
368 tokens issued by above four functions will be aborted. Type
369 EFI_TCP4_COMPLETION_TOKEN is defined in
370 EFI_TCP4_PROTOCOL.Connect().
371
372 @retval EFI_SUCCESS The asynchronous I/O request is aborted and Token->Event
373 is signaled.
374 @retval EFI_INVALID_PARAMETER This is NULL.
375 @retval EFI_NOT_STARTED This instance hasn't been configured.
376 @retval EFI_NO_MAPPING When using the default address, configuration
377 (DHCP, BOOTP,RARP, etc.) hasn't finished yet.
378 @retval EFI_NOT_FOUND The asynchronous I/O request isn't found in the
379 transmission or receive queue. It has either
380 completed or wasn't issued by Transmit() and Receive().
381
382 **/
383 EFI_STATUS
384 EFIAPI
385 Tcp4Cancel (
386 IN EFI_TCP4_PROTOCOL *This,
387 IN EFI_TCP4_COMPLETION_TOKEN *Token OPTIONAL
388 );
389
390 /**
391 Poll to receive incoming data and transmit outgoing segments.
392
393 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
394
395 @retval EFI_SUCCESS Incoming or outgoing data was processed.
396 @retval EFI_INVALID_PARAMETER This is NULL.
397 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
398 @retval EFI_NOT_READY No incoming or outgoing data was processed.
399 @retval EFI_TIMEOUT Data was dropped out of the transmission or
400 receive queue. Consider increasing the polling
401 rate.
402
403 **/
404 EFI_STATUS
405 EFIAPI
406 Tcp4Poll (
407 IN EFI_TCP4_PROTOCOL *This
408 );
409
410 //
411 // EFI_TCP6_PROTOCOL definitions.
412 //
413
414 /**
415 Get the current operational status.
416
417 The GetModeData() function copies the current operational settings of this EFI TCPv6
418 Protocol instance into user-supplied buffers. This function can also be used to retrieve
419 the operational setting of underlying drivers such as IPv6, MNP, or SNP.
420
421 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
422 @param[out] Tcp6State The buffer in which the current TCP state is
423 returned. Optional parameter that may be NULL.
424 @param[out] Tcp6ConfigData The buffer in which the current TCP configuration
425 is returned. Optional parameter that may be NULL.
426 @param[out] Ip6ModeData The buffer in which the current IPv6 configuration
427 data used by the TCP instance is returned.
428 Optional parameter that may be NULL.
429 @param[out] MnpConfigData The buffer in which the current MNP configuration
430 data used indirectly by the TCP instance is returned.
431 Optional parameter that may be NULL.
432 @param[out] SnpModeData The buffer in which the current SNP mode data
433 used indirectly by the TCP instance is returned.
434 Optional parameter that may be NULL.
435
436 @retval EFI_SUCCESS The mode data was read.
437 @retval EFI_NOT_STARTED No configuration data is available because this instance hasn't
438 been started.
439 @retval EFI_INVALID_PARAMETER This is NULL.
440
441 **/
442 EFI_STATUS
443 EFIAPI
444 Tcp6GetModeData (
445 IN EFI_TCP6_PROTOCOL *This,
446 OUT EFI_TCP6_CONNECTION_STATE *Tcp6State OPTIONAL,
447 OUT EFI_TCP6_CONFIG_DATA *Tcp6ConfigData OPTIONAL,
448 OUT EFI_IP6_MODE_DATA *Ip6ModeData OPTIONAL,
449 OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,
450 OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL
451 );
452
453 /**
454 Initialize or brutally reset the operational parameters for this EFI TCPv6 instance.
455
456 The Configure() function does the following:
457 - Initialize this TCP instance, i.e., initialize the communication end settings and
458 specify active open or passive open for an instance.
459 - Reset this TCP instance brutally, i.e., cancel all pending asynchronous tokens, flush
460 transmission and receiving buffer directly without informing the communication peer.
461
462 No other TCPv6 Protocol operation except Poll() can be executed by this instance until
463 it is configured properly. For an active TCP instance, after a proper configuration it
464 may call Connect() to initiates the three-way handshake. For a passive TCP instance,
465 its state will transit to Tcp6StateListen after configuration, and Accept() may be
466 called to listen the incoming TCP connection requests. If Tcp6ConfigData is set to NULL,
467 the instance is reset. Resetting process will be done brutally, the state machine will
468 be set to Tcp6StateClosed directly, the receive queue and transmit queue will be flushed,
469 and no traffic is allowed through this instance.
470
471 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
472 @param[in] Tcp6ConfigData Pointer to the configure data to configure the instance.
473 If Tcp6ConfigData is set to NULL, the instance is reset.
474
475 @retval EFI_SUCCESS The operational settings were set, changed, or reset
476 successfully.
477 @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a source
478 address for this instance, but no source address was available for
479 use.
480 @retval EFI_INVALID_PARAMETER One or more of the following conditions are TRUE:
481 - This is NULL.
482 - Tcp6ConfigData->AccessPoint.StationAddress is neither zero nor
483 one of the configured IP addresses in the underlying IPv6 driver.
484 - Tcp6ConfigData->AccessPoint.RemoteAddress isn't a valid unicast
485 IPv6 address.
486 - Tcp6ConfigData->AccessPoint.RemoteAddress is zero or
487 Tcp6ConfigData->AccessPoint.RemotePort is zero when
488 Tcp6ConfigData->AccessPoint.ActiveFlag is TRUE.
489 - A same access point has been configured in other TCP
490 instance properly.
491 @retval EFI_ACCESS_DENIED Configuring TCP instance when it is configured without
492 calling Configure() with NULL to reset it.
493 @retval EFI_UNSUPPORTED One or more of the control options are not supported in
494 the implementation.
495 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources when
496 executing Configure().
497 @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.
498
499 **/
500 EFI_STATUS
501 EFIAPI
502 Tcp6Configure (
503 IN EFI_TCP6_PROTOCOL *This,
504 IN EFI_TCP6_CONFIG_DATA *Tcp6ConfigData OPTIONAL
505 );
506
507 /**
508 Initiate a nonblocking TCP connection request for an active TCP instance.
509
510 The Connect() function will initiate an active open to the remote peer configured
511 in current TCP instance if it is configured active. If the connection succeeds or
512 fails due to an error, the ConnectionToken->CompletionToken.Event will be signaled,
513 and ConnectionToken->CompletionToken.Status will be updated accordingly. This
514 function can only be called for the TCP instance in Tcp6StateClosed state. The
515 instance will transfer into Tcp6StateSynSent if the function returns EFI_SUCCESS.
516 If TCP three-way handshake succeeds, its state will become Tcp6StateEstablished;
517 otherwise, the state will return to Tcp6StateClosed.
518
519 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
520 @param[in] ConnectionToken Pointer to the connection token to return when the TCP
521 three-way handshake finishes.
522
523 @retval EFI_SUCCESS The connection request successfully initiated and the state of
524 this TCP instance has been changed to Tcp6StateSynSent.
525 @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.
526 @retval EFI_ACCESS_DENIED One or more of the following conditions are TRUE:
527 - This instance is not configured as an active instance.
528 - This instance is not in Tcp6StateClosed state.
529 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
530 - This is NULL.
531 - ConnectionToken is NULL.
532 - ConnectionToken->CompletionToken.Event is NULL.
533 @retval EFI_OUT_OF_RESOURCES The driver can't allocate enough resources to initiate the active open.
534 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
535
536 **/
537 EFI_STATUS
538 EFIAPI
539 Tcp6Connect (
540 IN EFI_TCP6_PROTOCOL *This,
541 IN EFI_TCP6_CONNECTION_TOKEN *ConnectionToken
542 );
543
544 /**
545 Listen on the passive instance to accept an incoming connection request. This is a
546 nonblocking operation.
547
548 The Accept() function initiates an asynchronous accept request to wait for an incoming
549 connection on the passive TCP instance. If a remote peer successfully establishes a
550 connection with this instance, a new TCP instance will be created and its handle will
551 be returned in ListenToken->NewChildHandle. The newly created instance is configured
552 by inheriting the passive instance's configuration, and is ready for use upon return.
553 The new instance is in the Tcp6StateEstablished state.
554
555 The ListenToken->CompletionToken.Event will be signaled when a new connection is
556 accepted, user aborts the listen or connection is reset.
557
558 This function only can be called when the current TCP instance is in Tcp6StateListen state.
559
560 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
561 @param[in] ListenToken Pointer to the listen token to return when the operation finishes.
562
563
564 @retval EFI_SUCCESS The listen token was been queued successfully.
565 @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.
566 @retval EFI_ACCESS_DENIED One or more of the following are TRUE:
567 - This instance is not a passive instance.
568 - This instance is not in Tcp6StateListen state.
569 - The same listen token has already existed in the listen
570 token queue of this TCP instance.
571 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
572 - This is NULL.
573 - ListenToken is NULL.
574 - ListentToken->CompletionToken.Event is NULL.
575 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resources to finish the operation.
576 @retval EFI_DEVICE_ERROR Any unexpected error not belonging to the error
577 categories given above.
578
579 **/
580 EFI_STATUS
581 EFIAPI
582 Tcp6Accept (
583 IN EFI_TCP6_PROTOCOL *This,
584 IN EFI_TCP6_LISTEN_TOKEN *ListenToken
585 );
586
587 /**
588 Queues outgoing data into the transmit queue.
589
590 The Transmit() function queues a sending request to this TCP instance along with the
591 user data. The status of the token is updated and the event in the token will be
592 signaled once the data is sent out or some error occurs.
593
594 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
595 @param[in] Token Pointer to the completion token to queue to the transmit queue.
596
597 @retval EFI_SUCCESS The data has been queued for transmission.
598 @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.
599 @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a
600 source address for this instance, but no source address was
601 available for use.
602 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
603 - This is NULL.
604 - Token is NULL.
605 - Token->CompletionToken.Event is NULL.
606 - Token->Packet.TxData is NULL.
607 - Token->Packet.FragmentCount is zero.
608 - Token->Packet.DataLength is not equal to the sum of fragment lengths.
609 @retval EFI_ACCESS_DENIED One or more of the following conditions are TRUE:
610 - A transmit completion token with the same Token->
611 CompletionToken.Event was already in the
612 transmission queue.
613 - The current instance is in Tcp6StateClosed state.
614 - The current instance is a passive one and it is in
615 Tcp6StateListen state.
616 - User has called Close() to disconnect this connection.
617 @retval EFI_NOT_READY The completion token could not be queued because the
618 transmit queue is full.
619 @retval EFI_OUT_OF_RESOURCES Could not queue the transmit data because of a resource
620 shortage.
621 @retval EFI_NETWORK_UNREACHABLE There is no route to the destination network or address.
622
623 **/
624 EFI_STATUS
625 EFIAPI
626 Tcp6Transmit (
627 IN EFI_TCP6_PROTOCOL *This,
628 IN EFI_TCP6_IO_TOKEN *Token
629 );
630
631 /**
632 Places an asynchronous receive request into the receiving queue.
633
634 The Receive() function places a completion token into the receive packet queue. This
635 function is always asynchronous. The caller must allocate the Token->CompletionToken.Event
636 and the FragmentBuffer used to receive data. The caller also must fill the DataLength, which
637 represents the whole length of all FragmentBuffer. When the receive operation completes, the
638 EFI TCPv6 Protocol driver updates the Token->CompletionToken.Status and Token->Packet.RxData
639 fields, and the Token->CompletionToken.Event is signaled. If data is obtained, the data and its length
640 will be copied into the FragmentTable. At the same time the full length of received data will
641 be recorded in the DataLength fields. Providing a proper notification function and context
642 for the event enables the user to receive the notification and receiving status. That
643 notification function is guaranteed to not be re-entered.
644
645 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
646 @param[in] Token Pointer to a token that is associated with the receive data
647 descriptor.
648
649 @retval EFI_SUCCESS The receive completion token was cached.
650 @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.
651 @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a source
652 address for this instance, but no source address was available for use.
653 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
654 - This is NULL.
655 - Token is NULL.
656 - Token->CompletionToken.Event is NULL.
657 - Token->Packet.RxData is NULL.
658 - Token->Packet.RxData->DataLength is 0.
659 - The Token->Packet.RxData->DataLength is not the
660 sum of all FragmentBuffer length in FragmentTable.
661 @retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued due to a lack of
662 system resources (usually memory).
663 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
664 The EFI TCPv6 Protocol instance has been reset to startup defaults.
665 @retval EFI_ACCESS_DENIED One or more of the following conditions is TRUE:
666 - A receive completion token with the same Token->CompletionToken.Event
667 was already in the receive queue.
668 - The current instance is in Tcp6StateClosed state.
669 - The current instance is a passive one and it is in
670 Tcp6StateListen state.
671 - The user has called Close() to disconnect this connection.
672 @retval EFI_CONNECTION_FIN The communication peer has closed the connection, and there is no
673 buffered data in the receive buffer of this instance.
674 @retval EFI_NOT_READY The receive request could not be queued because the receive queue is full.
675
676 **/
677 EFI_STATUS
678 EFIAPI
679 Tcp6Receive (
680 IN EFI_TCP6_PROTOCOL *This,
681 IN EFI_TCP6_IO_TOKEN *Token
682 );
683
684 /**
685 Disconnecting a TCP connection gracefully or reset a TCP connection. This function is a
686 nonblocking operation.
687
688 Initiate an asynchronous close token to the TCP driver. After Close() is called, any buffered
689 transmission data will be sent by the TCP driver, and the current instance will have a graceful close
690 working flow described as RFC 793 if AbortOnClose is set to FALSE, otherwise, a rest packet
691 will be sent by TCP driver to fast disconnect this connection. When the close operation completes
692 successfully the TCP instance is in Tcp6StateClosed state, all pending asynchronous
693 operations are signaled, and any buffers used for TCP network traffic are flushed.
694
695 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
696 @param[in] CloseToken Pointer to the close token to return when operation finishes.
697
698 @retval EFI_SUCCESS The Close() was called successfully.
699 @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.
700 @retval EFI_ACCESS_DENIED One or more of the following are TRUE:
701 - CloseToken or CloseToken->CompletionToken.Event is already in use.
702 - Previous Close() call on this instance has not finished.
703 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
704 - This is NULL.
705 - CloseToken is NULL.
706 - CloseToken->CompletionToken.Event is NULL.
707 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resources to finish the operation.
708 @retval EFI_DEVICE_ERROR Any unexpected error not belonging to the error categories given above.
709
710 **/
711 EFI_STATUS
712 EFIAPI
713 Tcp6Close (
714 IN EFI_TCP6_PROTOCOL *This,
715 IN EFI_TCP6_CLOSE_TOKEN *CloseToken
716 );
717
718 /**
719 Abort an asynchronous connection, listen, transmission or receive request.
720
721 The Cancel() function aborts a pending connection, listen, transmit or
722 receive request.
723
724 If Token is not NULL and the token is in the connection, listen, transmission
725 or receive queue when it is being cancelled, its Token->Status will be set
726 to EFI_ABORTED and then Token->Event will be signaled.
727
728 If the token is not in one of the queues, which usually means that the
729 asynchronous operation has completed, EFI_NOT_FOUND is returned.
730
731 If Token is NULL all asynchronous token issued by Connect(), Accept(),
732 Transmit() and Receive() will be aborted.
733
734 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
735 @param[in] Token Pointer to a token that has been issued by
736 EFI_TCP6_PROTOCOL.Connect(),
737 EFI_TCP6_PROTOCOL.Accept(),
738 EFI_TCP6_PROTOCOL.Transmit() or
739 EFI_TCP6_PROTOCOL.Receive(). If NULL, all pending
740 tokens issued by above four functions will be aborted. Type
741 EFI_TCP6_COMPLETION_TOKEN is defined in
742 EFI_TCP_PROTOCOL.Connect().
743
744 @retval EFI_SUCCESS The asynchronous I/O request is aborted and Token->Event
745 is signaled.
746 @retval EFI_INVALID_PARAMETER This is NULL.
747 @retval EFI_NOT_STARTED This instance hasn't been configured.
748 @retval EFI_NOT_FOUND The asynchronous I/O request isn't found in the transmission or
749 receive queue. It has either completed or wasn't issued by
750 Transmit() and Receive().
751
752 **/
753 EFI_STATUS
754 EFIAPI
755 Tcp6Cancel (
756 IN EFI_TCP6_PROTOCOL *This,
757 IN EFI_TCP6_COMPLETION_TOKEN *Token OPTIONAL
758 );
759
760 /**
761 Poll to receive incoming data and transmit outgoing segments.
762
763 The Poll() function increases the rate that data is moved between the network
764 and application and can be called when the TCP instance is created successfully.
765 Its use is optional.
766
767 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
768
769 @retval EFI_SUCCESS Incoming or outgoing data was processed.
770 @retval EFI_INVALID_PARAMETER This is NULL.
771 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
772 @retval EFI_NOT_READY No incoming or outgoing data is processed.
773 @retval EFI_TIMEOUT Data was dropped out of the transmission or receive queue.
774 Consider increasing the polling rate.
775
776 **/
777 EFI_STATUS
778 EFIAPI
779 Tcp6Poll (
780 IN EFI_TCP6_PROTOCOL *This
781 );
782
783 #endif