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 - 2016, 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 This The pointer to the EFI_TCP4_PROTOCOL instance.
488 @param Token The pointer to a token that has been issued by
489 EFI_TCP4_PROTOCOL.Connect(),
490 EFI_TCP4_PROTOCOL.Accept(),
491 EFI_TCP4_PROTOCOL.Transmit() or
492 EFI_TCP4_PROTOCOL.Receive(). If NULL, all pending
493 tokens issued by above four functions will be aborted. Type
494 EFI_TCP4_COMPLETION_TOKEN is defined in
495 EFI_TCP4_PROTOCOL.Connect().
497 @retval EFI_SUCCESS The asynchronous I/O request is aborted and Token->Event
499 @retval EFI_INVALID_PARAMETER This is NULL.
500 @retval EFI_NOT_STARTED This instance hasn't been configured.
501 @retval EFI_NO_MAPPING When using the default address, configuration
502 (DHCP, BOOTP,RARP, etc.) hasn't finished yet.
503 @retval EFI_NOT_FOUND The asynchronous I/O request isn't found in the
504 transmission or receive queue. It has either
505 completed or wasn't issued by Transmit() and Receive().
511 IN EFI_TCP4_PROTOCOL
*This
,
512 IN EFI_TCP4_COMPLETION_TOKEN
*Token OPTIONAL
518 return EFI_INVALID_PARAMETER
;
521 Sock
= SOCK_FROM_THIS (This
);
523 return SockCancel (Sock
, Token
);
527 Poll to receive incoming data and transmit outgoing segments.
529 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
531 @retval EFI_SUCCESS Incoming or outgoing data was processed.
532 @retval EFI_INVALID_PARAMETER This is NULL.
533 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
534 @retval EFI_NOT_READY No incoming or outgoing data was processed.
535 @retval EFI_TIMEOUT Data was dropped out of the transmission or
536 receive queue. Consider increasing the polling
543 IN EFI_TCP4_PROTOCOL
*This
550 return EFI_INVALID_PARAMETER
;
553 Sock
= SOCK_FROM_THIS (This
);
555 Status
= Sock
->ProtoHandler (Sock
, SOCK_POLL
, NULL
);
561 Get the current operational status.
563 The GetModeData() function copies the current operational settings of this EFI TCPv6
564 Protocol instance into user-supplied buffers. This function can also be used to retrieve
565 the operational setting of underlying drivers such as IPv6, MNP, or SNP.
567 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
568 @param[out] Tcp6State The buffer in which the current TCP state is
569 returned. Optional parameter that may be NULL.
570 @param[out] Tcp6ConfigData The buffer in which the current TCP configuration
571 is returned. Optional parameter that may be NULL.
572 @param[out] Ip6ModeData The buffer in which the current IPv6 configuration
573 data used by the TCP instance is returned.
574 Optional parameter that may be NULL.
575 @param[out] MnpConfigData The buffer in which the current MNP configuration
576 data indirectly used by the TCP instance is returned.
577 Optional parameter that may be NULL.
578 @param[out] SnpModeData The buffer in which the current SNP mode data
579 indirectly used by the TCP instance is returned.
580 Optional parameter that may be NULL.
582 @retval EFI_SUCCESS The mode data was read.
583 @retval EFI_NOT_STARTED No configuration data is available because this instance hasn't
585 @retval EFI_INVALID_PARAMETER This is NULL.
591 IN EFI_TCP6_PROTOCOL
*This
,
592 OUT EFI_TCP6_CONNECTION_STATE
*Tcp6State OPTIONAL
,
593 OUT EFI_TCP6_CONFIG_DATA
*Tcp6ConfigData OPTIONAL
,
594 OUT EFI_IP6_MODE_DATA
*Ip6ModeData OPTIONAL
,
595 OUT EFI_MANAGED_NETWORK_CONFIG_DATA
*MnpConfigData OPTIONAL
,
596 OUT EFI_SIMPLE_NETWORK_MODE
*SnpModeData OPTIONAL
599 TCP6_MODE_DATA TcpMode
;
603 return EFI_INVALID_PARAMETER
;
606 Sock
= SOCK_FROM_THIS (This
);
608 TcpMode
.Tcp6State
= Tcp6State
;
609 TcpMode
.Tcp6ConfigData
= Tcp6ConfigData
;
610 TcpMode
.Ip6ModeData
= Ip6ModeData
;
611 TcpMode
.MnpConfigData
= MnpConfigData
;
612 TcpMode
.SnpModeData
= SnpModeData
;
614 return SockGetMode (Sock
, &TcpMode
);
618 Initialize or brutally reset the operational parameters for this EFI TCPv6 instance.
620 The Configure() function does the following:
621 - Initialize this TCP instance, i.e., initialize the communication end settings and
622 specify active open or passive open for an instance.
623 - Reset this TCP instance brutally, i.e., cancel all pending asynchronous tokens, flush
624 transmission and receiving buffer directly without informing the communication peer.
626 No other TCPv6 Protocol operation except Poll() can be executed by this instance until
627 it is configured properly. For an active TCP instance, after a proper configuration it
628 may call Connect() to initiate a three-way handshake. For a passive TCP instance,
629 its state transits to Tcp6StateListen after configuration, and Accept() may be
630 called to listen the incoming TCP connection requests. If Tcp6ConfigData is set to NULL,
631 the instance is reset. The resetting process will be done brutally, the state machine will
632 be set to Tcp6StateClosed directly, the receive queue and transmit queue will be flushed,
633 and no traffic is allowed through this instance.
635 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
636 @param[in] Tcp6ConfigData Pointer to the configure data to configure the instance.
637 If Tcp6ConfigData is set to NULL, the instance is reset.
639 @retval EFI_SUCCESS The operational settings were set, changed, or reset
641 @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a source
642 address for this instance, but no source address was available for
644 @retval EFI_INVALID_PARAMETER One or more of the following conditions are TRUE:
646 - Tcp6ConfigData->AccessPoint.StationAddress is neither zero nor
647 one of the configured IP addresses in the underlying IPv6 driver.
648 - Tcp6ConfigData->AccessPoint.RemoteAddress isn't a valid unicast
650 - Tcp6ConfigData->AccessPoint.RemoteAddress is zero or
651 Tcp6ConfigData->AccessPoint.RemotePort is zero when
652 Tcp6ConfigData->AccessPoint.ActiveFlag is TRUE.
653 - A same access point has been configured in other TCP
655 @retval EFI_ACCESS_DENIED Configuring a TCP instance when it is configured without
656 calling Configure() with NULL to reset it.
657 @retval EFI_UNSUPPORTED One or more of the control options are not supported in
659 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources when
660 executing Configure().
661 @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.
667 IN EFI_TCP6_PROTOCOL
*This
,
668 IN EFI_TCP6_CONFIG_DATA
*Tcp6ConfigData OPTIONAL
671 EFI_TCP6_OPTION
*Option
;
674 EFI_IPv6_ADDRESS
*Ip
;
677 return EFI_INVALID_PARAMETER
;
681 // Tcp protocol related parameter check will be conducted here
683 if (NULL
!= Tcp6ConfigData
) {
685 Ip
= &Tcp6ConfigData
->AccessPoint
.RemoteAddress
;
686 if (!NetIp6IsUnspecifiedAddr (Ip
) && !NetIp6IsValidUnicast (Ip
)) {
687 return EFI_INVALID_PARAMETER
;
690 if (Tcp6ConfigData
->AccessPoint
.ActiveFlag
&&
691 (0 == Tcp6ConfigData
->AccessPoint
.RemotePort
|| NetIp6IsUnspecifiedAddr (Ip
))
693 return EFI_INVALID_PARAMETER
;
696 Ip
= &Tcp6ConfigData
->AccessPoint
.StationAddress
;
697 if (!NetIp6IsUnspecifiedAddr (Ip
) && !NetIp6IsValidUnicast (Ip
)) {
698 return EFI_INVALID_PARAMETER
;
701 Option
= Tcp6ConfigData
->ControlOption
;
702 if ((NULL
!= Option
) && (Option
->EnableSelectiveAck
|| Option
->EnablePathMtuDiscovery
)) {
703 return EFI_UNSUPPORTED
;
707 Sock
= SOCK_FROM_THIS (This
);
709 if (NULL
== Tcp6ConfigData
) {
710 return SockFlush (Sock
);
713 Status
= SockConfigure (Sock
, Tcp6ConfigData
);
715 if (EFI_NO_MAPPING
== Status
) {
716 Sock
->ConfigureState
= SO_NO_MAPPING
;
723 Initiate a nonblocking TCP connection request for an active TCP instance.
725 The Connect() function will initiate an active open to the remote peer configured
726 in a current TCP instance if it is configured active. If the connection succeeds or
727 fails due to any error, the ConnectionToken->CompletionToken.Event will be signaled
728 and ConnectionToken->CompletionToken.Status will be updated accordingly. This
729 function can only be called for the TCP instance in the Tcp6StateClosed state. The
730 instance will transfer into Tcp6StateSynSent if the function returns EFI_SUCCESS.
731 If a TCP three-way handshake succeeds, its state will become Tcp6StateEstablished.
732 Otherwise, the state will return to Tcp6StateClosed.
734 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
735 @param[in] ConnectionToken Pointer to the connection token to return when the TCP three
736 way handshake finishes.
738 @retval EFI_SUCCESS The connection request successfully initiated and the state of
739 this TCP instance has been changed to Tcp6StateSynSent.
740 @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.
741 @retval EFI_ACCESS_DENIED One or more of the following conditions are TRUE:
742 - This instance is not configured as an active one.
743 - This instance is not in Tcp6StateClosed state.
744 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
746 - ConnectionToken is NULL.
747 - ConnectionToken->CompletionToken.Event is NULL.
748 @retval EFI_OUT_OF_RESOURCES The driver can't allocate enough resources to initiate the active open.
749 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
755 IN EFI_TCP6_PROTOCOL
*This
,
756 IN EFI_TCP6_CONNECTION_TOKEN
*ConnectionToken
761 if (NULL
== This
|| NULL
== ConnectionToken
|| NULL
== ConnectionToken
->CompletionToken
.Event
) {
762 return EFI_INVALID_PARAMETER
;
765 Sock
= SOCK_FROM_THIS (This
);
767 return SockConnect (Sock
, ConnectionToken
);
771 Listen on the passive instance to accept an incoming connection request. This is a
772 nonblocking operation.
774 The Accept() function initiates an asynchronous accept request to wait for an incoming
775 connection on the passive TCP instance. If a remote peer successfully establishes a
776 connection with this instance, a new TCP instance will be created and its handle will
777 be returned in ListenToken->NewChildHandle. The newly created instance is configured
778 by inheriting the passive instance's configuration and is ready for use upon return.
779 The new instance is in the Tcp6StateEstablished state.
781 The ListenToken->CompletionToken.Event will be signaled when a new connection is
782 accepted, when a user aborts the listen or when a connection is reset.
784 This function only can be called when a current TCP instance is in Tcp6StateListen state.
786 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
787 @param[in] ListenToken Pointer to the listen token to return when operation finishes.
790 @retval EFI_SUCCESS The listen token queued successfully.
791 @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.
792 @retval EFI_ACCESS_DENIED One or more of the following are TRUE:
793 - This instance is not a passive instance.
794 - This instance is not in Tcp6StateListen state.
795 - The same listen token has already existed in the listen
796 token queue of this TCP instance.
797 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
799 - ListenToken is NULL.
800 - ListentToken->CompletionToken.Event is NULL.
801 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resource to finish the operation.
802 @retval EFI_DEVICE_ERROR Any unexpected error not belonging to a category listed above.
808 IN EFI_TCP6_PROTOCOL
*This
,
809 IN EFI_TCP6_LISTEN_TOKEN
*ListenToken
814 if (NULL
== This
|| NULL
== ListenToken
|| NULL
== ListenToken
->CompletionToken
.Event
) {
815 return EFI_INVALID_PARAMETER
;
818 Sock
= SOCK_FROM_THIS (This
);
820 return SockAccept (Sock
, ListenToken
);
824 Queues outgoing data into the transmit queue.
826 The Transmit() function queues a sending request to this TCP instance along with the
827 user data. The status of the token is updated and the event in the token will be
828 signaled once the data is sent out or an error occurs.
830 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
831 @param[in] Token Pointer to the completion token to queue to the transmit queue.
833 @retval EFI_SUCCESS The data has been queued for transmission.
834 @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.
835 @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a
836 source address for this instance, but no source address was
838 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
841 - Token->CompletionToken.Event is NULL.
842 - Token->Packet.TxData is NULL.
843 - Token->Packet.FragmentCount is zero.
844 - Token->Packet.DataLength is not equal to the sum of fragment lengths.
845 @retval EFI_ACCESS_DENIED One or more of the following conditions are TRUE:
846 - A transmit completion token with the same Token->
847 CompletionToken.Event was already in the
849 - The current instance is in Tcp6StateClosed state.
850 - The current instance is a passive one and it is in
851 Tcp6StateListen state.
852 - User has called Close() to disconnect this connection.
853 @retval EFI_NOT_READY The completion token could not be queued because the
854 transmit queue is full.
855 @retval EFI_OUT_OF_RESOURCES Could not queue the transmit data because of resource
857 @retval EFI_NETWORK_UNREACHABLE There is no route to the destination network or address.
863 IN EFI_TCP6_PROTOCOL
*This
,
864 IN EFI_TCP6_IO_TOKEN
*Token
872 NULL
== Token
->CompletionToken
.Event
||
873 NULL
== Token
->Packet
.TxData
||
874 0 == Token
->Packet
.TxData
->FragmentCount
||
875 0 == Token
->Packet
.TxData
->DataLength
877 return EFI_INVALID_PARAMETER
;
880 Status
= TcpChkDataBuf (
881 Token
->Packet
.TxData
->DataLength
,
882 Token
->Packet
.TxData
->FragmentCount
,
883 (EFI_TCP4_FRAGMENT_DATA
*) Token
->Packet
.TxData
->FragmentTable
885 if (EFI_ERROR (Status
)) {
889 Sock
= SOCK_FROM_THIS (This
);
891 return SockSend (Sock
, Token
);
895 Places an asynchronous receive request into the receiving queue.
897 The Receive() function places a completion token into the receive packet queue. This
898 function is always asynchronous. The caller must allocate the Token->CompletionToken.Event
899 and the FragmentBuffer used to receive data. The caller also must fill the DataLength that
900 represents the whole length of all FragmentBuffer. When the receive operation completes, the
901 EFI TCPv6 Protocol driver updates the Token->CompletionToken.Status and Token->Packet.RxData
902 fields, and the Token->CompletionToken.Event is signaled. If data obtained, the data and its length
903 will be copied into the FragmentTable; at the same time the full length of received data will
904 be recorded in the DataLength fields. Providing a proper notification function and context
905 for the event enables the user to receive the notification and receiving status. That
906 notification function is guaranteed to not be re-entered.
908 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
909 @param[in] Token Pointer to a token that is associated with the receive data
912 @retval EFI_SUCCESS The receive completion token was cached.
913 @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.
914 @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a source
915 address for this instance, but no source address was available for use.
916 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
919 - Token->CompletionToken.Event is NULL.
920 - Token->Packet.RxData is NULL.
921 - Token->Packet.RxData->DataLength is 0.
922 - The Token->Packet.RxData->DataLength is not the
923 sum of all FragmentBuffer length in FragmentTable.
924 @retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued due to a lack of
925 system resources (usually memory).
926 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
927 The EFI TCPv6 Protocol instance has been reset to startup defaults.
928 @retval EFI_ACCESS_DENIED One or more of the following conditions is TRUE:
929 - A receive completion token with the same Token->CompletionToken.Event
930 was already in the receive queue.
931 - The current instance is in Tcp6StateClosed state.
932 - The current instance is a passive one and it is in
933 Tcp6StateListen state.
934 - User has called Close() to disconnect this connection.
935 @retval EFI_CONNECTION_FIN The communication peer has closed the connection and there is no
936 buffered data in the receive buffer of this instance.
937 @retval EFI_NOT_READY The receive request could not be queued because the receive queue is full.
943 IN EFI_TCP6_PROTOCOL
*This
,
944 IN EFI_TCP6_IO_TOKEN
*Token
952 NULL
== Token
->CompletionToken
.Event
||
953 NULL
== Token
->Packet
.RxData
||
954 0 == Token
->Packet
.RxData
->FragmentCount
||
955 0 == Token
->Packet
.RxData
->DataLength
957 return EFI_INVALID_PARAMETER
;
960 Status
= TcpChkDataBuf (
961 Token
->Packet
.RxData
->DataLength
,
962 Token
->Packet
.RxData
->FragmentCount
,
963 (EFI_TCP4_FRAGMENT_DATA
*) Token
->Packet
.RxData
->FragmentTable
965 if (EFI_ERROR (Status
)) {
969 Sock
= SOCK_FROM_THIS (This
);
971 return SockRcv (Sock
, Token
);
975 Disconnecting a TCP connection gracefully or reset a TCP connection. This function is a
976 nonblocking operation.
978 Initiate an asynchronous close token to the TCP driver. After Close() is called, any buffered
979 transmission data will be sent by the TCP driver, and the current instance will have a graceful close
980 working flow described as RFC 793 if AbortOnClose is set to FALSE. Otherwise, a rest packet
981 will be sent by TCP driver to fast disconnect this connection. When the close operation completes
982 successfully the TCP instance is in Tcp6StateClosed state, all pending asynchronous
983 operations are signaled, and any buffers used for TCP network traffic are flushed.
985 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
986 @param[in] CloseToken Pointer to the close token to return when operation finishes.
988 @retval EFI_SUCCESS The Close() was called successfully.
989 @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.
990 @retval EFI_ACCESS_DENIED One or more of the following are TRUE:
991 - CloseToken or CloseToken->CompletionToken.Event is already in use.
992 - Previous Close() call on this instance has not finished.
993 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
995 - CloseToken is NULL.
996 - CloseToken->CompletionToken.Event is NULL.
997 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resource to finish the operation.
998 @retval EFI_DEVICE_ERROR Any unexpected error not belonging to error categories given above.
1004 IN EFI_TCP6_PROTOCOL
*This
,
1005 IN EFI_TCP6_CLOSE_TOKEN
*CloseToken
1010 if (NULL
== This
|| NULL
== CloseToken
|| NULL
== CloseToken
->CompletionToken
.Event
) {
1011 return EFI_INVALID_PARAMETER
;
1014 Sock
= SOCK_FROM_THIS (This
);
1016 return SockClose (Sock
, CloseToken
, CloseToken
->AbortOnClose
);
1020 Abort an asynchronous connection, listen, transmission or receive request.
1022 The Cancel() function aborts a pending connection, listen, transmit or
1025 If Token is not NULL and the token is in the connection, listen, transmission
1026 or receive queue when it is being cancelled, its Token->Status will be set
1027 to EFI_ABORTED and then Token->Event will be signaled.
1029 If the token is not in one of the queues, which usually means that the
1030 asynchronous operation has completed, EFI_NOT_FOUND is returned.
1032 If Token is NULL all asynchronous token issued by Connect(), Accept(),
1033 Transmit() and Receive() will be aborted.
1035 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
1036 @param[in] Token Pointer to a token that has been issued by
1037 EFI_TCP6_PROTOCOL.Connect(),
1038 EFI_TCP6_PROTOCOL.Accept(),
1039 EFI_TCP6_PROTOCOL.Transmit() or
1040 EFI_TCP6_PROTOCOL.Receive(). If NULL, all pending
1041 tokens issued by above four functions will be aborted. Type
1042 EFI_TCP6_COMPLETION_TOKEN is defined in
1043 EFI_TCP_PROTOCOL.Connect().
1045 @retval EFI_SUCCESS The asynchronous I/O request is aborted and Token->Event
1047 @retval EFI_INVALID_PARAMETER This is NULL.
1048 @retval EFI_NOT_STARTED This instance hasn't been configured.
1049 @retval EFI_NOT_FOUND The asynchronous I/O request isn't found in the transmission or
1050 receive queue. It has either completed or wasn't issued by
1051 Transmit() and Receive().
1057 IN EFI_TCP6_PROTOCOL
*This
,
1058 IN EFI_TCP6_COMPLETION_TOKEN
*Token OPTIONAL
1064 return EFI_INVALID_PARAMETER
;
1067 Sock
= SOCK_FROM_THIS (This
);
1069 return SockCancel (Sock
, Token
);
1073 Poll to receive incoming data and transmit outgoing segments.
1075 The Poll() function increases the rate that data is moved between the network
1076 and application, and can be called when the TCP instance is created successfully.
1077 Its use is optional.
1079 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
1081 @retval EFI_SUCCESS Incoming or outgoing data was processed.
1082 @retval EFI_INVALID_PARAMETER This is NULL.
1083 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
1084 @retval EFI_NOT_READY No incoming or outgoing data is processed.
1085 @retval EFI_TIMEOUT Data was dropped out of the transmission or receive queue.
1086 Consider increasing the polling rate.
1092 IN EFI_TCP6_PROTOCOL
*This
1099 return EFI_INVALID_PARAMETER
;
1102 Sock
= SOCK_FROM_THIS (This
);
1104 Status
= Sock
->ProtoHandler (Sock
, SOCK_POLL
, NULL
);