]> git.proxmox.com Git - mirror_edk2.git/blame - NetworkPkg/DnsDxe/DnsImpl.h
NetworkPkg: Fix an error that the call function declared implicitly.
[mirror_edk2.git] / NetworkPkg / DnsDxe / DnsImpl.h
CommitLineData
99c048ef 1/** @file\r
2DnsDxe support functions implementation.\r
3 \r
4Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
5This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#ifndef __EFI_DNS_IMPL_H_\r
16#define __EFI_DNS_IMPL_H_\r
17\r
18#include <Uefi.h>\r
19\r
20//\r
21// Libraries classes\r
22//\r
23#include <Library/BaseLib.h>\r
24#include <Library/UefiLib.h>\r
25#include <Library/UefiBootServicesTableLib.h>\r
26#include <Library/UefiDriverEntryPoint.h>\r
27#include <Library/UefiRuntimeServicesTableLib.h>\r
28#include <Library/BaseMemoryLib.h>\r
29#include <Library/MemoryAllocationLib.h>\r
30#include <Library/NetLib.h>\r
31#include <Library/DebugLib.h>\r
32#include <Library/DpcLib.h>\r
33#include <Library/PrintLib.h>\r
34#include <Library/UdpIoLib.h>\r
35\r
36//\r
37// UEFI Driver Model Protocols\r
38//\r
39#include <Protocol/DriverBinding.h>\r
40#include <Protocol/ComponentName2.h>\r
41#include <Protocol/ComponentName.h>\r
42\r
43#include <Protocol/Udp4.h>\r
44#include <Protocol/Dhcp4.h>\r
45#include <Protocol/Dns4.h>\r
46\r
47#include <Protocol/Udp6.h>\r
48#include <Protocol/Dhcp6.h>\r
49#include <Protocol/Dns6.h>\r
50\r
51#include <Protocol/Ip4Config2.h>\r
52\r
53#include "DnsDriver.h"\r
54#include "DnsDhcp.h"\r
55\r
56//\r
57// Driver Version\r
58//\r
59#define DNS_VERSION 0x00000000\r
60\r
61//\r
62// Protocol instances\r
63//\r
64extern EFI_COMPONENT_NAME_PROTOCOL gDnsComponentName;\r
65extern EFI_COMPONENT_NAME2_PROTOCOL gDnsComponentName2;\r
66extern EFI_UNICODE_STRING_TABLE *gDnsControllerNameTable;\r
67\r
68extern EFI_DRIVER_BINDING_PROTOCOL gDns4DriverBinding;\r
69extern EFI_SERVICE_BINDING_PROTOCOL mDns4ServiceBinding;\r
70extern EFI_DNS4_PROTOCOL mDns4Protocol;\r
71\r
72extern EFI_DRIVER_BINDING_PROTOCOL gDns6DriverBinding;\r
73extern EFI_SERVICE_BINDING_PROTOCOL mDns6ServiceBinding;\r
74extern EFI_DNS6_PROTOCOL mDns6Protocol;\r
75\r
76//\r
77// DNS related\r
78//\r
79#define DNS_SERVER_PORT 53\r
80\r
81#define DNS_PROTOCOL_UDP EFI_IP_PROTO_UDP\r
82#define DNS_PROTOCOL_TCP EFI_IP_PROTO_TCP\r
83\r
84#define DNS_STATE_UNCONFIGED 0\r
85#define DNS_STATE_CONFIGED 1\r
86#define DNS_STATE_DESTROY 2\r
87\r
88#define DNS_DEFAULT_TIMEOUT 2\r
89#define DNS_DEFAULT_RETRY 3\r
90#define DNS_DEFAULT_BLKSIZE 512\r
91\r
92#define DNS_TIME_TO_GETMAP 5\r
93\r
94#pragma pack(1)\r
95\r
96typedef union _DNS_FLAGS DNS_FLAGS;\r
97\r
98typedef struct {\r
99 LIST_ENTRY AllCacheLink;\r
100 EFI_DNS4_CACHE_ENTRY DnsCache; \r
101} DNS4_CACHE;\r
102\r
103typedef struct {\r
104 LIST_ENTRY AllCacheLink;\r
105 EFI_DNS6_CACHE_ENTRY DnsCache; \r
106} DNS6_CACHE;\r
107\r
108typedef struct {\r
109 LIST_ENTRY AllServerLink;\r
110 EFI_IPv4_ADDRESS Dns4ServerIp; \r
111} DNS4_SERVER_IP;\r
112\r
113typedef struct {\r
114 LIST_ENTRY AllServerLink;\r
115 EFI_IPv6_ADDRESS Dns6ServerIp; \r
116} DNS6_SERVER_IP;\r
117\r
118typedef struct {\r
119 UINT32 PacketToLive;\r
120 CHAR16 *QueryHostName;\r
121 EFI_IPv4_ADDRESS QueryIpAddress;\r
122 EFI_DNS4_COMPLETION_TOKEN *Token;\r
123} DNS4_TOKEN_ENTRY;\r
124\r
125typedef struct {\r
126 UINT32 PacketToLive;\r
127 CHAR16 *QueryHostName;\r
128 EFI_IPv6_ADDRESS QueryIpAddress;\r
129 EFI_DNS6_COMPLETION_TOKEN *Token;\r
130} DNS6_TOKEN_ENTRY;\r
131\r
132union _DNS_FLAGS{\r
133 struct {\r
134 UINT16 RCode:4;\r
135 UINT16 Zero:3;\r
136 UINT16 RA:1;\r
137 UINT16 RD:1;\r
138 UINT16 TC:1;\r
139 UINT16 AA:1;\r
140 UINT16 OpCode:4;\r
141 UINT16 QR:1;\r
142 } Bits;\r
143 UINT16 Uint16;\r
144};\r
145\r
146#define DNS_FLAGS_QR_QUERY 0\r
147#define DNS_FLAGS_QR_RESPONSE 1\r
148\r
149#define DNS_FLAGS_OPCODE_STANDARD 0\r
150#define DNS_FLAGS_OPCODE_INVERSE 1\r
151#define DNS_FLAGS_OPCODE_SERVER_STATE 2\r
152\r
153#define DNS_FLAGS_RCODE_NO_ERROR 0\r
154#define DNS_FLAGS_RCODE_NAME_ERROR 3\r
155\r
156typedef struct {\r
157 UINT16 Identification;\r
158 DNS_FLAGS Flags;\r
159 UINT16 QuestionsNum;\r
160 UINT16 AnswersNum;\r
161 UINT16 AuthorityNum;\r
162 UINT16 AditionalNum;\r
163} DNS_HEADER;\r
164\r
165typedef struct {\r
166 UINT16 Type;\r
167 UINT16 Class;\r
168} DNS_QUERY_SECTION;\r
169\r
170typedef struct {\r
171 UINT16 Type;\r
172 UINT16 Class;\r
173 UINT32 Ttl;\r
174 UINT16 DataLength;\r
175} DNS_ANSWER_SECTION;\r
176\r
177#define DNS_TYPE_A 1\r
178#define DNS_TYPE_NS 2\r
179#define DNS_TYPE_CNAME 5\r
180#define DNS_TYPE_PTR 12\r
181#define DNS_TYPE_HINFO 13\r
182#define DNS_TYPE_MX 15\r
183#define DNS_TYPE_AAAA 28\r
184#define DNS_TYPE_SRV_RR 33\r
185#define DNS_TYPE_AXFR 252\r
186#define DNS_TYPE_ANY 255\r
187\r
188#define DNS_CLASS_INET 1\r
189\r
190#define DNS4_DOMAIN L"in-addr.arpa"\r
191#define DNS6_DOMAIN L"IP6.ARPA"\r
192\r
193\r
194#pragma pack()\r
195\r
196/**\r
197 Remove TokenEntry from TokenMap.\r
198\r
199 @param[in] TokenMap All DNSv4 Token entrys.\r
200 @param[in] TokenEntry TokenEntry need to be removed.\r
201\r
202 @retval EFI_SUCCESS Remove TokenEntry from TokenMap sucessfully.\r
203 @retval EFI_NOT_FOUND TokenEntry is not found in TokenMap.\r
204\r
205**/\r
206EFI_STATUS\r
207Dns4RemoveTokenEntry (\r
208 IN NET_MAP *TokenMap,\r
209 IN DNS4_TOKEN_ENTRY *TokenEntry\r
210 );\r
211\r
212/**\r
213 Remove TokenEntry from TokenMap.\r
214\r
215 @param[in] TokenMap All DNSv6 Token entrys.\r
216 @param[in] TokenEntry TokenEntry need to be removed.\r
217\r
218 @retval EFI_SUCCESS Remove TokenEntry from TokenMap sucessfully.\r
219 @retval EFI_NOT_FOUND TokenEntry is not found in TokenMap.\r
220 \r
221**/\r
222EFI_STATUS\r
223Dns6RemoveTokenEntry (\r
224 IN NET_MAP *TokenMap,\r
225 IN DNS6_TOKEN_ENTRY *TokenEntry\r
226 );\r
227\r
228/**\r
229 This function cancle the token specified by Arg in the Map.\r
230\r
231 @param[in] Map Pointer to the NET_MAP.\r
232 @param[in] Item Pointer to the NET_MAP_ITEM.\r
233 @param[in] Arg Pointer to the token to be cancelled. If NULL, all\r
234 the tokens in this Map will be cancelled.\r
235 This parameter is optional and may be NULL.\r
236\r
237 @retval EFI_SUCCESS The token is cancelled if Arg is NULL, or the token\r
238 is not the same as that in the Item, if Arg is not\r
239 NULL.\r
240 @retval EFI_ABORTED Arg is not NULL, and the token specified by Arg is\r
241 cancelled.\r
242\r
243**/\r
244EFI_STATUS\r
245EFIAPI\r
246Dns4CancelTokens (\r
247 IN NET_MAP *Map,\r
248 IN NET_MAP_ITEM *Item,\r
249 IN VOID *Arg OPTIONAL\r
250 );\r
251\r
252/**\r
253 This function cancle the token specified by Arg in the Map.\r
254\r
255 @param[in] Map Pointer to the NET_MAP.\r
256 @param[in] Item Pointer to the NET_MAP_ITEM.\r
257 @param[in] Arg Pointer to the token to be cancelled. If NULL, all\r
258 the tokens in this Map will be cancelled.\r
259 This parameter is optional and may be NULL.\r
260\r
261 @retval EFI_SUCCESS The token is cancelled if Arg is NULL, or the token\r
262 is not the same as that in the Item, if Arg is not\r
263 NULL.\r
264 @retval EFI_ABORTED Arg is not NULL, and the token specified by Arg is\r
265 cancelled.\r
266\r
267**/\r
268EFI_STATUS\r
269EFIAPI\r
270Dns6CancelTokens (\r
271 IN NET_MAP *Map,\r
272 IN NET_MAP_ITEM *Item,\r
273 IN VOID *Arg OPTIONAL\r
274 );\r
275\r
276/**\r
277 Get the TokenEntry from the TokensMap.\r
278\r
279 @param[in] TokensMap All DNSv4 Token entrys\r
280 @param[in] Token Pointer to the token to be get.\r
281 @param[out] TokenEntry Pointer to TokenEntry corresponding Token.\r
282\r
283 @retval EFI_SUCCESS Get the TokenEntry from the TokensMap sucessfully.\r
284 @retval EFI_NOT_FOUND TokenEntry is not found in TokenMap.\r
285\r
286**/\r
287EFI_STATUS\r
288EFIAPI\r
289GetDns4TokenEntry (\r
290 IN NET_MAP *TokensMap,\r
291 IN EFI_DNS4_COMPLETION_TOKEN *Token, \r
292 OUT DNS4_TOKEN_ENTRY **TokenEntry\r
293 );\r
294\r
295/**\r
296 Get the TokenEntry from the TokensMap.\r
297\r
298 @param[in] TokensMap All DNSv6 Token entrys\r
299 @param[in] Token Pointer to the token to be get.\r
300 @param[out] TokenEntry Pointer to TokenEntry corresponding Token.\r
301\r
302 @retval EFI_SUCCESS Get the TokenEntry from the TokensMap sucessfully.\r
303 @retval EFI_NOT_FOUND TokenEntry is not found in TokenMap.\r
304\r
305**/\r
306EFI_STATUS\r
307EFIAPI\r
308GetDns6TokenEntry (\r
309 IN NET_MAP *TokensMap,\r
310 IN EFI_DNS6_COMPLETION_TOKEN *Token, \r
311 OUT DNS6_TOKEN_ENTRY **TokenEntry\r
312 );\r
313\r
314/**\r
315 Cancel DNS4 tokens from the DNS4 instance.\r
316\r
317 @param[in] Instance Pointer to the DNS instance context data.\r
318 @param[in] Token Pointer to the token to be canceled. If NULL, all\r
319 tokens in this instance will be cancelled.\r
320 This parameter is optional and may be NULL.\r
321\r
322 @retval EFI_SUCCESS The Token is cancelled.\r
323 @retval EFI_NOT_FOUND The Token is not found.\r
324\r
325**/\r
326EFI_STATUS\r
327Dns4InstanceCancelToken (\r
328 IN DNS_INSTANCE *Instance,\r
329 IN EFI_DNS4_COMPLETION_TOKEN *Token\r
330 );\r
331\r
332/**\r
333 Cancel DNS6 tokens from the DNS6 instance.\r
334\r
335 @param[in] Instance Pointer to the DNS instance context data.\r
336 @param[in] Token Pointer to the token to be canceled. If NULL, all\r
337 tokens in this instance will be cancelled.\r
338 This parameter is optional and may be NULL.\r
339\r
340 @retval EFI_SUCCESS The Token is cancelled.\r
341 @retval EFI_NOT_FOUND The Token is not found.\r
342\r
343**/\r
344EFI_STATUS\r
345Dns6InstanceCancelToken (\r
346 IN DNS_INSTANCE *Instance,\r
347 IN EFI_DNS6_COMPLETION_TOKEN *Token\r
348 );\r
349\r
350/**\r
351 Free the resource related to the configure parameters.\r
352\r
353 @param Config The DNS configure data\r
354\r
355**/\r
356VOID\r
357Dns4CleanConfigure (\r
358 IN OUT EFI_DNS4_CONFIG_DATA *Config\r
359 );\r
360\r
361/**\r
362 Free the resource related to the configure parameters.\r
363\r
364 @param Config The DNS configure data\r
365\r
366**/\r
367VOID\r
368Dns6CleanConfigure (\r
369 IN OUT EFI_DNS6_CONFIG_DATA *Config\r
370 );\r
371\r
372/**\r
373 Allocate memory for configure parameter such as timeout value for Dst,\r
374 then copy the configure parameter from Src to Dst.\r
375\r
376 @param[out] Dst The destination DHCP configure data.\r
377 @param[in] Src The source DHCP configure data.\r
378\r
379 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
380 @retval EFI_SUCCESS The configure is copied.\r
381\r
382**/\r
383EFI_STATUS\r
384Dns4CopyConfigure (\r
385 OUT EFI_DNS4_CONFIG_DATA *Dst,\r
386 IN EFI_DNS4_CONFIG_DATA *Src\r
387 );\r
388\r
389/**\r
390 Allocate memory for configure parameter such as timeout value for Dst,\r
391 then copy the configure parameter from Src to Dst.\r
392\r
393 @param[out] Dst The destination DHCP configure data.\r
394 @param[in] Src The source DHCP configure data.\r
395\r
396 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
397 @retval EFI_SUCCESS The configure is copied.\r
398\r
399**/\r
400EFI_STATUS\r
401Dns6CopyConfigure (\r
402 OUT EFI_DNS6_CONFIG_DATA *Dst,\r
403 IN EFI_DNS6_CONFIG_DATA *Src\r
404 );\r
405\r
406/**\r
407 Callback of Dns packet. Does nothing.\r
408\r
409 @param Arg The context.\r
410\r
411**/\r
412VOID\r
413EFIAPI\r
414DnsDummyExtFree (\r
415 IN VOID *Arg\r
416 );\r
417\r
418/**\r
419 Poll the UDP to get the IP4 default address, which may be retrieved\r
420 by DHCP. \r
421 \r
422 The default time out value is 5 seconds. If IP has retrieved the default address, \r
423 the UDP is reconfigured.\r
424\r
425 @param Instance The DNS instance\r
426 @param UdpIo The UDP_IO to poll\r
427 @param UdpCfgData The UDP configure data to reconfigure the UDP_IO\r
428\r
429 @retval TRUE The default address is retrieved and UDP is reconfigured.\r
430 @retval FALSE Some error occured.\r
431\r
432**/\r
433BOOLEAN\r
434Dns4GetMapping (\r
435 IN DNS_INSTANCE *Instance,\r
436 IN UDP_IO *UdpIo,\r
437 IN EFI_UDP4_CONFIG_DATA *UdpCfgData\r
438 );\r
439\r
440/**\r
441 Configure the opened Udp6 instance until the corresponding Ip6 instance\r
442 has been configured.\r
443\r
444 @param Instance The DNS instance\r
445 @param UdpIo The UDP_IO to poll\r
446 @param UdpCfgData The UDP configure data to reconfigure the UDP_IO\r
447\r
448 @retval TRUE Configure the Udp6 instance successfully.\r
449 @retval FALSE Some error occured.\r
450\r
451**/\r
452BOOLEAN\r
453Dns6GetMapping (\r
454 IN DNS_INSTANCE *Instance,\r
455 IN UDP_IO *UdpIo,\r
456 IN EFI_UDP6_CONFIG_DATA *UdpCfgData\r
457 );\r
458\r
459/**\r
460 Configure the UDP.\r
461 \r
462 @param Instance The DNS session\r
463 @param UdpIo The UDP_IO instance\r
464 \r
465 @retval EFI_SUCCESS The UDP is successfully configured for the\r
466 session.\r
467\r
468**/\r
469EFI_STATUS\r
470Dns4ConfigUdp (\r
471 IN DNS_INSTANCE *Instance,\r
472 IN UDP_IO *UdpIo\r
473 );\r
474\r
475/**\r
476 Configure the UDP.\r
477 \r
478 @param Instance The DNS session\r
479 @param UdpIo The UDP_IO instance\r
480\r
481 @retval EFI_SUCCESS The UDP is successfully configured for the\r
482 session.\r
483\r
484**/\r
485EFI_STATUS\r
486Dns6ConfigUdp (\r
487 IN DNS_INSTANCE *Instance,\r
488 IN UDP_IO *UdpIo\r
489 );\r
490\r
491/**\r
492 Update Dns4 cache to shared list of caches of all DNSv4 instances.\r
493 \r
494 @param Dns4CacheList All Dns4 cache list.\r
495 @param DeleteFlag If FALSE, this function is to add one entry to the DNS Cache. \r
496 If TRUE, this function will delete matching DNS Cache entry. \r
497 @param Override If TRUE, the matching DNS cache entry will be overwritten with the supplied parameter. \r
498 If FALSE, EFI_ACCESS_DENIED will be returned if the entry to be added is already exists.\r
499 @param DnsCacheEntry Entry Pointer to DNS Cache entry.\r
500\r
501 @retval EFI_SUCCESS Update Dns4 cache successfully.\r
502 @retval Others Failed to update Dns4 cache. \r
503 \r
504**/\r
505EFI_STATUS\r
506EFIAPI\r
507UpdateDns4Cache (\r
508 IN LIST_ENTRY *Dns4CacheList,\r
509 IN BOOLEAN DeleteFlag,\r
510 IN BOOLEAN Override,\r
511 IN EFI_DNS4_CACHE_ENTRY DnsCacheEntry\r
512 );\r
513\r
514/**\r
515 Update Dns6 cache to shared list of caches of all DNSv6 instances. \r
516\r
517 @param Dns6CacheList All Dns6 cache list.\r
518 @param DeleteFlag If FALSE, this function is to add one entry to the DNS Cache. \r
519 If TRUE, this function will delete matching DNS Cache entry. \r
520 @param Override If TRUE, the matching DNS cache entry will be overwritten with the supplied parameter. \r
521 If FALSE, EFI_ACCESS_DENIED will be returned if the entry to be added is already exists.\r
522 @param DnsCacheEntry Entry Pointer to DNS Cache entry.\r
523 \r
524 @retval EFI_SUCCESS Update Dns6 cache successfully.\r
525 @retval Others Failed to update Dns6 cache.\r
526**/ \r
527EFI_STATUS\r
528EFIAPI\r
529UpdateDns6Cache (\r
530 IN LIST_ENTRY *Dns6CacheList,\r
531 IN BOOLEAN DeleteFlag,\r
532 IN BOOLEAN Override,\r
533 IN EFI_DNS6_CACHE_ENTRY DnsCacheEntry\r
534 );\r
535\r
536/**\r
537 Add Dns4 ServerIp to common list of addresses of all configured DNSv4 server. \r
538\r
539 @param Dns4ServerList Common list of addresses of all configured DNSv4 server. \r
540 @param ServerIp DNS server Ip. \r
541\r
542 @retval EFI_SUCCESS Add Dns4 ServerIp to common list successfully.\r
543 @retval Others Failed to add Dns4 ServerIp to common list.\r
544 \r
545**/\r
546EFI_STATUS\r
547EFIAPI\r
548AddDns4ServerIp (\r
549 IN LIST_ENTRY *Dns4ServerList,\r
550 IN EFI_IPv4_ADDRESS ServerIp\r
551 );\r
552\r
553/**\r
554 Add Dns6 ServerIp to common list of addresses of all configured DNSv6 server. \r
555\r
556 @param Dns6ServerList Common list of addresses of all configured DNSv6 server. \r
557 @param ServerIp DNS server Ip. \r
558\r
559 @retval EFI_SUCCESS Add Dns6 ServerIp to common list successfully.\r
560 @retval Others Failed to add Dns6 ServerIp to common list.\r
561 \r
562**/ \r
563EFI_STATUS\r
564EFIAPI\r
565AddDns6ServerIp (\r
566 IN LIST_ENTRY *Dns6ServerList,\r
567 IN EFI_IPv6_ADDRESS ServerIp\r
568 );\r
569\r
570/**\r
571 Find out whether the response is valid or invalid.\r
572\r
573 @param TokensMap All DNS transmittal Tokens entry. \r
574 @param Identification Identification for queried packet. \r
575 @param Type Type for queried packet.\r
576 @param Item Return corresponding Token entry.\r
577\r
578 @retval TRUE The response is valid.\r
579 @retval FALSE The response is invalid.\r
580 \r
581**/ \r
582BOOLEAN\r
583IsValidDnsResponse (\r
584 IN NET_MAP *TokensMap,\r
585 IN UINT16 Identification,\r
586 IN UINT16 Type,\r
587 OUT NET_MAP_ITEM **Item\r
588 );\r
589\r
590/**\r
591 Parse Dns Response.\r
592\r
593 @param Instance The DNS instance\r
594 @param RxString Received buffer.\r
595 @param Completed Flag to indicate that Dns response is valid. \r
596 \r
597 @retval EFI_SUCCESS Parse Dns Response successfully.\r
598 @retval Others Failed to parse Dns Response.\r
599 \r
600**/ \r
601EFI_STATUS\r
602ParseDnsResponse (\r
603 IN OUT DNS_INSTANCE *Instance,\r
604 IN UINT8 *RxString,\r
605 OUT BOOLEAN *Completed\r
606 );\r
607\r
608/**\r
609 Parse response packet.\r
610\r
611 @param Packet The packets received.\r
612 @param EndPoint The local/remote UDP access point\r
613 @param IoStatus The status of the UDP receive\r
614 @param Context The opaque parameter to the function.\r
615\r
616**/ \r
617VOID\r
618EFIAPI\r
619DnsOnPacketReceived (\r
620 NET_BUF *Packet,\r
621 UDP_END_POINT *EndPoint,\r
622 EFI_STATUS IoStatus,\r
623 VOID *Context\r
624 );\r
625\r
626/**\r
627 Release the net buffer when packet is sent.\r
628\r
629 @param Packet The packets received.\r
630 @param EndPoint The local/remote UDP access point\r
631 @param IoStatus The status of the UDP receive\r
632 @param Context The opaque parameter to the function.\r
633\r
634**/\r
635VOID\r
636EFIAPI\r
637DnsOnPacketSent (\r
638 NET_BUF *Packet,\r
639 UDP_END_POINT *EndPoint,\r
640 EFI_STATUS IoStatus,\r
641 VOID *Context\r
642 );\r
643\r
644/**\r
645 Query request information.\r
646\r
647 @param Instance The DNS instance\r
648 @param Packet The packet for querying request information.\r
649\r
650 @retval EFI_SUCCESS Query request information successfully.\r
651 @retval Others Failed to query request information.\r
652\r
653**/\r
654EFI_STATUS\r
655DoDnsQuery (\r
656 IN DNS_INSTANCE *Instance,\r
657 IN NET_BUF *Packet\r
658 );\r
659\r
660/**\r
661 Construct the Packet to query Ip.\r
662\r
663 @param Instance The DNS instance\r
664 @param HostName Queried HostName \r
665 @param Type DNS query Type\r
666 @param Packet The packet for querying Ip\r
667\r
668 @retval EFI_SUCCESS The packet is constructed.\r
669 @retval Others Failed to construct the Packet.\r
670\r
671**/\r
672EFI_STATUS\r
673ConstructDNSQueryIp (\r
674 IN DNS_INSTANCE *Instance,\r
675 IN CHAR16 *HostName,\r
676 IN UINT16 Type,\r
677 OUT NET_BUF **Packet\r
678 );\r
679\r
680/**\r
681 Retransmit the packet.\r
682\r
683 @param Instance The DNS instance\r
684 @param Packet Retransmit the packet \r
685\r
686 @retval EFI_SUCCESS The packet is retransmitted.\r
687 @retval Others Failed to retransmit.\r
688\r
689**/\r
690EFI_STATUS\r
691DnsRetransmit (\r
692 IN DNS_INSTANCE *Instance,\r
693 IN NET_BUF *Packet\r
694 );\r
695\r
696/**\r
697 The timer ticking function for the DNS service.\r
698\r
699 @param Event The ticking event\r
700 @param Context The DNS service instance\r
701\r
702**/\r
703VOID\r
704EFIAPI\r
705DnsOnTimerRetransmit (\r
706 IN EFI_EVENT Event,\r
707 IN VOID *Context\r
708 );\r
709\r
710/**\r
711 The timer ticking function for the DNS driver.\r
712\r
713 @param Event The ticking event\r
714 @param Context NULL\r
715\r
716**/\r
717VOID\r
718EFIAPI\r
719DnsOnTimerUpdate (\r
720 IN EFI_EVENT Event,\r
721 IN VOID *Context\r
722 );\r
723\r
724\r
725/**\r
726 This function is used to retrieve DNS mode data for this DNS instance.\r
727\r
728 @param[in] This Pointer to EFI_DNS4_PROTOCOL instance.\r
729 @param[out] DnsModeData Pointer to the caller-allocated storage for the EFI_DNS4_MODE_DATA structure.\r
730\r
731 @retval EFI_SUCCESS The operation completed successfully.\r
732 @retval EFI_NOT_STARTED When DnsConfigData is queried, no configuration data is \r
733 available because this instance has not been configured.\r
734 @retval EFI_OUT_OF_RESOURCES Failed to allocate needed resources.\r
735 @retval EFI_INVALID_PARAMETER This is NULL or DnsModeData is NULL.\r
736\r
737**/\r
738EFI_STATUS\r
739EFIAPI\r
740Dns4GetModeData (\r
741 IN EFI_DNS4_PROTOCOL *This,\r
742 OUT EFI_DNS4_MODE_DATA *DnsModeData\r
743 );\r
744\r
745/**\r
746 This function is used to configure DNS configuration data for this DNS instance.\r
747\r
748 @param[in] This Pointer to EFI_DNS4_PROTOCOL instance.\r
749 @param[in] DnsConfigData Pointer to caller-allocated buffer containing EFI_DNS4_CONFIG_DATA structure. \r
750 If NULL, the driver will reinitialize the protocol instance to the unconfigured state.\r
751\r
752 @retval EFI_SUCCESS The operation completed successfully.\r
753 @retval EFI_UNSUPPORTED The designated protocol is not supported.\r
754 @retval EFI_OUT_OF_RESOURCES Failed to allocate needed resources.\r
755 @retval EFI_INVALID_PARAMETER This is NULL.\r
756 The StationIp address provided in DnsConfigData is not a valid unicast.\r
757 DnsServerList is NULL while DnsServerListCount is not equal to Zero.\r
758 DnsServerListCount is Zero while DnsServerListCount is not equal to NULL.\r
759 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. The EFI DNSv4 Protocol instance is not configured.\r
760\r
761**/\r
762EFI_STATUS\r
763EFIAPI\r
764Dns4Configure (\r
765 IN EFI_DNS4_PROTOCOL *This,\r
766 IN EFI_DNS4_CONFIG_DATA *DnsConfigData\r
767 );\r
768\r
769/**\r
770 The function is used to translate the host name to host IP address. \r
771 A type A query is used to get the one or more IP addresses for this host. \r
772\r
773 @param[in] This Pointer to EFI_DNS4_PROTOCOL instance.\r
774 @param[in] HostName Pointer to caller-supplied buffer containing Host name to be translated. \r
775 This buffer contains 16 bit characters but these are translated to ASCII for use with \r
776 DNSv4 server and there is no requirement for driver to support non-ASCII Unicode characters.\r
777 @param[in] Token Pointer to the caller-allocated completion token to return at the completion of the process to translate host name to host address. \r
778\r
779 @retval EFI_SUCCESS The operation completed successfully.\r
780 @retval EFI_OUT_OF_RESOURCES Failed to allocate needed resources.\r
781 @retval EFI_INVALID_PARAMETER This is NULL.\r
782 Token is NULL.\r
783 Token.Event is.NULL\r
784 HostName is NULL\r
785 @retval EFI_NO_MAPPING There's no source address is available for use.\r
786 @retval EFI_NOT_STARTED This instance has not been started.\r
787\r
788**/\r
789EFI_STATUS\r
790EFIAPI\r
791Dns4HostNameToIp (\r
792 IN EFI_DNS4_PROTOCOL *This,\r
793 IN CHAR16 *HostName,\r
794 IN EFI_DNS4_COMPLETION_TOKEN *Token\r
795 );\r
796\r
797/**\r
798 The function is used to translate the host address to host name. \r
799 A type PTR query is used to get the primary name of the host. \r
800\r
801 @param[in] This Pointer to EFI_DNS4_PROTOCOL instance.\r
802 @param[in] IpAddress IP address.\r
803 @param[in] Token Pointer to the caller-allocated completion used token to translate host address to host name.\r
804\r
805 @retval EFI_SUCCESS The operation completed successfully.\r
806 @retval EFI_OUT_OF_RESOURCES Failed to allocate needed resources.\r
807 @retval EFI_INVALID_PARAMETER This is NULL.\r
808 Token is NULL.\r
809 Token.Event is NULL.\r
810 IpAddress is not valid IP address.\r
811 @retval EFI_NO_MAPPING There's no source address is available for use.\r
812 @retval EFI_NOT_STARTED This instance has not been started.\r
813 @retval EFI_UNSUPPORTED This function is not supported.\r
814\r
815**/\r
816EFI_STATUS\r
817EFIAPI\r
818Dns4IpToHostName (\r
819 IN EFI_DNS4_PROTOCOL *This,\r
820 IN EFI_IPv4_ADDRESS IpAddress,\r
821 IN EFI_DNS4_COMPLETION_TOKEN *Token\r
822 );\r
823\r
824/**\r
825 This function retrieves arbitrary information from the DNS. \r
826 The caller supplies a QNAME, QTYPE, and QCLASS, and all of the matching RRs are returned. \r
827 All RR content (e.g., Ttl) was returned. \r
828 The caller need parse the returned RR to get required information. This function is optional.\r
829\r
830 @param[in] This Pointer to EFI_DNS4_PROTOCOL instance.\r
831 @param[in] QName Pointer to Query Name.\r
832 @param[in] QType Query Type.\r
833 @param[in] QClass Query Name.\r
834 @param[in] Token Point to the caller-allocated completion token to retrieve arbitrary information.\r
835\r
836 @retval EFI_SUCCESS The operation completed successfully.\r
837 @retval EFI_OUT_OF_RESOURCES Failed to allocate needed resources.\r
838 @retval EFI_INVALID_PARAMETER This is NULL.\r
839 Token is NULL.\r
840 Token.Event is NULL.\r
841 QName is NULL.\r
842 @retval EFI_NO_MAPPING There's no source address is available for use.\r
843 @retval EFI_ALREADY_STARTED This Token is being used in another DNS session.\r
844 @retval EFI_UNSUPPORTED This function is not supported. Or the requested QType is not supported\r
845\r
846**/\r
847EFI_STATUS\r
848EFIAPI\r
849Dns4GeneralLookUp (\r
850 IN EFI_DNS4_PROTOCOL *This,\r
851 IN CHAR8 *QName,\r
852 IN UINT16 QType, \r
853 IN UINT16 QClass,\r
854 IN EFI_DNS4_COMPLETION_TOKEN *Token\r
855 );\r
856\r
857/**\r
858 This function is used to add/delete/modify DNS cache entry. \r
859 DNS cache can be normally dynamically updated after the DNS resolve succeeds. \r
860 This function provided capability to manually add/delete/modify the DNS cache.\r
861\r
862 @param[in] This Pointer to EFI_DNS4_PROTOCOL instance.\r
863 @param[in] DeleteFlag If FALSE, this function is to add one entry to the DNS Cache. \r
864 If TRUE, this function will delete matching DNS Cache entry. \r
865 @param[in] Override If TRUE, the matching DNS cache entry will be overwritten with the supplied parameter. \r
866 If FALSE, EFI_ACCESS_DENIED will be returned if the entry to be added is already exists.\r
867 @param[in] DnsCacheEntry Pointer to DNS Cache entry.\r
868\r
869 @retval EFI_SUCCESS The operation completed successfully.\r
870 @retval EFI_INVALID_PARAMETER This is NULL. \r
871 DnsCacheEntry.HostName is NULL.\r
872 DnsCacheEntry.IpAddress is NULL.\r
873 DnsCacheEntry.Timeout is zero.\r
874 @retval EFI_ACCESS_DENIED The DNS cache entry already exists and Override is not TRUE. \r
875\r
876**/\r
877EFI_STATUS\r
878EFIAPI\r
879Dns4UpdateDnsCache (\r
880 IN EFI_DNS4_PROTOCOL *This,\r
881 IN BOOLEAN DeleteFlag,\r
882 IN BOOLEAN Override,\r
883 IN EFI_DNS4_CACHE_ENTRY DnsCacheEntry\r
884 );\r
885\r
886/**\r
887 This function can be used by network drivers and applications to increase the rate that data packets are moved between \r
888 the communications device and the transmit and receive queues. In some systems, the periodic timer event in the managed \r
889 network driver may not poll the underlying communications device fast enough to transmit and/or receive all data packets \r
890 without missing incoming packets or dropping outgoing packets.\r
891\r
892 @param[in] This Pointer to EFI_DNS4_PROTOCOL instance.\r
893\r
894 @retval EFI_SUCCESS Incoming or outgoing data was processed.\r
895 @retval EFI_INVALID_PARAMETER This is NULL. \r
896 @retval EFI_NOT_STARTED This EFI DNS Protocol instance has not been started. \r
897 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. \r
898 @retval EFI_TIMEOUT Data was dropped out of the transmit and/or receive queue. \r
899 Consider increasing the polling rate.\r
900 \r
901**/\r
902EFI_STATUS\r
903EFIAPI\r
904Dns4Poll (\r
905 IN EFI_DNS4_PROTOCOL *This\r
906 );\r
907\r
908/**\r
909 This function is used to abort a pending resolution request. \r
910 After calling this function, Token.Status will be set to EFI_ABORTED and then Token.\r
911\r
912 @param[in] This Pointer to EFI_DNS4_PROTOCOL instance.\r
913 @param[in] Token Pointer to a token that has been issued by EFI_DNS4_PROTOCOL.HostNameToIp(), \r
914 EFI_DNS4_PROTOCOL.IpToHostName() or EFI_DNS4_PROTOCOL.GeneralLookup(). \r
915 If NULL, all pending tokens are aborted.\r
916\r
917 @retval EFI_SUCCESS Incoming or outgoing data was processed.\r
918 @retval EFI_INVALID_PARAMETER This is NULL. \r
919 @retval EFI_NOT_STARTED This EFI DNS Protocol instance has not been started. \r
920 @retval EFI_NOT_FOUND When Token is not NULL, and the asynchronous DNS operation was not found in the transmit queue. \r
921 It was either completed or was not issued by HostNameToIp(), IpToHostName() or GeneralLookup().\r
922 \r
923**/\r
924EFI_STATUS\r
925EFIAPI\r
926Dns4Cancel (\r
927 IN EFI_DNS4_PROTOCOL *This,\r
928 IN EFI_DNS4_COMPLETION_TOKEN *Token\r
929 );\r
930\r
931\r
932/**\r
933 This function is used to retrieve DNS mode data for this DNS instance.\r
934\r
935 @param[in] This Pointer to EFI_DNS6_PROTOCOL instance.\r
936 @param[out] DnsModeData Pointer to the caller-allocated storage for the EFI_DNS6_MODE_DATA structure.\r
937\r
938 @retval EFI_SUCCESS The operation completed successfully.\r
939 @retval EFI_NOT_STARTED When DnsConfigData is queried, no configuration data is \r
940 available because this instance has not been configured.\r
941 @retval EFI_OUT_OF_RESOURCES Failed to allocate needed resources.\r
942 @retval EFI_INVALID_PARAMETER This is NULL or DnsModeData is NULL.\r
943\r
944**/\r
945EFI_STATUS\r
946EFIAPI\r
947Dns6GetModeData (\r
948 IN EFI_DNS6_PROTOCOL *This,\r
949 OUT EFI_DNS6_MODE_DATA *DnsModeData\r
950 );\r
951\r
952/**\r
953 The function is used to set and change the configuration data for this EFI DNSv6 Protocol driver instance. \r
954 Reset the DNS instance if DnsConfigData is NULL.\r
955\r
956 @param[in] This Pointer to EFI_DNS6_PROTOCOL instance.\r
957 @param[in] DnsConfigData Pointer to the configuration data structure. \r
958 All associated storage to be allocated and released by caller.\r
959\r
960 @retval EFI_SUCCESS The operation completed successfully.\r
961 @retval EFI_UNSUPPORTED The designated protocol is not supported.\r
962 @retval EFI_OUT_OF_RESOURCES Failed to allocate needed resources.\r
963 @retval EFI_INVALID_PARAMETER This is NULL.\r
964 The StationIp address provided in DnsConfigData is not a valid unicast.\r
965 DnsServerList is NULL while DnsServerListCount is not equal to Zero.\r
966 DnsServerListCount is Zero while DnsServerList is not equal to NULL.\r
967 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. The EFI DNSv6 Protocol instance is not configured.\r
968\r
969**/\r
970EFI_STATUS\r
971EFIAPI\r
972Dns6Configure (\r
973 IN EFI_DNS6_PROTOCOL *This,\r
974 IN EFI_DNS6_CONFIG_DATA *DnsConfigData\r
975 );\r
976\r
977/**\r
978 The function is used to translate the host name to host IP address. \r
979 A type AAAA query is used to get the one or more IPv6 addresses for this host. \r
980\r
981 @param[in] This Pointer to EFI_DNS6_PROTOCOL instance.\r
982 @param[in] HostName Pointer to caller-supplied buffer containing Host name to be translated. \r
983 This buffer contains 16 bit characters but these are translated to ASCII for use with \r
984 DNSv4 server and there is no requirement for driver to support non-ASCII Unicode characters.\r
985 @param[in] Token Pointer to the caller-allocated completion token to return at the completion of the process to translate host name to host address. \r
986\r
987 @retval EFI_SUCCESS The operation completed successfully.\r
988 @retval EFI_OUT_OF_RESOURCES Failed to allocate needed resources.\r
989 @retval EFI_INVALID_PARAMETER This is NULL.\r
990 Token is NULL.\r
991 Token.Event is.NULL\r
992 HostName is NULL\r
993 @retval EFI_NO_MAPPING There's no source address is available for use.\r
994 @retval EFI_NOT_STARTED This instance has not been started.\r
995\r
996**/\r
997EFI_STATUS\r
998EFIAPI\r
999Dns6HostNameToIp (\r
1000 IN EFI_DNS6_PROTOCOL *This,\r
1001 IN CHAR16 *HostName,\r
1002 IN EFI_DNS6_COMPLETION_TOKEN *Token\r
1003 );\r
1004\r
1005/**\r
1006 The function is used to translate the host address to host name. \r
1007 A type PTR query is used to get the primary name of the host. \r
1008\r
1009 @param[in] This Pointer to EFI_DNS6_PROTOCOL instance.\r
1010 @param[in] IpAddress IP address.\r
1011 @param[in] Token Pointer to the caller-allocated completion used token to translate host address to host name.\r
1012\r
1013 @retval EFI_SUCCESS The operation completed successfully.\r
1014 @retval EFI_OUT_OF_RESOURCES Failed to allocate needed resources.\r
1015 @retval EFI_INVALID_PARAMETER This is NULL.\r
1016 Token is NULL.\r
1017 Token.Event is NULL.\r
1018 IpAddress is not valid IP address.\r
1019 @retval EFI_NO_MAPPING There's no source address is available for use.\r
1020 @retval EFI_NOT_STARTED This instance has not been started.\r
1021 @retval EFI_UNSUPPORTED This function is not supported.\r
1022\r
1023**/\r
1024EFI_STATUS\r
1025EFIAPI\r
1026Dns6IpToHostName (\r
1027 IN EFI_DNS6_PROTOCOL *This,\r
1028 IN EFI_IPv6_ADDRESS IpAddress,\r
1029 IN EFI_DNS6_COMPLETION_TOKEN *Token\r
1030 );\r
1031\r
1032/**\r
1033 This function retrieves arbitrary information from the DNS. \r
1034 The caller supplies a QNAME, QTYPE, and QCLASS, and all of the matching RRs are returned. \r
1035 All RR content (e.g., Ttl) was returned. \r
1036 The caller need parse the returned RR to get required information. This function is optional.\r
1037\r
1038 @param[in] This Pointer to EFI_DNS6_PROTOCOL instance.\r
1039 @param[in] QName Pointer to Query Name.\r
1040 @param[in] QType Query Type.\r
1041 @param[in] QClass Query Name.\r
1042 @param[in] Token Point to the caller-allocated completion token to retrieve arbitrary information.\r
1043\r
1044 @retval EFI_SUCCESS The operation completed successfully.\r
1045 @retval EFI_OUT_OF_RESOURCES Failed to allocate needed resources.\r
1046 @retval EFI_INVALID_PARAMETER This is NULL.\r
1047 Token is NULL.\r
1048 Token.Event is NULL.\r
1049 QName is NULL.\r
1050 @retval EFI_NO_MAPPING There's no source address is available for use.\r
1051 @retval EFI_NOT_STARTED This instance has not been started.\r
1052 @retval EFI_UNSUPPORTED This function is not supported. Or the requested QType is not supported\r
1053\r
1054**/\r
1055EFI_STATUS\r
1056EFIAPI\r
1057Dns6GeneralLookUp (\r
1058 IN EFI_DNS6_PROTOCOL *This,\r
1059 IN CHAR8 *QName,\r
1060 IN UINT16 QType, \r
1061 IN UINT16 QClass,\r
1062 IN EFI_DNS6_COMPLETION_TOKEN *Token\r
1063 );\r
1064\r
1065/**\r
1066 This function is used to add/delete/modify DNS cache entry. \r
1067 DNS cache can be normally dynamically updated after the DNS resolve succeeds. \r
1068 This function provided capability to manually add/delete/modify the DNS cache.\r
1069\r
1070 @param[in] This Pointer to EFI_DNS6_PROTOCOL instance.\r
1071 @param[in] DeleteFlag If FALSE, this function is to add one entry to the DNS Cache. \r
1072 If TRUE, this function will delete matching DNS Cache entry. \r
1073 @param[in] Override If TRUE, the matching DNS cache entry will be overwritten with the supplied parameter. \r
1074 If FALSE, EFI_ACCESS_DENIED will be returned if the entry to be added is already exists.\r
1075 @param[in] DnsCacheEntry Pointer to DNS Cache entry.\r
1076\r
1077 @retval EFI_SUCCESS The operation completed successfully.\r
1078 @retval EFI_INVALID_PARAMETER This is NULL. \r
1079 DnsCacheEntry.HostName is NULL.\r
1080 DnsCacheEntry.IpAddress is NULL.\r
1081 DnsCacheEntry.Timeout is zero.\r
1082 @retval EFI_ACCESS_DENIED The DNS cache entry already exists and Override is not TRUE. \r
1083\r
1084**/\r
1085EFI_STATUS\r
1086EFIAPI\r
1087Dns6UpdateDnsCache (\r
1088 IN EFI_DNS6_PROTOCOL *This,\r
1089 IN BOOLEAN DeleteFlag,\r
1090 IN BOOLEAN Override,\r
1091 IN EFI_DNS6_CACHE_ENTRY DnsCacheEntry\r
1092 );\r
1093\r
1094/**\r
1095 This function can be used by network drivers and applications to increase the rate that data packets are moved between \r
1096 the communications device and the transmit and receive queues. In some systems, the periodic timer event in the managed \r
1097 network driver may not poll the underlying communications device fast enough to transmit and/or receive all data packets \r
1098 without missing incoming packets or dropping outgoing packets.\r
1099\r
1100 @param[in] This Pointer to EFI_DNS6_PROTOCOL instance.\r
1101\r
1102 @retval EFI_SUCCESS Incoming or outgoing data was processed.\r
1103 @retval EFI_INVALID_PARAMETER This is NULL. \r
1104 @retval EFI_NOT_STARTED This EFI DNS Protocol instance has not been started. \r
1105 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. \r
1106 @retval EFI_TIMEOUT Data was dropped out of the transmit and/or receive queue. \r
1107 Consider increasing the polling rate.\r
1108 \r
1109**/\r
1110EFI_STATUS\r
1111EFIAPI\r
1112Dns6Poll (\r
1113 IN EFI_DNS6_PROTOCOL *This\r
1114 );\r
1115\r
1116/**\r
1117 This function is used to abort a pending resolution request. \r
1118 After calling this function, Token.Status will be set to EFI_ABORTED and then Token.\r
1119\r
1120 @param[in] This Pointer to EFI_DNS6_PROTOCOL instance.\r
1121 @param[in] Token Pointer to a token that has been issued by EFI_DNS6_PROTOCOL.HostNameToIp(), \r
1122 EFI_DNS6_PROTOCOL.IpToHostName() or EFI_DNS6_PROTOCOL.GeneralLookup(). \r
1123 If NULL, all pending tokens are aborted.\r
1124\r
1125 @retval EFI_SUCCESS Incoming or outgoing data was processed.\r
1126 @retval EFI_INVALID_PARAMETER This is NULL. \r
1127 @retval EFI_NOT_STARTED This EFI DNS Protocol instance has not been started. \r
1128 @retval EFI_NOT_FOUND When Token is not NULL, and the asynchronous DNS operation was not found in the transmit queue. \r
1129 It was either completed or was not issued by HostNameToIp(), IpToHostName() or GeneralLookup().\r
1130 \r
1131**/\r
1132EFI_STATUS\r
1133EFIAPI\r
1134Dns6Cancel (\r
1135 IN EFI_DNS6_PROTOCOL *This,\r
1136 IN EFI_DNS6_COMPLETION_TOKEN *Token\r
1137 );\r
1138\r
1139#endif\r