MyWebUniversity.com Home Page
 



Darwin Mac OS X man pages main menu
RESOLVER(3)              BSD Library Functions Manual              RESOLVER(3)

NAME
     resquery, ressearch, resmkquery, ressend, resinit, dncomp,
     dnexpand, dnskipname, nsget16, nsget32, nsput16, nsput32 --
     resolver routines

LIBRARY
     Standard C Library (libc, -lc)

SYNOPSIS
     ##include <>
     ##include <>
     ##include <>
     ##include <>

     int
     resquery(const char *dname, int class, int type, uchar *answer,
         int anslen);

     int
     ressearch(const char *dname, int class, int type, uchar *answer,
         int anslen);

     int
     resmkquery(int op, const char *dname, int class, int type,
         const uchar *data, int datalen, const uchar *newrrin, uchar *buf,
         int buflen);

     int
     ressend(const uchar *msg, int msglen, uchar *answer, int anslen);

     int
     resinit();

     int
     dncomp(const char *expdn, uchar *compdn, int length, uchar **dnptrs,
         uchar **lastdnptr);

     int
     dnexpand(const uchar *msg, const uchar *eomorig,
         const uchar *compdn, char *expdn, int length);

     int
     dnskipname(const uchar *compdn, const uchar *eom);

     uint
     nsget16(const uchar *src);

     ulong
     nsget32(const uchar *src);

     void
     nsput16(uint src, uchar *dst);

     void
     nsput32(ulong src, uchar *dst);

