]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg: Did some code enhancement for DxeIpIoLib.
authorWang Fan <fan.wang@intel.com>
Wed, 10 Jan 2018 03:09:28 +0000 (11:09 +0800)
committerJiaxin Wu <jiaxin.wu@intel.com>
Tue, 16 Jan 2018 03:10:05 +0000 (11:10 +0800)
* In DxeIpIo, there are several places use ASSERT() to check input
  parameters without and descriptions or error handling. This patch
  fixed this issue.
* Fixed some incorrect descriptions in code commence.
* Remove unneeded Exit tag in function IpIoOpen and IpIoConfigIp.
* Add EFIAPI tag for function IpIoRefreshNeighbor.

Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wang Fan <fan.wang@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
MdeModulePkg/Include/Library/IpIoLib.h
MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.c

index 463bf95b499a51f310b25fe83103a3f6bb393285..61653b0418e3f894e36a549e842d1336dc599b3b 100644 (file)
@@ -310,6 +310,8 @@ typedef struct _IP_IO_IP_INFO {
 \r
 /**\r
   Create a new IP_IO instance.\r
+\r
+  If IpVersion is not IP_VERSION_4 or IP_VERSION_6, then ASSERT().\r
   \r
   This function uses IP4/IP6 service binding protocol in Controller to create\r
   an IP4/IP6 child (aka IP4/IP6 instance).\r
@@ -353,6 +355,8 @@ IpIoDestroy (
 \r
 /**\r
   Stop an IP_IO instance.\r
+\r
+  If Ip version is not IP_VERSION_4 or IP_VERSION_6, then ASSERT().\r
   \r
   This function is paired with IpIoOpen(). The IP_IO will be unconfigured, and all\r
   pending send/receive tokens will be canceled.\r
@@ -372,7 +376,9 @@ IpIoStop (
 \r
 /**\r
   Open an IP_IO instance for use.\r
-  \r
+\r
+  If Ip version is not IP_VERSION_4 or IP_VERSION_6, then ASSERT().\r
+\r
   This function is called after IpIoCreate(). It is used for configuring the IP\r
   instance and register the callbacks and their context data for sending and\r
   receiving IP packets.\r
@@ -401,7 +407,7 @@ IpIoOpen (
 /**\r
   Send out an IP packet.\r
   \r
-  This function is called after IpIoOpen(). The data to be sent are wrapped in\r
+  This function is called after IpIoOpen(). The data to be sent is wrapped in\r
   Pkt. The IP instance wrapped in IpIo is used for sending by default but can be\r
   overriden by Sender. Other sending configs, like source address and gateway\r
   address etc., are specified in OverrideData.\r
@@ -439,6 +445,9 @@ IpIoSend (
 /**\r
   Cancel the IP transmit token that wraps this Packet.\r
 \r
+  If IpIo is NULL, then ASSERT().\r
+  If Packet is NULL, then ASSERT().\r
+\r
   @param[in]  IpIo                  The pointer to the IP_IO instance.\r
   @param[in]  Packet                The pointer to the packet of NET_BUF to cancel.\r
 \r
@@ -452,6 +461,9 @@ IpIoCancelTxToken (
 \r
 /**\r
   Add a new IP instance for sending data.\r
+\r
+  If IpIo is NULL, then ASSERT().\r
+  If Ip version is not IP_VERSION_4 or IP_VERSION_6, then ASSERT().\r
   \r
   The function is used to add the IP_IO to the IP_IO sending list. The caller\r
   can later use IpIoFindSender() to get the IP_IO and call IpIoSend() to send\r
@@ -473,6 +485,8 @@ IpIoAddIp (
   Configure the IP instance of this IpInfo and start the receiving if IpConfigData\r
   is not NULL.\r
 \r
+  If Ip version is not IP_VERSION_4 or IP_VERSION_6, then ASSERT().\r
+\r
   @param[in, out]  IpInfo          The pointer to the IP_IO_IP_INFO instance.\r
   @param[in, out]  IpConfigData    The IP4 or IP6 configure data used to configure \r
                                    the IP instance. If NULL, the IP instance is reset.\r
@@ -495,6 +509,8 @@ IpIoConfigIp (
 /**\r
   Destroy an IP instance maintained in IpIo->IpList for\r
   sending purpose.\r
+\r
+  If Ip version is not IP_VERSION_4 or IP_VERSION_6, then ASSERT().  \r
   \r
   This function pairs with IpIoAddIp(). The IpInfo is previously created by\r
   IpIoAddIp(). The IP_IO_IP_INFO::RefCnt is decremented and the IP instance\r
@@ -586,6 +602,7 @@ IpIoGetIcmpErrStatus (
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 IpIoRefreshNeighbor (\r
   IN IP_IO           *IpIo,\r
   IN EFI_IP_ADDRESS  *Neighbor,\r
index c7bc1aa8d021a664fb1fd85cf645685a50891527..0c6681d9d58edce947ddafd401ac4ad0e0d76318 100644 (file)
@@ -2,7 +2,7 @@
   IpIo Library.\r
 \r
 (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>\r
-Copyright (c) 2005 - 2017, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.<BR>\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
@@ -634,8 +634,8 @@ IpIoExtFree (
   @param[in]       Dest                 Pointer to the destination IP address.\r
   @param[in]       Override             Pointer to the overriden IP_IO data.\r
 \r
-  @return Pointer to the data structure created to wrap the packet. If NULL,\r
-  @return resource limit occurred.\r
+  @return Pointer to the data structure created to wrap the packet. If any error occurs, \r
+          then return NULL.\r
 \r
 **/\r
 IP_IO_SEND_ENTRY *\r
@@ -1075,7 +1075,7 @@ IpIoListenHandlerDpc (
         IP4_NET_EQUAL (IpIo->StationIp, EFI_NTOHL (((EFI_IP4_RECEIVE_DATA *) RxData)->Header->SourceAddress), IpIo->SubnetMask) &&\r
         !NetIp4IsUnicast (EFI_NTOHL (((EFI_IP4_RECEIVE_DATA *) RxData)->Header->SourceAddress), IpIo->SubnetMask)) {\r
       //\r
-      // The source address is not zero and it's not a unicast IP address, discard it.\r
+      // The source address doesn't match StationIp and it's not a unicast IP address, discard it.\r
       //\r
       goto CleanUp;\r
     }\r
@@ -1221,6 +1221,8 @@ IpIoListenHandler (
 \r
 /**\r
   Create a new IP_IO instance.\r
+\r
+  If IpVersion is not IP_VERSION_4 or IP_VERSION_6, then ASSERT().\r
   \r
   This function uses IP4/IP6 service binding protocol in Controller to create\r
   an IP4/IP6 child (aka IP4/IP6 instance).\r
@@ -1286,7 +1288,7 @@ IpIoCreate (
              Image,\r
              &IpIo->ChildHandle,\r
              IpVersion,             \r
-             (VOID **)&(IpIo->Ip)\r
+             (VOID **) & (IpIo->Ip)\r
              );\r
   if (EFI_ERROR (Status)) {\r
     goto ReleaseIpIo;\r
@@ -1308,7 +1310,9 @@ ReleaseIpIo:
 \r
 /**\r
   Open an IP_IO instance for use.\r
-  \r
+\r
+  If Ip version is not IP_VERSION_4 or IP_VERSION_6, then ASSERT().\r
+\r
   This function is called after IpIoCreate(). It is used for configuring the IP\r
   instance and register the callbacks and their context data for sending and\r
   receiving IP packets.\r
@@ -1419,7 +1423,7 @@ IpIoOpen (
                              );\r
     if (EFI_ERROR (Status)) {\r
       IpIo->Ip.Ip4->Configure (IpIo->Ip.Ip4, NULL);\r
-      goto ErrorExit;\r
+      return Status;\r
     }\r
 \r
   } else {\r
@@ -1431,21 +1435,21 @@ IpIoOpen (
                              );\r
     if (EFI_ERROR (Status)) {\r
       IpIo->Ip.Ip6->Configure (IpIo->Ip.Ip6, NULL);\r
-      goto ErrorExit;\r
+      return Status;\r
     }\r
   }\r
 \r
   IpIo->IsConfigured = TRUE;\r
   InsertTailList (&mActiveIpIoList, &IpIo->Entry);\r
 \r
-ErrorExit:\r
-\r
   return Status;\r
 }\r
 \r
 \r
 /**\r
   Stop an IP_IO instance.\r
+\r
+  If Ip version is not IP_VERSION_4 or IP_VERSION_6, then ASSERT().\r
   \r
   This function is paired with IpIoOpen(). The IP_IO will be unconfigured and all\r
   the pending send/receive tokens will be canceled.\r
@@ -1577,7 +1581,7 @@ IpIoDestroy (
 /**\r
   Send out an IP packet.\r
   \r
-  This function is called after IpIoOpen(). The data to be sent are wrapped in\r
+  This function is called after IpIoOpen(). The data to be sent is wrapped in\r
   Pkt. The IP instance wrapped in IpIo is used for sending by default but can be\r
   overriden by Sender. Other sending configs, like source address and gateway\r
   address etc., are specified in OverrideData.\r
@@ -1664,6 +1668,9 @@ IpIoSend (
 /**\r
   Cancel the IP transmit token which wraps this Packet.\r
 \r
+  If IpIo is NULL, then ASSERT().\r
+  If Packet is NULL, then ASSERT().\r
+\r
   @param[in]  IpIo                  Pointer to the IP_IO instance.\r
   @param[in]  Packet                Pointer to the packet of NET_BUF to cancel.\r
 \r
@@ -1710,6 +1717,9 @@ IpIoCancelTxToken (
 \r
 /**\r
   Add a new IP instance for sending data.\r
+\r
+  If IpIo is NULL, then ASSERT().\r
+  If Ip version is not IP_VERSION_4 or IP_VERSION_6, then ASSERT().\r
   \r
   The function is used to add the IP_IO to the IP_IO sending list. The caller\r
   can later use IpIoFindSender() to get the IP_IO and call IpIoSend() to send\r
@@ -1737,6 +1747,7 @@ IpIoAddIp (
   if (IpInfo == NULL) {\r
     return NULL;\r
   }\r
+  ASSERT ((IpInfo->IpVersion == IP_VERSION_4) || (IpInfo->IpVersion == IP_VERSION_6));\r
 \r
   //\r
   // Init this IpInfo, set the Addr and SubnetMask to 0 before we configure the IP\r
@@ -1812,6 +1823,9 @@ ReleaseIpInfo:
   Configure the IP instance of this IpInfo and start the receiving if IpConfigData\r
   is not NULL.\r
 \r
+  If IpInfo is NULL, then ASSERT().\r
+  If Ip version is not IP_VERSION_4 or IP_VERSION_6, then ASSERT().\r
+\r
   @param[in, out]  IpInfo          Pointer to the IP_IO_IP_INFO instance.\r
   @param[in, out]  IpConfigData    The IP configure data used to configure the IP\r
                                    instance, if NULL the IP instance is reset. If\r
@@ -1861,7 +1875,7 @@ IpIoConfigIp (
   }\r
 \r
   if (EFI_ERROR (Status)) {\r
-    goto OnExit;\r
+    return Status;\r
   }\r
 \r
   if (IpConfigData != NULL) {\r
@@ -1876,7 +1890,7 @@ IpIoConfigIp (
                            );\r
         if (EFI_ERROR (Status)) {\r
           Ip.Ip4->Configure (Ip.Ip4, NULL);\r
-          goto OnExit;\r
+          return Status;\r
         }\r
 \r
         IP4_COPY_ADDRESS (&((EFI_IP4_CONFIG_DATA*) IpConfigData)->StationAddress, &Ip4ModeData.ConfigData.StationAddress);\r
@@ -1910,7 +1924,7 @@ IpIoConfigIp (
                          );\r
       if (EFI_ERROR (Status)) {\r
         Ip.Ip6->Configure (Ip.Ip6, NULL);\r
-        goto OnExit;\r
+        return Status;\r
       }\r
 \r
       if (Ip6ModeData.IsConfigured) {\r
@@ -1946,7 +1960,7 @@ IpIoConfigIp (
 \r
       } else {\r
         Status = EFI_NO_MAPPING;\r
-        goto OnExit;\r
+        return Status;\r
       } \r
 \r
       CopyMem (\r
@@ -1971,8 +1985,6 @@ IpIoConfigIp (
     ZeroMem (&IpInfo->PreMask, sizeof (IpInfo->PreMask));\r
   }\r
 \r
-OnExit:\r
-\r
   return Status;\r
 }\r
 \r
@@ -1980,6 +1992,8 @@ OnExit:
 /**\r
   Destroy an IP instance maintained in IpIo->IpList for\r
   sending purpose.\r
+\r
+  If Ip version is not IP_VERSION_4 or IP_VERSION_6, then ASSERT().\r
   \r
   This function pairs with IpIoAddIp(). The IpInfo is previously created by\r
   IpIoAddIp(). The IP_IO_IP_INFO::RefCnt is decremented and the IP instance\r
@@ -2112,8 +2126,7 @@ IpIoFindSender (
           *IpIo = IpIoPtr;\r
           return IpInfo;       \r
         }\r
-      }      \r
-\r
+      }\r
     }\r
   }\r
 \r
@@ -2260,6 +2273,7 @@ IpIoGetIcmpErrStatus (
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 IpIoRefreshNeighbor (\r
   IN IP_IO           *IpIo,\r
   IN EFI_IP_ADDRESS  *Neighbor,\r