]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/SnpDxe/Mcast_ip_to_mac.c
sync comments, fix function header, rename variable name to follow coding style.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / SnpDxe / Mcast_ip_to_mac.c
index 91b5e02fc1974a8d1fbc9687999f443399febc21..00c80eb95f179c353804a2f10a257348161d91a8 100644 (file)
@@ -1,72 +1,66 @@
 /** @file\r
-Copyright (c) 2004 - 2007, Intel Corporation\r
-All rights reserved. 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
+               Implementation of converting an multicast IP address to multicast HW MAC\r
+               address.\r
\r
+Copyright (c) 2004 - 2007, Intel Corporation. <BR> \r
+All rights reserved. This program and the accompanying materials are licensed \r
+and made available under the terms and conditions of the BSD License which \r
+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
 \r
-Module name:\r
-  mcast_ip_to_mac.c\r
-\r
-Abstract:\r
-\r
-Revision history:\r
-  2000-Feb-17 M(f)J   Genesis.\r
-\r
 **/\r
 \r
 #include "Snp.h"\r
 \r
 /**\r
-  this routine calls undi to convert an multicast IP address to a MAC address\r
+  this routine calls undi to convert an multicast IP address to a MAC address.\r
 \r
-  @param  snp   pointer to snp driver structure\r
+  @param  Snp   pointer to snp driver structure\r
   @param  IPv6  flag to indicate if this is an ipv6 address\r
   @param  IP    multicast IP address\r
   @param  MAC   pointer to hold the return MAC address\r
 \r
 \r
 **/\r
-STATIC\r
 EFI_STATUS\r
