]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Igmp.c
MdeModulePkg: Clean up source files
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Ip4Dxe / Ip4Igmp.c
index 4fbabe2f362d034f526bc68cbf14f05f58a65275..ee768bb39da65c7aeeb193aa7cf789882c2d801e 100644 (file)
@@ -1,7 +1,8 @@
 /** @file\r
+  This file implements the RFC2236: IGMP v2.\r
 \r
-Copyright (c) 2005 - 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\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
 http://opensource.org/licenses/bsd-license.php\r
@@ -9,16 +10,6 @@ http://opensource.org/licenses/bsd-license.php
 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
 \r
-\r
-Module Name:\r
-\r
-  Ip4Igmp.c\r
-\r
-Abstract:\r
-\r
-  This file implements the RFC2236: IGMP v2\r
-\r
-\r
 **/\r
 \r
 #include "Ip4Impl.h"\r
@@ -34,16 +25,16 @@ UINT32  mRouteAlertOption = 0x00000494;
   Init the IGMP control data of the IP4 service instance, configure\r
   MNP to receive ALL SYSTEM multicast.\r
 \r
-  @param  IpSb                   The IP4 service whose IGMP is to be initialized.\r
+  @param[in, out]  IpSb          The IP4 service whose IGMP is to be initialized.\r
 \r
+  @retval EFI_SUCCESS            IGMP of the IpSb is successfully initialized.\r
   @retval EFI_OUT_OF_RESOURCES   Failed to allocate resource to initialize IGMP.\r
   @retval Others                 Failed to initialize the IGMP of IpSb.\r
