]> git.proxmox.com Git - mirror_edk2.git/blobdiff - NetworkPkg/TcpDxe/TcpMain.c
NetworkPkg: Support TCP Cancel function
[mirror_edk2.git] / NetworkPkg / TcpDxe / TcpMain.c
index 55a6d5b7d21330dbea17054cd3989d90708a930e..96a295a7fe309529dfa66eda90912b07f2d3b6bf 100644 (file)
@@ -1,7 +1,8 @@
 /** @file\r
   Implementation of EFI_TCP4_PROTOCOL and EFI_TCP6_PROTOCOL.\r
 \r
-  Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
+  (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>\r
+  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>\r
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
@@ -75,12 +76,12 @@ TcpChkDataBuf (
 EFI_STATUS\r
 EFIAPI\r
 Tcp4GetModeData (\r
-  IN CONST  EFI_TCP4_PROTOCOL                  *This,\r
-  OUT       EFI_TCP4_CONNECTION_STATE          *Tcp4State      OPTIONAL,\r
-  OUT       EFI_TCP4_CONFIG_DATA               *Tcp4ConfigData OPTIONAL,\r
-  OUT       EFI_IP4_MODE_DATA                  *Ip4ModeData    OPTIONAL,\r
-  OUT       EFI_MANAGED_NETWORK_CONFIG_DATA    *MnpConfigData  OPTIONAL,\r
-  OUT       EFI_SIMPLE_NETWORK_MODE            *SnpModeData    OPTIONAL\r
+  IN   EFI_TCP4_PROTOCOL                  *This,\r
+  OUT  EFI_TCP4_CONNECTION_STATE          *Tcp4State      OPTIONAL,\r
+  OUT  EFI_TCP4_CONFIG_DATA               *Tcp4ConfigData OPTIONAL,\r
+  OUT  EFI_IP4_MODE_DATA                  *Ip4ModeData    OPTIONAL,\r
+  OUT  EFI_MANAGED_NETWORK_CONFIG_DATA    *MnpConfigData  OPTIONAL,\r
+  OUT  EFI_SIMPLE_NETWORK_MODE            *SnpModeData    OPTIONAL\r
   )\r
 {\r
   TCP4_MODE_DATA  TcpMode;\r
@@ -483,14 +484,25 @@ Tcp4Close (
 /**\r
   Abort an asynchronous connection, listen, transmission or receive request.\r
 \r
-  @param[in]  This                 Pointer to the EFI_TCP4_PROTOCOL instance.\r
-  @param[in]  Token                Pointer to a token that has been issued by\r
-                                   Connect(), Accept(), Transmit() or Receive(). If\r
-                                   NULL, all pending tokens issued by the four\r
-                                   functions listed above will be aborted.\r
-\r
-  @retval EFI_UNSUPPORTED          The operation is not supported in the current\r
-                                   implementation.\r
+  @param  This  The pointer to the EFI_TCP4_PROTOCOL instance.\r
+  @param  Token The pointer to a token that has been issued by\r
+                EFI_TCP4_PROTOCOL.Connect(),\r
+                EFI_TCP4_PROTOCOL.Accept(),\r
+                EFI_TCP4_PROTOCOL.Transmit() or\r
+                EFI_TCP4_PROTOCOL.Receive(). If NULL, all pending\r
+                tokens issued by above four functions will be aborted. Type\r
+                EFI_TCP4_COMPLETION_TOKEN is defined in\r
+                EFI_TCP4_PROTOCOL.Connect().\r
+\r
+  @retval  EFI_SUCCESS             The asynchronous I/O request is aborted and Token->Event\r
+                                   is signaled.\r
+  @retval  EFI_INVALID_PARAMETER   This is NULL.\r
+  @retval  EFI_NOT_STARTED         This instance hasn't been configured.\r
+  @retval  EFI_NO_MAPPING          When using the default address, configuration\r
+                                   (DHCP, BOOTP,RARP, etc.) hasn't finished yet.\r
+  @retval  EFI_NOT_FOUND           The asynchronous I/O request isn't found in the\r
+                                   transmission or receive queue. It has either\r
+                                   completed or wasn't issued by Transmit() and Receive().\r
 \r
 **/\r
 EFI_STATUS\r
@@ -500,7 +512,15 @@ Tcp4Cancel (
   IN EFI_TCP4_COMPLETION_TOKEN     *Token OPTIONAL\r
   )\r
 {\r
-  return EFI_UNSUPPORTED;\r
+  SOCKET  *Sock;\r
+\r
+  if (NULL == This) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  Sock = SOCK_FROM_THIS (This);\r
+\r
+  return SockCancel (Sock, Token);\r
 }\r
 \r
 /**\r
@@ -997,20 +1017,20 @@ Tcp6Close (
 }\r
 \r
 /**\r
-  Abort an asynchronous connection, listen, transmission, or receive request.\r
+  Abort an asynchronous connection, listen, transmission or receive request.\r
 \r
-  The Cancel() function aborts a pending connection, listen, transmit, or\r
+  The Cancel() function aborts a pending connection, listen, transmit or\r
   receive request.\r
 \r
-  If Token is not NULL and the token is in the connection, listen, transmission,\r
+  If Token is not NULL and the token is in the connection, listen, transmission\r
   or receive queue when it is being cancelled, its Token->Status will be set\r
-  to EFI_ABORTED, and then Token->Event will be signaled.\r
+  to EFI_ABORTED and then Token->Event will be signaled.\r
 \r
   If the token is not in one of the queues, which usually means that the\r
   asynchronous operation has completed, EFI_NOT_FOUND is returned.\r
 \r
   If Token is NULL all asynchronous token issued by Connect(), Accept(),\r
-  Transmit(), and Receive() will be aborted.\r
+  Transmit() and Receive() will be aborted.\r
 \r
   @param[in] This                Pointer to the EFI_TCP6_PROTOCOL instance.\r
   @param[in] Token               Pointer to a token that has been issued by\r
@@ -1022,7 +1042,13 @@ Tcp6Close (
                                  EFI_TCP6_COMPLETION_TOKEN is defined in\r
                                  EFI_TCP_PROTOCOL.Connect().\r
 \r
-  @retval EFI_UNSUPPORTED        The implementation does not support this function.\r
+  @retval EFI_SUCCESS            The asynchronous I/O request is aborted and Token->Event\r
+                                 is signaled.\r
+  @retval EFI_INVALID_PARAMETER  This is NULL.\r
+  @retval EFI_NOT_STARTED        This instance hasn't been configured.\r
+  @retval EFI_NOT_FOUND          The asynchronous I/O request isn't found in the transmission or\r
+                                 receive queue. It has either completed or wasn't issued by\r
+                                 Transmit() and Receive().\r
 \r
 **/\r
 EFI_STATUS\r
@@ -1032,7 +1058,15 @@ Tcp6Cancel (
   IN EFI_TCP6_COMPLETION_TOKEN   *Token OPTIONAL\r
   )\r
 {\r
-  return EFI_UNSUPPORTED;\r
+  SOCKET  *Sock;\r
+\r
+  if (NULL == This) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  Sock = SOCK_FROM_THIS (This);\r
+\r
+  return SockCancel (Sock, Token);\r
 }\r
 \r
 /**\r