TianoCore EDK2
master
Loading...
Searching...
No Matches
SnpMcastIpToMac.c
Go to the documentation of this file.
1
13
#include <
Library/UefiBootServicesTableLib.h
>
14
15
#include "
VirtioNet.h
"
16
41
EFI_STATUS
42
EFIAPI
43
VirtioNetMcastIpToMac
(
44
IN
EFI_SIMPLE_NETWORK_PROTOCOL
*This,
45
IN
BOOLEAN IPv6,
46
IN
EFI_IP_ADDRESS
*Ip,
47
OUT
EFI_MAC_ADDRESS
*Mac
48
)
49
{
50
VNET_DEV
*Dev;
51
EFI_TPL
OldTpl;
52
EFI_STATUS
Status;
53
54
//
55
// http://en.wikipedia.org/wiki/Multicast_address
56
//
57
if
((This ==
NULL
) || (Ip ==
NULL
) || (Mac ==
NULL
) ||
58
(IPv6 && ((Ip->v6.Addr[0]) != 0xFF)) ||
// invalid IPv6 mcast addr
59
(!IPv6 && ((Ip->v4.Addr[0] & 0xF0) != 0xE0))
// invalid IPv4 mcast addr
60
)
61
{
62
return
EFI_INVALID_PARAMETER;
63
}
64
65
Dev = VIRTIO_NET_FROM_SNP (This);
66
OldTpl =
gBS
->RaiseTPL (TPL_CALLBACK);
67
switch
(Dev->Snm.
State
) {
68
case
EfiSimpleNetworkStopped:
69
Status = EFI_NOT_STARTED;
70
goto
Exit
;
71
case
EfiSimpleNetworkStarted:
72
Status = EFI_DEVICE_ERROR;
73
goto
Exit
;
74
default
:
75
break
;
76
}
77
78
//
79
// http://en.wikipedia.org/wiki/IP_multicast#Layer_2_delivery
80
//
81
if
(IPv6) {
82
Mac->Addr[0] = 0x33;
83
Mac->Addr[1] = 0x33;
84
Mac->Addr[2] = Ip->v6.Addr[12];
85
Mac->Addr[3] = Ip->v6.Addr[13];
86
Mac->Addr[4] = Ip->v6.Addr[14];
87
Mac->Addr[5] = Ip->v6.Addr[15];
88
}
else
{
89
Mac->Addr[0] = 0x01;
90
Mac->Addr[1] = 0x00;
91
Mac->Addr[2] = 0x5E;
92
Mac->Addr[3] = Ip->v4.Addr[1] & 0x7F;
93
Mac->Addr[4] = Ip->v4.Addr[2];
94
Mac->Addr[5] = Ip->v4.Addr[3];
95
}
96
97
Status =
EFI_SUCCESS
;
98
99
Exit
:
100
gBS
->RestoreTPL (OldTpl);
101
return
Status;
102
}
NULL
#define NULL
Definition:
Base.h:319
IN
#define IN
Definition:
Base.h:279
OUT
#define OUT
Definition:
Base.h:284
VirtioNetMcastIpToMac
EFI_STATUS EFIAPI VirtioNetMcastIpToMac(IN EFI_SIMPLE_NETWORK_PROTOCOL *This, IN BOOLEAN IPv6, IN EFI_IP_ADDRESS *Ip, OUT EFI_MAC_ADDRESS *Mac)
Definition:
SnpMcastIpToMac.c:43
Exit
VOID EFIAPI Exit(IN EFI_STATUS Status)
Definition:
ApplicationEntryPoint.c:83
EFI_STATUS
RETURN_STATUS EFI_STATUS
Definition:
UefiBaseType.h:29
EFI_TPL
UINTN EFI_TPL
Definition:
UefiBaseType.h:41
EFI_SUCCESS
#define EFI_SUCCESS
Definition:
UefiBaseType.h:112
UefiBootServicesTableLib.h
gBS
EFI_BOOT_SERVICES * gBS
Definition:
UefiBootServicesTableLib.c:17
VirtioNet.h
_EFI_SIMPLE_NETWORK_PROTOCOL
Definition:
SimpleNetwork.h:643
EFI_MAC_ADDRESS
Definition:
UefiBaseType.h:95
EFI_SIMPLE_NETWORK_MODE::State
UINT32 State
Definition:
SimpleNetwork.h:166
VNET_DEV
Definition:
VirtioNet.h:64
EFI_IP_ADDRESS
Definition:
UefiBaseType.h:103
OvmfPkg
VirtioNetDxe
SnpMcastIpToMac.c
Generated on Fri Nov 15 2024 18:01:22 for TianoCore EDK2 by
1.9.6