set socket pgrp to avoid races; block SIGURG till done;
[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.\"
21b6cc0f 5.\" @(#)resolver.3 1.5 (Berkeley) %G%
49bbe9e0 6.\"
7403e690 7.TH RESOLVER 3 "15 November 1985"
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
66ad1208 58.B dn_expand(msg, msglen, comp_dn, exp_dn, length)
49bbe9e0 59.br
49bbe9e0
KD
60.B char *msg, *comp_dn, exp_dn;
61.br
66ad1208 62.B int msglen, length;
49bbe9e0
KD
63.SH DESCRIPTION
64These routines are used for making, sending and interpreting packets to
65Internet domain name servers. Global information that is used by the
66resolver routines is kept in the variable
67.IR _res .
68Most of the values have reasonable defaults and can be ignored. Options
69stored in
70.I _res.options
71are defined in
72.I resolv.h
73and are as follows. Options are a simple bit mask and are or'ed in to
74enable.
75.IP RES_INIT
76True if the initial name server address and default domain name are
77initialized (i.e.,
78.I res_init
79has been called).
80.IP RES_DEBUG
81Print debugging messages.
82.IP RES_AAONLY
83Accept authoritative answers only.
84.I Res_send
85will continue until it finds an authoritative answer or finds an error.
86Currently this is not implemented.
87.IP RES_USEVC
88Use TCP connections for queries instead of UDP.
21b6cc0f
KD
89.IP RES_STAYOPEN
90Used with RES_USEVC to keep the TCP connection open between
91queries.
92This is useful only in programs that regularly do many queries.
93UDP should be the normal mode used.
49bbe9e0
KD
94.IP RES_IGNTC
95Unused currently (ignore truncation errors, i.e., don't retry with TCP).
96.IP RES_RECURSE
97Set the recursion desired bit in queries. This is the default.
98(
99.I res_send
21b6cc0f
KD
100does not do iterative queries and expects the name server
101to handle recursion.)
49bbe9e0
KD
102.IP RES_DEFNAMES
103Append the default domain name to single label queries. This is the default.
104.PP
105.I Res_init
106.PP
7403e690
KD
107reads the initialization file to get the default
108domain name and the Internet address of the initial hosts
49bbe9e0 109running the name server. If this line does not exist, the host running
7403e690 110the resolver is tried.
49bbe9e0 111.I Res_mkquery
21b6cc0f 112makes a standard query message and places it in
49bbe9e0
KD
113.IR buf .
114.I Res_mkquery
115will return the size of the query or \-1 if the query is
116larger than
117.IR buflen .
118.I Op
119is usually QUERY but can be any of the query types defined in
120.IR nameser.h .
121.I Dname
122is the domain name. If
123.I dname
124consists of a single label and the RES_DEFNAMES flag is enabled
125(the default),
126.I dname
127will be appended with the current domain name. The current
128domain name is defined in a system file and can be overridden
129by the environment variable LOCALDOMAIN.
130.I Newrr
131is currently unused but is intended for making update messages.
132.PP
133.I Res_send
21b6cc0f 134sends a query to name servers and returns an answer.
49bbe9e0
KD
135It will call
136.I res_init
7403e690 137if RES_INIT is not set, send the query to the local name server, and
49bbe9e0
KD
138handle timeouts and retries. The length of the message is returned or
139\-1 if there were errors.
140.PP
141.I Dn_expand
142Expands the compressed domain name
143.I comp_dn
144to a full domain name. Expanded names are converted to upper case.
145.I Msg
146is a pointer to the beginning of the message,
147.I exp_dn
148is a pointer to a buffer of size
149.I length
150for the result.
151The size of compressed name is returned or -1 if there was an error.
152.PP
153.I Dn_comp
154Compresses the domain name
155.I exp_dn
156and stores it in
157.IR comp_dn .
158The size of the compressed name is returned or -1 if there were errors.
159.I length is the size of the array pointed to by
160.IR comp_dn .
161.I Dnptrs
162is a list of pointers to previously compressed names in the current message.
163The first pointer points to
164to the beginning of the message and the list ends with NULL.
165.I lastdnptr
166is a pointer to the end of the array pointed to
167.IR dnptrs .
168A side effect is to update the list of pointers for
169labels inserted into the message by
170.I dn_comp
171as the name is compressed.
172If
173.I dnptr
174is NULL, we don't try to compress names. If
175.I lastdnptr
176is NULL, we don't update the list.
177.SH FILES
09bbc5a9 178/etc/resolv.conf see resolver(5)
49bbe9e0 179.SH "SEE ALSO"
21b6cc0f
KD
180named(8), resolver(5), RFC882, RFC883, RFC973, RFC974,
181BIND - Operations Guide