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