Seth Woolley's Man Viewer

Manual for resolver - man resolver

([section] manual, -k keyword, -K [section] search, -f whatis)
man plain no title

RESOLVER(3)                Linux Programmer's Manual               RESOLVER(3)



NAME
       res_init,    res_query,   res_search,   res_querydomain,   res_mkquery,
       res_send, dn_comp, dn_expand - resolver(3,5) routines

SYNOPSIS
       #include <netinet/in.h>
       #include <arpa/nameser.h>
       #include <resolv.h>
       extern struct state _res;

       int res_init(void);

       int res_query(const char *dname, int class, int type,
              unsigned char *answer, int anslen);

       int res_search(const char *dname, int class, int type,
              unsigned char *answer, int anslen);

       int res_querydomain(const char *name, const char *domain,
              int class, int type, unsigned char *answer,
              int anslen);

       int res_mkquery(int op, const char *dname, int class,
              int type, char *data, int datalen, struct rrec *newrr,
              char *buf, int buflen);

       int res_send(const char *msg, int msglen, char *answer,
              int anslen);

       int dn_comp(unsigned char *exp_dn, unsigned char *comp_dn,
              int length, unsigned char **dnptrs, unsigned char *exp_dn,
              unsigned char **lastdnptr);

       int dn_expand(unsigned char *msg, unsigned char *eomorig,
              unsigned char *comp_dn, unsigned char *exp_dn,
              int length);

       Link with -lresolv.

DESCRIPTION
       These functions make queries to and interpret the responses from Inter-
       net domain name servers.

       The  res_init() function reads the configuration files (see resolv+(8))
       to  get  the  default  domain  name,  search  order  and  name   server
       address(es).   If  no  server is given, the local host(1,5) is tried.  If no
       domain is given, that associated with the local host(1,5) is used.   It  can
       be overridden with the environment variable LOCALDOMAIN.  res_init() is
       normally executed by the first call to one of the other functions.

       The res_query() function queries the name server for  the  fully-quali-
       fied  domain  name name of specified type and class.  The reply is left
       in(1,8) the buffer answer of length anslen supplied by the caller.

       The res_search() function makes a query and waits for the response like
       res_query(),  but  in(1,8)  addition implements the default and search rules
       controlled by RES_DEFNAMES and  RES_DNSRCH  (see  description  of  _res
       options below).

       The  res_querydomain()  function makes a query using res_query() on the
       concatenation of name and domain.

       The following functions are lower-level routines used by res_query().

       The res_mkquery() function constructs a query message in(1,8) buf of  length
       buflen  for the domain name dname.  The query type op is usually QUERY,
       but can be any of the types defined in(1,8) <arpa/nameser.h>.  newrr is cur-
       rently unused.

       The  res_send()  function  sends  a pre-formatted query given in(1,8) msg of
       length msglen and returns the answer  in(1,8)  answer  which  is  of  length
       anslen.  It will call res_init(), if(3,n) it has not already been called.

       The  dn_comp() function compresses the domain name exp_dn and stores it
       in(1,8) the buffer comp_dn of length length.  The compression uses an  array
       of  pointers  dnptrs to previously compressed names in(1,8) the current mes-
       sage.  The first pointer points to the beginning of the message and the
       list ends with NULL.  The limit of the array is specified by lastdnptr.
       if(3,n) dnptr is NULL, domain names are not  compressed.   If  lastdnptr  is
       NULL, the list of labels is not updated.

       The  dn_expand() function expands the compressed domain name comp_dn to
       a full domain name, which is  placed  in(1,8)  the  buffer  exp_dn  of  size
       length.   The compressed name is contained in(1,8) a query or reply message,
       and msg points to the beginning of the message.

       The resolver(3,5) routines use global configuration  and  state  information
       contained  in(1,8)  the structure _res, which is defined in(1,8) <resolv.h>.  The
       only field that is normally manipulated by the  user  is  _res.options.
       This field can contain the bitwise ``or'' of the following options:


       RES_INIT
              True if(3,n) res_init() has been called.

       RES_DEBUG
              Print debugging messages.

       RES_AAONLY
              Accept  authoritative  answers only.  res_send() continues until
              it fins an authoritative answer or returns an error.  [Not  cur-
              rently implemented].

       RES_USEVC
              Use TCP connections for queries rather than UDP datagrams.

       RES_PRIMARY
              Query primary domain name server only.

       RES_IGNTC
              Ignore truncation errors.  Don't retry with TCP.  [Not currently
              implemented].

       RES_RECURSE
              Set the recursion desired bit in(1,8) queries.  Recursion is  carried
              out  by  the domain name server, not by res_send().  [Enabled by
              default].

       RES_DEFNAMES
              If set(7,n,1 builtins), res_search() will append the default domain name to sin-
              gle  component  names,  ie.  those  that  do  not contain a dot.
              [Enabled by default].

       RES_STAYOPEN
              Used with RES_USEVC to keep  the  TCP  connection  open(2,3,n)  between
              queries.

       RES_DNSRCH
              If  set(7,n,1 builtins),  res_search() will search for host(1,5) names in(1,8) the current
              domain and in(1,8) parent domains.  This option is used by gethostby-
              name(3).  [Enabled by default].

RETURN VALUE
       The res_init() function returns 0 on success, or -1 if(3,n) an error(8,n) occurs.

       The res_query(),  res_search(),  res_querydomain(),  res_mkquery()  and
       res_send()  functions  return  the  length of the response, or -1 if(3,n) an
       error(8,n) occurs.

       The dn_comp() and dn_expand() functions return the length of  the  com-
       pressed name, or -1 if(3,n) an error(8,n) occurs.

FILES
       /etc/resolv.conf          resolver(3,5) configuration file(1,n)
       /etc/host.conf            resolver(3,5) configuration file(1,n)

CONFORMING TO
       BSD 4.3

SEE ALSO
       gethostbyname(3), hostname(7), named(5,8)(8), resolv+(8)



BSD                               2004-10-31                       RESOLVER(3)

References for this manual (incoming links)