TianoCore EDK2 master
Loading...
Searching...
No Matches
DnsImpl.c File Reference
#include "DnsImpl.h"

Go to the source code of this file.

Functions

EFI_STATUS Dns4RemoveTokenEntry (IN NET_MAP *TokenMap, IN DNS4_TOKEN_ENTRY *TokenEntry)
 
EFI_STATUS Dns6RemoveTokenEntry (IN NET_MAP *TokenMap, IN DNS6_TOKEN_ENTRY *TokenEntry)
 
EFI_STATUS EFIAPI Dns4CancelTokens (IN NET_MAP *Map, IN NET_MAP_ITEM *Item, IN VOID *Arg OPTIONAL)
 
EFI_STATUS EFIAPI Dns6CancelTokens (IN NET_MAP *Map, IN NET_MAP_ITEM *Item, IN VOID *Arg OPTIONAL)
 
EFI_STATUS EFIAPI GetDns4TokenEntry (IN NET_MAP *TokensMap, IN EFI_DNS4_COMPLETION_TOKEN *Token, OUT DNS4_TOKEN_ENTRY **TokenEntry)
 
EFI_STATUS EFIAPI GetDns6TokenEntry (IN NET_MAP *TokensMap, IN EFI_DNS6_COMPLETION_TOKEN *Token, OUT DNS6_TOKEN_ENTRY **TokenEntry)
 
EFI_STATUS Dns4InstanceCancelToken (IN DNS_INSTANCE *Instance, IN EFI_DNS4_COMPLETION_TOKEN *Token)
 
EFI_STATUS Dns6InstanceCancelToken (IN DNS_INSTANCE *Instance, IN EFI_DNS6_COMPLETION_TOKEN *Token)
 
VOID Dns4CleanConfigure (IN OUT EFI_DNS4_CONFIG_DATA *Config)
 
VOID Dns6CleanConfigure (IN OUT EFI_DNS6_CONFIG_DATA *Config)
 
EFI_STATUS Dns4CopyConfigure (OUT EFI_DNS4_CONFIG_DATA *Dst, IN EFI_DNS4_CONFIG_DATA *Src)
 
EFI_STATUS Dns6CopyConfigure (OUT EFI_DNS6_CONFIG_DATA *Dst, IN EFI_DNS6_CONFIG_DATA *Src)
 
VOID EFIAPI DnsDummyExtFree (IN VOID *Arg)
 
BOOLEAN Dns4GetMapping (IN DNS_INSTANCE *Instance, IN UDP_IO *UdpIo, IN EFI_UDP4_CONFIG_DATA *UdpCfgData)
 
BOOLEAN Dns6GetMapping (IN DNS_INSTANCE *Instance, IN UDP_IO *UdpIo, IN EFI_UDP6_CONFIG_DATA *UdpCfgData)
 
EFI_STATUS Dns4ConfigUdp (IN DNS_INSTANCE *Instance, IN UDP_IO *UdpIo)
 
EFI_STATUS Dns6ConfigUdp (IN DNS_INSTANCE *Instance, IN UDP_IO *UdpIo)
 
EFI_STATUS EFIAPI UpdateDns4Cache (IN LIST_ENTRY *Dns4CacheList, IN BOOLEAN DeleteFlag, IN BOOLEAN Override, IN EFI_DNS4_CACHE_ENTRY DnsCacheEntry)
 
EFI_STATUS EFIAPI UpdateDns6Cache (IN LIST_ENTRY *Dns6CacheList, IN BOOLEAN DeleteFlag, IN BOOLEAN Override, IN EFI_DNS6_CACHE_ENTRY DnsCacheEntry)
 
EFI_STATUS EFIAPI AddDns4ServerIp (IN LIST_ENTRY *Dns4ServerList, IN EFI_IPv4_ADDRESS ServerIp)
 
EFI_STATUS EFIAPI AddDns6ServerIp (IN LIST_ENTRY *Dns6ServerList, IN EFI_IPv6_ADDRESS ServerIp)
 
BOOLEAN IsValidDnsResponse (IN NET_MAP *TokensMap, IN UINT16 Identification, IN UINT16 Type, IN UINT16 Class, OUT NET_MAP_ITEM **Item)
 
EFI_STATUS ParseDnsResponse (IN OUT DNS_INSTANCE *Instance, IN UINT8 *RxString, IN UINT32 Length, OUT BOOLEAN *Completed)
 
VOID EFIAPI DnsOnPacketReceived (NET_BUF *Packet, UDP_END_POINT *EndPoint, EFI_STATUS IoStatus, VOID *Context)
 
