--- /dev/null
+/** @file\r
+Implementation of EFI_DNS4_PROTOCOL and EFI_DNS6_PROTOCOL interfaces.\r
+\r
+Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "DnsImpl.h"\r
+\r
+EFI_DNS4_PROTOCOL mDns4Protocol = {\r
+ Dns4GetModeData,\r
+ Dns4Configure,\r
+ Dns4HostNameToIp,\r
+ Dns4IpToHostName,\r
+ Dns4GeneralLookUp,\r
+ Dns4UpdateDnsCache,\r
+ Dns4Poll,\r
+ Dns4Cancel\r
+};\r
+\r
+EFI_DNS6_PROTOCOL mDns6Protocol = {\r
+ Dns6GetModeData,\r
+ Dns6Configure,\r
+ Dns6HostNameToIp,\r
+ Dns6IpToHostName,\r
+ Dns6GeneralLookUp,\r
+ Dns6UpdateDnsCache,\r
+ Dns6Poll,\r
+ Dns6Cancel\r
+};\r
+\r
+/**\r
+ This function is used to retrieve DNS mode data for this DNS instance.\r
+\r
+ @param[in] This Pointer to EFI_DNS4_PROTOCOL instance.\r
+ @param[out] DnsModeData Pointer to the caller-allocated storage for the EFI_DNS4_MODE_DATA structure.\r
+\r
+ @retval EFI_SUCCESS The operation completed successfully.\r
+ @retval EFI_NOT_STARTED When DnsConfigData is queried, no configuration data is \r
+ available because this instance has not been configured.\r
+ @retval EFI_OUT_OF_RESOURCES Failed to allocate needed resources.\r
+ @retval EFI_INVALID_PARAMETER This is NULL or DnsModeData is NULL.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Dns4GetModeData (\r
+ IN EFI_DNS4_PROTOCOL *This,\r
+ OUT EFI_DNS4_MODE_DATA *DnsModeData\r
+ )\r
+{\r
+ DNS_INSTANCE *Instance;\r
+ \r
+ EFI_TPL OldTpl;\r
+\r
+ UINTN Index;\r
+ \r
+ LIST_ENTRY *Entry;\r
+ LIST_ENTRY *Next;\r
+ \r
+ DNS4_SERVER_IP *ServerItem;\r
+ EFI_IPv4_ADDRESS *ServerList;\r
+ DNS4_CACHE *CacheItem;\r
+ EFI_DNS4_CACHE_ENTRY *CacheList;\r
+ EFI_STATUS Status;\r
+\r
+ ServerItem = NULL;\r
+ ServerList = NULL;\r
+ CacheItem = NULL;\r
+ CacheList = NULL;\r
+ Status = EFI_SUCCESS;\r
+ \r
+ \r
+ if ((This == NULL) || (DnsModeData == NULL)) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
+ \r
+ Instance = DNS_INSTANCE_FROM_THIS_PROTOCOL4 (This);\r
+ if (Instance->State == DNS_STATE_UNCONFIGED) {\r
+ gBS->RestoreTPL (OldTpl);\r
+ return EFI_NOT_STARTED;\r
+ }\r
+ \r
+ ZeroMem (DnsModeData, sizeof (EFI_DNS4_MODE_DATA));\r
+\r
+ //\r
+ // Get the current configuration data of this instance. \r
+ //\r
+ Status = Dns4CopyConfigure (&DnsModeData->DnsConfigData, &Instance->Dns4CfgData);\r
+ if (EFI_ERROR (Status)) {\r
+ gBS->RestoreTPL (OldTpl);\r
+ return Status;\r
+ }\r
+\r
+ //\r
+ // Get the DnsServerCount and DnsServerList\r
+ //\r
+ Index = 0;\r
+ NET_LIST_FOR_EACH_SAFE (Entry, Next, &mDriverData->Dns4ServerList) {\r
+ Index++;\r
+ }\r
+ DnsModeData->DnsServerCount = (UINT32) Index;\r
+ ServerList = AllocatePool (sizeof (EFI_IPv4_ADDRESS) * DnsModeData->DnsServerCount);\r
+ ASSERT (ServerList != NULL);\r
+ Index = 0;\r
+ NET_LIST_FOR_EACH_SAFE (Entry, Next, &mDriverData->Dns4ServerList) {\r
+ ServerItem = NET_LIST_USER_STRUCT (Entry, DNS4_SERVER_IP, AllServerLink);\r
+ CopyMem (ServerList + Index, &ServerItem->Dns4ServerIp, sizeof (EFI_IPv4_ADDRESS));\r
+ Index++;\r
+ }\r
+ DnsModeData->DnsServerList = ServerList;\r
+\r
+ //\r
+ // Get the DnsCacheCount and DnsCacheList\r
+ //\r
+ Index =0;\r
+ NET_LIST_FOR_EACH_SAFE (Entry, Next, &mDriverData->Dns4CacheList) {\r
+ Index++;\r
+ }\r
+ DnsModeData->DnsCacheCount = (UINT32) Index;\r
+ CacheList = AllocatePool (sizeof (EFI_DNS4_CACHE_ENTRY) * DnsModeData->DnsCacheCount);\r
+ ASSERT (CacheList != NULL);\r
+ Index =0;\r
+ NET_LIST_FOR_EACH_SAFE (Entry, Next, &mDriverData->Dns4CacheList) {\r
+ CacheItem = NET_LIST_USER_STRUCT (Entry, DNS4_CACHE, AllCacheLink);\r
+ CopyMem (CacheList + Index, &CacheItem->DnsCache, sizeof (EFI_DNS4_CACHE_ENTRY));\r
+ Index++;\r
+ }\r
+ DnsModeData->DnsCacheList = CacheList;\r
+\r
+ gBS->RestoreTPL (OldTpl);\r
+ \r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ This function is used to configure DNS configuration data for this DNS instance.\r
+\r
+ @param[in] This Pointer to EFI_DNS4_PROTOCOL instance.\r
+ @param[in] DnsConfigData Pointer to caller-allocated buffer containing EFI_DNS4_CONFIG_DATA structure. \r
+ If NULL, the driver will reinitialize the protocol instance to the unconfigured state.\r
+\r
+ @retval EFI_SUCCESS The operation completed successfully.\r
+ @retval EFI_UNSUPPORTED The designated protocol is not supported.\r
+ @retval EFI_OUT_OF_RESOURCES Failed to allocate needed resources.\r
+ @retval EFI_INVALID_PARAMETER This is NULL.\r
+ The StationIp address provided in DnsConfigData is not a valid unicast.\r
+ DnsServerList is NULL while DnsServerListCount is not equal to Zero.\r
+ DnsServerListCount is Zero while DnsServerListCount is not equal to NULL.\r
+ @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. The EFI DNSv4 Protocol instance is not configured.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Dns4Configure (\r
+ IN EFI_DNS4_PROTOCOL *This,\r
+ IN EFI_DNS4_CONFIG_DATA *DnsConfigData\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ DNS_INSTANCE *Instance;\r
+ \r
+ EFI_TPL OldTpl;\r
+ IP4_ADDR Ip;\r
+ IP4_ADDR Netmask;\r
+\r
+ UINT32 ServerListCount;\r
+ EFI_IPv4_ADDRESS *ServerList; \r
+\r
+ Status = EFI_SUCCESS;\r
+ ServerList = NULL;\r
+ \r
+ if (This == NULL || \r
+ (DnsConfigData != NULL && ((DnsConfigData->DnsServerListCount != 0 && DnsConfigData->DnsServerList == NULL) || \r
+ (DnsConfigData->DnsServerListCount == 0 && DnsConfigData->DnsServerList != NULL)))) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ if (DnsConfigData != NULL && DnsConfigData->Protocol != DNS_PROTOCOL_UDP) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
+\r
+ Instance = DNS_INSTANCE_FROM_THIS_PROTOCOL4 (This);\r
+\r
+ if (DnsConfigData == NULL) {\r
+ ZeroMem (&Instance->SessionDnsServer, sizeof (EFI_IP_ADDRESS));\r
+ \r
+ //\r
+ // Reset the Instance if ConfigData is NULL\r
+ //\r
+ if (!NetMapIsEmpty(&Instance->Dns4TxTokens)) {\r
+ Dns4InstanceCancelToken(Instance, NULL);\r
+ }\r
+\r
+ Instance->MaxRetry = 0;\r
+\r
+ if (Instance->UdpIo != NULL){\r
+ UdpIoCleanIo (Instance->UdpIo);\r
+ }\r
+ \r
+ if (Instance->Dns4CfgData.DnsServerList != NULL) {\r
+ FreePool (Instance->Dns4CfgData.DnsServerList);\r
+ }\r
+ ZeroMem (&Instance->Dns4CfgData, sizeof (EFI_DNS4_CONFIG_DATA));\r
+ \r
+ Instance->State = DNS_STATE_UNCONFIGED;\r
+ } else {\r
+ //\r
+ // Configure the parameters for new operation.\r
+ //\r
+ CopyMem (&Ip, &DnsConfigData->StationIp, sizeof (IP4_ADDR));\r
+ CopyMem (&Netmask, &DnsConfigData->SubnetMask, sizeof (IP4_ADDR));\r
+\r
+ Ip = NTOHL (Ip);\r
+ Netmask = NTOHL (Netmask);\r
+\r
+ if (!DnsConfigData->UseDefaultSetting &&\r
+ ((!IP4_IS_VALID_NETMASK (Netmask) || !NetIp4IsUnicast (Ip, Netmask)))) {\r
+ Status = EFI_INVALID_PARAMETER;\r
+ goto ON_EXIT;\r
+ }\r
+\r
+ Status = Dns4CopyConfigure (&Instance->Dns4CfgData, DnsConfigData);\r
+ if (EFI_ERROR (Status)) {\r
+ goto ON_EXIT;\r
+ }\r
+\r
+ if (DnsConfigData->DnsServerListCount == 0 || DnsConfigData->DnsServerList == NULL) {\r
+ gBS->RestoreTPL (OldTpl); \r
+ \r
+ //\r
+ // The DNS instance will retrieve DNS server from DHCP Server\r
+ //\r
+ Status = GetDns4ServerFromDhcp4 (\r
+ Instance,\r
+ &ServerListCount, \r
+ &ServerList\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ ASSERT(ServerList != NULL);\r
+ \r
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
+\r
+ CopyMem (&Instance->SessionDnsServer.v4, &ServerList[0], sizeof (EFI_IPv4_ADDRESS));\r
+ } else {\r
+ CopyMem (&Instance->SessionDnsServer.v4, &DnsConfigData->DnsServerList[0], sizeof (EFI_IPv4_ADDRESS));\r
+ }\r
+\r
+ //\r
+ // Config UDP\r
+ //\r
+ Status = Dns4ConfigUdp (Instance, Instance->UdpIo);\r
+ if (EFI_ERROR (Status)) {\r
+ if (Instance->Dns4CfgData.DnsServerList != NULL) {\r
+ FreePool (Instance->Dns4CfgData.DnsServerList);\r
+ }\r
+ goto ON_EXIT;\r
+ }\r
+\r
+ //\r
+ // Add configured DNS server used by this instance to ServerList.\r
+ //\r
+ Status = AddDns4ServerIp (&mDriverData->Dns4ServerList, Instance->SessionDnsServer.v4);\r
+ if (EFI_ERROR (Status)) {\r
+ if (Instance->Dns4CfgData.DnsServerList != NULL) {\r
+ FreePool (Instance->Dns4CfgData.DnsServerList);\r
+ }\r
+ goto ON_EXIT;\r
+ }\r
+ \r
+ Instance->State = DNS_STATE_CONFIGED;\r
+ }\r
+\r
+ON_EXIT:\r
+ gBS->RestoreTPL (OldTpl);\r
+ return Status;\r
+}\r
+\r
+/**\r
+ The function is used to translate the host name to host IP address. \r
+ A type A query is used to get the one or more IP addresses for this host. \r
+\r
+ @param[in] This Pointer to EFI_DNS4_PROTOCOL instance.\r
+ @param[in] HostName Pointer to caller-supplied buffer containing Host name to be translated. \r
+ This buffer contains 16 bit characters but these are translated to ASCII for use with \r
+ DNSv4 server and there is no requirement for driver to support non-ASCII Unicode characters.\r
+ @param[in] Token Pointer to the caller-allocated completion token to return at the completion of the process to translate host name to host address. \r
+\r
+ @retval EFI_SUCCESS The operation completed successfully.\r
+ @retval EFI_OUT_OF_RESOURCES Failed to allocate needed resources.\r
+ @retval EFI_INVALID_PARAMETER This is NULL.\r
+ Token is NULL.\r
+ Token.Event is.NULL\r
+ HostName is NULL\r
+ @retval EFI_NO_MAPPING There's no source address is available for use.\r
+ @retval EFI_NOT_STARTED This instance has not been started.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Dns4HostNameToIp (\r
+ IN EFI_DNS4_PROTOCOL *This,\r
+ IN CHAR16 *HostName,\r
+ IN EFI_DNS4_COMPLETION_TOKEN *Token\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ \r
+ DNS_INSTANCE *Instance;\r
+ \r
+ EFI_DNS4_CONFIG_DATA *ConfigData;\r
+ \r
+ UINTN Index;\r
+ DNS4_CACHE *Item;\r
+ LIST_ENTRY *Entry;\r
+ LIST_ENTRY *Next;\r
+ \r
+ DNS4_TOKEN_ENTRY *TokenEntry;\r
+ NET_BUF *Packet;\r
+ \r
+ EFI_TPL OldTpl;\r
+ \r
+ Status = EFI_SUCCESS;\r
+ Item = NULL;\r
+ TokenEntry = NULL;\r
+ Packet = NULL;\r
+ \r
+ //\r
+ // Validate the parameters\r
+ //\r
+ if ((This == NULL) || (HostName == NULL) || Token == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+ \r
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
+ \r
+ Instance = DNS_INSTANCE_FROM_THIS_PROTOCOL4 (This);\r
+ \r
+ ConfigData = &(Instance->Dns4CfgData);\r
+ \r
+ Instance->MaxRetry = ConfigData->RetryCount;\r
+ \r
+ Token->Status = EFI_NOT_READY;\r
+ Token->RetryCount = 0;\r
+ Token->RetryInterval = ConfigData->RetryInterval;\r
+\r
+ if (Instance->State != DNS_STATE_CONFIGED) {\r
+ Status = EFI_NOT_STARTED;\r
+ goto ON_EXIT;\r
+ }\r
+\r
+ //\r
+ // Check the MaxRetry and RetryInterval values.\r
+ //\r
+ if (Instance->MaxRetry == 0) {\r
+ Instance->MaxRetry = DNS_DEFAULT_RETRY;\r
+ }\r
+\r
+ if (Token->RetryInterval < DNS_DEFAULT_TIMEOUT) {\r
+ Token->RetryInterval = DNS_DEFAULT_TIMEOUT;\r
+ }\r
+\r
+ //\r
+ // Check cache\r
+ //\r
+ if (ConfigData->EnableDnsCache) {\r
+ Index = 0;\r
+ NET_LIST_FOR_EACH_SAFE (Entry, Next, &mDriverData->Dns4CacheList) {\r
+ Item = NET_LIST_USER_STRUCT (Entry, DNS4_CACHE, AllCacheLink);\r
+ if (StrCmp (HostName, Item->DnsCache.HostName) == 0) {\r
+ Index++;\r
+ }\r
+ }\r
+\r
+ if (Index != 0) {\r
+ Token->RspData.H2AData = AllocatePool (sizeof (DNS_HOST_TO_ADDR_DATA));\r
+ if (Token->RspData.H2AData == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto ON_EXIT;\r
+ }\r
+\r
+ Token->RspData.H2AData->IpCount = (UINT32)Index;\r
+ Token->RspData.H2AData->IpList = AllocatePool (sizeof (EFI_IPv4_ADDRESS) * Index);\r
+ if (Token->RspData.H2AData->IpList == NULL) {\r
+ if (Token->RspData.H2AData != NULL) {\r
+ FreePool (Token->RspData.H2AData);\r
+ }\r
+ \r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto ON_EXIT;\r
+ }\r
+\r
+ Index = 0;\r
+ NET_LIST_FOR_EACH_SAFE (Entry, Next, &mDriverData->Dns4CacheList) {\r
+ Item = NET_LIST_USER_STRUCT (Entry, DNS4_CACHE, AllCacheLink);\r
+ if ((UINT32)Index < Token->RspData.H2AData->IpCount && StrCmp (HostName, Item->DnsCache.HostName) == 0) {\r
+ CopyMem ((Token->RspData.H2AData->IpList) + Index, Item->DnsCache.IpAddress, sizeof (EFI_IPv4_ADDRESS));\r
+ Index++; \r
+ }\r
+ }\r
+ \r
+ Token->Status = EFI_SUCCESS;\r
+ \r
+ if (Token->Event != NULL) {\r
+ gBS->SignalEvent (Token->Event);\r
+ DispatchDpc ();\r
+ }\r
+\r
+ Status = Token->Status;\r
+ goto ON_EXIT;\r
+ } \r
+ }\r
+\r
+ //\r
+ // Construct DNS TokenEntry.\r
+ //\r
+ TokenEntry = AllocateZeroPool (sizeof(DNS4_TOKEN_ENTRY));\r
+ if (TokenEntry == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto ON_EXIT;\r
+ }\r
+ \r
+ TokenEntry->PacketToLive = Token->RetryInterval;\r
+ TokenEntry->QueryHostName = HostName;\r
+ TokenEntry->Token = Token;\r
+\r
+ //\r
+ // Construct DNS Query Packet.\r
+ //\r
+ Status = ConstructDNSQueryIp (Instance, TokenEntry->QueryHostName, DNS_TYPE_A, &Packet);\r
+ if (EFI_ERROR (Status)) {\r
+ if (TokenEntry != NULL) {\r
+ FreePool (TokenEntry);\r
+ }\r
+ \r
+ goto ON_EXIT;\r
+ }\r
+\r
+ //\r
+ // Save the token into the Dns4TxTokens map.\r
+ //\r
+ Status = NetMapInsertTail (&Instance->Dns4TxTokens, TokenEntry, Packet);\r
+ if (EFI_ERROR (Status)) {\r
+ if (TokenEntry != NULL) {\r
+ FreePool (TokenEntry);\r
+ }\r
+ \r
+ NetbufFree (Packet);\r
+ \r
+ goto ON_EXIT;\r
+ }\r
+ \r
+ //\r
+ // Dns Query Ip\r
+ //\r
+ Status = DoDnsQuery (Instance, Packet);\r
+ if (EFI_ERROR (Status)) {\r
+ if (TokenEntry != NULL) {\r
+ FreePool (TokenEntry);\r
+ }\r
+ \r
+ NetbufFree (Packet);\r
+ }\r
+ \r
+ON_EXIT:\r
+ gBS->RestoreTPL (OldTpl);\r
+ return Status;\r
+}\r
+\r
+/**\r
+ The function is used to translate the host address to host name. \r
+ A type PTR query is used to get the primary name of the host. \r
+\r
+ @param[in] This Pointer to EFI_DNS4_PROTOCOL instance.\r
+ @param[in] IpAddress IP address.\r
+ @param[in] Token Pointer to the caller-allocated completion used token to translate host address to host name.\r
+\r
+ @retval EFI_SUCCESS The operation completed successfully.\r
+ @retval EFI_OUT_OF_RESOURCES Failed to allocate needed resources.\r
+ @retval EFI_INVALID_PARAMETER This is NULL.\r
+ Token is NULL.\r
+ Token.Event is NULL.\r
+ IpAddress is not valid IP address.\r
+ @retval EFI_NO_MAPPING There's no source address is available for use.\r
+ @retval EFI_NOT_STARTED This instance has not been started.\r
+ @retval EFI_UNSUPPORTED This function is not supported.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Dns4IpToHostName (\r
+ IN EFI_DNS4_PROTOCOL *This,\r
+ IN EFI_IPv4_ADDRESS IpAddress,\r
+ IN EFI_DNS4_COMPLETION_TOKEN *Token\r
+ )\r
+{\r
+ return EFI_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+ This function retrieves arbitrary information from the DNS. \r
+ The caller supplies a QNAME, QTYPE, and QCLASS, and all of the matching RRs are returned. \r
+ All RR content (e.g., Ttl) was returned. \r
+ The caller need parse the returned RR to get required information. This function is optional.\r
+\r
+ @param[in] This Pointer to EFI_DNS4_PROTOCOL instance.\r
+ @param[in] QName Pointer to Query Name.\r
+ @param[in] QType Query Type.\r
+ @param[in] QClass Query Name.\r
+ @param[in] Token Point to the caller-allocated completion token to retrieve arbitrary information.\r
+\r
+ @retval EFI_SUCCESS The operation completed successfully.\r
+ @retval EFI_OUT_OF_RESOURCES Failed to allocate needed resources.\r
+ @retval EFI_INVALID_PARAMETER This is NULL.\r
+ Token is NULL.\r
+ Token.Event is NULL.\r
+ QName is NULL.\r
+ @retval EFI_NO_MAPPING There's no source address is available for use.\r
+ @retval EFI_ALREADY_STARTED This Token is being used in another DNS session.\r
+ @retval EFI_UNSUPPORTED This function is not supported. Or the requested QType is not supported\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Dns4GeneralLookUp (\r
+ IN EFI_DNS4_PROTOCOL *This,\r
+ IN CHAR8 *QName,\r
+ IN UINT16 QType, \r
+ IN UINT16 QClass,\r
+ IN EFI_DNS4_COMPLETION_TOKEN *Token\r
+ )\r
+{\r
+ return EFI_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+ This function is used to add/delete/modify DNS cache entry. \r
+ DNS cache can be normally dynamically updated after the DNS resolve succeeds. \r
+ This function provided capability to manually add/delete/modify the DNS cache.\r
+\r
+ @param[in] This Pointer to EFI_DNS4_PROTOCOL instance.\r
+ @param[in] DeleteFlag If FALSE, this function is to add one entry to the DNS Cache. \r
+ If TRUE, this function will delete matching DNS Cache entry. \r
+ @param[in] Override If TRUE, the matching DNS cache entry will be overwritten with the supplied parameter. \r
+ If FALSE, EFI_ACCESS_DENIED will be returned if the entry to be added is already exists.\r
+ @param[in] DnsCacheEntry Pointer to DNS Cache entry.\r
+\r
+ @retval EFI_SUCCESS The operation completed successfully.\r
+ @retval EFI_INVALID_PARAMETER This is NULL. \r
+ DnsCacheEntry.HostName is NULL.\r
+ DnsCacheEntry.IpAddress is NULL.\r
+ DnsCacheEntry.Timeout is zero.\r
+ @retval EFI_ACCESS_DENIED The DNS cache entry already exists and Override is not TRUE. \r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Dns4UpdateDnsCache (\r
+ IN EFI_DNS4_PROTOCOL *This,\r
+ IN BOOLEAN DeleteFlag,\r
+ IN BOOLEAN Override,\r
+ IN EFI_DNS4_CACHE_ENTRY DnsCacheEntry\r
+ )\r
+{\r
+ EFI_STATUS Status; \r
+ EFI_TPL OldTpl;\r
+\r
+ Status = EFI_SUCCESS;\r
+ \r
+ if (DnsCacheEntry.HostName == NULL || DnsCacheEntry.IpAddress == NULL || DnsCacheEntry.Timeout == 0) {\r
+ return EFI_INVALID_PARAMETER; \r
+ }\r
+ \r
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
+\r
+ //\r
+ // Update Dns4Cache here.\r
+ //\r
+ Status = UpdateDns4Cache (&mDriverData->Dns4CacheList, DeleteFlag, Override, DnsCacheEntry);\r
+\r
+ gBS->RestoreTPL (OldTpl);\r
+ \r
+ return Status;\r
+}\r
+\r
+/**\r
+ This function can be used by network drivers and applications to increase the rate that data packets are moved between \r
+ the communications device and the transmit and receive queues. In some systems, the periodic timer event in the managed \r
+ network driver may not poll the underlying communications device fast enough to transmit and/or receive all data packets \r
+ without missing incoming packets or dropping outgoing packets.\r
+\r
+ @param[in] This Pointer to EFI_DNS4_PROTOCOL instance.\r
+\r
+ @retval EFI_SUCCESS Incoming or outgoing data was processed.\r
+ @retval EFI_INVALID_PARAMETER This is NULL. \r
+ @retval EFI_NOT_STARTED This EFI DNS Protocol instance has not been started. \r
+ @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. \r
+ @retval EFI_TIMEOUT Data was dropped out of the transmit and/or receive queue. \r
+ Consider increasing the polling rate.\r
+ \r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Dns4Poll (\r
+ IN EFI_DNS4_PROTOCOL *This\r
+ )\r
+{\r
+ DNS_INSTANCE *Instance;\r
+ EFI_UDP4_PROTOCOL *Udp;\r
+\r
+ if (This == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ Instance = DNS_INSTANCE_FROM_THIS_PROTOCOL4 (This);\r
+\r
+ if (Instance->State == DNS_STATE_UNCONFIGED) {\r
+ return EFI_NOT_STARTED;\r
+ } else if (Instance->State == DNS_STATE_DESTROY) {\r
+ return EFI_DEVICE_ERROR;\r
+ }\r
+\r
+ Udp = Instance->UdpIo->Protocol.Udp4;\r
+ \r
+ return Udp->Poll (Udp);\r
+}\r
+\r
+/**\r
+ This function is used to abort a pending resolution request. \r
+ After calling this function, Token.Status will be set to EFI_ABORTED and then Token.\r
+\r
+ @param[in] This Pointer to EFI_DNS4_PROTOCOL instance.\r
+ @param[in] Token Pointer to a token that has been issued by EFI_DNS4_PROTOCOL.HostNameToIp(), \r
+ EFI_DNS4_PROTOCOL.IpToHostName() or EFI_DNS4_PROTOCOL.GeneralLookup(). \r
+ If NULL, all pending tokens are aborted.\r
+\r
+ @retval EFI_SUCCESS Incoming or outgoing data was processed.\r
+ @retval EFI_INVALID_PARAMETER This is NULL. \r
+ @retval EFI_NOT_STARTED This EFI DNS Protocol instance has not been started. \r
+ @retval EFI_NOT_FOUND When Token is not NULL, and the asynchronous DNS operation was not found in the transmit queue. \r
+ It was either completed or was not issued by HostNameToIp(), IpToHostName() or GeneralLookup().\r
+ \r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Dns4Cancel (\r
+ IN EFI_DNS4_PROTOCOL *This,\r
+ IN EFI_DNS4_COMPLETION_TOKEN *Token\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ DNS_INSTANCE *Instance;\r
+ EFI_TPL OldTpl;\r
+\r
+ if (This == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ Instance = DNS_INSTANCE_FROM_THIS_PROTOCOL4 (This);\r
+\r
+ if (Instance->State == DNS_STATE_UNCONFIGED) {\r
+ return EFI_NOT_STARTED;\r
+ }\r
+\r
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
+\r
+ //\r
+ // Cancle the tokens specified by Token for this instance.\r
+ //\r
+ Status = Dns4InstanceCancelToken (Instance, Token);\r
+\r
+ //\r
+ // Dispatch the DPC queued by the NotifyFunction of the canceled token's events.\r
+ //\r
+ DispatchDpc ();\r
+\r
+ gBS->RestoreTPL (OldTpl);\r
+\r
+ return Status;\r
+}\r
+\r
+/**\r
+ This function is used to retrieve DNS mode data for this DNS instance.\r
+\r
+ @param[in] This Pointer to EFI_DNS6_PROTOCOL instance.\r
+ @param[out] DnsModeData Pointer to the caller-allocated storage for the EFI_DNS6_MODE_DATA structure.\r
+\r
+ @retval EFI_SUCCESS The operation completed successfully.\r
+ @retval EFI_NOT_STARTED When DnsConfigData is queried, no configuration data is \r
+ available because this instance has not been configured.\r
+ @retval EFI_OUT_OF_RESOURCES Failed to allocate needed resources.\r
+ @retval EFI_INVALID_PARAMETER This is NULL or DnsModeData is NULL.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Dns6GetModeData (\r
+ IN EFI_DNS6_PROTOCOL *This,\r
+ OUT EFI_DNS6_MODE_DATA *DnsModeData\r
+ )\r
+{\r
+ DNS_INSTANCE *Instance;\r
+ \r
+ EFI_TPL OldTpl;\r
+\r
+ UINTN Index;\r
+ \r
+ LIST_ENTRY *Entry;\r
+ LIST_ENTRY *Next;\r
+\r
+ DNS6_SERVER_IP *ServerItem;\r
+ EFI_IPv6_ADDRESS *ServerList;\r
+ DNS6_CACHE *CacheItem;\r
+ EFI_DNS6_CACHE_ENTRY *CacheList;\r
+ EFI_STATUS Status;\r
+\r
+ ServerItem = NULL;\r
+ ServerList = NULL;\r
+ CacheItem = NULL;\r
+ CacheList = NULL;\r
+ Status = EFI_SUCCESS;\r
+\r
+ if ((This == NULL) || (DnsModeData == NULL)) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
+ \r
+ Instance = DNS_INSTANCE_FROM_THIS_PROTOCOL6 (This);\r
+ if (Instance->State == DNS_STATE_UNCONFIGED) {\r
+ gBS->RestoreTPL (OldTpl);\r
+ return EFI_NOT_STARTED;\r
+ }\r
+\r
+ ZeroMem (DnsModeData, sizeof (EFI_DNS6_MODE_DATA));\r
+\r
+ //\r
+ // Get the current configuration data of this instance. \r
+ //\r
+ Status = Dns6CopyConfigure(&DnsModeData->DnsConfigData, &Instance->Dns6CfgData);\r
+ if (EFI_ERROR (Status)) {\r
+ gBS->RestoreTPL (OldTpl);\r
+ return Status;\r
+ }\r
+ \r
+ //\r
+ // Get the DnsServerCount and DnsServerList\r
+ //\r
+ Index = 0;\r
+ NET_LIST_FOR_EACH_SAFE (Entry, Next, &mDriverData->Dns6ServerList) {\r
+ Index++;\r
+ }\r
+ DnsModeData->DnsServerCount = (UINT32) Index;\r
+ ServerList = AllocatePool (sizeof(EFI_IPv6_ADDRESS) * DnsModeData->DnsServerCount);\r
+ ASSERT (ServerList != NULL);\r
+ Index = 0;\r
+ NET_LIST_FOR_EACH_SAFE (Entry, Next, &mDriverData->Dns6ServerList) {\r
+ ServerItem = NET_LIST_USER_STRUCT (Entry, DNS6_SERVER_IP, AllServerLink);\r
+ CopyMem (ServerList + Index, &ServerItem->Dns6ServerIp, sizeof (EFI_IPv6_ADDRESS));\r
+ Index++;\r
+ }\r
+ DnsModeData->DnsServerList = ServerList;\r
+\r
+ //\r
+ // Get the DnsCacheCount and DnsCacheList\r
+ //\r
+ Index =0;\r
+ NET_LIST_FOR_EACH_SAFE (Entry, Next, &mDriverData->Dns6CacheList) {\r
+ Index++;\r
+ }\r
+ DnsModeData->DnsCacheCount = (UINT32) Index;\r
+ CacheList = AllocatePool (sizeof(EFI_DNS6_CACHE_ENTRY) * DnsModeData->DnsCacheCount);\r
+ ASSERT (CacheList != NULL);\r
+ Index =0;\r
+ NET_LIST_FOR_EACH_SAFE (Entry, Next, &mDriverData->Dns6CacheList) {\r
+ CacheItem = NET_LIST_USER_STRUCT (Entry, DNS6_CACHE, AllCacheLink);\r
+ CopyMem (CacheList + Index, &CacheItem->DnsCache, sizeof (EFI_DNS6_CACHE_ENTRY));\r
+ Index++;\r
+ }\r
+ DnsModeData->DnsCacheList = CacheList;\r
+\r
+ gBS->RestoreTPL (OldTpl);\r
+ \r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ The function is used to set and change the configuration data for this EFI DNSv6 Protocol driver instance. \r
+ Reset the DNS instance if DnsConfigData is NULL.\r
+\r
+ @param[in] This Pointer to EFI_DNS6_PROTOCOL instance.\r
+ @param[in] DnsConfigData Pointer to the configuration data structure. \r
+ All associated storage to be allocated and released by caller.\r
+\r
+ @retval EFI_SUCCESS The operation completed successfully.\r
+ @retval EFI_UNSUPPORTED The designated protocol is not supported.\r
+ @retval EFI_OUT_OF_RESOURCES Failed to allocate needed resources.\r
+ @retval EFI_INVALID_PARAMETER This is NULL.\r
+ The StationIp address provided in DnsConfigData is not a valid unicast.\r
+ DnsServerList is NULL while DnsServerListCount is not equal to Zero.\r
+ DnsServerListCount is Zero while DnsServerList is not equal to NULL.\r
+ @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. The EFI DNSv6 Protocol instance is not configured.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Dns6Configure (\r
+ IN EFI_DNS6_PROTOCOL *This,\r
+ IN EFI_DNS6_CONFIG_DATA *DnsConfigData\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ DNS_INSTANCE *Instance;\r
+ \r
+ EFI_TPL OldTpl;\r
+\r
+ UINT32 ServerListCount;\r
+ EFI_IPv6_ADDRESS *ServerList; \r
+\r
+ Status = EFI_SUCCESS;\r
+ ServerList = NULL;\r
+\r
+ if (This == NULL || \r
+ (DnsConfigData != NULL && ((DnsConfigData->DnsServerCount != 0 && DnsConfigData->DnsServerList == NULL) || \r
+ (DnsConfigData->DnsServerCount == 0 && DnsConfigData->DnsServerList != NULL)))) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ if (DnsConfigData != NULL && DnsConfigData->Protocol != DNS_PROTOCOL_UDP) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
+\r
+ Instance = DNS_INSTANCE_FROM_THIS_PROTOCOL6 (This);\r
+\r
+ if (DnsConfigData == NULL) {\r
+ ZeroMem (&Instance->SessionDnsServer, sizeof (EFI_IP_ADDRESS));\r
+\r
+ //\r
+ // Reset the Instance if ConfigData is NULL\r
+ //\r
+ if (!NetMapIsEmpty(&Instance->Dns6TxTokens)) {\r
+ Dns6InstanceCancelToken(Instance, NULL);\r
+ }\r
+\r
+ Instance->MaxRetry = 0;\r
+\r
+ if (Instance->UdpIo != NULL){\r
+ UdpIoCleanIo (Instance->UdpIo);\r
+ }\r
+\r
+ if (Instance->Dns6CfgData.DnsServerList != NULL) {\r
+ FreePool (Instance->Dns6CfgData.DnsServerList);\r
+ }\r
+ ZeroMem (&Instance->Dns6CfgData, sizeof (EFI_DNS6_CONFIG_DATA));\r
+ \r
+ Instance->State = DNS_STATE_UNCONFIGED;\r
+ } else {\r
+ //\r
+ // Configure the parameters for new operation.\r
+ //\r
+ if (!NetIp6IsValidUnicast (&DnsConfigData->StationIp)) {\r
+ Status = EFI_INVALID_PARAMETER;\r
+ goto ON_EXIT;\r
+ }\r
+\r
+ Status = Dns6CopyConfigure (&Instance->Dns6CfgData, DnsConfigData);\r
+ if (EFI_ERROR (Status)) {\r
+ goto ON_EXIT;\r
+ }\r
+\r
+ if (DnsConfigData->DnsServerCount == 0 || DnsConfigData->DnsServerList == NULL) {\r
+ gBS->RestoreTPL (OldTpl);\r
+\r
+ //\r
+ //The DNS instance will retrieve DNS server from DHCP Server.\r
+ //\r
+ Status = GetDns6ServerFromDhcp6 (\r
+ Instance->Service->ImageHandle,\r
+ Instance->Service->ControllerHandle, \r
+ &ServerListCount, \r
+ &ServerList\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ goto ON_EXIT;\r
+ }\r
+ \r
+ ASSERT(ServerList != NULL);\r
+\r
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
+\r
+ CopyMem (&Instance->SessionDnsServer.v6, &ServerList[0], sizeof (EFI_IPv6_ADDRESS));\r
+ } else {\r
+ CopyMem (&Instance->SessionDnsServer.v6, &DnsConfigData->DnsServerList[0], sizeof (EFI_IPv6_ADDRESS));\r
+ }\r
+\r
+ //\r
+ // Config UDP\r
+ //\r
+ Status = Dns6ConfigUdp (Instance, Instance->UdpIo);\r
+ if (EFI_ERROR (Status)) {\r
+ if (Instance->Dns6CfgData.DnsServerList != NULL) {\r
+ FreePool (Instance->Dns6CfgData.DnsServerList);\r
+ }\r
+ goto ON_EXIT;\r
+ }\r
+\r
+ //\r
+ // Add configured DNS server used by this instance to ServerList.\r
+ //\r
+ Status = AddDns6ServerIp (&mDriverData->Dns6ServerList, Instance->SessionDnsServer.v6);\r
+ if (EFI_ERROR (Status)) {\r
+ if (Instance->Dns6CfgData.DnsServerList != NULL) {\r
+ FreePool (Instance->Dns6CfgData.DnsServerList);\r
+ }\r
+ goto ON_EXIT;\r
+ }\r
+ \r
+ Instance->State = DNS_STATE_CONFIGED;\r
+ }\r
+\r
+ON_EXIT:\r
+ gBS->RestoreTPL (OldTpl);\r
+ return Status;\r
+}\r
+\r
+/**\r
+ The function is used to translate the host name to host IP address. \r
+ A type AAAA query is used to get the one or more IPv6 addresses for this host. \r
+\r
+ @param[in] This Pointer to EFI_DNS6_PROTOCOL instance.\r
+ @param[in] HostName Pointer to caller-supplied buffer containing Host name to be translated. \r
+ This buffer contains 16 bit characters but these are translated to ASCII for use with \r
+ DNSv4 server and there is no requirement for driver to support non-ASCII Unicode characters.\r
+ @param[in] Token Pointer to the caller-allocated completion token to return at the completion of the process to translate host name to host address. \r
+\r
+ @retval EFI_SUCCESS The operation completed successfully.\r
+ @retval EFI_OUT_OF_RESOURCES Failed to allocate needed resources.\r
+ @retval EFI_INVALID_PARAMETER This is NULL.\r
+ Token is NULL.\r
+ Token.Event is.NULL\r
+ HostName is NULL\r
+ @retval EFI_NO_MAPPING There's no source address is available for use.\r
+ @retval EFI_NOT_STARTED This instance has not been started.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Dns6HostNameToIp (\r
+ IN EFI_DNS6_PROTOCOL *This,\r
+ IN CHAR16 *HostName,\r
+ IN EFI_DNS6_COMPLETION_TOKEN *Token\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ \r
+ DNS_INSTANCE *Instance;\r
+\r
+ EFI_DNS6_CONFIG_DATA *ConfigData;\r
+ \r
+ UINTN Index; \r
+ DNS6_CACHE *Item;\r
+ LIST_ENTRY *Entry;\r
+ LIST_ENTRY *Next;\r
+ \r
+ DNS6_TOKEN_ENTRY *TokenEntry;\r
+ NET_BUF *Packet;\r
+ \r
+ EFI_TPL OldTpl;\r
+ \r
+ Status = EFI_SUCCESS;\r
+ Item = NULL;\r
+ TokenEntry = NULL;\r
+ Packet = NULL;\r
+\r
+ //\r
+ // Validate the parameters\r
+ //\r
+ if ((This == NULL) || (HostName == NULL) || Token == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
+ \r
+ Instance = DNS_INSTANCE_FROM_THIS_PROTOCOL6 (This);\r
+ \r
+ ConfigData = &(Instance->Dns6CfgData);\r
+ \r
+ Instance->MaxRetry = ConfigData->RetryCount;\r
+\r
+ Token->Status = EFI_NOT_READY;\r
+ Token->RetryCount = 0;\r
+ Token->RetryInterval = ConfigData->RetryInterval;\r
+\r
+ if (Instance->State != DNS_STATE_CONFIGED) {\r
+ Status = EFI_NOT_STARTED;\r
+ goto ON_EXIT;\r
+ }\r
+\r
+ //\r
+ // Check the MaxRetry and RetryInterval values.\r
+ //\r
+ if (Instance->MaxRetry == 0) {\r
+ Instance->MaxRetry = DNS_DEFAULT_RETRY;\r
+ }\r
+\r
+ if (Token->RetryInterval < DNS_DEFAULT_TIMEOUT) {\r
+ Token->RetryInterval = DNS_DEFAULT_TIMEOUT;\r
+ } \r
+\r
+ //\r
+ // Check cache\r
+ //\r
+ if (ConfigData->EnableDnsCache) {\r
+ Index = 0;\r
+ NET_LIST_FOR_EACH_SAFE (Entry, Next, &mDriverData->Dns6CacheList) {\r
+ Item = NET_LIST_USER_STRUCT (Entry, DNS6_CACHE, AllCacheLink);\r
+ if (StrCmp (HostName, Item->DnsCache.HostName) == 0) {\r
+ Index++;\r
+ }\r
+ }\r
+\r
+ if (Index != 0) {\r
+ Token->RspData.H2AData = AllocatePool (sizeof (DNS6_HOST_TO_ADDR_DATA));\r
+ if (Token->RspData.H2AData == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto ON_EXIT;\r
+ }\r
+\r
+ Token->RspData.H2AData->IpCount = (UINT32)Index;\r
+ Token->RspData.H2AData->IpList = AllocatePool (sizeof (EFI_IPv6_ADDRESS) * Index);\r
+ if (Token->RspData.H2AData->IpList == NULL) {\r
+ if (Token->RspData.H2AData != NULL) {\r
+ FreePool (Token->RspData.H2AData);\r
+ }\r
+ \r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto ON_EXIT;\r
+ }\r
+\r
+ Index = 0;\r
+ NET_LIST_FOR_EACH_SAFE (Entry, Next, &mDriverData->Dns6CacheList) {\r
+ Item = NET_LIST_USER_STRUCT (Entry, DNS6_CACHE, AllCacheLink);\r
+ if ((UINT32)Index < Token->RspData.H2AData->IpCount && StrCmp (HostName, Item->DnsCache.HostName) == 0) {\r
+ CopyMem ((Token->RspData.H2AData->IpList) + Index, Item->DnsCache.IpAddress, sizeof (EFI_IPv6_ADDRESS));\r
+ Index++;\r
+ }\r
+ }\r
+ \r
+ Token->Status = EFI_SUCCESS;\r
+ \r
+ if (Token->Event != NULL) {\r
+ gBS->SignalEvent (Token->Event);\r
+ DispatchDpc ();\r
+ }\r
+ \r
+ Status = Token->Status;\r
+ goto ON_EXIT;\r
+ } \r
+ }\r
+\r
+ //\r
+ // Construct DNS TokenEntry.\r
+ //\r
+ TokenEntry = AllocateZeroPool (sizeof (DNS6_TOKEN_ENTRY));\r
+ if (TokenEntry == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto ON_EXIT;\r
+ }\r
+ \r
+ TokenEntry->PacketToLive = Token->RetryInterval;\r
+ TokenEntry->QueryHostName = HostName;\r
+ TokenEntry->Token = Token;\r
+\r
+ //\r
+ // Construct DNS Query Packet.\r
+ //\r
+ Status = ConstructDNSQueryIp (Instance, TokenEntry->QueryHostName, DNS_TYPE_AAAA, &Packet);\r
+ if (EFI_ERROR (Status)) {\r
+ if (TokenEntry != NULL) {\r
+ FreePool (TokenEntry);\r
+ }\r
+ \r
+ goto ON_EXIT;\r
+ }\r
+\r
+ //\r
+ // Save the token into the Dns6TxTokens map.\r
+ //\r
+ Status = NetMapInsertTail (&Instance->Dns6TxTokens, TokenEntry, Packet);\r
+ if (EFI_ERROR (Status)) {\r
+ if (TokenEntry != NULL) {\r
+ FreePool (TokenEntry);\r
+ }\r
+ \r
+ NetbufFree (Packet);\r
+ \r
+ goto ON_EXIT;\r
+ }\r
+ \r
+ //\r
+ // Dns Query Ip\r
+ //\r
+ Status = DoDnsQuery (Instance, Packet);\r
+ if (EFI_ERROR (Status)) {\r
+ if (TokenEntry != NULL) {\r
+ FreePool (TokenEntry);\r
+ }\r
+ \r
+ NetbufFree (Packet);\r
+ }\r
+ \r
+ON_EXIT:\r
+ gBS->RestoreTPL (OldTpl);\r
+ return Status;\r
+}\r
+\r
+/**\r
+ The function is used to translate the host address to host name. \r
+ A type PTR query is used to get the primary name of the host. \r
+\r
+ @param[in] This Pointer to EFI_DNS6_PROTOCOL instance.\r
+ @param[in] IpAddress IP address.\r
+ @param[in] Token Pointer to the caller-allocated completion used token to translate host address to host name.\r
+\r
+ @retval EFI_SUCCESS The operation completed successfully.\r
+ @retval EFI_OUT_OF_RESOURCES Failed to allocate needed resources.\r
+ @retval EFI_INVALID_PARAMETER This is NULL.\r
+ Token is NULL.\r
+ Token.Event is NULL.\r
+ IpAddress is not valid IP address.\r
+ @retval EFI_NO_MAPPING There's no source address is available for use.\r
+ @retval EFI_NOT_STARTED This instance has not been started.\r
+ @retval EFI_UNSUPPORTED This function is not supported.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Dns6IpToHostName (\r
+ IN EFI_DNS6_PROTOCOL *This,\r
+ IN EFI_IPv6_ADDRESS IpAddress,\r
+ IN EFI_DNS6_COMPLETION_TOKEN *Token\r
+ )\r
+{\r
+ return EFI_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+ This function retrieves arbitrary information from the DNS. \r
+ The caller supplies a QNAME, QTYPE, and QCLASS, and all of the matching RRs are returned. \r
+ All RR content (e.g., Ttl) was returned. \r
+ The caller need parse the returned RR to get required information. This function is optional.\r
+\r
+ @param[in] This Pointer to EFI_DNS6_PROTOCOL instance.\r
+ @param[in] QName Pointer to Query Name.\r
+ @param[in] QType Query Type.\r
+ @param[in] QClass Query Name.\r
+ @param[in] Token Point to the caller-allocated completion token to retrieve arbitrary information.\r
+\r
+ @retval EFI_SUCCESS The operation completed successfully.\r
+ @retval EFI_OUT_OF_RESOURCES Failed to allocate needed resources.\r
+ @retval EFI_INVALID_PARAMETER This is NULL.\r
+ Token is NULL.\r
+ Token.Event is NULL.\r
+ QName is NULL.\r
+ @retval EFI_NO_MAPPING There's no source address is available for use.\r
+ @retval EFI_NOT_STARTED This instance has not been started.\r
+ @retval EFI_UNSUPPORTED This function is not supported. Or the requested QType is not supported\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Dns6GeneralLookUp (\r
+ IN EFI_DNS6_PROTOCOL *This,\r
+ IN CHAR8 *QName,\r
+ IN UINT16 QType, \r
+ IN UINT16 QClass,\r
+ IN EFI_DNS6_COMPLETION_TOKEN *Token\r
+ )\r
+{\r
+ return EFI_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+ This function is used to add/delete/modify DNS cache entry. \r
+ DNS cache can be normally dynamically updated after the DNS resolve succeeds. \r
+ This function provided capability to manually add/delete/modify the DNS cache.\r
+\r
+ @param[in] This Pointer to EFI_DNS6_PROTOCOL instance.\r
+ @param[in] DeleteFlag If FALSE, this function is to add one entry to the DNS Cache. \r
+ If TRUE, this function will delete matching DNS Cache entry. \r
+ @param[in] Override If TRUE, the matching DNS cache entry will be overwritten with the supplied parameter. \r
+ If FALSE, EFI_ACCESS_DENIED will be returned if the entry to be added is already exists.\r
+ @param[in] DnsCacheEntry Pointer to DNS Cache entry.\r
+\r
+ @retval EFI_SUCCESS The operation completed successfully.\r
+ @retval EFI_INVALID_PARAMETER This is NULL. \r
+ DnsCacheEntry.HostName is NULL.\r
+ DnsCacheEntry.IpAddress is NULL.\r
+ DnsCacheEntry.Timeout is zero.\r
+ @retval EFI_ACCESS_DENIED The DNS cache entry already exists and Override is not TRUE. \r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Dns6UpdateDnsCache (\r
+ IN EFI_DNS6_PROTOCOL *This,\r
+ IN BOOLEAN DeleteFlag,\r
+ IN BOOLEAN Override,\r
+ IN EFI_DNS6_CACHE_ENTRY DnsCacheEntry\r
+ )\r
+{\r
+ EFI_STATUS Status; \r
+ EFI_TPL OldTpl;\r
+\r
+ Status = EFI_SUCCESS;\r
+ \r
+ if (DnsCacheEntry.HostName == NULL || DnsCacheEntry.IpAddress == NULL || DnsCacheEntry.Timeout == 0) {\r
+ return EFI_INVALID_PARAMETER; \r
+ }\r
+ \r
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
+\r
+ //\r
+ // Update Dns6Cache here.\r
+ //\r
+ Status = UpdateDns6Cache (&mDriverData->Dns6CacheList, DeleteFlag, Override, DnsCacheEntry);\r
+ \r
+ gBS->RestoreTPL (OldTpl);\r
+ \r
+ return Status;\r
+}\r
+\r
+/**\r
+ This function can be used by network drivers and applications to increase the rate that data packets are moved between \r
+ the communications device and the transmit and receive queues. In some systems, the periodic timer event in the managed \r
+ network driver may not poll the underlying communications device fast enough to transmit and/or receive all data packets \r
+ without missing incoming packets or dropping outgoing packets.\r
+\r
+ @param[in] This Pointer to EFI_DNS6_PROTOCOL instance.\r
+\r
+ @retval EFI_SUCCESS Incoming or outgoing data was processed.\r
+ @retval EFI_INVALID_PARAMETER This is NULL. \r
+ @retval EFI_NOT_STARTED This EFI DNS Protocol instance has not been started. \r
+ @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. \r
+ @retval EFI_TIMEOUT Data was dropped out of the transmit and/or receive queue. \r
+ Consider increasing the polling rate.\r
+ \r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Dns6Poll (\r
+ IN EFI_DNS6_PROTOCOL *This\r
+ )\r
+{\r
+ DNS_INSTANCE *Instance;\r
+ EFI_UDP6_PROTOCOL *Udp;\r
+\r
+ if (This == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ Instance = DNS_INSTANCE_FROM_THIS_PROTOCOL6 (This);\r
+\r
+ if (Instance->State == DNS_STATE_UNCONFIGED) {\r
+ return EFI_NOT_STARTED;\r
+ } else if (Instance->State == DNS_STATE_DESTROY) {\r
+ return EFI_DEVICE_ERROR;\r
+ }\r
+\r
+ Udp = Instance->UdpIo->Protocol.Udp6;\r
+ \r
+ return Udp->Poll (Udp);\r
+}\r
+\r
+/**\r
+ This function is used to abort a pending resolution request. \r
+ After calling this function, Token.Status will be set to EFI_ABORTED and then Token.\r
+\r
+ @param[in] This Pointer to EFI_DNS6_PROTOCOL instance.\r
+ @param[in] Token Pointer to a token that has been issued by EFI_DNS6_PROTOCOL.HostNameToIp(), \r
+ EFI_DNS6_PROTOCOL.IpToHostName() or EFI_DNS6_PROTOCOL.GeneralLookup(). \r
+ If NULL, all pending tokens are aborted.\r
+\r
+ @retval EFI_SUCCESS Incoming or outgoing data was processed.\r
+ @retval EFI_INVALID_PARAMETER This is NULL. \r
+ @retval EFI_NOT_STARTED This EFI DNS Protocol instance has not been started. \r
+ @retval EFI_NOT_FOUND When Token is not NULL, and the asynchronous DNS operation was not found in the transmit queue. \r
+ It was either completed or was not issued by HostNameToIp(), IpToHostName() or GeneralLookup().\r
+ \r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Dns6Cancel (\r
+ IN EFI_DNS6_PROTOCOL *This,\r
+ IN EFI_DNS6_COMPLETION_TOKEN *Token\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ DNS_INSTANCE *Instance;\r
+ EFI_TPL OldTpl;\r
+\r
+ if (This == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ Instance = DNS_INSTANCE_FROM_THIS_PROTOCOL6 (This);\r
+\r
+ if (Instance->State == DNS_STATE_UNCONFIGED) {\r
+ return EFI_NOT_STARTED;\r
+ }\r
+\r
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
+\r
+ //\r
+ // Cancle the tokens specified by Token for this instance.\r
+ //\r
+ Status = Dns6InstanceCancelToken (Instance, Token);\r
+\r
+ //\r
+ // Dispatch the DPC queued by the NotifyFunction of the canceled token's events.\r
+ //\r
+ DispatchDpc ();\r
+\r
+ gBS->RestoreTPL (OldTpl);\r
+\r
+ return Status;\r
+}\r
+\r