2 Implementation of EFI_DNS4_PROTOCOL and EFI_DNS6_PROTOCOL interfaces.
4 Copyright (c) 2015 - 2017, 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
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.
17 EFI_DNS4_PROTOCOL mDns4Protocol
= {
28 EFI_DNS6_PROTOCOL mDns6Protocol
= {
40 Retrieve mode data of this DNS instance.
42 This function is used to retrieve DNS mode data for this DNS instance.
44 @param[in] This Pointer to EFI_DNS4_PROTOCOL instance.
45 @param[out] DnsModeData Point to the mode data.
47 @retval EFI_SUCCESS The operation completed successfully.
48 @retval EFI_NOT_STARTED When DnsConfigData is queried, no configuration data
49 is available because this instance has not been
51 @retval EFI_INVALID_PARAMETER This is NULL or DnsModeData is NULL.
52 @retval EFI_OUT_OF_RESOURCES Failed to allocate needed resources.
57 IN EFI_DNS4_PROTOCOL
*This
,
58 OUT EFI_DNS4_MODE_DATA
*DnsModeData
61 DNS_INSTANCE
*Instance
;
70 DNS4_SERVER_IP
*ServerItem
;
71 EFI_IPv4_ADDRESS
*ServerList
;
72 DNS4_CACHE
*CacheItem
;
73 EFI_DNS4_CACHE_ENTRY
*CacheList
;
83 if ((This
== NULL
) || (DnsModeData
== NULL
)) {
84 return EFI_INVALID_PARAMETER
;
87 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
89 Instance
= DNS_INSTANCE_FROM_THIS_PROTOCOL4 (This
);
90 if (Instance
->State
== DNS_STATE_UNCONFIGED
) {
91 Status
= EFI_NOT_STARTED
;
95 ZeroMem (DnsModeData
, sizeof (EFI_DNS4_MODE_DATA
));
98 // Get the current configuration data of this instance.
100 Status
= Dns4CopyConfigure (&DnsModeData
->DnsConfigData
, &Instance
->Dns4CfgData
);
101 if (EFI_ERROR (Status
)) {
106 // Get the DnsServerCount and DnsServerList
109 NET_LIST_FOR_EACH_SAFE (Entry
, Next
, &mDriverData
->Dns4ServerList
) {
112 DnsModeData
->DnsServerCount
= (UINT32
) Index
;
113 ServerList
= AllocatePool (sizeof (EFI_IPv4_ADDRESS
) * DnsModeData
->DnsServerCount
);
114 if (ServerList
== NULL
) {
115 Status
= EFI_OUT_OF_RESOURCES
;
116 Dns4CleanConfigure (&DnsModeData
->DnsConfigData
);
121 NET_LIST_FOR_EACH_SAFE (Entry
, Next
, &mDriverData
->Dns4ServerList
) {
122 ServerItem
= NET_LIST_USER_STRUCT (Entry
, DNS4_SERVER_IP
, AllServerLink
);
123 CopyMem (ServerList
+ Index
, &ServerItem
->Dns4ServerIp
, sizeof (EFI_IPv4_ADDRESS
));
126 DnsModeData
->DnsServerList
= ServerList
;
129 // Get the DnsCacheCount and DnsCacheList
132 NET_LIST_FOR_EACH_SAFE (Entry
, Next
, &mDriverData
->Dns4CacheList
) {
135 DnsModeData
->DnsCacheCount
= (UINT32
) Index
;
136 CacheList
= AllocatePool (sizeof (EFI_DNS4_CACHE_ENTRY
) * DnsModeData
->DnsCacheCount
);
137 if (CacheList
== NULL
) {
138 Status
= EFI_OUT_OF_RESOURCES
;
139 Dns4CleanConfigure (&DnsModeData
->DnsConfigData
);
140 FreePool (ServerList
);
145 NET_LIST_FOR_EACH_SAFE (Entry
, Next
, &mDriverData
->Dns4CacheList
) {
146 CacheItem
= NET_LIST_USER_STRUCT (Entry
, DNS4_CACHE
, AllCacheLink
);
147 CopyMem (CacheList
+ Index
, &CacheItem
->DnsCache
, sizeof (EFI_DNS4_CACHE_ENTRY
));
150 DnsModeData
->DnsCacheList
= CacheList
;
153 gBS
->RestoreTPL (OldTpl
);
158 Configure this DNS instance.
160 This function is used to configure DNS mode data for this DNS instance.
162 @param[in] This Pointer to EFI_DNS4_PROTOCOL instance.
163 @param[in] DnsConfigData Point to the Configuration data.
165 @retval EFI_SUCCESS The operation completed successfully.
166 @retval EFI_UNSUPPORTED The designated protocol is not supported.
167 @retval EFI_INVALID_PARAMTER Thisis NULL.
168 The StationIp address provided in DnsConfigData is not a
170 DnsServerList is NULL while DnsServerListCount
172 DnsServerListCount is ZERO while DnsServerList
174 @retval EFI_OUT_OF_RESOURCES The DNS instance data or required space could not be
176 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. The
177 EFI DNSv4 Protocol instance is not configured.
178 @retval EFI_ALREADY_STARTED Second call to Configure() with DnsConfigData. To
179 reconfigure the instance the caller must call Configure()
180 with NULL first to return driver to unconfigured state.
185 IN EFI_DNS4_PROTOCOL
*This
,
186 IN EFI_DNS4_CONFIG_DATA
*DnsConfigData
190 DNS_INSTANCE
*Instance
;
196 UINT32 ServerListCount
;
197 EFI_IPv4_ADDRESS
*ServerList
;
199 Status
= EFI_SUCCESS
;
203 (DnsConfigData
!= NULL
&& ((DnsConfigData
->DnsServerListCount
!= 0 && DnsConfigData
->DnsServerList
== NULL
) ||
204 (DnsConfigData
->DnsServerListCount
== 0 && DnsConfigData
->DnsServerList
!= NULL
)))) {
205 return EFI_INVALID_PARAMETER
;
208 if (DnsConfigData
!= NULL
&& DnsConfigData
->Protocol
!= DNS_PROTOCOL_UDP
) {
209 return EFI_UNSUPPORTED
;
212 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
214 Instance
= DNS_INSTANCE_FROM_THIS_PROTOCOL4 (This
);
216 if (DnsConfigData
== NULL
) {
217 ZeroMem (&Instance
->SessionDnsServer
, sizeof (EFI_IP_ADDRESS
));
220 // Reset the Instance if ConfigData is NULL
222 if (!NetMapIsEmpty(&Instance
->Dns4TxTokens
)) {
223 Dns4InstanceCancelToken(Instance
, NULL
);
226 Instance
->MaxRetry
= 0;
228 if (Instance
->UdpIo
!= NULL
){
229 UdpIoCleanIo (Instance
->UdpIo
);
232 if (Instance
->Dns4CfgData
.DnsServerList
!= NULL
) {
233 FreePool (Instance
->Dns4CfgData
.DnsServerList
);
235 ZeroMem (&Instance
->Dns4CfgData
, sizeof (EFI_DNS4_CONFIG_DATA
));
237 Instance
->State
= DNS_STATE_UNCONFIGED
;
240 // Configure the parameters for new operation.
242 CopyMem (&Ip
, &DnsConfigData
->StationIp
, sizeof (IP4_ADDR
));
243 CopyMem (&Netmask
, &DnsConfigData
->SubnetMask
, sizeof (IP4_ADDR
));
246 Netmask
= NTOHL (Netmask
);
248 if (!DnsConfigData
->UseDefaultSetting
&&
249 ((!IP4_IS_VALID_NETMASK (Netmask
) || (Netmask
!= 0 && !NetIp4IsUnicast (Ip
, Netmask
))))) {
250 Status
= EFI_INVALID_PARAMETER
;
254 Status
= Dns4CopyConfigure (&Instance
->Dns4CfgData
, DnsConfigData
);
255 if (EFI_ERROR (Status
)) {
259 if (DnsConfigData
->DnsServerListCount
== 0 || DnsConfigData
->DnsServerList
== NULL
) {
260 gBS
->RestoreTPL (OldTpl
);
263 // The DNS instance will retrieve DNS server from DHCP Server
265 Status
= GetDns4ServerFromDhcp4 (
270 if (EFI_ERROR (Status
)) {
274 ASSERT(ServerList
!= NULL
);
276 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
278 CopyMem (&Instance
->SessionDnsServer
.v4
, &ServerList
[0], sizeof (EFI_IPv4_ADDRESS
));
280 CopyMem (&Instance
->SessionDnsServer
.v4
, &DnsConfigData
->DnsServerList
[0], sizeof (EFI_IPv4_ADDRESS
));
286 Status
= Dns4ConfigUdp (Instance
, Instance
->UdpIo
);
287 if (EFI_ERROR (Status
)) {
288 if (Instance
->Dns4CfgData
.DnsServerList
!= NULL
) {
289 FreePool (Instance
->Dns4CfgData
.DnsServerList
);
290 Instance
->Dns4CfgData
.DnsServerList
= NULL
;
296 // Add configured DNS server used by this instance to ServerList.
298 Status
= AddDns4ServerIp (&mDriverData
->Dns4ServerList
, Instance
->SessionDnsServer
.v4
);
299 if (EFI_ERROR (Status
)) {
300 if (Instance
->Dns4CfgData
.DnsServerList
!= NULL
) {
301 FreePool (Instance
->Dns4CfgData
.DnsServerList
);
302 Instance
->Dns4CfgData
.DnsServerList
= NULL
;
307 Instance
->State
= DNS_STATE_CONFIGED
;
311 gBS
->RestoreTPL (OldTpl
);
316 Host name to host address translation.
318 The HostNameToIp () function is used to translate the host name to host IP address. A
319 type A query is used to get the one or more IP addresses for this host.
321 @param[in] This Pointer to EFI_DNS4_PROTOCOL instance.
322 @param[in] HostName Host name.
323 @param[in] Token Point to the completion token to translate host name
326 @retval EFI_SUCCESS The operation completed successfully.
327 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
331 HostName is NULL. HostName string is unsupported format.
332 @retval EFI_NO_MAPPING There's no source address is available for use.
333 @retval EFI_NOT_STARTED This instance has not been started.
338 IN EFI_DNS4_PROTOCOL
*This
,
340 IN EFI_DNS4_COMPLETION_TOKEN
*Token
345 DNS_INSTANCE
*Instance
;
347 EFI_DNS4_CONFIG_DATA
*ConfigData
;
356 DNS4_TOKEN_ENTRY
*TokenEntry
;
361 Status
= EFI_SUCCESS
;
368 // Validate the parameters
370 if ((This
== NULL
) || (HostName
== NULL
) || Token
== NULL
) {
371 return EFI_INVALID_PARAMETER
;
374 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
376 Instance
= DNS_INSTANCE_FROM_THIS_PROTOCOL4 (This
);
378 ConfigData
= &(Instance
->Dns4CfgData
);
380 Instance
->MaxRetry
= ConfigData
->RetryCount
;
382 Token
->Status
= EFI_NOT_READY
;
383 Token
->RetryCount
= 0;
384 Token
->RetryInterval
= ConfigData
->RetryInterval
;
386 if (Instance
->State
!= DNS_STATE_CONFIGED
) {
387 Status
= EFI_NOT_STARTED
;
392 // Check the MaxRetry and RetryInterval values.
394 if (Instance
->MaxRetry
== 0) {
395 Instance
->MaxRetry
= DNS_DEFAULT_RETRY
;
398 if (Token
->RetryInterval
< DNS_DEFAULT_TIMEOUT
) {
399 Token
->RetryInterval
= DNS_DEFAULT_TIMEOUT
;
405 if (ConfigData
->EnableDnsCache
) {
407 NET_LIST_FOR_EACH_SAFE (Entry
, Next
, &mDriverData
->Dns4CacheList
) {
408 Item
= NET_LIST_USER_STRUCT (Entry
, DNS4_CACHE
, AllCacheLink
);
409 if (StrCmp (HostName
, Item
->DnsCache
.HostName
) == 0) {
415 Token
->RspData
.H2AData
= AllocatePool (sizeof (DNS_HOST_TO_ADDR_DATA
));
416 if (Token
->RspData
.H2AData
== NULL
) {
417 Status
= EFI_OUT_OF_RESOURCES
;
421 Token
->RspData
.H2AData
->IpCount
= (UINT32
)Index
;
422 Token
->RspData
.H2AData
->IpList
= AllocatePool (sizeof (EFI_IPv4_ADDRESS
) * Index
);
423 if (Token
->RspData
.H2AData
->IpList
== NULL
) {
424 if (Token
->RspData
.H2AData
!= NULL
) {
425 FreePool (Token
->RspData
.H2AData
);
428 Status
= EFI_OUT_OF_RESOURCES
;
433 NET_LIST_FOR_EACH_SAFE (Entry
, Next
, &mDriverData
->Dns4CacheList
) {
434 Item
= NET_LIST_USER_STRUCT (Entry
, DNS4_CACHE
, AllCacheLink
);
435 if ((UINT32
)Index
< Token
->RspData
.H2AData
->IpCount
&& StrCmp (HostName
, Item
->DnsCache
.HostName
) == 0) {
436 CopyMem ((Token
->RspData
.H2AData
->IpList
) + Index
, Item
->DnsCache
.IpAddress
, sizeof (EFI_IPv4_ADDRESS
));
441 Token
->Status
= EFI_SUCCESS
;
443 if (Token
->Event
!= NULL
) {
444 gBS
->SignalEvent (Token
->Event
);
448 Status
= Token
->Status
;
454 // Construct DNS TokenEntry.
456 TokenEntry
= AllocateZeroPool (sizeof(DNS4_TOKEN_ENTRY
));
457 if (TokenEntry
== NULL
) {
458 Status
= EFI_OUT_OF_RESOURCES
;
462 TokenEntry
->PacketToLive
= Token
->RetryInterval
;
463 TokenEntry
->QueryHostName
= HostName
;
464 TokenEntry
->Token
= Token
;
469 QueryName
= NetLibCreateDnsQName (TokenEntry
->QueryHostName
);
470 if (QueryName
== NULL
) {
471 Status
= EFI_OUT_OF_RESOURCES
;
476 // Construct DNS Query Packet.
478 Status
= ConstructDNSQuery (Instance
, QueryName
, DNS_TYPE_A
, DNS_CLASS_INET
, &Packet
);
479 if (EFI_ERROR (Status
)) {
480 if (TokenEntry
!= NULL
) {
481 FreePool (TokenEntry
);
487 ASSERT (Packet
!= NULL
);
490 // Save the token into the Dns4TxTokens map.
492 Status
= NetMapInsertTail (&Instance
->Dns4TxTokens
, TokenEntry
, Packet
);
493 if (EFI_ERROR (Status
)) {
494 if (TokenEntry
!= NULL
) {
495 FreePool (TokenEntry
);
506 Status
= DoDnsQuery (Instance
, Packet
);
507 if (EFI_ERROR (Status
)) {
508 Dns4RemoveTokenEntry (&Instance
->Dns4TxTokens
, TokenEntry
);
510 if (TokenEntry
!= NULL
) {
511 FreePool (TokenEntry
);
518 if (QueryName
!= NULL
) {
519 FreePool (QueryName
);
522 gBS
->RestoreTPL (OldTpl
);
527 IPv4 address to host name translation also known as Reverse DNS lookup.
529 The IpToHostName() function is used to translate the host address to host name. A type PTR
530 query is used to get the primary name of the host. Support of this function is optional.
532 @param[in] This Pointer to EFI_DNS4_PROTOCOL instance.
533 @param[in] IpAddress Ip Address.
534 @param[in] Token Point to the completion token to translate host
535 address to host name.
537 @retval EFI_SUCCESS The operation completed successfully.
538 @retval EFI_UNSUPPORTED This function is not supported.
539 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
543 IpAddress is not valid IP address .
544 @retval EFI_NO_MAPPING There's no source address is available for use.
545 @retval EFI_ALREADY_STARTED This Token is being used in another DNS session.
546 @retval EFI_OUT_OF_RESOURCES Failed to allocate needed resources.
551 IN EFI_DNS4_PROTOCOL
*This
,
552 IN EFI_IPv4_ADDRESS IpAddress
,
553 IN EFI_DNS4_COMPLETION_TOKEN
*Token
556 return EFI_UNSUPPORTED
;
560 Retrieve arbitrary information from the DNS server.
562 This GeneralLookup() function retrieves arbitrary information from the DNS. The caller
563 supplies a QNAME, QTYPE, and QCLASS, and all of the matching RRs are returned. All
564 RR content (e.g., TTL) was returned. The caller need parse the returned RR to get
565 required information. The function is optional.
567 @param[in] This Pointer to EFI_DNS4_PROTOCOL instance.
568 @param[in] QName Pointer to Query Name.
569 @param[in] QType Query Type.
570 @param[in] QClass Query Name.
571 @param[in] Token Point to the completion token to retrieve arbitrary
574 @retval EFI_SUCCESS The operation completed successfully.
575 @retval EFI_UNSUPPORTED This function is not supported. Or the requested
576 QType is not supported
577 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
582 @retval EFI_NO_MAPPING There's no source address is available for use.
583 @retval EFI_ALREADY_STARTED This Token is being used in another DNS session.
584 @retval EFI_OUT_OF_RESOURCES Failed to allocate needed resources.
589 IN EFI_DNS4_PROTOCOL
*This
,
593 IN EFI_DNS4_COMPLETION_TOKEN
*Token
598 DNS_INSTANCE
*Instance
;
600 EFI_DNS4_CONFIG_DATA
*ConfigData
;
602 DNS4_TOKEN_ENTRY
*TokenEntry
;
607 Status
= EFI_SUCCESS
;
612 // Validate the parameters
614 if ((This
== NULL
) || (QName
== NULL
) || Token
== NULL
) {
615 return EFI_INVALID_PARAMETER
;
618 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
620 Instance
= DNS_INSTANCE_FROM_THIS_PROTOCOL4 (This
);
622 ConfigData
= &(Instance
->Dns4CfgData
);
624 Instance
->MaxRetry
= ConfigData
->RetryCount
;
626 Token
->Status
= EFI_NOT_READY
;
627 Token
->RetryCount
= 0;
628 Token
->RetryInterval
= ConfigData
->RetryInterval
;
630 if (Instance
->State
!= DNS_STATE_CONFIGED
) {
631 Status
= EFI_NOT_STARTED
;
636 // Check the MaxRetry and RetryInterval values.
638 if (Instance
->MaxRetry
== 0) {
639 Instance
->MaxRetry
= DNS_DEFAULT_RETRY
;
642 if (Token
->RetryInterval
< DNS_DEFAULT_TIMEOUT
) {
643 Token
->RetryInterval
= DNS_DEFAULT_TIMEOUT
;
647 // Construct DNS TokenEntry.
649 TokenEntry
= AllocateZeroPool (sizeof(DNS4_TOKEN_ENTRY
));
650 if (TokenEntry
== NULL
) {
651 Status
= EFI_OUT_OF_RESOURCES
;
655 TokenEntry
->PacketToLive
= Token
->RetryInterval
;
656 TokenEntry
->GeneralLookUp
= TRUE
;
657 TokenEntry
->Token
= Token
;
660 // Construct DNS Query Packet.
662 Status
= ConstructDNSQuery (Instance
, QName
, QType
, QClass
, &Packet
);
663 if (EFI_ERROR (Status
)) {
664 if (TokenEntry
!= NULL
) {
665 FreePool (TokenEntry
);
671 ASSERT (Packet
!= NULL
);
674 // Save the token into the Dns4TxTokens map.
676 Status
= NetMapInsertTail (&Instance
->Dns4TxTokens
, TokenEntry
, Packet
);
677 if (EFI_ERROR (Status
)) {
678 if (TokenEntry
!= NULL
) {
679 FreePool (TokenEntry
);
690 Status
= DoDnsQuery (Instance
, Packet
);
691 if (EFI_ERROR (Status
)) {
692 Dns4RemoveTokenEntry (&Instance
->Dns4TxTokens
, TokenEntry
);
694 if (TokenEntry
!= NULL
) {
695 FreePool (TokenEntry
);
702 gBS
->RestoreTPL (OldTpl
);
707 This function is to update the DNS Cache.
709 The UpdateDnsCache() function is used to add/delete/modify DNS cache entry. DNS cache
710 can be normally dynamically updated after the DNS resolve succeeds. This function
711 provided capability to manually add/delete/modify the DNS cache.
713 @param[in] This Pointer to EFI_DNS4_PROTOCOL instance.
714 @param[in] DeleteFlag If FALSE, this function is to add one entry to the
715 DNS Cahce. If TRUE, this function will delete
716 matching DNS Cache entry.
717 @param[in] Override If TRUE, the maching DNS cache entry will be
718 overwritten with the supplied parameter. If FALSE,
719 EFI_ACCESS_DENIED will be returned if the entry to
720 be added is already existed.
721 @param[in] DnsCacheEntry Pointer to DNS Cache entry.
723 @retval EFI_SUCCESS The operation completed successfully.
724 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
726 DnsCacheEntry.HostName is NULL.
727 DnsCacheEntry.IpAddress is NULL.
728 DnsCacheEntry.Timeout is zero.
729 @retval EFI_ACCESS_DENIED The DNS cache entry already exists and Override is
735 IN EFI_DNS4_PROTOCOL
*This
,
736 IN BOOLEAN DeleteFlag
,
738 IN EFI_DNS4_CACHE_ENTRY DnsCacheEntry
744 Status
= EFI_SUCCESS
;
746 if (DnsCacheEntry
.HostName
== NULL
|| DnsCacheEntry
.IpAddress
== NULL
|| DnsCacheEntry
.Timeout
== 0) {
747 return EFI_INVALID_PARAMETER
;
750 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
753 // Update Dns4Cache here.
755 Status
= UpdateDns4Cache (&mDriverData
->Dns4CacheList
, DeleteFlag
, Override
, DnsCacheEntry
);
757 gBS
->RestoreTPL (OldTpl
);
763 Polls for incoming data packets and processes outgoing data packets.
765 The Poll() function can be used by network drivers and applications to increase the
766 rate that data packets are moved between the communications device and the transmit
768 In some systems, the periodic timer event in the managed network driver may not poll
769 the underlying communications device fast enough to transmit and/or receive all data
770 packets without missing incoming packets or dropping outgoing packets. Drivers and
771 applications that are experiencing packet loss should try calling the Poll()
774 @param[in] This Pointer to EFI_DNS4_PROTOCOL instance.
776 @retval EFI_SUCCESS Incoming or outgoing data was processed.
777 @retval EFI_NOT_STARTED This EFI DNS Protocol instance has not been started.
778 @retval EFI_INVALID_PARAMETER This is NULL.
779 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
780 @retval EFI_TIMEOUT Data was dropped out of the transmit and/or receive
781 queue. Consider increasing the polling rate.
786 IN EFI_DNS4_PROTOCOL
*This
789 DNS_INSTANCE
*Instance
;
790 EFI_UDP4_PROTOCOL
*Udp
;
793 return EFI_INVALID_PARAMETER
;
796 Instance
= DNS_INSTANCE_FROM_THIS_PROTOCOL4 (This
);
798 if (Instance
->State
== DNS_STATE_UNCONFIGED
) {
799 return EFI_NOT_STARTED
;
800 } else if (Instance
->State
== DNS_STATE_DESTROY
) {
801 return EFI_DEVICE_ERROR
;
804 Udp
= Instance
->UdpIo
->Protocol
.Udp4
;
806 return Udp
->Poll (Udp
);
810 Abort an asynchronous DNS operation, including translation between IP and Host, and
811 general look up behavior.
813 The Cancel() function is used to abort a pending resolution request. After calling
814 this function, Token.Status will be set to EFI_ABORTED and then Token.Event will be
815 signaled. If the token is not in one of the queues, which usually means that the
816 asynchronous operation has completed, this function will not signal the token and
817 EFI_NOT_FOUND is returned.
819 @param[in] This Pointer to EFI_DNS4_PROTOCOL instance.
820 @param[in] Token Pointer to a token that has been issued by
821 EFI_DNS4_PROTOCOL.HostNameToIp (),
822 EFI_DNS4_PROTOCOL.IpToHostName() or
823 EFI_DNS4_PROTOCOL.GeneralLookup().
824 If NULL, all pending tokens are aborted.
826 @retval EFI_SUCCESS Incoming or outgoing data was processed.
827 @retval EFI_NOT_STARTED This EFI DNS4 Protocol instance has not been started.
828 @retval EFI_INVALID_PARAMETER This is NULL.
829 @retval EFI_NOT_FOUND When Token is not NULL, and the asynchronous DNS
830 operation was not found in the transmit queue. It
831 was either completed or was not issued by
832 HostNameToIp(), IpToHostName() or GeneralLookup().
837 IN EFI_DNS4_PROTOCOL
*This
,
838 IN EFI_DNS4_COMPLETION_TOKEN
*Token
842 DNS_INSTANCE
*Instance
;
846 return EFI_INVALID_PARAMETER
;
849 Instance
= DNS_INSTANCE_FROM_THIS_PROTOCOL4 (This
);
851 if (Instance
->State
== DNS_STATE_UNCONFIGED
) {
852 return EFI_NOT_STARTED
;
855 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
858 // Cancle the tokens specified by Token for this instance.
860 Status
= Dns4InstanceCancelToken (Instance
, Token
);
863 // Dispatch the DPC queued by the NotifyFunction of the canceled token's events.
867 gBS
->RestoreTPL (OldTpl
);
873 Retrieve mode data of this DNS instance.
875 This function is used to retrieve DNS mode data for this DNS instance.
877 @param[in] This Pointer to EFI_DNS6_PROTOCOL instance.
878 @param[out] DnsModeData Pointer to the caller-allocated storage for the
879 EFI_DNS6_MODE_DATA data.
881 @retval EFI_SUCCESS The operation completed successfully.
882 @retval EFI_NOT_STARTED When DnsConfigData is queried, no configuration data
883 is available because this instance has not been
885 @retval EFI_INVALID_PARAMETER This is NULL or DnsModeData is NULL.
886 @retval EFI_OUT_OF_RESOURCE Failed to allocate needed resources.
891 IN EFI_DNS6_PROTOCOL
*This
,
892 OUT EFI_DNS6_MODE_DATA
*DnsModeData
895 DNS_INSTANCE
*Instance
;
904 DNS6_SERVER_IP
*ServerItem
;
905 EFI_IPv6_ADDRESS
*ServerList
;
906 DNS6_CACHE
*CacheItem
;
907 EFI_DNS6_CACHE_ENTRY
*CacheList
;
914 Status
= EFI_SUCCESS
;
916 if ((This
== NULL
) || (DnsModeData
== NULL
)) {
917 return EFI_INVALID_PARAMETER
;
920 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
922 Instance
= DNS_INSTANCE_FROM_THIS_PROTOCOL6 (This
);
923 if (Instance
->State
== DNS_STATE_UNCONFIGED
) {
924 Status
= EFI_NOT_STARTED
;
928 ZeroMem (DnsModeData
, sizeof (EFI_DNS6_MODE_DATA
));
931 // Get the current configuration data of this instance.
933 Status
= Dns6CopyConfigure (&DnsModeData
->DnsConfigData
, &Instance
->Dns6CfgData
);
934 if (EFI_ERROR (Status
)) {
939 // Get the DnsServerCount and DnsServerList
942 NET_LIST_FOR_EACH_SAFE (Entry
, Next
, &mDriverData
->Dns6ServerList
) {
945 DnsModeData
->DnsServerCount
= (UINT32
) Index
;
946 ServerList
= AllocatePool (sizeof(EFI_IPv6_ADDRESS
) * DnsModeData
->DnsServerCount
);
947 if (ServerList
== NULL
) {
948 Status
= EFI_OUT_OF_RESOURCES
;
949 Dns6CleanConfigure (&DnsModeData
->DnsConfigData
);
954 NET_LIST_FOR_EACH_SAFE (Entry
, Next
, &mDriverData
->Dns6ServerList
) {
955 ServerItem
= NET_LIST_USER_STRUCT (Entry
, DNS6_SERVER_IP
, AllServerLink
);
956 CopyMem (ServerList
+ Index
, &ServerItem
->Dns6ServerIp
, sizeof (EFI_IPv6_ADDRESS
));
959 DnsModeData
->DnsServerList
= ServerList
;
962 // Get the DnsCacheCount and DnsCacheList
965 NET_LIST_FOR_EACH_SAFE (Entry
, Next
, &mDriverData
->Dns6CacheList
) {
968 DnsModeData
->DnsCacheCount
= (UINT32
) Index
;
969 CacheList
= AllocatePool (sizeof(EFI_DNS6_CACHE_ENTRY
) * DnsModeData
->DnsCacheCount
);
970 if (CacheList
== NULL
) {
971 Status
= EFI_OUT_OF_RESOURCES
;
972 Dns6CleanConfigure (&DnsModeData
->DnsConfigData
);
973 FreePool (ServerList
);
978 NET_LIST_FOR_EACH_SAFE (Entry
, Next
, &mDriverData
->Dns6CacheList
) {
979 CacheItem
= NET_LIST_USER_STRUCT (Entry
, DNS6_CACHE
, AllCacheLink
);
980 CopyMem (CacheList
+ Index
, &CacheItem
->DnsCache
, sizeof (EFI_DNS6_CACHE_ENTRY
));
983 DnsModeData
->DnsCacheList
= CacheList
;
986 gBS
->RestoreTPL (OldTpl
);
991 Configure this DNS instance.
993 The Configure() function is used to set and change the configuration data for this
994 EFI DNSv6 Protocol driver instance. Reset the DNS instance if DnsConfigData is NULL.
996 @param[in] This Pointer to EFI_DNS6_PROTOCOL instance.
997 @param[in] DnsConfigData Pointer to the configuration data structure. All associated
998 storage to be allocated and released by caller.
1000 @retval EFI_SUCCESS The operation completed successfully.
1001 @retval EFI_INVALID_PARAMTER This is NULL.
1002 The StationIp address provided in DnsConfigData is not zero and not a valid unicast.
1003 DnsServerList is NULL while DnsServerList Count is not ZERO.
1004 DnsServerList Count is ZERO while DnsServerList is not NULL.
1005 @retval EFI_OUT_OF_RESOURCES The DNS instance data or required space could not be allocated.
1006 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. The
1007 EFI DNSv6 Protocol instance is not configured.
1008 @retval EFI_UNSUPPORTED The designated protocol is not supported.
1009 @retval EFI_ALREADY_STARTED Second call to Configure() with DnsConfigData. To
1010 reconfigure the instance the caller must call Configure() with
1011 NULL first to return driver to unconfigured state.
1016 IN EFI_DNS6_PROTOCOL
*This
,
1017 IN EFI_DNS6_CONFIG_DATA
*DnsConfigData
1021 DNS_INSTANCE
*Instance
;
1025 UINT32 ServerListCount
;
1026 EFI_IPv6_ADDRESS
*ServerList
;
1028 Status
= EFI_SUCCESS
;
1032 (DnsConfigData
!= NULL
&& ((DnsConfigData
->DnsServerCount
!= 0 && DnsConfigData
->DnsServerList
== NULL
) ||
1033 (DnsConfigData
->DnsServerCount
== 0 && DnsConfigData
->DnsServerList
!= NULL
)))) {
1034 return EFI_INVALID_PARAMETER
;
1037 if (DnsConfigData
!= NULL
&& DnsConfigData
->Protocol
!= DNS_PROTOCOL_UDP
) {
1038 return EFI_UNSUPPORTED
;
1041 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
1043 Instance
= DNS_INSTANCE_FROM_THIS_PROTOCOL6 (This
);
1045 if (DnsConfigData
== NULL
) {
1046 ZeroMem (&Instance
->SessionDnsServer
, sizeof (EFI_IP_ADDRESS
));
1049 // Reset the Instance if ConfigData is NULL
1051 if (!NetMapIsEmpty(&Instance
->Dns6TxTokens
)) {
1052 Dns6InstanceCancelToken(Instance
, NULL
);
1055 Instance
->MaxRetry
= 0;
1057 if (Instance
->UdpIo
!= NULL
){
1058 UdpIoCleanIo (Instance
->UdpIo
);
1061 if (Instance
->Dns6CfgData
.DnsServerList
!= NULL
) {
1062 FreePool (Instance
->Dns6CfgData
.DnsServerList
);
1064 ZeroMem (&Instance
->Dns6CfgData
, sizeof (EFI_DNS6_CONFIG_DATA
));
1066 Instance
->State
= DNS_STATE_UNCONFIGED
;
1069 // Configure the parameters for new operation.
1071 if (!NetIp6IsUnspecifiedAddr (&DnsConfigData
->StationIp
) && !NetIp6IsValidUnicast (&DnsConfigData
->StationIp
)) {
1072 Status
= EFI_INVALID_PARAMETER
;
1076 Status
= Dns6CopyConfigure (&Instance
->Dns6CfgData
, DnsConfigData
);
1077 if (EFI_ERROR (Status
)) {
1081 if (DnsConfigData
->DnsServerCount
== 0 || DnsConfigData
->DnsServerList
== NULL
) {
1082 gBS
->RestoreTPL (OldTpl
);
1085 //The DNS instance will retrieve DNS server from DHCP Server.
1087 Status
= GetDns6ServerFromDhcp6 (
1088 Instance
->Service
->ImageHandle
,
1089 Instance
->Service
->ControllerHandle
,
1093 if (EFI_ERROR (Status
)) {
1097 ASSERT(ServerList
!= NULL
);
1099 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
1101 CopyMem (&Instance
->SessionDnsServer
.v6
, &ServerList
[0], sizeof (EFI_IPv6_ADDRESS
));
1103 CopyMem (&Instance
->SessionDnsServer
.v6
, &DnsConfigData
->DnsServerList
[0], sizeof (EFI_IPv6_ADDRESS
));
1109 gBS
->RestoreTPL (OldTpl
);
1110 Status
= Dns6ConfigUdp (Instance
, Instance
->UdpIo
);
1111 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
1112 if (EFI_ERROR (Status
)) {
1113 if (Instance
->Dns6CfgData
.DnsServerList
!= NULL
) {
1114 FreePool (Instance
->Dns6CfgData
.DnsServerList
);
1115 Instance
->Dns6CfgData
.DnsServerList
= NULL
;
1121 // Add configured DNS server used by this instance to ServerList.
1123 Status
= AddDns6ServerIp (&mDriverData
->Dns6ServerList
, Instance
->SessionDnsServer
.v6
);
1124 if (EFI_ERROR (Status
)) {
1125 if (Instance
->Dns6CfgData
.DnsServerList
!= NULL
) {
1126 FreePool (Instance
->Dns6CfgData
.DnsServerList
);
1127 Instance
->Dns6CfgData
.DnsServerList
= NULL
;
1132 Instance
->State
= DNS_STATE_CONFIGED
;
1136 gBS
->RestoreTPL (OldTpl
);
1141 Host name to host address translation.
1143 The HostNameToIp () function is used to translate the host name to host IP address. A
1144 type AAAA query is used to get the one or more IPv6 addresses for this host.
1146 @param[in] This Pointer to EFI_DNS6_PROTOCOL instance.
1147 @param[in] HostName Host name.
1148 @param[in] Token Point to the completion token to translate host name
1151 @retval EFI_SUCCESS The operation completed successfully.
1152 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
1155 Token.Event is NULL.
1156 HostName is NULL or buffer contained unsupported characters.
1157 @retval EFI_NO_MAPPING There's no source address is available for use.
1158 @retval EFI_ALREADY_STARTED This Token is being used in another DNS session.
1159 @retval EFI_NOT_STARTED This instance has not been started.
1160 @retval EFI_OUT_OF_RESOURCES Failed to allocate needed resources.
1165 IN EFI_DNS6_PROTOCOL
*This
,
1166 IN CHAR16
*HostName
,
1167 IN EFI_DNS6_COMPLETION_TOKEN
*Token
1172 DNS_INSTANCE
*Instance
;
1174 EFI_DNS6_CONFIG_DATA
*ConfigData
;
1183 DNS6_TOKEN_ENTRY
*TokenEntry
;
1188 Status
= EFI_SUCCESS
;
1195 // Validate the parameters
1197 if ((This
== NULL
) || (HostName
== NULL
) || Token
== NULL
) {
1198 return EFI_INVALID_PARAMETER
;
1201 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
1203 Instance
= DNS_INSTANCE_FROM_THIS_PROTOCOL6 (This
);
1205 ConfigData
= &(Instance
->Dns6CfgData
);
1207 Instance
->MaxRetry
= ConfigData
->RetryCount
;
1209 Token
->Status
= EFI_NOT_READY
;
1210 Token
->RetryCount
= 0;
1211 Token
->RetryInterval
= ConfigData
->RetryInterval
;
1213 if (Instance
->State
!= DNS_STATE_CONFIGED
) {
1214 Status
= EFI_NOT_STARTED
;
1219 // Check the MaxRetry and RetryInterval values.
1221 if (Instance
->MaxRetry
== 0) {
1222 Instance
->MaxRetry
= DNS_DEFAULT_RETRY
;
1225 if (Token
->RetryInterval
< DNS_DEFAULT_TIMEOUT
) {
1226 Token
->RetryInterval
= DNS_DEFAULT_TIMEOUT
;
1232 if (ConfigData
->EnableDnsCache
) {
1234 NET_LIST_FOR_EACH_SAFE (Entry
, Next
, &mDriverData
->Dns6CacheList
) {
1235 Item
= NET_LIST_USER_STRUCT (Entry
, DNS6_CACHE
, AllCacheLink
);
1236 if (StrCmp (HostName
, Item
->DnsCache
.HostName
) == 0) {
1242 Token
->RspData
.H2AData
= AllocatePool (sizeof (DNS6_HOST_TO_ADDR_DATA
));
1243 if (Token
->RspData
.H2AData
== NULL
) {
1244 Status
= EFI_OUT_OF_RESOURCES
;
1248 Token
->RspData
.H2AData
->IpCount
= (UINT32
)Index
;
1249 Token
->RspData
.H2AData
->IpList
= AllocatePool (sizeof (EFI_IPv6_ADDRESS
) * Index
);
1250 if (Token
->RspData
.H2AData
->IpList
== NULL
) {
1251 if (Token
->RspData
.H2AData
!= NULL
) {
1252 FreePool (Token
->RspData
.H2AData
);
1255 Status
= EFI_OUT_OF_RESOURCES
;
1260 NET_LIST_FOR_EACH_SAFE (Entry
, Next
, &mDriverData
->Dns6CacheList
) {
1261 Item
= NET_LIST_USER_STRUCT (Entry
, DNS6_CACHE
, AllCacheLink
);
1262 if ((UINT32
)Index
< Token
->RspData
.H2AData
->IpCount
&& StrCmp (HostName
, Item
->DnsCache
.HostName
) == 0) {
1263 CopyMem ((Token
->RspData
.H2AData
->IpList
) + Index
, Item
->DnsCache
.IpAddress
, sizeof (EFI_IPv6_ADDRESS
));
1268 Token
->Status
= EFI_SUCCESS
;
1270 if (Token
->Event
!= NULL
) {
1271 gBS
->SignalEvent (Token
->Event
);
1275 Status
= Token
->Status
;
1281 // Construct DNS TokenEntry.
1283 TokenEntry
= AllocateZeroPool (sizeof (DNS6_TOKEN_ENTRY
));
1284 if (TokenEntry
== NULL
) {
1285 Status
= EFI_OUT_OF_RESOURCES
;
1289 TokenEntry
->PacketToLive
= Token
->RetryInterval
;
1290 TokenEntry
->QueryHostName
= HostName
;
1291 TokenEntry
->Token
= Token
;
1297 QueryName
= NetLibCreateDnsQName (TokenEntry
->QueryHostName
);
1298 if (QueryName
== NULL
) {
1299 Status
= EFI_OUT_OF_RESOURCES
;
1304 // Construct DNS Query Packet.
1306 Status
= ConstructDNSQuery (Instance
, QueryName
, DNS_TYPE_AAAA
, DNS_CLASS_INET
, &Packet
);
1307 if (EFI_ERROR (Status
)) {
1308 if (TokenEntry
!= NULL
) {
1309 FreePool (TokenEntry
);
1315 ASSERT (Packet
!= NULL
);
1318 // Save the token into the Dns6TxTokens map.
1320 Status
= NetMapInsertTail (&Instance
->Dns6TxTokens
, TokenEntry
, Packet
);
1321 if (EFI_ERROR (Status
)) {
1322 if (TokenEntry
!= NULL
) {
1323 FreePool (TokenEntry
);
1326 NetbufFree (Packet
);
1334 Status
= DoDnsQuery (Instance
, Packet
);
1335 if (EFI_ERROR (Status
)) {
1336 Dns6RemoveTokenEntry (&Instance
->Dns6TxTokens
, TokenEntry
);
1338 if (TokenEntry
!= NULL
) {
1339 FreePool (TokenEntry
);
1342 NetbufFree (Packet
);
1346 if (QueryName
!= NULL
) {
1347 FreePool (QueryName
);
1350 gBS
->RestoreTPL (OldTpl
);
1355 Host address to host name translation.
1357 The IpToHostName () function is used to translate the host address to host name. A
1358 type PTR query is used to get the primary name of the host. Implementation can choose
1359 to support this function or not.
1361 @param[in] This Pointer to EFI_DNS6_PROTOCOL instance.
1362 @param[in] IpAddress Ip Address.
1363 @param[in] Token Point to the completion token to translate host
1364 address to host name.
1366 @retval EFI_SUCCESS The operation completed successfully.
1367 @retval EFI_UNSUPPORTED This function is not supported.
1368 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
1371 Token.Event is NULL.
1372 IpAddress is not valid IP address.
1373 @retval EFI_NO_MAPPING There's no source address is available for use.
1374 @retval EFI_NOT_STARTED This instance has not been started.
1375 @retval EFI_OUT_OF_RESOURCES Failed to allocate needed resources.
1380 IN EFI_DNS6_PROTOCOL
*This
,
1381 IN EFI_IPv6_ADDRESS IpAddress
,
1382 IN EFI_DNS6_COMPLETION_TOKEN
*Token
1385 return EFI_UNSUPPORTED
;
1389 This function provides capability to retrieve arbitrary information from the DNS
1392 This GeneralLookup() function retrieves arbitrary information from the DNS. The caller
1393 supplies a QNAME, QTYPE, and QCLASS, and all of the matching RRs are returned. All
1394 RR content (e.g., TTL) was returned. The caller need parse the returned RR to get
1395 required information. The function is optional. Implementation can choose to support
1398 @param[in] This Pointer to EFI_DNS6_PROTOCOL instance.
1399 @param[in] QName Pointer to Query Name.
1400 @param[in] QType Query Type.
1401 @param[in] QClass Query Name.
1402 @param[in] Token Point to the completion token to retrieve arbitrary
1405 @retval EFI_SUCCESS The operation completed successfully.
1406 @retval EFI_UNSUPPORTED This function is not supported. Or the requested
1407 QType is not supported
1408 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
1411 Token.Event is NULL.
1413 @retval EFI_NO_MAPPING There's no source address is available for use.
1414 @retval EFI_NOT_STARTED This instance has not been started.
1415 @retval EFI_OUT_OF_RESOURCES Failed to allocate needed resources.
1420 IN EFI_DNS6_PROTOCOL
*This
,
1424 IN EFI_DNS6_COMPLETION_TOKEN
*Token
1429 DNS_INSTANCE
*Instance
;
1431 EFI_DNS6_CONFIG_DATA
*ConfigData
;
1433 DNS6_TOKEN_ENTRY
*TokenEntry
;
1438 Status
= EFI_SUCCESS
;
1443 // Validate the parameters
1445 if ((This
== NULL
) || (QName
== NULL
) || Token
== NULL
) {
1446 return EFI_INVALID_PARAMETER
;
1449 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
1451 Instance
= DNS_INSTANCE_FROM_THIS_PROTOCOL6 (This
);
1453 ConfigData
= &(Instance
->Dns6CfgData
);
1455 Instance
->MaxRetry
= ConfigData
->RetryCount
;
1457 Token
->Status
= EFI_NOT_READY
;
1458 Token
->RetryCount
= 0;
1459 Token
->RetryInterval
= ConfigData
->RetryInterval
;
1461 if (Instance
->State
!= DNS_STATE_CONFIGED
) {
1462 Status
= EFI_NOT_STARTED
;
1467 // Check the MaxRetry and RetryInterval values.
1469 if (Instance
->MaxRetry
== 0) {
1470 Instance
->MaxRetry
= DNS_DEFAULT_RETRY
;
1473 if (Token
->RetryInterval
< DNS_DEFAULT_TIMEOUT
) {
1474 Token
->RetryInterval
= DNS_DEFAULT_TIMEOUT
;
1478 // Construct DNS TokenEntry.
1480 TokenEntry
= AllocateZeroPool (sizeof(DNS6_TOKEN_ENTRY
));
1481 if (TokenEntry
== NULL
) {
1482 Status
= EFI_OUT_OF_RESOURCES
;
1486 TokenEntry
->PacketToLive
= Token
->RetryInterval
;
1487 TokenEntry
->GeneralLookUp
= TRUE
;
1488 TokenEntry
->Token
= Token
;
1491 // Construct DNS Query Packet.
1493 Status
= ConstructDNSQuery (Instance
, QName
, QType
, QClass
, &Packet
);
1494 if (EFI_ERROR (Status
)) {
1495 if (TokenEntry
!= NULL
) {
1496 FreePool (TokenEntry
);
1502 ASSERT (Packet
!= NULL
);
1505 // Save the token into the Dns6TxTokens map.
1507 Status
= NetMapInsertTail (&Instance
->Dns6TxTokens
, TokenEntry
, Packet
);
1508 if (EFI_ERROR (Status
)) {
1509 if (TokenEntry
!= NULL
) {
1510 FreePool (TokenEntry
);
1513 NetbufFree (Packet
);
1521 Status
= DoDnsQuery (Instance
, Packet
);
1522 if (EFI_ERROR (Status
)) {
1523 Dns6RemoveTokenEntry (&Instance
->Dns6TxTokens
, TokenEntry
);
1525 if (TokenEntry
!= NULL
) {
1526 FreePool (TokenEntry
);
1529 NetbufFree (Packet
);
1533 gBS
->RestoreTPL (OldTpl
);
1538 This function is to update the DNS Cache.
1540 The UpdateDnsCache() function is used to add/delete/modify DNS cache entry. DNS cache
1541 can be normally dynamically updated after the DNS resolve succeeds. This function
1542 provided capability to manually add/delete/modify the DNS cache.
1544 @param[in] This Pointer to EFI_DNS6_PROTOCOL instance.
1545 @param[in] DeleteFlag If FALSE, this function is to add one entry to the
1546 DNS Cahce. If TRUE, this function will delete
1547 matching DNS Cache entry.
1548 @param[in] Override If TRUE, the maching DNS cache entry will be
1549 overwritten with the supplied parameter. If FALSE,
1550 EFI_ACCESS_DENIED will be returned if the entry to
1551 be added is already existed.
1552 @param[in] DnsCacheEntry Pointer to DNS Cache entry.
1554 @retval EFI_SUCCESS The operation completed successfully.
1555 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
1557 DnsCacheEntry.HostName is NULL.
1558 DnsCacheEntry.IpAddress is NULL.
1559 DnsCacheEntry.Timeout is zero.
1560 @retval EFI_ACCESS_DENIED The DNS cache entry already exists and Override is
1562 @retval EFI_OUT_OF_RESOURCE Failed to allocate needed resources.
1566 Dns6UpdateDnsCache (
1567 IN EFI_DNS6_PROTOCOL
*This
,
1568 IN BOOLEAN DeleteFlag
,
1569 IN BOOLEAN Override
,
1570 IN EFI_DNS6_CACHE_ENTRY DnsCacheEntry
1576 Status
= EFI_SUCCESS
;
1578 if (DnsCacheEntry
.HostName
== NULL
|| DnsCacheEntry
.IpAddress
== NULL
|| DnsCacheEntry
.Timeout
== 0) {
1579 return EFI_INVALID_PARAMETER
;
1582 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
1585 // Update Dns6Cache here.
1587 Status
= UpdateDns6Cache (&mDriverData
->Dns6CacheList
, DeleteFlag
, Override
, DnsCacheEntry
);
1589 gBS
->RestoreTPL (OldTpl
);
1595 Polls for incoming data packets and processes outgoing data packets.
1597 The Poll() function can be used by network drivers and applications to increase the
1598 rate that data packets are moved between the communications device and the transmit
1601 In some systems, the periodic timer event in the managed network driver may not poll
1602 the underlying communications device fast enough to transmit and/or receive all data
1603 packets without missing incoming packets or dropping outgoing packets. Drivers and
1604 applications that are experiencing packet loss should try calling the Poll()
1605 function more often.
1607 @param[in] This Pointer to EFI_DNS6_PROTOCOL instance.
1609 @retval EFI_SUCCESS Incoming or outgoing data was processed.
1610 @retval EFI_NOT_STARTED This EFI DNS Protocol instance has not been started.
1611 @retval EFI_INVALID_PARAMETER This is NULL.
1612 @retval EFI_NO_MAPPING There is no source address is available for use.
1613 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
1614 @retval EFI_TIMEOUT Data was dropped out of the transmit and/or receive
1615 queue. Consider increasing the polling rate.
1620 IN EFI_DNS6_PROTOCOL
*This
1623 DNS_INSTANCE
*Instance
;
1624 EFI_UDP6_PROTOCOL
*Udp
;
1627 return EFI_INVALID_PARAMETER
;
1630 Instance
= DNS_INSTANCE_FROM_THIS_PROTOCOL6 (This
);
1632 if (Instance
->State
== DNS_STATE_UNCONFIGED
) {
1633 return EFI_NOT_STARTED
;
1634 } else if (Instance
->State
== DNS_STATE_DESTROY
) {
1635 return EFI_DEVICE_ERROR
;
1638 Udp
= Instance
->UdpIo
->Protocol
.Udp6
;
1640 return Udp
->Poll (Udp
);
1644 Abort an asynchronous DNS operation, including translation between IP and Host, and
1645 general look up behavior.
1647 The Cancel() function is used to abort a pending resolution request. After calling
1648 this function, Token.Status will be set to EFI_ABORTED and then Token.Event will be
1649 signaled. If the token is not in one of the queues, which usually means that the
1650 asynchronous operation has completed, this function will not signal the token and
1651 EFI_NOT_FOUND is returned.
1653 @param[in] This Pointer to EFI_DNS6_PROTOCOL instance.
1654 @param[in] Token Pointer to a token that has been issued by
1655 EFI_DNS6_PROTOCOL.HostNameToIp (),
1656 EFI_DNS6_PROTOCOL.IpToHostName() or
1657 EFI_DNS6_PROTOCOL.GeneralLookup().
1658 If NULL, all pending tokens are aborted.
1660 @retval EFI_SUCCESS Incoming or outgoing data was processed.
1661 @retval EFI_NOT_STARTED This EFI DNS6 Protocol instance has not been started.
1662 @retval EFI_INVALID_PARAMETER This is NULL.
1663 @retval EFI_NO_MAPPING There's no source address is available for use.
1664 @retval EFI_NOT_FOUND When Token is not NULL, and the asynchronous DNS
1665 operation was not found in the transmit queue. It
1666 was either completed or was not issued by
1667 HostNameToIp(), IpToHostName() or GeneralLookup().
1672 IN EFI_DNS6_PROTOCOL
*This
,
1673 IN EFI_DNS6_COMPLETION_TOKEN
*Token
1677 DNS_INSTANCE
*Instance
;
1681 return EFI_INVALID_PARAMETER
;
1684 Instance
= DNS_INSTANCE_FROM_THIS_PROTOCOL6 (This
);
1686 if (Instance
->State
== DNS_STATE_UNCONFIGED
) {
1687 return EFI_NOT_STARTED
;
1690 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
1693 // Cancle the tokens specified by Token for this instance.
1695 Status
= Dns6InstanceCancelToken (Instance
, Token
);
1698 // Dispatch the DPC queued by the NotifyFunction of the canceled token's events.
1702 gBS
->RestoreTPL (OldTpl
);