2 Implementation of converting an multicast IP address to multicast HW MAC
5 Copyright (c) 2004 - 2007, Intel Corporation. <BR>
6 All rights reserved. This program and the accompanying materials are licensed
7 and made available under the terms and conditions of the BSD License which
8 accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19 this routine calls undi to convert an multicast IP address to a MAC address.
21 @param Snp pointer to snp driver structure
22 @param IPv6 flag to indicate if this is an ipv6 address
23 @param IP multicast IP address
24 @param MAC pointer to hold the return MAC address
32 IN EFI_IP_ADDRESS
*IP
,
33 IN OUT EFI_MAC_ADDRESS
*MAC
36 PXE_CPB_MCAST_IP_TO_MAC
*Cpb
;
37 PXE_DB_MCAST_IP_TO_MAC
*Db
;
41 Snp
->Cdb
.OpCode
= PXE_OPCODE_MCAST_IP_TO_MAC
;
42 Snp
->Cdb
.OpFlags
= (UINT16
) (IPv6
? PXE_OPFLAGS_MCAST_IPV6_TO_MAC
: PXE_OPFLAGS_MCAST_IPV4_TO_MAC
);
43 Snp
->Cdb
.CPBsize
= sizeof (PXE_CPB_MCAST_IP_TO_MAC
);
44 Snp
->Cdb
.DBsize
= sizeof (PXE_DB_MCAST_IP_TO_MAC
);
46 Snp
->Cdb
.CPBaddr
= (UINT64
)(UINTN
) Cpb
;
47 Snp
->Cdb
.DBaddr
= (UINT64
)(UINTN
) Db
;
49 Snp
->Cdb
.StatCode
= PXE_STATCODE_INITIALIZE
;
50 Snp
->Cdb
.StatFlags
= PXE_STATFLAGS_INITIALIZE
;
51 Snp
->Cdb
.IFnum
= Snp
->IfNum
;
52 Snp
->Cdb
.Control
= PXE_CONTROL_LAST_CDB_IN_LIST
;
54 CopyMem (&Cpb
->IP
, IP
, sizeof (PXE_IP_ADDR
));
57 // Issue UNDI command and check result.
59 DEBUG ((EFI_D_NET
, "\nSnp->undi.mcast_ip_to_mac() "));
61 (*Snp
->IssueUndi32Command
) ((UINT64
)(UINTN
) &Snp
->Cdb
);
63 switch (Snp
->Cdb
.StatCode
) {
64 case PXE_STATCODE_SUCCESS
:
67 case PXE_STATCODE_INVALID_CPB
:
68 return EFI_INVALID_PARAMETER
;
70 case PXE_STATCODE_UNSUPPORTED
:
73 "\nSnp->undi.mcast_ip_to_mac() %xh:%xh\n",
77 return EFI_UNSUPPORTED
;
81 // UNDI command failed. Return EFI_DEVICE_ERROR
86 "\nSnp->undi.mcast_ip_to_mac() %xh:%xh\n",
91 return EFI_DEVICE_ERROR
;
94 CopyMem (MAC
, &Db
->MAC
, sizeof (PXE_MAC_ADDR
));
100 Converts a multicast IP address to a multicast HW MAC address.
102 This function converts a multicast IP address to a multicast HW MAC address
103 for all packet transactions. If the mapping is accepted, then EFI_SUCCESS will
106 @param This A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL instance.
107 @param IPv6 Set to TRUE if the multicast IP address is IPv6 [RFC 2460].
108 Set to FALSE if the multicast IP address is IPv4 [RFC 791].
109 @param IP The multicast IP address that is to be converted to a multicast
111 @param MAC The multicast HW MAC address that is to be generated from IP.
113 @retval EFI_SUCCESS The multicast IP address was mapped to the
114 multicast HW MAC address.
115 @retval EFI_NOT_STARTED The Simple Network Protocol interface has not
116 been started by calling Start().
117 @retval EFI_INVALID_PARAMETER IP is NULL.
118 @retval EFI_INVALID_PARAMETER MAC is NULL.
119 @retval EFI_INVALID_PARAMETER IP does not point to a valid IPv4 or IPv6
121 @retval EFI_DEVICE_ERROR The Simple Network Protocol interface has not
122 been initialized by calling Initialize().
123 @retval EFI_UNSUPPORTED IPv6 is TRUE and the implementation does not
124 support IPv6 multicast to MAC address conversion.
129 SnpUndi32McastIpToMac (
130 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
132 IN EFI_IP_ADDRESS
*IP
,
133 OUT EFI_MAC_ADDRESS
*MAC
141 // Get pointer to SNP driver instance for *this.
144 return EFI_INVALID_PARAMETER
;
147 if (IP
== NULL
|| MAC
== NULL
) {
148 return EFI_INVALID_PARAMETER
;
151 Snp
= EFI_SIMPLE_NETWORK_DEV_FROM_THIS (This
);
153 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
155 switch (Snp
->Mode
.State
) {
156 case EfiSimpleNetworkInitialized
:
159 case EfiSimpleNetworkStopped
:
160 Status
= EFI_NOT_STARTED
;
164 Status
= EFI_DEVICE_ERROR
;
168 Status
= PxeIp2Mac (Snp
, IPv6
, IP
, MAC
);
171 gBS
->RestoreTPL (OldTpl
);