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