Nicolas Borla / Mbed OS BBR_1Ebene
Embed: (wiki syntax)

« Back to documentation index

Fnet_dns

Data Structures

struct  fnet_dns_resolved_addr
 Initialization parameters for the fnet_dns_init() function. More...
struct  fnet_dns_params
 Initialization parameters for the fnet_dns_init() function. More...

Typedefs

typedef void(* fnet_dns_callback_resolved_t )(const struct fnet_dns_resolved_addr *addr_list, fnet_size_t addr_list_size, fnet_uint32_t cookie)
 Prototype of the DNS-client callback function that is called when the DNS client has completed the resolving.

Enumerations

enum  fnet_dns_state_t { FNET_DNS_STATE_DISABLED = 0, FNET_DNS_STATE_TX, FNET_DNS_STATE_RX, FNET_DNS_STATE_RELEASE }
 

DNS-client states.
Used mainly for debugging purposes.

More...

Functions

fnet_return_t fnet_dns_init (struct fnet_dns_params *params)
 Initializes DNS client service and starts the host name resolving.
void fnet_dns_release (void)
 Aborts the resolving and releases the DNS-client service.
fnet_dns_state_t fnet_dns_state (void)
 Retrieves the current state of the DNS-client service (for debugging purposes).

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_poll_service() 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 still continue to call fnet_poll_service() 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:

  • FNET_CFG_DNS
  • FNET_CFG_DNS_RESOLVER
  • FNET_CFG_DNS_PORT
  • FNET_CFG_DNS_RETRANSMISSION_MAX
  • FNET_CFG_DNS_RETRANSMISSION_TIMEOUT
  • FNET_CFG_ND6_RDNSS
  • FNET_CFG_ND6_RDNSS_LIST_SIZE

Typedef Documentation

typedef void(* fnet_dns_callback_resolved_t)(const struct fnet_dns_resolved_addr *addr_list, fnet_size_t addr_list_size, fnet_uint32_t cookie)

Prototype of the DNS-client callback function that is called when the DNS client has completed the resolving.

Parameters:
addr_familyIP address family.
It determines the address pointed to by addr.
addr_listPointer to the list of addresses or FNET_NULL if the resolving was failed.
addr_list_sizeNumber of resolved addresses in addr_list.
cookieUser-application specific parameter. It's set during the DNS-client service initialization as part of fnet_dns_params.
See also:
fnet_dns_resolve(), fnet_dns_params

Definition at line 112 of file fnet_dns.h.


Enumeration Type Documentation

DNS-client states.
Used mainly for debugging purposes.

Enumerator:
FNET_DNS_STATE_DISABLED 

The DNS-client service is not initialized or is released.

FNET_DNS_STATE_TX 

The DNS-client service sends the request to the DNS server.

FNET_DNS_STATE_RX 

The DNS-client service waits a response from the DNS server.

FNET_DNS_STATE_RELEASE 

The DNS resolving is completed or received error.

Definition at line 77 of file fnet_dns.h.


Function Documentation

fnet_return_t fnet_dns_init ( struct fnet_dns_params params )

Initializes DNS client service and starts the host name resolving.

Parameters:
paramsInitialization parameters.
Returns:
This function returns:
See also:
fnet_dns_params, fnet_dns_callback_resolved_t, fnet_dns_release()

This function initializes the DNS client service and starts the host name resolving. It allocates all needed resources and registers the DNS service in the polling list.
After the initialization, the user application should call the main polling function fnet_poll_service() periodically to run the DNS service routine in the background.
The resolved IP-address will be passed to the fnet_dns_callback_resolved_t callback function, which is set in params.
The DNS service is released automatically as soon as the resolving is finished or an error is occurred.

void fnet_dns_release ( void   )

Aborts the resolving and releases the DNS-client service.

See also:
fnet_dns_init()

This function stops the DNS-client service. It releases all resources used by the service, and unregisters it from the polling list.
Use this function only in the case of the early termination of the service, because the DNS service is released automatically as soon as the resolving is finished.

fnet_dns_state_t fnet_dns_state ( void   )

Retrieves the current state of the DNS-client service (for debugging purposes).

Returns:
This function returns the current state of the DNS-client service. The state is defined by the fnet_dns_state_t.

This function returns the current state of the DNS-client service. If the state is FNET_DNS_STATE_DISABLED, the DNS client is not initialized or released.
It is used mainly for debugging purposes.