]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.h
Add VLAN support.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / IScsiDxe / IScsiMisc.h
1 /** @file
2 Miscellaneous definitions for iSCSI driver.
3
4 Copyright (c) 2004 - 2009, Intel Corporation.<BR>
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #ifndef _ISCSI_MISC_H_
16 #define _ISCSI_MISC_H_
17
18 #include <Library/BaseLib.h>
19
20 typedef struct _ISCSI_SESSION_CONFIG_DATA ISCSI_SESSION_CONFIG_DATA;
21
22 #pragma pack(1)
23 typedef struct {
24 BOOLEAN Enabled;
25
26 BOOLEAN InitiatorInfoFromDhcp;
27 EFI_IPv4_ADDRESS LocalIp;
28 EFI_IPv4_ADDRESS SubnetMask;
29 EFI_IPv4_ADDRESS Gateway;
30
31 BOOLEAN TargetInfoFromDhcp;
32 CHAR8 TargetName[ISCSI_NAME_MAX_SIZE];
33 EFI_IPv4_ADDRESS TargetIp;
34 UINT16 TargetPort;
35 UINT8 BootLun[8];
36 } ISCSI_SESSION_CONFIG_NVDATA;
37 #pragma pack()
38
39 struct _ISCSI_SESSION_CONFIG_DATA {
40 ISCSI_SESSION_CONFIG_NVDATA NvData;
41
42 EFI_IPv4_ADDRESS PrimaryDns;
43 EFI_IPv4_ADDRESS SecondaryDns;
44 EFI_IPv4_ADDRESS DhcpServer;
45 };
46
47 /**
48 Calculate the prefix length of the IPv4 subnet mask.
49
50 @param[in] SubnetMask The IPv4 subnet mask.
51
52 @return The prefix length of the subnet mask.
53 @retval 0 Other errors as indicated.
54 **/
55 UINT8
56 IScsiGetSubnetMaskPrefixLength (
57 IN EFI_IPv4_ADDRESS *SubnetMask
58 );
59
60 /**
61 Convert the hexadecimal encoded LUN string into the 64-bit LUN.
62
63 @param[in] Str The hexadecimal encoded LUN string.
64 @param[out] Lun Storage to return the 64-bit LUN.
65
66 @retval EFI_SUCCESS The 64-bit LUN is stored in Lun.
67 @retval EFI_INVALID_PARAMETER The string is malformatted.
68 **/
69 EFI_STATUS
70 IScsiAsciiStrToLun (
71 IN CHAR8 *Str,
72 OUT UINT8 *Lun
73 );
74
75 /**
76 Convert the 64-bit LUN into the hexadecimal encoded LUN string.
77
78 @param[in] Lun The 64-bit LUN.
79 @param[out] Str The storage to return the hexadecimal encoded LUN string.
80 **/
81 VOID
82 IScsiLunToUnicodeStr (
83 IN UINT8 *Lun,
84 OUT CHAR16 *Str
85 );
86
87 /**
88 Convert the ASCII string into a UNICODE string.
89
90 @param[in] Source The ASCII string.
91 @param[out] Destination The storage to return the UNICODE string.
92
93 @return CHAR16 * Pointer to the UNICODE string.
94 **/
95 CHAR16 *
96 IScsiAsciiStrToUnicodeStr (
97 IN CHAR8 *Source,
98 OUT CHAR16 *Destination
99 );
100
101 /**
102 Convert the UNICODE string into an ASCII string.
103
104 @param[in] Source The UNICODE string.
105 @param[out] Destination The storage to return the ASCII string.
106
107 @return CHAR8 * Pointer to the ASCII string.
108 **/
109 CHAR8 *
110 IScsiUnicodeStrToAsciiStr (
111 IN CHAR16 *Source,
112 OUT CHAR8 *Destination
113 );
114
115 /**
116 Convert the mac address into a hexadecimal encoded "-" seperated string.
117
118 @param[in] Mac The mac address.
119 @param[in] Len Length in bytes of the mac address.
120 @param[in] VlanId VLAN ID of the network device.
121 @param[out] Str The storage to return the mac string.
122 **/
123 VOID
124 IScsiMacAddrToStr (
125 IN EFI_MAC_ADDRESS *Mac,
126 IN UINT32 Len,
127 IN UINT16 VlanId,
128 OUT CHAR16 *Str
129 );
130
131 /**
132 Convert the decimal dotted IPv4 address into the binary IPv4 address.
133
134 @param[in] Str The UNICODE string.
135 @param[out] Ip The storage to return the ASCII string.
136
137 @retval EFI_SUCCESS The binary IP address is returned in Ip.
138 @retval EFI_INVALID_PARAMETER The IP string is malformatted.
139 **/
140 EFI_STATUS
141 IScsiAsciiStrToIp (
142 IN CHAR8 *Str,
143 OUT EFI_IPv4_ADDRESS *Ip
144 );
145
146 /**
147 Convert the binary encoded buffer into a hexadecimal encoded string.
148
149 @param[in] BinBuffer The buffer containing the binary data.
150 @param[in] BinLength Length of the binary buffer.
151 @param[in, out] HexStr Pointer to the string.
152 @param[in, out] HexLength The length of the string.
153
154 @retval EFI_SUCCESS The binary data is converted to the hexadecimal string
155 and the length of the string is updated.
156 @retval EFI_BUFFER_TOO_SMALL The string is too small.
157 @retval EFI_INVALID_PARAMETER The IP string is malformatted.
158 **/
159 EFI_STATUS
160 IScsiBinToHex (
161 IN UINT8 *BinBuffer,
162 IN UINT32 BinLength,
163 IN OUT CHAR8 *HexStr,
164 IN OUT UINT32 *HexLength
165 );
166
167 /**
168 Convert the hexadecimal string into a binary encoded buffer.
169
170 @param[in, out] BinBuffer The binary buffer.
171 @param[in, out] BinLength Length of the binary buffer.
172 @param[in] HexStr The hexadecimal string.
173
174 @retval EFI_SUCCESS The hexadecimal string is converted into a binary
175 encoded buffer.
176 @retval EFI_BUFFER_TOO_SMALL The binary buffer is too small to hold the converted data.
177 **/
178 EFI_STATUS
179 IScsiHexToBin (
180 IN OUT UINT8 *BinBuffer,
181 IN OUT UINT32 *BinLength,
182 IN CHAR8 *HexStr
183 );
184
185 /**
186 Generate random numbers.
187
188 @param[in, out] Rand The buffer to contain random numbers.
189 @param[in] RandLength The length of the Rand buffer.
190 **/
191 VOID
192 IScsiGenRandom (
193 IN OUT UINT8 *Rand,
194 IN UINTN RandLength
195 );
196
197 /**
198 Create the iSCSI driver data..
199
200 @param[in] Image The handle of the driver image.
201 @param[in] Controller The handle of the controller.
202
203 @return The iSCSI driver data created.
204 @retval NULL Other errors as indicated.
205 **/
206 ISCSI_DRIVER_DATA *
207 IScsiCreateDriverData (
208 IN EFI_HANDLE Image,
209 IN EFI_HANDLE Controller
210 );
211
212 /**
213 Clean the iSCSI driver data.
214
215 @param[in] Private The iSCSI driver data.
216 **/
217 VOID
218 IScsiCleanDriverData (
219 IN ISCSI_DRIVER_DATA *Private
220 );
221
222 /**
223 Get the various configuration data of this iSCSI instance.
224
225 @param[in] Private The iSCSI driver data.
226
227 @retval EFI_SUCCESS The configuration of this instance is got.
228 @retval EFI_ABORTED The operation was aborted.
229 @retval Others Other errors as indicated.
230 **/
231 EFI_STATUS
232 IScsiGetConfigData (
233 IN ISCSI_DRIVER_DATA *Private
234 );
235
236 /**
237 Get the device path of the iSCSI tcp connection and update it.
238
239 @param[in] Private The iSCSI driver data.
240
241 @return The updated device path.
242 @retval NULL Other errors as indicated.
243 **/
244 EFI_DEVICE_PATH_PROTOCOL *
245 IScsiGetTcpConnDevicePath (
246 IN ISCSI_DRIVER_DATA *Private
247 );
248
249 /**
250 Abort the session when the transition from BS to RT is initiated.
251
252 @param[in] Event The event signaled.
253 @param[in] Context The iSCSI driver data.
254 **/
255 VOID
256 EFIAPI
257 IScsiOnExitBootService (
258 IN EFI_EVENT Event,
259 IN VOID *Context
260 );
261
262
263
264 #endif