VOID EFIAPI DnsOnPacketSent (NET_BUF *Packet, UDP_END_POINT *EndPoint, EFI_STATUS IoStatus, VOID *Context)
 
EFI_STATUS DoDnsQuery (IN DNS_INSTANCE *Instance, IN NET_BUF *Packet)
 
EFI_STATUS ConstructDNSQuery (IN DNS_INSTANCE *Instance, IN CHAR8 *QueryName, IN UINT16 Type, IN UINT16 Class, OUT NET_BUF **Packet)
 
EFI_STATUS DnsRetransmit (IN DNS_INSTANCE *Instance, IN NET_BUF *Packet)
 
VOID EFIAPI DnsOnTimerRetransmit (IN EFI_EVENT Event, IN VOID *Context)
 
VOID EFIAPI DnsOnTimerUpdate (IN EFI_EVENT Event, IN VOID *Context)
 

Detailed Description

DnsDxe support functions implementation.

Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.
Copyright (c) Microsoft Corporation SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file DnsImpl.c.

Function Documentation

◆ AddDns4ServerIp()

EFI_STATUS EFIAPI AddDns4ServerIp ( IN LIST_ENTRY Dns4ServerList,
IN EFI_IPv4_ADDRESS  ServerIp 
)

Add Dns4 ServerIp to common list of addresses of all configured DNSv4 server.

Parameters
Dns4ServerListCommon list of addresses of all configured DNSv4 server.
ServerIpDNS server Ip.
Return values
EFI_SUCCESSAdd Dns4 ServerIp to common list successfully.
OthersFailed to add Dns4 ServerIp to common list.

Definition at line 957 of file DnsImpl.c.

◆ AddDns6ServerIp()

EFI_STATUS EFIAPI AddDns6ServerIp ( IN LIST_ENTRY Dns6ServerList,
IN EFI_IPv6_ADDRESS  ServerIp 
)

Add Dns6 ServerIp to common list of addresses of all configured DNSv6 server.

Parameters
Dns6ServerListCommon list of addresses of all configured DNSv6 server.
ServerIpDNS server Ip.
Return values
EFI_SUCCESSAdd Dns6 ServerIp to common list successfully.
OthersFailed to add Dns6 ServerIp to common list.

Definition at line 1012 of file DnsImpl.c.

◆ ConstructDNSQuery()

EFI_STATUS ConstructDNSQuery ( IN DNS_INSTANCE Instance,
IN CHAR8 *  QueryName,
IN UINT16  Type,
IN UINT16  Class,
OUT NET_BUF **  Packet 
)

Construct the Packet according query section.

Parameters
InstanceThe DNS instance
QueryNameQueried Name
TypeQueried Type
ClassQueried Class
PacketThe packet for query
Return values
EFI_SUCCESSThe packet is constructed.
OthersFailed to construct the Packet.

Definition at line 1956 of file DnsImpl.c.

◆ Dns4CancelTokens()

EFI_STATUS EFIAPI Dns4CancelTokens ( IN NET_MAP Map,
IN NET_MAP_ITEM Item,
IN VOID *Arg  OPTIONAL 
)

This function cancel the token specified by Arg in the Map.

Parameters
[in]MapPointer to the NET_MAP.
[in]ItemPointer to the NET_MAP_ITEM.
[in]ArgPointer to the token to be cancelled. If NULL, all the tokens in this Map will be cancelled. This parameter is optional and may be NULL.
Return values
EFI_SUCCESSThe token is cancelled if Arg is NULL, or the token is not the same as that in the Item, if Arg is not NULL.
EFI_ABORTEDArg is not NULL, and the token specified by Arg is cancelled.

Definition at line 100 of file DnsImpl.c.

◆ Dns4CleanConfigure()

VOID Dns4CleanConfigure ( IN OUT EFI_DNS4_CONFIG_DATA Config)

Free the resource related to the configure parameters.

Parameters
ConfigThe DNS configure data

Definition at line 397 of file DnsImpl.c.

◆ Dns4ConfigUdp()

EFI_STATUS Dns4ConfigUdp ( IN DNS_INSTANCE Instance,
IN UDP_IO UdpIo 
)

Configure the UDP.

Parameters
InstanceThe DNS session
UdpIoThe UDP_IO instance
Return values
EFI_SUCCESSThe UDP is successfully configured for the session.

Definition at line 666 of file DnsImpl.c.

◆ Dns4CopyConfigure()

EFI_STATUS Dns4CopyConfigure ( OUT EFI_DNS4_CONFIG_DATA Dst,
IN EFI_DNS4_CONFIG_DATA Src 
)