-pxe_ip2mac (\r
-  IN SNP_DRIVER          *snp,\r
+PxeIp2Mac (\r
+  IN SNP_DRIVER          *Snp,\r
   IN BOOLEAN             IPv6,\r
   IN EFI_IP_ADDRESS      *IP,\r
   IN OUT EFI_MAC_ADDRESS *MAC\r
   )\r
 {\r
-  PXE_CPB_MCAST_IP_TO_MAC *cpb;\r
-  PXE_DB_MCAST_IP_TO_MAC  *db;\r
+  PXE_CPB_MCAST_IP_TO_MAC *Cpb;\r
+  PXE_DB_MCAST_IP_TO_MAC  *Db;\r
 \r
-  cpb                 = snp->cpb;\r
-  db                  = snp->db;\r
-  snp->cdb.OpCode     = PXE_OPCODE_MCAST_IP_TO_MAC;\r
-  snp->cdb.OpFlags    = (UINT16) (IPv6 ? PXE_OPFLAGS_MCAST_IPV6_TO_MAC : PXE_OPFLAGS_MCAST_IPV4_TO_MAC);\r
-  snp->cdb.CPBsize    = sizeof (PXE_CPB_MCAST_IP_TO_MAC);\r
-  snp->cdb.DBsize     = sizeof (PXE_DB_MCAST_IP_TO_MAC);\r
+  Cpb                 = Snp->Cpb;\r
+  Db                  = Snp->Db;\r
+  Snp->Cdb.OpCode     = PXE_OPCODE_MCAST_IP_TO_MAC;\r
+  Snp->Cdb.OpFlags    = (UINT16) (IPv6 ? PXE_OPFLAGS_MCAST_IPV6_TO_MAC : PXE_OPFLAGS_MCAST_IPV4_TO_MAC);\r
+  Snp->Cdb.CPBsize    = sizeof (PXE_CPB_MCAST_IP_TO_MAC);\r
+  Snp->Cdb.DBsize     = sizeof (PXE_DB_MCAST_IP_TO_MAC);\r
 \r
-  snp->cdb.CPBaddr    = (UINT64)(UINTN) cpb;\r
-  snp->cdb.DBaddr     = (UINT64)(UINTN) db;\r
+  Snp->Cdb.CPBaddr    = (UINT64)(UINTN) Cpb;\r
+  Snp->Cdb.DBaddr     = (UINT64)(UINTN) Db;\r
 \r
-  snp->cdb.StatCode   = PXE_STATCODE_INITIALIZE;\r
-  snp->cdb.StatFlags  = PXE_STATFLAGS_INITIALIZE;\r
-  snp->cdb.IFnum      = snp->if_num;\r
-  snp->cdb.Control    = PXE_CONTROL_LAST_CDB_IN_LIST;\r
+  Snp->Cdb.StatCode   = PXE_STATCODE_INITIALIZE;\r
+  Snp->Cdb.StatFlags  = PXE_STATFLAGS_INITIALIZE;\r
+  Snp->Cdb.IFnum      = Snp->IfNum;\r
+  Snp->Cdb.Control    = PXE_CONTROL_LAST_CDB_IN_LIST;\r
 \r
-  CopyMem (&cpb->IP, IP, sizeof (PXE_IP_ADDR));\r
+  CopyMem (&Cpb->IP, IP, sizeof (PXE_IP_ADDR));\r
 \r
   //\r
   // Issue UNDI command and check result.\r
   //\r
-  DEBUG ((EFI_D_NET, "\nsnp->undi.mcast_ip_to_mac()  "));\r
+  DEBUG ((EFI_D_NET, "\nSnp->undi.mcast_ip_to_mac()  "));\r
 \r
-  (*snp->issue_undi32_command) ((UINT64)(UINTN) &snp->cdb);\r
+  (*Snp->IssueUndi32Command) ((UINT64)(UINTN) &Snp->Cdb);\r
 \r
-  switch (snp->cdb.StatCode) {\r
+  switch (Snp->Cdb.StatCode) {\r
   case PXE_STATCODE_SUCCESS:\r
     break;\r
 \r
@@ -76,9 +70,9 @@ pxe_ip2mac (
   case PXE_STATCODE_UNSUPPORTED:\r
     DEBUG (\r
       (EFI_D_NET,\r
-      "\nsnp->undi.mcast_ip_to_mac()  %xh:%xh\n",\r
-      snp->cdb.StatFlags,\r
-      snp->cdb.StatCode)\r
+      "\nSnp->undi.mcast_ip_to_mac()  %xh:%xh\n",\r
+      Snp->Cdb.StatFlags,\r
+      Snp->Cdb.StatCode)\r
       );\r
     return EFI_UNSUPPORTED;\r
 \r
@@ -89,49 +83,64 @@ pxe_ip2mac (
     //\r
     DEBUG (\r
       (EFI_D_NET,\r
-      "\nsnp->undi.mcast_ip_to_mac()  %xh:%xh\n",\r
-      snp->cdb.StatFlags,\r
-      snp->cdb.StatCode)\r
+      "\nSnp->undi.mcast_ip_to_mac()  %xh:%xh\n",\r
+      Snp->Cdb.StatFlags,\r
+      Snp->Cdb.StatCode)\r
       );\r
 \r
     return EFI_DEVICE_ERROR;\r
   }\r
 \r
-  CopyMem (MAC, &db->MAC, sizeof (PXE_MAC_ADDR));\r
+  CopyMem (MAC, &Db->MAC, sizeof (PXE_MAC_ADDR));\r
   return EFI_SUCCESS;\r
 }\r
 \r
 \r
 /**\r
-  This is the SNP interface routine for converting a multicast IP address to\r
-  a MAC address.\r
-  This routine basically retrieves snp structure, checks the SNP state and\r
-  calls the pxe_ip2mac routine to actually do the conversion\r
-\r
-  @param  this  context pointer\r
-  @param  IPv6  flag to indicate if this is an ipv6 address\r
-  @param  IP    multicast IP address\r
-  @param  MAC   pointer to hold the return MAC address\r
-\r
+  Converts a multicast IP address to a multicast HW MAC address.\r
+  \r
+  This function converts a multicast IP address to a multicast HW MAC address \r
+  for all packet transactions. If the mapping is accepted, then EFI_SUCCESS will\r
+  be returned.\r
+\r
+  @param This A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL instance.\r
+  @param IPv6 Set to TRUE if the multicast IP address is IPv6 [RFC 2460].\r
+              Set to FALSE if the multicast IP address is IPv4 [RFC 791]. \r
+  @param IP   The multicast IP address that is to be converted to a multicast \r
+              HW MAC address.\r
+  @param MAC  The multicast HW MAC address that is to be generated from IP.\r
+\r
+  @retval EFI_SUCCESS           The multicast IP address was mapped to the\r
+                                multicast HW MAC address.\r
+  @retval EFI_NOT_STARTED       The Simple Network Protocol interface has not \r
+                                been started by calling Start().\r
+  @retval EFI_INVALID_PARAMETER IP is NULL.\r
+  @retval EFI_INVALID_PARAMETER MAC is NULL.\r
+  @retval EFI_INVALID_PARAMETER IP does not point to a valid IPv4 or IPv6 \r
+                                multicast address.\r
+  @retval EFI_DEVICE_ERROR      The Simple Network Protocol interface has not \r
+                                been initialized by calling Initialize().\r
+  @retval EFI_UNSUPPORTED       IPv6 is TRUE and the implementation does not \r
+                                support IPv6 multicast to MAC address conversion.\r
 \r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
-snp_undi32_mcast_ip_to_mac (\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL *this,\r
+SnpUndi32McastIpToMac (\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL *This,\r
   IN BOOLEAN                     IPv6,\r
   IN EFI_IP_ADDRESS              *IP,\r
   OUT EFI_MAC_ADDRESS            *MAC\r
   )\r
 {\r
-  SNP_DRIVER  *snp;\r
+  SNP_DRIVER  *Snp;\r
   EFI_TPL     OldTpl;\r
   EFI_STATUS  Status;\r
 \r
   //\r
   // Get pointer to SNP driver instance for *this.\r
   //\r
-  if (this == NULL) {\r
+  if (This == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
@@ -139,11 +148,11 @@ snp_undi32_mcast_ip_to_mac (
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  snp = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (this);\r
+  Snp = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (This);\r
 \r
   OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
 \r
-  switch (snp->mode.State) {\r
+  switch (Snp->Mode.State) {\r
   case EfiSimpleNetworkInitialized:\r
     break;\r
 \r
@@ -156,7 +165,7 @@ snp_undi32_mcast_ip_to_mac (
     goto ON_EXIT;\r
   }\r
 \r
-  Status = pxe_ip2mac (snp, IPv6, IP, MAC);\r
+  Status = PxeIp2Mac (Snp, IPv6, IP, MAC);\r
 \r
 ON_EXIT:\r
   gBS->RestoreTPL (OldTpl);\r