2 Implementation of EFI_TCP4_PROTOCOL and EFI_TCP6_PROTOCOL.
4 (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>
5 Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>
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.
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.
20 Check the integrity of the data buffer.
22 @param[in] DataLen The total length of the data buffer.
23 @param[in] FragmentCount The fragment count of the fragment table.
24 @param[in] FragmentTable Pointer to the fragment table of the data
27 @retval EFI_SUCCESS The integrity check passed.
28 @retval EFI_INVALID_PARAMETER The integrity check failed.
34 IN UINT32 FragmentCount
,
35 IN EFI_TCP4_FRAGMENT_DATA
*FragmentTable
42 for (Index
= 0, Len
= 0; Index
< FragmentCount
; Index
++) {
43 Len
= Len
+ FragmentTable
[Index
].FragmentLength
;
47 return EFI_INVALID_PARAMETER
;
54 Get the current operational status.
56 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
57 @param[out] Tcp4State Pointer to the buffer to receive the current TCP
58 state. Optional parameter that may be NULL.
59 @param[out] Tcp4ConfigData Pointer to the buffer to receive the current TCP
60 configuration. Optional parameter that may be NULL.
61 @param[out] Ip4ModeData Pointer to the buffer to receive the current
62 IPv4 configuration. Optional parameter that may be NULL.
63 @param[out] MnpConfigData Pointer to the buffer to receive the current MNP
64 configuration data indirectly used by the TCPv4
65 Instance. Optional parameter that may be NULL.
66 @param[out] SnpModeData Pointer to the buffer to receive the current SNP
67 configuration data indirectly used by the TCPv4
68 Instance. Optional parameter that may be NULL.
70 @retval EFI_SUCCESS The mode data was read.
71 @retval EFI_NOT_STARTED No configuration data is available because this
72 instance hasn't been started.
73 @retval EFI_INVALID_PARAMETER This is NULL.
79 IN EFI_TCP4_PROTOCOL
*This
,
80 OUT EFI_TCP4_CONNECTION_STATE
*Tcp4State OPTIONAL
,
81 OUT EFI_TCP4_CONFIG_DATA
*Tcp4ConfigData OPTIONAL
,
82 OUT EFI_IP4_MODE_DATA
*Ip4ModeData OPTIONAL
,
83 OUT EFI_MANAGED_NETWORK_CONFIG_DATA
*MnpConfigData OPTIONAL
,
84 OUT EFI_SIMPLE_NETWORK_MODE
*SnpModeData OPTIONAL
87 TCP4_MODE_DATA TcpMode
;
91 return EFI_INVALID_PARAMETER
;
94 Sock
= SOCK_FROM_THIS (This
);
96 TcpMode
.Tcp4State
= Tcp4State
;
97 TcpMode
.Tcp4ConfigData
= Tcp4ConfigData
;
98 TcpMode
.Ip4ModeData
= Ip4ModeData
;
99 TcpMode
.MnpConfigData
= MnpConfigData
;
100 TcpMode
.SnpModeData
= SnpModeData
;
102 return SockGetMode (Sock
, &TcpMode
);
106 Initialize or brutally reset the operational parameters for
107 this EFI TCPv4 instance.
109 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
110 @param[in] TcpConfigData Pointer to the configure data to configure the
111 instance. Optional parameter that may be NULL.
113 @retval EFI_SUCCESS The operational settings were set, changed, or
115 @retval EFI_NO_MAPPING When using a default address, configuration
116 (through DHCP, BOOTP, RARP, etc.) is not
118 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
119 @retval EFI_ACCESS_DENIED Configuring TCP instance when it is already
121 @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.
122 @retval EFI_UNSUPPORTED One or more of the control options are not
123 supported in the implementation.
124 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources.
130 IN EFI_TCP4_PROTOCOL
* This
,
131 IN EFI_TCP4_CONFIG_DATA
* TcpConfigData OPTIONAL
134 EFI_TCP4_OPTION
*Option
;
141 return EFI_INVALID_PARAMETER
;
145 // Tcp protocol related parameter check will be conducted here
147 if (NULL
!= TcpConfigData
) {
149 CopyMem (&Ip
, &TcpConfigData
->AccessPoint
.RemoteAddress
, sizeof (IP4_ADDR
));
150 if ((Ip
!= 0) && !NetIp4IsUnicast (NTOHL (Ip
), 0)) {
151 return EFI_INVALID_PARAMETER
;
154 if (TcpConfigData
->AccessPoint
.ActiveFlag
&& (0 == TcpConfigData
->AccessPoint
.RemotePort
|| (Ip
== 0))) {
155 return EFI_INVALID_PARAMETER
;
158 if (!TcpConfigData
->AccessPoint
.UseDefaultAddress
) {
160 CopyMem (&Ip
, &TcpConfigData
->AccessPoint
.StationAddress
, sizeof (IP4_ADDR
));
161 CopyMem (&SubnetMask
, &TcpConfigData
->AccessPoint
.SubnetMask
, sizeof (IP4_ADDR
));
162 if (!NetIp4IsUnicast (NTOHL (Ip
), 0) || !IP4_IS_VALID_NETMASK (NTOHL (SubnetMask
))) {
163 return EFI_INVALID_PARAMETER
;
167 Option
= TcpConfigData
->ControlOption
;
168 if ((NULL
!= Option
) && (Option
->EnableSelectiveAck
|| Option
->EnablePathMtuDiscovery
)) {
169 return EFI_UNSUPPORTED
;
173 Sock
= SOCK_FROM_THIS (This
);
175 if (NULL
== TcpConfigData
) {
176 return SockFlush (Sock
);
179 Status
= SockConfigure (Sock
, TcpConfigData
);
181 if (EFI_NO_MAPPING
== Status
) {
182 Sock
->ConfigureState
= SO_NO_MAPPING
;
189 Add or delete routing entries.
191 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
192 @param[in] DeleteRoute If TRUE, delete the specified route from routing
193 table; if FALSE, add the specified route to
195 @param[in] SubnetAddress The destination network.
196 @param[in] SubnetMask The subnet mask for the destination network.
197 @param[in] GatewayAddress The gateway address for this route.
199 @retval EFI_SUCCESS The operation completed successfully.
200 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance has not been
202 @retval EFI_NO_MAPPING When using a default address, configuration
203 (through DHCP, BOOTP, RARP, etc.) is not
205 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
206 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resources to add the
207 entry to the routing table.
208 @retval EFI_NOT_FOUND This route is not in the routing table.
209 @retval EFI_ACCESS_DENIED This route is already in the routing table.
210 @retval EFI_UNSUPPORTED The TCP driver does not support this operation.
216 IN EFI_TCP4_PROTOCOL
*This
,
217 IN BOOLEAN DeleteRoute
,
218 IN EFI_IPv4_ADDRESS
*SubnetAddress
,
219 IN EFI_IPv4_ADDRESS
*SubnetMask
,
220 IN EFI_IPv4_ADDRESS
*GatewayAddress
224 TCP4_ROUTE_INFO RouteInfo
;
227 return EFI_INVALID_PARAMETER
;
230 Sock
= SOCK_FROM_THIS (This
);
232 RouteInfo
.DeleteRoute
= DeleteRoute
;
233 RouteInfo
.SubnetAddress
= SubnetAddress
;
234 RouteInfo
.SubnetMask
= SubnetMask
;
235 RouteInfo
.GatewayAddress
= GatewayAddress
;
237 return SockRoute (Sock
, &RouteInfo
);
241 Initiate a non-blocking TCP connection request for an active TCP instance.
243 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
244 @param[in] ConnectionToken Pointer to the connection token to return when
245 the TCP three way handshake finishes.
247 @retval EFI_SUCCESS The connection request successfully
249 @retval EFI_NOT_STARTED This EFI_TCP4_PROTOCOL instance hasn't been
251 @retval EFI_ACCESS_DENIED The instance is not configured as an active one,
252 or it is not in Tcp4StateClosed state.
253 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
254 @retval EFI_OUT_OF_RESOURCES The driver can't allocate enough resources to
255 initiate the active open.
256 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
262 IN EFI_TCP4_PROTOCOL
*This
,
263 IN EFI_TCP4_CONNECTION_TOKEN
*ConnectionToken
268 if (NULL
== This
|| NULL
== ConnectionToken
|| NULL
== ConnectionToken
->CompletionToken
.Event
) {
269 return EFI_INVALID_PARAMETER
;
272 Sock
= SOCK_FROM_THIS (This
);
274 return SockConnect (Sock
, ConnectionToken
);
278 Listen on the passive instance to accept an incoming connection request.
280 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
281 @param[in] ListenToken Pointer to the listen token to return when
284 @retval EFI_SUCCESS The listen token was queued successfully.
285 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been
287 @retval EFI_ACCESS_DENIED The instatnce is not a passive one or it is not
288 in Tcp4StateListen state or a same listen token
289 has already existed in the listen token queue of
291 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
292 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resources to finish
294 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
300 IN EFI_TCP4_PROTOCOL
*This
,
301 IN EFI_TCP4_LISTEN_TOKEN
*ListenToken
306 if (NULL
== This
|| NULL
== ListenToken
|| NULL
== ListenToken
->CompletionToken
.Event
) {
307 return EFI_INVALID_PARAMETER
;
310 Sock
= SOCK_FROM_THIS (This
);
312 return SockAccept (Sock
, ListenToken
);
316 Queues outgoing data into the transmit queue
318 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
319 @param[in] Token Pointer to the completion token to queue to the
322 @retval EFI_SUCCESS The data has been queued for transmission.
323 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been
325 @retval EFI_NO_MAPPING When using a default address, configuration
326 (DHCP, BOOTP, RARP, etc.) is not finished yet.
327 @retval EFI_INVALID_PARAMETER One or more parameters are invalid
328 @retval EFI_ACCESS_DENIED One or more of the following conditions is TRUE:
329 * A transmit completion token with the same
330 Token-> CompletionToken.Event was already in the
331 transmission queue. * The current instance is in
332 Tcp4StateClosed state. * The current instance is
333 a passive one and it is in Tcp4StateListen
334 state. * User has called Close() to disconnect
336 @retval EFI_NOT_READY The completion token could not be queued because
337 the transmit queue is full.
338 @retval EFI_OUT_OF_RESOURCES Could not queue the transmit data because of a
340 @retval EFI_NETWORK_UNREACHABLE There is no route to the destination network or
347 IN EFI_TCP4_PROTOCOL
*This
,
348 IN EFI_TCP4_IO_TOKEN
*Token
356 NULL
== Token
->CompletionToken
.Event
||
357 NULL
== Token
->Packet
.TxData
||
358 0 == Token
->Packet
.TxData
->FragmentCount
||
359 0 == Token
->Packet
.TxData
->DataLength
361 return EFI_INVALID_PARAMETER
;
364 Status
= TcpChkDataBuf (
365 Token
->Packet
.TxData
->DataLength
,
366 Token
->Packet
.TxData
->FragmentCount
,
367 Token
->Packet
.TxData
->FragmentTable
369 if (EFI_ERROR (Status
)) {
373 Sock
= SOCK_FROM_THIS (This
);
375 return SockSend (Sock
, Token
);
379 Place an asynchronous receive request into the receiving queue.
381 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
382 @param[in] Token Pointer to a token that is associated with the
383 receive data descriptor.
385 @retval EFI_SUCCESS The receive completion token was cached
386 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been
388 @retval EFI_NO_MAPPING When using a default address, configuration
389 (DHCP, BOOTP, RARP, etc.) is not finished yet.
390 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
391 @retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued
392 due to a lack of system resources.
393 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
394 @retval EFI_ACCESS_DENIED One or more of the following conditions is TRUE:
395 * A receive completion token with the same
396 Token->CompletionToken.Event was already in the
397 receive queue. * The current instance is in
398 Tcp4StateClosed state. * The current instance is
399 a passive one and it is in Tcp4StateListen
400 state. * User has called Close() to disconnect
402 @retval EFI_CONNECTION_FIN The communication peer has closed the connection,
403 and there is no any buffered data in the receive
404 buffer of this instance.
405 @retval EFI_NOT_READY The receive request could not be queued because
406 the receive queue is full.
412 IN EFI_TCP4_PROTOCOL
*This
,
413 IN EFI_TCP4_IO_TOKEN
*Token
421 NULL
== Token
->CompletionToken
.Event
||
422 NULL
== Token
->Packet
.RxData
||
423 0 == Token
->Packet
.RxData
->FragmentCount
||
424 0 == Token
->Packet
.RxData
->DataLength
426 return EFI_INVALID_PARAMETER
;
429 Status
= TcpChkDataBuf (
430 Token
->Packet
.RxData
->DataLength
,
431 Token
->Packet
.RxData
->FragmentCount
,
432 Token
->Packet
.RxData
->FragmentTable
434 if (EFI_ERROR (Status
)) {
438 Sock
= SOCK_FROM_THIS (This
);
440 return SockRcv (Sock
, Token
);
445 Disconnecting a TCP connection gracefully or reset a TCP connection.
447 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
448 @param[in] CloseToken Pointer to the close token to return when
451 @retval EFI_SUCCESS The operation completed successfully.
452 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been
454 @retval EFI_ACCESS_DENIED One or more of the following are TRUE: *
455 Configure() has been called with TcpConfigData
456 set to NULL, and this function has not returned.
457 * Previous Close() call on this instance has not
459 @retval EFI_INVALID_PARAMETER One ore more parameters are invalid.
460 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resources to finish the
462 @retval EFI_DEVICE_ERROR Any unexpected category error not belonging to those
469 IN EFI_TCP4_PROTOCOL
*This
,
470 IN EFI_TCP4_CLOSE_TOKEN
*CloseToken
475 if (NULL
== This
|| NULL
== CloseToken
|| NULL
== CloseToken
->CompletionToken
.Event
) {
476 return EFI_INVALID_PARAMETER
;
479 Sock
= SOCK_FROM_THIS (This
);
481 return SockClose (Sock
, CloseToken
, CloseToken
->AbortOnClose
);
485 Abort an asynchronous connection, listen, transmission or receive request.
487 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
488 @param[in] Token Pointer to a token that has been issued by
489 Connect(), Accept(), Transmit() or Receive(). If
490 NULL, all pending tokens issued by the four
491 functions listed above will be aborted.
493 @retval EFI_UNSUPPORTED The operation is not supported in the current
500 IN EFI_TCP4_PROTOCOL
*This
,
501 IN EFI_TCP4_COMPLETION_TOKEN
*Token OPTIONAL
504 return EFI_UNSUPPORTED
;
508 Poll to receive incoming data and transmit outgoing segments.
510 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
512 @retval EFI_SUCCESS Incoming or outgoing data was processed.
513 @retval EFI_INVALID_PARAMETER This is NULL.
514 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
515 @retval EFI_NOT_READY No incoming or outgoing data was processed.
516 @retval EFI_TIMEOUT Data was dropped out of the transmission or
517 receive queue. Consider increasing the polling
524 IN EFI_TCP4_PROTOCOL
*This
531 return EFI_INVALID_PARAMETER
;
534 Sock
= SOCK_FROM_THIS (This
);
536 Status
= Sock
->ProtoHandler (Sock
, SOCK_POLL
, NULL
);
542 Get the current operational status.
544 The GetModeData() function copies the current operational settings of this EFI TCPv6
545 Protocol instance into user-supplied buffers. This function can also be used to retrieve
546 the operational setting of underlying drivers such as IPv6, MNP, or SNP.
548 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
549 @param[out] Tcp6State The buffer in which the current TCP state is
550 returned. Optional parameter that may be NULL.
551 @param[out] Tcp6ConfigData The buffer in which the current TCP configuration
552 is returned. Optional parameter that may be NULL.
553 @param[out] Ip6ModeData The buffer in which the current IPv6 configuration
554 data used by the TCP instance is returned.
555 Optional parameter that may be NULL.
556 @param[out] MnpConfigData The buffer in which the current MNP configuration
557 data indirectly used by the TCP instance is returned.
558 Optional parameter that may be NULL.
559 @param[out] SnpModeData The buffer in which the current SNP mode data
560 indirectly used by the TCP instance is returned.
561 Optional parameter that may be NULL.
563 @retval EFI_SUCCESS The mode data was read.
564 @retval EFI_NOT_STARTED No configuration data is available because this instance hasn't
566 @retval EFI_INVALID_PARAMETER This is NULL.
572 IN EFI_TCP6_PROTOCOL
*This
,
573 OUT EFI_TCP6_CONNECTION_STATE
*Tcp6State OPTIONAL
,
574 OUT EFI_TCP6_CONFIG_DATA
*Tcp6ConfigData OPTIONAL
,
575 OUT EFI_IP6_MODE_DATA
*Ip6ModeData OPTIONAL
,
576 OUT EFI_MANAGED_NETWORK_CONFIG_DATA
*MnpConfigData OPTIONAL
,
577 OUT EFI_SIMPLE_NETWORK_MODE
*SnpModeData OPTIONAL
580 TCP6_MODE_DATA TcpMode
;
584 return EFI_INVALID_PARAMETER
;
587 Sock
= SOCK_FROM_THIS (This
);
589 TcpMode
.Tcp6State
= Tcp6State
;
590 TcpMode
.Tcp6ConfigData
= Tcp6ConfigData
;
591 TcpMode
.Ip6ModeData
= Ip6ModeData
;
592 TcpMode
.MnpConfigData
= MnpConfigData
;
593 TcpMode
.SnpModeData
= SnpModeData
;
595 return SockGetMode (Sock
, &TcpMode
);
599 Initialize or brutally reset the operational parameters for this EFI TCPv6 instance.
601 The Configure() function does the following:
602 - Initialize this TCP instance, i.e., initialize the communication end settings and
603 specify active open or passive open for an instance.
604 - Reset this TCP instance brutally, i.e., cancel all pending asynchronous tokens, flush
605 transmission and receiving buffer directly without informing the communication peer.
607 No other TCPv6 Protocol operation except Poll() can be executed by this instance until
608 it is configured properly. For an active TCP instance, after a proper configuration it
609 may call Connect() to initiate a three-way handshake. For a passive TCP instance,
610 its state transits to Tcp6StateListen after configuration, and Accept() may be
611 called to listen the incoming TCP connection requests. If Tcp6ConfigData is set to NULL,
612 the instance is reset. The resetting process will be done brutally, the state machine will
613 be set to Tcp6StateClosed directly, the receive queue and transmit queue will be flushed,
614 and no traffic is allowed through this instance.
616 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
617 @param[in] Tcp6ConfigData Pointer to the configure data to configure the instance.
618 If Tcp6ConfigData is set to NULL, the instance is reset.
620 @retval EFI_SUCCESS The operational settings were set, changed, or reset
622 @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a source
623 address for this instance, but no source address was available for
625 @retval EFI_INVALID_PARAMETER One or more of the following conditions are TRUE:
627 - Tcp6ConfigData->AccessPoint.StationAddress is neither zero nor
628 one of the configured IP addresses in the underlying IPv6 driver.
629 - Tcp6ConfigData->AccessPoint.RemoteAddress isn't a valid unicast
631 - Tcp6ConfigData->AccessPoint.RemoteAddress is zero or
632 Tcp6ConfigData->AccessPoint.RemotePort is zero when
633 Tcp6ConfigData->AccessPoint.ActiveFlag is TRUE.
634 - A same access point has been configured in other TCP
636 @retval EFI_ACCESS_DENIED Configuring a TCP instance when it is configured without
637 calling Configure() with NULL to reset it.
638 @retval EFI_UNSUPPORTED One or more of the control options are not supported in
640 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources when
641 executing Configure().
642 @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.
648 IN EFI_TCP6_PROTOCOL
*This
,
649 IN EFI_TCP6_CONFIG_DATA
*Tcp6ConfigData OPTIONAL
652 EFI_TCP6_OPTION
*Option
;
655 EFI_IPv6_ADDRESS
*Ip
;
658 return EFI_INVALID_PARAMETER
;
662 // Tcp protocol related parameter check will be conducted here
664 if (NULL
!= Tcp6ConfigData
) {
666 Ip
= &Tcp6ConfigData
->AccessPoint
.RemoteAddress
;
667 if (!NetIp6IsUnspecifiedAddr (Ip
) && !NetIp6IsValidUnicast (Ip
)) {
668 return EFI_INVALID_PARAMETER
;
671 if (Tcp6ConfigData
->AccessPoint
.ActiveFlag
&&
672 (0 == Tcp6ConfigData
->AccessPoint
.RemotePort
|| NetIp6IsUnspecifiedAddr (Ip
))
674 return EFI_INVALID_PARAMETER
;
677 Ip
= &Tcp6ConfigData
->AccessPoint
.StationAddress
;
678 if (!NetIp6IsUnspecifiedAddr (Ip
) && !NetIp6IsValidUnicast (Ip
)) {
679 return EFI_INVALID_PARAMETER
;
682 Option
= Tcp6ConfigData
->ControlOption
;
683 if ((NULL
!= Option
) && (Option
->EnableSelectiveAck
|| Option
->EnablePathMtuDiscovery
)) {
684 return EFI_UNSUPPORTED
;
688 Sock
= SOCK_FROM_THIS (This
);
690 if (NULL
== Tcp6ConfigData
) {
691 return SockFlush (Sock
);
694 Status
= SockConfigure (Sock
, Tcp6ConfigData
);
696 if (EFI_NO_MAPPING
== Status
) {
697 Sock
->ConfigureState
= SO_NO_MAPPING
;
704 Initiate a nonblocking TCP connection request for an active TCP instance.
706 The Connect() function will initiate an active open to the remote peer configured
707 in a current TCP instance if it is configured active. If the connection succeeds or
708 fails due to any error, the ConnectionToken->CompletionToken.Event will be signaled
709 and ConnectionToken->CompletionToken.Status will be updated accordingly. This
710 function can only be called for the TCP instance in the Tcp6StateClosed state. The
711 instance will transfer into Tcp6StateSynSent if the function returns EFI_SUCCESS.
712 If a TCP three-way handshake succeeds, its state will become Tcp6StateEstablished.
713 Otherwise, the state will return to Tcp6StateClosed.
715 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
716 @param[in] ConnectionToken Pointer to the connection token to return when the TCP three
717 way handshake finishes.
719 @retval EFI_SUCCESS The connection request successfully initiated and the state of
720 this TCP instance has been changed to Tcp6StateSynSent.
721 @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.
722 @retval EFI_ACCESS_DENIED One or more of the following conditions are TRUE:
723 - This instance is not configured as an active one.
724 - This instance is not in Tcp6StateClosed state.
725 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
727 - ConnectionToken is NULL.
728 - ConnectionToken->CompletionToken.Event is NULL.
729 @retval EFI_OUT_OF_RESOURCES The driver can't allocate enough resources to initiate the active open.
730 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
736 IN EFI_TCP6_PROTOCOL
*This
,
737 IN EFI_TCP6_CONNECTION_TOKEN
*ConnectionToken
742 if (NULL
== This
|| NULL
== ConnectionToken
|| NULL
== ConnectionToken
->CompletionToken
.Event
) {
743 return EFI_INVALID_PARAMETER
;
746 Sock
= SOCK_FROM_THIS (This
);
748 return SockConnect (Sock
, ConnectionToken
);
752 Listen on the passive instance to accept an incoming connection request. This is a
753 nonblocking operation.
755 The Accept() function initiates an asynchronous accept request to wait for an incoming
756 connection on the passive TCP instance. If a remote peer successfully establishes a
757 connection with this instance, a new TCP instance will be created and its handle will
758 be returned in ListenToken->NewChildHandle. The newly created instance is configured
759 by inheriting the passive instance's configuration and is ready for use upon return.
760 The new instance is in the Tcp6StateEstablished state.
762 The ListenToken->CompletionToken.Event will be signaled when a new connection is
763 accepted, when a user aborts the listen or when a connection is reset.
765 This function only can be called when a current TCP instance is in Tcp6StateListen state.
767 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
768 @param[in] ListenToken Pointer to the listen token to return when operation finishes.
771 @retval EFI_SUCCESS The listen token queued successfully.
772 @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.
773 @retval EFI_ACCESS_DENIED One or more of the following are TRUE:
774 - This instance is not a passive instance.
775 - This instance is not in Tcp6StateListen state.
776 - The same listen token has already existed in the listen
777 token queue of this TCP instance.
778 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
780 - ListenToken is NULL.
781 - ListentToken->CompletionToken.Event is NULL.
782 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resource to finish the operation.
783 @retval EFI_DEVICE_ERROR Any unexpected error not belonging to a category listed above.
789 IN EFI_TCP6_PROTOCOL
*This
,
790 IN EFI_TCP6_LISTEN_TOKEN
*ListenToken
795 if (NULL
== This
|| NULL
== ListenToken
|| NULL
== ListenToken
->CompletionToken
.Event
) {
796 return EFI_INVALID_PARAMETER
;
799 Sock
= SOCK_FROM_THIS (This
);
801 return SockAccept (Sock
, ListenToken
);
805 Queues outgoing data into the transmit queue.
807 The Transmit() function queues a sending request to this TCP instance along with the
808 user data. The status of the token is updated and the event in the token will be
809 signaled once the data is sent out or an error occurs.
811 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
812 @param[in] Token Pointer to the completion token to queue to the transmit queue.
814 @retval EFI_SUCCESS The data has been queued for transmission.
815 @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.
816 @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a
817 source address for this instance, but no source address was
819 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
822 - Token->CompletionToken.Event is NULL.
823 - Token->Packet.TxData is NULL.
824 - Token->Packet.FragmentCount is zero.
825 - Token->Packet.DataLength is not equal to the sum of fragment lengths.
826 @retval EFI_ACCESS_DENIED One or more of the following conditions are TRUE:
827 - A transmit completion token with the same Token->
828 CompletionToken.Event was already in the
830 - The current instance is in Tcp6StateClosed state.
831 - The current instance is a passive one and it is in
832 Tcp6StateListen state.
833 - User has called Close() to disconnect this connection.
834 @retval EFI_NOT_READY The completion token could not be queued because the
835 transmit queue is full.
836 @retval EFI_OUT_OF_RESOURCES Could not queue the transmit data because of resource
838 @retval EFI_NETWORK_UNREACHABLE There is no route to the destination network or address.
844 IN EFI_TCP6_PROTOCOL
*This
,
845 IN EFI_TCP6_IO_TOKEN
*Token
853 NULL
== Token
->CompletionToken
.Event
||
854 NULL
== Token
->Packet
.TxData
||
855 0 == Token
->Packet
.TxData
->FragmentCount
||
856 0 == Token
->Packet
.TxData
->DataLength
858 return EFI_INVALID_PARAMETER
;
861 Status
= TcpChkDataBuf (
862 Token
->Packet
.TxData
->DataLength
,
863 Token
->Packet
.TxData
->FragmentCount
,
864 (EFI_TCP4_FRAGMENT_DATA
*) Token
->Packet
.TxData
->FragmentTable
866 if (EFI_ERROR (Status
)) {
870 Sock
= SOCK_FROM_THIS (This
);
872 return SockSend (Sock
, Token
);
876 Places an asynchronous receive request into the receiving queue.
878 The Receive() function places a completion token into the receive packet queue. This
879 function is always asynchronous. The caller must allocate the Token->CompletionToken.Event
880 and the FragmentBuffer used to receive data. The caller also must fill the DataLength that
881 represents the whole length of all FragmentBuffer. When the receive operation completes, the
882 EFI TCPv6 Protocol driver updates the Token->CompletionToken.Status and Token->Packet.RxData
883 fields, and the Token->CompletionToken.Event is signaled. If data obtained, the data and its length
884 will be copied into the FragmentTable; at the same time the full length of received data will
885 be recorded in the DataLength fields. Providing a proper notification function and context
886 for the event enables the user to receive the notification and receiving status. That
887 notification function is guaranteed to not be re-entered.
889 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
890 @param[in] Token Pointer to a token that is associated with the receive data
893 @retval EFI_SUCCESS The receive completion token was cached.
894 @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.
895 @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a source
896 address for this instance, but no source address was available for use.
897 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
900 - Token->CompletionToken.Event is NULL.
901 - Token->Packet.RxData is NULL.
902 - Token->Packet.RxData->DataLength is 0.
903 - The Token->Packet.RxData->DataLength is not the
904 sum of all FragmentBuffer length in FragmentTable.
905 @retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued due to a lack of
906 system resources (usually memory).
907 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
908 The EFI TCPv6 Protocol instance has been reset to startup defaults.
909 @retval EFI_ACCESS_DENIED One or more of the following conditions is TRUE:
910 - A receive completion token with the same Token->CompletionToken.Event
911 was already in the receive queue.
912 - The current instance is in Tcp6StateClosed state.
913 - The current instance is a passive one and it is in
914 Tcp6StateListen state.
915 - User has called Close() to disconnect this connection.
916 @retval EFI_CONNECTION_FIN The communication peer has closed the connection and there is no
917 buffered data in the receive buffer of this instance.
918 @retval EFI_NOT_READY The receive request could not be queued because the receive queue is full.
924 IN EFI_TCP6_PROTOCOL
*This
,
925 IN EFI_TCP6_IO_TOKEN
*Token
933 NULL
== Token
->CompletionToken
.Event
||
934 NULL
== Token
->Packet
.RxData
||
935 0 == Token
->Packet
.RxData
->FragmentCount
||
936 0 == Token
->Packet
.RxData
->DataLength
938 return EFI_INVALID_PARAMETER
;
941 Status
= TcpChkDataBuf (
942 Token
->Packet
.RxData
->DataLength
,
943 Token
->Packet
.RxData
->FragmentCount
,
944 (EFI_TCP4_FRAGMENT_DATA
*) Token
->Packet
.RxData
->FragmentTable
946 if (EFI_ERROR (Status
)) {
950 Sock
= SOCK_FROM_THIS (This
);
952 return SockRcv (Sock
, Token
);
956 Disconnecting a TCP connection gracefully or reset a TCP connection. This function is a
957 nonblocking operation.
959 Initiate an asynchronous close token to the TCP driver. After Close() is called, any buffered
960 transmission data will be sent by the TCP driver, and the current instance will have a graceful close
961 working flow described as RFC 793 if AbortOnClose is set to FALSE. Otherwise, a rest packet
962 will be sent by TCP driver to fast disconnect this connection. When the close operation completes
963 successfully the TCP instance is in Tcp6StateClosed state, all pending asynchronous
964 operations are signaled, and any buffers used for TCP network traffic are flushed.
966 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
967 @param[in] CloseToken Pointer to the close token to return when operation finishes.
969 @retval EFI_SUCCESS The Close() was called successfully.
970 @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.
971 @retval EFI_ACCESS_DENIED One or more of the following are TRUE:
972 - CloseToken or CloseToken->CompletionToken.Event is already in use.
973 - Previous Close() call on this instance has not finished.
974 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
976 - CloseToken is NULL.
977 - CloseToken->CompletionToken.Event is NULL.
978 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resource to finish the operation.
979 @retval EFI_DEVICE_ERROR Any unexpected error not belonging to error categories given above.
985 IN EFI_TCP6_PROTOCOL
*This
,
986 IN EFI_TCP6_CLOSE_TOKEN
*CloseToken
991 if (NULL
== This
|| NULL
== CloseToken
|| NULL
== CloseToken
->CompletionToken
.Event
) {
992 return EFI_INVALID_PARAMETER
;
995 Sock
= SOCK_FROM_THIS (This
);
997 return SockClose (Sock
, CloseToken
, CloseToken
->AbortOnClose
);
1001 Abort an asynchronous connection, listen, transmission, or receive request.
1003 The Cancel() function aborts a pending connection, listen, transmit, or
1006 If Token is not NULL and the token is in the connection, listen, transmission,
1007 or receive queue when it is being cancelled, its Token->Status will be set
1008 to EFI_ABORTED, and then Token->Event will be signaled.
1010 If the token is not in one of the queues, which usually means that the
1011 asynchronous operation has completed, EFI_NOT_FOUND is returned.
1013 If Token is NULL all asynchronous token issued by Connect(), Accept(),
1014 Transmit(), and Receive() will be aborted.
1016 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
1017 @param[in] Token Pointer to a token that has been issued by
1018 EFI_TCP6_PROTOCOL.Connect(),
1019 EFI_TCP6_PROTOCOL.Accept(),
1020 EFI_TCP6_PROTOCOL.Transmit() or
1021 EFI_TCP6_PROTOCOL.Receive(). If NULL, all pending
1022 tokens issued by above four functions will be aborted. Type
1023 EFI_TCP6_COMPLETION_TOKEN is defined in
1024 EFI_TCP_PROTOCOL.Connect().
1026 @retval EFI_UNSUPPORTED The implementation does not support this function.
1032 IN EFI_TCP6_PROTOCOL
*This
,
1033 IN EFI_TCP6_COMPLETION_TOKEN
*Token OPTIONAL
1036 return EFI_UNSUPPORTED
;
1040 Poll to receive incoming data and transmit outgoing segments.
1042 The Poll() function increases the rate that data is moved between the network
1043 and application, and can be called when the TCP instance is created successfully.
1044 Its use is optional.
1046 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
1048 @retval EFI_SUCCESS Incoming or outgoing data was processed.
1049 @retval EFI_INVALID_PARAMETER This is NULL.
1050 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
1051 @retval EFI_NOT_READY No incoming or outgoing data is processed.
1052 @retval EFI_TIMEOUT Data was dropped out of the transmission or receive queue.
1053 Consider increasing the polling rate.
1059 IN EFI_TCP6_PROTOCOL
*This
1066 return EFI_INVALID_PARAMETER
;
1069 Sock
= SOCK_FROM_THIS (This
);
1071 Status
= Sock
->ProtoHandler (Sock
, SOCK_POLL
, NULL
);