2 Copyright (c) 2004 - 2007, Intel Corporation
3 All rights reserved. This program and the accompanying materials
4 are licensed and made available under the terms and conditions of the BSD License
5 which accompanies this distribution. The full text of the license may be found at
6 http://opensource.org/licenses/bsd-license.php
8 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
9 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 2000-Feb-17 M(f)J Genesis.
24 this routine calls undi to convert an multicast IP address to a MAC address
26 @param snp pointer to snp driver structure
27 @param IPv6 flag to indicate if this is an ipv6 address
28 @param IP multicast IP address
29 @param MAC pointer to hold the return MAC address
37 IN EFI_IP_ADDRESS
*IP
,
38 IN OUT EFI_MAC_ADDRESS
*MAC
41 PXE_CPB_MCAST_IP_TO_MAC
*cpb
;
42 PXE_DB_MCAST_IP_TO_MAC
*db
;
46 snp
->cdb
.OpCode
= PXE_OPCODE_MCAST_IP_TO_MAC
;
47 snp
->cdb
.OpFlags
= (UINT16
) (IPv6
? PXE_OPFLAGS_MCAST_IPV6_TO_MAC
: PXE_OPFLAGS_MCAST_IPV4_TO_MAC
);
48 snp
->cdb
.CPBsize
= sizeof (PXE_CPB_MCAST_IP_TO_MAC
);
49 snp
->cdb
.DBsize
= sizeof (PXE_DB_MCAST_IP_TO_MAC
);
51 snp
->cdb
.CPBaddr
= (UINT64
)(UINTN
) cpb
;
52 snp
->cdb
.DBaddr
= (UINT64
)(UINTN
) db
;
54 snp
->cdb
.StatCode
= PXE_STATCODE_INITIALIZE
;
55 snp
->cdb
.StatFlags
= PXE_STATFLAGS_INITIALIZE
;
56 snp
->cdb
.IFnum
= snp
->if_num
;
57 snp
->cdb
.Control
= PXE_CONTROL_LAST_CDB_IN_LIST
;
59 CopyMem (&cpb
->IP
, IP
, sizeof (PXE_IP_ADDR
));
62 // Issue UNDI command and check result.
64 DEBUG ((EFI_D_NET
, "\nsnp->undi.mcast_ip_to_mac() "));
66 (*snp
->issue_undi32_command
) ((UINT64
)(UINTN
) &snp
->cdb
);
68 switch (snp
->cdb
.StatCode
) {
69 case PXE_STATCODE_SUCCESS
:
72 case PXE_STATCODE_INVALID_CPB
:
73 return EFI_INVALID_PARAMETER
;
75 case PXE_STATCODE_UNSUPPORTED
:
78 "\nsnp->undi.mcast_ip_to_mac() %xh:%xh\n",
82 return EFI_UNSUPPORTED
;
86 // UNDI command failed. Return EFI_DEVICE_ERROR
91 "\nsnp->undi.mcast_ip_to_mac() %xh:%xh\n",
96 return EFI_DEVICE_ERROR
;
99 CopyMem (MAC
, &db
->MAC
, sizeof (PXE_MAC_ADDR
));
105 This is the SNP interface routine for converting a multicast IP address to
107 This routine basically retrieves snp structure, checks the SNP state and
108 calls the pxe_ip2mac routine to actually do the conversion
110 @param this context pointer
111 @param IPv6 flag to indicate if this is an ipv6 address
112 @param IP multicast IP address
113 @param MAC pointer to hold the return MAC address
119 snp_undi32_mcast_ip_to_mac (
120 IN EFI_SIMPLE_NETWORK_PROTOCOL
*this,
122 IN EFI_IP_ADDRESS
*IP
,
123 OUT EFI_MAC_ADDRESS
*MAC
131 // Get pointer to SNP driver instance for *this.
134 return EFI_INVALID_PARAMETER
;
137 if (IP
== NULL
|| MAC
== NULL
) {
138 return EFI_INVALID_PARAMETER
;
141 snp
= EFI_SIMPLE_NETWORK_DEV_FROM_THIS (this);
143 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
145 switch (snp
->mode
.State
) {
146 case EfiSimpleNetworkInitialized
:
149 case EfiSimpleNetworkStopped
:
150 Status
= EFI_NOT_STARTED
;
154 Status
= EFI_DEVICE_ERROR
;
158 Status
= pxe_ip2mac (snp
, IPv6
, IP
, MAC
);
161 gBS
->RestoreTPL (OldTpl
);