2 Implementation of EFI_DNS4_PROTOCOL and EFI_DNS6_PROTOCOL interfaces.
4 Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
11 EFI_DNS4_PROTOCOL mDns4Protocol
= {
22 EFI_DNS6_PROTOCOL mDns6Protocol
= {
34 Retrieve mode data of this DNS instance.
36 This function is used to retrieve DNS mode data for this DNS instance.
38 @param[in] This Pointer to EFI_DNS4_PROTOCOL instance.
39 @param[out] DnsModeData Point to the mode data.
41 @retval EFI_SUCCESS The operation completed successfully.
42 @retval EFI_NOT_STARTED When DnsConfigData is queried, no configuration data
43 is available because this instance has not been
45 @retval EFI_INVALID_PARAMETER This is NULL or DnsModeData is NULL.
46 @retval EFI_OUT_OF_RESOURCES Failed to allocate needed resources.
51 IN EFI_DNS4_PROTOCOL
*This
,
52 OUT EFI_DNS4_MODE_DATA
*DnsModeData
55 DNS_INSTANCE
*Instance
;
64 DNS4_SERVER_IP
*ServerItem
;
65 EFI_IPv4_ADDRESS
*ServerList
;
66 DNS4_CACHE
*CacheItem
;
67 EFI_DNS4_CACHE_ENTRY
*CacheList
;
76 if ((This
== NULL
) || (DnsModeData
== NULL
)) {
77 return EFI_INVALID_PARAMETER
;
80 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
82 Instance
= DNS_INSTANCE_FROM_THIS_PROTOCOL4 (This
);
83 if (Instance
->State
== DNS_STATE_UNCONFIGED
) {
84 Status
= EFI_NOT_STARTED
;
88 ZeroMem (DnsModeData
, sizeof (EFI_DNS4_MODE_DATA
));
91 // Get the current configuration data of this instance.
93 Status
= Dns4CopyConfigure (&DnsModeData
->DnsConfigData
, &Instance
->Dns4CfgData
);
94 if (EFI_ERROR (Status
)) {
99 // Get the DnsServerCount and DnsServerList
102 NET_LIST_FOR_EACH_SAFE (Entry
, Next
, &mDriverData
->Dns4ServerList
) {
105 DnsModeData
->DnsServerCount
= (UINT32
)Index
;
106 ServerList
= AllocatePool (sizeof (EFI_IPv4_ADDRESS
) * DnsModeData
->DnsServerCount
);
107 if (ServerList
== NULL
) {
108 Status
= EFI_OUT_OF_RESOURCES
;
109 Dns4CleanConfigure (&DnsModeData
->DnsConfigData
);
114 NET_LIST_FOR_EACH_SAFE (Entry
, Next
, &mDriverData
->Dns4ServerList
) {
115 ServerItem
= NET_LIST_USER_STRUCT (Entry
, DNS4_SERVER_IP
, AllServerLink
);
116 CopyMem (ServerList
+ Index
, &ServerItem
->Dns4ServerIp
, sizeof (EFI_IPv4_ADDRESS
));
119 DnsModeData
->DnsServerList
= ServerList
;
122 // Get the DnsCacheCount and DnsCacheList
125 NET_LIST_FOR_EACH_SAFE (Entry
, Next
, &mDriverData
->Dns4CacheList
) {
128 DnsModeData
->DnsCacheCount
= (UINT32
)Index
;
129 CacheList
= AllocatePool (sizeof (EFI_DNS4_CACHE_ENTRY
) * DnsModeData
->DnsCacheCount
);
130 if (CacheList
== NULL
) {
131 Status
= EFI_OUT_OF_RESOURCES
;
132 Dns4CleanConfigure (&DnsModeData
->DnsConfigData
);
133 FreePool (ServerList
);
138 NET_LIST_FOR_EACH_SAFE (Entry
, Next
, &mDriverData
->Dns4CacheList
) {
139 CacheItem
= NET_LIST_USER_STRUCT (Entry
, DNS4_CACHE
, AllCacheLink
);
140 CopyMem (CacheList
+ Index
, &CacheItem
->DnsCache
, sizeof (EFI_DNS4_CACHE_ENTRY
));
143 DnsModeData
->DnsCacheList
= CacheList
;
146 gBS
->RestoreTPL (OldTpl
);
151 Configure this DNS instance.
153 This function is used to configure DNS mode data for this DNS instance.
155 @param[in] This Pointer to EFI_DNS4_PROTOCOL instance.
156 @param[in] DnsConfigData Point to the Configuration data.
158 @retval EFI_SUCCESS The operation completed successfully.
159 @retval EFI_UNSUPPORTED The designated protocol is not supported.
160 @retval EFI_INVALID_PARAMETER This is NULL.
161 The StationIp address provided in DnsConfigData is not a
163 DnsServerList is NULL while DnsServerListCount
165 DnsServerListCount is ZERO while DnsServerList
167 @retval EFI_OUT_OF_RESOURCES The DNS instance data or required space could not be
169 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. The
170 EFI DNSv4 Protocol instance is not configured.
171 @retval EFI_ALREADY_STARTED Second call to Configure() with DnsConfigData. To
172 reconfigure the instance the caller must call Configure()
173 with NULL first to return driver to unconfigured state.
178 IN EFI_DNS4_PROTOCOL
*This
,
179 IN EFI_DNS4_CONFIG_DATA
*DnsConfigData
183 DNS_INSTANCE
*Instance
;
189 UINT32 ServerListCount
;
190 EFI_IPv4_ADDRESS
*ServerList
;
192 Status
= EFI_SUCCESS
;
195 if ((This
== NULL
) ||
196 ((DnsConfigData
!= NULL
) && (((DnsConfigData
->DnsServerListCount
!= 0) && (DnsConfigData
->DnsServerList
== NULL
)) ||
197 ((DnsConfigData
->DnsServerListCount
== 0) && (DnsConfigData
->DnsServerList
!= NULL
)))))
199 return EFI_INVALID_PARAMETER
;
202 if ((DnsConfigData
!= NULL
) && (DnsConfigData
->Protocol
!= DNS_PROTOCOL_UDP
)) {
203 return EFI_UNSUPPORTED
;
206 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
208 Instance
= DNS_INSTANCE_FROM_THIS_PROTOCOL4 (This
);
210 if (DnsConfigData
== NULL
) {
211 ZeroMem (&Instance
->SessionDnsServer
, sizeof (EFI_IP_ADDRESS
));
214 // Reset the Instance if ConfigData is NULL
216 if (!NetMapIsEmpty (&Instance
->Dns4TxTokens
)) {
217 Dns4InstanceCancelToken (Instance
, NULL
);
220 if (Instance
->UdpIo
!= NULL
) {
221 UdpIoCleanIo (Instance
->UdpIo
);
224 if (Instance
->Dns4CfgData
.DnsServerList
!= NULL
) {
225 FreePool (Instance
->Dns4CfgData
.DnsServerList
);
228 ZeroMem (&Instance
->Dns4CfgData
, sizeof (EFI_DNS4_CONFIG_DATA
));
230 Instance
->State
= DNS_STATE_UNCONFIGED
;
233 // Configure the parameters for new operation.
235 CopyMem (&Ip
, &DnsConfigData
->StationIp
, sizeof (IP4_ADDR
));
236 CopyMem (&Netmask
, &DnsConfigData
->SubnetMask
, sizeof (IP4_ADDR
));
239 Netmask
= NTOHL (Netmask
);
241 if (!DnsConfigData
->UseDefaultSetting
&&
242 ((!IP4_IS_VALID_NETMASK (Netmask
) || ((Netmask
!= 0) && !NetIp4IsUnicast (Ip
, Netmask
)))))
244 Status
= EFI_INVALID_PARAMETER
;
248 Status
= Dns4CopyConfigure (&Instance
->Dns4CfgData
, DnsConfigData
);
249 if (EFI_ERROR (Status
)) {
253 if (DnsConfigData
->DnsServerListCount
== 0) {
254 gBS
->RestoreTPL (OldTpl
);
257 // The DNS instance will retrieve DNS server from DHCP Server
259 Status
= GetDns4ServerFromDhcp4 (
264 if (EFI_ERROR (Status
)) {
268 ASSERT (ServerList
!= NULL
);
270 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
272 CopyMem (&Instance
->SessionDnsServer
.v4
, &ServerList
[0], sizeof (EFI_IPv4_ADDRESS
));
274 CopyMem (&Instance
->SessionDnsServer
.v4
, &DnsConfigData
->DnsServerList
[0], sizeof (EFI_IPv4_ADDRESS
));
280 Status
= Dns4ConfigUdp (Instance
, Instance
->UdpIo
);
281 if (EFI_ERROR (Status
)) {
282 if (Instance
->Dns4CfgData
.DnsServerList
!= NULL
) {
283 FreePool (Instance
->Dns4CfgData
.DnsServerList
);
284 Instance
->Dns4CfgData
.DnsServerList
= NULL
;
291 // Add configured DNS server used by this instance to ServerList.
293 Status
= AddDns4ServerIp (&mDriverData
->Dns4ServerList
, Instance
->SessionDnsServer
.v4
);
294 if (EFI_ERROR (Status
)) {
295 if (Instance
->Dns4CfgData
.DnsServerList
!= NULL
) {
296 FreePool (Instance
->Dns4CfgData
.DnsServerList
);
297 Instance
->Dns4CfgData
.DnsServerList
= NULL
;
303 Instance
->State
= DNS_STATE_CONFIGED
;
307 gBS
->RestoreTPL (OldTpl
);
312 Host name to host address translation.
314 The HostNameToIp () function is used to translate the host name to host IP address. A
315 type A query is used to get the one or more IP addresses for this host.
317 @param[in] This Pointer to EFI_DNS4_PROTOCOL instance.
318 @param[in] HostName Host name.
319 @param[in] Token Point to the completion token to translate host name
322 @retval EFI_SUCCESS The operation completed successfully.
323 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
327 HostName is NULL. HostName string is unsupported format.
328 @retval EFI_NO_MAPPING There's no source address is available for use.
329 @retval EFI_NOT_STARTED This instance has not been started.
334 IN EFI_DNS4_PROTOCOL
*This
,
336 IN EFI_DNS4_COMPLETION_TOKEN
*Token
341 DNS_INSTANCE
*Instance
;
343 EFI_DNS4_CONFIG_DATA
*ConfigData
;
352 DNS4_TOKEN_ENTRY
*TokenEntry
;
357 Status
= EFI_SUCCESS
;
364 // Validate the parameters
366 if ((This
== NULL
) || (HostName
== NULL
) || (Token
== NULL
)) {
367 return EFI_INVALID_PARAMETER
;
370 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
372 Instance
= DNS_INSTANCE_FROM_THIS_PROTOCOL4 (This
);
374 ConfigData
= &(Instance
->Dns4CfgData
);
376 if (Instance
->State
!= DNS_STATE_CONFIGED
) {
377 Status
= EFI_NOT_STARTED
;
381 Token
->Status
= EFI_NOT_READY
;
384 // If zero, use the parameter configured through Dns.Configure() interface.
386 if (Token
->RetryCount
== 0) {
387 Token
->RetryCount
= ConfigData
->RetryCount
;
391 // If zero, use the parameter configured through Dns.Configure() interface.
393 if (Token
->RetryInterval
== 0) {
394 Token
->RetryInterval
= ConfigData
->RetryInterval
;
398 // Minimum interval of retry is 2 second. If the retry interval is less than 2 second, then use the 2 second.
400 if (Token
->RetryInterval
< DNS_DEFAULT_TIMEOUT
) {
401 Token
->RetryInterval
= DNS_DEFAULT_TIMEOUT
;
407 if (ConfigData
->EnableDnsCache
) {
409 NET_LIST_FOR_EACH_SAFE (Entry
, Next
, &mDriverData
->Dns4CacheList
) {
410 Item
= NET_LIST_USER_STRUCT (Entry
, DNS4_CACHE
, AllCacheLink
);
411 if (StrCmp (HostName
, Item
->DnsCache
.HostName
) == 0) {
417 Token
->RspData
.H2AData
= AllocatePool (sizeof (DNS_HOST_TO_ADDR_DATA
));
418 if (Token
->RspData
.H2AData
== NULL
) {
419 Status
= EFI_OUT_OF_RESOURCES
;
423 Token
->RspData
.H2AData
->IpCount
= (UINT32
)Index
;
424 Token
->RspData
.H2AData
->IpList
= AllocatePool (sizeof (EFI_IPv4_ADDRESS
) * Index
);
425 if (Token
->RspData
.H2AData
->IpList
== NULL
) {
426 if (Token
->RspData
.H2AData
!= NULL
) {
427 FreePool (Token
->RspData
.H2AData
);
430 Status
= EFI_OUT_OF_RESOURCES
;
435 NET_LIST_FOR_EACH_SAFE (Entry
, Next
, &mDriverData
->Dns4CacheList
) {
436 Item
= NET_LIST_USER_STRUCT (Entry
, DNS4_CACHE
, AllCacheLink
);
437 if (((UINT32
)Index
< Token
->RspData
.H2AData
->IpCount
) && (StrCmp (HostName
, Item
->DnsCache
.HostName
) == 0)) {
438 CopyMem ((Token
->RspData
.H2AData
->IpList
) + Index
, Item
->DnsCache
.IpAddress
, sizeof (EFI_IPv4_ADDRESS
));
443 Token
->Status
= EFI_SUCCESS
;
445 if (Token
->Event
!= NULL
) {
446 gBS
->SignalEvent (Token
->Event
);
450 Status
= Token
->Status
;
456 // Construct DNS TokenEntry.
458 TokenEntry
= AllocateZeroPool (sizeof (DNS4_TOKEN_ENTRY
));
459 if (TokenEntry
== NULL
) {
460 Status
= EFI_OUT_OF_RESOURCES
;
464 TokenEntry
->PacketToLive
= Token
->RetryInterval
;
465 TokenEntry
->Token
= Token
;
466 TokenEntry
->QueryHostName
= AllocateZeroPool (StrSize (HostName
));
467 if (TokenEntry
->QueryHostName
== NULL
) {
468 Status
= EFI_OUT_OF_RESOURCES
;
472 CopyMem (TokenEntry
->QueryHostName
, HostName
, StrSize (HostName
));
477 QueryName
= NetLibCreateDnsQName (TokenEntry
->QueryHostName
);
478 if (QueryName
== NULL
) {
479 Status
= EFI_OUT_OF_RESOURCES
;
484 // Construct DNS Query Packet.
486 Status
= ConstructDNSQuery (Instance
, QueryName
, DNS_TYPE_A
, DNS_CLASS_INET
, &Packet
);
487 if (EFI_ERROR (Status
)) {
491 ASSERT (Packet
!= NULL
);
494 // Save the token into the Dns4TxTokens map.
496 Status
= NetMapInsertTail (&Instance
->Dns4TxTokens
, TokenEntry
, Packet
);
497 if (EFI_ERROR (Status
)) {
504 Status
= DoDnsQuery (Instance
, Packet
);
505 if (EFI_ERROR (Status
)) {
506 Dns4RemoveTokenEntry (&Instance
->Dns4TxTokens
, TokenEntry
);
511 if (EFI_ERROR (Status
)) {
512 if (TokenEntry
!= NULL
) {
513 if (TokenEntry
->QueryHostName
!= NULL
) {
514 FreePool (TokenEntry
->QueryHostName
);
517 FreePool (TokenEntry
);
520 if (Packet
!= NULL
) {
525 if (QueryName
!= NULL
) {
526 FreePool (QueryName
);
529 gBS
->RestoreTPL (OldTpl
);
534 IPv4 address to host name translation also known as Reverse DNS lookup.
536 The IpToHostName() function is used to translate the host address to host name. A type PTR
537 query is used to get the primary name of the host. Support of this function is optional.
539 @param[in] This Pointer to EFI_DNS4_PROTOCOL instance.
540 @param[in] IpAddress Ip Address.
541 @param[in] Token Point to the completion token to translate host
542 address to host name.
544 @retval EFI_SUCCESS The operation completed successfully.
545 @retval EFI_UNSUPPORTED This function is not supported.
546 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
550 IpAddress is not valid IP address .
551 @retval EFI_NO_MAPPING There's no source address is available for use.
552 @retval EFI_ALREADY_STARTED This Token is being used in another DNS session.
553 @retval EFI_OUT_OF_RESOURCES Failed to allocate needed resources.
558 IN EFI_DNS4_PROTOCOL
*This
,
559 IN EFI_IPv4_ADDRESS IpAddress
,
560 IN EFI_DNS4_COMPLETION_TOKEN
*Token
563 return EFI_UNSUPPORTED
;
567 Retrieve arbitrary information from the DNS server.
569 This GeneralLookup() function retrieves arbitrary information from the DNS. The caller
570 supplies a QNAME, QTYPE, and QCLASS, and all of the matching RRs are returned. All
571 RR content (e.g., TTL) was returned. The caller need parse the returned RR to get
572 required information. The function is optional.
574 @param[in] This Pointer to EFI_DNS4_PROTOCOL instance.
575 @param[in] QName Pointer to Query Name.
576 @param[in] QType Query Type.
577 @param[in] QClass Query Name.
578 @param[in] Token Point to the completion token to retrieve arbitrary
581 @retval EFI_SUCCESS The operation completed successfully.
582 @retval EFI_UNSUPPORTED This function is not supported. Or the requested
583 QType is not supported
584 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
589 @retval EFI_NO_MAPPING There's no source address is available for use.
590 @retval EFI_ALREADY_STARTED This Token is being used in another DNS session.
591 @retval EFI_OUT_OF_RESOURCES Failed to allocate needed resources.
596 IN EFI_DNS4_PROTOCOL
*This
,
600 IN EFI_DNS4_COMPLETION_TOKEN
*Token
605 DNS_INSTANCE
*Instance
;
607 EFI_DNS4_CONFIG_DATA
*ConfigData
;
609 DNS4_TOKEN_ENTRY
*TokenEntry
;
614 Status
= EFI_SUCCESS
;
619 // Validate the parameters
621 if ((This
== NULL
) || (QName
== NULL
) || (Token
== NULL
)) {
622 return EFI_INVALID_PARAMETER
;
625 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
627 Instance
= DNS_INSTANCE_FROM_THIS_PROTOCOL4 (This
);
629 ConfigData
= &(Instance
->Dns4CfgData
);
631 if (Instance
->State
!= DNS_STATE_CONFIGED
) {
632 Status
= EFI_NOT_STARTED
;
636 Token
->Status
= EFI_NOT_READY
;
639 // If zero, use the parameter configured through Dns.Configure() interface.
641 if (Token
->RetryCount
== 0) {
642 Token
->RetryCount
= ConfigData
->RetryCount
;
646 // If zero, use the parameter configured through Dns.Configure() interface.
648 if (Token
->RetryInterval
== 0) {
649 Token
->RetryInterval
= ConfigData
->RetryInterval
;
653 // Minimum interval of retry is 2 second. If the retry interval is less than 2 second, then use the 2 second.
655 if (Token
->RetryInterval
< DNS_DEFAULT_TIMEOUT
) {
656 Token
->RetryInterval
= DNS_DEFAULT_TIMEOUT
;
660 // Construct DNS TokenEntry.
662 TokenEntry
= AllocateZeroPool (sizeof (DNS4_TOKEN_ENTRY
));
663 if (TokenEntry
== NULL
) {
664 Status
= EFI_OUT_OF_RESOURCES
;
668 TokenEntry
->PacketToLive
= Token
->RetryInterval
;
669 TokenEntry
->GeneralLookUp
= TRUE
;
670 TokenEntry
->Token
= Token
;
673 // Construct DNS Query Packet.
675 Status
= ConstructDNSQuery (Instance
, QName
, QType
, QClass
, &Packet
);
676 if (EFI_ERROR (Status
)) {
677 if (TokenEntry
!= NULL
) {
678 FreePool (TokenEntry
);
684 ASSERT (Packet
!= NULL
);
687 // Save the token into the Dns4TxTokens map.
689 Status
= NetMapInsertTail (&Instance
->Dns4TxTokens
, TokenEntry
, Packet
);
690 if (EFI_ERROR (Status
)) {
691 if (TokenEntry
!= NULL
) {
692 FreePool (TokenEntry
);
703 Status
= DoDnsQuery (Instance
, Packet
);
704 if (EFI_ERROR (Status
)) {
705 Dns4RemoveTokenEntry (&Instance
->Dns4TxTokens
, TokenEntry
);
707 if (TokenEntry
!= NULL
) {
708 FreePool (TokenEntry
);
715 gBS
->RestoreTPL (OldTpl
);
720 This function is to update the DNS Cache.
722 The UpdateDnsCache() function is used to add/delete/modify DNS cache entry. DNS cache
723 can be normally dynamically updated after the DNS resolve succeeds. This function
724 provided capability to manually add/delete/modify the DNS cache.
726 @param[in] This Pointer to EFI_DNS4_PROTOCOL instance.
727 @param[in] DeleteFlag If FALSE, this function is to add one entry to the
728 DNS Cache. If TRUE, this function will delete
729 matching DNS Cache entry.
730 @param[in] Override If TRUE, the matching DNS cache entry will be
731 overwritten with the supplied parameter. If FALSE,
732 EFI_ACCESS_DENIED will be returned if the entry to
733 be added is already existed.
734 @param[in] DnsCacheEntry Pointer to DNS Cache entry.
736 @retval EFI_SUCCESS The operation completed successfully.
737 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
739 DnsCacheEntry.HostName is NULL.
740 DnsCacheEntry.IpAddress is NULL.
741 DnsCacheEntry.Timeout is zero.
742 @retval EFI_ACCESS_DENIED The DNS cache entry already exists and Override is
748 IN EFI_DNS4_PROTOCOL
*This
,
749 IN BOOLEAN DeleteFlag
,
751 IN EFI_DNS4_CACHE_ENTRY DnsCacheEntry
757 Status
= EFI_SUCCESS
;
759 if ((DnsCacheEntry
.HostName
== NULL
) || (DnsCacheEntry
.IpAddress
== NULL
) || (DnsCacheEntry
.Timeout
== 0)) {
760 return EFI_INVALID_PARAMETER
;
763 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
766 // Update Dns4Cache here.
768 Status
= UpdateDns4Cache (&mDriverData
->Dns4CacheList
, DeleteFlag
, Override
, DnsCacheEntry
);
770 gBS
->RestoreTPL (OldTpl
);
776 Polls for incoming data packets and processes outgoing data packets.
778 The Poll() function can be used by network drivers and applications to increase the
779 rate that data packets are moved between the communications device and the transmit
781 In some systems, the periodic timer event in the managed network driver may not poll
782 the underlying communications device fast enough to transmit and/or receive all data
783 packets without missing incoming packets or dropping outgoing packets. Drivers and
784 applications that are experiencing packet loss should try calling the Poll()
787 @param[in] This Pointer to EFI_DNS4_PROTOCOL instance.
789 @retval EFI_SUCCESS Incoming or outgoing data was processed.
790 @retval EFI_NOT_STARTED This EFI DNS Protocol instance has not been started.
791 @retval EFI_INVALID_PARAMETER This is NULL.
792 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
793 @retval EFI_TIMEOUT Data was dropped out of the transmit and/or receive
794 queue. Consider increasing the polling rate.
799 IN EFI_DNS4_PROTOCOL
*This
802 DNS_INSTANCE
*Instance
;
803 EFI_UDP4_PROTOCOL
*Udp
;
806 return EFI_INVALID_PARAMETER
;
809 Instance
= DNS_INSTANCE_FROM_THIS_PROTOCOL4 (This
);
811 if (Instance
->State
== DNS_STATE_UNCONFIGED
) {
812 return EFI_NOT_STARTED
;
813 } else if (Instance
->State
== DNS_STATE_DESTROY
) {
814 return EFI_DEVICE_ERROR
;
817 Udp
= Instance
->UdpIo
->Protocol
.Udp4
;
819 return Udp
->Poll (Udp
);
823 Abort an asynchronous DNS operation, including translation between IP and Host, and
824 general look up behavior.
826 The Cancel() function is used to abort a pending resolution request. After calling
827 this function, Token.Status will be set to EFI_ABORTED and then Token.Event will be
828 signaled. If the token is not in one of the queues, which usually means that the
829 asynchronous operation has completed, this function will not signal the token and
830 EFI_NOT_FOUND is returned.
832 @param[in] This Pointer to EFI_DNS4_PROTOCOL instance.
833 @param[in] Token Pointer to a token that has been issued by
834 EFI_DNS4_PROTOCOL.HostNameToIp (),
835 EFI_DNS4_PROTOCOL.IpToHostName() or
836 EFI_DNS4_PROTOCOL.GeneralLookup().
837 If NULL, all pending tokens are aborted.
839 @retval EFI_SUCCESS Incoming or outgoing data was processed.
840 @retval EFI_NOT_STARTED This EFI DNS4 Protocol instance has not been started.
841 @retval EFI_INVALID_PARAMETER This is NULL.
842 @retval EFI_NOT_FOUND When Token is not NULL, and the asynchronous DNS
843 operation was not found in the transmit queue. It
844 was either completed or was not issued by
845 HostNameToIp(), IpToHostName() or GeneralLookup().
850 IN EFI_DNS4_PROTOCOL
*This
,
851 IN EFI_DNS4_COMPLETION_TOKEN
*Token
855 DNS_INSTANCE
*Instance
;
859 return EFI_INVALID_PARAMETER
;
862 Instance
= DNS_INSTANCE_FROM_THIS_PROTOCOL4 (This
);
864 if (Instance
->State
== DNS_STATE_UNCONFIGED
) {
865 return EFI_NOT_STARTED
;
868 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
871 // Cancel the tokens specified by Token for this instance.
873 Status
= Dns4InstanceCancelToken (Instance
, Token
);
876 // Dispatch the DPC queued by the NotifyFunction of the canceled token's events.
880 gBS
->RestoreTPL (OldTpl
);
886 Retrieve mode data of this DNS instance.
888 This function is used to retrieve DNS mode data for this DNS instance.
890 @param[in] This Pointer to EFI_DNS6_PROTOCOL instance.
891 @param[out] DnsModeData Pointer to the caller-allocated storage for the
892 EFI_DNS6_MODE_DATA data.
894 @retval EFI_SUCCESS The operation completed successfully.
895 @retval EFI_NOT_STARTED When DnsConfigData is queried, no configuration data
896 is available because this instance has not been
898 @retval EFI_INVALID_PARAMETER This is NULL or DnsModeData is NULL.
899 @retval EFI_OUT_OF_RESOURCE Failed to allocate needed resources.
904 IN EFI_DNS6_PROTOCOL
*This
,
905 OUT EFI_DNS6_MODE_DATA
*DnsModeData
908 DNS_INSTANCE
*Instance
;
917 DNS6_SERVER_IP
*ServerItem
;
918 EFI_IPv6_ADDRESS
*ServerList
;
919 DNS6_CACHE
*CacheItem
;
920 EFI_DNS6_CACHE_ENTRY
*CacheList
;
927 Status
= EFI_SUCCESS
;
929 if ((This
== NULL
) || (DnsModeData
== NULL
)) {
930 return EFI_INVALID_PARAMETER
;
933 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
935 Instance
= DNS_INSTANCE_FROM_THIS_PROTOCOL6 (This
);
936 if (Instance
->State
== DNS_STATE_UNCONFIGED
) {
937 Status
= EFI_NOT_STARTED
;
941 ZeroMem (DnsModeData
, sizeof (EFI_DNS6_MODE_DATA
));
944 // Get the current configuration data of this instance.
946 Status
= Dns6CopyConfigure (&DnsModeData
->DnsConfigData
, &Instance
->Dns6CfgData
);
947 if (EFI_ERROR (Status
)) {
952 // Get the DnsServerCount and DnsServerList
955 NET_LIST_FOR_EACH_SAFE (Entry
, Next
, &mDriverData
->Dns6ServerList
) {
958 DnsModeData
->DnsServerCount
= (UINT32
)Index
;
959 ServerList
= AllocatePool (sizeof (EFI_IPv6_ADDRESS
) * DnsModeData
->DnsServerCount
);
960 if (ServerList
== NULL
) {
961 Status
= EFI_OUT_OF_RESOURCES
;
962 Dns6CleanConfigure (&DnsModeData
->DnsConfigData
);
967 NET_LIST_FOR_EACH_SAFE (Entry
, Next
, &mDriverData
->Dns6ServerList
) {
968 ServerItem
= NET_LIST_USER_STRUCT (Entry
, DNS6_SERVER_IP
, AllServerLink
);
969 CopyMem (ServerList
+ Index
, &ServerItem
->Dns6ServerIp
, sizeof (EFI_IPv6_ADDRESS
));
972 DnsModeData
->DnsServerList
= ServerList
;
975 // Get the DnsCacheCount and DnsCacheList
978 NET_LIST_FOR_EACH_SAFE (Entry
, Next
, &mDriverData
->Dns6CacheList
) {
981 DnsModeData
->DnsCacheCount
= (UINT32
)Index
;
982 CacheList
= AllocatePool (sizeof (EFI_DNS6_CACHE_ENTRY
) * DnsModeData
->DnsCacheCount
);
983 if (CacheList
== NULL
) {
984 Status
= EFI_OUT_OF_RESOURCES
;
985 Dns6CleanConfigure (&DnsModeData
->DnsConfigData
);
986 FreePool (ServerList
);
991 NET_LIST_FOR_EACH_SAFE (Entry
, Next
, &mDriverData
->Dns6CacheList
) {
992 CacheItem
= NET_LIST_USER_STRUCT (Entry
, DNS6_CACHE
, AllCacheLink
);
993 CopyMem (CacheList
+ Index
, &CacheItem
->DnsCache
, sizeof (EFI_DNS6_CACHE_ENTRY
));
996 DnsModeData
->DnsCacheList
= CacheList
;
999 gBS
->RestoreTPL (OldTpl
);
1004 Configure this DNS instance.
1006 The Configure() function is used to set and change the configuration data for this
1007 EFI DNSv6 Protocol driver instance. Reset the DNS instance if DnsConfigData is NULL.
1009 @param[in] This Pointer to EFI_DNS6_PROTOCOL instance.
1010 @param[in] DnsConfigData Pointer to the configuration data structure. All associated
1011 storage to be allocated and released by caller.
1013 @retval EFI_SUCCESS The operation completed successfully.
1014 @retval EFI_INVALID_PARAMETER This is NULL.
1015 The StationIp address provided in DnsConfigData is not zero and not a valid unicast.
1016 DnsServerList is NULL while DnsServerList Count is not ZERO.
1017 DnsServerList Count is ZERO while DnsServerList is not NULL.
1018 @retval EFI_OUT_OF_RESOURCES The DNS instance data or required space could not be allocated.
1019 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. The
1020 EFI DNSv6 Protocol instance is not configured.
1021 @retval EFI_UNSUPPORTED The designated protocol is not supported.
1022 @retval EFI_ALREADY_STARTED Second call to Configure() with DnsConfigData. To
1023 reconfigure the instance the caller must call Configure() with
1024 NULL first to return driver to unconfigured state.
1029 IN EFI_DNS6_PROTOCOL
*This
,
1030 IN EFI_DNS6_CONFIG_DATA
*DnsConfigData
1034 DNS_INSTANCE
*Instance
;
1038 UINT32 ServerListCount
;
1039 EFI_IPv6_ADDRESS
*ServerList
;
1041 Status
= EFI_SUCCESS
;
1044 if ((This
== NULL
) ||
1045 ((DnsConfigData
!= NULL
) && (((DnsConfigData
->DnsServerCount
!= 0) && (DnsConfigData
->DnsServerList
== NULL
)) ||
1046 ((DnsConfigData
->DnsServerCount
== 0) && (DnsConfigData
->DnsServerList
!= NULL
)))))
1048 return EFI_INVALID_PARAMETER
;
1051 if ((DnsConfigData
!= NULL
) && (DnsConfigData
->Protocol
!= DNS_PROTOCOL_UDP
)) {
1052 return EFI_UNSUPPORTED
;
1055 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
1057 Instance
= DNS_INSTANCE_FROM_THIS_PROTOCOL6 (This
);
1059 if (DnsConfigData
== NULL
) {
1060 ZeroMem (&Instance
->SessionDnsServer
, sizeof (EFI_IP_ADDRESS
));
1063 // Reset the Instance if ConfigData is NULL
1065 if (!NetMapIsEmpty (&Instance
->Dns6TxTokens
)) {
1066 Dns6InstanceCancelToken (Instance
, NULL
);
1069 if (Instance
->UdpIo
!= NULL
) {
1070 UdpIoCleanIo (Instance
->UdpIo
);
1073 if (Instance
->Dns6CfgData
.DnsServerList
!= NULL
) {
1074 FreePool (Instance
->Dns6CfgData
.DnsServerList
);
1077 ZeroMem (&Instance
->Dns6CfgData
, sizeof (EFI_DNS6_CONFIG_DATA
));
1079 Instance
->State
= DNS_STATE_UNCONFIGED
;
1082 // Configure the parameters for new operation.
1084 if (!NetIp6IsUnspecifiedAddr (&DnsConfigData
->StationIp
) && !NetIp6IsValidUnicast (&DnsConfigData
->StationIp
)) {
1085 Status
= EFI_INVALID_PARAMETER
;
1089 Status
= Dns6CopyConfigure (&Instance
->Dns6CfgData
, DnsConfigData
);
1090 if (EFI_ERROR (Status
)) {
1094 if (DnsConfigData
->DnsServerCount
== 0) {
1095 gBS
->RestoreTPL (OldTpl
);
1098 // The DNS instance will retrieve DNS server from DHCP Server.
1100 Status
= GetDns6ServerFromDhcp6 (
1101 Instance
->Service
->ImageHandle
,
1102 Instance
->Service
->ControllerHandle
,
1106 if (EFI_ERROR (Status
)) {
1110 ASSERT (ServerList
!= NULL
);
1112 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
1114 CopyMem (&Instance
->SessionDnsServer
.v6
, &ServerList
[0], sizeof (EFI_IPv6_ADDRESS
));
1116 CopyMem (&Instance
->SessionDnsServer
.v6
, &DnsConfigData
->DnsServerList
[0], sizeof (EFI_IPv6_ADDRESS
));
1122 gBS
->RestoreTPL (OldTpl
);
1123 Status
= Dns6ConfigUdp (Instance
, Instance
->UdpIo
);
1124 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
1125 if (EFI_ERROR (Status
)) {
1126 if (Instance
->Dns6CfgData
.DnsServerList
!= NULL
) {
1127 FreePool (Instance
->Dns6CfgData
.DnsServerList
);
1128 Instance
->Dns6CfgData
.DnsServerList
= NULL
;
1135 // Add configured DNS server used by this instance to ServerList.
1137 Status
= AddDns6ServerIp (&mDriverData
->Dns6ServerList
, Instance
->SessionDnsServer
.v6
);
1138 if (EFI_ERROR (Status
)) {
1139 if (Instance
->Dns6CfgData
.DnsServerList
!= NULL
) {
1140 FreePool (Instance
->Dns6CfgData
.DnsServerList
);
1141 Instance
->Dns6CfgData
.DnsServerList
= NULL
;
1147 Instance
->State
= DNS_STATE_CONFIGED
;
1151 gBS
->RestoreTPL (OldTpl
);
1156 Host name to host address translation.
1158 The HostNameToIp () function is used to translate the host name to host IP address. A
1159 type AAAA query is used to get the one or more IPv6 addresses for this host.
1161 @param[in] This Pointer to EFI_DNS6_PROTOCOL instance.
1162 @param[in] HostName Host name.
1163 @param[in] Token Point to the completion token to translate host name
1166 @retval EFI_SUCCESS The operation completed successfully.
1167 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
1170 Token.Event is NULL.
1171 HostName is NULL or buffer contained unsupported characters.
1172 @retval EFI_NO_MAPPING There's no source address is available for use.
1173 @retval EFI_ALREADY_STARTED This Token is being used in another DNS session.
1174 @retval EFI_NOT_STARTED This instance has not been started.
1175 @retval EFI_OUT_OF_RESOURCES Failed to allocate needed resources.
1180 IN EFI_DNS6_PROTOCOL
*This
,
1181 IN CHAR16
*HostName
,
1182 IN EFI_DNS6_COMPLETION_TOKEN
*Token
1187 DNS_INSTANCE
*Instance
;
1189 EFI_DNS6_CONFIG_DATA
*ConfigData
;
1198 DNS6_TOKEN_ENTRY
*TokenEntry
;
1203 Status
= EFI_SUCCESS
;
1210 // Validate the parameters
1212 if ((This
== NULL
) || (HostName
== NULL
) || (Token
== NULL
)) {
1213 return EFI_INVALID_PARAMETER
;
1216 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
1218 Instance
= DNS_INSTANCE_FROM_THIS_PROTOCOL6 (This
);
1220 ConfigData
= &(Instance
->Dns6CfgData
);
1222 if (Instance
->State
!= DNS_STATE_CONFIGED
) {
1223 Status
= EFI_NOT_STARTED
;
1227 Token
->Status
= EFI_NOT_READY
;
1230 // If zero, use the parameter configured through Dns.Configure() interface.
1232 if (Token
->RetryCount
== 0) {
1233 Token
->RetryCount
= ConfigData
->RetryCount
;
1237 // If zero, use the parameter configured through Dns.Configure() interface.
1239 if (Token
->RetryInterval
== 0) {
1240 Token
->RetryInterval
= ConfigData
->RetryInterval
;
1244 // Minimum interval of retry is 2 second. If the retry interval is less than 2 second, then use the 2 second.
1246 if (Token
->RetryInterval
< DNS_DEFAULT_TIMEOUT
) {
1247 Token
->RetryInterval
= DNS_DEFAULT_TIMEOUT
;
1253 if (ConfigData
->EnableDnsCache
) {
1255 NET_LIST_FOR_EACH_SAFE (Entry
, Next
, &mDriverData
->Dns6CacheList
) {
1256 Item
= NET_LIST_USER_STRUCT (Entry
, DNS6_CACHE
, AllCacheLink
);
1257 if (StrCmp (HostName
, Item
->DnsCache
.HostName
) == 0) {
1263 Token
->RspData
.H2AData
= AllocatePool (sizeof (DNS6_HOST_TO_ADDR_DATA
));
1264 if (Token
->RspData
.H2AData
== NULL
) {
1265 Status
= EFI_OUT_OF_RESOURCES
;
1269 Token
->RspData
.H2AData
->IpCount
= (UINT32
)Index
;
1270 Token
->RspData
.H2AData
->IpList
= AllocatePool (sizeof (EFI_IPv6_ADDRESS
) * Index
);
1271 if (Token
->RspData
.H2AData
->IpList
== NULL
) {
1272 if (Token
->RspData
.H2AData
!= NULL
) {
1273 FreePool (Token
->RspData
.H2AData
);
1276 Status
= EFI_OUT_OF_RESOURCES
;
1281 NET_LIST_FOR_EACH_SAFE (Entry
, Next
, &mDriverData
->Dns6CacheList
) {
1282 Item
= NET_LIST_USER_STRUCT (Entry
, DNS6_CACHE
, AllCacheLink
);
1283 if (((UINT32
)Index
< Token
->RspData
.H2AData
->IpCount
) && (StrCmp (HostName
, Item
->DnsCache
.HostName
) == 0)) {
1284 CopyMem ((Token
->RspData
.H2AData
->IpList
) + Index
, Item
->DnsCache
.IpAddress
, sizeof (EFI_IPv6_ADDRESS
));
1289 Token
->Status
= EFI_SUCCESS
;
1291 if (Token
->Event
!= NULL
) {
1292 gBS
->SignalEvent (Token
->Event
);
1296 Status
= Token
->Status
;
1302 // Construct DNS TokenEntry.
1304 TokenEntry
= AllocateZeroPool (sizeof (DNS6_TOKEN_ENTRY
));
1305 if (TokenEntry
== NULL
) {
1306 Status
= EFI_OUT_OF_RESOURCES
;
1310 TokenEntry
->PacketToLive
= Token
->RetryInterval
;
1311 TokenEntry
->Token
= Token
;
1312 TokenEntry
->QueryHostName
= AllocateZeroPool (StrSize (HostName
));
1313 if (TokenEntry
->QueryHostName
== NULL
) {
1314 Status
= EFI_OUT_OF_RESOURCES
;
1318 CopyMem (TokenEntry
->QueryHostName
, HostName
, StrSize (HostName
));
1323 QueryName
= NetLibCreateDnsQName (TokenEntry
->QueryHostName
);
1324 if (QueryName
== NULL
) {
1325 Status
= EFI_OUT_OF_RESOURCES
;
1330 // Construct DNS Query Packet.
1332 Status
= ConstructDNSQuery (Instance
, QueryName
, DNS_TYPE_AAAA
, DNS_CLASS_INET
, &Packet
);
1333 if (EFI_ERROR (Status
)) {
1337 ASSERT (Packet
!= NULL
);
1340 // Save the token into the Dns6TxTokens map.
1342 Status
= NetMapInsertTail (&Instance
->Dns6TxTokens
, TokenEntry
, Packet
);
1343 if (EFI_ERROR (Status
)) {
1350 Status
= DoDnsQuery (Instance
, Packet
);
1351 if (EFI_ERROR (Status
)) {
1352 Dns6RemoveTokenEntry (&Instance
->Dns6TxTokens
, TokenEntry
);
1357 if (EFI_ERROR (Status
)) {
1358 if (TokenEntry
!= NULL
) {
1359 if (TokenEntry
->QueryHostName
!= NULL
) {
1360 FreePool (TokenEntry
->QueryHostName
);
1363 FreePool (TokenEntry
);
1366 if (Packet
!= NULL
) {
1367 NetbufFree (Packet
);
1371 if (QueryName
!= NULL
) {
1372 FreePool (QueryName
);
1375 gBS
->RestoreTPL (OldTpl
);
1380 Host address to host name translation.
1382 The IpToHostName () function is used to translate the host address to host name. A
1383 type PTR query is used to get the primary name of the host. Implementation can choose
1384 to support this function or not.
1386 @param[in] This Pointer to EFI_DNS6_PROTOCOL instance.
1387 @param[in] IpAddress Ip Address.
1388 @param[in] Token Point to the completion token to translate host
1389 address to host name.
1391 @retval EFI_SUCCESS The operation completed successfully.
1392 @retval EFI_UNSUPPORTED This function is not supported.
1393 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
1396 Token.Event is NULL.
1397 IpAddress is not valid IP address.
1398 @retval EFI_NO_MAPPING There's no source address is available for use.
1399 @retval EFI_NOT_STARTED This instance has not been started.
1400 @retval EFI_OUT_OF_RESOURCES Failed to allocate needed resources.
1405 IN EFI_DNS6_PROTOCOL
*This
,
1406 IN EFI_IPv6_ADDRESS IpAddress
,
1407 IN EFI_DNS6_COMPLETION_TOKEN
*Token
1410 return EFI_UNSUPPORTED
;
1414 This function provides capability to retrieve arbitrary information from the DNS
1417 This GeneralLookup() function retrieves arbitrary information from the DNS. The caller
1418 supplies a QNAME, QTYPE, and QCLASS, and all of the matching RRs are returned. All
1419 RR content (e.g., TTL) was returned. The caller need parse the returned RR to get
1420 required information. The function is optional. Implementation can choose to support
1423 @param[in] This Pointer to EFI_DNS6_PROTOCOL instance.
1424 @param[in] QName Pointer to Query Name.
1425 @param[in] QType Query Type.
1426 @param[in] QClass Query Name.
1427 @param[in] Token Point to the completion token to retrieve arbitrary
1430 @retval EFI_SUCCESS The operation completed successfully.
1431 @retval EFI_UNSUPPORTED This function is not supported. Or the requested
1432 QType is not supported
1433 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
1436 Token.Event is NULL.
1438 @retval EFI_NO_MAPPING There's no source address is available for use.
1439 @retval EFI_NOT_STARTED This instance has not been started.
1440 @retval EFI_OUT_OF_RESOURCES Failed to allocate needed resources.
1445 IN EFI_DNS6_PROTOCOL
*This
,
1449 IN EFI_DNS6_COMPLETION_TOKEN
*Token
1454 DNS_INSTANCE
*Instance
;
1456 EFI_DNS6_CONFIG_DATA
*ConfigData
;
1458 DNS6_TOKEN_ENTRY
*TokenEntry
;
1463 Status
= EFI_SUCCESS
;
1468 // Validate the parameters
1470 if ((This
== NULL
) || (QName
== NULL
) || (Token
== NULL
)) {
1471 return EFI_INVALID_PARAMETER
;
1474 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
1476 Instance
= DNS_INSTANCE_FROM_THIS_PROTOCOL6 (This
);
1478 ConfigData
= &(Instance
->Dns6CfgData
);
1480 if (Instance
->State
!= DNS_STATE_CONFIGED
) {
1481 Status
= EFI_NOT_STARTED
;
1485 Token
->Status
= EFI_NOT_READY
;
1488 // If zero, use the parameter configured through Dns.Configure() interface.
1490 if (Token
->RetryCount
== 0) {
1491 Token
->RetryCount
= ConfigData
->RetryCount
;
1495 // If zero, use the parameter configured through Dns.Configure() interface.
1497 if (Token
->RetryInterval
== 0) {
1498 Token
->RetryInterval
= ConfigData
->RetryInterval
;
1502 // Minimum interval of retry is 2 second. If the retry interval is less than 2 second, then use the 2 second.
1504 if (Token
->RetryInterval
< DNS_DEFAULT_TIMEOUT
) {
1505 Token
->RetryInterval
= DNS_DEFAULT_TIMEOUT
;
1509 // Construct DNS TokenEntry.
1511 TokenEntry
= AllocateZeroPool (sizeof (DNS6_TOKEN_ENTRY
));
1512 if (TokenEntry
== NULL
) {
1513 Status
= EFI_OUT_OF_RESOURCES
;
1517 TokenEntry
->PacketToLive
= Token
->RetryInterval
;
1518 TokenEntry
->GeneralLookUp
= TRUE
;
1519 TokenEntry
->Token
= Token
;
1522 // Construct DNS Query Packet.
1524 Status
= ConstructDNSQuery (Instance
, QName
, QType
, QClass
, &Packet
);
1525 if (EFI_ERROR (Status
)) {
1526 if (TokenEntry
!= NULL
) {
1527 FreePool (TokenEntry
);
1533 ASSERT (Packet
!= NULL
);
1536 // Save the token into the Dns6TxTokens map.
1538 Status
= NetMapInsertTail (&Instance
->Dns6TxTokens
, TokenEntry
, Packet
);
1539 if (EFI_ERROR (Status
)) {
1540 if (TokenEntry
!= NULL
) {
1541 FreePool (TokenEntry
);
1544 NetbufFree (Packet
);
1552 Status
= DoDnsQuery (Instance
, Packet
);
1553 if (EFI_ERROR (Status
)) {
1554 Dns6RemoveTokenEntry (&Instance
->Dns6TxTokens
, TokenEntry
);
1556 if (TokenEntry
!= NULL
) {
1557 FreePool (TokenEntry
);
1560 NetbufFree (Packet
);
1564 gBS
->RestoreTPL (OldTpl
);
1569 This function is to update the DNS Cache.
1571 The UpdateDnsCache() function is used to add/delete/modify DNS cache entry. DNS cache
1572 can be normally dynamically updated after the DNS resolve succeeds. This function
1573 provided capability to manually add/delete/modify the DNS cache.
1575 @param[in] This Pointer to EFI_DNS6_PROTOCOL instance.
1576 @param[in] DeleteFlag If FALSE, this function is to add one entry to the
1577 DNS Cache. If TRUE, this function will delete
1578 matching DNS Cache entry.
1579 @param[in] Override If TRUE, the matching DNS cache entry will be
1580 overwritten with the supplied parameter. If FALSE,
1581 EFI_ACCESS_DENIED will be returned if the entry to
1582 be added is already existed.
1583 @param[in] DnsCacheEntry Pointer to DNS Cache entry.
1585 @retval EFI_SUCCESS The operation completed successfully.
1586 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
1588 DnsCacheEntry.HostName is NULL.
1589 DnsCacheEntry.IpAddress is NULL.
1590 DnsCacheEntry.Timeout is zero.
1591 @retval EFI_ACCESS_DENIED The DNS cache entry already exists and Override is
1593 @retval EFI_OUT_OF_RESOURCE Failed to allocate needed resources.
1597 Dns6UpdateDnsCache (
1598 IN EFI_DNS6_PROTOCOL
*This
,
1599 IN BOOLEAN DeleteFlag
,
1600 IN BOOLEAN Override
,
1601 IN EFI_DNS6_CACHE_ENTRY DnsCacheEntry
1607 Status
= EFI_SUCCESS
;
1609 if ((DnsCacheEntry
.HostName
== NULL
) || (DnsCacheEntry
.IpAddress
== NULL
) || (DnsCacheEntry
.Timeout
== 0)) {
1610 return EFI_INVALID_PARAMETER
;
1613 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
1616 // Update Dns6Cache here.
1618 Status
= UpdateDns6Cache (&mDriverData
->Dns6CacheList
, DeleteFlag
, Override
, DnsCacheEntry
);
1620 gBS
->RestoreTPL (OldTpl
);
1626 Polls for incoming data packets and processes outgoing data packets.
1628 The Poll() function can be used by network drivers and applications to increase the
1629 rate that data packets are moved between the communications device and the transmit
1632 In some systems, the periodic timer event in the managed network driver may not poll
1633 the underlying communications device fast enough to transmit and/or receive all data
1634 packets without missing incoming packets or dropping outgoing packets. Drivers and
1635 applications that are experiencing packet loss should try calling the Poll()
1636 function more often.
1638 @param[in] This Pointer to EFI_DNS6_PROTOCOL instance.
1640 @retval EFI_SUCCESS Incoming or outgoing data was processed.
1641 @retval EFI_NOT_STARTED This EFI DNS Protocol instance has not been started.
1642 @retval EFI_INVALID_PARAMETER This is NULL.
1643 @retval EFI_NO_MAPPING There is no source address is available for use.
1644 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
1645 @retval EFI_TIMEOUT Data was dropped out of the transmit and/or receive
1646 queue. Consider increasing the polling rate.
1651 IN EFI_DNS6_PROTOCOL
*This
1654 DNS_INSTANCE
*Instance
;
1655 EFI_UDP6_PROTOCOL
*Udp
;
1658 return EFI_INVALID_PARAMETER
;
1661 Instance
= DNS_INSTANCE_FROM_THIS_PROTOCOL6 (This
);
1663 if (Instance
->State
== DNS_STATE_UNCONFIGED
) {
1664 return EFI_NOT_STARTED
;
1665 } else if (Instance
->State
== DNS_STATE_DESTROY
) {
1666 return EFI_DEVICE_ERROR
;
1669 Udp
= Instance
->UdpIo
->Protocol
.Udp6
;
1671 return Udp
->Poll (Udp
);
1675 Abort an asynchronous DNS operation, including translation between IP and Host, and
1676 general look up behavior.
1678 The Cancel() function is used to abort a pending resolution request. After calling
1679 this function, Token.Status will be set to EFI_ABORTED and then Token.Event will be
1680 signaled. If the token is not in one of the queues, which usually means that the
1681 asynchronous operation has completed, this function will not signal the token and
1682 EFI_NOT_FOUND is returned.
1684 @param[in] This Pointer to EFI_DNS6_PROTOCOL instance.
1685 @param[in] Token Pointer to a token that has been issued by
1686 EFI_DNS6_PROTOCOL.HostNameToIp (),
1687 EFI_DNS6_PROTOCOL.IpToHostName() or
1688 EFI_DNS6_PROTOCOL.GeneralLookup().
1689 If NULL, all pending tokens are aborted.
1691 @retval EFI_SUCCESS Incoming or outgoing data was processed.
1692 @retval EFI_NOT_STARTED This EFI DNS6 Protocol instance has not been started.
1693 @retval EFI_INVALID_PARAMETER This is NULL.
1694 @retval EFI_NO_MAPPING There's no source address is available for use.
1695 @retval EFI_NOT_FOUND When Token is not NULL, and the asynchronous DNS
1696 operation was not found in the transmit queue. It
1697 was either completed or was not issued by
1698 HostNameToIp(), IpToHostName() or GeneralLookup().
1703 IN EFI_DNS6_PROTOCOL
*This
,
1704 IN EFI_DNS6_COMPLETION_TOKEN
*Token
1708 DNS_INSTANCE
*Instance
;
1712 return EFI_INVALID_PARAMETER
;
1715 Instance
= DNS_INSTANCE_FROM_THIS_PROTOCOL6 (This
);
1717 if (Instance
->State
== DNS_STATE_UNCONFIGED
) {
1718 return EFI_NOT_STARTED
;
1721 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
1724 // Cancel the tokens specified by Token for this instance.
1726 Status
= Dns6InstanceCancelToken (Instance
, Token
);
1729 // Dispatch the DPC queued by the NotifyFunction of the canceled token's events.
1733 gBS
->RestoreTPL (OldTpl
);