]> git.proxmox.com Git - mirror_edk2.git/blob - NetworkPkg/UefiPxeBcDxe/PxeBcSupport.h
Add NetworkPkg (P.UDK2010.UP3.Network.P1)
[mirror_edk2.git] / NetworkPkg / UefiPxeBcDxe / PxeBcSupport.h
1 /** @file
2 Support functions declaration for UefiPxeBc Driver.
3
4 Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
5
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php.
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15
16 #ifndef __EFI_PXEBC_SUPPORT_H__
17 #define __EFI_PXEBC_SUPPORT_H__
18
19
20 #define ICMP_DEST_UNREACHABLE 3
21 #define ICMP_SOURCE_QUENCH 4
22 #define ICMP_REDIRECT 5
23 #define ICMP_ECHO_REQUEST 8
24 #define ICMP_TIME_EXCEEDED 11
25 #define ICMP_PARAMETER_PROBLEM 12
26
27
28 /**
29 This function obtain the system guid and serial number from the smbios table.
30
31 @param[out] SystemGuid The pointer of returned system guid.
32
33 @retval EFI_SUCCESS Successfully obtained the system guid.
34 @retval EFI_NOT_FOUND Did not find the SMBIOS table.
35
36 **/
37 EFI_STATUS
38 PxeBcGetSystemGuid (
39 OUT EFI_GUID *SystemGuid
40 );
41
42
43 /**
44 Flush the previous configration using the new station Ip address.
45
46 @param[in] Private Pointer to PxeBc private data.
47 @param[in] StationIp Pointer to the station Ip address.
48 @param[in] SubnetMask Pointer to the subnet mask address for v4.
49
50 @retval EFI_SUCCESS Successfully flushed the previous config.
51 @retval Others Failed to flush using the new station Ip.
52
53 **/
54 EFI_STATUS
55 PxeBcFlushStaionIp (
56 PXEBC_PRIVATE_DATA *Private,
57 EFI_IP_ADDRESS *StationIp,
58 EFI_IP_ADDRESS *SubnetMask OPTIONAL
59 );
60
61
62 /**
63 Notify callback function when an event is triggered.
64
65 @param[in] Event The triggered event.
66 @param[in] Context The opaque parameter to the function.
67
68 **/
69 VOID
70 EFIAPI
71 PxeBcCommonNotify (
72 IN EFI_EVENT Event,
73 IN VOID *Context
74 );
75
76
77 /**
78 Perform arp resolution from the arp cache in PxeBcMode.
79
80 @param Mode Pointer to EFI_PXE_BASE_CODE_MODE.
81 @param Ip4Addr The Ip4 address for resolution.
82 @param MacAddress The resoluted MAC address if the resolution is successful.
83 The value is undefined if resolution fails.
84
85 @retval TRUE Found a matched entry.
86 @retval FALSE Did not find a matched entry.
87
88 **/
89 BOOLEAN
90 PxeBcCheckArpCache (
91 IN EFI_PXE_BASE_CODE_MODE *Mode,
92 IN EFI_IPv4_ADDRESS *Ip4Addr,
93 OUT EFI_MAC_ADDRESS *MacAddress
94 );
95
96
97 /**
98 Update arp cache periodically.
99
100 @param Event Pointer to EFI_PXE_BC_PROTOCOL.
101 @param Context Context of the timer event.
102
103 **/
104 VOID
105 EFIAPI
106 PxeBcArpCacheUpdate (
107 IN EFI_EVENT Event,
108 IN VOID *Context
109 );
110
111
112 /**
113 xxx
114
115 @param Event The event signaled.
116 @param Context The context passed in by the event notifier.
117
118 **/
119 VOID
120 EFIAPI
121 PxeBcIcmpErrorUpdate (
122 IN EFI_EVENT Event,
123 IN VOID *Context
124 );
125
126
127 /**
128 xxx
129
130 @param Event The event signaled.
131 @param Context The context passed in by the event notifier.
132
133 **/
134 VOID
135 EFIAPI
136 PxeBcIcmp6ErrorUpdate (
137 IN EFI_EVENT Event,
138 IN VOID *Context
139 );
140
141
142 /**
143 This function is to configure a UDPv4 instance for UdpWrite.
144
145 @param[in] Udp4 Pointer to EFI_UDP4_PROTOCOL.
146 @param[in] StationIp Pointer to the station address.
147 @param[in] SubnetMask Pointer to the subnet mask.
148 @param[in] Gateway Pointer to the gateway address.
149 @param[in, out] SrcPort Pointer to the source port.
150 @param[in] DoNotFragment The flag of DoNotFragment bit in the IPv4
151 packet.
152
153 @retval EFI_SUCCESS Successfully configured this instance.
154 @retval Others Failed to configure this instance.
155
156 **/
157 EFI_STATUS
158 PxeBcConfigUdp4Write (
159 IN EFI_UDP4_PROTOCOL *Udp4,
160 IN EFI_IPv4_ADDRESS *StationIp,
161 IN EFI_IPv4_ADDRESS *SubnetMask,
162 IN EFI_IPv4_ADDRESS *Gateway,
163 IN OUT UINT16 *SrcPort,
164 IN BOOLEAN DoNotFragment
165 );
166
167
168 /**
169 This function is to configure a UDPv6 instance for UdpWrite.
170
171 @param[in] Udp6 Pointer to EFI_UDP6_PROTOCOL.
172 @param[in] StationIp Pointer to the station address.
173 @param[in, out] SrcPort Pointer to the source port.
174
175 @retval EFI_SUCCESS Successfuly configured this instance.
176 @retval Others Failed to configure this instance.
177
178 **/
179 EFI_STATUS
180 PxeBcConfigUdp6Write (
181 IN EFI_UDP6_PROTOCOL *Udp6,
182 IN EFI_IPv6_ADDRESS *StationIp,
183 IN OUT UINT16 *SrcPort
184 );
185
186 /**
187 This function is to configure a UDPv4 instance for UdpWrite.
188
189 @param[in] Udp4 Pointer to EFI_UDP4_PROTOCOL.
190 @param[in] Session Pointer to the UDP4 session data.
191 @param[in] TimeoutEvent The event for timeout.
192 @param[in] Gateway Pointer to the gateway address.
193 @param[in] HeaderSize An optional field which may be set to the length of a header
194 at HeaderPtr to be prefixed to the data at BufferPtr.
195 @param[in] HeaderPtr If HeaderSize is not NULL, a pointer to a header to be
196 prefixed to the data at BufferPtr.
197 @param[in] BufferSize A pointer to the size of the data at BufferPtr.
198 @param[in] BufferPtr A pointer to the data to be written.
199
200 @retval EFI_SUCCESS Successfully sent out data with Udp4Write.
201 @retval Others Failed to send out data.
202
203 **/
204 EFI_STATUS
205 PxeBcUdp4Write (
206 IN EFI_UDP4_PROTOCOL *Udp4,
207 IN EFI_UDP4_SESSION_DATA *Session,
208 IN EFI_EVENT TimeoutEvent,
209 IN EFI_IPv4_ADDRESS *Gateway OPTIONAL,
210 IN UINTN *HeaderSize OPTIONAL,
211 IN VOID *HeaderPtr OPTIONAL,
212 IN UINTN *BufferSize,
213 IN VOID *BufferPtr
214 );
215
216
217 /**
218 This function is to configure a UDPv6 instance for UdpWrite.
219
220 @param[in] Udp6 Pointer to EFI_UDP6_PROTOCOL.
221 @param[in] Session Pointer to the UDP6 session data.
222 @param[in] TimeoutEvent The event for timeout.
223 @param[in] HeaderSize An optional field which may be set to the length of a header
224 at HeaderPtr to be prefixed to the data at BufferPtr.
225 @param[in] HeaderPtr If HeaderSize is not NULL, a pointer to a header to be
226 prefixed to the data at BufferPtr.
227 @param[in] BufferSize A pointer to the size of the data at BufferPtr.
228 @param[in] BufferPtr A pointer to the data to be written.
229
230 @retval EFI_SUCCESS Successfully to send out data with Udp6Write.
231 @retval Others Failed to send out data.
232
233 **/
234 EFI_STATUS
235 PxeBcUdp6Write (
236 IN EFI_UDP6_PROTOCOL *Udp6,
237 IN EFI_UDP6_SESSION_DATA *Session,
238 IN EFI_EVENT TimeoutEvent,
239 IN UINTN *HeaderSize OPTIONAL,
240 IN VOID *HeaderPtr OPTIONAL,
241 IN UINTN *BufferSize,
242 IN VOID *BufferPtr
243 );
244
245
246 /**
247 Check the received packet with the Ip filter.
248
249 @param[in] Mode Pointer to mode data of PxeBc.
250 @param[in] Session Pointer to the current UDPv4 session.
251 @param[in] OpFlags Operation flag for UdpRead/UdpWrite.
252
253 @retval TRUE Succesfully passed the Ip filter.
254 @retval FALSE Failed to pass the Ip filter.
255
256 **/
257 BOOLEAN
258 PxeBcCheckByIpFilter (
259 IN EFI_PXE_BASE_CODE_MODE *Mode,
260 IN VOID *Session,
261 IN UINT16 OpFlags
262 );
263
264
265 /**
266 Filter the received packet with the destination Ip.
267
268 @param[in] Mode Pointer to mode data of PxeBc.
269 @param[in] Session Pointer to the current UDPv4 session.
270 @param[in, out] DestIp Pointer to the dest Ip address.
271 @param[in] OpFlags Operation flag for UdpRead/UdpWrite.
272
273 @retval TRUE Succesfully passed the IPv4 filter.
274 @retval FALSE Failed to pass the IPv4 filter.
275
276 **/
277 BOOLEAN
278 PxeBcCheckByDestIp (
279 IN EFI_PXE_BASE_CODE_MODE *Mode,
280 IN VOID *Session,
281 IN OUT EFI_IP_ADDRESS *DestIp,
282 IN UINT16 OpFlags
283 );
284
285
286 /**
287 Check the received packet with the destination port.
288
289 @param[in] PxeBcMode Pointer to mode data of PxeBc.
290 @param[in] Session Pointer to the current UDPv4 session.
291 @param[in, out] DestPort Pointer to the destination port.
292 @param[in] OpFlags Operation flag for UdpRead/UdpWrite.
293
294 @retval TRUE Succesfully passed the IPv4 filter.
295 @retval FALSE Failed to pass the IPv4 filter.
296
297 **/
298 BOOLEAN
299 PxeBcCheckByDestPort (
300 IN EFI_PXE_BASE_CODE_MODE *Mode,
301 IN VOID *Session,
302 IN OUT UINT16 *DestPort,
303 IN UINT16 OpFlags
304 );
305
306
307 /**
308 Filter the received packet with the source Ip.
309
310 @param[in] Mode Pointer to mode data of PxeBc.
311 @param[in] Session Pointer to the current UDPv4 session.
312 @param[in, out] SrcIp Pointer to the source Ip address.
313 @param[in] OpFlags Operation flag for UdpRead/UdpWrite.
314
315 @retval TRUE Succesfully passed the IPv4 filter.
316 @retval FALSE Failed to pass the IPv4 filter.
317
318 **/
319 BOOLEAN
320 PxeBcFilterBySrcIp (
321 IN EFI_PXE_BASE_CODE_MODE *Mode,
322 IN VOID *Session,
323 IN OUT EFI_IP_ADDRESS *SrcIp,
324 IN UINT16 OpFlags
325 );
326
327
328 /**
329 Filter the received packet with the source port.
330
331 @param[in] Mode Pointer to mode data of PxeBc.
332 @param[in] Session Pointer to the current UDPv4 session.
333 @param[in, out] SrcPort Pointer to the source port.
334 @param[in] OpFlags Operation flag for UdpRead/UdpWrite.
335
336 @retval TRUE Succesfully passed the IPv4 filter.
337 @retval FALSE Failed to pass the IPv4 filter.
338
339 **/
340 BOOLEAN
341 PxeBcFilterBySrcPort (
342 IN EFI_PXE_BASE_CODE_MODE *Mode,
343 IN VOID *Session,
344 IN OUT UINT16 *SrcPort,
345 IN UINT16 OpFlags
346 );
347
348
349 /**
350 This function is to receive packet with Udp4Read.
351
352 @param[in] Udp4 Pointer to EFI_UDP4_PROTOCOL.
353 @param[in] Token Pointer to EFI_UDP4_COMPLETION_TOKEN.
354 @param[in] Mode Pointer to EFI_PXE_BASE_CODE_MODE.
355 @param[in] TimeoutEvent The event for timeout.
356 @param[in] OpFlags The UDP operation flags.
357 @param[in] IsDone Pointer to IsDone flag.
358 @param[out] IsMatched Pointer to IsMatched flag.
359 @param[in, out] DestIp Pointer to destination address.
360 @param[in, out] DestPort Pointer to destination port.
361 @param[in, out] SrcIp Pointer to source address.
362 @param[in, out] SrcPort Pointer to source port.
363
364 @retval EFI_SUCCESS Successfully read data with Udp4.
365 @retval Others Failed to send out data.
366
367 **/
368 EFI_STATUS
369 PxeBcUdp4Read (
370 IN EFI_UDP4_PROTOCOL *Udp4,
371 IN EFI_UDP4_COMPLETION_TOKEN *Token,
372 IN EFI_PXE_BASE_CODE_MODE *Mode,
373 IN EFI_EVENT TimeoutEvent,
374 IN UINT16 OpFlags,
375 IN BOOLEAN *IsDone,
376 OUT BOOLEAN *IsMatched,
377 IN OUT EFI_IP_ADDRESS *DestIp OPTIONAL,
378 IN OUT EFI_PXE_BASE_CODE_UDP_PORT *DestPort OPTIONAL,
379 IN OUT EFI_IP_ADDRESS *SrcIp OPTIONAL,
380 IN OUT EFI_PXE_BASE_CODE_UDP_PORT *SrcPort OPTIONAL
381 );
382
383
384 /**
385 This function is to receive packet with Udp6Read.
386
387 @param[in] Udp6 Pointer to EFI_UDP6_PROTOCOL.
388 @param[in] Token Pointer to EFI_UDP6_COMPLETION_TOKEN.
389 @param[in] Mode Pointer to EFI_PXE_BASE_CODE_MODE.
390 @param[in] TimeoutEvent The event for timeout.
391 @param[in] OpFlags The UDP operation flags.
392 @param[in] IsDone Pointer to IsDone flag.
393 @param[out] IsMatched Pointer to IsMatched flag.
394 @param[in, out] DestIp Pointer to destination address.
395 @param[in, out] DestPort Pointer to destination port.
396 @param[in, out] SrcIp Pointer to source address.
397 @param[in, out] SrcPort Pointer to source port.
398
399 @retval EFI_SUCCESS Successfully read data with Udp6.
400 @retval Others Failed to send out data.
401
402 **/
403 EFI_STATUS
404 PxeBcUdp6Read (
405 IN EFI_UDP6_PROTOCOL *Udp6,
406 IN EFI_UDP6_COMPLETION_TOKEN *Token,
407 IN EFI_PXE_BASE_CODE_MODE *Mode,
408 IN EFI_EVENT TimeoutEvent,
409 IN UINT16 OpFlags,
410 IN BOOLEAN *IsDone,
411 OUT BOOLEAN *IsMatched,
412 IN OUT EFI_IP_ADDRESS *DestIp OPTIONAL,
413 IN OUT EFI_PXE_BASE_CODE_UDP_PORT *DestPort OPTIONAL,
414 IN OUT EFI_IP_ADDRESS *SrcIp OPTIONAL,
415 IN OUT EFI_PXE_BASE_CODE_UDP_PORT *SrcPort OPTIONAL
416 );
417
418
419 /**
420 This function is to display the IPv4 address.
421
422 @param[in] Ip Pointer to the IPv4 address.
423
424 **/
425 VOID
426 PxeBcShowIp4Addr (
427 IN EFI_IPv4_ADDRESS *Ip
428 );
429
430
431 /**
432 This function is to display the IPv6 address.
433
434 @param[in] Ip Pointer to the IPv6 address.
435
436 **/
437 VOID
438 PxeBcShowIp6Addr (
439 IN EFI_IPv6_ADDRESS *Ip
440 );
441
442
443 /**
444 This function is to convert UINTN to ASCII string with required format.
445
446 @param[in] Number Numeric value to be converted.
447 @param[in] Buffer Pointer to the buffer for ASCII string.
448 @param[in] Length Length of the required format.
449
450 **/
451 VOID
452 PxeBcUintnToAscDecWithFormat (
453 IN UINTN Number,
454 IN UINT8 *Buffer,
455 IN INTN Length
456 );
457
458
459 /**
460 This function is to convert a UINTN to a ASCII string, and return the
461 actual length of the buffer.
462
463 @param[in] Number Numeric value to be converted.
464 @param[in] Buffer Pointer to the buffer for ASCII string.
465
466 @return Length The actual length of the ASCII string.
467
468 **/
469 UINTN
470 PxeBcUintnToAscDec (
471 IN UINTN Number,
472 IN UINT8 *Buffer
473 );
474
475 /**
476 This function is to convert unicode hex number to a UINT8.
477
478 @param[out] Digit The converted UINT8 for output.
479 @param[in] Char The unicode hex number to be converted.
480
481 @retval EFI_SUCCESS Successfully converted the unicode hex.
482 @retval EFI_INVALID_PARAMETER Failed to convert the unicode hex.
483
484 **/
485 EFI_STATUS
486 PxeBcUniHexToUint8 (
487 OUT UINT8 *Digit,
488 IN CHAR16 Char
489 );
490
491 #endif