EDK2 doxygen online documents - Firmware Encoding Index 1
EDK2 doxygen online documents - Firmware Encoding Index

MdeModulePkg/Universal/Network/SnpDxe/Mcast_ip_to_mac.c

Go to the documentation of this file.
00001 
00016 #include "Snp.h"
00017 
00033 EFI_STATUS
00034 PxeIp2Mac (
00035   IN SNP_DRIVER          *Snp,
00036   IN BOOLEAN             IPv6,
00037   IN EFI_IP_ADDRESS      *IP,
00038   IN OUT EFI_MAC_ADDRESS *MAC
00039   )
00040 {
00041   PXE_CPB_MCAST_IP_TO_MAC *Cpb;
00042   PXE_DB_MCAST_IP_TO_MAC  *Db;
00043 
00044   Cpb                 = Snp->Cpb;
00045   Db                  = Snp->Db;
00046   Snp->Cdb.OpCode     = PXE_OPCODE_MCAST_IP_TO_MAC;
00047   Snp->Cdb.OpFlags    = (UINT16) (IPv6 ? PXE_OPFLAGS_MCAST_IPV6_TO_MAC : PXE_OPFLAGS_MCAST_IPV4_TO_MAC);
00048   Snp->Cdb.CPBsize    = (UINT16) sizeof (PXE_CPB_MCAST_IP_TO_MAC);
00049   Snp->Cdb.DBsize     = (UINT16) sizeof (PXE_DB_MCAST_IP_TO_MAC);
00050 
00051   Snp->Cdb.CPBaddr    = (UINT64)(UINTN) Cpb;
00052   Snp->Cdb.DBaddr     = (UINT64)(UINTN) Db;
00053 
00054   Snp->Cdb.StatCode   = PXE_STATCODE_INITIALIZE;
00055   Snp->Cdb.StatFlags  = PXE_STATFLAGS_INITIALIZE;
00056   Snp->Cdb.IFnum      = Snp->IfNum;
00057   Snp->Cdb.Control    = PXE_CONTROL_LAST_CDB_IN_LIST;
00058 
00059   CopyMem (&Cpb->IP, IP, sizeof (PXE_IP_ADDR));
00060 
00061   //
00062   // Issue UNDI command and check result.
00063   //
00064   DEBUG ((EFI_D_NET, "\nSnp->undi.mcast_ip_to_mac()  "));
00065 
00066   (*Snp->IssueUndi32Command) ((UINT64)(UINTN) &Snp->Cdb);
00067 
00068   switch (Snp->Cdb.StatCode) {
00069   case PXE_STATCODE_SUCCESS:
00070     break;
00071 
00072   case PXE_STATCODE_INVALID_CPB:
00073     return EFI_INVALID_PARAMETER;
00074 
00075   case PXE_STATCODE_UNSUPPORTED:
00076     DEBUG (
00077       (EFI_D_NET,
00078       "\nSnp->undi.mcast_ip_to_mac()  %xh:%xh\n",
00079       Snp->Cdb.StatFlags,
00080       Snp->Cdb.StatCode)
00081       );
00082     return EFI_UNSUPPORTED;
00083 
00084   default:
00085     //
00086     // UNDI command failed.  Return EFI_DEVICE_ERROR
00087     // to caller.
00088     //
00089     DEBUG (
00090       (EFI_D_NET,
00091       "\nSnp->undi.mcast_ip_to_mac()  %xh:%xh\n",
00092       Snp->Cdb.StatFlags,
00093       Snp->Cdb.StatCode)
00094       );
00095 
00096     return EFI_DEVICE_ERROR;
00097   }
00098 
00099   CopyMem (MAC, &Db->MAC, sizeof (PXE_MAC_ADDR));
00100   return EFI_SUCCESS;
00101 }
00102 
00103 
00132 EFI_STATUS
00133 EFIAPI
00134 SnpUndi32McastIpToMac (
00135   IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
00136   IN BOOLEAN                     IPv6,
00137   IN EFI_IP_ADDRESS              *IP,
00138   OUT EFI_MAC_ADDRESS            *MAC
00139   )
00140 {
00141   SNP_DRIVER  *Snp;
00142   EFI_TPL     OldTpl;
00143   EFI_STATUS  Status;
00144 
00145   //
00146   // Get pointer to SNP driver instance for *this.
00147   //
00148   if (This == NULL) {
00149     return EFI_INVALID_PARAMETER;
00150   }
00151 
00152   if (IP == NULL || MAC == NULL) {
00153     return EFI_INVALID_PARAMETER;
00154   }
00155 
00156   Snp = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (This);
00157 
00158   OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
00159 
00160   switch (Snp->Mode.State) {
00161   case EfiSimpleNetworkInitialized:
00162     break;
00163 
00164   case EfiSimpleNetworkStopped:
00165     Status = EFI_NOT_STARTED;
00166     goto ON_EXIT;
00167 
00168   default:
00169     Status = EFI_DEVICE_ERROR;
00170     goto ON_EXIT;
00171   }
00172 
00173   Status = PxeIp2Mac (Snp, IPv6, IP, MAC);
00174 
00175 ON_EXIT:
00176   gBS->RestoreTPL (OldTpl);
00177 
00178   return Status;
00179 }
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Defines