1 /** @file 2 Declaration of protocol interfaces in EFI_TCP4_PROTOCOL and EFI_TCP6_PROTOCOL. 3 It is the common head file for all Tcp*.c in TCP driver. 4 5 Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR> 6 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. 11 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. 14 15 **/ 16 17 #ifndef _TCP_MAIN_H_ 18 #define _TCP_MAIN_H_ 19 20 #include <Protocol/ServiceBinding.h> 21 #include <Protocol/DriverBinding.h> 22 #include <Library/IpIoLib.h> 23 #include <Library/DevicePathLib.h> 24 #include <Library/PrintLib.h> 25 26 #include "Socket.h" 27 #include "TcpProto.h" 28 #include "TcpDriver.h" 29 #include "TcpFunc.h" 30 31 extern UINT16 mTcp4RandomPort; 32 extern UINT16 mTcp6RandomPort; 33 extern CHAR16 *mTcpStateName[]; 34 extern EFI_COMPONENT_NAME_PROTOCOL gTcpComponentName; 35 extern EFI_COMPONENT_NAME2_PROTOCOL gTcpComponentName2; 36 extern EFI_UNICODE_STRING_TABLE *gTcpControllerNameTable; 37 38 extern LIST_ENTRY mTcpRunQue; 39 extern LIST_ENTRY mTcpListenQue; 40 extern TCP_SEQNO mTcpGlobalIss; 41 extern UINT32 mTcpTick; 42 43 /// 44 /// 30 seconds. 45 /// 46 #define TCP6_KEEP_NEIGHBOR_TIME 30 47 /// 48 /// 5 seconds, since 1 tick equals 200ms. 49 /// 50 #define TCP6_REFRESH_NEIGHBOR_TICK 25 51 52 #define TCP_EXPIRE_TIME 65535 53 54 /// 55 /// The implementation selects the initial send sequence number and the unit to 56 /// be added when it is increased. 57 /// 58 #define TCP_BASE_ISS 0x4d7e980b 59 #define TCP_ISS_INCREMENT_1 2048 60 #define TCP_ISS_INCREMENT_2 100 61 62 typedef union { 63 EFI_TCP4_CONFIG_DATA Tcp4CfgData; 64 EFI_TCP6_CONFIG_DATA Tcp6CfgData; 65 } TCP_CONFIG_DATA; 66 67 typedef union { 68 EFI_TCP4_ACCESS_POINT Tcp4Ap; 69 EFI_TCP6_ACCESS_POINT Tcp6Ap; 70 } TCP_ACCESS_POINT; 71 72 typedef struct _TCP4_MODE_DATA { 73 EFI_TCP4_CONNECTION_STATE *Tcp4State; 74 EFI_TCP4_CONFIG_DATA *Tcp4ConfigData; 75 EFI_IP4_MODE_DATA *Ip4ModeData; 76 EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData; 77 EFI_SIMPLE_NETWORK_MODE *SnpModeData; 78 } TCP4_MODE_DATA; 79 80 typedef struct _TCP6_MODE_DATA { 81 EFI_TCP6_CONNECTION_STATE *Tcp6State; 82 EFI_TCP6_CONFIG_DATA *Tcp6ConfigData; 83 EFI_IP6_MODE_DATA *Ip6ModeData; 84 EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData; 85 EFI_SIMPLE_NETWORK_MODE *SnpModeData; 86 } TCP6_MODE_DATA; 87 88 typedef struct _TCP4_ROUTE_INFO { 89 BOOLEAN DeleteRoute; 90 EFI_IPv4_ADDRESS *SubnetAddress; 91 EFI_IPv4_ADDRESS *SubnetMask; 92 EFI_IPv4_ADDRESS *GatewayAddress; 93 } TCP4_ROUTE_INFO; 94 95 typedef struct { 96 EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding; 97 UINTN NumberOfChildren; 98 EFI_HANDLE *ChildHandleBuffer; 99 } TCP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT; 100 101 // 102 // EFI_TCP4_PROTOCOL definitions. 103 // 104 105 /** 106 Get the current operational status. 107 108 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance. 109 @param[out] Tcp4State Pointer to the buffer to receive the current TCP 110 state. Optional parameter that may be NULL. 111 @param[out] Tcp4ConfigData Pointer to the buffer to receive the current TCP 112 configuration. Optional parameter that may be NULL. 113 @param[out] Ip4ModeData Pointer to the buffer to receive the current 114 IPv4 configuration. Optional parameter that may be NULL. 115 @param[out] MnpConfigData Pointer to the buffer to receive the current MNP 116 configuration data indirectly used by the TCPv4 117 Instance. Optional parameter that may be NULL. 118 @param[out] SnpModeData Pointer to the buffer to receive the current SNP 119 configuration data indirectly used by the TCPv4 120 Instance. Optional parameter that may be NULL. 121 122 @retval EFI_SUCCESS The mode data was read. 123 @retval EFI_NOT_STARTED No configuration data is available because this 124 instance hasn't been started. 125 @retval EFI_INVALID_PARAMETER This is NULL. 126 127 **/ 128 EFI_STATUS 129 EFIAPI 130 Tcp4GetModeData ( 131 IN EFI_TCP4_PROTOCOL *This, 132 OUT EFI_TCP4_CONNECTION_STATE *Tcp4State OPTIONAL, 133 OUT EFI_TCP4_CONFIG_DATA *Tcp4ConfigData OPTIONAL, 134 OUT EFI_IP4_MODE_DATA *Ip4ModeData OPTIONAL, 135 OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL, 136 OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL 137 ); 138 139 /** 140 Initialize or brutally reset the operational parameters for 141 this EFI TCPv4 instance. 142 143 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance. 144 @param[in] TcpConfigData Pointer to the configure data to configure the 145 instance. Optional parameter that may be NULL. 146 147 @retval EFI_SUCCESS The operational settings are set, changed, or 148 reset successfully. 149 @retval EFI_NO_MAPPING When using a default address, configuration 150 (through DHCP, BOOTP, RARP, etc.) is not 151 finished. 152 @retval EFI_INVALID_PARAMETER One or more parameters are invalid. 153 @retval EFI_ACCESS_DENIED Configuring the TCP instance when it is already 154 configured. 155 @retval EFI_DEVICE_ERROR An unexpected network or system error occurred. 156 @retval EFI_UNSUPPORTED One or more of the control options are not 157 supported in the implementation. 158 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources. 159 160 **/ 161 EFI_STATUS 162 EFIAPI 163 Tcp4Configure ( 164 IN EFI_TCP4_PROTOCOL * This, 165 IN EFI_TCP4_CONFIG_DATA * TcpConfigData OPTIONAL 166 ); 167 168 /** 169 Add or delete routing entries. 170 171 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance. 172 @param[in] DeleteRoute If TRUE, delete the specified route from routing 173 table; if FALSE, add the specified route to 174 routing table. 175 @param[in] SubnetAddress The destination network. 176 @param[in] SubnetMask The subnet mask for the destination network. 177 @param[in] GatewayAddress The gateway address for this route. 178 179 @retval EFI_SUCCESS The operation completed successfully. 180 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance has not been 181 configured. 182 @retval EFI_NO_MAPPING When using a default address, configuration 183 (through DHCP, BOOTP, RARP, etc.) is not 184 finished. 185 @retval EFI_INVALID_PARAMETER One or more parameters are invalid. 186 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resources to add the 187 entry to the routing table. 188 @retval EFI_NOT_FOUND This route is not in the routing table. 189 @retval EFI_ACCESS_DENIED This route is already in the routing table. 190 @retval EFI_UNSUPPORTED The TCP driver does not support this operation. 191 192 **/ 193 EFI_STATUS 194 EFIAPI 195 Tcp4Routes ( 196 IN EFI_TCP4_PROTOCOL *This, 197 IN BOOLEAN DeleteRoute, 198 IN EFI_IPv4_ADDRESS *SubnetAddress, 199 IN EFI_IPv4_ADDRESS *SubnetMask, 200 IN EFI_IPv4_ADDRESS *GatewayAddress 201 ); 202 203 /** 204 Initiate a nonblocking TCP connection request for an active TCP instance. 205 206 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance. 207 @param[in] ConnectionToken Pointer to the connection token to return when 208 the TCP three way handshake finishes. 209 210 @retval EFI_SUCCESS The connection request is successfully 211 initiated. 212 @retval EFI_NOT_STARTED This EFI_TCP4_PROTOCOL instance hasn't been 213 configured. 214 @retval EFI_ACCESS_DENIED The instance is not configured as an active one 215 or it is not in Tcp4StateClosed state. 216 @retval EFI_INVALID_PARAMETER One or more parameters are invalid. 217 @retval EFI_OUT_OF_RESOURCES The driver can't allocate enough resources to 218 initiate the active open. 219 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. 220 221 **/ 222 EFI_STATUS 223 EFIAPI 224 Tcp4Connect ( 225 IN EFI_TCP4_PROTOCOL *This, 226 IN EFI_TCP4_CONNECTION_TOKEN *ConnectionToken 227 ); 228 229 /** 230 Listen on the passive instance to accept an incoming connection request. 231 232 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance. 233 @param[in] ListenToken Pointer to the listen token to return when 234 operation finishes. 235 236 @retval EFI_SUCCESS The listen token has been queued successfully. 237 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been 238 configured. 239 @retval EFI_ACCESS_DENIED The instatnce is not a passive one or it is not 240 in Tcp4StateListen state, or a same listen token 241 has already existed in the listen token queue of 242 this TCP instance. 243 @retval EFI_INVALID_PARAMETER One or more parameters are invalid. 244 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resources to finish 245 the operation. 246 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. 247 248 **/ 249 EFI_STATUS 250 EFIAPI 251 Tcp4Accept ( 252 IN EFI_TCP4_PROTOCOL *This, 253 IN EFI_TCP4_LISTEN_TOKEN *ListenToken 254 ); 255 256 /** 257 Queues outgoing data into the transmit queue 258 259 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance 260 @param[in] Token Pointer to the completion token to queue to the 261 transmit queue 262 263 @retval EFI_SUCCESS The data has been queued for transmission 264 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been 265 configured. 266 @retval EFI_NO_MAPPING When using a default address, configuration 267 (DHCP, BOOTP, RARP, etc.) is not finished yet. 268 @retval EFI_INVALID_PARAMETER One or more parameters are invalid 269 @retval EFI_ACCESS_DENIED One or more of the following conditions is TRUE: 270 * A transmit completion token with the same 271 Token-> CompletionToken.Event was already in the 272 transmission queue. * The current instance is in 273 Tcp4StateClosed state * The current instance is 274 a passive one and it is in Tcp4StateListen 275 state. * User has called Close() to disconnect 276 this connection. 277 @retval EFI_NOT_READY The completion token could not be queued because 278 the transmit queue is full. 279 @retval EFI_OUT_OF_RESOURCES Could not queue the transmit data because of a 280 resource shortage. 281 @retval EFI_NETWORK_UNREACHABLE There is no route to the destination network or 282 address. 283 284 **/ 285 EFI_STATUS 286 EFIAPI 287 Tcp4Transmit ( 288 IN EFI_TCP4_PROTOCOL *This, 289 IN EFI_TCP4_IO_TOKEN *Token 290 ); 291 292 /** 293 Place an asynchronous receive request into the receiving queue. 294 295 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance. 296 @param[in] Token Pointer to a token that is associated with the 297 receive data descriptor. 298 299 @retval EFI_SUCCESS The receive completion token was cached. 300 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been 301 configured. 302 @retval EFI_NO_MAPPING When using a default address, configuration 303 (DHCP, BOOTP, RARP, etc.) is not finished yet. 304 @retval EFI_INVALID_PARAMETER One or more parameters are invalid. 305 @retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued 306 due to a lack of system resources. 307 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. 308 @retval EFI_ACCESS_DENIED One or more of the following conditions is TRUE: 309 * A receive completion token with the same 310 Token->CompletionToken.Event was already in the 311 receive queue. * The current instance is in 312 Tcp4StateClosed state. * The current instance is 313 a passive one and it is in Tcp4StateListen 314 state. * User has called Close() to disconnect 315 this connection. 316 @retval EFI_CONNECTION_FIN The communication peer has closed the connection 317 and there is no buffered data in the receive 318 buffer of this instance. 319 @retval EFI_NOT_READY The receive request could not be queued because 320 the receive queue is full. 321 322 **/ 323 EFI_STATUS 324 EFIAPI 325 Tcp4Receive ( 326 IN EFI_TCP4_PROTOCOL *This, 327 IN EFI_TCP4_IO_TOKEN *Token 328 ); 329 330 /** 331 Disconnecting a TCP connection gracefully or reset a TCP connection. 332 333 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance. 334 @param[in] CloseToken Pointer to the close token to return when 335 operation finishes. 336 337 @retval EFI_SUCCESS The operation completed successfully. 338 @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been 339 configured. 340 @retval EFI_ACCESS_DENIED One or more of the following are TRUE: * 341 Configure() has been called with TcpConfigData 342 set to NULL and this function has not returned. 343 * Previous Close() call on this instance has not 344 finished. 345 @retval EFI_INVALID_PARAMETER One ore more parameters are invalid. 346 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resources to finish the 347 operation. 348 @retval EFI_DEVICE_ERROR Any unexpected error not belonging to the error 349 categories given above. 350 351 **/ 352 EFI_STATUS 353 EFIAPI 354 Tcp4Close ( 355 IN EFI_TCP4_PROTOCOL *This, 356 IN EFI_TCP4_CLOSE_TOKEN *CloseToken 357 ); 358 359 /** 360 Abort an asynchronous connection, listen, transmission or receive request. 361 362 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance. 363 @param[in] Token Pointer to a token that has been issued by 364 Connect(), Accept(), Transmit() or Receive(). If 365 NULL, all pending tokens issued by the above four 366 functions will be aborted. 367 368 @retval EFI_UNSUPPORTED The operation is not supported in the current 369 implementation. 370 371 **/ 372 EFI_STATUS 373 EFIAPI 374 Tcp4Cancel ( 375 IN EFI_TCP4_PROTOCOL *This, 376 IN EFI_TCP4_COMPLETION_TOKEN *Token OPTIONAL 377 ); 378 379 /** 380 Poll to receive incoming data and transmit outgoing segments. 381 382 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance. 383 384 @retval EFI_SUCCESS Incoming or outgoing data was processed. 385 @retval EFI_INVALID_PARAMETER This is NULL. 386 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. 387 @retval EFI_NOT_READY No incoming or outgoing data was processed. 388 @retval EFI_TIMEOUT Data was dropped out of the transmission or 389 receive queue. Consider increasing the polling 390 rate. 391 392 **/ 393 EFI_STATUS 394 EFIAPI 395 Tcp4Poll ( 396 IN EFI_TCP4_PROTOCOL *This 397 ); 398 399 // 400 // EFI_TCP6_PROTOCOL definitions. 401 // 402 403 /** 404 Get the current operational status. 405 406 The GetModeData() function copies the current operational settings of this EFI TCPv6 407 Protocol instance into user-supplied buffers. This function can also be used to retrieve 408 the operational setting of underlying drivers such as IPv6, MNP, or SNP. 409 410 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance. 411 @param[out] Tcp6State The buffer in which the current TCP state is 412 returned. Optional parameter that may be NULL. 413 @param[out] Tcp6ConfigData The buffer in which the current TCP configuration 414 is returned. Optional parameter that may be NULL. 415 @param[out] Ip6ModeData The buffer in which the current IPv6 configuration 416 data used by the TCP instance is returned. 417 Optional parameter that may be NULL. 418 @param[out] MnpConfigData The buffer in which the current MNP configuration 419 data used indirectly by the TCP instance is returned. 420 Optional parameter that may be NULL. 421 @param[out] SnpModeData The buffer in which the current SNP mode data 422 used indirectly by the TCP instance is returned. 423 Optional parameter that may be NULL. 424 425 @retval EFI_SUCCESS The mode data was read. 426 @retval EFI_NOT_STARTED No configuration data is available because this instance hasn't 427 been started. 428 @retval EFI_INVALID_PARAMETER This is NULL. 429 430 **/ 431 EFI_STATUS 432 EFIAPI 433 Tcp6GetModeData ( 434 IN EFI_TCP6_PROTOCOL *This, 435 OUT EFI_TCP6_CONNECTION_STATE *Tcp6State OPTIONAL, 436 OUT EFI_TCP6_CONFIG_DATA *Tcp6ConfigData OPTIONAL, 437 OUT EFI_IP6_MODE_DATA *Ip6ModeData OPTIONAL, 438 OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL, 439 OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL 440 ); 441 442 /** 443 Initialize or brutally reset the operational parameters for this EFI TCPv6 instance. 444 445 The Configure() function does the following: 446 - Initialize this TCP instance, i.e., initialize the communication end settings and 447 specify active open or passive open for an instance. 448 - Reset this TCP instance brutally, i.e., cancel all pending asynchronous tokens, flush 449 transmission and receiving buffer directly without informing the communication peer. 450 451 No other TCPv6 Protocol operation except Poll() can be executed by this instance until 452 it is configured properly. For an active TCP instance, after a proper configuration it 453 may call Connect() to initiates the three-way handshake. For a passive TCP instance, 454 its state will transit to Tcp6StateListen after configuration, and Accept() may be 455 called to listen the incoming TCP connection requests. If Tcp6ConfigData is set to NULL, 456 the instance is reset. Resetting process will be done brutally, the state machine will 457 be set to Tcp6StateClosed directly, the receive queue and transmit queue will be flushed, 458 and no traffic is allowed through this instance. 459 460 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance. 461 @param[in] Tcp6ConfigData Pointer to the configure data to configure the instance. 462 If Tcp6ConfigData is set to NULL, the instance is reset. 463 464 @retval EFI_SUCCESS The operational settings were set, changed, or reset 465 successfully. 466 @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a source 467 address for this instance, but no source address was available for 468 use. 469 @retval EFI_INVALID_PARAMETER One or more of the following conditions are TRUE: 470 - This is NULL. 471 - Tcp6ConfigData->AccessPoint.StationAddress is neither zero nor 472 one of the configured IP addresses in the underlying IPv6 driver. 473 - Tcp6ConfigData->AccessPoint.RemoteAddress isn't a valid unicast 474 IPv6 address. 475 - Tcp6ConfigData->AccessPoint.RemoteAddress is zero or 476 Tcp6ConfigData->AccessPoint.RemotePort is zero when 477 Tcp6ConfigData->AccessPoint.ActiveFlag is TRUE. 478 - A same access point has been configured in other TCP 479 instance properly. 480 @retval EFI_ACCESS_DENIED Configuring TCP instance when it is configured without 481 calling Configure() with NULL to reset it. 482 @retval EFI_UNSUPPORTED One or more of the control options are not supported in 483 the implementation. 484 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources when 485 executing Configure(). 486 @retval EFI_DEVICE_ERROR An unexpected network or system error occurred. 487 488 **/ 489 EFI_STATUS 490 EFIAPI 491 Tcp6Configure ( 492 IN EFI_TCP6_PROTOCOL *This, 493 IN EFI_TCP6_CONFIG_DATA *Tcp6ConfigData OPTIONAL 494 ); 495 496 /** 497 Initiate a nonblocking TCP connection request for an active TCP instance. 498 499 The Connect() function will initiate an active open to the remote peer configured 500 in current TCP instance if it is configured active. If the connection succeeds or 501 fails due to an error, the ConnectionToken->CompletionToken.Event will be signaled, 502 and ConnectionToken->CompletionToken.Status will be updated accordingly. This 503 function can only be called for the TCP instance in Tcp6StateClosed state. The 504 instance will transfer into Tcp6StateSynSent if the function returns EFI_SUCCESS. 505 If TCP three-way handshake succeeds, its state will become Tcp6StateEstablished; 506 otherwise, the state will return to Tcp6StateClosed. 507 508 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance. 509 @param[in] ConnectionToken Pointer to the connection token to return when the TCP 510 three-way handshake finishes. 511 512 @retval EFI_SUCCESS The connection request successfully initiated and the state of 513 this TCP instance has been changed to Tcp6StateSynSent. 514 @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured. 515 @retval EFI_ACCESS_DENIED One or more of the following conditions are TRUE: 516 - This instance is not configured as an active instance. 517 - This instance is not in Tcp6StateClosed state. 518 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE: 519 - This is NULL. 520 - ConnectionToken is NULL. 521 - ConnectionToken->CompletionToken.Event is NULL. 522 @retval EFI_OUT_OF_RESOURCES The driver can't allocate enough resources to initiate the active open. 523 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. 524 525 **/ 526 EFI_STATUS 527 EFIAPI 528 Tcp6Connect ( 529 IN EFI_TCP6_PROTOCOL *This, 530 IN EFI_TCP6_CONNECTION_TOKEN *ConnectionToken 531 ); 532 533 /** 534 Listen on the passive instance to accept an incoming connection request. This is a 535 nonblocking operation. 536 537 The Accept() function initiates an asynchronous accept request to wait for an incoming 538 connection on the passive TCP instance. If a remote peer successfully establishes a 539 connection with this instance, a new TCP instance will be created and its handle will 540 be returned in ListenToken->NewChildHandle. The newly created instance is configured 541 by inheriting the passive instance's configuration, and is ready for use upon return. 542 The new instance is in the Tcp6StateEstablished state. 543 544 The ListenToken->CompletionToken.Event will be signaled when a new connection is 545 accepted, user aborts the listen or connection is reset. 546 547 This function only can be called when the current TCP instance is in Tcp6StateListen state. 548 549 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance. 550 @param[in] ListenToken Pointer to the listen token to return when the operation finishes. 551 552 553 @retval EFI_SUCCESS The listen token was been queued successfully. 554 @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured. 555 @retval EFI_ACCESS_DENIED One or more of the following are TRUE: 556 - This instance is not a passive instance. 557 - This instance is not in Tcp6StateListen state. 558 - The same listen token has already existed in the listen 559 token queue of this TCP instance. 560 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE: 561 - This is NULL. 562 - ListenToken is NULL. 563 - ListentToken->CompletionToken.Event is NULL. 564 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resources to finish the operation. 565 @retval EFI_DEVICE_ERROR Any unexpected error not belonging to the error 566 categories given above. 567 568 **/ 569 EFI_STATUS 570 EFIAPI 571 Tcp6Accept ( 572 IN EFI_TCP6_PROTOCOL *This, 573 IN EFI_TCP6_LISTEN_TOKEN *ListenToken 574 ); 575 576 /** 577 Queues outgoing data into the transmit queue. 578 579 The Transmit() function queues a sending request to this TCP instance along with the 580 user data. The status of the token is updated and the event in the token will be 581 signaled once the data is sent out or some error occurs. 582 583 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance. 584 @param[in] Token Pointer to the completion token to queue to the transmit queue. 585 586 @retval EFI_SUCCESS The data has been queued for transmission. 587 @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured. 588 @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a 589 source address for this instance, but no source address was 590 available for use. 591 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE: 592 - This is NULL. 593 - Token is NULL. 594 - Token->CompletionToken.Event is NULL. 595 - Token->Packet.TxData is NULL. 596 - Token->Packet.FragmentCount is zero. 597 - Token->Packet.DataLength is not equal to the sum of fragment lengths. 598 @retval EFI_ACCESS_DENIED One or more of the following conditions are TRUE: 599 - A transmit completion token with the same Token-> 600 CompletionToken.Event was already in the 601 transmission queue. 602 - The current instance is in Tcp6StateClosed state. 603 - The current instance is a passive one and it is in 604 Tcp6StateListen state. 605 - User has called Close() to disconnect this connection. 606 @retval EFI_NOT_READY The completion token could not be queued because the 607 transmit queue is full. 608 @retval EFI_OUT_OF_RESOURCES Could not queue the transmit data because of a resource 609 shortage. 610 @retval EFI_NETWORK_UNREACHABLE There is no route to the destination network or address. 611 612 **/ 613 EFI_STATUS 614 EFIAPI 615 Tcp6Transmit ( 616 IN EFI_TCP6_PROTOCOL *This, 617 IN EFI_TCP6_IO_TOKEN *Token 618 ); 619 620 /** 621 Places an asynchronous receive request into the receiving queue. 622 623 The Receive() function places a completion token into the receive packet queue. This 624 function is always asynchronous. The caller must allocate the Token->CompletionToken.Event 625 and the FragmentBuffer used to receive data. The caller also must fill the DataLength, which 626 represents the whole length of all FragmentBuffer. When the receive operation completes, the 627 EFI TCPv6 Protocol driver updates the Token->CompletionToken.Status and Token->Packet.RxData 628 fields, and the Token->CompletionToken.Event is signaled. If data is obtained, the data and its length 629 will be copied into the FragmentTable. At the same time the full length of received data will 630 be recorded in the DataLength fields. Providing a proper notification function and context 631 for the event enables the user to receive the notification and receiving status. That 632 notification function is guaranteed to not be re-entered. 633 634 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance. 635 @param[in] Token Pointer to a token that is associated with the receive data 636 descriptor. 637 638 @retval EFI_SUCCESS The receive completion token was cached. 639 @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured. 640 @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a source 641 address for this instance, but no source address was available for use. 642 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE: 643 - This is NULL. 644 - Token is NULL. 645 - Token->CompletionToken.Event is NULL. 646 - Token->Packet.RxData is NULL. 647 - Token->Packet.RxData->DataLength is 0. 648 - The Token->Packet.RxData->DataLength is not the 649 sum of all FragmentBuffer length in FragmentTable. 650 @retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued due to a lack of 651 system resources (usually memory). 652 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. 653 The EFI TCPv6 Protocol instance has been reset to startup defaults. 654 @retval EFI_ACCESS_DENIED One or more of the following conditions is TRUE: 655 - A receive completion token with the same Token->CompletionToken.Event 656 was already in the receive queue. 657 - The current instance is in Tcp6StateClosed state. 658 - The current instance is a passive one and it is in 659 Tcp6StateListen state. 660 - The user has called Close() to disconnect this connection. 661 @retval EFI_CONNECTION_FIN The communication peer has closed the connection, and there is no 662 buffered data in the receive buffer of this instance. 663 @retval EFI_NOT_READY The receive request could not be queued because the receive queue is full. 664 665 **/ 666 EFI_STATUS 667 EFIAPI 668 Tcp6Receive ( 669 IN EFI_TCP6_PROTOCOL *This, 670 IN EFI_TCP6_IO_TOKEN *Token 671 ); 672 673 /** 674 Disconnecting a TCP connection gracefully or reset a TCP connection. This function is a 675 nonblocking operation. 676 677 Initiate an asynchronous close token to the TCP driver. After Close() is called, any buffered 678 transmission data will be sent by the TCP driver, and the current instance will have a graceful close 679 working flow described as RFC 793 if AbortOnClose is set to FALSE, otherwise, a rest packet 680 will be sent by TCP driver to fast disconnect this connection. When the close operation completes 681 successfully the TCP instance is in Tcp6StateClosed state, all pending asynchronous 682 operations are signaled, and any buffers used for TCP network traffic are flushed. 683 684 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance. 685 @param[in] CloseToken Pointer to the close token to return when operation finishes. 686 687 @retval EFI_SUCCESS The Close() was called successfully. 688 @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured. 689 @retval EFI_ACCESS_DENIED One or more of the following are TRUE: 690 - CloseToken or CloseToken->CompletionToken.Event is already in use. 691 - Previous Close() call on this instance has not finished. 692 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE: 693 - This is NULL. 694 - CloseToken is NULL. 695 - CloseToken->CompletionToken.Event is NULL. 696 @retval EFI_OUT_OF_RESOURCES Could not allocate enough resources to finish the operation. 697 @retval EFI_DEVICE_ERROR Any unexpected error not belonging to the error categories given above. 698 699 **/ 700 EFI_STATUS 701 EFIAPI 702 Tcp6Close ( 703 IN EFI_TCP6_PROTOCOL *This, 704 IN EFI_TCP6_CLOSE_TOKEN *CloseToken 705 ); 706 707 /** 708 Abort an asynchronous connection, listen, transmission or receive request. 709 710 The Cancel() function aborts a pending connection, listen, transmit or 711 receive request. 712 713 If Token is not NULL and the token is in the connection, listen, transmission 714 or receive queue when it is being cancelled, its Token->Status will be set 715 to EFI_ABORTED and then Token->Event will be signaled. 716 717 If the token is not in one of the queues, which usually means that the 718 asynchronous operation has completed, EFI_NOT_FOUND is returned. 719 720 If Token is NULL all asynchronous token issued by Connect(), Accept(), 721 Transmit() and Receive() will be aborted. 722 723 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance. 724 @param[in] Token Pointer to a token that has been issued by 725 EFI_TCP6_PROTOCOL.Connect(), 726 EFI_TCP6_PROTOCOL.Accept(), 727 EFI_TCP6_PROTOCOL.Transmit() or 728 EFI_TCP6_PROTOCOL.Receive(). If NULL, all pending 729 tokens issued by above four functions will be aborted. Type 730 EFI_TCP6_COMPLETION_TOKEN is defined in 731 EFI_TCP_PROTOCOL.Connect(). 732 733 @retval EFI_UNSUPPORTED The implementation does not support this function. 734 735 **/ 736 EFI_STATUS 737 EFIAPI 738 Tcp6Cancel ( 739 IN EFI_TCP6_PROTOCOL *This, 740 IN EFI_TCP6_COMPLETION_TOKEN *Token OPTIONAL 741 ); 742 743 /** 744 Poll to receive incoming data and transmit outgoing segments. 745 746 The Poll() function increases the rate that data is moved between the network 747 and application and can be called when the TCP instance is created successfully. 748 Its use is optional. 749 750 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance. 751 752 @retval EFI_SUCCESS Incoming or outgoing data was processed. 753 @retval EFI_INVALID_PARAMETER This is NULL. 754 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. 755 @retval EFI_NOT_READY No incoming or outgoing data is processed. 756 @retval EFI_TIMEOUT Data was dropped out of the transmission or receive queue. 757 Consider increasing the polling rate. 758 759 **/ 760 EFI_STATUS 761 EFIAPI 762 Tcp6Poll ( 763 IN EFI_TCP6_PROTOCOL *This 764 ); 765 766 #endif 767