This enables functionality like /etc/hosts
for dns_query()
More...
This enables functionality like /etc/hosts
for dns_query()
This module allows to make static hostname - IP address mappings that will be taken into consideration when using dns_query()
or a higher level API that makes use of dns_query()
.
To enable this, add the hosts
module to your Makefile
:
To add a static hostname mapping to your code, just declare it with HOST_IPV4()
or HOST_IPV6()
anywhere in a .c
file
The hostname should then be resolved by any tool or function that makes use of dns_query()
:
Files | |
file | hosts.h |
Static mappings from hostnames to IP addresses. | |
Data Structures | |
struct | hostnames_v4_xfa_t |
A single IPv4 host in the list of hostnames. More... | |
struct | hostnames_v6_xfa_t |
A single IPv6 host in the list of hostnames. More... | |
Macros | |
#define | HOST_IPV4(host, ip) |
Define IPv4 host. More... | |
#define | HOST_IPV6(host, ip) |
Define IPv6 host. More... | |
Functions | |
int | hosts_query (const char *host_name, void *addr_out, int family) |
Get IP address for a host name. More... | |
#define HOST_IPV4 | ( | host, | |
ip | |||
) |
Define IPv4 host.
extern "C"
function implemented in C.This macro is a helper for defining a hostname -> address mapping and adding it to the host names XFA (cross file array).
Example:
#define HOST_IPV6 | ( | host, | |
ip | |||
) |
Define IPv6 host.
extern "C"
function implemented in C.This macro is a helper for defining a hostname -> address mapping and adding it to the host names XFA (cross file array).
Example:
int hosts_query | ( | const char * | host_name, |
void * | addr_out, | ||
int | family | ||
) |
Get IP address for a host name.
Host Name <-> IP address mappings can be statically defined with the HOST_IPV6 macro.
[in] | host_name | Host name to resolve into address |
[out] | addr_out | Buffer to write result into, but be able to accommodate an address of the selected family |
[in] | family | Either AF_INET (IPv4), AF_INET6 (IPv6) or AF_UNSPEC (either IPv4 or IPv6) |
-ENOENT | if no matching entry could be found |