2 Implementation of EFI_DNS4_PROTOCOL and EFI_DNS6_PROTOCOL interfaces.
4 Copyright (c) 2015 - 2018, 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 if (Instance
->UdpIo
!= NULL
){
227 UdpIoCleanIo (Instance
->UdpIo
);
230 if (Instance
->Dns4CfgData
.DnsServerList
!= NULL
) {
231 FreePool (Instance
->Dns4CfgData
.DnsServerList
);
233 ZeroMem (&Instance
->Dns4CfgData
, sizeof (EFI_DNS4_CONFIG_DATA
));
235 Instance
->State
= DNS_STATE_UNCONFIGED
;
238 // Configure the parameters for new operation.
240 CopyMem (&Ip
, &DnsConfigData
->StationIp
, sizeof (IP4_ADDR
));
241 CopyMem (&Netmask
, &DnsConfigData
->SubnetMask
, sizeof (IP4_ADDR
));
244 Netmask
= NTOHL (Netmask
);
246 if (!DnsConfigData
->UseDefaultSetting
&&
247 ((!IP4_IS_VALID_NETMASK (Netmask
) || (Netmask
!= 0 && !NetIp4IsUnicast (Ip
, Netmask
))))) {
248 Status
= EFI_INVALID_PARAMETER
;
252 Status
= Dns4CopyConfigure (&Instance
->Dns4CfgData
, DnsConfigData
);
253 if (EFI_ERROR (Status
)) {
257 if (DnsConfigData
->DnsServerListCount
== 0) {
258 gBS
->RestoreTPL (OldTpl
);
261 // The DNS instance will retrieve DNS server from DHCP Server
263 Status
= GetDns4ServerFromDhcp4 (
268 if (EFI_ERROR (Status
)) {
272 ASSERT(ServerList
!= NULL
);
274 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
276 CopyMem (&Instance
->SessionDnsServer
.v4
, &ServerList
[0], sizeof (EFI_IPv4_ADDRESS
));
278 CopyMem (&Instance
->SessionDnsServer
.v4
, &DnsConfigData
->DnsServerList
[0], sizeof (EFI_IPv4_ADDRESS
));
284 Status
= Dns4ConfigUdp (Instance
, Instance
->UdpIo
);
285 if (EFI_ERROR (Status
)) {
286 if (Instance
->Dns4CfgData
.DnsServerList
!= NULL
) {
287 FreePool (Instance
->Dns4CfgData
.DnsServerList
);
288 Instance
->Dns4CfgData
.DnsServerList
= NULL
;
294 // Add configured DNS server used by this instance to ServerList.
296 Status
= AddDns4ServerIp (&mDriverData
->Dns4ServerList
, Instance
->SessionDnsServer
.v4
);
297 if (EFI_ERROR (Status
)) {
298 if (Instance
->Dns4CfgData
.DnsServerList
!= NULL
) {
299 FreePool (Instance
->Dns4CfgData
.DnsServerList
);
300 Instance
->Dns4CfgData
.DnsServerList
= NULL
;
305 Instance
->State
= DNS_STATE_CONFIGED
;
309 gBS
->RestoreTPL (OldTpl
);
314 Host name to host address translation.
316 The HostNameToIp () function is used to translate the host name to host IP address. A
317 type A query is used to get the one or more IP addresses for this host.
319 @param[in] This Pointer to EFI_DNS4_PROTOCOL instance.
320 @param[in] HostName Host name.
321 @param[in] Token Point to the completion token to translate host name
324 @retval EFI_SUCCESS The operation completed successfully.
325 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
329 HostName is NULL. HostName string is unsupported format.
330 @retval EFI_NO_MAPPING There's no source address is available for use.
331 @retval EFI_NOT_STARTED This instance has not been started.
336 IN EFI_DNS4_PROTOCOL
*This
,
338 IN EFI_DNS4_COMPLETION_TOKEN
*Token
343 DNS_INSTANCE
*Instance
;
345 EFI_DNS4_CONFIG_DATA
*ConfigData
;
354 DNS4_TOKEN_ENTRY
*TokenEntry
;
359 Status
= EFI_SUCCESS
;
366 // Validate the parameters
368 if ((This
== NULL
) || (HostName
== NULL
) || Token
== NULL
) {
369 return EFI_INVALID_PARAMETER
;
372 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
374 Instance
= DNS_INSTANCE_FROM_THIS_PROTOCOL4 (This
);
376 ConfigData
= &(Instance
->Dns4CfgData
);
378 if (Instance
->State
!= DNS_STATE_CONFIGED
) {
379 Status
= EFI_NOT_STARTED
;
383 Token
->Status
= EFI_NOT_READY
;
386 // If zero, use the parameter configured through Dns.Configure() interface.
388 if (Token
->RetryCount
== 0) {
389 Token
->RetryCount
= ConfigData
->RetryCount
;
393 // If zero, use the parameter configured through Dns.Configure() interface.
395 if (Token
->RetryInterval
== 0) {
396 Token
->RetryInterval
= ConfigData
->RetryInterval
;
400 // Minimum interval of retry is 2 second. If the retry interval is less than 2 second, then use the 2 second.
402 if (Token
->RetryInterval
< DNS_DEFAULT_TIMEOUT
) {
403 Token
->RetryInterval
= DNS_DEFAULT_TIMEOUT
;
409 if (ConfigData
->EnableDnsCache
) {
411 NET_LIST_FOR_EACH_SAFE (Entry
, Next
, &mDriverData
->Dns4CacheList
) {
412 Item
= NET_LIST_USER_STRUCT (Entry
, DNS4_CACHE
, AllCacheLink
);
413 if (StrCmp (HostName
, Item
->DnsCache
.HostName
) == 0) {
419 Token
->RspData
.H2AData
= AllocatePool (sizeof (DNS_HOST_TO_ADDR_DATA
));
420 if (Token
->RspData
.H2AData
== NULL
) {
421 Status
= EFI_OUT_OF_RESOURCES
;
425 Token
->RspData
.H2AData
->IpCount
= (UINT32
)Index
;
426 Token
->RspData
.H2AData
->IpList
= AllocatePool (sizeof (EFI_IPv4_ADDRESS
) * Index
);
427 if (Token
->RspData
.H2AData
->IpList
== NULL
) {
428 if (Token
->RspData
.H2AData
!= NULL
) {
429 FreePool (Token
->RspData
.H2AData
);
432 Status
= EFI_OUT_OF_RESOURCES
;
437 NET_LIST_FOR_EACH_SAFE (Entry
, Next
, &mDriverData
->Dns4CacheList
) {
438 Item
= NET_LIST_USER_STRUCT (Entry
, DNS4_CACHE
, AllCacheLink
);
439 if ((UINT32
)Index
< Token
->RspData
.H2AData
->IpCount
&& StrCmp (HostName
, Item
->DnsCache
.HostName
) == 0) {
440 CopyMem ((Token
->RspData
.H2AData
->IpList
) + Index
, Item
->DnsCache
.IpAddress
, sizeof (EFI_IPv4_ADDRESS
));
445 Token
->Status
= EFI_SUCCESS
;
447 if (Token
->Event
!= NULL
) {
448 gBS
->SignalEvent (Token
->Event
);
452 Status
= Token
->Status
;
458 // Construct DNS TokenEntry.
460 TokenEntry
= AllocateZeroPool (sizeof(DNS4_TOKEN_ENTRY
));
461 if (TokenEntry
== NULL
) {
462 Status
= EFI_OUT_OF_RESOURCES
;
466 TokenEntry
->PacketToLive
= Token
->RetryInterval
;
467 TokenEntry
->Token
= Token
;
468 TokenEntry
->QueryHostName
= AllocateZeroPool (StrSize (HostName
));
469 if (TokenEntry
->QueryHostName
== NULL
) {
470 Status
= EFI_OUT_OF_RESOURCES
;
474 CopyMem (TokenEntry
->QueryHostName
, HostName
, StrSize (HostName
));
479 QueryName
= NetLibCreateDnsQName (TokenEntry
->QueryHostName
);
480 if (QueryName
== NULL
) {
481 Status
= EFI_OUT_OF_RESOURCES
;
486 // Construct DNS Query Packet.
488 Status
= ConstructDNSQuery (Instance
, QueryName
, DNS_TYPE_A
, DNS_CLASS_INET
, &Packet
);
489 if (EFI_ERROR (Status
)) {
493 ASSERT (Packet
!= NULL
);
496 // Save the token into the Dns4TxTokens map.
498 Status
= NetMapInsertTail (&Instance
->Dns4TxTokens
, TokenEntry
, Packet
);
499 if (EFI_ERROR (Status
)) {
506 Status
= DoDnsQuery (Instance
, Packet
);
507 if (EFI_ERROR (Status
)) {
508 Dns4RemoveTokenEntry (&Instance
->Dns4TxTokens
, TokenEntry
);
513 if (EFI_ERROR (Status
)) {
514 if (TokenEntry
!= NULL
) {
515 if (TokenEntry
->QueryHostName
!= NULL
) {
516 FreePool (TokenEntry
->QueryHostName
);
519 FreePool (TokenEntry
);
522 if (Packet
!= NULL
) {
527 if (QueryName
!= NULL
) {
528 FreePool (QueryName
);
531 gBS
->RestoreTPL (OldTpl
);
536 IPv4 address to host name translation also known as Reverse DNS lookup.
538 The IpToHostName() function is used to translate the host address to host name. A type PTR
539 query is used to get the primary name of the host. Support of this function is optional.
541 @param[in] This Pointer to EFI_DNS4_PROTOCOL instance.
542 @param[in] IpAddress Ip Address.
543 @param[in] Token Point to the completion token to translate host
544 address to host name.
546 @retval EFI_SUCCESS The operation completed successfully.
547 @retval EFI_UNSUPPORTED This function is not supported.
548 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
552 IpAddress is not valid IP address .
553 @retval EFI_NO_MAPPING There's no source address is available for use.
554 @retval EFI_ALREADY_STARTED This Token is being used in another DNS session.
555 @retval EFI_OUT_OF_RESOURCES Failed to allocate needed resources.
560 IN EFI_DNS4_PROTOCOL
*This
,
561 IN EFI_IPv4_ADDRESS IpAddress
,
562 IN EFI_DNS4_COMPLETION_TOKEN
*Token
565 return EFI_UNSUPPORTED
;
569 Retrieve arbitrary information from the DNS server.
571 This GeneralLookup() function retrieves arbitrary information from the DNS. The caller
572 supplies a QNAME, QTYPE, and QCLASS, and all of the matching RRs are returned. All
573 RR content (e.g., TTL) was returned. The caller need parse the returned RR to get
574 required information. The function is optional.
576 @param[in] This Pointer to EFI_DNS4_PROTOCOL instance.
577 @param[in] QName Pointer to Query Name.
578 @param[in] QType Query Type.
579 @param[in] QClass Query Name.
580 @param[in] Token Point to the completion token to retrieve arbitrary
583 @retval EFI_SUCCESS The operation completed successfully.
584 @retval EFI_UNSUPPORTED This function is not supported. Or the requested
585 QType is not supported
586 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
591 @retval EFI_NO_MAPPING There's no source address is available for use.
592 @retval EFI_ALREADY_STARTED This Token is being used in another DNS session.
593 @retval EFI_OUT_OF_RESOURCES Failed to allocate needed resources.
598 IN EFI_DNS4_PROTOCOL
*This
,
602 IN EFI_DNS4_COMPLETION_TOKEN
*Token
607 DNS_INSTANCE
*Instance
;
609 EFI_DNS4_CONFIG_DATA
*ConfigData
;
611 DNS4_TOKEN_ENTRY
*TokenEntry
;
616 Status
= EFI_SUCCESS
;
621 // Validate the parameters
623 if ((This
== NULL
) || (QName
== NULL
) || Token
== NULL
) {
624 return EFI_INVALID_PARAMETER
;
627 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
629 Instance
= DNS_INSTANCE_FROM_THIS_PROTOCOL4 (This
);
631 ConfigData
= &(Instance
->Dns4CfgData
);
633 if (Instance
->State
!= DNS_STATE_CONFIGED
) {
634 Status
= EFI_NOT_STARTED
;
638 Token
->Status
= EFI_NOT_READY
;
641 // If zero, use the parameter configured through Dns.Configure() interface.
643 if (Token
->RetryCount
== 0) {
644 Token
->RetryCount
= ConfigData
->RetryCount
;
648 // If zero, use the parameter configured through Dns.Configure() interface.
650 if (Token
->RetryInterval
== 0) {
651 Token
->RetryInterval
= ConfigData
->RetryInterval
;
655 // Minimum interval of retry is 2 second. If the retry interval is less than 2 second, then use the 2 second.
657 if (Token
->RetryInterval
< DNS_DEFAULT_TIMEOUT
) {
658 Token
->RetryInterval
= DNS_DEFAULT_TIMEOUT
;
662 // Construct DNS TokenEntry.
664 TokenEntry
= AllocateZeroPool (sizeof(DNS4_TOKEN_ENTRY
));
665 if (TokenEntry
== NULL
) {
666 Status
= EFI_OUT_OF_RESOURCES
;
670 TokenEntry
->PacketToLive
= Token
->RetryInterval
;
671 TokenEntry
->GeneralLookUp
= TRUE
;
672 TokenEntry
->Token
= Token
;
675 // Construct DNS Query Packet.
677 Status
= ConstructDNSQuery (Instance
, QName
, QType
, QClass
, &Packet
);
678 if (EFI_ERROR (Status
)) {
679 if (TokenEntry
!= NULL
) {
680 FreePool (TokenEntry
);
686 ASSERT (Packet
!= NULL
);
689 // Save the token into the Dns4TxTokens map.
691 Status
= NetMapInsertTail (&Instance
->Dns4TxTokens
, TokenEntry
, Packet
);
692 if (EFI_ERROR (Status
)) {
693 if (TokenEntry
!= NULL
) {
694 FreePool (TokenEntry
);
705 Status
= DoDnsQuery (Instance
, Packet
);
706 if (EFI_ERROR (Status
)) {
707 Dns4RemoveTokenEntry (&Instance
->Dns4TxTokens
, TokenEntry
);
709 if (TokenEntry
!= NULL
) {
710 FreePool (TokenEntry
);
717 gBS
->RestoreTPL (OldTpl
);
722 This function is to update the DNS Cache.
724 The UpdateDnsCache() function is used to add/delete/modify DNS cache entry. DNS cache
725 can be normally dynamically updated after the DNS resolve succeeds. This function
726 provided capability to manually add/delete/modify the DNS cache.
728 @param[in] This Pointer to EFI_DNS4_PROTOCOL instance.
729 @param[in] DeleteFlag If FALSE, this function is to add one entry to the
730 DNS Cahce. If TRUE, this function will delete
731 matching DNS Cache entry.
732 @param[in] Override If TRUE, the maching DNS cache entry will be
733 overwritten with the supplied parameter. If FALSE,
734 EFI_ACCESS_DENIED will be returned if the entry to
735 be added is already existed.
736 @param[in] DnsCacheEntry Pointer to DNS Cache entry.
738 @retval EFI_SUCCESS The operation completed successfully.
739 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
741 DnsCacheEntry.HostName is NULL.
742 DnsCacheEntry.IpAddress is NULL.
743 DnsCacheEntry.Timeout is zero.
744 @retval EFI_ACCESS_DENIED The DNS cache entry already exists and Override is
750 IN EFI_DNS4_PROTOCOL
*This
,
751 IN BOOLEAN DeleteFlag
,
753 IN EFI_DNS4_CACHE_ENTRY DnsCacheEntry
759 Status
= EFI_SUCCESS
;
761 if (DnsCacheEntry
.HostName
== NULL
|| DnsCacheEntry
.IpAddress
== NULL
|| DnsCacheEntry
.Timeout
== 0) {
762 return EFI_INVALID_PARAMETER
;
765 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
768 // Update Dns4Cache here.
770 Status
= UpdateDns4Cache (&mDriverData
->Dns4CacheList
, DeleteFlag
, Override
, DnsCacheEntry
);
772 gBS
->RestoreTPL (OldTpl
);
778 Polls for incoming data packets and processes outgoing data packets.
780 The Poll() function can be used by network drivers and applications to increase the
781 rate that data packets are moved between the communications device and the transmit
783 In some systems, the periodic timer event in the managed network driver may not poll
784 the underlying communications device fast enough to transmit and/or receive all data
785 packets without missing incoming packets or dropping outgoing packets. Drivers and
786 applications that are experiencing packet loss should try calling the Poll()
789 @param[in] This Pointer to EFI_DNS4_PROTOCOL instance.
791 @retval EFI_SUCCESS Incoming or outgoing data was processed.
792 @retval EFI_NOT_STARTED This EFI DNS Protocol instance has not been started.
793 @retval EFI_INVALID_PARAMETER This is NULL.
794 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
795 @retval EFI_TIMEOUT Data was dropped out of the transmit and/or receive
796 queue. Consider increasing the polling rate.
801 IN EFI_DNS4_PROTOCOL
*This
804 DNS_INSTANCE
*Instance
;
805 EFI_UDP4_PROTOCOL
*Udp
;
808 return EFI_INVALID_PARAMETER
;
811 Instance
= DNS_INSTANCE_FROM_THIS_PROTOCOL4 (This
);
813 if (Instance
->State
== DNS_STATE_UNCONFIGED
) {
814 return EFI_NOT_STARTED
;
815 } else if (Instance
->State
== DNS_STATE_DESTROY
) {
816 return EFI_DEVICE_ERROR
;
819 Udp
= Instance
->UdpIo
->Protocol
.Udp4
;
821 return Udp
->Poll (Udp
);
825 Abort an asynchronous DNS operation, including translation between IP and Host, and
826 general look up behavior.
828 The Cancel() function is used to abort a pending resolution request. After calling
829 this function, Token.Status will be set to EFI_ABORTED and then Token.Event will be
830 signaled. If the token is not in one of the queues, which usually means that the
831 asynchronous operation has completed, this function will not signal the token and
832 EFI_NOT_FOUND is returned.
834 @param[in] This Pointer to EFI_DNS4_PROTOCOL instance.
835 @param[in] Token Pointer to a token that has been issued by
836 EFI_DNS4_PROTOCOL.HostNameToIp (),
837 EFI_DNS4_PROTOCOL.IpToHostName() or
838 EFI_DNS4_PROTOCOL.GeneralLookup().
839 If NULL, all pending tokens are aborted.
841 @retval EFI_SUCCESS Incoming or outgoing data was processed.
842 @retval EFI_NOT_STARTED This EFI DNS4 Protocol instance has not been started.
843 @retval EFI_INVALID_PARAMETER This is NULL.
844 @retval EFI_NOT_FOUND When Token is not NULL, and the asynchronous DNS
845 operation was not found in the transmit queue. It
846 was either completed or was not issued by
847 HostNameToIp(), IpToHostName() or GeneralLookup().
852 IN EFI_DNS4_PROTOCOL
*This
,
853 IN EFI_DNS4_COMPLETION_TOKEN
*Token
857 DNS_INSTANCE
*Instance
;
861 return EFI_INVALID_PARAMETER
;
864 Instance
= DNS_INSTANCE_FROM_THIS_PROTOCOL4 (This
);
866 if (Instance
->State
== DNS_STATE_UNCONFIGED
) {
867 return EFI_NOT_STARTED
;
870 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
873 // Cancle the tokens specified by Token for this instance.
875 Status
= Dns4InstanceCancelToken (Instance
, Token
);
878 // Dispatch the DPC queued by the NotifyFunction of the canceled token's events.
882 gBS
->RestoreTPL (OldTpl
);
888 Retrieve mode data of this DNS instance.
890 This function is used to retrieve DNS mode data for this DNS instance.
892 @param[in] This Pointer to EFI_DNS6_PROTOCOL instance.
893 @param[out] DnsModeData Pointer to the caller-allocated storage for the
894 EFI_DNS6_MODE_DATA data.
896 @retval EFI_SUCCESS The operation completed successfully.
897 @retval EFI_NOT_STARTED When DnsConfigData is queried, no configuration data
898 is available because this instance has not been
900 @retval EFI_INVALID_PARAMETER This is NULL or DnsModeData is NULL.
901 @retval EFI_OUT_OF_RESOURCE Failed to allocate needed resources.
906 IN EFI_DNS6_PROTOCOL
*This
,
907 OUT EFI_DNS6_MODE_DATA
*DnsModeData
910 DNS_INSTANCE
*Instance
;
919 DNS6_SERVER_IP
*ServerItem
;
920 EFI_IPv6_ADDRESS
*ServerList
;
921 DNS6_CACHE
*CacheItem
;
922 EFI_DNS6_CACHE_ENTRY
*CacheList
;
929 Status
= EFI_SUCCESS
;
931 if ((This
== NULL
) || (DnsModeData
== NULL
)) {
932 return EFI_INVALID_PARAMETER
;
935 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
937 Instance
= DNS_INSTANCE_FROM_THIS_PROTOCOL6 (This
);
938 if (Instance
->State
== DNS_STATE_UNCONFIGED
) {
939 Status
= EFI_NOT_STARTED
;
943 ZeroMem (DnsModeData
, sizeof (EFI_DNS6_MODE_DATA
));
946 // Get the current configuration data of this instance.
948 Status
= Dns6CopyConfigure (&DnsModeData
->DnsConfigData
, &Instance
->Dns6CfgData
);
949 if (EFI_ERROR (Status
)) {
954 // Get the DnsServerCount and DnsServerList
957 NET_LIST_FOR_EACH_SAFE (Entry
, Next
, &mDriverData
->Dns6ServerList
) {
960 DnsModeData
->DnsServerCount
= (UINT32
) Index
;
961 ServerList
= AllocatePool (sizeof(EFI_IPv6_ADDRESS
) * DnsModeData
->DnsServerCount
);
962 if (ServerList
== NULL
) {
963 Status
= EFI_OUT_OF_RESOURCES
;
964 Dns6CleanConfigure (&DnsModeData
->DnsConfigData
);
969 NET_LIST_FOR_EACH_SAFE (Entry
, Next
, &mDriverData
->Dns6ServerList
) {
970 ServerItem
= NET_LIST_USER_STRUCT (Entry
, DNS6_SERVER_IP
, AllServerLink
);
971 CopyMem (ServerList
+ Index
, &ServerItem
->Dns6ServerIp
, sizeof (EFI_IPv6_ADDRESS
));
974 DnsModeData
->DnsServerList
= ServerList
;
977 // Get the DnsCacheCount and DnsCacheList
980 NET_LIST_FOR_EACH_SAFE (Entry
, Next
, &mDriverData
->Dns6CacheList
) {
983 DnsModeData
->DnsCacheCount
= (UINT32
) Index
;
984 CacheList
= AllocatePool (sizeof(EFI_DNS6_CACHE_ENTRY
) * DnsModeData
->DnsCacheCount
);
985 if (CacheList
== NULL
) {
986 Status
= EFI_OUT_OF_RESOURCES
;
987 Dns6CleanConfigure (&DnsModeData
->DnsConfigData
);
988 FreePool (ServerList
);
993 NET_LIST_FOR_EACH_SAFE (Entry
, Next
, &mDriverData
->Dns6CacheList
) {
994 CacheItem
= NET_LIST_USER_STRUCT (Entry
, DNS6_CACHE
, AllCacheLink
);
995 CopyMem (CacheList
+ Index
, &CacheItem
->DnsCache
, sizeof (EFI_DNS6_CACHE_ENTRY
));
998 DnsModeData
->DnsCacheList
= CacheList
;
1001 gBS
->RestoreTPL (OldTpl
);
1006 Configure this DNS instance.
1008 The Configure() function is used to set and change the configuration data for this
1009 EFI DNSv6 Protocol driver instance. Reset the DNS instance if DnsConfigData is NULL.
1011 @param[in] This Pointer to EFI_DNS6_PROTOCOL instance.
1012 @param[in] DnsConfigData Pointer to the configuration data structure. All associated
1013 storage to be allocated and released by caller.
1015 @retval EFI_SUCCESS The operation completed successfully.
1016 @retval EFI_INVALID_PARAMTER This is NULL.
1017 The StationIp address provided in DnsConfigData is not zero and not a valid unicast.
1018 DnsServerList is NULL while DnsServerList Count is not ZERO.
1019 DnsServerList Count is ZERO while DnsServerList is not NULL.
1020 @retval EFI_OUT_OF_RESOURCES The DNS instance data or required space could not be allocated.
1021 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. The
1022 EFI DNSv6 Protocol instance is not configured.
1023 @retval EFI_UNSUPPORTED The designated protocol is not supported.
1024 @retval EFI_ALREADY_STARTED Second call to Configure() with DnsConfigData. To
1025 reconfigure the instance the caller must call Configure() with
1026 NULL first to return driver to unconfigured state.
1031 IN EFI_DNS6_PROTOCOL
*This
,
1032 IN EFI_DNS6_CONFIG_DATA
*DnsConfigData
1036 DNS_INSTANCE
*Instance
;
1040 UINT32 ServerListCount
;
1041 EFI_IPv6_ADDRESS
*ServerList
;
1043 Status
= EFI_SUCCESS
;
1047 (DnsConfigData
!= NULL
&& ((DnsConfigData
->DnsServerCount
!= 0 && DnsConfigData
->DnsServerList
== NULL
) ||
1048 (DnsConfigData
->DnsServerCount
== 0 && DnsConfigData
->DnsServerList
!= NULL
)))) {
1049 return EFI_INVALID_PARAMETER
;
1052 if (DnsConfigData
!= NULL
&& DnsConfigData
->Protocol
!= DNS_PROTOCOL_UDP
) {
1053 return EFI_UNSUPPORTED
;
1056 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
1058 Instance
= DNS_INSTANCE_FROM_THIS_PROTOCOL6 (This
);
1060 if (DnsConfigData
== NULL
) {
1061 ZeroMem (&Instance
->SessionDnsServer
, sizeof (EFI_IP_ADDRESS
));
1064 // Reset the Instance if ConfigData is NULL
1066 if (!NetMapIsEmpty(&Instance
->Dns6TxTokens
)) {
1067 Dns6InstanceCancelToken(Instance
, NULL
);
1070 if (Instance
->UdpIo
!= NULL
){
1071 UdpIoCleanIo (Instance
->UdpIo
);
1074 if (Instance
->Dns6CfgData
.DnsServerList
!= NULL
) {
1075 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
;
1134 // Add configured DNS server used by this instance to ServerList.
1136 Status
= AddDns6ServerIp (&mDriverData
->Dns6ServerList
, Instance
->SessionDnsServer
.v6
);
1137 if (EFI_ERROR (Status
)) {
1138 if (Instance
->Dns6CfgData
.DnsServerList
!= NULL
) {
1139 FreePool (Instance
->Dns6CfgData
.DnsServerList
);
1140 Instance
->Dns6CfgData
.DnsServerList
= NULL
;
1145 Instance
->State
= DNS_STATE_CONFIGED
;
1149 gBS
->RestoreTPL (OldTpl
);
1154 Host name to host address translation.
1156 The HostNameToIp () function is used to translate the host name to host IP address. A
1157 type AAAA query is used to get the one or more IPv6 addresses for this host.
1159 @param[in] This Pointer to EFI_DNS6_PROTOCOL instance.
1160 @param[in] HostName Host name.
1161 @param[in] Token Point to the completion token to translate host name
1164 @retval EFI_SUCCESS The operation completed successfully.
1165 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
1168 Token.Event is NULL.
1169 HostName is NULL or buffer contained unsupported characters.
1170 @retval EFI_NO_MAPPING There's no source address is available for use.
1171 @retval EFI_ALREADY_STARTED This Token is being used in another DNS session.
1172 @retval EFI_NOT_STARTED This instance has not been started.
1173 @retval EFI_OUT_OF_RESOURCES Failed to allocate needed resources.
1178 IN EFI_DNS6_PROTOCOL
*This
,
1179 IN CHAR16
*HostName
,
1180 IN EFI_DNS6_COMPLETION_TOKEN
*Token
1185 DNS_INSTANCE
*Instance
;
1187 EFI_DNS6_CONFIG_DATA
*ConfigData
;
1196 DNS6_TOKEN_ENTRY
*TokenEntry
;
1201 Status
= EFI_SUCCESS
;
1208 // Validate the parameters
1210 if ((This
== NULL
) || (HostName
== NULL
) || Token
== NULL
) {
1211 return EFI_INVALID_PARAMETER
;
1214 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
1216 Instance
= DNS_INSTANCE_FROM_THIS_PROTOCOL6 (This
);
1218 ConfigData
= &(Instance
->Dns6CfgData
);
1220 if (Instance
->State
!= DNS_STATE_CONFIGED
) {
1221 Status
= EFI_NOT_STARTED
;
1225 Token
->Status
= EFI_NOT_READY
;
1228 // If zero, use the parameter configured through Dns.Configure() interface.
1230 if (Token
->RetryCount
== 0) {
1231 Token
->RetryCount
= ConfigData
->RetryCount
;
1235 // If zero, use the parameter configured through Dns.Configure() interface.
1237 if (Token
->RetryInterval
== 0) {
1238 Token
->RetryInterval
= ConfigData
->RetryInterval
;
1242 // Minimum interval of retry is 2 second. If the retry interval is less than 2 second, then use the 2 second.
1244 if (Token
->RetryInterval
< DNS_DEFAULT_TIMEOUT
) {
1245 Token
->RetryInterval
= DNS_DEFAULT_TIMEOUT
;
1251 if (ConfigData
->EnableDnsCache
) {
1253 NET_LIST_FOR_EACH_SAFE (Entry
, Next
, &mDriverData
->Dns6CacheList
) {
1254 Item
= NET_LIST_USER_STRUCT (Entry
, DNS6_CACHE
, AllCacheLink
);
1255 if (StrCmp (HostName
, Item
->DnsCache
.HostName
) == 0) {
1261 Token
->RspData
.H2AData
= AllocatePool (sizeof (DNS6_HOST_TO_ADDR_DATA
));
1262 if (Token
->RspData
.H2AData
== NULL
) {
1263 Status
= EFI_OUT_OF_RESOURCES
;
1267 Token
->RspData
.H2AData
->IpCount
= (UINT32
)Index
;
1268 Token
->RspData
.H2AData
->IpList
= AllocatePool (sizeof (EFI_IPv6_ADDRESS
) * Index
);
1269 if (Token
->RspData
.H2AData
->IpList
== NULL
) {
1270 if (Token
->RspData
.H2AData
!= NULL
) {
1271 FreePool (Token
->RspData
.H2AData
);
1274 Status
= EFI_OUT_OF_RESOURCES
;
1279 NET_LIST_FOR_EACH_SAFE (Entry
, Next
, &mDriverData
->Dns6CacheList
) {
1280 Item
= NET_LIST_USER_STRUCT (Entry
, DNS6_CACHE
, AllCacheLink
);
1281 if ((UINT32
)Index
< Token
->RspData
.H2AData
->IpCount
&& StrCmp (HostName
, Item
->DnsCache
.HostName
) == 0) {
1282 CopyMem ((Token
->RspData
.H2AData
->IpList
) + Index
, Item
->DnsCache
.IpAddress
, sizeof (EFI_IPv6_ADDRESS
));
1287 Token
->Status
= EFI_SUCCESS
;
1289 if (Token
->Event
!= NULL
) {
1290 gBS
->SignalEvent (Token
->Event
);
1294 Status
= Token
->Status
;
1300 // Construct DNS TokenEntry.
1302 TokenEntry
= AllocateZeroPool (sizeof (DNS6_TOKEN_ENTRY
));
1303 if (TokenEntry
== NULL
) {
1304 Status
= EFI_OUT_OF_RESOURCES
;
1308 TokenEntry
->PacketToLive
= Token
->RetryInterval
;
1309 TokenEntry
->Token
= Token
;
1310 TokenEntry
->QueryHostName
= AllocateZeroPool (StrSize (HostName
));
1311 if (TokenEntry
->QueryHostName
== NULL
) {
1312 Status
= EFI_OUT_OF_RESOURCES
;
1316 CopyMem (TokenEntry
->QueryHostName
, HostName
, StrSize (HostName
));
1321 QueryName
= NetLibCreateDnsQName (TokenEntry
->QueryHostName
);
1322 if (QueryName
== NULL
) {
1323 Status
= EFI_OUT_OF_RESOURCES
;
1328 // Construct DNS Query Packet.
1330 Status
= ConstructDNSQuery (Instance
, QueryName
, DNS_TYPE_AAAA
, DNS_CLASS_INET
, &Packet
);
1331 if (EFI_ERROR (Status
)) {
1335 ASSERT (Packet
!= NULL
);
1338 // Save the token into the Dns6TxTokens map.
1340 Status
= NetMapInsertTail (&Instance
->Dns6TxTokens
, TokenEntry
, Packet
);
1341 if (EFI_ERROR (Status
)) {
1348 Status
= DoDnsQuery (Instance
, Packet
);
1349 if (EFI_ERROR (Status
)) {
1350 Dns6RemoveTokenEntry (&Instance
->Dns6TxTokens
, TokenEntry
);
1355 if (EFI_ERROR (Status
)) {
1356 if (TokenEntry
!= NULL
) {
1357 if (TokenEntry
->QueryHostName
!= NULL
) {
1358 FreePool (TokenEntry
->QueryHostName
);
1361 FreePool (TokenEntry
);
1364 if (Packet
!= NULL
) {
1365 NetbufFree (Packet
);
1369 if (QueryName
!= NULL
) {
1370 FreePool (QueryName
);
1373 gBS
->RestoreTPL (OldTpl
);
1378 Host address to host name translation.
1380 The IpToHostName () function is used to translate the host address to host name. A
1381 type PTR query is used to get the primary name of the host. Implementation can choose
1382 to support this function or not.
1384 @param[in] This Pointer to EFI_DNS6_PROTOCOL instance.
1385 @param[in] IpAddress Ip Address.
1386 @param[in] Token Point to the completion token to translate host
1387 address to host name.
1389 @retval EFI_SUCCESS The operation completed successfully.
1390 @retval EFI_UNSUPPORTED This function is not supported.
1391 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
1394 Token.Event is NULL.
1395 IpAddress is not valid IP address.
1396 @retval EFI_NO_MAPPING There's no source address is available for use.
1397 @retval EFI_NOT_STARTED This instance has not been started.
1398 @retval EFI_OUT_OF_RESOURCES Failed to allocate needed resources.
1403 IN EFI_DNS6_PROTOCOL
*This
,
1404 IN EFI_IPv6_ADDRESS IpAddress
,
1405 IN EFI_DNS6_COMPLETION_TOKEN
*Token
1408 return EFI_UNSUPPORTED
;
1412 This function provides capability to retrieve arbitrary information from the DNS
1415 This GeneralLookup() function retrieves arbitrary information from the DNS. The caller
1416 supplies a QNAME, QTYPE, and QCLASS, and all of the matching RRs are returned. All
1417 RR content (e.g., TTL) was returned. The caller need parse the returned RR to get
1418 required information. The function is optional. Implementation can choose to support
1421 @param[in] This Pointer to EFI_DNS6_PROTOCOL instance.
1422 @param[in] QName Pointer to Query Name.
1423 @param[in] QType Query Type.
1424 @param[in] QClass Query Name.
1425 @param[in] Token Point to the completion token to retrieve arbitrary
1428 @retval EFI_SUCCESS The operation completed successfully.
1429 @retval EFI_UNSUPPORTED This function is not supported. Or the requested
1430 QType is not supported
1431 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
1434 Token.Event is NULL.
1436 @retval EFI_NO_MAPPING There's no source address is available for use.
1437 @retval EFI_NOT_STARTED This instance has not been started.
1438 @retval EFI_OUT_OF_RESOURCES Failed to allocate needed resources.
1443 IN EFI_DNS6_PROTOCOL
*This
,
1447 IN EFI_DNS6_COMPLETION_TOKEN
*Token
1452 DNS_INSTANCE
*Instance
;
1454 EFI_DNS6_CONFIG_DATA
*ConfigData
;
1456 DNS6_TOKEN_ENTRY
*TokenEntry
;
1461 Status
= EFI_SUCCESS
;
1466 // Validate the parameters
1468 if ((This
== NULL
) || (QName
== NULL
) || Token
== NULL
) {
1469 return EFI_INVALID_PARAMETER
;
1472 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
1474 Instance
= DNS_INSTANCE_FROM_THIS_PROTOCOL6 (This
);
1476 ConfigData
= &(Instance
->Dns6CfgData
);
1478 if (Instance
->State
!= DNS_STATE_CONFIGED
) {
1479 Status
= EFI_NOT_STARTED
;
1483 Token
->Status
= EFI_NOT_READY
;
1486 // If zero, use the parameter configured through Dns.Configure() interface.
1488 if (Token
->RetryCount
== 0) {
1489 Token
->RetryCount
= ConfigData
->RetryCount
;
1493 // If zero, use the parameter configured through Dns.Configure() interface.
1495 if (Token
->RetryInterval
== 0) {
1496 Token
->RetryInterval
= ConfigData
->RetryInterval
;
1500 // Minimum interval of retry is 2 second. If the retry interval is less than 2 second, then use the 2 second.
1502 if (Token
->RetryInterval
< DNS_DEFAULT_TIMEOUT
) {
1503 Token
->RetryInterval
= DNS_DEFAULT_TIMEOUT
;
1507 // Construct DNS TokenEntry.
1509 TokenEntry
= AllocateZeroPool (sizeof(DNS6_TOKEN_ENTRY
));
1510 if (TokenEntry
== NULL
) {
1511 Status
= EFI_OUT_OF_RESOURCES
;
1515 TokenEntry
->PacketToLive
= Token
->RetryInterval
;
1516 TokenEntry
->GeneralLookUp
= TRUE
;
1517 TokenEntry
->Token
= Token
;
1520 // Construct DNS Query Packet.
1522 Status
= ConstructDNSQuery (Instance
, QName
, QType
, QClass
, &Packet
);
1523 if (EFI_ERROR (Status
)) {
1524 if (TokenEntry
!= NULL
) {
1525 FreePool (TokenEntry
);
1531 ASSERT (Packet
!= NULL
);
1534 // Save the token into the Dns6TxTokens map.
1536 Status
= NetMapInsertTail (&Instance
->Dns6TxTokens
, TokenEntry
, Packet
);
1537 if (EFI_ERROR (Status
)) {
1538 if (TokenEntry
!= NULL
) {
1539 FreePool (TokenEntry
);
1542 NetbufFree (Packet
);
1550 Status
= DoDnsQuery (Instance
, Packet
);
1551 if (EFI_ERROR (Status
)) {
1552 Dns6RemoveTokenEntry (&Instance
->Dns6TxTokens
, TokenEntry
);
1554 if (TokenEntry
!= NULL
) {
1555 FreePool (TokenEntry
);
1558 NetbufFree (Packet
);
1562 gBS
->RestoreTPL (OldTpl
);
1567 This function is to update the DNS Cache.
1569 The UpdateDnsCache() function is used to add/delete/modify DNS cache entry. DNS cache
1570 can be normally dynamically updated after the DNS resolve succeeds. This function
1571 provided capability to manually add/delete/modify the DNS cache.
1573 @param[in] This Pointer to EFI_DNS6_PROTOCOL instance.
1574 @param[in] DeleteFlag If FALSE, this function is to add one entry to the
1575 DNS Cahce. If TRUE, this function will delete
1576 matching DNS Cache entry.
1577 @param[in] Override If TRUE, the maching DNS cache entry will be
1578 overwritten with the supplied parameter. If FALSE,
1579 EFI_ACCESS_DENIED will be returned if the entry to
1580 be added is already existed.
1581 @param[in] DnsCacheEntry Pointer to DNS Cache entry.
1583 @retval EFI_SUCCESS The operation completed successfully.
1584 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
1586 DnsCacheEntry.HostName is NULL.
1587 DnsCacheEntry.IpAddress is NULL.
1588 DnsCacheEntry.Timeout is zero.
1589 @retval EFI_ACCESS_DENIED The DNS cache entry already exists and Override is
1591 @retval EFI_OUT_OF_RESOURCE Failed to allocate needed resources.
1595 Dns6UpdateDnsCache (
1596 IN EFI_DNS6_PROTOCOL
*This
,
1597 IN BOOLEAN DeleteFlag
,
1598 IN BOOLEAN Override
,
1599 IN EFI_DNS6_CACHE_ENTRY DnsCacheEntry
1605 Status
= EFI_SUCCESS
;
1607 if (DnsCacheEntry
.HostName
== NULL
|| DnsCacheEntry
.IpAddress
== NULL
|| DnsCacheEntry
.Timeout
== 0) {
1608 return EFI_INVALID_PARAMETER
;
1611 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
1614 // Update Dns6Cache here.
1616 Status
= UpdateDns6Cache (&mDriverData
->Dns6CacheList
, DeleteFlag
, Override
, DnsCacheEntry
);
1618 gBS
->RestoreTPL (OldTpl
);
1624 Polls for incoming data packets and processes outgoing data packets.
1626 The Poll() function can be used by network drivers and applications to increase the
1627 rate that data packets are moved between the communications device and the transmit
1630 In some systems, the periodic timer event in the managed network driver may not poll
1631 the underlying communications device fast enough to transmit and/or receive all data
1632 packets without missing incoming packets or dropping outgoing packets. Drivers and
1633 applications that are experiencing packet loss should try calling the Poll()
1634 function more often.
1636 @param[in] This Pointer to EFI_DNS6_PROTOCOL instance.
1638 @retval EFI_SUCCESS Incoming or outgoing data was processed.
1639 @retval EFI_NOT_STARTED This EFI DNS Protocol instance has not been started.
1640 @retval EFI_INVALID_PARAMETER This is NULL.
1641 @retval EFI_NO_MAPPING There is no source address is available for use.
1642 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
1643 @retval EFI_TIMEOUT Data was dropped out of the transmit and/or receive
1644 queue. Consider increasing the polling rate.
1649 IN EFI_DNS6_PROTOCOL
*This
1652 DNS_INSTANCE
*Instance
;
1653 EFI_UDP6_PROTOCOL
*Udp
;
1656 return EFI_INVALID_PARAMETER
;
1659 Instance
= DNS_INSTANCE_FROM_THIS_PROTOCOL6 (This
);
1661 if (Instance
->State
== DNS_STATE_UNCONFIGED
) {
1662 return EFI_NOT_STARTED
;
1663 } else if (Instance
->State
== DNS_STATE_DESTROY
) {
1664 return EFI_DEVICE_ERROR
;
1667 Udp
= Instance
->UdpIo
->Protocol
.Udp6
;
1669 return Udp
->Poll (Udp
);
1673 Abort an asynchronous DNS operation, including translation between IP and Host, and
1674 general look up behavior.
1676 The Cancel() function is used to abort a pending resolution request. After calling
1677 this function, Token.Status will be set to EFI_ABORTED and then Token.Event will be
1678 signaled. If the token is not in one of the queues, which usually means that the
1679 asynchronous operation has completed, this function will not signal the token and
1680 EFI_NOT_FOUND is returned.
1682 @param[in] This Pointer to EFI_DNS6_PROTOCOL instance.
1683 @param[in] Token Pointer to a token that has been issued by
1684 EFI_DNS6_PROTOCOL.HostNameToIp (),
1685 EFI_DNS6_PROTOCOL.IpToHostName() or
1686 EFI_DNS6_PROTOCOL.GeneralLookup().
1687 If NULL, all pending tokens are aborted.
1689 @retval EFI_SUCCESS Incoming or outgoing data was processed.
1690 @retval EFI_NOT_STARTED This EFI DNS6 Protocol instance has not been started.
1691 @retval EFI_INVALID_PARAMETER This is NULL.
1692 @retval EFI_NO_MAPPING There's no source address is available for use.
1693 @retval EFI_NOT_FOUND When Token is not NULL, and the asynchronous DNS
1694 operation was not found in the transmit queue. It
1695 was either completed or was not issued by
1696 HostNameToIp(), IpToHostName() or GeneralLookup().
1701 IN EFI_DNS6_PROTOCOL
*This
,
1702 IN EFI_DNS6_COMPLETION_TOKEN
*Token
1706 DNS_INSTANCE
*Instance
;
1710 return EFI_INVALID_PARAMETER
;
1713 Instance
= DNS_INSTANCE_FROM_THIS_PROTOCOL6 (This
);
1715 if (Instance
->State
== DNS_STATE_UNCONFIGED
) {
1716 return EFI_NOT_STARTED
;
1719 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
1722 // Cancle the tokens specified by Token for this instance.
1724 Status
= Dns6InstanceCancelToken (Instance
, Token
);
1727 // Dispatch the DPC queued by the NotifyFunction of the canceled token's events.
1731 gBS
->RestoreTPL (OldTpl
);