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