Langue: en

Autres versions - même langue

Version: 269971 (debian - 07/07/09)

Section: 3 (Bibliothèques de fonctions)


dns_ip4 - Host name to IP addresses


#include <dns.h>

dns_ip4(&out, &fqdn);
dns_ip4_packet(&out, buf, len);

  stralloc out = {0};
  stralloc fqdn = {0};
  char *buf;
  unsigned int len;


dns_ip4 looks up 4-byte IP addresses for the fully-qualified domain name in fqdn. It puts the concatenation of the IP addresses into out and returns 0. If the domain does not exist in DNS, or has no IP addresses, out will be empty.

If dns_ip4 has trouble with the DNS lookup or runs out of memory, it returns -1, setting errno appropriately. It may or may not change out.

If fqdn is a dotted-decimal IP address, dns_ip4 puts that IP address into out without checking DNS. More generally, if fqdn is a dot-separated sequence of dotted-decimal IP addresses, dns_ip4 puts those IP addresses into out without checking DNS. Brackets may appear inside the dotted-decimal IP addresses; they are ignored.

dns_ip4_packet is a low-level component of dns_ip4, designed to support asynchronous DNS lookups. It reads a DNS packet of length len from buf, extracts IP addresses from the answer section of the packet, puts the addresses into out, and returns 0 or -1 the same way as dns_ip4.


dns_domain(3), dns_ip4_qualify(3), dns_mx(3), dns_name4(3), dns_packet(3), dns_random(3), dns_transmit(3), dns_txt(3)