2 Copyright (c) 2006, 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.
28 IN EFI_IP_ADDRESS
*IP
,
29 IN OUT EFI_MAC_ADDRESS
*MAC
34 this routine calls undi to convert an multicast IP address to a MAC address
37 snp - pointer to snp driver structure
38 IPv6 - flag to indicate if this is an ipv6 address
39 IP - multicast IP address
40 MAC - pointer to hold the return MAC address
46 PXE_CPB_MCAST_IP_TO_MAC
*cpb
;
47 PXE_DB_MCAST_IP_TO_MAC
*db
;
51 snp
->cdb
.OpCode
= PXE_OPCODE_MCAST_IP_TO_MAC
;
52 snp
->cdb
.OpFlags
= (UINT16
) (IPv6
? PXE_OPFLAGS_MCAST_IPV6_TO_MAC
: PXE_OPFLAGS_MCAST_IPV4_TO_MAC
);
53 snp
->cdb
.CPBsize
= sizeof (PXE_CPB_MCAST_IP_TO_MAC
);
54 snp
->cdb
.DBsize
= sizeof (PXE_DB_MCAST_IP_TO_MAC
);
56 snp
->cdb
.CPBaddr
= (UINT64
) (UINTN
) cpb
;
57 snp
->cdb
.DBaddr
= (UINT64
) (UINTN
) db
;
59 snp
->cdb
.StatCode
= PXE_STATCODE_INITIALIZE
;
60 snp
->cdb
.StatFlags
= PXE_STATFLAGS_INITIALIZE
;
61 snp
->cdb
.IFnum
= snp
->if_num
;
62 snp
->cdb
.Control
= PXE_CONTROL_LAST_CDB_IN_LIST
;
64 CopyMem (&cpb
->IP
, IP
, sizeof (PXE_IP_ADDR
));
67 // Issue UNDI command and check result.
69 DEBUG ((EFI_D_NET
, "\nsnp->undi.mcast_ip_to_mac() "));
71 (*snp
->issue_undi32_command
) ((UINT64
) (UINTN
) &snp
->cdb
);
73 switch (snp
->cdb
.StatCode
) {
74 case PXE_STATCODE_SUCCESS
:
77 case PXE_STATCODE_INVALID_CPB
:
78 return EFI_INVALID_PARAMETER
;
80 case PXE_STATCODE_UNSUPPORTED
:
83 "\nsnp->undi.mcast_ip_to_mac() %xh:%xh\n",
87 return EFI_UNSUPPORTED
;
91 // UNDI command failed. Return EFI_DEVICE_ERROR
96 "\nsnp->undi.mcast_ip_to_mac() %xh:%xh\n",
101 return EFI_DEVICE_ERROR
;
104 CopyMem (MAC
, &db
->MAC
, sizeof (PXE_MAC_ADDR
));
110 snp_undi32_mcast_ip_to_mac (
111 IN EFI_SIMPLE_NETWORK_PROTOCOL
*this,
113 IN EFI_IP_ADDRESS
*IP
,
114 OUT EFI_MAC_ADDRESS
*MAC
119 This is the SNP interface routine for converting a multicast IP address to
121 This routine basically retrieves snp structure, checks the SNP state and
122 calls the pxe_ip2mac routine to actually do the conversion
125 this - context pointer
126 IPv6 - flag to indicate if this is an ipv6 address
127 IP - multicast IP address
128 MAC - pointer to hold the return MAC address
137 // Get pointer to SNP driver instance for *this.
140 return EFI_INVALID_PARAMETER
;
143 snp
= EFI_SIMPLE_NETWORK_DEV_FROM_THIS (this);
146 return EFI_DEVICE_ERROR
;
149 switch (snp
->mode
.State
) {
150 case EfiSimpleNetworkInitialized
:
153 case EfiSimpleNetworkStopped
:
154 return EFI_NOT_STARTED
;
156 case EfiSimpleNetworkStarted
:
157 return EFI_DEVICE_ERROR
;
160 return EFI_DEVICE_ERROR
;
163 if (IP
== NULL
|| MAC
== NULL
) {
164 return EFI_INVALID_PARAMETER
;
167 return pxe_ip2mac (snp
, IPv6
, IP
, MAC
);