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