Allocate memory for configure parameter such as timeout value for Dst, then copy the configure parameter from Src to Dst.

Parameters
[out]DstThe destination DHCP configure data.
[in]SrcThe source DHCP configure data.
Return values
EFI_OUT_OF_RESOURCESFailed to allocate memory.
EFI_SUCCESSThe configure is copied.

Definition at line 438 of file DnsImpl.c.

◆ Dns4GetMapping()

BOOLEAN Dns4GetMapping ( IN DNS_INSTANCE Instance,
IN UDP_IO UdpIo,
IN EFI_UDP4_CONFIG_DATA UdpCfgData 
)

Poll the UDP to get the IP4 default address, which may be retrieved by DHCP.

The default time out value is 5 seconds. If IP has retrieved the default address, the UDP is reconfigured.

Parameters
InstanceThe DNS instance
UdpIoThe UDP_IO to poll
UdpCfgDataThe UDP configure data to reconfigure the UDP_IO
Return values
TRUEThe default address is retrieved and UDP is reconfigured.
FALSESome error occurred.

Definition at line 540 of file DnsImpl.c.

◆ Dns4InstanceCancelToken()

EFI_STATUS Dns4InstanceCancelToken ( IN DNS_INSTANCE Instance,
IN EFI_DNS4_COMPLETION_TOKEN Token 
)

Cancel DNS4 tokens from the DNS4 instance.

Parameters
[in]InstancePointer to the DNS instance context data.
[in]TokenPointer to the token to be canceled. If NULL, all tokens in this instance will be cancelled. This parameter is optional and may be NULL.
Return values
EFI_SUCCESSThe Token is cancelled.
EFI_NOT_FOUNDThe Token is not found.

Definition at line 287 of file DnsImpl.c.

◆ Dns4RemoveTokenEntry()

EFI_STATUS Dns4RemoveTokenEntry ( IN NET_MAP TokenMap,
IN DNS4_TOKEN_ENTRY TokenEntry 
)

Remove TokenEntry from TokenMap.

Parameters
[in]TokenMapAll DNSv4 Token entrys.
[in]TokenEntryTokenEntry need to be removed.
Return values
EFI_SUCCESSRemove TokenEntry from TokenMap successfully.
EFI_NOT_FOUNDTokenEntry is not found in TokenMap.

Definition at line 23 of file DnsImpl.c.

◆ Dns6CancelTokens()

EFI_STATUS EFIAPI Dns6CancelTokens ( IN NET_MAP Map,
IN NET_MAP_ITEM Item,
IN VOID *Arg  OPTIONAL 
)

This function cancel the token specified by Arg in the Map.

Parameters
[in]MapPointer to the NET_MAP.
[in]ItemPointer to the NET_MAP_ITEM.
[in]ArgPointer to the token to be cancelled. If NULL, all the tokens in this Map will be cancelled. This parameter is optional and may be NULL.
Return values
EFI_SUCCESSThe token is cancelled if Arg is NULL, or the token is not the same as that in the Item, if Arg is not NULL.
EFI_ABORTEDArg is not NULL, and the token specified by Arg is cancelled.

Definition at line 160 of file DnsImpl.c.

◆ Dns6CleanConfigure()

VOID Dns6CleanConfigure ( IN OUT EFI_DNS6_CONFIG_DATA Config)

Free the resource related to the configure parameters.

Parameters
ConfigThe DNS configure data

Definition at line 415 of file DnsImpl.c.

◆ Dns6ConfigUdp()

EFI_STATUS Dns6ConfigUdp ( IN DNS_INSTANCE Instance,
IN UDP_IO UdpIo 
)

Configure the UDP.

Parameters
InstanceThe DNS session
UdpIoThe UDP_IO instance
Return values
EFI_SUCCESSThe UDP is successfully configured for the session.

Definition at line 714 of file DnsImpl.c.

◆ Dns6CopyConfigure()

EFI_STATUS Dns6CopyConfigure ( OUT EFI_DNS6_CONFIG_DATA Dst,
IN EFI_DNS6_CONFIG_DATA Src 
)

Allocate memory for configure parameter such as timeout value for Dst, then copy the configure parameter from Src to Dst.

Parameters
[out]DstThe destination DHCP configure data.
[in]SrcThe source DHCP configure data.
Return values
EFI_OUT_OF_RESOURCESFailed to allocate memory.
EFI_SUCCESSThe configure is copied.

Definition at line 480 of file DnsImpl.c.

◆ Dns6GetMapping()