DESCRIPTION
     These routines are used for making, sending and interpreting query and
     reply messages with Internet domain name servers.

     Global configuration and state information that is used by the resolver
     routines is kept in the structure res.  Most of the values have reason-
     able defaults and can be ignored.  Options stored in res.options are
     defined in resolv.h and are as follows.  Options are stored as a simple
     bit mask containing the bitwise ``or'' of the options enabled.

     RESINIT       True if the initial name server address and default domain
                    name are initialized (i.e., resinit() has been called).

     RESDEBUG      Print debugging messages.

     RESAONLY     Accept authoritative answers only.  With this option,
                    ressend() should continue until it finds an authoritative
                    answer or finds an error.  Currently this is not imple-
                    mented.

     RESUSEVC      Use TCP connections for queries instead of UDP datagrams.

     RESTAYOPEN   Used with RESUSEVC to keep the TCP connection open
                    between queries.  This is useful only in programs that
                    regularly do many queries.  UDP should be the normal mode
                    used.

     RESIGNTC      Unused currently (ignore truncation errors, i.e., don't
                    retry with TCP).

     RESRECURSE    Set the recursion-desired bit in queries.  This is the
                    default.  (ressend() does not do iterative queries and
                    expects the name server to handle recursion.)

     RESDEFNAMES   If set, ressearch() will append the default domain name
                    to single-component names (those that do not contain a
                    dot).  This option is enabled by default.

     RESDNSRCH     If this option is set, ressearch() will search for host
                    names in the current domain and in parent domains; see
                    hostname(7).  This is used by the standard host lookup
                    routine gethostbyname(3).  This option is enabled by
                    default.

     RESNOALIASES  This option turns off the user level aliasing feature con-
                    trolled by the ``HOSTALIASES'' environment variable.  Net-
                    work daemons should set this option.

     RESUSEINET6  Enables support for IPv6-only applications.  This causes
                    IPv4 addresses to be returned as an IPv4 mapped address.
                    For example, 10.1.1.1 will be returned as ::ffff:10.1.1.1.
                    The option is meaningful with certain kernel configuration
                    only.

     RESUSEDNS0  Enables support for OPT pseudo-R for EDNS0 extension.
                    With the option, resolver code will attach OPT pseudo-R
                    into DNS queries, to inform of our receive buffer size.
                    The option will allow DNS servers to take advantage of
                    non-default receive buffer size, and to send larger
                    replies.  DNS query packets with EDNS0 extension is not
                    compatible with non-EDNS0 DNS servers.

     The resinit() routine reads the configuration file (if any; see
     resolver(5)) to get the default domain name, search list and the Internet
     address of the local name server(s).  If no server is configured, the
     host running the resolver is tried.  The current domain name is defined
     by the hostname if not specified in the configuration file; it can be
     overridden by the environment variable LOCALDOMAIN.  This environment
     variable may contain several blank-separated tokens if you wish to over-
     ride the search list on a per-process basis.  This is similar to the
     search command in the configuration file.  Another environment variable
     ``RESOPTIONS'' can be set to override certain internal resolver options
     which are otherwise set by changing fields in the res structure or are
     inherited from the configuration file's options command.  The syntax of
     the ``RESOPTIONS'' environment variable is explained in resolver(5).
     Initialization normally occurs on the first call to one of the following
     routines.

     The resquery() function provides an interface to the server query mecha-
     nism.  It constructs a query, sends it to the local server, awaits a
     response, and makes preliminary checks on the reply.  The query requests
     information of the specified type and class for the specified fully-qual-
     ified domain name dname.  The reply message is left in the answer buffer
     with length anslen supplied by the caller.

     The ressearch() routine makes a query and awaits a response like
     resquery(), but in addition, it implements the default and search rules
     controlled by the RESDEFNAMES and RESDNSRCH options.  It returns the
     first successful reply.

     The remaining routines are lower-level routines used by resquery().  The
     resmkquery() function constructs a standard query message and places it
     in buf.  It returns the size of the query, or -1 if the query is larger
     than buflen.  The query type op is usually QUERY, but can be any of the
     query types defined in .  The domain name for the query
     is given by dname.  Newrr is currently unused but is intended for making
     update messages.

     The ressend() routine sends a pre-formatted query and returns an answer.
     It will call resinit() if RESINIT is not set, send the query to the
     local name server, and handle timeouts and retries.  The length of the
     reply message is returned, or -1 if there were errors.

     The dncomp() function compresses the domain name expdn and stores it in
     compdn.  The size of the compressed name is returned or -1 if there were
     errors.  The size of the array pointed to by compdn is given by length.
     The compression uses an array of pointers dnptrs to previously-compressed
     names in the current message.  The first pointer points to the beginning
     of the message and the list ends with NUL.  The limit to the array is
     specified by lastdnptr.  A side effect of dncomp() is to update the list
     of pointers for labels inserted into the message as the name is com-
     pressed.  If dnptr is NUL, names are not compressed.  If lastdnptr is
     NUL, the list of labels is not updated.

     The dnexpand() entry expands the compressed domain name compdn to a
     full domain name The compressed name is contained in a query or reply
     message; msg is a pointer to the beginning of the message.  The uncom-
     pressed name is placed in the buffer indicated by expdn which is of size
     length.  The size of compressed name is returned or -1 if there was an
     error.

     The dnskipname() function skips over a compressed domain name, which
     starts at a location pointed to by compdn.  The compressed name is con-
     tained in a query or reply message; eom is a pointer to the end of the
     message.  The size of compressed name is returned or -1 if there was an
     error.

     The nsget16() function gets a 16-bit quantity from a buffer pointed to
     by src.

     The nsget32() function gets a 32-bit quantity from a buffer pointed to
     by src.

     The nsput16() function puts a 16-bit quantity src to a buffer pointed to
     by dst.

     The nsput32() function puts a 32-bit quantity src to a buffer pointed to
     by dst.

FILES
     /etc/resolv.conf  The configuration file, see resolver(5).

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

     RFC1032, RFC1033, RFC1034, RFC1035, RFC974

     Name Server Operations Guide for BIND.

HISTORY
     The resquery function appeared in 4.3BSD.

BSD                              June 4, 1993                              BSD
Darwin Mac OS X man pages main menu

Contact us      |       About us      |       Term of use      |       Copyright © 2000-2010 MyWebUniversity.com ™