TianoCore EDK2 master
Loading...
Searching...
No Matches
Mcast_ip_to_mac.c
Go to the documentation of this file.
1
10#include "Snp.h"
11
29 IN SNP_DRIVER *Snp,
30 IN BOOLEAN IPv6,
33 )
34{
37
38 Cpb = Snp->Cpb;
39 Db = Snp->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);
44
45 Snp->Cdb.CPBaddr = (UINT64)(UINTN)Cpb;
46 Snp->Cdb.DBaddr = (UINT64)(UINTN)Db;
47
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;
52
53 CopyMem (&Cpb->IP, IP, sizeof (PXE_IP_ADDR));
54
55 //
56 // Issue UNDI command and check result.
57 //
58 DEBUG ((DEBUG_NET, "\nSnp->undi.mcast_ip_to_mac() "));
59
60 (*Snp->IssueUndi32Command)((UINT64)(UINTN)&Snp->Cdb);
61
62 switch (Snp->Cdb.StatCode) {
64 break;
65
66 case PXE_STATCODE_INVALID_CPB:
67 return EFI_INVALID_PARAMETER;
68
69 case PXE_STATCODE_UNSUPPORTED:
70 DEBUG (
71 (DEBUG_NET,
72 "\nSnp->undi.mcast_ip_to_mac() %xh:%xh\n",
73 Snp->Cdb.StatFlags,
74 Snp->Cdb.StatCode)
75 );
76 return EFI_UNSUPPORTED;
77
78 default:
79 //
80 // UNDI command failed. Return EFI_DEVICE_ERROR
81 // to caller.
82 //
83 DEBUG (
84 (DEBUG_NET,
85 "\nSnp->undi.mcast_ip_to_mac() %xh:%xh\n",
86 Snp->Cdb.StatFlags,
87 Snp->Cdb.StatCode)
88 );
89
90 return EFI_DEVICE_ERROR;
91 }
92
93 CopyMem (MAC, &Db->MAC, sizeof (PXE_MAC_ADDR));
94 return EFI_SUCCESS;
95}
96
126EFIAPI
129 IN BOOLEAN IPv6,
130 IN EFI_IP_ADDRESS *IP,
132 )
133{
134 SNP_DRIVER *Snp;
135 EFI_TPL OldTpl;
136 EFI_STATUS Status;
137
138 //
139 // Get pointer to SNP driver instance for *this.
140 //
141 if (This == NULL) {
142 return EFI_INVALID_PARAMETER;
143 }
144
145 if ((IP == NULL) || (MAC == NULL)) {
146 return EFI_INVALID_PARAMETER;
147 }
148
149 Snp = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (This);
150
151 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
152
153 switch (Snp->Mode.State) {
154 case EfiSimpleNetworkInitialized:
155 break;
156
157 case EfiSimpleNetworkStopped:
158 Status = EFI_NOT_STARTED;
159 goto ON_EXIT;
160
161 default:
162 Status = EFI_DEVICE_ERROR;
163 goto ON_EXIT;
164 }
165
166 Status = PxeIp2Mac (Snp, IPv6, IP, MAC);
167
168ON_EXIT:
169 gBS->RestoreTPL (OldTpl);
170
171 return Status;
172}
UINT64 UINTN
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
EFI_STATUS PxeIp2Mac(IN SNP_DRIVER *Snp, IN BOOLEAN IPv6, IN EFI_IP_ADDRESS *IP, IN OUT EFI_MAC_ADDRESS *MAC)
EFI_STATUS EFIAPI SnpUndi32McastIpToMac(IN EFI_SIMPLE_NETWORK_PROTOCOL *This, IN BOOLEAN IPv6, IN EFI_IP_ADDRESS *IP, OUT EFI_MAC_ADDRESS *MAC)
#define NULL
Definition: Base.h:319
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
#define DEBUG(Expression)
Definition: DebugLib.h:434
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
UINTN EFI_TPL
Definition: UefiBaseType.h:41
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_BOOT_SERVICES * gBS
#define PXE_OPCODE_MCAST_IP_TO_MAC
Definition: UefiPxe.h:145
#define PXE_STATCODE_SUCCESS
Definition: UefiPxe.h:602
Definition: Snp.h:55