BOOLEAN Dns6GetMapping ( IN DNS_INSTANCE Instance,
IN UDP_IO UdpIo,
IN EFI_UDP6_CONFIG_DATA UdpCfgData 
)

Configure the opened Udp6 instance until the corresponding Ip6 instance has been configured.

Parameters
InstanceThe DNS instance
UdpIoThe UDP_IO to poll
UdpCfgDataThe UDP configure data to reconfigure the UDP_IO
Return values
TRUEConfigure the Udp6 instance successfully.
FALSESome error occurred.

Definition at line 592 of file DnsImpl.c.

◆ Dns6InstanceCancelToken()

EFI_STATUS Dns6InstanceCancelToken ( IN DNS_INSTANCE Instance,
IN EFI_DNS6_COMPLETION_TOKEN Token 
)

Cancel DNS6 tokens from the DNS6 instance.

Parameters
[in]InstancePointer to the DNS instance context data.
[in]TokenPointer to the token to be canceled. If NULL, all tokens in this instance will be cancelled. This parameter is optional and may be NULL.
Return values
EFI_SUCCESSThe Token is cancelled.
EFI_NOT_FOUNDThe Token is not found.

Definition at line 345 of file DnsImpl.c.

◆ Dns6RemoveTokenEntry()

EFI_STATUS Dns6RemoveTokenEntry ( IN NET_MAP TokenMap,
IN DNS6_TOKEN_ENTRY TokenEntry 
)

Remove TokenEntry from TokenMap.

Parameters
[in]TokenMapAll DNSv6 Token entrys.
[in]TokenEntryTokenEntry need to be removed.
Return values
EFI_SUCCESSRemove TokenEntry from TokenMap successfully.
EFI_NOT_FOUNDTokenEntry is not found in TokenMap.

Definition at line 58 of file DnsImpl.c.

◆ DnsDummyExtFree()

VOID EFIAPI DnsDummyExtFree ( IN VOID *  Arg)

Callback of Dns packet. Does nothing.

Parameters
ArgThe context.

Definition at line 518 of file DnsImpl.c.

◆ DnsOnPacketReceived()

VOID EFIAPI DnsOnPacketReceived ( NET_BUF Packet,
UDP_END_POINT EndPoint,
EFI_STATUS  IoStatus,
VOID *  Context 
)

Parse response packet.

Parameters
PacketThe packets received.
EndPointThe local/remote UDP access point
IoStatusThe status of the UDP receive
ContextThe opaque parameter to the function.

Definition at line 1804 of file DnsImpl.c.

◆ DnsOnPacketSent()

VOID EFIAPI DnsOnPacketSent ( NET_BUF Packet,
UDP_END_POINT EndPoint,
EFI_STATUS  IoStatus,
VOID *  Context 
)

Release the net buffer when packet is sent.

Parameters
PacketThe packets received.
EndPointThe local/remote UDP access point
IoStatusThe status of the UDP receive
ContextThe opaque parameter to the function.

Definition at line 1862 of file DnsImpl.c.

◆ DnsOnTimerRetransmit()

VOID EFIAPI DnsOnTimerRetransmit ( IN EFI_EVENT  Event,
IN VOID *  Context 
)

The timer ticking function for the DNS services.

Parameters
EventThe ticking event
ContextThe DNS service instance

Definition at line 2098 of file DnsImpl.c.

◆ DnsOnTimerUpdate()

VOID EFIAPI DnsOnTimerUpdate ( IN EFI_EVENT  Event,
IN VOID *  Context 
)

The timer ticking function for the DNS driver.

Parameters
EventThe ticking event
ContextNULL

Definition at line 2219 of file DnsImpl.c.

◆ DnsRetransmit()

EFI_STATUS DnsRetransmit ( IN DNS_INSTANCE Instance,
IN NET_BUF Packet 
)

Retransmit the packet.

Parameters
InstanceThe DNS instance
PacketRetransmit the packet
Return values
EFI_SUCCESSThe packet is retransmitted.
OthersFailed to retransmit.

Definition at line 2054 of file DnsImpl.c.

◆ DoDnsQuery()

EFI_STATUS DoDnsQuery ( IN DNS_INSTANCE Instance,
IN NET_BUF Packet 
)

Query request information.

Parameters
InstanceThe DNS instance
PacketThe packet for querying request information.
Return values
EFI_SUCCESSQuery request information successfully.
OthersFailed to query request information.

Definition at line 1915 of file DnsImpl.c.

◆ GetDns4TokenEntry()