-  @retval EFI_SUCCESS            IGMP of the IpSb is successfully initialized.\r
 \r
 **/\r
 EFI_STATUS\r
 Ip4InitIgmp (\r
-  IN IP4_SERVICE            *IpSb\r
+  IN OUT IP4_SERVICE            *IpSb\r
   )\r
 {\r
   IGMP_SERVICE_DATA             *IgmpCtrl;\r
@@ -85,7 +76,7 @@ Ip4InitIgmp (
   return EFI_SUCCESS;\r
 \r
 ON_ERROR:\r
-  gBS->FreePool (Group);\r
+  FreePool (Group);\r
   return Status;\r
 }\r
 \r
@@ -94,12 +85,12 @@ ON_ERROR:
   Find the IGMP_GROUP structure which contains the status of multicast\r
   group Address in this IGMP control block\r
 \r
-  @param  IgmpCtrl               The IGMP control block to search from\r
-  @param  Address                The multicast address to search\r
+  @param[in]  IgmpCtrl               The IGMP control block to search from.\r
+  @param[in]  Address                The multicast address to search.\r
 \r
   @return NULL if the multicast address isn't in the IGMP control block. Otherwise\r
-  @return the point to the IGMP_GROUP which contains the status of multicast group\r
-  @return for Address.\r
+          the point to the IGMP_GROUP which contains the status of multicast group\r
+          for Address.\r
 \r
 **/\r
 IGMP_GROUP *\r
@@ -128,11 +119,11 @@ Ip4FindGroup (
   same MAC address. Several IP4 multicast address may be mapped to\r
   the same MAC address.\r
 \r
-  @param  IgmpCtrl               The IGMP control block to search in\r
-  @param  Mac                    The MAC address to search\r
+  @param[in]  IgmpCtrl               The IGMP control block to search in.\r
+  @param[in]  Mac                    The MAC address to search.\r
 \r
   @return The number of the IP4 multicast group that mapped to the same\r
-  @return multicast group Mac.\r
+          multicast group Mac.\r
 \r
 **/\r
 INTN\r
@@ -162,15 +153,15 @@ Ip4FindMac (
 /**\r
   Send an IGMP protocol message to the Dst, such as IGMP v1 membership report.\r
 \r
-  @param  IpSb                   The IP4 service instance that requests the\r
-                                 transmission\r
-  @param  Dst                    The destinaton to send to\r
-  @param  Type                   The IGMP message type, such as IGMP v2 membership\r
-                                 report\r
-  @param  Group                  The group address in the IGMP message head.\r
+  @param[in]  IpSb               The IP4 service instance that requests the\r
+                                 transmission.\r
+  @param[in]  Dst                The destinaton to send to.\r
+  @param[in]  Type               The IGMP message type, such as IGMP v1 membership\r
+                                 report.\r
+  @param[in]  Group              The group address in the IGMP message head.\r
 \r
-  @retval EFI_OUT_OF_RESOURCES   Failed to allocate memory to build the message\r
-  @retval EFI_SUCCESS            The IGMP message is successfully send\r
+  @retval EFI_OUT_OF_RESOURCES   Failed to allocate memory to build the message.\r
+  @retval EFI_SUCCESS            The IGMP message is successfully send.\r
   @retval Others                 Failed to send the IGMP message.\r
 \r
 **/\r
@@ -201,6 +192,9 @@ Ip4SendIgmpMessage (
   NetbufReserve (Packet, IP4_MAX_HEADLEN);\r
 \r
   Igmp = (IGMP_HEAD *) NetbufAllocSpace (Packet, sizeof (IGMP_HEAD), FALSE);\r
+  if (Igmp == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
 \r
   Igmp->Type        = Type;\r
   Igmp->MaxRespTime = 0;\r
@@ -233,12 +227,12 @@ Ip4SendIgmpMessage (
   Send an IGMP membership report. Depends on whether the server is\r
   v1 or v2, it will send either a V1 or V2 membership report.\r
 \r
-  @param  IpSb                   The IP4 service instance that requests the\r
+  @param[in]  IpSb               The IP4 service instance that requests the\r
                                  transmission.\r
-  @param  Group                  The group address to report\r
+  @param[in]  Group              The group address to report.\r
 \r
-  @retval EFI_OUT_OF_RESOURCES   Failed to allocate memory to build the message\r
-  @retval EFI_SUCCESS            The IGMP report message is successfully send\r
+  @retval EFI_OUT_OF_RESOURCES   Failed to allocate memory to build the message.\r
+  @retval EFI_SUCCESS            The IGMP report message is successfully send.\r
   @retval Others                 Failed to send the report.\r
 \r
 **/\r
@@ -257,13 +251,13 @@ Ip4SendIgmpReport (
 \r
 \r
 /**\r
-  Join the multicast group on behavior of this IP4 child\r
+  Join the multicast group on behalf of this IP4 child\r
 \r
-  @param  IpInstance             The IP4 child that wants to join the group\r
-  @param  Address                The group to join\r
+  @param[in]  IpInstance         The IP4 child that wants to join the group.\r
+  @param[in]  Address            The group to join.\r
 \r
-  @retval EFI_SUCCESS            Successfully join the multicast group\r
-  @retval EFI_OUT_OF_RESOURCES   Failed to allocate resources\r
+  @retval EFI_SUCCESS            Successfully join the multicast group.\r
+  @retval EFI_OUT_OF_RESOURCES   Failed to allocate resources.\r
   @retval Others                 Failed to join the multicast group.\r
 \r
 **/\r
@@ -331,19 +325,19 @@ Ip4JoinGroup (
   return EFI_SUCCESS;\r
 \r
 ON_ERROR:\r
-  gBS->FreePool (Group);\r
+  FreePool (Group);\r
   return Status;\r
 }\r
 \r
 \r
 /**\r
-  Leave the IP4 multicast group on behavior of IpInstance.\r
+  Leave the IP4 multicast group on behalf of IpInstance.\r
 \r
-  @param  IpInstance             The IP4 child that wants to leave the group\r
-                                 address\r
-  @param  Address                The group address to leave\r
+  @param[in]  IpInstance         The IP4 child that wants to leave the group\r
+                                 address.\r
+  @param[in]  Address            The group address to leave.\r
 \r
-  @retval EFI_NOT_FOUND          The IP4 service instance isn't in the group\r
+  @retval EFI_NOT_FOUND          The IP4 service instance isn't in the group.\r
   @retval EFI_SUCCESS            Successfully leave the multicast group.\r
   @retval Others                 Failed to leave the multicast group.\r
 \r
@@ -395,12 +389,12 @@ Ip4LeaveGroup (
   // Send a leave report if the membership is reported by us\r
   // and we are talking IGMPv2.\r
   //\r
-  if (Group->ReportByUs && !IgmpCtrl->Igmpv1QuerySeen) {\r
+  if (Group->ReportByUs && IgmpCtrl->Igmpv1QuerySeen == 0) {\r
     Ip4SendIgmpMessage (IpSb, IP4_ALLROUTER_ADDRESS, IGMP_LEAVE_GROUP, Group->Address);\r
   }\r
 \r
   RemoveEntryList (&Group->Link);\r
-  gBS->FreePool (Group);\r
+  FreePool (Group);\r
 \r
   return EFI_SUCCESS;\r
 }\r
@@ -409,9 +403,9 @@ Ip4LeaveGroup (
 /**\r
   Handle the received IGMP message for the IP4 service instance.\r
 \r
-  @param  IpSb                   The IP4 service instance that received the message\r
-  @param  Head                   The IP4 header of the received message\r
-  @param  Packet                 The IGMP message, without IP4 header\r
+  @param[in]  IpSb               The IP4 service instance that received the message.\r
+  @param[in]  Head               The IP4 header of the received message.\r
+  @param[in]  Packet             The IGMP message, without IP4 header.\r
 \r
   @retval EFI_INVALID_PARAMETER  The IGMP message is malformated.\r
   @retval EFI_SUCCESS            The IGMP message is successfully processed.\r
@@ -450,7 +444,7 @@ Ip4IgmpHandle (
   switch (Igmp.Type) {\r
   case IGMP_MEMBERSHIP_QUERY:\r
     //\r
-    // If MaxRespTIme is zero, it is most likely that we are\r
+    // If MaxRespTime is zero, it is most likely that we are\r
     // talking to a V1 router\r
     //\r
     if (Igmp.MaxRespTime == 0) {\r
@@ -511,13 +505,11 @@ Ip4IgmpHandle (
   The periodical timer function for IGMP. It does the following\r
   things:\r
   1. Decrease the Igmpv1QuerySeen to make it possible to refresh\r
-  the IGMP server type.\r
+     the IGMP server type.\r
   2. Decrease the report timer for each IGMP group in "delaying\r
-  member" state.\r
-\r
-  @param  IpSb                   The IP4 service instance that is ticking\r
+     member" state.\r
 \r
-  @return None\r
+  @param[in]  IpSb                   The IP4 service instance that is ticking.\r
 \r
 **/\r
 VOID\r
@@ -561,12 +553,12 @@ Ip4IgmpTicking (
   assume the byte order of the both Source and Addr, the\r
   network byte order is used by the caller.\r
 \r
-  @param  Source                 The array of group addresses to add to\r
-  @param  Count                  The number of group addresses in the Source\r
-  @param  Addr                   The IP4 multicast address to add\r
+  @param[in]  Source                 The array of group addresses to add to.\r
+  @param[in]  Count                  The number of group addresses in the Source.\r
+  @param[in]  Addr                   The IP4 multicast address to add.\r
 \r
   @return NULL if failed to allocate memory for the new groups,\r
-  @return otherwise the new combined group addresses.\r
+          otherwise the new combined group addresses.\r
 \r
 **/\r
 IP4_ADDR *\r
@@ -592,24 +584,24 @@ Ip4CombineGroups (
 \r
 \r
 /**\r
-  Remove a group address frome the array of group addresses.\r
+  Remove a group address from the array of group addresses.\r
   Although the function doesn't assume the byte order of the\r
   both Groups and Addr, the network byte order is used by\r
   the caller.\r
 \r
-  @param  Groups                 The array of group addresses to remove from\r
-  @param  Count                  The number of group addresses in the Groups\r
-  @param  Addr                   The IP4 multicast address to remove\r
+  @param  Groups            The array of group addresses to remove from.\r
+  @param  Count             The number of group addresses in the Groups.\r
+  @param  Addr              The IP4 multicast address to remove.\r
 \r
   @return The nubmer of group addresses in the Groups after remove.\r
-  @return It is Count if the Addr isn't in the Groups.\r
+          It is Count if the Addr isn't in the Groups.\r
 \r
 **/\r
 INTN\r
 Ip4RemoveGroupAddr (\r
-  IN IP4_ADDR               *Groups,\r
-  IN UINT32                 Count,\r
-  IN IP4_ADDR               Addr\r
+  IN OUT IP4_ADDR               *Groups,\r
+  IN     UINT32                 Count,\r
+  IN     IP4_ADDR               Addr\r
   )\r
 {\r
   UINT32                    Index;\r