Commit | Line | Data |
---|---|---|
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 | |
10 | res_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 |
64 | These routines are used for making, sending and interpreting packets |
65 | for use with Internet domain name servers. | |
66 | Global information that is used by the | |
49bbe9e0 KD |
67 | resolver routines is kept in the variable |
68 | .IR _res . | |
c470f385 MK |
69 | Most of the values have reasonable defaults and can be ignored. |
70 | Options | |
49bbe9e0 KD |
71 | stored in |
72 | .I _res.options | |
73 | are defined in | |
74 | .I resolv.h | |
c470f385 MK |
75 | and are as follows. |
76 | Options are stored a simple bit mask containing the bitwise ``or'' | |
77 | of the options enabled. | |
49bbe9e0 KD |
78 | .IP RES_INIT |
79 | True if the initial name server address and default domain name are | |
80 | initialized (i.e., | |
81 | .I res_init | |
82 | has been called). | |
83 | .IP RES_DEBUG | |
84 | Print debugging messages. | |
85 | .IP RES_AAONLY | |
86 | Accept authoritative answers only. | |
c470f385 MK |
87 | With this option, |
88 | .I res_send | |
89 | should continue until it finds an authoritative answer or finds an error. | |
49bbe9e0 KD |
90 | Currently this is not implemented. |
91 | .IP RES_USEVC | |
c470f385 | 92 | Use TCP connections for queries instead of UDP datagrams. |
21b6cc0f KD |
93 | .IP RES_STAYOPEN |
94 | Used with RES_USEVC to keep the TCP connection open between | |
95 | queries. | |
96 | This is useful only in programs that regularly do many queries. | |
97 | UDP should be the normal mode used. | |
49bbe9e0 KD |
98 | .IP RES_IGNTC |
99 | Unused currently (ignore truncation errors, i.e., don't retry with TCP). | |
100 | .IP RES_RECURSE | |
c470f385 MK |
101 | Set the recursion-desired bit in queries. |
102 | This is the default. | |
49bbe9e0 KD |
103 | ( |
104 | .I res_send | |
21b6cc0f KD |
105 | does not do iterative queries and expects the name server |
106 | to handle recursion.) | |
49bbe9e0 | 107 | .IP RES_DEFNAMES |
c470f385 MK |
108 | If set, |
109 | .I res_mkquery | |
110 | will append the default domain name to single-component names | |
111 | (those that do not contain a dot). | |
112 | This is the default. | |
113 | .IP RES_DNSRCH | |
114 | If this option is set, | |
115 | the standard host lookup routine | |
116 | .IR gethostbyname (3) | |
117 | will 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 |
122 | reads the initialization file to get the default |
123 | domain name and the Internet address of the initial hosts | |
c470f385 MK |
124 | running the name server. |
125 | If this line does not exist, the host running | |
7403e690 | 126 | the resolver is tried. |
49bbe9e0 | 127 | .I Res_mkquery |
21b6cc0f | 128 | makes a standard query message and places it in |
49bbe9e0 KD |
129 | .IR buf . |
130 | .I Res_mkquery | |
131 | will return the size of the query or \-1 if the query is | |
132 | larger than | |
133 | .IR buflen . | |
134 | .I Op | |
135 | is usually QUERY but can be any of the query types defined in | |
136 | .IR nameser.h . | |
137 | .I Dname | |
c470f385 MK |
138 | is the domain name. |
139 | If | |
49bbe9e0 KD |
140 | .I dname |
141 | consists 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 . | |
144 | The current domain name is defined by the hostname | |
145 | or is specified in a system file; it can be overridden | |
49bbe9e0 KD |
146 | by the environment variable LOCALDOMAIN. |
147 | .I Newrr | |
148 | is currently unused but is intended for making update messages. | |
149 | .PP | |
150 | .I Res_send | |
21b6cc0f | 151 | sends a query to name servers and returns an answer. |
49bbe9e0 KD |
152 | It will call |
153 | .I res_init | |
7403e690 | 154 | if RES_INIT is not set, send the query to the local name server, and |
c470f385 MK |
155 | handle timeouts and retries. |
156 | The length of the message is returned, or | |
49bbe9e0 KD |
157 | \-1 if there were errors. |
158 | .PP | |
159 | .I Dn_expand | |
e030f4aa | 160 | expands the compressed domain name |
49bbe9e0 KD |
161 | .I comp_dn |
162 | to a full domain name. Expanded names are converted to upper case. | |
163 | .I Msg | |
164 | is a pointer to the beginning of the message, | |
165 | .I exp_dn | |
166 | is a pointer to a buffer of size | |
167 | .I length | |
168 | for the result. | |
169 | The size of compressed name is returned or -1 if there was an error. | |
170 | .PP | |
171 | .I Dn_comp | |
e030f4aa | 172 | compresses the domain name |
49bbe9e0 KD |
173 | .I exp_dn |
174 | and stores it in | |
175 | .IR comp_dn . | |
176 | The 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 | |
180 | is a list of pointers to previously compressed names in the current message. | |
181 | The first pointer points to | |
182 | to the beginning of the message and the list ends with NULL. | |
183 | .I lastdnptr | |
184 | is a pointer to the end of the array pointed to | |
185 | .IR dnptrs . | |
186 | A side effect is to update the list of pointers for | |
187 | labels inserted into the message by | |
188 | .I dn_comp | |
189 | as the name is compressed. | |
190 | If | |
191 | .I dnptr | |
c470f385 MK |
192 | is NULL, names are not compressed. |
193 | If | |
49bbe9e0 | 194 | .I lastdnptr |
c470f385 | 195 | is 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 |
199 | gethostbyname(3), named(8), resolver(5), hostname(7), |
200 | .br | |
201 | RFC882, RFC883, RFC973, RFC974, | |
202 | .br | |
e030f4aa | 203 | SMM:11 Name Server Operations Guide for BIND |