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 SPDX-License-Identifier: BSD-2-Clause-Patent
14 Check the integrity of the data buffer.
16 @param[in] DataLen The total length of the data buffer.
17 @param[in] FragmentCount The fragment count of the fragment table.
18 @param[in] FragmentTable Pointer to the fragment table of the data
21 @retval EFI_SUCCESS The integrity check passed.
22 @retval EFI_INVALID_PARAMETER The integrity check failed.
28 IN UINT32 FragmentCount
,
29 IN EFI_TCP4_FRAGMENT_DATA
*FragmentTable
36 for (Index
= 0, Len
= 0; Index
< FragmentCount
; Index
++) {
37 if (FragmentTable
[Index
].FragmentBuffer
== NULL
) {
38 return EFI_INVALID_PARAMETER
;
40 Len
= Len
+ FragmentTable
[Index
].FragmentLength
;
44 return EFI_INVALID_PARAMETER
;
51 Get the current operational status.
53 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
54 @param[out] Tcp4State Pointer to the buffer to receive the current TCP
55 state. Optional parameter that may be NULL.
56 @param[out] Tcp4ConfigData Pointer to the buffer to receive the current TCP
57 configuration. Optional parameter that may be NULL.
58 @param[out] Ip4ModeData Pointer to the buffer to receive the current
59 IPv4 configuration. Optional parameter that may be NULL.
60 @param[out] MnpConfigData Pointer to the buffer to receive the current MNP
61 configuration data indirectly used by the TCPv4
62 Instance. Optional parameter that may be NULL.
63 @param[out] SnpModeData Pointer to the buffer to receive the current SNP
64 configuration data indirectly used by the TCPv4
65 Instance. Optional parameter that may be NULL.
67 @retval EFI_SUCCESS The mode data was read.
68 @retval EFI_NOT_STARTED No configuration data is available because this
69 instance hasn't been started.
70 @retval EFI_INVALID_PARAMETER This is NULL.
76 IN EFI_TCP4_PROTOCOL
*This
,
77 OUT EFI_TCP4_CONNECTION_STATE
*Tcp4State OPTIONAL
,
78 OUT EFI_TCP4_CONFIG_DATA
*Tcp4ConfigData OPTIONAL
,
79 OUT EFI_IP4_MODE_DATA
*Ip4ModeData OPTIONAL
,
80 OUT EFI_MANAGED_NETWORK_CONFIG_DATA
*MnpConfigData OPTIONAL
,
81 OUT EFI_SIMPLE_NETWORK_MODE
*SnpModeData OPTIONAL
84 TCP4_MODE_DATA TcpMode
;
88 return EFI_INVALID_PARAMETER
;
91 Sock
= SOCK_FROM_THIS (This
);
93 TcpMode
.Tcp4State
= Tcp4State
;
94 TcpMode
.Tcp4ConfigData
= Tcp4ConfigData
;
95 TcpMode
.Ip4ModeData
= Ip4ModeData
;
96 TcpMode
.MnpConfigData
= MnpConfigData
;
97 TcpMode
.SnpModeData
= SnpModeData
;
99 return SockGetMode (Sock
, &TcpMode
);
103 Initialize or brutally reset the operational parameters for
104 this EFI TCPv4 instance.
106 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
107 @param[in] TcpConfigData Pointer to the configure data to configure the
108 instance. Optional parameter that may be NULL.
110 @retval EFI_SUCCESS The operational settings were set, changed, or
112 @retval EFI_NO_MAPPING When using a default address, configuration
113 (through DHCP, BOOTP, RARP, etc.) is not
115 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
116 @retval EFI_ACCESS_DENIED Configuring TCP instance when it is already
118 @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.
119 @retval EFI_UNSUPPORTED One or more of the control options are not
120 supported in the implementation.
121 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources.
127 IN EFI_TCP4_PROTOCOL
* This
,
128 IN EFI_TCP4_CONFIG_DATA
* TcpConfigData OPTIONAL
131 EFI_TCP4_OPTION
*Option
;
138 return EFI_INVALID_PARAMETER
;
142 // Tcp protocol related parameter check will be conducted here
144 if (NULL
!= TcpConfigData
) {
146 CopyMem (&Ip
, &TcpConfigData
->AccessPoint
.RemoteAddress
, sizeof (IP4_ADDR
));
147 if (IP4_IS_LOCAL_BROADCAST (NTOHL (Ip
))) {
148 return EFI_INVALID_PARAMETER
;
151 if (TcpConfigData
->AccessPoint
.ActiveFlag
&& (0 == TcpConfigData
->AccessPoint
.RemotePort
|| (Ip
== 0))) {
152 return EFI_INVALID_PARAMETER
;
155 if (!TcpConfigData
->AccessPoint
.UseDefaultAddress
) {
157 CopyMem (&Ip
, &TcpConfigData
->AccessPoint
.StationAddress
, sizeof (IP4_ADDR
));
158 CopyMem (&SubnetMask
, &TcpConfigData
->AccessPoint
.SubnetMask
, sizeof (IP4_ADDR
));
159 if (!IP4_IS_VALID_NETMASK (NTOHL (SubnetMask
)) ||
160 (SubnetMask
!= 0 && !NetIp4IsUnicast (NTOHL (Ip
), NTOHL (SubnetMask
)))) {
161 return EFI_INVALID_PARAMETER
;
165 Option
= TcpConfigData
->ControlOption
;
166 if ((NULL
!= Option
) && (Option
->EnableSelectiveAck
|| Option
->EnablePathMtuDiscovery
)) {
167 return EFI_UNSUPPORTED
;
171 Sock
= SOCK_FROM_THIS (This
);
173 if (NULL
== TcpConfigData
) {
174 return SockFlush (Sock
);
177 Status
= SockConfigure (Sock
, TcpConfigData
);
179 if (EFI_NO_MAPPING
== Status
) {
180 Sock
->ConfigureState
= SO_NO_MAPPING
;
187 Add or delete routing entries.
189 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
190 @param[in] DeleteRoute If TRUE, delete the specified route from routing
191 table; if FALSE, add the specified route to
193 @param[in] SubnetAddress The destination network.
194 @param[in] SubnetMask The subnet mask for the destination network.
195 @param[in] GatewayAddress The gateway address for this route.
197 @retval EFI_SUCCESS The operation completed successfully.
198 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance has not been
200 @retval EFI_NO_MAPPING When using a default address, configuration
201 (through DHCP, BOOTP, RARP, etc.) is not
203 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
204 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resources to add the
205 entry to the routing table.
206 @retval EFI_NOT_FOUND This route is not in the routing table.
207 @retval EFI_ACCESS_DENIED This route is already in the routing table.
208 @retval EFI_UNSUPPORTED The TCP driver does not support this operation.
214 IN EFI_TCP4_PROTOCOL
*This
,
215 IN BOOLEAN DeleteRoute
,
216 IN EFI_IPv4_ADDRESS
*SubnetAddress
,
217 IN EFI_IPv4_ADDRESS
*SubnetMask
,
218 IN EFI_IPv4_ADDRESS
*GatewayAddress
222 TCP4_ROUTE_INFO RouteInfo
;
225 return EFI_INVALID_PARAMETER
;
228 Sock
= SOCK_FROM_THIS (This
);
230 RouteInfo
.DeleteRoute
= DeleteRoute
;
231 RouteInfo
.SubnetAddress
= SubnetAddress
;
232 RouteInfo
.SubnetMask
= SubnetMask
;
233 RouteInfo
.GatewayAddress
= GatewayAddress
;
235 return SockRoute (Sock
, &RouteInfo
);
239 Initiate a non-blocking TCP connection request for an active TCP instance.
241 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
242 @param[in] ConnectionToken Pointer to the connection token to return when
243 the TCP three way handshake finishes.
245 @retval EFI_SUCCESS The connection request successfully
247 @retval EFI_NOT_STARTED This EFI_TCP4_PROTOCOL instance hasn't been
249 @retval EFI_ACCESS_DENIED The instance is not configured as an active one,
250 or it is not in Tcp4StateClosed state.
251 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
252 @retval EFI_OUT_OF_RESOURCES The driver can't allocate enough resources to
253 initiate the active open.
254 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
260 IN EFI_TCP4_PROTOCOL
*This
,
261 IN EFI_TCP4_CONNECTION_TOKEN
*ConnectionToken
266 if (NULL
== This
|| NULL
== ConnectionToken
|| NULL
== ConnectionToken
->CompletionToken
.Event
) {
267 return EFI_INVALID_PARAMETER
;
270 Sock
= SOCK_FROM_THIS (This
);
272 return SockConnect (Sock
, ConnectionToken
);
276 Listen on the passive instance to accept an incoming connection request.
278 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
279 @param[in] ListenToken Pointer to the listen token to return when
282 @retval EFI_SUCCESS The listen token was queued successfully.
283 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been
285 @retval EFI_ACCESS_DENIED The instatnce is not a passive one or it is not
286 in Tcp4StateListen state or a same listen token
287 has already existed in the listen token queue of
289 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
290 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resources to finish
292 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
298 IN EFI_TCP4_PROTOCOL
*This
,
299 IN EFI_TCP4_LISTEN_TOKEN
*ListenToken
304 if (NULL
== This
|| NULL
== ListenToken
|| NULL
== ListenToken
->CompletionToken
.Event
) {
305 return EFI_INVALID_PARAMETER
;
308 Sock
= SOCK_FROM_THIS (This
);
310 return SockAccept (Sock
, ListenToken
);
314 Queues outgoing data into the transmit queue
316 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
317 @param[in] Token Pointer to the completion token to queue to the
320 @retval EFI_SUCCESS The data has been queued for transmission.
321 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been
323 @retval EFI_NO_MAPPING When using a default address, configuration
324 (DHCP, BOOTP, RARP, etc.) is not finished yet.
325 @retval EFI_INVALID_PARAMETER One or more parameters are invalid
326 @retval EFI_ACCESS_DENIED One or more of the following conditions is TRUE:
327 * A transmit completion token with the same
328 Token-> CompletionToken.Event was already in the
329 transmission queue. * The current instance is in
330 Tcp4StateClosed state. * The current instance is
331 a passive one and it is in Tcp4StateListen
332 state. * User has called Close() to disconnect
334 @retval EFI_NOT_READY The completion token could not be queued because
335 the transmit queue is full.
336 @retval EFI_OUT_OF_RESOURCES Could not queue the transmit data because of a
338 @retval EFI_NETWORK_UNREACHABLE There is no route to the destination network or
345 IN EFI_TCP4_PROTOCOL
*This
,
346 IN EFI_TCP4_IO_TOKEN
*Token
354 NULL
== Token
->CompletionToken
.Event
||
355 NULL
== Token
->Packet
.TxData
||
356 0 == Token
->Packet
.TxData
->FragmentCount
||
357 0 == Token
->Packet
.TxData
->DataLength
359 return EFI_INVALID_PARAMETER
;
362 Status
= TcpChkDataBuf (
363 Token
->Packet
.TxData
->DataLength
,
364 Token
->Packet
.TxData
->FragmentCount
,
365 Token
->Packet
.TxData
->FragmentTable
367 if (EFI_ERROR (Status
)) {
371 Sock
= SOCK_FROM_THIS (This
);
373 return SockSend (Sock
, Token
);
377 Place an asynchronous receive request into the receiving queue.
379 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
380 @param[in] Token Pointer to a token that is associated with the
381 receive data descriptor.
383 @retval EFI_SUCCESS The receive completion token was cached
384 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been
386 @retval EFI_NO_MAPPING When using a default address, configuration
387 (DHCP, BOOTP, RARP, etc.) is not finished yet.
388 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
389 @retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued
390 due to a lack of system resources.
391 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
392 @retval EFI_ACCESS_DENIED One or more of the following conditions is TRUE:
393 * A receive completion token with the same
394 Token->CompletionToken.Event was already in the
395 receive queue. * The current instance is in
396 Tcp4StateClosed state. * The current instance is
397 a passive one and it is in Tcp4StateListen
398 state. * User has called Close() to disconnect
400 @retval EFI_CONNECTION_FIN The communication peer has closed the connection,
401 and there is no any buffered data in the receive
402 buffer of this instance.
403 @retval EFI_NOT_READY The receive request could not be queued because
404 the receive queue is full.
410 IN EFI_TCP4_PROTOCOL
*This
,
411 IN EFI_TCP4_IO_TOKEN
*Token
419 NULL
== Token
->CompletionToken
.Event
||
420 NULL
== Token
->Packet
.RxData
||
421 0 == Token
->Packet
.RxData
->FragmentCount
||
422 0 == Token
->Packet
.RxData
->DataLength
424 return EFI_INVALID_PARAMETER
;
427 Status
= TcpChkDataBuf (
428 Token
->Packet
.RxData
->DataLength
,
429 Token
->Packet
.RxData
->FragmentCount
,
430 Token
->Packet
.RxData
->FragmentTable
432 if (EFI_ERROR (Status
)) {
436 Sock
= SOCK_FROM_THIS (This
);
438 return SockRcv (Sock
, Token
);
443 Disconnecting a TCP connection gracefully or reset a TCP connection.
445 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
446 @param[in] CloseToken Pointer to the close token to return when
449 @retval EFI_SUCCESS The operation completed successfully.
450 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been
452 @retval EFI_ACCESS_DENIED One or more of the following are TRUE: *
453 Configure() has been called with TcpConfigData
454 set to NULL, and this function has not returned.
455 * Previous Close() call on this instance has not
457 @retval EFI_INVALID_PARAMETER One ore more parameters are invalid.
458 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resources to finish the
460 @retval EFI_DEVICE_ERROR Any unexpected category error not belonging to those
467 IN EFI_TCP4_PROTOCOL
*This
,
468 IN EFI_TCP4_CLOSE_TOKEN
*CloseToken
473 if (NULL
== This
|| NULL
== CloseToken
|| NULL
== CloseToken
->CompletionToken
.Event
) {
474 return EFI_INVALID_PARAMETER
;
477 Sock
= SOCK_FROM_THIS (This
);
479 return SockClose (Sock
, CloseToken
, CloseToken
->AbortOnClose
);
483 Abort an asynchronous connection, listen, transmission or receive request.
485 @param This The pointer to the EFI_TCP4_PROTOCOL instance.
486 @param Token The pointer to a token that has been issued by
487 EFI_TCP4_PROTOCOL.Connect(),
488 EFI_TCP4_PROTOCOL.Accept(),
489 EFI_TCP4_PROTOCOL.Transmit() or
490 EFI_TCP4_PROTOCOL.Receive(). If NULL, all pending
491 tokens issued by above four functions will be aborted. Type
492 EFI_TCP4_COMPLETION_TOKEN is defined in
493 EFI_TCP4_PROTOCOL.Connect().
495 @retval EFI_SUCCESS The asynchronous I/O request is aborted and Token->Event
497 @retval EFI_INVALID_PARAMETER This is NULL.
498 @retval EFI_NOT_STARTED This instance hasn't been configured.
499 @retval EFI_NO_MAPPING When using the default address, configuration
500 (DHCP, BOOTP,RARP, etc.) hasn't finished yet.
501 @retval EFI_NOT_FOUND The asynchronous I/O request isn't found in the
502 transmission or receive queue. It has either
503 completed or wasn't issued by Transmit() and Receive().
509 IN EFI_TCP4_PROTOCOL
*This
,
510 IN EFI_TCP4_COMPLETION_TOKEN
*Token OPTIONAL
516 return EFI_INVALID_PARAMETER
;
519 Sock
= SOCK_FROM_THIS (This
);
521 return SockCancel (Sock
, Token
);
525 Poll to receive incoming data and transmit outgoing segments.
527 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.
529 @retval EFI_SUCCESS Incoming or outgoing data was processed.
530 @retval EFI_INVALID_PARAMETER This is NULL.
531 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
532 @retval EFI_NOT_READY No incoming or outgoing data was processed.
533 @retval EFI_TIMEOUT Data was dropped out of the transmission or
534 receive queue. Consider increasing the polling
541 IN EFI_TCP4_PROTOCOL
*This
548 return EFI_INVALID_PARAMETER
;
551 Sock
= SOCK_FROM_THIS (This
);
553 Status
= Sock
->ProtoHandler (Sock
, SOCK_POLL
, NULL
);
559 Get the current operational status.
561 The GetModeData() function copies the current operational settings of this EFI TCPv6
562 Protocol instance into user-supplied buffers. This function can also be used to retrieve
563 the operational setting of underlying drivers such as IPv6, MNP, or SNP.
565 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
566 @param[out] Tcp6State The buffer in which the current TCP state is
567 returned. Optional parameter that may be NULL.
568 @param[out] Tcp6ConfigData The buffer in which the current TCP configuration
569 is returned. Optional parameter that may be NULL.
570 @param[out] Ip6ModeData The buffer in which the current IPv6 configuration
571 data used by the TCP instance is returned.
572 Optional parameter that may be NULL.
573 @param[out] MnpConfigData The buffer in which the current MNP configuration
574 data indirectly used by the TCP instance is returned.
575 Optional parameter that may be NULL.
576 @param[out] SnpModeData The buffer in which the current SNP mode data
577 indirectly used by the TCP instance is returned.
578 Optional parameter that may be NULL.
580 @retval EFI_SUCCESS The mode data was read.
581 @retval EFI_NOT_STARTED No configuration data is available because this instance hasn't
583 @retval EFI_INVALID_PARAMETER This is NULL.
589 IN EFI_TCP6_PROTOCOL
*This
,
590 OUT EFI_TCP6_CONNECTION_STATE
*Tcp6State OPTIONAL
,
591 OUT EFI_TCP6_CONFIG_DATA
*Tcp6ConfigData OPTIONAL
,
592 OUT EFI_IP6_MODE_DATA
*Ip6ModeData OPTIONAL
,
593 OUT EFI_MANAGED_NETWORK_CONFIG_DATA
*MnpConfigData OPTIONAL
,
594 OUT EFI_SIMPLE_NETWORK_MODE
*SnpModeData OPTIONAL
597 TCP6_MODE_DATA TcpMode
;
601 return EFI_INVALID_PARAMETER
;
604 Sock
= SOCK_FROM_THIS (This
);
606 TcpMode
.Tcp6State
= Tcp6State
;
607 TcpMode
.Tcp6ConfigData
= Tcp6ConfigData
;
608 TcpMode
.Ip6ModeData
= Ip6ModeData
;
609 TcpMode
.MnpConfigData
= MnpConfigData
;
610 TcpMode
.SnpModeData
= SnpModeData
;
612 return SockGetMode (Sock
, &TcpMode
);
616 Initialize or brutally reset the operational parameters for this EFI TCPv6 instance.
618 The Configure() function does the following:
619 - Initialize this TCP instance, i.e., initialize the communication end settings and
620 specify active open or passive open for an instance.
621 - Reset this TCP instance brutally, i.e., cancel all pending asynchronous tokens, flush
622 transmission and receiving buffer directly without informing the communication peer.
624 No other TCPv6 Protocol operation except Poll() can be executed by this instance until
625 it is configured properly. For an active TCP instance, after a proper configuration it
626 may call Connect() to initiate a three-way handshake. For a passive TCP instance,
627 its state transits to Tcp6StateListen after configuration, and Accept() may be
628 called to listen the incoming TCP connection requests. If Tcp6ConfigData is set to NULL,
629 the instance is reset. The resetting process will be done brutally, the state machine will
630 be set to Tcp6StateClosed directly, the receive queue and transmit queue will be flushed,
631 and no traffic is allowed through this instance.
633 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
634 @param[in] Tcp6ConfigData Pointer to the configure data to configure the instance.
635 If Tcp6ConfigData is set to NULL, the instance is reset.
637 @retval EFI_SUCCESS The operational settings were set, changed, or reset
639 @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a source
640 address for this instance, but no source address was available for
642 @retval EFI_INVALID_PARAMETER One or more of the following conditions are TRUE:
644 - Tcp6ConfigData->AccessPoint.StationAddress is neither zero nor
645 one of the configured IP addresses in the underlying IPv6 driver.
646 - Tcp6ConfigData->AccessPoint.RemoteAddress isn't a valid unicast
648 - Tcp6ConfigData->AccessPoint.RemoteAddress is zero or
649 Tcp6ConfigData->AccessPoint.RemotePort is zero when
650 Tcp6ConfigData->AccessPoint.ActiveFlag is TRUE.
651 - A same access point has been configured in other TCP
653 @retval EFI_ACCESS_DENIED Configuring a TCP instance when it is configured without
654 calling Configure() with NULL to reset it.
655 @retval EFI_UNSUPPORTED One or more of the control options are not supported in
657 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources when
658 executing Configure().
659 @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.
665 IN EFI_TCP6_PROTOCOL
*This
,
666 IN EFI_TCP6_CONFIG_DATA
*Tcp6ConfigData OPTIONAL
669 EFI_TCP6_OPTION
*Option
;
672 EFI_IPv6_ADDRESS
*Ip
;
675 return EFI_INVALID_PARAMETER
;
679 // Tcp protocol related parameter check will be conducted here
681 if (NULL
!= Tcp6ConfigData
) {
683 Ip
= &Tcp6ConfigData
->AccessPoint
.RemoteAddress
;
684 if (!NetIp6IsUnspecifiedAddr (Ip
) && !NetIp6IsValidUnicast (Ip
)) {
685 return EFI_INVALID_PARAMETER
;
688 if (Tcp6ConfigData
->AccessPoint
.ActiveFlag
&&
689 (0 == Tcp6ConfigData
->AccessPoint
.RemotePort
|| NetIp6IsUnspecifiedAddr (Ip
))
691 return EFI_INVALID_PARAMETER
;
694 Ip
= &Tcp6ConfigData
->AccessPoint
.StationAddress
;
695 if (!NetIp6IsUnspecifiedAddr (Ip
) && !NetIp6IsValidUnicast (Ip
)) {
696 return EFI_INVALID_PARAMETER
;
699 Option
= Tcp6ConfigData
->ControlOption
;
700 if ((NULL
!= Option
) && (Option
->EnableSelectiveAck
|| Option
->EnablePathMtuDiscovery
)) {
701 return EFI_UNSUPPORTED
;
705 Sock
= SOCK_FROM_THIS (This
);
707 if (NULL
== Tcp6ConfigData
) {
708 return SockFlush (Sock
);
711 Status
= SockConfigure (Sock
, Tcp6ConfigData
);
713 if (EFI_NO_MAPPING
== Status
) {
714 Sock
->ConfigureState
= SO_NO_MAPPING
;
721 Initiate a nonblocking TCP connection request for an active TCP instance.
723 The Connect() function will initiate an active open to the remote peer configured
724 in a current TCP instance if it is configured active. If the connection succeeds or
725 fails due to any error, the ConnectionToken->CompletionToken.Event will be signaled
726 and ConnectionToken->CompletionToken.Status will be updated accordingly. This
727 function can only be called for the TCP instance in the Tcp6StateClosed state. The
728 instance will transfer into Tcp6StateSynSent if the function returns EFI_SUCCESS.
729 If a TCP three-way handshake succeeds, its state will become Tcp6StateEstablished.
730 Otherwise, the state will return to Tcp6StateClosed.
732 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
733 @param[in] ConnectionToken Pointer to the connection token to return when the TCP three
734 way handshake finishes.
736 @retval EFI_SUCCESS The connection request successfully initiated and the state of
737 this TCP instance has been changed to Tcp6StateSynSent.
738 @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.
739 @retval EFI_ACCESS_DENIED One or more of the following conditions are TRUE:
740 - This instance is not configured as an active one.
741 - This instance is not in Tcp6StateClosed state.
742 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
744 - ConnectionToken is NULL.
745 - ConnectionToken->CompletionToken.Event is NULL.
746 @retval EFI_OUT_OF_RESOURCES The driver can't allocate enough resources to initiate the active open.
747 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
753 IN EFI_TCP6_PROTOCOL
*This
,
754 IN EFI_TCP6_CONNECTION_TOKEN
*ConnectionToken
759 if (NULL
== This
|| NULL
== ConnectionToken
|| NULL
== ConnectionToken
->CompletionToken
.Event
) {
760 return EFI_INVALID_PARAMETER
;
763 Sock
= SOCK_FROM_THIS (This
);
765 return SockConnect (Sock
, ConnectionToken
);
769 Listen on the passive instance to accept an incoming connection request. This is a
770 nonblocking operation.
772 The Accept() function initiates an asynchronous accept request to wait for an incoming
773 connection on the passive TCP instance. If a remote peer successfully establishes a
774 connection with this instance, a new TCP instance will be created and its handle will
775 be returned in ListenToken->NewChildHandle. The newly created instance is configured
776 by inheriting the passive instance's configuration and is ready for use upon return.
777 The new instance is in the Tcp6StateEstablished state.
779 The ListenToken->CompletionToken.Event will be signaled when a new connection is
780 accepted, when a user aborts the listen or when a connection is reset.
782 This function only can be called when a current TCP instance is in Tcp6StateListen state.
784 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
785 @param[in] ListenToken Pointer to the listen token to return when operation finishes.
788 @retval EFI_SUCCESS The listen token queued successfully.
789 @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.
790 @retval EFI_ACCESS_DENIED One or more of the following are TRUE:
791 - This instance is not a passive instance.
792 - This instance is not in Tcp6StateListen state.
793 - The same listen token has already existed in the listen
794 token queue of this TCP instance.
795 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
797 - ListenToken is NULL.
798 - ListentToken->CompletionToken.Event is NULL.
799 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resource to finish the operation.
800 @retval EFI_DEVICE_ERROR Any unexpected error not belonging to a category listed above.
806 IN EFI_TCP6_PROTOCOL
*This
,
807 IN EFI_TCP6_LISTEN_TOKEN
*ListenToken
812 if (NULL
== This
|| NULL
== ListenToken
|| NULL
== ListenToken
->CompletionToken
.Event
) {
813 return EFI_INVALID_PARAMETER
;
816 Sock
= SOCK_FROM_THIS (This
);
818 return SockAccept (Sock
, ListenToken
);
822 Queues outgoing data into the transmit queue.
824 The Transmit() function queues a sending request to this TCP instance along with the
825 user data. The status of the token is updated and the event in the token will be
826 signaled once the data is sent out or an error occurs.
828 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
829 @param[in] Token Pointer to the completion token to queue to the transmit queue.
831 @retval EFI_SUCCESS The data has been queued for transmission.
832 @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.
833 @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a
834 source address for this instance, but no source address was
836 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
839 - Token->CompletionToken.Event is NULL.
840 - Token->Packet.TxData is NULL.
841 - Token->Packet.FragmentCount is zero.
842 - Token->Packet.DataLength is not equal to the sum of fragment lengths.
843 @retval EFI_ACCESS_DENIED One or more of the following conditions are TRUE:
844 - A transmit completion token with the same Token->
845 CompletionToken.Event was already in the
847 - The current instance is in Tcp6StateClosed state.
848 - The current instance is a passive one and it is in
849 Tcp6StateListen state.
850 - User has called Close() to disconnect this connection.
851 @retval EFI_NOT_READY The completion token could not be queued because the
852 transmit queue is full.
853 @retval EFI_OUT_OF_RESOURCES Could not queue the transmit data because of resource
855 @retval EFI_NETWORK_UNREACHABLE There is no route to the destination network or address.
861 IN EFI_TCP6_PROTOCOL
*This
,
862 IN EFI_TCP6_IO_TOKEN
*Token
870 NULL
== Token
->CompletionToken
.Event
||
871 NULL
== Token
->Packet
.TxData
||
872 0 == Token
->Packet
.TxData
->FragmentCount
||
873 0 == Token
->Packet
.TxData
->DataLength
875 return EFI_INVALID_PARAMETER
;
878 Status
= TcpChkDataBuf (
879 Token
->Packet
.TxData
->DataLength
,
880 Token
->Packet
.TxData
->FragmentCount
,
881 (EFI_TCP4_FRAGMENT_DATA
*) Token
->Packet
.TxData
->FragmentTable
883 if (EFI_ERROR (Status
)) {
887 Sock
= SOCK_FROM_THIS (This
);
889 return SockSend (Sock
, Token
);
893 Places an asynchronous receive request into the receiving queue.
895 The Receive() function places a completion token into the receive packet queue. This
896 function is always asynchronous. The caller must allocate the Token->CompletionToken.Event
897 and the FragmentBuffer used to receive data. The caller also must fill the DataLength that
898 represents the whole length of all FragmentBuffer. When the receive operation completes, the
899 EFI TCPv6 Protocol driver updates the Token->CompletionToken.Status and Token->Packet.RxData
900 fields, and the Token->CompletionToken.Event is signaled. If data obtained, the data and its length
901 will be copied into the FragmentTable; at the same time the full length of received data will
902 be recorded in the DataLength fields. Providing a proper notification function and context
903 for the event enables the user to receive the notification and receiving status. That
904 notification function is guaranteed to not be re-entered.
906 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
907 @param[in] Token Pointer to a token that is associated with the receive data
910 @retval EFI_SUCCESS The receive completion token was cached.
911 @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.
912 @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a source
913 address for this instance, but no source address was available for use.
914 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
917 - Token->CompletionToken.Event is NULL.
918 - Token->Packet.RxData is NULL.
919 - Token->Packet.RxData->DataLength is 0.
920 - The Token->Packet.RxData->DataLength is not the
921 sum of all FragmentBuffer length in FragmentTable.
922 @retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued due to a lack of
923 system resources (usually memory).
924 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
925 The EFI TCPv6 Protocol instance has been reset to startup defaults.
926 @retval EFI_ACCESS_DENIED One or more of the following conditions is TRUE:
927 - A receive completion token with the same Token->CompletionToken.Event
928 was already in the receive queue.
929 - The current instance is in Tcp6StateClosed state.
930 - The current instance is a passive one and it is in
931 Tcp6StateListen state.
932 - User has called Close() to disconnect this connection.
933 @retval EFI_CONNECTION_FIN The communication peer has closed the connection and there is no
934 buffered data in the receive buffer of this instance.
935 @retval EFI_NOT_READY The receive request could not be queued because the receive queue is full.
941 IN EFI_TCP6_PROTOCOL
*This
,
942 IN EFI_TCP6_IO_TOKEN
*Token
950 NULL
== Token
->CompletionToken
.Event
||
951 NULL
== Token
->Packet
.RxData
||
952 0 == Token
->Packet
.RxData
->FragmentCount
||
953 0 == Token
->Packet
.RxData
->DataLength
955 return EFI_INVALID_PARAMETER
;
958 Status
= TcpChkDataBuf (
959 Token
->Packet
.RxData
->DataLength
,
960 Token
->Packet
.RxData
->FragmentCount
,
961 (EFI_TCP4_FRAGMENT_DATA
*) Token
->Packet
.RxData
->FragmentTable
963 if (EFI_ERROR (Status
)) {
967 Sock
= SOCK_FROM_THIS (This
);
969 return SockRcv (Sock
, Token
);
973 Disconnecting a TCP connection gracefully or reset a TCP connection. This function is a
974 nonblocking operation.
976 Initiate an asynchronous close token to the TCP driver. After Close() is called, any buffered
977 transmission data will be sent by the TCP driver, and the current instance will have a graceful close
978 working flow described as RFC 793 if AbortOnClose is set to FALSE. Otherwise, a rest packet
979 will be sent by TCP driver to fast disconnect this connection. When the close operation completes
980 successfully the TCP instance is in Tcp6StateClosed state, all pending asynchronous
981 operations are signaled, and any buffers used for TCP network traffic are flushed.
983 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
984 @param[in] CloseToken Pointer to the close token to return when operation finishes.
986 @retval EFI_SUCCESS The Close() was called successfully.
987 @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.
988 @retval EFI_ACCESS_DENIED One or more of the following are TRUE:
989 - CloseToken or CloseToken->CompletionToken.Event is already in use.
990 - Previous Close() call on this instance has not finished.
991 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
993 - CloseToken is NULL.
994 - CloseToken->CompletionToken.Event is NULL.
995 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resource to finish the operation.
996 @retval EFI_DEVICE_ERROR Any unexpected error not belonging to error categories given above.
1002 IN EFI_TCP6_PROTOCOL
*This
,
1003 IN EFI_TCP6_CLOSE_TOKEN
*CloseToken
1008 if (NULL
== This
|| NULL
== CloseToken
|| NULL
== CloseToken
->CompletionToken
.Event
) {
1009 return EFI_INVALID_PARAMETER
;
1012 Sock
= SOCK_FROM_THIS (This
);
1014 return SockClose (Sock
, CloseToken
, CloseToken
->AbortOnClose
);
1018 Abort an asynchronous connection, listen, transmission or receive request.
1020 The Cancel() function aborts a pending connection, listen, transmit or
1023 If Token is not NULL and the token is in the connection, listen, transmission
1024 or receive queue when it is being cancelled, its Token->Status will be set
1025 to EFI_ABORTED and then Token->Event will be signaled.
1027 If the token is not in one of the queues, which usually means that the
1028 asynchronous operation has completed, EFI_NOT_FOUND is returned.
1030 If Token is NULL all asynchronous token issued by Connect(), Accept(),
1031 Transmit() and Receive() will be aborted.
1033 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
1034 @param[in] Token Pointer to a token that has been issued by
1035 EFI_TCP6_PROTOCOL.Connect(),
1036 EFI_TCP6_PROTOCOL.Accept(),
1037 EFI_TCP6_PROTOCOL.Transmit() or
1038 EFI_TCP6_PROTOCOL.Receive(). If NULL, all pending
1039 tokens issued by above four functions will be aborted. Type
1040 EFI_TCP6_COMPLETION_TOKEN is defined in
1041 EFI_TCP_PROTOCOL.Connect().
1043 @retval EFI_SUCCESS The asynchronous I/O request is aborted and Token->Event
1045 @retval EFI_INVALID_PARAMETER This is NULL.
1046 @retval EFI_NOT_STARTED This instance hasn't been configured.
1047 @retval EFI_NOT_FOUND The asynchronous I/O request isn't found in the transmission or
1048 receive queue. It has either completed or wasn't issued by
1049 Transmit() and Receive().
1055 IN EFI_TCP6_PROTOCOL
*This
,
1056 IN EFI_TCP6_COMPLETION_TOKEN
*Token OPTIONAL
1062 return EFI_INVALID_PARAMETER
;
1065 Sock
= SOCK_FROM_THIS (This
);
1067 return SockCancel (Sock
, Token
);
1071 Poll to receive incoming data and transmit outgoing segments.
1073 The Poll() function increases the rate that data is moved between the network
1074 and application, and can be called when the TCP instance is created successfully.
1075 Its use is optional.
1077 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.
1079 @retval EFI_SUCCESS Incoming or outgoing data was processed.
1080 @retval EFI_INVALID_PARAMETER This is NULL.
1081 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
1082 @retval EFI_NOT_READY No incoming or outgoing data is processed.
1083 @retval EFI_TIMEOUT Data was dropped out of the transmission or receive queue.
1084 Consider increasing the polling rate.
1090 IN EFI_TCP6_PROTOCOL
*This
1097 return EFI_INVALID_PARAMETER
;
1100 Sock
= SOCK_FROM_THIS (This
);
1102 Status
= Sock
->ProtoHandler (Sock
, SOCK_POLL
, NULL
);