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 - 2018, 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 if (FragmentTable
[Index
].FragmentBuffer
== NULL
) {
44 return EFI_INVALID_PARAMETER
;
46 Len
= Len
+ FragmentTable
[Index
].FragmentLength
;
50 return EFI_INVALID_PARAMETER
;
57 Get the current operational status.
59 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
60 @param[out] Tcp4State Pointer to the buffer to receive the current TCP
61 state. Optional parameter that may be NULL.
62 @param[out] Tcp4ConfigData Pointer to the buffer to receive the current TCP
63 configuration. Optional parameter that may be NULL.
64 @param[out] Ip4ModeData Pointer to the buffer to receive the current
65 IPv4 configuration. Optional parameter that may be NULL.
66 @param[out] MnpConfigData Pointer to the buffer to receive the current MNP
67 configuration data indirectly used by the TCPv4
68 Instance. Optional parameter that may be NULL.
69 @param[out] SnpModeData Pointer to the buffer to receive the current SNP
70 configuration data indirectly used by the TCPv4
71 Instance. Optional parameter that may be NULL.
73 @retval EFI_SUCCESS The mode data was read.
74 @retval EFI_NOT_STARTED No configuration data is available because this
75 instance hasn't been started.
76 @retval EFI_INVALID_PARAMETER This is NULL.
82 IN EFI_TCP4_PROTOCOL
*This
,
83 OUT EFI_TCP4_CONNECTION_STATE
*Tcp4State OPTIONAL
,
84 OUT EFI_TCP4_CONFIG_DATA
*Tcp4ConfigData OPTIONAL
,
85 OUT EFI_IP4_MODE_DATA
*Ip4ModeData OPTIONAL
,
86 OUT EFI_MANAGED_NETWORK_CONFIG_DATA
*MnpConfigData OPTIONAL
,
87 OUT EFI_SIMPLE_NETWORK_MODE
*SnpModeData OPTIONAL
90 TCP4_MODE_DATA TcpMode
;
94 return EFI_INVALID_PARAMETER
;
97 Sock
= SOCK_FROM_THIS (This
);
99 TcpMode
.Tcp4State
= Tcp4State
;
100 TcpMode
.Tcp4ConfigData
= Tcp4ConfigData
;
101 TcpMode
.Ip4ModeData
= Ip4ModeData
;
102 TcpMode
.MnpConfigData
= MnpConfigData
;
103 TcpMode
.SnpModeData
= SnpModeData
;
105 return SockGetMode (Sock
, &TcpMode
);
109 Initialize or brutally reset the operational parameters for
110 this EFI TCPv4 instance.
112 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
113 @param[in] TcpConfigData Pointer to the configure data to configure the
114 instance. Optional parameter that may be NULL.
116 @retval EFI_SUCCESS The operational settings were set, changed, or
118 @retval EFI_NO_MAPPING When using a default address, configuration
119 (through DHCP, BOOTP, RARP, etc.) is not
121 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
122 @retval EFI_ACCESS_DENIED Configuring TCP instance when it is already
124 @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.
125 @retval EFI_UNSUPPORTED One or more of the control options are not
126 supported in the implementation.
127 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources.
133 IN EFI_TCP4_PROTOCOL
* This
,
134 IN EFI_TCP4_CONFIG_DATA
* TcpConfigData OPTIONAL
137 EFI_TCP4_OPTION
*Option
;
144 return EFI_INVALID_PARAMETER
;
148 // Tcp protocol related parameter check will be conducted here
150 if (NULL
!= TcpConfigData
) {
152 CopyMem (&Ip
, &TcpConfigData
->AccessPoint
.RemoteAddress
, sizeof (IP4_ADDR
));
153 if (IP4_IS_LOCAL_BROADCAST (NTOHL (Ip
))) {
154 return EFI_INVALID_PARAMETER
;
157 if (TcpConfigData
->AccessPoint
.ActiveFlag
&& (0 == TcpConfigData
->AccessPoint
.RemotePort
|| (Ip
== 0))) {
158 return EFI_INVALID_PARAMETER
;
161 if (!TcpConfigData
->AccessPoint
.UseDefaultAddress
) {
163 CopyMem (&Ip
, &TcpConfigData
->AccessPoint
.StationAddress
, sizeof (IP4_ADDR
));
164 CopyMem (&SubnetMask
, &TcpConfigData
->AccessPoint
.SubnetMask
, sizeof (IP4_ADDR
));
165 if (!IP4_IS_VALID_NETMASK (NTOHL (SubnetMask
)) ||
166 (SubnetMask
!= 0 && !NetIp4IsUnicast (NTOHL (Ip
), NTOHL (SubnetMask
)))) {
167 return EFI_INVALID_PARAMETER
;
171 Option
= TcpConfigData
->ControlOption
;
172 if ((NULL
!= Option
) && (Option
->EnableSelectiveAck
|| Option
->EnablePathMtuDiscovery
)) {
173 return EFI_UNSUPPORTED
;
177 Sock
= SOCK_FROM_THIS (This
);
179 if (NULL
== TcpConfigData
) {
180 return SockFlush (Sock
);
183 Status
= SockConfigure (Sock
, TcpConfigData
);
185 if (EFI_NO_MAPPING
== Status
) {
186 Sock
->ConfigureState
= SO_NO_MAPPING
;
193 Add or delete routing entries.
195 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
196 @param[in] DeleteRoute If TRUE, delete the specified route from routing
197 table; if FALSE, add the specified route to
199 @param[in] SubnetAddress The destination network.
200 @param[in] SubnetMask The subnet mask for the destination network.
201 @param[in] GatewayAddress The gateway address for this route.
203 @retval EFI_SUCCESS The operation completed successfully.
204 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance has not been
206 @retval EFI_NO_MAPPING When using a default address, configuration
207 (through DHCP, BOOTP, RARP, etc.) is not
209 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
210 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resources to add the
211 entry to the routing table.
212 @retval EFI_NOT_FOUND This route is not in the routing table.
213 @retval EFI_ACCESS_DENIED This route is already in the routing table.
214 @retval EFI_UNSUPPORTED The TCP driver does not support this operation.
220 IN EFI_TCP4_PROTOCOL
*This
,
221 IN BOOLEAN DeleteRoute
,
222 IN EFI_IPv4_ADDRESS
*SubnetAddress
,
223 IN EFI_IPv4_ADDRESS
*SubnetMask
,
224 IN EFI_IPv4_ADDRESS
*GatewayAddress
228 TCP4_ROUTE_INFO RouteInfo
;
231 return EFI_INVALID_PARAMETER
;
234 Sock
= SOCK_FROM_THIS (This
);
236 RouteInfo
.DeleteRoute
= DeleteRoute
;
237 RouteInfo
.SubnetAddress
= SubnetAddress
;
238 RouteInfo
.SubnetMask
= SubnetMask
;
239 RouteInfo
.GatewayAddress
= GatewayAddress
;
241 return SockRoute (Sock
, &RouteInfo
);
245 Initiate a non-blocking TCP connection request for an active TCP instance.
247 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
248 @param[in] ConnectionToken Pointer to the connection token to return when
249 the TCP three way handshake finishes.
251 @retval EFI_SUCCESS The connection request successfully
253 @retval EFI_NOT_STARTED This EFI_TCP4_PROTOCOL instance hasn't been
255 @retval EFI_ACCESS_DENIED The instance is not configured as an active one,
256 or it is not in Tcp4StateClosed state.
257 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
258 @retval EFI_OUT_OF_RESOURCES The driver can't allocate enough resources to
259 initiate the active open.
260 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
266 IN EFI_TCP4_PROTOCOL
*This
,
267 IN EFI_TCP4_CONNECTION_TOKEN
*ConnectionToken
272 if (NULL
== This
|| NULL
== ConnectionToken
|| NULL
== ConnectionToken
->CompletionToken
.Event
) {
273 return EFI_INVALID_PARAMETER
;
276 Sock
= SOCK_FROM_THIS (This
);
278 return SockConnect (Sock
, ConnectionToken
);
282 Listen on the passive instance to accept an incoming connection request.
284 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
285 @param[in] ListenToken Pointer to the listen token to return when
288 @retval EFI_SUCCESS The listen token was queued successfully.
289 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been
291 @retval EFI_ACCESS_DENIED The instatnce is not a passive one or it is not
292 in Tcp4StateListen state or a same listen token
293 has already existed in the listen token queue of
295 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
296 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resources to finish
298 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
304 IN EFI_TCP4_PROTOCOL
*This
,
305 IN EFI_TCP4_LISTEN_TOKEN
*ListenToken
310 if (NULL
== This
|| NULL
== ListenToken
|| NULL
== ListenToken
->CompletionToken
.Event
) {
311 return EFI_INVALID_PARAMETER
;
314 Sock
= SOCK_FROM_THIS (This
);
316 return SockAccept (Sock
, ListenToken
);
320 Queues outgoing data into the transmit queue
322 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
323 @param[in] Token Pointer to the completion token to queue to the
326 @retval EFI_SUCCESS The data has been queued for transmission.
327 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been
329 @retval EFI_NO_MAPPING When using a default address, configuration
330 (DHCP, BOOTP, RARP, etc.) is not finished yet.
331 @retval EFI_INVALID_PARAMETER One or more parameters are invalid
332 @retval EFI_ACCESS_DENIED One or more of the following conditions is TRUE:
333 * A transmit completion token with the same
334 Token-> CompletionToken.Event was already in the
335 transmission queue. * The current instance is in
336 Tcp4StateClosed state. * The current instance is
337 a passive one and it is in Tcp4StateListen
338 state. * User has called Close() to disconnect
340 @retval EFI_NOT_READY The completion token could not be queued because
341 the transmit queue is full.
342 @retval EFI_OUT_OF_RESOURCES Could not queue the transmit data because of a
344 @retval EFI_NETWORK_UNREACHABLE There is no route to the destination network or
351 IN EFI_TCP4_PROTOCOL
*This
,
352 IN EFI_TCP4_IO_TOKEN
*Token
360 NULL
== Token
->CompletionToken
.Event
||
361 NULL
== Token
->Packet
.TxData
||
362 0 == Token
->Packet
.TxData
->FragmentCount
||
363 0 == Token
->Packet
.TxData
->DataLength
365 return EFI_INVALID_PARAMETER
;
368 Status
= TcpChkDataBuf (
369 Token
->Packet
.TxData
->DataLength
,
370 Token
->Packet
.TxData
->FragmentCount
,
371 Token
->Packet
.TxData
->FragmentTable
373 if (EFI_ERROR (Status
)) {
377 Sock
= SOCK_FROM_THIS (This
);
379 return SockSend (Sock
, Token
);
383 Place an asynchronous receive request into the receiving queue.
385 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
386 @param[in] Token Pointer to a token that is associated with the
387 receive data descriptor.
389 @retval EFI_SUCCESS The receive completion token was cached
390 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been
392 @retval EFI_NO_MAPPING When using a default address, configuration
393 (DHCP, BOOTP, RARP, etc.) is not finished yet.
394 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
395 @retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued
396 due to a lack of system resources.
397 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
398 @retval EFI_ACCESS_DENIED One or more of the following conditions is TRUE:
399 * A receive completion token with the same
400 Token->CompletionToken.Event was already in the
401 receive queue. * The current instance is in
402 Tcp4StateClosed state. * The current instance is
403 a passive one and it is in Tcp4StateListen
404 state. * User has called Close() to disconnect
406 @retval EFI_CONNECTION_FIN The communication peer has closed the connection,
407 and there is no any buffered data in the receive
408 buffer of this instance.
409 @retval EFI_NOT_READY The receive request could not be queued because
410 the receive queue is full.
416 IN EFI_TCP4_PROTOCOL
*This
,
417 IN EFI_TCP4_IO_TOKEN
*Token
425 NULL
== Token
->CompletionToken
.Event
||
426 NULL
== Token
->Packet
.RxData
||
427 0 == Token
->Packet
.RxData
->FragmentCount
||
428 0 == Token
->Packet
.RxData
->DataLength
430 return EFI_INVALID_PARAMETER
;
433 Status
= TcpChkDataBuf (
434 Token
->Packet
.RxData
->DataLength
,
435 Token
->Packet
.RxData
->FragmentCount
,
436 Token
->Packet
.RxData
->FragmentTable
438 if (EFI_ERROR (Status
)) {
442 Sock
= SOCK_FROM_THIS (This
);
444 return SockRcv (Sock
, Token
);
449 Disconnecting a TCP connection gracefully or reset a TCP connection.
451 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
452 @param[in] CloseToken Pointer to the close token to return when
455 @retval EFI_SUCCESS The operation completed successfully.
456 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been
458 @retval EFI_ACCESS_DENIED One or more of the following are TRUE: *
459 Configure() has been called with TcpConfigData
460 set to NULL, and this function has not returned.
461 * Previous Close() call on this instance has not
463 @retval EFI_INVALID_PARAMETER One ore more parameters are invalid.
464 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resources to finish the
466 @retval EFI_DEVICE_ERROR Any unexpected category error not belonging to those
473 IN EFI_TCP4_PROTOCOL
*This
,
474 IN EFI_TCP4_CLOSE_TOKEN
*CloseToken
479 if (NULL
== This
|| NULL
== CloseToken
|| NULL
== CloseToken
->CompletionToken
.Event
) {
480 return EFI_INVALID_PARAMETER
;
483 Sock
= SOCK_FROM_THIS (This
);
485 return SockClose (Sock
, CloseToken
, CloseToken
->AbortOnClose
);
489 Abort an asynchronous connection, listen, transmission or receive request.
491 @param This The pointer to the EFI_TCP4_PROTOCOL instance.
492 @param Token The pointer to a token that has been issued by
493 EFI_TCP4_PROTOCOL.Connect(),
494 EFI_TCP4_PROTOCOL.Accept(),
495 EFI_TCP4_PROTOCOL.Transmit() or
496 EFI_TCP4_PROTOCOL.Receive(). If NULL, all pending
497 tokens issued by above four functions will be aborted. Type
498 EFI_TCP4_COMPLETION_TOKEN is defined in
499 EFI_TCP4_PROTOCOL.Connect().
501 @retval EFI_SUCCESS The asynchronous I/O request is aborted and Token->Event
503 @retval EFI_INVALID_PARAMETER This is NULL.
504 @retval EFI_NOT_STARTED This instance hasn't been configured.
505 @retval EFI_NO_MAPPING When using the default address, configuration
506 (DHCP, BOOTP,RARP, etc.) hasn't finished yet.
507 @retval EFI_NOT_FOUND The asynchronous I/O request isn't found in the
508 transmission or receive queue. It has either
509 completed or wasn't issued by Transmit() and Receive().
515 IN EFI_TCP4_PROTOCOL
*This
,
516 IN EFI_TCP4_COMPLETION_TOKEN
*Token OPTIONAL
522 return EFI_INVALID_PARAMETER
;
525 Sock
= SOCK_FROM_THIS (This
);
527 return SockCancel (Sock
, Token
);
531 Poll to receive incoming data and transmit outgoing segments.
533 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
535 @retval EFI_SUCCESS Incoming or outgoing data was processed.
536 @retval EFI_INVALID_PARAMETER This is NULL.
537 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
538 @retval EFI_NOT_READY No incoming or outgoing data was processed.
539 @retval EFI_TIMEOUT Data was dropped out of the transmission or
540 receive queue. Consider increasing the polling
547 IN EFI_TCP4_PROTOCOL
*This
554 return EFI_INVALID_PARAMETER
;
557 Sock
= SOCK_FROM_THIS (This
);
559 Status
= Sock
->ProtoHandler (Sock
, SOCK_POLL
, NULL
);
565 Get the current operational status.
567 The GetModeData() function copies the current operational settings of this EFI TCPv6
568 Protocol instance into user-supplied buffers. This function can also be used to retrieve
569 the operational setting of underlying drivers such as IPv6, MNP, or SNP.
571 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
572 @param[out] Tcp6State The buffer in which the current TCP state is
573 returned. Optional parameter that may be NULL.
574 @param[out] Tcp6ConfigData The buffer in which the current TCP configuration
575 is returned. Optional parameter that may be NULL.
576 @param[out] Ip6ModeData The buffer in which the current IPv6 configuration
577 data used by the TCP instance is returned.
578 Optional parameter that may be NULL.
579 @param[out] MnpConfigData The buffer in which the current MNP configuration
580 data indirectly used by the TCP instance is returned.
581 Optional parameter that may be NULL.
582 @param[out] SnpModeData The buffer in which the current SNP mode data
583 indirectly used by the TCP instance is returned.
584 Optional parameter that may be NULL.
586 @retval EFI_SUCCESS The mode data was read.
587 @retval EFI_NOT_STARTED No configuration data is available because this instance hasn't
589 @retval EFI_INVALID_PARAMETER This is NULL.
595 IN EFI_TCP6_PROTOCOL
*This
,
596 OUT EFI_TCP6_CONNECTION_STATE
*Tcp6State OPTIONAL
,
597 OUT EFI_TCP6_CONFIG_DATA
*Tcp6ConfigData OPTIONAL
,
598 OUT EFI_IP6_MODE_DATA
*Ip6ModeData OPTIONAL
,
599 OUT EFI_MANAGED_NETWORK_CONFIG_DATA
*MnpConfigData OPTIONAL
,
600 OUT EFI_SIMPLE_NETWORK_MODE
*SnpModeData OPTIONAL
603 TCP6_MODE_DATA TcpMode
;
607 return EFI_INVALID_PARAMETER
;
610 Sock
= SOCK_FROM_THIS (This
);
612 TcpMode
.Tcp6State
= Tcp6State
;
613 TcpMode
.Tcp6ConfigData
= Tcp6ConfigData
;
614 TcpMode
.Ip6ModeData
= Ip6ModeData
;
615 TcpMode
.MnpConfigData
= MnpConfigData
;
616 TcpMode
.SnpModeData
= SnpModeData
;
618 return SockGetMode (Sock
, &TcpMode
);
622 Initialize or brutally reset the operational parameters for this EFI TCPv6 instance.
624 The Configure() function does the following:
625 - Initialize this TCP instance, i.e., initialize the communication end settings and
626 specify active open or passive open for an instance.
627 - Reset this TCP instance brutally, i.e., cancel all pending asynchronous tokens, flush
628 transmission and receiving buffer directly without informing the communication peer.
630 No other TCPv6 Protocol operation except Poll() can be executed by this instance until
631 it is configured properly. For an active TCP instance, after a proper configuration it
632 may call Connect() to initiate a three-way handshake. For a passive TCP instance,
633 its state transits to Tcp6StateListen after configuration, and Accept() may be
634 called to listen the incoming TCP connection requests. If Tcp6ConfigData is set to NULL,
635 the instance is reset. The resetting process will be done brutally, the state machine will
636 be set to Tcp6StateClosed directly, the receive queue and transmit queue will be flushed,
637 and no traffic is allowed through this instance.
639 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
640 @param[in] Tcp6ConfigData Pointer to the configure data to configure the instance.
641 If Tcp6ConfigData is set to NULL, the instance is reset.
643 @retval EFI_SUCCESS The operational settings were set, changed, or reset
645 @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a source
646 address for this instance, but no source address was available for
648 @retval EFI_INVALID_PARAMETER One or more of the following conditions are TRUE:
650 - Tcp6ConfigData->AccessPoint.StationAddress is neither zero nor
651 one of the configured IP addresses in the underlying IPv6 driver.
652 - Tcp6ConfigData->AccessPoint.RemoteAddress isn't a valid unicast
654 - Tcp6ConfigData->AccessPoint.RemoteAddress is zero or
655 Tcp6ConfigData->AccessPoint.RemotePort is zero when
656 Tcp6ConfigData->AccessPoint.ActiveFlag is TRUE.
657 - A same access point has been configured in other TCP
659 @retval EFI_ACCESS_DENIED Configuring a TCP instance when it is configured without
660 calling Configure() with NULL to reset it.
661 @retval EFI_UNSUPPORTED One or more of the control options are not supported in
663 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources when
664 executing Configure().
665 @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.
671 IN EFI_TCP6_PROTOCOL
*This
,
672 IN EFI_TCP6_CONFIG_DATA
*Tcp6ConfigData OPTIONAL
675 EFI_TCP6_OPTION
*Option
;
678 EFI_IPv6_ADDRESS
*Ip
;
681 return EFI_INVALID_PARAMETER
;
685 // Tcp protocol related parameter check will be conducted here
687 if (NULL
!= Tcp6ConfigData
) {
689 Ip
= &Tcp6ConfigData
->AccessPoint
.RemoteAddress
;
690 if (!NetIp6IsUnspecifiedAddr (Ip
) && !NetIp6IsValidUnicast (Ip
)) {
691 return EFI_INVALID_PARAMETER
;
694 if (Tcp6ConfigData
->AccessPoint
.ActiveFlag
&&
695 (0 == Tcp6ConfigData
->AccessPoint
.RemotePort
|| NetIp6IsUnspecifiedAddr (Ip
))
697 return EFI_INVALID_PARAMETER
;
700 Ip
= &Tcp6ConfigData
->AccessPoint
.StationAddress
;
701 if (!NetIp6IsUnspecifiedAddr (Ip
) && !NetIp6IsValidUnicast (Ip
)) {
702 return EFI_INVALID_PARAMETER
;
705 Option
= Tcp6ConfigData
->ControlOption
;
706 if ((NULL
!= Option
) && (Option
->EnableSelectiveAck
|| Option
->EnablePathMtuDiscovery
)) {
707 return EFI_UNSUPPORTED
;
711 Sock
= SOCK_FROM_THIS (This
);
713 if (NULL
== Tcp6ConfigData
) {
714 return SockFlush (Sock
);
717 Status
= SockConfigure (Sock
, Tcp6ConfigData
);
719 if (EFI_NO_MAPPING
== Status
) {
720 Sock
->ConfigureState
= SO_NO_MAPPING
;
727 Initiate a nonblocking TCP connection request for an active TCP instance.
729 The Connect() function will initiate an active open to the remote peer configured
730 in a current TCP instance if it is configured active. If the connection succeeds or
731 fails due to any error, the ConnectionToken->CompletionToken.Event will be signaled
732 and ConnectionToken->CompletionToken.Status will be updated accordingly. This
733 function can only be called for the TCP instance in the Tcp6StateClosed state. The
734 instance will transfer into Tcp6StateSynSent if the function returns EFI_SUCCESS.
735 If a TCP three-way handshake succeeds, its state will become Tcp6StateEstablished.
736 Otherwise, the state will return to Tcp6StateClosed.
738 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
739 @param[in] ConnectionToken Pointer to the connection token to return when the TCP three
740 way handshake finishes.
742 @retval EFI_SUCCESS The connection request successfully initiated and the state of
743 this TCP instance has been changed to Tcp6StateSynSent.
744 @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.
745 @retval EFI_ACCESS_DENIED One or more of the following conditions are TRUE:
746 - This instance is not configured as an active one.
747 - This instance is not in Tcp6StateClosed state.
748 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
750 - ConnectionToken is NULL.
751 - ConnectionToken->CompletionToken.Event is NULL.
752 @retval EFI_OUT_OF_RESOURCES The driver can't allocate enough resources to initiate the active open.
753 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
759 IN EFI_TCP6_PROTOCOL
*This
,
760 IN EFI_TCP6_CONNECTION_TOKEN
*ConnectionToken
765 if (NULL
== This
|| NULL
== ConnectionToken
|| NULL
== ConnectionToken
->CompletionToken
.Event
) {
766 return EFI_INVALID_PARAMETER
;
769 Sock
= SOCK_FROM_THIS (This
);
771 return SockConnect (Sock
, ConnectionToken
);
775 Listen on the passive instance to accept an incoming connection request. This is a
776 nonblocking operation.
778 The Accept() function initiates an asynchronous accept request to wait for an incoming
779 connection on the passive TCP instance. If a remote peer successfully establishes a
780 connection with this instance, a new TCP instance will be created and its handle will
781 be returned in ListenToken->NewChildHandle. The newly created instance is configured
782 by inheriting the passive instance's configuration and is ready for use upon return.
783 The new instance is in the Tcp6StateEstablished state.
785 The ListenToken->CompletionToken.Event will be signaled when a new connection is
786 accepted, when a user aborts the listen or when a connection is reset.
788 This function only can be called when a current TCP instance is in Tcp6StateListen state.
790 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
791 @param[in] ListenToken Pointer to the listen token to return when operation finishes.
794 @retval EFI_SUCCESS The listen token queued successfully.
795 @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.
796 @retval EFI_ACCESS_DENIED One or more of the following are TRUE:
797 - This instance is not a passive instance.
798 - This instance is not in Tcp6StateListen state.
799 - The same listen token has already existed in the listen
800 token queue of this TCP instance.
801 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
803 - ListenToken is NULL.
804 - ListentToken->CompletionToken.Event is NULL.
805 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resource to finish the operation.
806 @retval EFI_DEVICE_ERROR Any unexpected error not belonging to a category listed above.
812 IN EFI_TCP6_PROTOCOL
*This
,
813 IN EFI_TCP6_LISTEN_TOKEN
*ListenToken
818 if (NULL
== This
|| NULL
== ListenToken
|| NULL
== ListenToken
->CompletionToken
.Event
) {
819 return EFI_INVALID_PARAMETER
;
822 Sock
= SOCK_FROM_THIS (This
);
824 return SockAccept (Sock
, ListenToken
);
828 Queues outgoing data into the transmit queue.
830 The Transmit() function queues a sending request to this TCP instance along with the
831 user data. The status of the token is updated and the event in the token will be
832 signaled once the data is sent out or an error occurs.
834 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
835 @param[in] Token Pointer to the completion token to queue to the transmit queue.
837 @retval EFI_SUCCESS The data has been queued for transmission.
838 @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.
839 @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a
840 source address for this instance, but no source address was
842 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
845 - Token->CompletionToken.Event is NULL.
846 - Token->Packet.TxData is NULL.
847 - Token->Packet.FragmentCount is zero.
848 - Token->Packet.DataLength is not equal to the sum of fragment lengths.
849 @retval EFI_ACCESS_DENIED One or more of the following conditions are TRUE:
850 - A transmit completion token with the same Token->
851 CompletionToken.Event was already in the
853 - The current instance is in Tcp6StateClosed state.
854 - The current instance is a passive one and it is in
855 Tcp6StateListen state.
856 - User has called Close() to disconnect this connection.
857 @retval EFI_NOT_READY The completion token could not be queued because the
858 transmit queue is full.
859 @retval EFI_OUT_OF_RESOURCES Could not queue the transmit data because of resource
861 @retval EFI_NETWORK_UNREACHABLE There is no route to the destination network or address.
867 IN EFI_TCP6_PROTOCOL
*This
,
868 IN EFI_TCP6_IO_TOKEN
*Token
876 NULL
== Token
->CompletionToken
.Event
||
877 NULL
== Token
->Packet
.TxData
||
878 0 == Token
->Packet
.TxData
->FragmentCount
||
879 0 == Token
->Packet
.TxData
->DataLength
881 return EFI_INVALID_PARAMETER
;
884 Status
= TcpChkDataBuf (
885 Token
->Packet
.TxData
->DataLength
,
886 Token
->Packet
.TxData
->FragmentCount
,
887 (EFI_TCP4_FRAGMENT_DATA
*) Token
->Packet
.TxData
->FragmentTable
889 if (EFI_ERROR (Status
)) {
893 Sock
= SOCK_FROM_THIS (This
);
895 return SockSend (Sock
, Token
);
899 Places an asynchronous receive request into the receiving queue.
901 The Receive() function places a completion token into the receive packet queue. This
902 function is always asynchronous. The caller must allocate the Token->CompletionToken.Event
903 and the FragmentBuffer used to receive data. The caller also must fill the DataLength that
904 represents the whole length of all FragmentBuffer. When the receive operation completes, the
905 EFI TCPv6 Protocol driver updates the Token->CompletionToken.Status and Token->Packet.RxData
906 fields, and the Token->CompletionToken.Event is signaled. If data obtained, the data and its length
907 will be copied into the FragmentTable; at the same time the full length of received data will
908 be recorded in the DataLength fields. Providing a proper notification function and context
909 for the event enables the user to receive the notification and receiving status. That
910 notification function is guaranteed to not be re-entered.
912 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
913 @param[in] Token Pointer to a token that is associated with the receive data
916 @retval EFI_SUCCESS The receive completion token was cached.
917 @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.
918 @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a source
919 address for this instance, but no source address was available for use.
920 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
923 - Token->CompletionToken.Event is NULL.
924 - Token->Packet.RxData is NULL.
925 - Token->Packet.RxData->DataLength is 0.
926 - The Token->Packet.RxData->DataLength is not the
927 sum of all FragmentBuffer length in FragmentTable.
928 @retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued due to a lack of
929 system resources (usually memory).
930 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
931 The EFI TCPv6 Protocol instance has been reset to startup defaults.
932 @retval EFI_ACCESS_DENIED One or more of the following conditions is TRUE:
933 - A receive completion token with the same Token->CompletionToken.Event
934 was already in the receive queue.
935 - The current instance is in Tcp6StateClosed state.
936 - The current instance is a passive one and it is in
937 Tcp6StateListen state.
938 - User has called Close() to disconnect this connection.
939 @retval EFI_CONNECTION_FIN The communication peer has closed the connection and there is no
940 buffered data in the receive buffer of this instance.
941 @retval EFI_NOT_READY The receive request could not be queued because the receive queue is full.
947 IN EFI_TCP6_PROTOCOL
*This
,
948 IN EFI_TCP6_IO_TOKEN
*Token
956 NULL
== Token
->CompletionToken
.Event
||
957 NULL
== Token
->Packet
.RxData
||
958 0 == Token
->Packet
.RxData
->FragmentCount
||
959 0 == Token
->Packet
.RxData
->DataLength
961 return EFI_INVALID_PARAMETER
;
964 Status
= TcpChkDataBuf (
965 Token
->Packet
.RxData
->DataLength
,
966 Token
->Packet
.RxData
->FragmentCount
,
967 (EFI_TCP4_FRAGMENT_DATA
*) Token
->Packet
.RxData
->FragmentTable
969 if (EFI_ERROR (Status
)) {
973 Sock
= SOCK_FROM_THIS (This
);
975 return SockRcv (Sock
, Token
);
979 Disconnecting a TCP connection gracefully or reset a TCP connection. This function is a
980 nonblocking operation.
982 Initiate an asynchronous close token to the TCP driver. After Close() is called, any buffered
983 transmission data will be sent by the TCP driver, and the current instance will have a graceful close
984 working flow described as RFC 793 if AbortOnClose is set to FALSE. Otherwise, a rest packet
985 will be sent by TCP driver to fast disconnect this connection. When the close operation completes
986 successfully the TCP instance is in Tcp6StateClosed state, all pending asynchronous
987 operations are signaled, and any buffers used for TCP network traffic are flushed.
989 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
990 @param[in] CloseToken Pointer to the close token to return when operation finishes.
992 @retval EFI_SUCCESS The Close() was called successfully.
993 @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.
994 @retval EFI_ACCESS_DENIED One or more of the following are TRUE:
995 - CloseToken or CloseToken->CompletionToken.Event is already in use.
996 - Previous Close() call on this instance has not finished.
997 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
999 - CloseToken is NULL.
1000 - CloseToken->CompletionToken.Event is NULL.
1001 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resource to finish the operation.
1002 @retval EFI_DEVICE_ERROR Any unexpected error not belonging to error categories given above.
1008 IN EFI_TCP6_PROTOCOL
*This
,
1009 IN EFI_TCP6_CLOSE_TOKEN
*CloseToken
1014 if (NULL
== This
|| NULL
== CloseToken
|| NULL
== CloseToken
->CompletionToken
.Event
) {
1015 return EFI_INVALID_PARAMETER
;
1018 Sock
= SOCK_FROM_THIS (This
);
1020 return SockClose (Sock
, CloseToken
, CloseToken
->AbortOnClose
);
1024 Abort an asynchronous connection, listen, transmission or receive request.
1026 The Cancel() function aborts a pending connection, listen, transmit or
1029 If Token is not NULL and the token is in the connection, listen, transmission
1030 or receive queue when it is being cancelled, its Token->Status will be set
1031 to EFI_ABORTED and then Token->Event will be signaled.
1033 If the token is not in one of the queues, which usually means that the
1034 asynchronous operation has completed, EFI_NOT_FOUND is returned.
1036 If Token is NULL all asynchronous token issued by Connect(), Accept(),
1037 Transmit() and Receive() will be aborted.
1039 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
1040 @param[in] Token Pointer to a token that has been issued by
1041 EFI_TCP6_PROTOCOL.Connect(),
1042 EFI_TCP6_PROTOCOL.Accept(),
1043 EFI_TCP6_PROTOCOL.Transmit() or
1044 EFI_TCP6_PROTOCOL.Receive(). If NULL, all pending
1045 tokens issued by above four functions will be aborted. Type
1046 EFI_TCP6_COMPLETION_TOKEN is defined in
1047 EFI_TCP_PROTOCOL.Connect().
1049 @retval EFI_SUCCESS The asynchronous I/O request is aborted and Token->Event
1051 @retval EFI_INVALID_PARAMETER This is NULL.
1052 @retval EFI_NOT_STARTED This instance hasn't been configured.
1053 @retval EFI_NOT_FOUND The asynchronous I/O request isn't found in the transmission or
1054 receive queue. It has either completed or wasn't issued by
1055 Transmit() and Receive().
1061 IN EFI_TCP6_PROTOCOL
*This
,
1062 IN EFI_TCP6_COMPLETION_TOKEN
*Token OPTIONAL
1068 return EFI_INVALID_PARAMETER
;
1071 Sock
= SOCK_FROM_THIS (This
);
1073 return SockCancel (Sock
, Token
);
1077 Poll to receive incoming data and transmit outgoing segments.
1079 The Poll() function increases the rate that data is moved between the network
1080 and application, and can be called when the TCP instance is created successfully.
1081 Its use is optional.
1083 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
1085 @retval EFI_SUCCESS Incoming or outgoing data was processed.
1086 @retval EFI_INVALID_PARAMETER This is NULL.
1087 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
1088 @retval EFI_NOT_READY No incoming or outgoing data is processed.
1089 @retval EFI_TIMEOUT Data was dropped out of the transmission or receive queue.
1090 Consider increasing the polling rate.
1096 IN EFI_TCP6_PROTOCOL
*This
1103 return EFI_INVALID_PARAMETER
;
1106 Sock
= SOCK_FROM_THIS (This
);
1108 Status
= Sock
->ProtoHandler (Sock
, SOCK_POLL
, NULL
);