Embedded TCP/IP stack  4.7.0
DNS client/resolver API

Detailed Description

The DNS client/resolver service allows user application to resolve IP addresses of internet hosts that are identified by a host name.
It does this by sending DNS request to a DNS Server. The IP address of a DNS Server is specified manually or can be obtained from the DHCP Server for the Local Area Network.

After the DNS client is initialized by calling the fnet_dns_init() function, the user application should call the main service-polling function fnet_service_poll() periodically in background.
The resolved IP-address will be passed to the fnet_dns_callback_resolved_t callback function, which is set during the DNS-client service initialization.
The DNS client service is released automatically as soon as the requested host name is fully resolved or an error occurs. Your application code may continue to call fnet_service_poll() to handle other services, but this will not have any impact on the DNS client communication until you initialize the next IP address resolving by calling fnet_dns_init() again.

For the DNS-client service example, refer to the FNET Shell demo source code.

Note
Current version of the DNS client:
  • does not cache the resolved IP addresses.
  • can process only one request at a time.
  • uses UDP protocol, without message truncation.
  • does not support DNS servers without recursion (all real-life DNS servers support it).
  • takes the first resolved IP address, even if the DNS server provides several ones.

Configuration parameters:

Data Structures

struct  fnet_dns_resolved_addr_t
 Resolved address structure provided by fnet_dns_callback_resolved_t callback function. More...
 
struct  fnet_dns_params
 Initialization parameters for the fnet_dns_init() function. More...
 

Typedefs

typedef void * fnet_dns_desc_t
 DNS client descriptor. More...
 
typedef void(* fnet_dns_callback_resolved_t) (const fnet_dns_resolved_addr_t *addr_list, fnet_size_t addr_list_size, const fnet_char_t *host_name, void *cookie)
 Prototype of the DNS-client callback function that is called when the DNS client has completed the resolving. More...
 

Functions

fnet_dns_desc_t fnet_dns_init (struct fnet_dns_params *params)
 Initializes the DNS client service and starts the host name resolving. More...
 
void fnet_dns_release (fnet_dns_desc_t desc)
 Aborts the resolving and releases the DNS-client service. More...
 
fnet_bool_t fnet_dns_is_enabled (fnet_dns_desc_t desc)
 Detects if the DNS client service is enabled or disabled. More...
 

© 2005-2020 by Andrej Butok. http://fnet.sourceforge.net