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 - 2017, 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 (IP4_IS_LOCAL_BROADCAST (NTOHL (Ip
))) {
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 (!IP4_IS_VALID_NETMASK (NTOHL (SubnetMask
)) ||
163 (SubnetMask
!= 0 && !NetIp4IsUnicast (NTOHL (Ip
), NTOHL (SubnetMask
)))) {
164 return EFI_INVALID_PARAMETER
;
168 Option
= TcpConfigData
->ControlOption
;
169 if ((NULL
!= Option
) && (Option
->EnableSelectiveAck
|| Option
->EnablePathMtuDiscovery
)) {
170 return EFI_UNSUPPORTED
;
174 Sock
= SOCK_FROM_THIS (This
);
176 if (NULL
== TcpConfigData
) {
177 return SockFlush (Sock
);
180 Status
= SockConfigure (Sock
, TcpConfigData
);
182 if (EFI_NO_MAPPING
== Status
) {
183 Sock
->ConfigureState
= SO_NO_MAPPING
;
190 Add or delete routing entries.
192 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
193 @param[in] DeleteRoute If TRUE, delete the specified route from routing
194 table; if FALSE, add the specified route to
196 @param[in] SubnetAddress The destination network.
197 @param[in] SubnetMask The subnet mask for the destination network.
198 @param[in] GatewayAddress The gateway address for this route.
200 @retval EFI_SUCCESS The operation completed successfully.
201 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance has not been
203 @retval EFI_NO_MAPPING When using a default address, configuration
204 (through DHCP, BOOTP, RARP, etc.) is not
206 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
207 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resources to add the
208 entry to the routing table.
209 @retval EFI_NOT_FOUND This route is not in the routing table.
210 @retval EFI_ACCESS_DENIED This route is already in the routing table.
211 @retval EFI_UNSUPPORTED The TCP driver does not support this operation.
217 IN EFI_TCP4_PROTOCOL
*This
,
218 IN BOOLEAN DeleteRoute
,
219 IN EFI_IPv4_ADDRESS
*SubnetAddress
,
220 IN EFI_IPv4_ADDRESS
*SubnetMask
,
221 IN EFI_IPv4_ADDRESS
*GatewayAddress
225 TCP4_ROUTE_INFO RouteInfo
;
228 return EFI_INVALID_PARAMETER
;
231 Sock
= SOCK_FROM_THIS (This
);
233 RouteInfo
.DeleteRoute
= DeleteRoute
;
234 RouteInfo
.SubnetAddress
= SubnetAddress
;
235 RouteInfo
.SubnetMask
= SubnetMask
;
236 RouteInfo
.GatewayAddress
= GatewayAddress
;
238 return SockRoute (Sock
, &RouteInfo
);
242 Initiate a non-blocking TCP connection request for an active TCP instance.
244 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
245 @param[in] ConnectionToken Pointer to the connection token to return when
246 the TCP three way handshake finishes.
248 @retval EFI_SUCCESS The connection request successfully
250 @retval EFI_NOT_STARTED This EFI_TCP4_PROTOCOL instance hasn't been
252 @retval EFI_ACCESS_DENIED The instance is not configured as an active one,
253 or it is not in Tcp4StateClosed state.
254 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
255 @retval EFI_OUT_OF_RESOURCES The driver can't allocate enough resources to
256 initiate the active open.
257 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
263 IN EFI_TCP4_PROTOCOL
*This
,
264 IN EFI_TCP4_CONNECTION_TOKEN
*ConnectionToken
269 if (NULL
== This
|| NULL
== ConnectionToken
|| NULL
== ConnectionToken
->CompletionToken
.Event
) {
270 return EFI_INVALID_PARAMETER
;
273 Sock
= SOCK_FROM_THIS (This
);
275 return SockConnect (Sock
, ConnectionToken
);
279 Listen on the passive instance to accept an incoming connection request.
281 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
282 @param[in] ListenToken Pointer to the listen token to return when
285 @retval EFI_SUCCESS The listen token was queued successfully.
286 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been
288 @retval EFI_ACCESS_DENIED The instatnce is not a passive one or it is not
289 in Tcp4StateListen state or a same listen token
290 has already existed in the listen token queue of
292 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
293 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resources to finish
295 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
301 IN EFI_TCP4_PROTOCOL
*This
,
302 IN EFI_TCP4_LISTEN_TOKEN
*ListenToken
307 if (NULL
== This
|| NULL
== ListenToken
|| NULL
== ListenToken
->CompletionToken
.Event
) {
308 return EFI_INVALID_PARAMETER
;
311 Sock
= SOCK_FROM_THIS (This
);
313 return SockAccept (Sock
, ListenToken
);
317 Queues outgoing data into the transmit queue
319 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
320 @param[in] Token Pointer to the completion token to queue to the
323 @retval EFI_SUCCESS The data has been queued for transmission.
324 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been
326 @retval EFI_NO_MAPPING When using a default address, configuration
327 (DHCP, BOOTP, RARP, etc.) is not finished yet.
328 @retval EFI_INVALID_PARAMETER One or more parameters are invalid
329 @retval EFI_ACCESS_DENIED One or more of the following conditions is TRUE:
330 * A transmit completion token with the same
331 Token-> CompletionToken.Event was already in the
332 transmission queue. * The current instance is in
333 Tcp4StateClosed state. * The current instance is
334 a passive one and it is in Tcp4StateListen
335 state. * User has called Close() to disconnect
337 @retval EFI_NOT_READY The completion token could not be queued because
338 the transmit queue is full.
339 @retval EFI_OUT_OF_RESOURCES Could not queue the transmit data because of a
341 @retval EFI_NETWORK_UNREACHABLE There is no route to the destination network or
348 IN EFI_TCP4_PROTOCOL
*This
,
349 IN EFI_TCP4_IO_TOKEN
*Token
357 NULL
== Token
->CompletionToken
.Event
||
358 NULL
== Token
->Packet
.TxData
||
359 0 == Token
->Packet
.TxData
->FragmentCount
||
360 0 == Token
->Packet
.TxData
->DataLength
362 return EFI_INVALID_PARAMETER
;
365 Status
= TcpChkDataBuf (
366 Token
->Packet
.TxData
->DataLength
,
367 Token
->Packet
.TxData
->FragmentCount
,
368 Token
->Packet
.TxData
->FragmentTable
370 if (EFI_ERROR (Status
)) {
374 Sock
= SOCK_FROM_THIS (This
);
376 return SockSend (Sock
, Token
);
380 Place an asynchronous receive request into the receiving queue.
382 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
383 @param[in] Token Pointer to a token that is associated with the
384 receive data descriptor.
386 @retval EFI_SUCCESS The receive completion token was cached
387 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been
389 @retval EFI_NO_MAPPING When using a default address, configuration
390 (DHCP, BOOTP, RARP, etc.) is not finished yet.
391 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
392 @retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued
393 due to a lack of system resources.
394 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
395 @retval EFI_ACCESS_DENIED One or more of the following conditions is TRUE:
396 * A receive completion token with the same
397 Token->CompletionToken.Event was already in the
398 receive queue. * The current instance is in
399 Tcp4StateClosed state. * The current instance is
400 a passive one and it is in Tcp4StateListen
401 state. * User has called Close() to disconnect
403 @retval EFI_CONNECTION_FIN The communication peer has closed the connection,
404 and there is no any buffered data in the receive
405 buffer of this instance.
406 @retval EFI_NOT_READY The receive request could not be queued because
407 the receive queue is full.
413 IN EFI_TCP4_PROTOCOL
*This
,
414 IN EFI_TCP4_IO_TOKEN
*Token
422 NULL
== Token
->CompletionToken
.Event
||
423 NULL
== Token
->Packet
.RxData
||
424 0 == Token
->Packet
.RxData
->FragmentCount
||
425 0 == Token
->Packet
.RxData
->DataLength
427 return EFI_INVALID_PARAMETER
;
430 Status
= TcpChkDataBuf (
431 Token
->Packet
.RxData
->DataLength
,
432 Token
->Packet
.RxData
->FragmentCount
,
433 Token
->Packet
.RxData
->FragmentTable
435 if (EFI_ERROR (Status
)) {
439 Sock
= SOCK_FROM_THIS (This
);
441 return SockRcv (Sock
, Token
);
446 Disconnecting a TCP connection gracefully or reset a TCP connection.
448 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
449 @param[in] CloseToken Pointer to the close token to return when
452 @retval EFI_SUCCESS The operation completed successfully.
453 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been
455 @retval EFI_ACCESS_DENIED One or more of the following are TRUE: *
456 Configure() has been called with TcpConfigData
457 set to NULL, and this function has not returned.
458 * Previous Close() call on this instance has not
460 @retval EFI_INVALID_PARAMETER One ore more parameters are invalid.
461 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resources to finish the
463 @retval EFI_DEVICE_ERROR Any unexpected category error not belonging to those
470 IN EFI_TCP4_PROTOCOL
*This
,
471 IN EFI_TCP4_CLOSE_TOKEN
*CloseToken
476 if (NULL
== This
|| NULL
== CloseToken
|| NULL
== CloseToken
->CompletionToken
.Event
) {
477 return EFI_INVALID_PARAMETER
;
480 Sock
= SOCK_FROM_THIS (This
);
482 return SockClose (Sock
, CloseToken
, CloseToken
->AbortOnClose
);
486 Abort an asynchronous connection, listen, transmission or receive request.
488 @param This The pointer to the EFI_TCP4_PROTOCOL instance.
489 @param Token The pointer to a token that has been issued by
490 EFI_TCP4_PROTOCOL.Connect(),
491 EFI_TCP4_PROTOCOL.Accept(),
492 EFI_TCP4_PROTOCOL.Transmit() or
493 EFI_TCP4_PROTOCOL.Receive(). If NULL, all pending
494 tokens issued by above four functions will be aborted. Type
495 EFI_TCP4_COMPLETION_TOKEN is defined in
496 EFI_TCP4_PROTOCOL.Connect().
498 @retval EFI_SUCCESS The asynchronous I/O request is aborted and Token->Event
500 @retval EFI_INVALID_PARAMETER This is NULL.
501 @retval EFI_NOT_STARTED This instance hasn't been configured.
502 @retval EFI_NO_MAPPING When using the default address, configuration
503 (DHCP, BOOTP,RARP, etc.) hasn't finished yet.
504 @retval EFI_NOT_FOUND The asynchronous I/O request isn't found in the
505 transmission or receive queue. It has either
506 completed or wasn't issued by Transmit() and Receive().
512 IN EFI_TCP4_PROTOCOL
*This
,
513 IN EFI_TCP4_COMPLETION_TOKEN
*Token OPTIONAL
519 return EFI_INVALID_PARAMETER
;
522 Sock
= SOCK_FROM_THIS (This
);
524 return SockCancel (Sock
, Token
);
528 Poll to receive incoming data and transmit outgoing segments.
530 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
532 @retval EFI_SUCCESS Incoming or outgoing data was processed.
533 @retval EFI_INVALID_PARAMETER This is NULL.
534 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
535 @retval EFI_NOT_READY No incoming or outgoing data was processed.
536 @retval EFI_TIMEOUT Data was dropped out of the transmission or
537 receive queue. Consider increasing the polling
544 IN EFI_TCP4_PROTOCOL
*This
551 return EFI_INVALID_PARAMETER
;
554 Sock
= SOCK_FROM_THIS (This
);
556 Status
= Sock
->ProtoHandler (Sock
, SOCK_POLL
, NULL
);
562 Get the current operational status.
564 The GetModeData() function copies the current operational settings of this EFI TCPv6
565 Protocol instance into user-supplied buffers. This function can also be used to retrieve
566 the operational setting of underlying drivers such as IPv6, MNP, or SNP.
568 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
569 @param[out] Tcp6State The buffer in which the current TCP state is
570 returned. Optional parameter that may be NULL.
571 @param[out] Tcp6ConfigData The buffer in which the current TCP configuration
572 is returned. Optional parameter that may be NULL.
573 @param[out] Ip6ModeData The buffer in which the current IPv6 configuration
574 data used by the TCP instance is returned.
575 Optional parameter that may be NULL.
576 @param[out] MnpConfigData The buffer in which the current MNP configuration
577 data indirectly used by the TCP instance is returned.
578 Optional parameter that may be NULL.
579 @param[out] SnpModeData The buffer in which the current SNP mode data
580 indirectly used by the TCP instance is returned.
581 Optional parameter that may be NULL.
583 @retval EFI_SUCCESS The mode data was read.
584 @retval EFI_NOT_STARTED No configuration data is available because this instance hasn't
586 @retval EFI_INVALID_PARAMETER This is NULL.
592 IN EFI_TCP6_PROTOCOL
*This
,
593 OUT EFI_TCP6_CONNECTION_STATE
*Tcp6State OPTIONAL
,
594 OUT EFI_TCP6_CONFIG_DATA
*Tcp6ConfigData OPTIONAL
,
595 OUT EFI_IP6_MODE_DATA
*Ip6ModeData OPTIONAL
,
596 OUT EFI_MANAGED_NETWORK_CONFIG_DATA
*MnpConfigData OPTIONAL
,
597 OUT EFI_SIMPLE_NETWORK_MODE
*SnpModeData OPTIONAL
600 TCP6_MODE_DATA TcpMode
;
604 return EFI_INVALID_PARAMETER
;
607 Sock
= SOCK_FROM_THIS (This
);
609 TcpMode
.Tcp6State
= Tcp6State
;
610 TcpMode
.Tcp6ConfigData
= Tcp6ConfigData
;
611 TcpMode
.Ip6ModeData
= Ip6ModeData
;
612 TcpMode
.MnpConfigData
= MnpConfigData
;
613 TcpMode
.SnpModeData
= SnpModeData
;
615 return SockGetMode (Sock
, &TcpMode
);
619 Initialize or brutally reset the operational parameters for this EFI TCPv6 instance.
621 The Configure() function does the following:
622 - Initialize this TCP instance, i.e., initialize the communication end settings and
623 specify active open or passive open for an instance.
624 - Reset this TCP instance brutally, i.e., cancel all pending asynchronous tokens, flush
625 transmission and receiving buffer directly without informing the communication peer.
627 No other TCPv6 Protocol operation except Poll() can be executed by this instance until
628 it is configured properly. For an active TCP instance, after a proper configuration it
629 may call Connect() to initiate a three-way handshake. For a passive TCP instance,
630 its state transits to Tcp6StateListen after configuration, and Accept() may be
631 called to listen the incoming TCP connection requests. If Tcp6ConfigData is set to NULL,
632 the instance is reset. The resetting process will be done brutally, the state machine will
633 be set to Tcp6StateClosed directly, the receive queue and transmit queue will be flushed,
634 and no traffic is allowed through this instance.
636 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
637 @param[in] Tcp6ConfigData Pointer to the configure data to configure the instance.
638 If Tcp6ConfigData is set to NULL, the instance is reset.
640 @retval EFI_SUCCESS The operational settings were set, changed, or reset
642 @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a source
643 address for this instance, but no source address was available for
645 @retval EFI_INVALID_PARAMETER One or more of the following conditions are TRUE:
647 - Tcp6ConfigData->AccessPoint.StationAddress is neither zero nor
648 one of the configured IP addresses in the underlying IPv6 driver.
649 - Tcp6ConfigData->AccessPoint.RemoteAddress isn't a valid unicast
651 - Tcp6ConfigData->AccessPoint.RemoteAddress is zero or
652 Tcp6ConfigData->AccessPoint.RemotePort is zero when
653 Tcp6ConfigData->AccessPoint.ActiveFlag is TRUE.
654 - A same access point has been configured in other TCP
656 @retval EFI_ACCESS_DENIED Configuring a TCP instance when it is configured without
657 calling Configure() with NULL to reset it.
658 @retval EFI_UNSUPPORTED One or more of the control options are not supported in
660 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources when
661 executing Configure().
662 @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.
668 IN EFI_TCP6_PROTOCOL
*This
,
669 IN EFI_TCP6_CONFIG_DATA
*Tcp6ConfigData OPTIONAL
672 EFI_TCP6_OPTION
*Option
;
675 EFI_IPv6_ADDRESS
*Ip
;
678 return EFI_INVALID_PARAMETER
;
682 // Tcp protocol related parameter check will be conducted here
684 if (NULL
!= Tcp6ConfigData
) {
686 Ip
= &Tcp6ConfigData
->AccessPoint
.RemoteAddress
;
687 if (!NetIp6IsUnspecifiedAddr (Ip
) && !NetIp6IsValidUnicast (Ip
)) {
688 return EFI_INVALID_PARAMETER
;
691 if (Tcp6ConfigData
->AccessPoint
.ActiveFlag
&&
692 (0 == Tcp6ConfigData
->AccessPoint
.RemotePort
|| NetIp6IsUnspecifiedAddr (Ip
))
694 return EFI_INVALID_PARAMETER
;
697 Ip
= &Tcp6ConfigData
->AccessPoint
.StationAddress
;
698 if (!NetIp6IsUnspecifiedAddr (Ip
) && !NetIp6IsValidUnicast (Ip
)) {
699 return EFI_INVALID_PARAMETER
;
702 Option
= Tcp6ConfigData
->ControlOption
;
703 if ((NULL
!= Option
) && (Option
->EnableSelectiveAck
|| Option
->EnablePathMtuDiscovery
)) {
704 return EFI_UNSUPPORTED
;
708 Sock
= SOCK_FROM_THIS (This
);
710 if (NULL
== Tcp6ConfigData
) {
711 return SockFlush (Sock
);
714 Status
= SockConfigure (Sock
, Tcp6ConfigData
);
716 if (EFI_NO_MAPPING
== Status
) {
717 Sock
->ConfigureState
= SO_NO_MAPPING
;
724 Initiate a nonblocking TCP connection request for an active TCP instance.
726 The Connect() function will initiate an active open to the remote peer configured
727 in a current TCP instance if it is configured active. If the connection succeeds or
728 fails due to any error, the ConnectionToken->CompletionToken.Event will be signaled
729 and ConnectionToken->CompletionToken.Status will be updated accordingly. This
730 function can only be called for the TCP instance in the Tcp6StateClosed state. The
731 instance will transfer into Tcp6StateSynSent if the function returns EFI_SUCCESS.
732 If a TCP three-way handshake succeeds, its state will become Tcp6StateEstablished.
733 Otherwise, the state will return to Tcp6StateClosed.
735 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
736 @param[in] ConnectionToken Pointer to the connection token to return when the TCP three
737 way handshake finishes.
739 @retval EFI_SUCCESS The connection request successfully initiated and the state of
740 this TCP instance has been changed to Tcp6StateSynSent.
741 @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.
742 @retval EFI_ACCESS_DENIED One or more of the following conditions are TRUE:
743 - This instance is not configured as an active one.
744 - This instance is not in Tcp6StateClosed state.
745 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
747 - ConnectionToken is NULL.
748 - ConnectionToken->CompletionToken.Event is NULL.
749 @retval EFI_OUT_OF_RESOURCES The driver can't allocate enough resources to initiate the active open.
750 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
756 IN EFI_TCP6_PROTOCOL
*This
,
757 IN EFI_TCP6_CONNECTION_TOKEN
*ConnectionToken
762 if (NULL
== This
|| NULL
== ConnectionToken
|| NULL
== ConnectionToken
->CompletionToken
.Event
) {
763 return EFI_INVALID_PARAMETER
;
766 Sock
= SOCK_FROM_THIS (This
);
768 return SockConnect (Sock
, ConnectionToken
);
772 Listen on the passive instance to accept an incoming connection request. This is a
773 nonblocking operation.
775 The Accept() function initiates an asynchronous accept request to wait for an incoming
776 connection on the passive TCP instance. If a remote peer successfully establishes a
777 connection with this instance, a new TCP instance will be created and its handle will
778 be returned in ListenToken->NewChildHandle. The newly created instance is configured
779 by inheriting the passive instance's configuration and is ready for use upon return.
780 The new instance is in the Tcp6StateEstablished state.
782 The ListenToken->CompletionToken.Event will be signaled when a new connection is
783 accepted, when a user aborts the listen or when a connection is reset.
785 This function only can be called when a current TCP instance is in Tcp6StateListen state.
787 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
788 @param[in] ListenToken Pointer to the listen token to return when operation finishes.
791 @retval EFI_SUCCESS The listen token queued successfully.
792 @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.
793 @retval EFI_ACCESS_DENIED One or more of the following are TRUE:
794 - This instance is not a passive instance.
795 - This instance is not in Tcp6StateListen state.
796 - The same listen token has already existed in the listen
797 token queue of this TCP instance.
798 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
800 - ListenToken is NULL.
801 - ListentToken->CompletionToken.Event is NULL.
802 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resource to finish the operation.
803 @retval EFI_DEVICE_ERROR Any unexpected error not belonging to a category listed above.
809 IN EFI_TCP6_PROTOCOL
*This
,
810 IN EFI_TCP6_LISTEN_TOKEN
*ListenToken
815 if (NULL
== This
|| NULL
== ListenToken
|| NULL
== ListenToken
->CompletionToken
.Event
) {
816 return EFI_INVALID_PARAMETER
;
819 Sock
= SOCK_FROM_THIS (This
);
821 return SockAccept (Sock
, ListenToken
);
825 Queues outgoing data into the transmit queue.
827 The Transmit() function queues a sending request to this TCP instance along with the
828 user data. The status of the token is updated and the event in the token will be
829 signaled once the data is sent out or an error occurs.
831 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
832 @param[in] Token Pointer to the completion token to queue to the transmit queue.
834 @retval EFI_SUCCESS The data has been queued for transmission.
835 @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.
836 @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a
837 source address for this instance, but no source address was
839 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
842 - Token->CompletionToken.Event is NULL.
843 - Token->Packet.TxData is NULL.
844 - Token->Packet.FragmentCount is zero.
845 - Token->Packet.DataLength is not equal to the sum of fragment lengths.
846 @retval EFI_ACCESS_DENIED One or more of the following conditions are TRUE:
847 - A transmit completion token with the same Token->
848 CompletionToken.Event was already in the
850 - The current instance is in Tcp6StateClosed state.
851 - The current instance is a passive one and it is in
852 Tcp6StateListen state.
853 - User has called Close() to disconnect this connection.
854 @retval EFI_NOT_READY The completion token could not be queued because the
855 transmit queue is full.
856 @retval EFI_OUT_OF_RESOURCES Could not queue the transmit data because of resource
858 @retval EFI_NETWORK_UNREACHABLE There is no route to the destination network or address.
864 IN EFI_TCP6_PROTOCOL
*This
,
865 IN EFI_TCP6_IO_TOKEN
*Token
873 NULL
== Token
->CompletionToken
.Event
||
874 NULL
== Token
->Packet
.TxData
||
875 0 == Token
->Packet
.TxData
->FragmentCount
||
876 0 == Token
->Packet
.TxData
->DataLength
878 return EFI_INVALID_PARAMETER
;
881 Status
= TcpChkDataBuf (
882 Token
->Packet
.TxData
->DataLength
,
883 Token
->Packet
.TxData
->FragmentCount
,
884 (EFI_TCP4_FRAGMENT_DATA
*) Token
->Packet
.TxData
->FragmentTable
886 if (EFI_ERROR (Status
)) {
890 Sock
= SOCK_FROM_THIS (This
);
892 return SockSend (Sock
, Token
);
896 Places an asynchronous receive request into the receiving queue.
898 The Receive() function places a completion token into the receive packet queue. This
899 function is always asynchronous. The caller must allocate the Token->CompletionToken.Event
900 and the FragmentBuffer used to receive data. The caller also must fill the DataLength that
901 represents the whole length of all FragmentBuffer. When the receive operation completes, the
902 EFI TCPv6 Protocol driver updates the Token->CompletionToken.Status and Token->Packet.RxData
903 fields, and the Token->CompletionToken.Event is signaled. If data obtained, the data and its length
904 will be copied into the FragmentTable; at the same time the full length of received data will
905 be recorded in the DataLength fields. Providing a proper notification function and context
906 for the event enables the user to receive the notification and receiving status. That
907 notification function is guaranteed to not be re-entered.
909 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
910 @param[in] Token Pointer to a token that is associated with the receive data
913 @retval EFI_SUCCESS The receive completion token was cached.
914 @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.
915 @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a source
916 address for this instance, but no source address was available for use.
917 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
920 - Token->CompletionToken.Event is NULL.
921 - Token->Packet.RxData is NULL.
922 - Token->Packet.RxData->DataLength is 0.
923 - The Token->Packet.RxData->DataLength is not the
924 sum of all FragmentBuffer length in FragmentTable.
925 @retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued due to a lack of
926 system resources (usually memory).
927 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
928 The EFI TCPv6 Protocol instance has been reset to startup defaults.
929 @retval EFI_ACCESS_DENIED One or more of the following conditions is TRUE:
930 - A receive completion token with the same Token->CompletionToken.Event
931 was already in the receive queue.
932 - The current instance is in Tcp6StateClosed state.
933 - The current instance is a passive one and it is in
934 Tcp6StateListen state.
935 - User has called Close() to disconnect this connection.
936 @retval EFI_CONNECTION_FIN The communication peer has closed the connection and there is no
937 buffered data in the receive buffer of this instance.
938 @retval EFI_NOT_READY The receive request could not be queued because the receive queue is full.
944 IN EFI_TCP6_PROTOCOL
*This
,
945 IN EFI_TCP6_IO_TOKEN
*Token
953 NULL
== Token
->CompletionToken
.Event
||
954 NULL
== Token
->Packet
.RxData
||
955 0 == Token
->Packet
.RxData
->FragmentCount
||
956 0 == Token
->Packet
.RxData
->DataLength
958 return EFI_INVALID_PARAMETER
;
961 Status
= TcpChkDataBuf (
962 Token
->Packet
.RxData
->DataLength
,
963 Token
->Packet
.RxData
->FragmentCount
,
964 (EFI_TCP4_FRAGMENT_DATA
*) Token
->Packet
.RxData
->FragmentTable
966 if (EFI_ERROR (Status
)) {
970 Sock
= SOCK_FROM_THIS (This
);
972 return SockRcv (Sock
, Token
);
976 Disconnecting a TCP connection gracefully or reset a TCP connection. This function is a
977 nonblocking operation.
979 Initiate an asynchronous close token to the TCP driver. After Close() is called, any buffered
980 transmission data will be sent by the TCP driver, and the current instance will have a graceful close
981 working flow described as RFC 793 if AbortOnClose is set to FALSE. Otherwise, a rest packet
982 will be sent by TCP driver to fast disconnect this connection. When the close operation completes
983 successfully the TCP instance is in Tcp6StateClosed state, all pending asynchronous
984 operations are signaled, and any buffers used for TCP network traffic are flushed.
986 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
987 @param[in] CloseToken Pointer to the close token to return when operation finishes.
989 @retval EFI_SUCCESS The Close() was called successfully.
990 @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.
991 @retval EFI_ACCESS_DENIED One or more of the following are TRUE:
992 - CloseToken or CloseToken->CompletionToken.Event is already in use.
993 - Previous Close() call on this instance has not finished.
994 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
996 - CloseToken is NULL.
997 - CloseToken->CompletionToken.Event is NULL.
998 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resource to finish the operation.
999 @retval EFI_DEVICE_ERROR Any unexpected error not belonging to error categories given above.
1005 IN EFI_TCP6_PROTOCOL
*This
,
1006 IN EFI_TCP6_CLOSE_TOKEN
*CloseToken
1011 if (NULL
== This
|| NULL
== CloseToken
|| NULL
== CloseToken
->CompletionToken
.Event
) {
1012 return EFI_INVALID_PARAMETER
;
1015 Sock
= SOCK_FROM_THIS (This
);
1017 return SockClose (Sock
, CloseToken
, CloseToken
->AbortOnClose
);
1021 Abort an asynchronous connection, listen, transmission or receive request.
1023 The Cancel() function aborts a pending connection, listen, transmit or
1026 If Token is not NULL and the token is in the connection, listen, transmission
1027 or receive queue when it is being cancelled, its Token->Status will be set
1028 to EFI_ABORTED and then Token->Event will be signaled.
1030 If the token is not in one of the queues, which usually means that the
1031 asynchronous operation has completed, EFI_NOT_FOUND is returned.
1033 If Token is NULL all asynchronous token issued by Connect(), Accept(),
1034 Transmit() and Receive() will be aborted.
1036 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
1037 @param[in] Token Pointer to a token that has been issued by
1038 EFI_TCP6_PROTOCOL.Connect(),
1039 EFI_TCP6_PROTOCOL.Accept(),
1040 EFI_TCP6_PROTOCOL.Transmit() or
1041 EFI_TCP6_PROTOCOL.Receive(). If NULL, all pending
1042 tokens issued by above four functions will be aborted. Type
1043 EFI_TCP6_COMPLETION_TOKEN is defined in
1044 EFI_TCP_PROTOCOL.Connect().
1046 @retval EFI_SUCCESS The asynchronous I/O request is aborted and Token->Event
1048 @retval EFI_INVALID_PARAMETER This is NULL.
1049 @retval EFI_NOT_STARTED This instance hasn't been configured.
1050 @retval EFI_NOT_FOUND The asynchronous I/O request isn't found in the transmission or
1051 receive queue. It has either completed or wasn't issued by
1052 Transmit() and Receive().
1058 IN EFI_TCP6_PROTOCOL
*This
,
1059 IN EFI_TCP6_COMPLETION_TOKEN
*Token OPTIONAL
1065 return EFI_INVALID_PARAMETER
;
1068 Sock
= SOCK_FROM_THIS (This
);
1070 return SockCancel (Sock
, Token
);
1074 Poll to receive incoming data and transmit outgoing segments.
1076 The Poll() function increases the rate that data is moved between the network
1077 and application, and can be called when the TCP instance is created successfully.
1078 Its use is optional.
1080 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
1082 @retval EFI_SUCCESS Incoming or outgoing data was processed.
1083 @retval EFI_INVALID_PARAMETER This is NULL.
1084 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
1085 @retval EFI_NOT_READY No incoming or outgoing data is processed.
1086 @retval EFI_TIMEOUT Data was dropped out of the transmission or receive queue.
1087 Consider increasing the polling rate.
1093 IN EFI_TCP6_PROTOCOL
*This
1100 return EFI_INVALID_PARAMETER
;
1103 Sock
= SOCK_FROM_THIS (This
);
1105 Status
= Sock
->ProtoHandler (Sock
, SOCK_POLL
, NULL
);