sockaddr's now require length (K. Sklower);
[unix-history] / usr / src / lib / libc / net / resolver.3
CommitLineData
7403e690 1.\" Copyright (c) 1985 Regents of the University of California.
49bbe9e0
KD
2.\" All rights reserved. The Berkeley software License Agreement
3.\" specifies the terms and conditions for redistribution.
4.\"
cdf61d7f 5.\" @(#)resolver.3 6.1 (Berkeley) %G%
49bbe9e0 6.\"
c470f385 7.TH RESOLVER 3 ""
49bbe9e0
KD
8.UC 4
9.SH NAME
10res_mkquery, res_send, res_init, dn_comp, dn_expand \- resolver routines
11.SH SYNOPSIS
12.B #include <sys/types.h>
13.br
14.B #include <netinet/in.h>
15.br
7403e690 16.B #include <arpa/nameser.h>
49bbe9e0 17.br
21b6cc0f 18.B #include <resolv.h>
49bbe9e0
KD
19.PP
20.B "res_mkquery(op, dname, class, type, data, datalen, newrr, buf, buflen)"
21.br
22.B int op;
23.br
24.B char *dname;
25.br
26.B int class, type;
27.br
28.B char *data;
29.br
30.B int datalen;
31.br
32.B struct rrec *newrr;
33.br
34.B char *buf;
35.br
36.B int buflen;
37.PP
38.B res_send(msg, msglen, answer, anslen)
39.br
40.B char *msg;
41.br
42.B int msglen;
43.br
44.B char *answer;
45.br
46.B int anslen;
47.PP
48.B res_init()
49.PP
50.B dn_comp(exp_dn, comp_dn, length, dnptrs, lastdnptr)
51.br
52.B char *exp_dn, *comp_dn;
53.br
54.B int length;
55.br
56.B char **dnptrs, **lastdnptr;
57.PP
5369f879 58.B dn_expand(msg, eomorig, comp_dn, exp_dn, length)
49bbe9e0 59.br
5369f879 60.B char *msg, *eomorig, *comp_dn, exp_dn;
49bbe9e0 61.br
5369f879 62.B int length;
49bbe9e0 63.SH DESCRIPTION
c470f385
MK
64These routines are used for making, sending and interpreting packets
65for use with Internet domain name servers.
66Global information that is used by the
49bbe9e0
KD
67resolver routines is kept in the variable
68.IR _res .
c470f385
MK
69Most of the values have reasonable defaults and can be ignored.
70Options
49bbe9e0
KD
71stored in
72.I _res.options
73are defined in
74.I resolv.h
c470f385
MK
75and are as follows.
76Options are stored a simple bit mask containing the bitwise ``or''
77of the options enabled.
49bbe9e0
KD
78.IP RES_INIT
79True if the initial name server address and default domain name are
80initialized (i.e.,
81.I res_init
82has been called).
83.IP RES_DEBUG
84Print debugging messages.
85.IP RES_AAONLY
86Accept authoritative answers only.
c470f385
MK
87With this option,
88.I res_send
89should continue until it finds an authoritative answer or finds an error.
49bbe9e0
KD
90Currently this is not implemented.
91.IP RES_USEVC
c470f385 92Use TCP connections for queries instead of UDP datagrams.
21b6cc0f
KD
93.IP RES_STAYOPEN
94Used with RES_USEVC to keep the TCP connection open between
95queries.
96This is useful only in programs that regularly do many queries.
97UDP should be the normal mode used.
49bbe9e0
KD
98.IP RES_IGNTC
99Unused currently (ignore truncation errors, i.e., don't retry with TCP).
100.IP RES_RECURSE
c470f385
MK
101Set the recursion-desired bit in queries.
102This is the default.
49bbe9e0
KD
103(
104.I res_send
21b6cc0f
KD
105does not do iterative queries and expects the name server
106to handle recursion.)
49bbe9e0 107.IP RES_DEFNAMES
c470f385
MK
108If set,
109.I res_mkquery
110will append the default domain name to single-component names
111(those that do not contain a dot).
112This is the default.
113.IP RES_DNSRCH
114If this option is set,
115the standard host lookup routine
116.IR gethostbyname (3)
117will search for host names in the current domain and in parent domains; see
118.IR hostname (7).
49bbe9e0
KD
119.PP
120.I Res_init
121.PP
7403e690
KD
122reads the initialization file to get the default
123domain name and the Internet address of the initial hosts
c470f385
MK
124running the name server.
125If this line does not exist, the host running
7403e690 126the resolver is tried.
49bbe9e0 127.I Res_mkquery
21b6cc0f 128makes a standard query message and places it in
49bbe9e0
KD
129.IR buf .
130.I Res_mkquery
131will return the size of the query or \-1 if the query is
132larger than
133.IR buflen .
134.I Op
135is usually QUERY but can be any of the query types defined in
136.IR nameser.h .
137.I Dname
c470f385
MK
138is the domain name.
139If
49bbe9e0
KD
140.I dname
141consists of a single label and the RES_DEFNAMES flag is enabled
c470f385
MK
142(the default), the current domain name will be appended to
143.IR dname .
144The current domain name is defined by the hostname
145or is specified in a system file; it can be overridden
49bbe9e0
KD
146by the environment variable LOCALDOMAIN.
147.I Newrr
148is currently unused but is intended for making update messages.
149.PP
150.I Res_send
21b6cc0f 151sends a query to name servers and returns an answer.
49bbe9e0
KD
152It will call
153.I res_init
7403e690 154if RES_INIT is not set, send the query to the local name server, and
c470f385
MK
155handle timeouts and retries.
156The length of the message is returned, or
49bbe9e0
KD
157\-1 if there were errors.
158.PP
159.I Dn_expand
e030f4aa 160expands the compressed domain name
49bbe9e0
KD
161.I comp_dn
162to a full domain name. Expanded names are converted to upper case.
163.I Msg
164is a pointer to the beginning of the message,
165.I exp_dn
166is a pointer to a buffer of size
167.I length
168for the result.
169The size of compressed name is returned or -1 if there was an error.
170.PP
171.I Dn_comp
e030f4aa 172compresses the domain name
49bbe9e0
KD
173.I exp_dn
174and stores it in
175.IR comp_dn .
176The size of the compressed name is returned or -1 if there were errors.
177.I length is the size of the array pointed to by
178.IR comp_dn .
179.I Dnptrs
180is a list of pointers to previously compressed names in the current message.
181The first pointer points to
182to the beginning of the message and the list ends with NULL.
183.I lastdnptr
184is a pointer to the end of the array pointed to
185.IR dnptrs .
186A side effect is to update the list of pointers for
187labels inserted into the message by
188.I dn_comp
189as the name is compressed.
190If
191.I dnptr
c470f385
MK
192is NULL, names are not compressed.
193If
49bbe9e0 194.I lastdnptr
c470f385 195is NULL, the list of labels is not updated.
49bbe9e0 196.SH FILES
c470f385 197/etc/resolv.conf see resolver(5)
49bbe9e0 198.SH "SEE ALSO"
c470f385
MK
199gethostbyname(3), named(8), resolver(5), hostname(7),
200.br
201RFC882, RFC883, RFC973, RFC974,
202.br
e030f4aa 203SMM:11 Name Server Operations Guide for BIND