]> git.proxmox.com Git - mirror_edk2.git/blob - EdkModulePkg/Universal/Network/Snp32_64/Dxe/mcast_ip_to_mac.c
Partially make EdkModulePkg pass intel IPF compiler with /W4 /WX switched on.
[mirror_edk2.git] / EdkModulePkg / Universal / Network / Snp32_64 / Dxe / mcast_ip_to_mac.c
1 /*++
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
7
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.
10
11 Module name:
12 mcast_ip_to_mac.c
13
14 Abstract:
15
16 Revision history:
17 2000-Feb-17 M(f)J Genesis.
18 --*/
19
20
21 #include "Snp.h"
22
23 STATIC
24 EFI_STATUS
25 pxe_ip2mac (
26 IN SNP_DRIVER *snp,
27 IN BOOLEAN IPv6,
28 IN EFI_IP_ADDRESS *IP,
29 IN OUT EFI_MAC_ADDRESS *MAC
30 )
31 /*++
32
33 Routine Description:
34 this routine calls undi to convert an multicast IP address to a MAC address
35
36 Arguments:
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
41
42 Returns:
43
44 --*/
45 {
46 PXE_CPB_MCAST_IP_TO_MAC *cpb;
47 PXE_DB_MCAST_IP_TO_MAC *db;
48
49 cpb = snp->cpb;
50 db = snp->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);
55
56 snp->cdb.CPBaddr = (UINT64) (UINTN) cpb;
57 snp->cdb.DBaddr = (UINT64) (UINTN) db;
58
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;
63
64 CopyMem (&cpb->IP, IP, sizeof (PXE_IP_ADDR));
65
66 //
67 // Issue UNDI command and check result.
68 //
69 DEBUG ((EFI_D_NET, "\nsnp->undi.mcast_ip_to_mac() "));
70
71 (*snp->issue_undi32_command) ((UINT64) (UINTN) &snp->cdb);
72
73 switch (snp->cdb.StatCode) {
74 case PXE_STATCODE_SUCCESS:
75 break;
76
77 case PXE_STATCODE_INVALID_CPB:
78 return EFI_INVALID_PARAMETER;
79
80 case PXE_STATCODE_UNSUPPORTED:
81 DEBUG (
82 (EFI_D_NET,
83 "\nsnp->undi.mcast_ip_to_mac() %xh:%xh\n",
84 snp->cdb.StatFlags,
85 snp->cdb.StatCode)
86 );
87 return EFI_UNSUPPORTED;
88
89 default:
90 //
91 // UNDI command failed. Return EFI_DEVICE_ERROR
92 // to caller.
93 //
94 DEBUG (
95 (EFI_D_NET,
96 "\nsnp->undi.mcast_ip_to_mac() %xh:%xh\n",
97 snp->cdb.StatFlags,
98 snp->cdb.StatCode)
99 );
100
101 return EFI_DEVICE_ERROR;
102 }
103
104 CopyMem (MAC, &db->MAC, sizeof (PXE_MAC_ADDR));
105 return EFI_SUCCESS;
106 }
107
108 EFI_STATUS
109 EFIAPI
110 snp_undi32_mcast_ip_to_mac (
111 IN EFI_SIMPLE_NETWORK_PROTOCOL *this,
112 IN BOOLEAN IPv6,
113 IN EFI_IP_ADDRESS *IP,
114 OUT EFI_MAC_ADDRESS *MAC
115 )
116 /*++
117
118 Routine Description:
119 This is the SNP interface routine for converting a multicast IP address to
120 a MAC address.
121 This routine basically retrieves snp structure, checks the SNP state and
122 calls the pxe_ip2mac routine to actually do the conversion
123
124 Arguments:
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
129
130 Returns:
131
132 --*/
133 {
134 SNP_DRIVER *snp;
135
136 //
137 // Get pointer to SNP driver instance for *this.
138 //
139 if (this == NULL) {
140 return EFI_INVALID_PARAMETER;
141 }
142
143 snp = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (this);
144
145 if (snp == NULL) {
146 return EFI_DEVICE_ERROR;
147 }
148
149 switch (snp->mode.State) {
150 case EfiSimpleNetworkInitialized:
151 break;
152
153 case EfiSimpleNetworkStopped:
154 return EFI_NOT_STARTED;
155
156 case EfiSimpleNetworkStarted:
157 return EFI_DEVICE_ERROR;
158
159 default:
160 return EFI_DEVICE_ERROR;
161 }
162
163 if (IP == NULL || MAC == NULL) {
164 return EFI_INVALID_PARAMETER;
165 }
166
167 return pxe_ip2mac (snp, IPv6, IP, MAC);
168 }