EFI_STATUS EFIAPI GetDns4TokenEntry ( IN NET_MAP TokensMap,
IN EFI_DNS4_COMPLETION_TOKEN Token,
OUT DNS4_TOKEN_ENTRY **  TokenEntry 
)

Get the TokenEntry from the TokensMap.

Parameters
[in]TokensMapAll DNSv4 Token entrys
[in]TokenPointer to the token to be get.
[out]TokenEntryPointer to TokenEntry corresponding Token.
Return values
EFI_SUCCESSGet the TokenEntry from the TokensMap successfully.
EFI_NOT_FOUNDTokenEntry is not found in TokenMap.

Definition at line 215 of file DnsImpl.c.

◆ GetDns6TokenEntry()

EFI_STATUS EFIAPI GetDns6TokenEntry ( IN NET_MAP TokensMap,
IN EFI_DNS6_COMPLETION_TOKEN Token,
OUT DNS6_TOKEN_ENTRY **  TokenEntry 
)

Get the TokenEntry from the TokensMap.

Parameters
[in]TokensMapAll DNSv6 Token entrys
[in]TokenPointer to the token to be get.
[out]TokenEntryPointer to TokenEntry corresponding Token.
Return values
EFI_SUCCESSGet the TokenEntry from the TokensMap successfully.
EFI_NOT_FOUNDTokenEntry is not found in TokenMap.

Definition at line 251 of file DnsImpl.c.

◆ IsValidDnsResponse()

BOOLEAN IsValidDnsResponse ( IN NET_MAP TokensMap,
IN UINT16  Identification,
IN UINT16  Type,
IN UINT16  Class,
OUT NET_MAP_ITEM **  Item 
)

Find out whether the response is valid or invalid.

Parameters
TokensMapAll DNS transmittal Tokens entry.
IdentificationIdentification for queried packet.
TypeType for queried packet.
ClassClass for queried packet.
ItemReturn corresponding Token entry.
Return values
TRUEThe response is valid.
FALSEThe response is invalid.

Definition at line 1069 of file DnsImpl.c.

◆ ParseDnsResponse()

EFI_STATUS ParseDnsResponse ( IN OUT DNS_INSTANCE Instance,
IN UINT8 *  RxString,
IN UINT32  Length,
OUT BOOLEAN *  Completed 
)

Parse Dns Response.

Parameters
InstanceThe DNS instance
RxStringReceived buffer.
LengthReceived buffer length.
CompletedFlag to indicate that Dns response is valid.
Return values
EFI_SUCCESSParse Dns Response successfully.
OthersFailed to parse Dns Response.

Definition at line 1124 of file DnsImpl.c.

◆ UpdateDns4Cache()

EFI_STATUS EFIAPI UpdateDns4Cache ( IN LIST_ENTRY Dns4CacheList,
IN BOOLEAN  DeleteFlag,
IN BOOLEAN  Override,
IN EFI_DNS4_CACHE_ENTRY  DnsCacheEntry 
)

Update Dns4 cache to shared list of caches of all DNSv4 instances.

Parameters
Dns4CacheListAll Dns4 cache list.
DeleteFlagIf FALSE, this function is to add one entry to the DNS Cache. If TRUE, this function will delete matching DNS Cache entry.
OverrideIf TRUE, the matching DNS cache entry will be overwritten with the supplied parameter. If FALSE, EFI_ACCESS_DENIED will be returned if the entry to be added is already exists.
DnsCacheEntryEntry Pointer to DNS Cache entry.
Return values
EFI_SUCCESSUpdate Dns4 cache successfully.
OthersFailed to update Dns4 cache.

Definition at line 762 of file DnsImpl.c.

◆ UpdateDns6Cache()

EFI_STATUS EFIAPI UpdateDns6Cache ( IN LIST_ENTRY Dns6CacheList,
IN BOOLEAN  DeleteFlag,
IN BOOLEAN  Override,
IN EFI_DNS6_CACHE_ENTRY  DnsCacheEntry 
)

Update Dns6 cache to shared list of caches of all DNSv6 instances.

Parameters
Dns6CacheListAll Dns6 cache list.
DeleteFlagIf FALSE, this function is to add one entry to the DNS Cache. If TRUE, this function will delete matching DNS Cache entry.
OverrideIf TRUE, the matching DNS cache entry will be overwritten with the supplied parameter. If FALSE, EFI_ACCESS_DENIED will be returned if the entry to be added is already exists.
DnsCacheEntryEntry Pointer to DNS Cache entry.
Return values
EFI_SUCCESSUpdate Dns6 cache successfully.
OthersFailed to update Dns6 cache.

Definition at line 861 of file DnsImpl.c.