2008-02-20 03:35:43 +01:00
|
|
|
/** @file
|
2018-06-27 15:08:52 +02:00
|
|
|
Implementation of converting an multicast IP address to multicast HW MAC
|
|
|
|
address.
|
|
|
|
|
|
|
|
Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
|
|
This program and the accompanying materials are licensed
|
|
|
|
and made available under the terms and conditions of the BSD License which
|
|
|
|
accompanies this distribution. The full text of the license may be found at
|
|
|
|
http://opensource.org/licenses/bsd-license.php
|
2008-02-20 03:35:43 +01:00
|
|
|
|
|
|
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
#include "Snp.h"
|
|
|
|
|
|
|
|
/**
|
2008-12-29 02:16:13 +01:00
|
|
|
Call undi to convert an multicast IP address to a MAC address.
|
2008-02-20 03:35:43 +01:00
|
|
|
|
2008-12-29 02:16:13 +01:00
|
|
|
@param Snp Pointer to snp driver structure.
|
|
|
|
@param IPv6 Flag to indicate if this is an ipv6 address.
|
|
|
|
@param IP Multicast IP address.
|
|
|
|
@param MAC Pointer to hold the return MAC address.
|
2008-02-20 03:35:43 +01:00
|
|
|
|
2018-06-27 15:08:52 +02:00
|
|
|
@retval EFI_SUCCESS The multicast IP address was mapped to the
|
2008-12-29 02:16:13 +01:00
|
|
|
multicast HW MAC address.
|
2018-06-27 15:08:52 +02:00
|
|
|
@retval EFI_INVALID_PARAMETER Invalid UNDI command.
|
|
|
|
@retval EFI_UNSUPPORTED Command is not supported by UNDI.
|
|
|
|
@retval EFI_DEVICE_ERROR Fail to execute UNDI command.
|
2008-02-20 03:35:43 +01:00
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
2008-11-13 04:42:21 +01:00
|
|
|
PxeIp2Mac (
|
|
|
|
IN SNP_DRIVER *Snp,
|
2008-02-20 03:35:43 +01:00
|
|
|
IN BOOLEAN IPv6,
|
|
|
|
IN EFI_IP_ADDRESS *IP,
|
|
|
|
IN OUT EFI_MAC_ADDRESS *MAC
|
|
|
|
)
|
|
|
|
{
|
2008-11-13 04:42:21 +01:00
|
|
|
PXE_CPB_MCAST_IP_TO_MAC *Cpb;
|
|
|
|
PXE_DB_MCAST_IP_TO_MAC *Db;
|
2008-02-20 03:35:43 +01:00
|
|
|
|
2008-11-13 04:42:21 +01:00
|
|
|
Cpb = Snp->Cpb;
|
|
|
|
Db = Snp->Db;
|
|
|
|
Snp->Cdb.OpCode = PXE_OPCODE_MCAST_IP_TO_MAC;
|
|
|
|
Snp->Cdb.OpFlags = (UINT16) (IPv6 ? PXE_OPFLAGS_MCAST_IPV6_TO_MAC : PXE_OPFLAGS_MCAST_IPV4_TO_MAC);
|
2010-09-15 09:48:11 +02:00
|
|
|
Snp->Cdb.CPBsize = (UINT16) sizeof (PXE_CPB_MCAST_IP_TO_MAC);
|
|
|
|
Snp->Cdb.DBsize = (UINT16) sizeof (PXE_DB_MCAST_IP_TO_MAC);
|
2008-02-20 03:35:43 +01:00
|
|
|
|
2008-11-13 04:42:21 +01:00
|
|
|
Snp->Cdb.CPBaddr = (UINT64)(UINTN) Cpb;
|
|
|
|
Snp->Cdb.DBaddr = (UINT64)(UINTN) Db;
|
2008-02-20 03:35:43 +01:00
|
|
|
|
2008-11-13 04:42:21 +01:00
|
|
|
Snp->Cdb.StatCode = PXE_STATCODE_INITIALIZE;
|
|
|
|
Snp->Cdb.StatFlags = PXE_STATFLAGS_INITIALIZE;
|
|
|
|
Snp->Cdb.IFnum = Snp->IfNum;
|
|
|
|
Snp->Cdb.Control = PXE_CONTROL_LAST_CDB_IN_LIST;
|
2008-02-20 03:35:43 +01:00
|
|
|
|
2008-11-13 04:42:21 +01:00
|
|
|
CopyMem (&Cpb->IP, IP, sizeof (PXE_IP_ADDR));
|
2008-02-20 03:35:43 +01:00
|
|
|
|
|
|
|
//
|
|
|
|
// Issue UNDI command and check result.
|
|
|
|
//
|
2009-02-09 02:22:19 +01:00
|
|
|
DEBUG ((EFI_D_NET, "\nSnp->undi.mcast_ip_to_mac() "));
|
2008-02-20 03:35:43 +01:00
|
|
|
|
2008-11-13 04:42:21 +01:00
|
|
|
(*Snp->IssueUndi32Command) ((UINT64)(UINTN) &Snp->Cdb);
|
2008-02-20 03:35:43 +01:00
|
|
|
|
2008-11-13 04:42:21 +01:00
|
|
|
switch (Snp->Cdb.StatCode) {
|
2008-02-20 03:35:43 +01:00
|
|
|
case PXE_STATCODE_SUCCESS:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PXE_STATCODE_INVALID_CPB:
|
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
case PXE_STATCODE_UNSUPPORTED:
|
|
|
|
DEBUG (
|
2009-02-09 02:22:19 +01:00
|
|
|
(EFI_D_NET,
|
2008-11-13 04:42:21 +01:00
|
|
|
"\nSnp->undi.mcast_ip_to_mac() %xh:%xh\n",
|
|
|
|
Snp->Cdb.StatFlags,
|
|
|
|
Snp->Cdb.StatCode)
|
2008-02-20 03:35:43 +01:00
|
|
|
);
|
|
|
|
return EFI_UNSUPPORTED;
|
|
|
|
|
|
|
|
default:
|
|
|
|
//
|
|
|
|
// UNDI command failed. Return EFI_DEVICE_ERROR
|
|
|
|
// to caller.
|
|
|
|
//
|
|
|
|
DEBUG (
|
2009-02-09 02:22:19 +01:00
|
|
|
(EFI_D_NET,
|
2008-11-13 04:42:21 +01:00
|
|
|
"\nSnp->undi.mcast_ip_to_mac() %xh:%xh\n",
|
|
|
|
Snp->Cdb.StatFlags,
|
|
|
|
Snp->Cdb.StatCode)
|
2008-02-20 03:35:43 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
return EFI_DEVICE_ERROR;
|
|
|
|
}
|
|
|
|
|
2008-11-13 04:42:21 +01:00
|
|
|
CopyMem (MAC, &Db->MAC, sizeof (PXE_MAC_ADDR));
|
2008-02-20 03:35:43 +01:00
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2008-11-13 04:42:21 +01:00
|
|
|
Converts a multicast IP address to a multicast HW MAC address.
|
2018-06-27 15:08:52 +02:00
|
|
|
|
|
|
|
This function converts a multicast IP address to a multicast HW MAC address
|
2008-11-13 04:42:21 +01:00
|
|
|
for all packet transactions. If the mapping is accepted, then EFI_SUCCESS will
|
|
|
|
be returned.
|
|
|
|
|
|
|
|
@param This A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL instance.
|
|
|
|
@param IPv6 Set to TRUE if the multicast IP address is IPv6 [RFC 2460].
|
2018-06-27 15:08:52 +02:00
|
|
|
Set to FALSE if the multicast IP address is IPv4 [RFC 791].
|
|
|
|
@param IP The multicast IP address that is to be converted to a multicast
|
2008-11-13 04:42:21 +01:00
|
|
|
HW MAC address.
|
|
|
|
@param MAC The multicast HW MAC address that is to be generated from IP.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The multicast IP address was mapped to the
|
|
|
|
multicast HW MAC address.
|
2018-06-27 15:08:52 +02:00
|
|
|
@retval EFI_NOT_STARTED The Simple Network Protocol interface has not
|
2008-11-13 04:42:21 +01:00
|
|
|
been started by calling Start().
|
|
|
|
@retval EFI_INVALID_PARAMETER IP is NULL.
|
|
|
|
@retval EFI_INVALID_PARAMETER MAC is NULL.
|
2018-06-27 15:08:52 +02:00
|
|
|
@retval EFI_INVALID_PARAMETER IP does not point to a valid IPv4 or IPv6
|
2008-11-13 04:42:21 +01:00
|
|
|
multicast address.
|
2018-06-27 15:08:52 +02:00
|
|
|
@retval EFI_DEVICE_ERROR The Simple Network Protocol interface has not
|
2008-11-13 04:42:21 +01:00
|
|
|
been initialized by calling Initialize().
|
2018-06-27 15:08:52 +02:00
|
|
|
@retval EFI_UNSUPPORTED IPv6 is TRUE and the implementation does not
|
2008-11-13 04:42:21 +01:00
|
|
|
support IPv6 multicast to MAC address conversion.
|
2008-02-20 03:35:43 +01:00
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
2008-11-13 04:42:21 +01:00
|
|
|
SnpUndi32McastIpToMac (
|
|
|
|
IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
|
2008-02-20 03:35:43 +01:00
|
|
|
IN BOOLEAN IPv6,
|
|
|
|
IN EFI_IP_ADDRESS *IP,
|
|
|
|
OUT EFI_MAC_ADDRESS *MAC
|
|
|
|
)
|
|
|
|
{
|
2008-11-13 04:42:21 +01:00
|
|
|
SNP_DRIVER *Snp;
|
2008-02-20 03:35:43 +01:00
|
|
|
EFI_TPL OldTpl;
|
|
|
|
EFI_STATUS Status;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Get pointer to SNP driver instance for *this.
|
|
|
|
//
|
2008-11-13 04:42:21 +01:00
|
|
|
if (This == NULL) {
|
2008-02-20 03:35:43 +01:00
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (IP == NULL || MAC == NULL) {
|
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
2008-11-13 04:42:21 +01:00
|
|
|
Snp = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (This);
|
2008-02-20 03:35:43 +01:00
|
|
|
|
|
|
|
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
|
|
|
|
|
2008-11-13 04:42:21 +01:00
|
|
|
switch (Snp->Mode.State) {
|
2008-02-20 03:35:43 +01:00
|
|
|
case EfiSimpleNetworkInitialized:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EfiSimpleNetworkStopped:
|
|
|
|
Status = EFI_NOT_STARTED;
|
|
|
|
goto ON_EXIT;
|
|
|
|
|
|
|
|
default:
|
|
|
|
Status = EFI_DEVICE_ERROR;
|
|
|
|
goto ON_EXIT;
|
|
|
|
}
|
|
|
|
|
2008-11-13 04:42:21 +01:00
|
|
|
Status = PxeIp2Mac (Snp, IPv6, IP, MAC);
|
2008-02-20 03:35:43 +01:00
|
|
|
|
|
|
|
ON_EXIT:
|
|
|
|
gBS->RestoreTPL (OldTpl);
|
|
|
|
|
|
|
|
return Status;
|
|
|
|
}
|