]> git.proxmox.com Git - mirror_edk2.git/blobdiff - NetworkPkg/TcpDxe/TcpMain.c
NetworkPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / NetworkPkg / TcpDxe / TcpMain.c
index 66a09c41eaa77a68a930e5c6e10fbec0ff809179..fa357cd01a83e38ddf78164cf7f9b4b40d3aee57 100644 (file)
@@ -2,15 +2,9 @@
   Implementation of EFI_TCP4_PROTOCOL and EFI_TCP6_PROTOCOL.\r
 \r
   (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>\r
-  Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2018, 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
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php.\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -40,6 +34,9 @@ TcpChkDataBuf (
   UINT32 Len;\r
 \r
   for (Index = 0, Len = 0; Index < FragmentCount; Index++) {\r
+    if (FragmentTable[Index].FragmentBuffer == NULL) {\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
     Len = Len + FragmentTable[Index].FragmentLength;\r
   }\r
 \r
@@ -147,7 +144,7 @@ Tcp4Configure (
   if (NULL != TcpConfigData) {\r
 \r
     CopyMem (&Ip, &TcpConfigData->AccessPoint.RemoteAddress, sizeof (IP4_ADDR));\r
-    if ((Ip != 0) && !NetIp4IsUnicast (NTOHL (Ip), 0)) {\r
+    if (IP4_IS_LOCAL_BROADCAST (NTOHL (Ip))) {\r
       return EFI_INVALID_PARAMETER;\r
     }\r
 \r
@@ -159,7 +156,8 @@ Tcp4Configure (
 \r
       CopyMem (&Ip, &TcpConfigData->AccessPoint.StationAddress, sizeof (IP4_ADDR));\r
       CopyMem (&SubnetMask, &TcpConfigData->AccessPoint.SubnetMask, sizeof (IP4_ADDR));\r
-      if (!NetIp4IsUnicast (NTOHL (Ip), 0) || !IP4_IS_VALID_NETMASK (NTOHL (SubnetMask))) {\r
+      if (!IP4_IS_VALID_NETMASK (NTOHL (SubnetMask)) ||\r
+          (SubnetMask != 0 && !NetIp4IsUnicast (NTOHL (Ip), NTOHL (SubnetMask)))) {\r
         return EFI_INVALID_PARAMETER;\r
       }\r
     }\r
@@ -230,9 +228,9 @@ Tcp4Routes (
   Sock                      = SOCK_FROM_THIS (This);\r
 \r
   RouteInfo.DeleteRoute     = DeleteRoute;\r
-  IP4_COPY_ADDRESS (&RouteInfo.SubnetAddress, &SubnetAddress);\r
-  IP4_COPY_ADDRESS (&RouteInfo.SubnetMask, &SubnetMask);\r
-  IP4_COPY_ADDRESS (&RouteInfo.GatewayAddress, &GatewayAddress);\r
+  RouteInfo.SubnetAddress   = SubnetAddress;\r
+  RouteInfo.SubnetMask      = SubnetMask;\r
+  RouteInfo.GatewayAddress  = GatewayAddress;\r
 \r
   return SockRoute (Sock, &RouteInfo);\r
 }\r
@@ -484,14 +482,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
@@ -501,7 +510,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
@@ -998,20 +1015,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
@@ -1023,7 +1040,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
@@ -1033,7 +1056,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