]> git.proxmox.com Git - mirror_edk2.git/blob - EdkModulePkg/Universal/Network/Snp32_64/Dxe/mcast_ip_to_mac.c
Fix capitalization
[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 EFI_STATUS
24 pxe_ip2mac (
25 IN SNP_DRIVER *snp,
26 IN BOOLEAN IPv6,
27 IN EFI_IP_ADDRESS *IP,
28 IN OUT EFI_MAC_ADDRESS *MAC
29 )
30 /*++
31
32 Routine Description:
33 this routine calls undi to convert an multicast IP address to a MAC address
34
35 Arguments:
36 snp - pointer to snp driver structure
37 IPv6 - flag to indicate if this is an ipv6 address
38 IP - multicast IP address
39 MAC - pointer to hold the return MAC address
40
41 Returns:
42
43 --*/
44 {
45 PXE_CPB_MCAST_IP_TO_MAC *cpb;
46 PXE_DB_MCAST_IP_TO_MAC *db;
47
48 cpb = snp->cpb;
49 db = snp->db;
50 snp->cdb.OpCode = PXE_OPCODE_MCAST_IP_TO_MAC;
51 snp->cdb.OpFlags = (UINT16) (IPv6 ? PXE_OPFLAGS_MCAST_IPV6_TO_MAC : PXE_OPFLAGS_MCAST_IPV4_TO_MAC);
52 snp->cdb.CPBsize = sizeof (PXE_CPB_MCAST_IP_TO_MAC);
53 snp->cdb.DBsize = sizeof (PXE_DB_MCAST_IP_TO_MAC);
54
55 snp->cdb.CPBaddr = (UINT64) (UINTN) cpb;
56 snp->cdb.DBaddr = (UINT64) (UINTN) db;
57
58 snp->cdb.StatCode = PXE_STATCODE_INITIALIZE;
59 snp->cdb.StatFlags = PXE_STATFLAGS_INITIALIZE;
60 snp->cdb.IFnum = snp->if_num;
61 snp->cdb.Control = PXE_CONTROL_LAST_CDB_IN_LIST;
62
63 CopyMem (&cpb->IP, IP, sizeof (PXE_IP_ADDR));
64
65 //
66 // Issue UNDI command and check result.
67 //
68 DEBUG ((EFI_D_NET, "\nsnp->undi.mcast_ip_to_mac() "));
69
70 (*snp->issue_undi32_command) ((UINT64) (UINTN) &snp->cdb);
71
72 switch (snp->cdb.StatCode) {
73 case PXE_STATCODE_SUCCESS:
74 break;
75
76 case PXE_STATCODE_INVALID_CPB:
77 return EFI_INVALID_PARAMETER;
78
79 case PXE_STATCODE_UNSUPPORTED:
80 DEBUG (
81 (EFI_D_NET,
82 "\nsnp->undi.mcast_ip_to_mac() %xh:%xh\n",
83 snp->cdb.StatFlags,
84 snp->cdb.StatCode)
85 );
86 return EFI_UNSUPPORTED;
87
88 default:
89 //
90 // UNDI command failed. Return EFI_DEVICE_ERROR
91 // to caller.
92 //
93 DEBUG (
94 (EFI_D_NET,
95 "\nsnp->undi.mcast_ip_to_mac() %xh:%xh\n",
96 snp->cdb.StatFlags,
97 snp->cdb.StatCode)
98 );
99
100 return EFI_DEVICE_ERROR;
101 }
102
103 CopyMem (MAC, &db->MAC, sizeof (PXE_MAC_ADDR));
104 return EFI_SUCCESS;
105 }
106
107 EFI_STATUS
108 EFIAPI
109 snp_undi32_mcast_ip_to_mac (
110 IN EFI_SIMPLE_NETWORK_PROTOCOL *this,
111 IN BOOLEAN IPv6,
112 IN EFI_IP_ADDRESS *IP,
113 OUT EFI_MAC_ADDRESS *MAC
114 )
115 /*++
116
117 Routine Description:
118 This is the SNP interface routine for converting a multicast IP address to
119 a MAC address.
120 This routine basically retrieves snp structure, checks the SNP state and
121 calls the pxe_ip2mac routine to actually do the conversion
122
123 Arguments:
124 this - context pointer
125 IPv6 - flag to indicate if this is an ipv6 address
126 IP - multicast IP address
127 MAC - pointer to hold the return MAC address
128
129 Returns:
130
131 --*/
132 {
133 SNP_DRIVER *snp;
134
135 //
136 // Get pointer to SNP driver instance for *this.
137 //
138 if (this == NULL) {
139 return EFI_INVALID_PARAMETER;
140 }
141
142 snp = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (this);
143
144 if (snp == NULL) {
145 return EFI_DEVICE_ERROR;
146 }
147
148 switch (snp->mode.State) {
149 case EfiSimpleNetworkInitialized:
150 break;
151
152 case EfiSimpleNetworkStopped:
153 return EFI_NOT_STARTED;
154
155 case EfiSimpleNetworkStarted:
156 return EFI_DEVICE_ERROR;
157
158 default:
159 return EFI_DEVICE_ERROR;
160 }
161
162 if (IP == NULL || MAC == NULL) {
163 return EFI_INVALID_PARAMETER;
164 }
165
166 return pxe_ip2mac (snp, IPv6, IP, MAC);
167 }