2 Implementation of converting an multicast IP address to multicast HW MAC
5 Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
13 Call undi to convert an multicast IP address to a MAC address.
15 @param Snp Pointer to snp driver structure.
16 @param IPv6 Flag to indicate if this is an ipv6 address.
17 @param IP Multicast IP address.
18 @param MAC Pointer to hold the return MAC address.
20 @retval EFI_SUCCESS The multicast IP address was mapped to the
21 multicast HW MAC address.
22 @retval EFI_INVALID_PARAMETER Invalid UNDI command.
23 @retval EFI_UNSUPPORTED Command is not supported by UNDI.
24 @retval EFI_DEVICE_ERROR Fail to execute UNDI command.
31 IN EFI_IP_ADDRESS
*IP
,
32 IN OUT EFI_MAC_ADDRESS
*MAC
35 PXE_CPB_MCAST_IP_TO_MAC
*Cpb
;
36 PXE_DB_MCAST_IP_TO_MAC
*Db
;
40 Snp
->Cdb
.OpCode
= PXE_OPCODE_MCAST_IP_TO_MAC
;
41 Snp
->Cdb
.OpFlags
= (UINT16
)(IPv6
? PXE_OPFLAGS_MCAST_IPV6_TO_MAC
: PXE_OPFLAGS_MCAST_IPV4_TO_MAC
);
42 Snp
->Cdb
.CPBsize
= (UINT16
)sizeof (PXE_CPB_MCAST_IP_TO_MAC
);
43 Snp
->Cdb
.DBsize
= (UINT16
)sizeof (PXE_DB_MCAST_IP_TO_MAC
);
45 Snp
->Cdb
.CPBaddr
= (UINT64
)(UINTN
)Cpb
;
46 Snp
->Cdb
.DBaddr
= (UINT64
)(UINTN
)Db
;
48 Snp
->Cdb
.StatCode
= PXE_STATCODE_INITIALIZE
;
49 Snp
->Cdb
.StatFlags
= PXE_STATFLAGS_INITIALIZE
;
50 Snp
->Cdb
.IFnum
= Snp
->IfNum
;
51 Snp
->Cdb
.Control
= PXE_CONTROL_LAST_CDB_IN_LIST
;
53 CopyMem (&Cpb
->IP
, IP
, sizeof (PXE_IP_ADDR
));
56 // Issue UNDI command and check result.
58 DEBUG ((DEBUG_NET
, "\nSnp->undi.mcast_ip_to_mac() "));
60 (*Snp
->IssueUndi32Command
)((UINT64
)(UINTN
)&Snp
->Cdb
);
62 switch (Snp
->Cdb
.StatCode
) {
63 case PXE_STATCODE_SUCCESS
:
66 case PXE_STATCODE_INVALID_CPB
:
67 return EFI_INVALID_PARAMETER
;
69 case PXE_STATCODE_UNSUPPORTED
:
72 "\nSnp->undi.mcast_ip_to_mac() %xh:%xh\n",
76 return EFI_UNSUPPORTED
;
80 // UNDI command failed. Return EFI_DEVICE_ERROR
85 "\nSnp->undi.mcast_ip_to_mac() %xh:%xh\n",
90 return EFI_DEVICE_ERROR
;
93 CopyMem (MAC
, &Db
->MAC
, sizeof (PXE_MAC_ADDR
));
98 Converts a multicast IP address to a multicast HW MAC address.
100 This function converts a multicast IP address to a multicast HW MAC address
101 for all packet transactions. If the mapping is accepted, then EFI_SUCCESS will
104 @param This A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL instance.
105 @param IPv6 Set to TRUE if the multicast IP address is IPv6 [RFC 2460].
106 Set to FALSE if the multicast IP address is IPv4 [RFC 791].
107 @param IP The multicast IP address that is to be converted to a multicast
109 @param MAC The multicast HW MAC address that is to be generated from IP.
111 @retval EFI_SUCCESS The multicast IP address was mapped to the
112 multicast HW MAC address.
113 @retval EFI_NOT_STARTED The Simple Network Protocol interface has not
114 been started by calling Start().
115 @retval EFI_INVALID_PARAMETER IP is NULL.
116 @retval EFI_INVALID_PARAMETER MAC is NULL.
117 @retval EFI_INVALID_PARAMETER IP does not point to a valid IPv4 or IPv6
119 @retval EFI_DEVICE_ERROR The Simple Network Protocol interface has not
120 been initialized by calling Initialize().
121 @retval EFI_UNSUPPORTED IPv6 is TRUE and the implementation does not
122 support IPv6 multicast to MAC address conversion.
127 SnpUndi32McastIpToMac (
128 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
130 IN EFI_IP_ADDRESS
*IP
,
131 OUT EFI_MAC_ADDRESS
*MAC
139 // Get pointer to SNP driver instance for *this.
142 return EFI_INVALID_PARAMETER
;
145 if ((IP
== NULL
) || (MAC
== NULL
)) {
146 return EFI_INVALID_PARAMETER
;
149 Snp
= EFI_SIMPLE_NETWORK_DEV_FROM_THIS (This
);
151 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
153 switch (Snp
->Mode
.State
) {
154 case EfiSimpleNetworkInitialized
:
157 case EfiSimpleNetworkStopped
:
158 Status
= EFI_NOT_STARTED
;
162 Status
= EFI_DEVICE_ERROR
;
166 Status
= PxeIp2Mac (Snp
, IPv6
, IP
, MAC
);
169 gBS
->RestoreTPL (OldTpl
);