1RESOLVER(3)                Library Functions Manual                RESOLVER(3)
2
3
4

NAME

6       res_mkquery, res_send, res_init, dn_comp, dn_expand - resolver routines
7

SYNOPSIS

9       #include <sys/types.h>
10       #include <netinet/in.h>
11       #include <arpa/nameser.h>
12       #include <resolv.h>
13
14       res_mkquery(op, dname, class, type, data, datalen, newrr, buf, buflen)
15       int op;
16       char *dname;
17       int class, type;
18       char *data;
19       int datalen;
20       struct rrec *newrr;
21       char *buf;
22       int buflen;
23
24       res_send(msg, msglen, answer, anslen)
25       char *msg;
26       int msglen;
27       char *answer;
28       int anslen;
29
30       res_init()
31
32       dn_comp(exp_dn, comp_dn, length, dnptrs, lastdnptr)
33       char *exp_dn, *comp_dn;
34       int length;
35       char **dnptrs, **lastdnptr;
36
37       dn_expand(msg, eomorig, comp_dn, exp_dn, length)
38       char *msg, *eomorig, *comp_dn, exp_dn;
39       int length;
40

DESCRIPTION

42       These  routines  are  used for making, sending and interpreting packets
43       for use with Internet domain name servers.  Global information that  is
44       used  by  the  resolver routines is kept in the variable _res.  Most of
45       the values have reasonable defaults and can be ignored.  Options stored
46       in  _res.options  are  defined in resolv.h and are as follows.  Options
47       are stored a simple bit mask  containing  the  bitwise  ``or''  of  the
48       options enabled.
49
50       RES_INIT
51              True  if the initial name server address and default domain name
52              are initialized (i.e., res_init has been called).
53
54       RES_DEBUG
55              Print debugging messages.
56
57       RES_AAONLY
58              Accept authoritative answers only.  With this  option,  res_send
59              should  continue until it finds an authoritative answer or finds
60              an error.  Currently this is not implemented.
61
62       RES_USEVC
63              Use TCP connections for queries instead of UDP datagrams.
64
65       RES_STAYOPEN
66              Used with RES_USEVC to keep  the  TCP  connection  open  between
67              queries.  This is useful only in programs that regularly do many
68              queries.  UDP should be the normal mode used.
69
70       RES_IGNTC
71              Unused currently (ignore truncation errors,  i.e.,  don't  retry
72              with TCP).
73
74       RES_RECURSE
75              Set  the recursion-desired bit in queries.  This is the default.
76              ( res_send does not do iterative queries and  expects  the  name
77              server to handle recursion.)
78
79       RES_DEFNAMES
80              If  set, res_mkquery will append the default domain name to sin‐
81              gle-component names (those that do not contain a dot).  This  is
82              the default.
83
84       RES_DNSRCH
85              If this option is set, the standard host lookup routine gethost‐
86              byname(3) will search for host names in the current  domain  and
87              in parent domains; see hostname(7).
88
89       Res_init
90
91       reads  the  initialization  file to get the default domain name and the
92       Internet address of the initial hosts running the name server.  If this
93       line   does  not  exist,  the  host  running  the  resolver  is  tried.
94       Res_mkquery makes a standard  query  message  and  places  it  in  buf.
95       Res_mkquery  will  return  the  size of the query or -1 if the query is
96       larger than buflen.  Op is usually QUERY but can be any  of  the  query
97       types  defined  in nameser.h.  Dname is the domain name.  If dname con‐
98       sists of a single label and  the  RES_DEFNAMES  flag  is  enabled  (the
99       default),  the current domain name will be appended to dname.  The cur‐
100       rent domain name is defined by the hostname or is specified in a system
101       file;  it  can  be  overridden by the environment variable LOCALDOMAIN.
102       Newrr is currently unused but is intended for making update messages.
103
104       Res_send sends a query to name servers and returns an answer.  It  will
105       call  res_init if RES_INIT is not set, send the query to the local name
106       server, and handle timeouts and retries.  The length of the message  is
107       returned, or -1 if there were errors.
108
109       Dn_expand  expands  the compressed domain name comp_dn to a full domain
110       name.  Expanded names are converted to upper case.  Msg is a pointer to
111       the  beginning  of the message, exp_dn is a pointer to a buffer of size
112       length for the result.  The size of compressed name is returned  or  -1
113       if there was an error.
114
115       Dn_comp  compresses  the  domain  name exp_dn and stores it in comp_dn.
116       The size of the compressed name is returned or -1 if there were errors.
117       length  is  the  size  of the array pointed to by comp_dn.  Dnptrs is a
118       list of pointers to previously compressed names in the current message.
119       The  first  pointer  points  to to the beginning of the message and the
120       list ends with NULL.  lastdnptr is a pointer to the end  of  the  array
121       pointed to dnptrs.  A side effect is to update the list of pointers for
122       labels inserted into the message by dn_comp as the name is  compressed.
123       If  dnptr is NULL, names are not compressed.  If lastdnptr is NULL, the
124       list of labels is not updated.
125

FILES

127       /etc/resolv.conf    see resolver(5)
128

SEE ALSO

130       gethostbyname(3), named(8), resolver(5), hostname(7),
131       RFC882, RFC883, RFC973, RFC974,
132       SMM:11 Name Server Operations Guide for BIND
133
134
135
1364th Berkeley Distribution      November 21, 1987                   RESOLVER(3)
Impressum