Sock DNS client. More...
Sock DNS client.
Files | |
file | dns.h |
DNS sock definitions. | |
Functions | |
int | sock_dns_query (const char *domain_name, void *addr_out, int family) |
Get IP address for DNS name. More... | |
Variables | |
sock_udp_ep_t | sock_dns_server |
global DNS server endpoint | |
DNS defines | |
#define | SOCK_DNS_PORT (53) |
#define | SOCK_DNS_RETRIES (2) |
#define | SOCK_DNS_MAX_NAME_LEN (CONFIG_DNS_MSG_LEN - sizeof(dns_hdr_t) - 4) |
int sock_dns_query | ( | const char * | domain_name, |
void * | addr_out, | ||
int | family | ||
) |
Get IP address for DNS name.
This function will synchronously try to resolve a DNS A or AAAA record by contacting the DNS server specified in the global variable sock_dns_server.
By supplying AF_INET, AF_INET6 or AF_UNSPEC in family
requesting of A records (IPv4), AAAA records (IPv6) or both can be selected.
This function will return the first DNS record it receives. IF both A and AAAA are requested, AAAA will be preferred.
addr_out
needs to provide space for any possible result! (4byte when family==AF_INET, 16byte otherwise)[in] | domain_name | DNS name to resolve into address |
[out] | addr_out | buffer to write result into |
[in] | family | Either AF_INET, AF_INET6 or AF_UNSPEC |