weAut_01 / weAutSys    R 2.2.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines
Files | Defines | Functions
DNS resolver
+ + uIP -- Application (layer) support + +

Overview

The uIP DNS resolver functions are used to lookup a hostname and map it to an IP address. It maintains a list of resolved hostnames that can be queried with the resolv_lookup() function. New hostnames can be resolved using the resolv_query() function.

When a hostname has been resolved (or found to be non-existent), the resolver code calls a callback function called resolv_found() that must be implemented by the module that uses the resolver.

Files

file  resolv.h
 

DNS resolver definitions.


Defines

#define MAX_DNS_RETRIES   8
 The maximum number of DNS retries.

Functions

void resolv_appcall (void)
 uIP event function for the DNS resolver
void resolv_conf (uint16_t *dnsserver)
 Configure which DNS server to use for queries.
void resolv_found (char *name, uint16_t *ipaddr)
 Callback function which is called after hostname look-up.
uint16_t * resolv_getserver (void)
 Obtain the currently configured DNS server.
void resolv_init (void)
 Initialise the resolver.
uint16_t * resolv_lookup (char *name)
 Look up a hostname in the array of known hostnames.
void resolv_query (char *name)
 Queues a name so that a question for the name will be sent out.

Function Documentation

void resolv_appcall ( void  )

uIP event function for the DNS resolver

Must only be called for the correct protocol / port (rport 53).

void resolv_found ( char *  name,
uint16_t *  ipaddr 
)

Callback function which is called after hostname look-up.

This function must be implemented by the module that uses the DNS resolver. It is called when the hostname requested got an IP address assigned by DNS server answer, or when such assignment could not be found.

Parameters:
namepointer to the name that was to look up
ipaddrpointer to a 4-byte array containing the IP address of the hostname, or NULL if the hostname could not be found.
void resolv_conf ( uint16_t *  dnsserver)

Configure which DNS server to use for queries.

Note:
weAutSys configuration can hold up to two DNS server IPs usually got by DHCP.
Parameters:
dnsservera pointer to a 4-byte representation of the DNS server's IP address
uint16_t* resolv_getserver ( void  )

Obtain the currently configured DNS server.

Returns:
A pointer to a 4-byte representation of the IP address of the currently configured DNS server or NULL if no DNS server has been configured.
uint16_t* resolv_lookup ( char *  name)

Look up a hostname in the array of known hostnames.

Note:
This function only looks in the internal array of known hostnames. It does not send out a query for the hostname, even if none was found. The function resolv_query() can be used to send such query.
Returns:
A pointer to a 4-byte representation of the hostname's IP address, or NULL if the hostname was not found in the array of hostnames.
void resolv_query ( char *  name)

Queues a name so that a question for the name will be sent out.

Parameters:
nameThe hostname that is to be queried.