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