Chapter 47. DNS

DNS API

The DNS client uses the normal BSD API for performing lookups: gethostbyname() and gethostbyaddr().

There are a few restrictions:

To initialise the DNS client the following function must be called:

#include <network.h>
int cyg_dns_res_init(struct in_addr *dns_server)

where dns_server is the address of the DNS server the client should query. On Error this function returns -1, otherwise 0 for success. If lookups are attemped before this function has been called, they will fail and return NULL.

The DNS client understands the concepts of the target being in a domain. By default no domain will be used. Host name lookups should be for fully qualified names. The domain name can be set using the function setdomainname(). Once set, the DNS client will first perform a lookup with the domain name appended. If this fails it will then perform a second lookup without the appended domain name.