2 Implementation of EFI_TCP4_PROTOCOL and EFI_TCP6_PROTOCOL.
4 Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php.
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19 Check the integrity of the data buffer.
21 @param[in] DataLen The total length of the data buffer.
22 @param[in] FragmentCount The fragment count of the fragment table.
23 @param[in] FragmentTable Pointer to the fragment table of the data
26 @retval EFI_SUCCESS The integrity check passed.
27 @retval EFI_INVALID_PARAMETER The integrity check failed.
33 IN UINT32 FragmentCount
,
34 IN EFI_TCP4_FRAGMENT_DATA
*FragmentTable
41 for (Index
= 0, Len
= 0; Index
< FragmentCount
; Index
++) {
42 Len
= Len
+ FragmentTable
[Index
].FragmentLength
;
46 return EFI_INVALID_PARAMETER
;
53 Get the current operational status.
55 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
56 @param[out] Tcp4State Pointer to the buffer to receive the current TCP
57 state. Optional parameter that may be NULL.
58 @param[out] Tcp4ConfigData Pointer to the buffer to receive the current TCP
59 configuration. Optional parameter that may be NULL.
60 @param[out] Ip4ModeData Pointer to the buffer to receive the current
61 IPv4 configuration. Optional parameter that may be NULL.
62 @param[out] MnpConfigData Pointer to the buffer to receive the current MNP
63 configuration data indirectly used by the TCPv4
64 Instance. Optional parameter that may be NULL.
65 @param[out] SnpModeData Pointer to the buffer to receive the current SNP
66 configuration data indirectly used by the TCPv4
67 Instance. Optional parameter that may be NULL.
69 @retval EFI_SUCCESS The mode data was read.
70 @retval EFI_NOT_STARTED No configuration data is available because this
71 instance hasn't been started.
72 @retval EFI_INVALID_PARAMETER This is NULL.
78 IN EFI_TCP4_PROTOCOL
*This
,
79 OUT EFI_TCP4_CONNECTION_STATE
*Tcp4State OPTIONAL
,
80 OUT EFI_TCP4_CONFIG_DATA
*Tcp4ConfigData OPTIONAL
,
81 OUT EFI_IP4_MODE_DATA
*Ip4ModeData OPTIONAL
,
82 OUT EFI_MANAGED_NETWORK_CONFIG_DATA
*MnpConfigData OPTIONAL
,
83 OUT EFI_SIMPLE_NETWORK_MODE
*SnpModeData OPTIONAL
86 TCP4_MODE_DATA TcpMode
;
90 return EFI_INVALID_PARAMETER
;
93 Sock
= SOCK_FROM_THIS (This
);
95 TcpMode
.Tcp4State
= Tcp4State
;
96 TcpMode
.Tcp4ConfigData
= Tcp4ConfigData
;
97 TcpMode
.Ip4ModeData
= Ip4ModeData
;
98 TcpMode
.MnpConfigData
= MnpConfigData
;
99 TcpMode
.SnpModeData
= SnpModeData
;
101 return SockGetMode (Sock
, &TcpMode
);
105 Initialize or brutally reset the operational parameters for
106 this EFI TCPv4 instance.
108 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
109 @param[in] TcpConfigData Pointer to the configure data to configure the
110 instance. Optional parameter that may be NULL.
112 @retval EFI_SUCCESS The operational settings were set, changed, or
114 @retval EFI_NO_MAPPING When using a default address, configuration
115 (through DHCP, BOOTP, RARP, etc.) is not
117 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
118 @retval EFI_ACCESS_DENIED Configuring TCP instance when it is already
120 @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.
121 @retval EFI_UNSUPPORTED One or more of the control options are not
122 supported in the implementation.
123 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources.
129 IN EFI_TCP4_PROTOCOL
* This
,
130 IN EFI_TCP4_CONFIG_DATA
* TcpConfigData OPTIONAL
133 EFI_TCP4_OPTION
*Option
;
140 return EFI_INVALID_PARAMETER
;
144 // Tcp protocol related parameter check will be conducted here
146 if (NULL
!= TcpConfigData
) {
148 CopyMem (&Ip
, &TcpConfigData
->AccessPoint
.RemoteAddress
, sizeof (IP4_ADDR
));
149 if ((Ip
!= 0) && !NetIp4IsUnicast (NTOHL (Ip
), 0)) {
150 return EFI_INVALID_PARAMETER
;
153 if (TcpConfigData
->AccessPoint
.ActiveFlag
&& (0 == TcpConfigData
->AccessPoint
.RemotePort
|| (Ip
== 0))) {
154 return EFI_INVALID_PARAMETER
;
157 if (!TcpConfigData
->AccessPoint
.UseDefaultAddress
) {
159 CopyMem (&Ip
, &TcpConfigData
->AccessPoint
.StationAddress
, sizeof (IP4_ADDR
));
160 CopyMem (&SubnetMask
, &TcpConfigData
->AccessPoint
.SubnetMask
, sizeof (IP4_ADDR
));
161 if (!NetIp4IsUnicast (NTOHL (Ip
), 0) || !IP4_IS_VALID_NETMASK (NTOHL (SubnetMask
))) {
162 return EFI_INVALID_PARAMETER
;
166 Option
= TcpConfigData
->ControlOption
;
167 if ((NULL
!= Option
) && (Option
->EnableSelectiveAck
|| Option
->EnablePathMtuDiscovery
)) {
168 return EFI_UNSUPPORTED
;
172 Sock
= SOCK_FROM_THIS (This
);
174 if (NULL
== TcpConfigData
) {
175 return SockFlush (Sock
);
178 Status
= SockConfigure (Sock
, TcpConfigData
);
180 if (EFI_NO_MAPPING
== Status
) {
181 Sock
->ConfigureState
= SO_NO_MAPPING
;
188 Add or delete routing entries.
190 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
191 @param[in] DeleteRoute If TRUE, delete the specified route from routing
192 table; if FALSE, add the specified route to
194 @param[in] SubnetAddress The destination network.
195 @param[in] SubnetMask The subnet mask for the destination network.
196 @param[in] GatewayAddress The gateway address for this route.
198 @retval EFI_SUCCESS The operation completed successfully.
199 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance has not been
201 @retval EFI_NO_MAPPING When using a default address, configuration
202 (through DHCP, BOOTP, RARP, etc.) is not
204 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
205 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resources to add the
206 entry to the routing table.
207 @retval EFI_NOT_FOUND This route is not in the routing table.
208 @retval EFI_ACCESS_DENIED This route is already in the routing table.
209 @retval EFI_UNSUPPORTED The TCP driver does not support this operation.
215 IN EFI_TCP4_PROTOCOL
*This
,
216 IN BOOLEAN DeleteRoute
,
217 IN EFI_IPv4_ADDRESS
*SubnetAddress
,
218 IN EFI_IPv4_ADDRESS
*SubnetMask
,
219 IN EFI_IPv4_ADDRESS
*GatewayAddress
223 TCP4_ROUTE_INFO RouteInfo
;
226 return EFI_INVALID_PARAMETER
;
229 Sock
= SOCK_FROM_THIS (This
);
231 RouteInfo
.DeleteRoute
= DeleteRoute
;
232 RouteInfo
.SubnetAddress
= SubnetAddress
;
233 RouteInfo
.SubnetMask
= SubnetMask
;
234 RouteInfo
.GatewayAddress
= GatewayAddress
;
236 return SockRoute (Sock
, &RouteInfo
);
240 Initiate a non-blocking TCP connection request for an active TCP instance.
242 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
243 @param[in] ConnectionToken Pointer to the connection token to return when
244 the TCP three way handshake finishes.
246 @retval EFI_SUCCESS The connection request successfully
248 @retval EFI_NOT_STARTED This EFI_TCP4_PROTOCOL instance hasn't been
250 @retval EFI_ACCESS_DENIED The instance is not configured as an active one,
251 or it is not in Tcp4StateClosed state.
252 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
253 @retval EFI_OUT_OF_RESOURCES The driver can't allocate enough resources to
254 initiate the active open.
255 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
261 IN EFI_TCP4_PROTOCOL
*This
,
262 IN EFI_TCP4_CONNECTION_TOKEN
*ConnectionToken
267 if (NULL
== This
|| NULL
== ConnectionToken
|| NULL
== ConnectionToken
->CompletionToken
.Event
) {
268 return EFI_INVALID_PARAMETER
;
271 Sock
= SOCK_FROM_THIS (This
);
273 return SockConnect (Sock
, ConnectionToken
);
277 Listen on the passive instance to accept an incoming connection request.
279 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
280 @param[in] ListenToken Pointer to the listen token to return when
283 @retval EFI_SUCCESS The listen token was queued successfully.
284 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been
286 @retval EFI_ACCESS_DENIED The instatnce is not a passive one or it is not
287 in Tcp4StateListen state or a same listen token
288 has already existed in the listen token queue of
290 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
291 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resources to finish
293 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
299 IN EFI_TCP4_PROTOCOL
*This
,
300 IN EFI_TCP4_LISTEN_TOKEN
*ListenToken
305 if (NULL
== This
|| NULL
== ListenToken
|| NULL
== ListenToken
->CompletionToken
.Event
) {
306 return EFI_INVALID_PARAMETER
;
309 Sock
= SOCK_FROM_THIS (This
);
311 return SockAccept (Sock
, ListenToken
);
315 Queues outgoing data into the transmit queue
317 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
318 @param[in] Token Pointer to the completion token to queue to the
321 @retval EFI_SUCCESS The data has been queued for transmission.
322 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been
324 @retval EFI_NO_MAPPING When using a default address, configuration
325 (DHCP, BOOTP, RARP, etc.) is not finished yet.
326 @retval EFI_INVALID_PARAMETER One or more parameters are invalid
327 @retval EFI_ACCESS_DENIED One or more of the following conditions is TRUE:
328 * A transmit completion token with the same
329 Token-> CompletionToken.Event was already in the
330 transmission queue. * The current instance is in
331 Tcp4StateClosed state. * The current instance is
332 a passive one and it is in Tcp4StateListen
333 state. * User has called Close() to disconnect
335 @retval EFI_NOT_READY The completion token could not be queued because
336 the transmit queue is full.
337 @retval EFI_OUT_OF_RESOURCES Could not queue the transmit data because of a
339 @retval EFI_NETWORK_UNREACHABLE There is no route to the destination network or
346 IN EFI_TCP4_PROTOCOL
*This
,
347 IN EFI_TCP4_IO_TOKEN
*Token
355 NULL
== Token
->CompletionToken
.Event
||
356 NULL
== Token
->Packet
.TxData
||
357 0 == Token
->Packet
.TxData
->FragmentCount
||
358 0 == Token
->Packet
.TxData
->DataLength
360 return EFI_INVALID_PARAMETER
;
363 Status
= TcpChkDataBuf (
364 Token
->Packet
.TxData
->DataLength
,
365 Token
->Packet
.TxData
->FragmentCount
,
366 Token
->Packet
.TxData
->FragmentTable
368 if (EFI_ERROR (Status
)) {
372 Sock
= SOCK_FROM_THIS (This
);
374 return SockSend (Sock
, Token
);
378 Place an asynchronous receive request into the receiving queue.
380 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
381 @param[in] Token Pointer to a token that is associated with the
382 receive data descriptor.
384 @retval EFI_SUCCESS The receive completion token was cached
385 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been
387 @retval EFI_NO_MAPPING When using a default address, configuration
388 (DHCP, BOOTP, RARP, etc.) is not finished yet.
389 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
390 @retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued
391 due to a lack of system resources.
392 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
393 @retval EFI_ACCESS_DENIED One or more of the following conditions is TRUE:
394 * A receive completion token with the same
395 Token->CompletionToken.Event was already in the
396 receive queue. * The current instance is in
397 Tcp4StateClosed state. * The current instance is
398 a passive one and it is in Tcp4StateListen
399 state. * User has called Close() to disconnect
401 @retval EFI_CONNECTION_FIN The communication peer has closed the connection,
402 and there is no any buffered data in the receive
403 buffer of this instance.
404 @retval EFI_NOT_READY The receive request could not be queued because
405 the receive queue is full.
411 IN EFI_TCP4_PROTOCOL
*This
,
412 IN EFI_TCP4_IO_TOKEN
*Token
420 NULL
== Token
->CompletionToken
.Event
||
421 NULL
== Token
->Packet
.RxData
||
422 0 == Token
->Packet
.RxData
->FragmentCount
||
423 0 == Token
->Packet
.RxData
->DataLength
425 return EFI_INVALID_PARAMETER
;
428 Status
= TcpChkDataBuf (
429 Token
->Packet
.RxData
->DataLength
,
430 Token
->Packet
.RxData
->FragmentCount
,
431 Token
->Packet
.RxData
->FragmentTable
433 if (EFI_ERROR (Status
)) {
437 Sock
= SOCK_FROM_THIS (This
);
439 return SockRcv (Sock
, Token
);
444 Disconnecting a TCP connection gracefully or reset a TCP connection.
446 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
447 @param[in] CloseToken Pointer to the close token to return when
450 @retval EFI_SUCCESS The operation completed successfully.
451 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been
453 @retval EFI_ACCESS_DENIED One or more of the following are TRUE: *
454 Configure() has been called with TcpConfigData
455 set to NULL, and this function has not returned.
456 * Previous Close() call on this instance has not
458 @retval EFI_INVALID_PARAMETER One ore more parameters are invalid.
459 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resources to finish the
461 @retval EFI_DEVICE_ERROR Any unexpected category error not belonging to those
468 IN EFI_TCP4_PROTOCOL
*This
,
469 IN EFI_TCP4_CLOSE_TOKEN
*CloseToken
474 if (NULL
== This
|| NULL
== CloseToken
|| NULL
== CloseToken
->CompletionToken
.Event
) {
475 return EFI_INVALID_PARAMETER
;
478 Sock
= SOCK_FROM_THIS (This
);
480 return SockClose (Sock
, CloseToken
, CloseToken
->AbortOnClose
);
484 Abort an asynchronous connection, listen, transmission or receive request.
486 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
487 @param[in] Token Pointer to a token that has been issued by
488 Connect(), Accept(), Transmit() or Receive(). If
489 NULL, all pending tokens issued by the four
490 functions listed above will be aborted.
492 @retval EFI_UNSUPPORTED The operation is not supported in the current
499 IN EFI_TCP4_PROTOCOL
*This
,
500 IN EFI_TCP4_COMPLETION_TOKEN
*Token OPTIONAL
503 return EFI_UNSUPPORTED
;
507 Poll to receive incoming data and transmit outgoing segments.
509 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
511 @retval EFI_SUCCESS Incoming or outgoing data was processed.
512 @retval EFI_INVALID_PARAMETER This is NULL.
513 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
514 @retval EFI_NOT_READY No incoming or outgoing data was processed.
515 @retval EFI_TIMEOUT Data was dropped out of the transmission or
516 receive queue. Consider increasing the polling
523 IN EFI_TCP4_PROTOCOL
*This
530 return EFI_INVALID_PARAMETER
;
533 Sock
= SOCK_FROM_THIS (This
);
535 Status
= Sock
->ProtoHandler (Sock
, SOCK_POLL
, NULL
);
541 Get the current operational status.
543 The GetModeData() function copies the current operational settings of this EFI TCPv6
544 Protocol instance into user-supplied buffers. This function can also be used to retrieve
545 the operational setting of underlying drivers such as IPv6, MNP, or SNP.
547 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
548 @param[out] Tcp6State The buffer in which the current TCP state is
549 returned. Optional parameter that may be NULL.
550 @param[out] Tcp6ConfigData The buffer in which the current TCP configuration
551 is returned. Optional parameter that may be NULL.
552 @param[out] Ip6ModeData The buffer in which the current IPv6 configuration
553 data used by the TCP instance is returned.
554 Optional parameter that may be NULL.
555 @param[out] MnpConfigData The buffer in which the current MNP configuration
556 data indirectly used by the TCP instance is returned.
557 Optional parameter that may be NULL.
558 @param[out] SnpModeData The buffer in which the current SNP mode data
559 indirectly used by the TCP instance is returned.
560 Optional parameter that may be NULL.
562 @retval EFI_SUCCESS The mode data was read.
563 @retval EFI_NOT_STARTED No configuration data is available because this instance hasn't
565 @retval EFI_INVALID_PARAMETER This is NULL.
571 IN EFI_TCP6_PROTOCOL
*This
,
572 OUT EFI_TCP6_CONNECTION_STATE
*Tcp6State OPTIONAL
,
573 OUT EFI_TCP6_CONFIG_DATA
*Tcp6ConfigData OPTIONAL
,
574 OUT EFI_IP6_MODE_DATA
*Ip6ModeData OPTIONAL
,
575 OUT EFI_MANAGED_NETWORK_CONFIG_DATA
*MnpConfigData OPTIONAL
,
576 OUT EFI_SIMPLE_NETWORK_MODE
*SnpModeData OPTIONAL
579 TCP6_MODE_DATA TcpMode
;
583 return EFI_INVALID_PARAMETER
;
586 Sock
= SOCK_FROM_THIS (This
);
588 TcpMode
.Tcp6State
= Tcp6State
;
589 TcpMode
.Tcp6ConfigData
= Tcp6ConfigData
;
590 TcpMode
.Ip6ModeData
= Ip6ModeData
;
591 TcpMode
.MnpConfigData
= MnpConfigData
;
592 TcpMode
.SnpModeData
= SnpModeData
;
594 return SockGetMode (Sock
, &TcpMode
);
598 Initialize or brutally reset the operational parameters for this EFI TCPv6 instance.
600 The Configure() function does the following:
601 - Initialize this TCP instance, i.e., initialize the communication end settings and
602 specify active open or passive open for an instance.
603 - Reset this TCP instance brutally, i.e., cancel all pending asynchronous tokens, flush
604 transmission and receiving buffer directly without informing the communication peer.
606 No other TCPv6 Protocol operation except Poll() can be executed by this instance until
607 it is configured properly. For an active TCP instance, after a proper configuration it
608 may call Connect() to initiate a three-way handshake. For a passive TCP instance,
609 its state transits to Tcp6StateListen after configuration, and Accept() may be
610 called to listen the incoming TCP connection requests. If Tcp6ConfigData is set to NULL,
611 the instance is reset. The resetting process will be done brutally, the state machine will
612 be set to Tcp6StateClosed directly, the receive queue and transmit queue will be flushed,
613 and no traffic is allowed through this instance.
615 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
616 @param[in] Tcp6ConfigData Pointer to the configure data to configure the instance.
617 If Tcp6ConfigData is set to NULL, the instance is reset.
619 @retval EFI_SUCCESS The operational settings were set, changed, or reset
621 @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a source
622 address for this instance, but no source address was available for
624 @retval EFI_INVALID_PARAMETER One or more of the following conditions are TRUE:
626 - Tcp6ConfigData->AccessPoint.StationAddress is neither zero nor
627 one of the configured IP addresses in the underlying IPv6 driver.
628 - Tcp6ConfigData->AccessPoint.RemoteAddress isn't a valid unicast
630 - Tcp6ConfigData->AccessPoint.RemoteAddress is zero or
631 Tcp6ConfigData->AccessPoint.RemotePort is zero when
632 Tcp6ConfigData->AccessPoint.ActiveFlag is TRUE.
633 - A same access point has been configured in other TCP
635 @retval EFI_ACCESS_DENIED Configuring a TCP instance when it is configured without
636 calling Configure() with NULL to reset it.
637 @retval EFI_UNSUPPORTED One or more of the control options are not supported in
639 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources when
640 executing Configure().
641 @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.
647 IN EFI_TCP6_PROTOCOL
*This
,
648 IN EFI_TCP6_CONFIG_DATA
*Tcp6ConfigData OPTIONAL
651 EFI_TCP6_OPTION
*Option
;
654 EFI_IPv6_ADDRESS
*Ip
;
657 return EFI_INVALID_PARAMETER
;
661 // Tcp protocol related parameter check will be conducted here
663 if (NULL
!= Tcp6ConfigData
) {
665 Ip
= &Tcp6ConfigData
->AccessPoint
.RemoteAddress
;
666 if (!NetIp6IsUnspecifiedAddr (Ip
) && !NetIp6IsValidUnicast (Ip
)) {
667 return EFI_INVALID_PARAMETER
;
670 if (Tcp6ConfigData
->AccessPoint
.ActiveFlag
&&
671 (0 == Tcp6ConfigData
->AccessPoint
.RemotePort
|| NetIp6IsUnspecifiedAddr (Ip
))
673 return EFI_INVALID_PARAMETER
;
676 Ip
= &Tcp6ConfigData
->AccessPoint
.StationAddress
;
677 if (!NetIp6IsUnspecifiedAddr (Ip
) && !NetIp6IsValidUnicast (Ip
)) {
678 return EFI_INVALID_PARAMETER
;
681 Option
= Tcp6ConfigData
->ControlOption
;
682 if ((NULL
!= Option
) && (Option
->EnableSelectiveAck
|| Option
->EnablePathMtuDiscovery
)) {
683 return EFI_UNSUPPORTED
;
687 Sock
= SOCK_FROM_THIS (This
);
689 if (NULL
== Tcp6ConfigData
) {
690 return SockFlush (Sock
);
693 Status
= SockConfigure (Sock
, Tcp6ConfigData
);
695 if (EFI_NO_MAPPING
== Status
) {
696 Sock
->ConfigureState
= SO_NO_MAPPING
;
703 Initiate a nonblocking TCP connection request for an active TCP instance.
705 The Connect() function will initiate an active open to the remote peer configured
706 in a current TCP instance if it is configured active. If the connection succeeds or
707 fails due to any error, the ConnectionToken->CompletionToken.Event will be signaled
708 and ConnectionToken->CompletionToken.Status will be updated accordingly. This
709 function can only be called for the TCP instance in the Tcp6StateClosed state. The
710 instance will transfer into Tcp6StateSynSent if the function returns EFI_SUCCESS.
711 If a TCP three-way handshake succeeds, its state will become Tcp6StateEstablished.
712 Otherwise, the state will return to Tcp6StateClosed.
714 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
715 @param[in] ConnectionToken Pointer to the connection token to return when the TCP three
716 way handshake finishes.
718 @retval EFI_SUCCESS The connection request successfully initiated and the state of
719 this TCP instance has been changed to Tcp6StateSynSent.
720 @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.
721 @retval EFI_ACCESS_DENIED One or more of the following conditions are TRUE:
722 - This instance is not configured as an active one.
723 - This instance is not in Tcp6StateClosed state.
724 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
726 - ConnectionToken is NULL.
727 - ConnectionToken->CompletionToken.Event is NULL.
728 @retval EFI_OUT_OF_RESOURCES The driver can't allocate enough resources to initiate the active open.
729 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
735 IN EFI_TCP6_PROTOCOL
*This
,
736 IN EFI_TCP6_CONNECTION_TOKEN
*ConnectionToken
741 if (NULL
== This
|| NULL
== ConnectionToken
|| NULL
== ConnectionToken
->CompletionToken
.Event
) {
742 return EFI_INVALID_PARAMETER
;
745 Sock
= SOCK_FROM_THIS (This
);
747 return SockConnect (Sock
, ConnectionToken
);
751 Listen on the passive instance to accept an incoming connection request. This is a
752 nonblocking operation.
754 The Accept() function initiates an asynchronous accept request to wait for an incoming
755 connection on the passive TCP instance. If a remote peer successfully establishes a
756 connection with this instance, a new TCP instance will be created and its handle will
757 be returned in ListenToken->NewChildHandle. The newly created instance is configured
758 by inheriting the passive instance's configuration and is ready for use upon return.
759 The new instance is in the Tcp6StateEstablished state.
761 The ListenToken->CompletionToken.Event will be signaled when a new connection is
762 accepted, when a user aborts the listen or when a connection is reset.
764 This function only can be called when a current TCP instance is in Tcp6StateListen state.
766 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
767 @param[in] ListenToken Pointer to the listen token to return when operation finishes.
770 @retval EFI_SUCCESS The listen token queued successfully.
771 @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.
772 @retval EFI_ACCESS_DENIED One or more of the following are TRUE:
773 - This instance is not a passive instance.
774 - This instance is not in Tcp6StateListen state.
775 - The same listen token has already existed in the listen
776 token queue of this TCP instance.
777 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
779 - ListenToken is NULL.
780 - ListentToken->CompletionToken.Event is NULL.
781 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resource to finish the operation.
782 @retval EFI_DEVICE_ERROR Any unexpected error not belonging to a category listed above.
788 IN EFI_TCP6_PROTOCOL
*This
,
789 IN EFI_TCP6_LISTEN_TOKEN
*ListenToken
794 if (NULL
== This
|| NULL
== ListenToken
|| NULL
== ListenToken
->CompletionToken
.Event
) {
795 return EFI_INVALID_PARAMETER
;
798 Sock
= SOCK_FROM_THIS (This
);
800 return SockAccept (Sock
, ListenToken
);
804 Queues outgoing data into the transmit queue.
806 The Transmit() function queues a sending request to this TCP instance along with the
807 user data. The status of the token is updated and the event in the token will be
808 signaled once the data is sent out or an error occurs.
810 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
811 @param[in] Token Pointer to the completion token to queue to the transmit queue.
813 @retval EFI_SUCCESS The data has been queued for transmission.
814 @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.
815 @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a
816 source address for this instance, but no source address was
818 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
821 - Token->CompletionToken.Event is NULL.
822 - Token->Packet.TxData is NULL.
823 - Token->Packet.FragmentCount is zero.
824 - Token->Packet.DataLength is not equal to the sum of fragment lengths.
825 @retval EFI_ACCESS_DENIED One or more of the following conditions are TRUE:
826 - A transmit completion token with the same Token->
827 CompletionToken.Event was already in the
829 - The current instance is in Tcp6StateClosed state.
830 - The current instance is a passive one and it is in
831 Tcp6StateListen state.
832 - User has called Close() to disconnect this connection.
833 @retval EFI_NOT_READY The completion token could not be queued because the
834 transmit queue is full.
835 @retval EFI_OUT_OF_RESOURCES Could not queue the transmit data because of resource
837 @retval EFI_NETWORK_UNREACHABLE There is no route to the destination network or address.
843 IN EFI_TCP6_PROTOCOL
*This
,
844 IN EFI_TCP6_IO_TOKEN
*Token
852 NULL
== Token
->CompletionToken
.Event
||
853 NULL
== Token
->Packet
.TxData
||
854 0 == Token
->Packet
.TxData
->FragmentCount
||
855 0 == Token
->Packet
.TxData
->DataLength
857 return EFI_INVALID_PARAMETER
;
860 Status
= TcpChkDataBuf (
861 Token
->Packet
.TxData
->DataLength
,
862 Token
->Packet
.TxData
->FragmentCount
,
863 (EFI_TCP4_FRAGMENT_DATA
*) Token
->Packet
.TxData
->FragmentTable
865 if (EFI_ERROR (Status
)) {
869 Sock
= SOCK_FROM_THIS (This
);
871 return SockSend (Sock
, Token
);
875 Places an asynchronous receive request into the receiving queue.
877 The Receive() function places a completion token into the receive packet queue. This
878 function is always asynchronous. The caller must allocate the Token->CompletionToken.Event
879 and the FragmentBuffer used to receive data. The caller also must fill the DataLength that
880 represents the whole length of all FragmentBuffer. When the receive operation completes, the
881 EFI TCPv6 Protocol driver updates the Token->CompletionToken.Status and Token->Packet.RxData
882 fields, and the Token->CompletionToken.Event is signaled. If data obtained, the data and its length
883 will be copied into the FragmentTable; at the same time the full length of received data will
884 be recorded in the DataLength fields. Providing a proper notification function and context
885 for the event enables the user to receive the notification and receiving status. That
886 notification function is guaranteed to not be re-entered.
888 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
889 @param[in] Token Pointer to a token that is associated with the receive data
892 @retval EFI_SUCCESS The receive completion token was cached.
893 @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.
894 @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a source
895 address for this instance, but no source address was available for use.
896 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
899 - Token->CompletionToken.Event is NULL.
900 - Token->Packet.RxData is NULL.
901 - Token->Packet.RxData->DataLength is 0.
902 - The Token->Packet.RxData->DataLength is not the
903 sum of all FragmentBuffer length in FragmentTable.
904 @retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued due to a lack of
905 system resources (usually memory).
906 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
907 The EFI TCPv6 Protocol instance has been reset to startup defaults.
908 @retval EFI_ACCESS_DENIED One or more of the following conditions is TRUE:
909 - A receive completion token with the same Token->CompletionToken.Event
910 was already in the receive queue.
911 - The current instance is in Tcp6StateClosed state.
912 - The current instance is a passive one and it is in
913 Tcp6StateListen state.
914 - User has called Close() to disconnect this connection.
915 @retval EFI_CONNECTION_FIN The communication peer has closed the connection and there is no
916 buffered data in the receive buffer of this instance.
917 @retval EFI_NOT_READY The receive request could not be queued because the receive queue is full.
923 IN EFI_TCP6_PROTOCOL
*This
,
924 IN EFI_TCP6_IO_TOKEN
*Token
932 NULL
== Token
->CompletionToken
.Event
||
933 NULL
== Token
->Packet
.RxData
||
934 0 == Token
->Packet
.RxData
->FragmentCount
||
935 0 == Token
->Packet
.RxData
->DataLength
937 return EFI_INVALID_PARAMETER
;
940 Status
= TcpChkDataBuf (
941 Token
->Packet
.RxData
->DataLength
,
942 Token
->Packet
.RxData
->FragmentCount
,
943 (EFI_TCP4_FRAGMENT_DATA
*) Token
->Packet
.RxData
->FragmentTable
945 if (EFI_ERROR (Status
)) {
949 Sock
= SOCK_FROM_THIS (This
);
951 return SockRcv (Sock
, Token
);
955 Disconnecting a TCP connection gracefully or reset a TCP connection. This function is a
956 nonblocking operation.
958 Initiate an asynchronous close token to the TCP driver. After Close() is called, any buffered
959 transmission data will be sent by the TCP driver, and the current instance will have a graceful close
960 working flow described as RFC 793 if AbortOnClose is set to FALSE. Otherwise, a rest packet
961 will be sent by TCP driver to fast disconnect this connection. When the close operation completes
962 successfully the TCP instance is in Tcp6StateClosed state, all pending asynchronous
963 operations are signaled, and any buffers used for TCP network traffic are flushed.
965 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
966 @param[in] CloseToken Pointer to the close token to return when operation finishes.
968 @retval EFI_SUCCESS The Close() was called successfully.
969 @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.
970 @retval EFI_ACCESS_DENIED One or more of the following are TRUE:
971 - CloseToken or CloseToken->CompletionToken.Event is already in use.
972 - Previous Close() call on this instance has not finished.
973 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
975 - CloseToken is NULL.
976 - CloseToken->CompletionToken.Event is NULL.
977 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resource to finish the operation.
978 @retval EFI_DEVICE_ERROR Any unexpected error not belonging to error categories given above.
984 IN EFI_TCP6_PROTOCOL
*This
,
985 IN EFI_TCP6_CLOSE_TOKEN
*CloseToken
990 if (NULL
== This
|| NULL
== CloseToken
|| NULL
== CloseToken
->CompletionToken
.Event
) {
991 return EFI_INVALID_PARAMETER
;
994 Sock
= SOCK_FROM_THIS (This
);
996 return SockClose (Sock
, CloseToken
, CloseToken
->AbortOnClose
);
1000 Abort an asynchronous connection, listen, transmission, or receive request.
1002 The Cancel() function aborts a pending connection, listen, transmit, or
1005 If Token is not NULL and the token is in the connection, listen, transmission,
1006 or receive queue when it is being cancelled, its Token->Status will be set
1007 to EFI_ABORTED, and then Token->Event will be signaled.
1009 If the token is not in one of the queues, which usually means that the
1010 asynchronous operation has completed, EFI_NOT_FOUND is returned.
1012 If Token is NULL all asynchronous token issued by Connect(), Accept(),
1013 Transmit(), and Receive() will be aborted.
1015 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
1016 @param[in] Token Pointer to a token that has been issued by
1017 EFI_TCP6_PROTOCOL.Connect(),
1018 EFI_TCP6_PROTOCOL.Accept(),
1019 EFI_TCP6_PROTOCOL.Transmit() or
1020 EFI_TCP6_PROTOCOL.Receive(). If NULL, all pending
1021 tokens issued by above four functions will be aborted. Type
1022 EFI_TCP6_COMPLETION_TOKEN is defined in
1023 EFI_TCP_PROTOCOL.Connect().
1025 @retval EFI_UNSUPPORTED The implementation does not support this function.
1031 IN EFI_TCP6_PROTOCOL
*This
,
1032 IN EFI_TCP6_COMPLETION_TOKEN
*Token OPTIONAL
1035 return EFI_UNSUPPORTED
;
1039 Poll to receive incoming data and transmit outgoing segments.
1041 The Poll() function increases the rate that data is moved between the network
1042 and application, and can be called when the TCP instance is created successfully.
1043 Its use is optional.
1045 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
1047 @retval EFI_SUCCESS Incoming or outgoing data was processed.
1048 @retval EFI_INVALID_PARAMETER This is NULL.
1049 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
1050 @retval EFI_NOT_READY No incoming or outgoing data is processed.
1051 @retval EFI_TIMEOUT Data was dropped out of the transmission or receive queue.
1052 Consider increasing the polling rate.
1058 IN EFI_TCP6_PROTOCOL
*This
1065 return EFI_INVALID_PARAMETER
;
1068 Sock
= SOCK_FROM_THIS (This
);
1070 Status
= Sock
->ProtoHandler (Sock
, SOCK_POLL
, NULL
);