Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ resolver(3) — AIX/RT 2.2.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

     resolver

Purpose

     Make, send, and interpret name server information.

Library

     Sockets Library (libsock.a)

Syntax

     #include <sys/types.h>                    unsigned short getshort (msgp)
     #include <netinet/in.h>                   char *msgp;
     #include <arpa/nameser.h>
     #include <resolv.h>                       unsigned long getlong (msgp)
                                               char *msgp;
     int res_mkquery (op, dname, class, type,
          data, datalen, reserved, buf, buflen)void putshort (short, msgp)
     int op;                                   unsigned short short;
     char *dname;                              char *msgp;
     int class, type;
     char *data;                               void putlong (long, msgp)
     int datalen;                              unsigned long long;
     struct rrec *reserved;                    char *msgp;
     char *buf;
     int buflen;

     int res_send (msgp, msglen, answer, anslen)
     char *msgp;
     int msglen;
     char *answer;
     int anslen;

     void res_init ( )

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

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

     dn_skip (comp_dn)
     char *comp_dn;

     dn_find (exp_dn, msg, dnptrs, lastdnptr)
     char *exp_dn, *msg;
     char **dnptrs, **lastdnptr;

     Description

     The res_mkquery, res_send,  res_init, dn_comp, dn_expand,
     dn_skip,  dn_find,   getshort,  getlong,   putshort,  and
     putlong subroutines are used to make, send, and interpret
     packets  for   name  servers  in  the   Internet  domain.
     Together these  subroutines form  the resolver, a  set of
     functions that resolves domain names.

     Global information that is used by these resolver subrou-
     tines is kept  in the _res structure.   This structure is
     defined in the resolv.h header  file, and it contains the
     following members:

          int     retrans;
          int     retry;
          long    options;
          int     nscount;
          struct  sockaddr_in nsaddr_list[MAXNS|;
          ushort  id;
          char    defdname[MAXDNAME|;
       #define nsaddr  nsaddr_list[0|

     The options field of the _res structure is constructed by
     logically OR-ing the following values:

     RES_INIT       Indicates whether the  initial name server
                    and default domain name have been initial-
                    ized (that  is, whether res_init  has been
                    called).

     RES_DEBUG      Prints debugging messages.

     RES_USEVC      Uses TCP  connections for  queries instead
                    of UDP.

     RES_STAYOPEN   Used  with RES_USEVC,  keeps the  TCP con-
                    nection open  between queries.   While UDP
                    is the  mode normally  used, TCP  mode and
                    this option  are useful for  programs that
                    regularly do many queries.

     RES_RECURSE    Sets   the  recursion   desired  bit   for
                    queries.  This is the default.

                    Note that the res_send subroutine does not
                    do iterative queries  and expects the name
                    server to handle recursion.

     RES_DEFNAMES   Appends the default  domain name to single
                    label queries.  This is the default.

     The res_mkquery subroutine makes a standard query message
     and places this message in the location pointed to by the
     buf parameter,  which has a  length that is  specified by
     the buflen parameter.  The op parameter is usually QUERY,
     but can be  set to any of the query  types defined in the
     arpa/nameser.h header file, as listed below:

     QUERY     Standard query

     IQUERY    Inverse query

     CQUERYM   Completion query (multiple)

     CQUERYU   Completion query (unique).

     The dname parameter points to the name of the domain.  If
     the value pointed  to by dname is a single  label and the
     RES_DEFNAMES bit  is set, as  it is by default,  dname is
     appended  with  the  current domain  name.   The  current
     domain name is defined by the nameserver in use or in the
     /etc/resolv.conf file.

     The class parameter has one of the following values:

     C_IN          Specifies the ARPA Internet

     C_CHAOS       Specifies the chaos network at MIT.

     The type parameter  has a value taken  from the following
     list:

     T_A           Host address

     T_NS          Authoritative server

     T_MD          Mail destination

     T_MF          Mail forwarder

     T_CNAME       Cannonical name

     T_SOA         Start of authority zone

     T_MB          Mailbox domain name

     T_MG          Mail group member

     T_MR          Mail rename name

     T_NULL        NULL resource record

     T_WKS         Well-known service

     T_PTR         Domain name pointer

     T_HINFO       Host information

     T_MINFO       Mailbox information

     T_MX          Mail routing information

     T_UINFO       User (finger) information

     T_UID         User ID

     T_GID         Group ID.

     The data parameter is a pointer  to the data that will be
     sent  to the  name server  as a  search key;  the datalen
     parameter defines the size of the data.

     The reserved parameter is reserved and currently unused.

     The res_send  subroutine sends  a query to  name servers,
     calling the  res_init subroutine if RES_INIT  is not set.
     This subroutine sends the query  to the local name server
     and handles timeouts and retries.

     The res_init  subroutine reads the  /etc/resolv.conf file
     for the default  domain name and the  Internet address of
     the initial hosts running the  name server.  If this line
     does not  exist, the  res_init subroutine tries  the host
     from which it was called.

     The dn_comp subroutine compresses the domain name pointed
     to  by the  exp_dn parameter  and stores  it in  the area
     pointed to  by the comp_dn parameter.   The length param-
     eter is the  size of the array pointed to  by the comp_dn
     parameter.  The dnptrs parameter is a list of pointers to
     previously compressed names in  the current message.  The
     first pointer points to the  beginning of the message and
     the list  ends with NULL.   The lastdnptr parameter  is a
     pointer to the end of the  array pointed to by the dnptrs
     parameter.

     A side effect of this subroutine is to update the list of
     pointers for  labels the dn_comp subroutine  inserts into
     the message as the name is compressed.  No names are com-
     pressed if the value of  dnptr is NULL.  If the lastdnptr
     parameter is NULL, the list of pointers is not updated.

     The  dn_expand subroutine  expands the  compressed domain
     name pointed to by the comp_dn parameter to a full domain
     name, converting  the expanded  names to  uppercase.  The
     msgp  parameter is  a  pointer to  the  beginning of  the
     message.  The exp_dn parameter is  a pointer to a buffer,
     with  the size  specified by  the length  parameter, that
     holds the  result.  The  eomorig parameter points  to the
     end  of the  original  message, which  contains the  com-
     pressed domain name.

     The  dn_skip subroutine  skips over  a compressed  domain
     name.

     The dn_find  subroutine searches  for an  expanded domain
     name  from  a list  of  previously  compressed names  and
     returns the offset from msg, if found.

     The getshort and getlong  subroutines get quantities from
     the  byte  stream  or  arbitrary  byte  boundaries.   The
     putshort and putlong subroutines  put quantities into the
     byte  stream  or  arbitrary byte  boundaries.   The  msgp
     parameter  for  all  of these  subroutines  represents  a
     pointer into the byte stream.

     Return Value

     The res_mkquery subroutine returns  the size of the query
     upon success.  A  value of -1 is returned  if the subrou-
     tine fails because the query  is larger than the value of
     the buflen parameter.

     The res_send subroutine returns the length of the message
     if it succeeds, and a value of -1 if it fails.

     The dn_comp subroutine returns the size of the compressed
     domain name if it succeeds.  A value of -1 is returned if
     the subroutine fails.

     The dn_exp  subroutine returns  the size of  the expanded
     domain name if it succeeds.  A value of -1 is returned if
     dn_exp fails.

     The getshort and getlong subroutines return a short and a
     long value, respectively.

     File

     /etc/resolv.conf         Contains name  server and domain
                              name information.

     Related Information

     The discussions of the domain name server and resolv.conf
     in Interface Program for use with TCP/IP.

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026