2 Implementation of EFI_DNS4_PROTOCOL and EFI_DNS6_PROTOCOL interfaces.
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
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
) || !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 Status
= Dns6ConfigUdp (Instance
, Instance
->UdpIo
);
1110 if (EFI_ERROR (Status
)) {
1111 if (Instance
->Dns6CfgData
.DnsServerList
!= NULL
) {
1112 FreePool (Instance
->Dns6CfgData
.DnsServerList
);
1113 Instance
->Dns6CfgData
.DnsServerList
= NULL
;
1119 // Add configured DNS server used by this instance to ServerList.
1121 Status
= AddDns6ServerIp (&mDriverData
->Dns6ServerList
, Instance
->SessionDnsServer
.v6
);
1122 if (EFI_ERROR (Status
)) {
1123 if (Instance
->Dns6CfgData
.DnsServerList
!= NULL
) {
1124 FreePool (Instance
->Dns6CfgData
.DnsServerList
);
1125 Instance
->Dns6CfgData
.DnsServerList
= NULL
;
1130 Instance
->State
= DNS_STATE_CONFIGED
;
1134 gBS
->RestoreTPL (OldTpl
);
1139 Host name to host address translation.
1141 The HostNameToIp () function is used to translate the host name to host IP address. A
1142 type AAAA query is used to get the one or more IPv6 addresses for this host.
1144 @param[in] This Pointer to EFI_DNS6_PROTOCOL instance.
1145 @param[in] HostName Host name.
1146 @param[in] Token Point to the completion token to translate host name
1149 @retval EFI_SUCCESS The operation completed successfully.
1150 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
1153 Token.Event is NULL.
1154 HostName is NULL or buffer contained unsupported characters.
1155 @retval EFI_NO_MAPPING There's no source address is available for use.
1156 @retval EFI_ALREADY_STARTED This Token is being used in another DNS session.
1157 @retval EFI_NOT_STARTED This instance has not been started.
1158 @retval EFI_OUT_OF_RESOURCES Failed to allocate needed resources.
1163 IN EFI_DNS6_PROTOCOL
*This
,
1164 IN CHAR16
*HostName
,
1165 IN EFI_DNS6_COMPLETION_TOKEN
*Token
1170 DNS_INSTANCE
*Instance
;
1172 EFI_DNS6_CONFIG_DATA
*ConfigData
;
1181 DNS6_TOKEN_ENTRY
*TokenEntry
;
1186 Status
= EFI_SUCCESS
;
1193 // Validate the parameters
1195 if ((This
== NULL
) || (HostName
== NULL
) || Token
== NULL
) {
1196 return EFI_INVALID_PARAMETER
;
1199 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
1201 Instance
= DNS_INSTANCE_FROM_THIS_PROTOCOL6 (This
);
1203 ConfigData
= &(Instance
->Dns6CfgData
);
1205 Instance
->MaxRetry
= ConfigData
->RetryCount
;
1207 Token
->Status
= EFI_NOT_READY
;
1208 Token
->RetryCount
= 0;
1209 Token
->RetryInterval
= ConfigData
->RetryInterval
;
1211 if (Instance
->State
!= DNS_STATE_CONFIGED
) {
1212 Status
= EFI_NOT_STARTED
;
1217 // Check the MaxRetry and RetryInterval values.
1219 if (Instance
->MaxRetry
== 0) {
1220 Instance
->MaxRetry
= DNS_DEFAULT_RETRY
;
1223 if (Token
->RetryInterval
< DNS_DEFAULT_TIMEOUT
) {
1224 Token
->RetryInterval
= DNS_DEFAULT_TIMEOUT
;
1230 if (ConfigData
->EnableDnsCache
) {
1232 NET_LIST_FOR_EACH_SAFE (Entry
, Next
, &mDriverData
->Dns6CacheList
) {
1233 Item
= NET_LIST_USER_STRUCT (Entry
, DNS6_CACHE
, AllCacheLink
);
1234 if (StrCmp (HostName
, Item
->DnsCache
.HostName
) == 0) {
1240 Token
->RspData
.H2AData
= AllocatePool (sizeof (DNS6_HOST_TO_ADDR_DATA
));
1241 if (Token
->RspData
.H2AData
== NULL
) {
1242 Status
= EFI_OUT_OF_RESOURCES
;
1246 Token
->RspData
.H2AData
->IpCount
= (UINT32
)Index
;
1247 Token
->RspData
.H2AData
->IpList
= AllocatePool (sizeof (EFI_IPv6_ADDRESS
) * Index
);
1248 if (Token
->RspData
.H2AData
->IpList
== NULL
) {
1249 if (Token
->RspData
.H2AData
!= NULL
) {
1250 FreePool (Token
->RspData
.H2AData
);
1253 Status
= EFI_OUT_OF_RESOURCES
;
1258 NET_LIST_FOR_EACH_SAFE (Entry
, Next
, &mDriverData
->Dns6CacheList
) {
1259 Item
= NET_LIST_USER_STRUCT (Entry
, DNS6_CACHE
, AllCacheLink
);
1260 if ((UINT32
)Index
< Token
->RspData
.H2AData
->IpCount
&& StrCmp (HostName
, Item
->DnsCache
.HostName
) == 0) {
1261 CopyMem ((Token
->RspData
.H2AData
->IpList
) + Index
, Item
->DnsCache
.IpAddress
, sizeof (EFI_IPv6_ADDRESS
));
1266 Token
->Status
= EFI_SUCCESS
;
1268 if (Token
->Event
!= NULL
) {
1269 gBS
->SignalEvent (Token
->Event
);
1273 Status
= Token
->Status
;
1279 // Construct DNS TokenEntry.
1281 TokenEntry
= AllocateZeroPool (sizeof (DNS6_TOKEN_ENTRY
));
1282 if (TokenEntry
== NULL
) {
1283 Status
= EFI_OUT_OF_RESOURCES
;
1287 TokenEntry
->PacketToLive
= Token
->RetryInterval
;
1288 TokenEntry
->QueryHostName
= HostName
;
1289 TokenEntry
->Token
= Token
;
1295 QueryName
= NetLibCreateDnsQName (TokenEntry
->QueryHostName
);
1296 if (QueryName
== NULL
) {
1297 Status
= EFI_OUT_OF_RESOURCES
;
1302 // Construct DNS Query Packet.
1304 Status
= ConstructDNSQuery (Instance
, QueryName
, DNS_TYPE_AAAA
, DNS_CLASS_INET
, &Packet
);
1305 if (EFI_ERROR (Status
)) {
1306 if (TokenEntry
!= NULL
) {
1307 FreePool (TokenEntry
);
1313 ASSERT (Packet
!= NULL
);
1316 // Save the token into the Dns6TxTokens map.
1318 Status
= NetMapInsertTail (&Instance
->Dns6TxTokens
, TokenEntry
, Packet
);
1319 if (EFI_ERROR (Status
)) {
1320 if (TokenEntry
!= NULL
) {
1321 FreePool (TokenEntry
);
1324 NetbufFree (Packet
);
1332 Status
= DoDnsQuery (Instance
, Packet
);
1333 if (EFI_ERROR (Status
)) {
1334 Dns6RemoveTokenEntry (&Instance
->Dns6TxTokens
, TokenEntry
);
1336 if (TokenEntry
!= NULL
) {
1337 FreePool (TokenEntry
);
1340 NetbufFree (Packet
);
1344 if (QueryName
!= NULL
) {
1345 FreePool (QueryName
);
1348 gBS
->RestoreTPL (OldTpl
);
1353 Host address to host name translation.
1355 The IpToHostName () function is used to translate the host address to host name. A
1356 type PTR query is used to get the primary name of the host. Implementation can choose
1357 to support this function or not.
1359 @param[in] This Pointer to EFI_DNS6_PROTOCOL instance.
1360 @param[in] IpAddress Ip Address.
1361 @param[in] Token Point to the completion token to translate host
1362 address to host name.
1364 @retval EFI_SUCCESS The operation completed successfully.
1365 @retval EFI_UNSUPPORTED This function is not supported.
1366 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
1369 Token.Event is NULL.
1370 IpAddress is not valid IP address.
1371 @retval EFI_NO_MAPPING There's no source address is available for use.
1372 @retval EFI_NOT_STARTED This instance has not been started.
1373 @retval EFI_OUT_OF_RESOURCES Failed to allocate needed resources.
1378 IN EFI_DNS6_PROTOCOL
*This
,
1379 IN EFI_IPv6_ADDRESS IpAddress
,
1380 IN EFI_DNS6_COMPLETION_TOKEN
*Token
1383 return EFI_UNSUPPORTED
;
1387 This function provides capability to retrieve arbitrary information from the DNS
1390 This GeneralLookup() function retrieves arbitrary information from the DNS. The caller
1391 supplies a QNAME, QTYPE, and QCLASS, and all of the matching RRs are returned. All
1392 RR content (e.g., TTL) was returned. The caller need parse the returned RR to get
1393 required information. The function is optional. Implementation can choose to support
1396 @param[in] This Pointer to EFI_DNS6_PROTOCOL instance.
1397 @param[in] QName Pointer to Query Name.
1398 @param[in] QType Query Type.
1399 @param[in] QClass Query Name.
1400 @param[in] Token Point to the completion token to retrieve arbitrary
1403 @retval EFI_SUCCESS The operation completed successfully.
1404 @retval EFI_UNSUPPORTED This function is not supported. Or the requested
1405 QType is not supported
1406 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
1409 Token.Event is NULL.
1411 @retval EFI_NO_MAPPING There's no source address is available for use.
1412 @retval EFI_NOT_STARTED This instance has not been started.
1413 @retval EFI_OUT_OF_RESOURCES Failed to allocate needed resources.
1418 IN EFI_DNS6_PROTOCOL
*This
,
1422 IN EFI_DNS6_COMPLETION_TOKEN
*Token
1427 DNS_INSTANCE
*Instance
;
1429 EFI_DNS6_CONFIG_DATA
*ConfigData
;
1431 DNS6_TOKEN_ENTRY
*TokenEntry
;
1436 Status
= EFI_SUCCESS
;
1441 // Validate the parameters
1443 if ((This
== NULL
) || (QName
== NULL
) || Token
== NULL
) {
1444 return EFI_INVALID_PARAMETER
;
1447 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
1449 Instance
= DNS_INSTANCE_FROM_THIS_PROTOCOL6 (This
);
1451 ConfigData
= &(Instance
->Dns6CfgData
);
1453 Instance
->MaxRetry
= ConfigData
->RetryCount
;
1455 Token
->Status
= EFI_NOT_READY
;
1456 Token
->RetryCount
= 0;
1457 Token
->RetryInterval
= ConfigData
->RetryInterval
;
1459 if (Instance
->State
!= DNS_STATE_CONFIGED
) {
1460 Status
= EFI_NOT_STARTED
;
1465 // Check the MaxRetry and RetryInterval values.
1467 if (Instance
->MaxRetry
== 0) {
1468 Instance
->MaxRetry
= DNS_DEFAULT_RETRY
;
1471 if (Token
->RetryInterval
< DNS_DEFAULT_TIMEOUT
) {
1472 Token
->RetryInterval
= DNS_DEFAULT_TIMEOUT
;
1476 // Construct DNS TokenEntry.
1478 TokenEntry
= AllocateZeroPool (sizeof(DNS6_TOKEN_ENTRY
));
1479 if (TokenEntry
== NULL
) {
1480 Status
= EFI_OUT_OF_RESOURCES
;
1484 TokenEntry
->PacketToLive
= Token
->RetryInterval
;
1485 TokenEntry
->GeneralLookUp
= TRUE
;
1486 TokenEntry
->Token
= Token
;
1489 // Construct DNS Query Packet.
1491 Status
= ConstructDNSQuery (Instance
, QName
, QType
, QClass
, &Packet
);
1492 if (EFI_ERROR (Status
)) {
1493 if (TokenEntry
!= NULL
) {
1494 FreePool (TokenEntry
);
1500 ASSERT (Packet
!= NULL
);
1503 // Save the token into the Dns6TxTokens map.
1505 Status
= NetMapInsertTail (&Instance
->Dns6TxTokens
, TokenEntry
, Packet
);
1506 if (EFI_ERROR (Status
)) {
1507 if (TokenEntry
!= NULL
) {
1508 FreePool (TokenEntry
);
1511 NetbufFree (Packet
);
1519 Status
= DoDnsQuery (Instance
, Packet
);
1520 if (EFI_ERROR (Status
)) {
1521 Dns6RemoveTokenEntry (&Instance
->Dns6TxTokens
, TokenEntry
);
1523 if (TokenEntry
!= NULL
) {
1524 FreePool (TokenEntry
);
1527 NetbufFree (Packet
);
1531 gBS
->RestoreTPL (OldTpl
);
1536 This function is to update the DNS Cache.
1538 The UpdateDnsCache() function is used to add/delete/modify DNS cache entry. DNS cache
1539 can be normally dynamically updated after the DNS resolve succeeds. This function
1540 provided capability to manually add/delete/modify the DNS cache.
1542 @param[in] This Pointer to EFI_DNS6_PROTOCOL instance.
1543 @param[in] DeleteFlag If FALSE, this function is to add one entry to the
1544 DNS Cahce. If TRUE, this function will delete
1545 matching DNS Cache entry.
1546 @param[in] Override If TRUE, the maching DNS cache entry will be
1547 overwritten with the supplied parameter. If FALSE,
1548 EFI_ACCESS_DENIED will be returned if the entry to
1549 be added is already existed.
1550 @param[in] DnsCacheEntry Pointer to DNS Cache entry.
1552 @retval EFI_SUCCESS The operation completed successfully.
1553 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
1555 DnsCacheEntry.HostName is NULL.
1556 DnsCacheEntry.IpAddress is NULL.
1557 DnsCacheEntry.Timeout is zero.
1558 @retval EFI_ACCESS_DENIED The DNS cache entry already exists and Override is
1560 @retval EFI_OUT_OF_RESOURCE Failed to allocate needed resources.
1564 Dns6UpdateDnsCache (
1565 IN EFI_DNS6_PROTOCOL
*This
,
1566 IN BOOLEAN DeleteFlag
,
1567 IN BOOLEAN Override
,
1568 IN EFI_DNS6_CACHE_ENTRY DnsCacheEntry
1574 Status
= EFI_SUCCESS
;
1576 if (DnsCacheEntry
.HostName
== NULL
|| DnsCacheEntry
.IpAddress
== NULL
|| DnsCacheEntry
.Timeout
== 0) {
1577 return EFI_INVALID_PARAMETER
;
1580 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
1583 // Update Dns6Cache here.
1585 Status
= UpdateDns6Cache (&mDriverData
->Dns6CacheList
, DeleteFlag
, Override
, DnsCacheEntry
);
1587 gBS
->RestoreTPL (OldTpl
);
1593 Polls for incoming data packets and processes outgoing data packets.
1595 The Poll() function can be used by network drivers and applications to increase the
1596 rate that data packets are moved between the communications device and the transmit
1599 In some systems, the periodic timer event in the managed network driver may not poll
1600 the underlying communications device fast enough to transmit and/or receive all data
1601 packets without missing incoming packets or dropping outgoing packets. Drivers and
1602 applications that are experiencing packet loss should try calling the Poll()
1603 function more often.
1605 @param[in] This Pointer to EFI_DNS6_PROTOCOL instance.
1607 @retval EFI_SUCCESS Incoming or outgoing data was processed.
1608 @retval EFI_NOT_STARTED This EFI DNS Protocol instance has not been started.
1609 @retval EFI_INVALID_PARAMETER This is NULL.
1610 @retval EFI_NO_MAPPING There is no source address is available for use.
1611 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
1612 @retval EFI_TIMEOUT Data was dropped out of the transmit and/or receive
1613 queue. Consider increasing the polling rate.
1618 IN EFI_DNS6_PROTOCOL
*This
1621 DNS_INSTANCE
*Instance
;
1622 EFI_UDP6_PROTOCOL
*Udp
;
1625 return EFI_INVALID_PARAMETER
;
1628 Instance
= DNS_INSTANCE_FROM_THIS_PROTOCOL6 (This
);
1630 if (Instance
->State
== DNS_STATE_UNCONFIGED
) {
1631 return EFI_NOT_STARTED
;
1632 } else if (Instance
->State
== DNS_STATE_DESTROY
) {
1633 return EFI_DEVICE_ERROR
;
1636 Udp
= Instance
->UdpIo
->Protocol
.Udp6
;
1638 return Udp
->Poll (Udp
);
1642 Abort an asynchronous DNS operation, including translation between IP and Host, and
1643 general look up behavior.
1645 The Cancel() function is used to abort a pending resolution request. After calling
1646 this function, Token.Status will be set to EFI_ABORTED and then Token.Event will be
1647 signaled. If the token is not in one of the queues, which usually means that the
1648 asynchronous operation has completed, this function will not signal the token and
1649 EFI_NOT_FOUND is returned.
1651 @param[in] This Pointer to EFI_DNS6_PROTOCOL instance.
1652 @param[in] Token Pointer to a token that has been issued by
1653 EFI_DNS6_PROTOCOL.HostNameToIp (),
1654 EFI_DNS6_PROTOCOL.IpToHostName() or
1655 EFI_DNS6_PROTOCOL.GeneralLookup().
1656 If NULL, all pending tokens are aborted.
1658 @retval EFI_SUCCESS Incoming or outgoing data was processed.
1659 @retval EFI_NOT_STARTED This EFI DNS6 Protocol instance has not been started.
1660 @retval EFI_INVALID_PARAMETER This is NULL.
1661 @retval EFI_NO_MAPPING There's no source address is available for use.
1662 @retval EFI_NOT_FOUND When Token is not NULL, and the asynchronous DNS
1663 operation was not found in the transmit queue. It
1664 was either completed or was not issued by
1665 HostNameToIp(), IpToHostName() or GeneralLookup().
1670 IN EFI_DNS6_PROTOCOL
*This
,
1671 IN EFI_DNS6_COMPLETION_TOKEN
*Token
1675 DNS_INSTANCE
*Instance
;
1679 return EFI_INVALID_PARAMETER
;
1682 Instance
= DNS_INSTANCE_FROM_THIS_PROTOCOL6 (This
);
1684 if (Instance
->State
== DNS_STATE_UNCONFIGED
) {
1685 return EFI_NOT_STARTED
;
1688 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
1691 // Cancle the tokens specified by Token for this instance.
1693 Status
= Dns6InstanceCancelToken (Instance
, Token
);
1696 // Dispatch the DPC queued by the NotifyFunction of the canceled token's events.
1700 gBS
->RestoreTPL (OldTpl
);