NAME

catnet_hostbyaddr - get hostnames and addresses from network database

SYNOPSIS

#include <cat/catutil.h>

catnet_host *catnet_hostbyaddr(const char *addr);

DESCRIPTION

This function takes a given name as an IP address in dotted decimal form (as returned by catnet_getnetinfo()), and returns the corresponding list of names and addresses, as known by the naming service (for example, DNS) in use on the machine.

The returned catnet_host structure looks as follows:

  typedef struct catnet_host {
      char **names;             /* name, alias, ..., NULL */
      char **addrs;             /* addresses, as strings, NULL-terminated */
  } catnet_host;

Where names is a NULL-terminated array of strings in which names[0] is the official name and the rest are the different alias names.

addrs is a NULL-terminated array of addresses specified as strings (in dotted decimal notation).

The entire catnet_host struct is stored in a single area of memory allocated by the function. This memory must be freed by a single call to free().

If no data was found, NULL is returned.

NOTES

This function is thread-safe, but is otherwise a wrapper around the standard call gethostbyaddr or gethostbyaddr_r.

SEE ALSO

cat, catnet

catnet_hostbyname