diff options
Diffstat (limited to 'src/lib/libc/net/resolver.3')
| -rw-r--r-- | src/lib/libc/net/resolver.3 | 354 |
1 files changed, 0 insertions, 354 deletions
diff --git a/src/lib/libc/net/resolver.3 b/src/lib/libc/net/resolver.3 deleted file mode 100644 index e820ea25ed..0000000000 --- a/src/lib/libc/net/resolver.3 +++ /dev/null | |||
| @@ -1,354 +0,0 @@ | |||
| 1 | .\" $OpenBSD: resolver.3,v 1.21 2007/05/31 19:19:30 jmc Exp $ | ||
| 2 | .\" | ||
| 3 | .\" Copyright (c) 1985, 1991, 1993 | ||
| 4 | .\" The Regents of the University of California. All rights reserved. | ||
| 5 | .\" | ||
| 6 | .\" Redistribution and use in source and binary forms, with or without | ||
| 7 | .\" modification, are permitted provided that the following conditions | ||
| 8 | .\" are met: | ||
| 9 | .\" 1. Redistributions of source code must retain the above copyright | ||
| 10 | .\" notice, this list of conditions and the following disclaimer. | ||
| 11 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
| 12 | .\" notice, this list of conditions and the following disclaimer in the | ||
| 13 | .\" documentation and/or other materials provided with the distribution. | ||
| 14 | .\" 3. Neither the name of the University nor the names of its contributors | ||
| 15 | .\" may be used to endorse or promote products derived from this software | ||
| 16 | .\" without specific prior written permission. | ||
| 17 | .\" | ||
| 18 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
| 19 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 20 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 21 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
| 22 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 23 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 24 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 25 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 26 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 27 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 28 | .\" SUCH DAMAGE. | ||
| 29 | .\" | ||
| 30 | .Dd $Mdocdate: May 31 2007 $ | ||
| 31 | .Dt RESOLVER 3 | ||
| 32 | .Os | ||
| 33 | .Sh NAME | ||
| 34 | .Nm res_query , | ||
| 35 | .Nm res_search , | ||
| 36 | .Nm res_mkquery , | ||
| 37 | .Nm res_send , | ||
| 38 | .Nm res_init , | ||
| 39 | .Nm dn_comp , | ||
| 40 | .Nm dn_expand | ||
| 41 | .Nd resolver routines | ||
| 42 | .Sh SYNOPSIS | ||
| 43 | .Fd #include <sys/types.h> | ||
| 44 | .Fd #include <netinet/in.h> | ||
| 45 | .Fd #include <arpa/nameser.h> | ||
| 46 | .Fd #include <resolv.h> | ||
| 47 | .Ft int | ||
| 48 | .Fo res_query | ||
| 49 | .Fa "const char *dname" | ||
| 50 | .Fa "int class" | ||
| 51 | .Fa "int type" | ||
| 52 | .Fa "unsigned char *answer" | ||
| 53 | .Fa "int anslen" | ||
| 54 | .Fc | ||
| 55 | .Ft int | ||
| 56 | .Fo res_search | ||
| 57 | .Fa "const char *dname" | ||
| 58 | .Fa "int class" | ||
| 59 | .Fa "int type" | ||
| 60 | .Fa "unsigned char *answer" | ||
| 61 | .Fa "int anslen" | ||
| 62 | .Fc | ||
| 63 | .Ft int | ||
| 64 | .Fo res_mkquery | ||
| 65 | .Fa "int op" | ||
| 66 | .Fa "const char *dname" | ||
| 67 | .Fa "int class" | ||
| 68 | .Fa "int type" | ||
| 69 | .Fa "const unsigned char *data" | ||
| 70 | .Fa "int datalen" | ||
| 71 | .Fa "const unsigned char *newrr" | ||
| 72 | .Fa "unsigned char *buf" | ||
| 73 | .Fa "int buflen" | ||
| 74 | .Fc | ||
| 75 | .Ft int | ||
| 76 | .Fo res_send | ||
| 77 | .Fa "const unsigned char *msg" | ||
| 78 | .Fa "int msglen" | ||
| 79 | .Fa "unsigned char *answer" | ||
| 80 | .Fa "int anslen" | ||
| 81 | .Fc | ||
| 82 | .Ft int | ||
| 83 | .Fn res_init "void" | ||
| 84 | .Ft int | ||
| 85 | .Fo dn_comp | ||
| 86 | .Fa "const char *exp_dn" | ||
| 87 | .Fa "unsigned char *comp_dn" | ||
| 88 | .Fa "int length" | ||
| 89 | .Fa "unsigned char **dnptrs" | ||
| 90 | .Fa "unsigned char **lastdnptr" | ||
| 91 | .Fc | ||
| 92 | .Ft int | ||
| 93 | .Fo dn_expand | ||
| 94 | .Fa "const unsigned char *msg" | ||
| 95 | .Fa "const unsigned char *eomorig" | ||
| 96 | .Fa "const unsigned char *comp_dn" | ||
| 97 | .Fa "char *exp_dn" | ||
| 98 | .Fa "int length" | ||
| 99 | .Fc | ||
| 100 | .Sh DESCRIPTION | ||
| 101 | These routines are used for making, sending, and interpreting | ||
| 102 | query and reply messages with Internet domain name servers. | ||
| 103 | .Pp | ||
| 104 | Global configuration and state information that is used by the | ||
| 105 | resolver routines is kept in the structure | ||
| 106 | .Li _res . | ||
| 107 | Most of the values have reasonable defaults and can be ignored. | ||
| 108 | Options stored in | ||
| 109 | .Li _res.options | ||
| 110 | are defined in | ||
| 111 | .Aq Pa resolv.h | ||
| 112 | and are as follows. | ||
| 113 | Options are stored as a simple bit mask containing the bitwise | ||
| 114 | .Tn OR | ||
| 115 | of the options enabled. | ||
| 116 | .Bl -tag -width RES_USE_INET6 | ||
| 117 | .It Dv RES_INIT | ||
| 118 | True if the initial name server address and default domain name are | ||
| 119 | initialized (i.e., | ||
| 120 | .Fn res_init | ||
| 121 | has been called). | ||
| 122 | .It Dv RES_DEBUG | ||
| 123 | Print debugging messages. | ||
| 124 | .It Dv RES_AAONLY | ||
| 125 | Accept authoritative answers only. | ||
| 126 | With this option, | ||
| 127 | .Fn res_send | ||
| 128 | should continue until it finds an authoritative answer or finds an error. | ||
| 129 | Currently this is not implemented. | ||
| 130 | .It Dv RES_USEVC | ||
| 131 | Use | ||
| 132 | .Tn TCP | ||
| 133 | connections for queries instead of | ||
| 134 | .Tn UDP | ||
| 135 | datagrams. | ||
| 136 | .It Dv RES_STAYOPEN | ||
| 137 | Used with | ||
| 138 | .Dv RES_USEVC | ||
| 139 | to keep the | ||
| 140 | .Tn TCP | ||
| 141 | connection open between queries. | ||
| 142 | This is useful only in programs that regularly do many queries. | ||
| 143 | .Tn UDP | ||
| 144 | should be the normal mode used. | ||
| 145 | .It Dv RES_IGNTC | ||
| 146 | Unused currently (ignore truncation errors, i.e., don't retry with | ||
| 147 | .Tn TCP ) . | ||
| 148 | .It Dv RES_RECURSE | ||
| 149 | Set the recursion-desired bit in queries. | ||
| 150 | This is the default. | ||
| 151 | .Pf ( Fn res_send | ||
| 152 | does not do iterative queries and expects the name server | ||
| 153 | to handle recursion.) | ||
| 154 | .It Dv RES_DEFNAMES | ||
| 155 | If set, | ||
| 156 | .Fn res_search | ||
| 157 | will append the default domain name to single-component names | ||
| 158 | (those that do not contain a dot). | ||
| 159 | This option is enabled by default. | ||
| 160 | .It Dv RES_DNSRCH | ||
| 161 | If this option is set, | ||
| 162 | .Fn res_search | ||
| 163 | will search for host names in the current domain and in parent domains; see | ||
| 164 | .Xr hostname 7 . | ||
| 165 | This is used by the standard host lookup routine | ||
| 166 | .Xr gethostbyname 3 . | ||
| 167 | This option is enabled by default. | ||
| 168 | .It Dv RES_USE_INET6 | ||
| 169 | Enables support for IPv6-only applications. | ||
| 170 | This causes IPv4 addresses to be returned as an IPv4 mapped address. | ||
| 171 | For example, 10.1.1.1 will be returned as ::ffff:10.1.1.1. | ||
| 172 | The option is not meaningful on | ||
| 173 | .Ox . | ||
| 174 | .It Dv RES_USE_EDNS0 | ||
| 175 | Enables support for OPT pseudo-RR for EDNS0 extension. | ||
| 176 | With this option, resolver code will attach OPT pseudo-RR into DNS queries, | ||
| 177 | to inform of our receive buffer size. | ||
| 178 | The option will allow DNS servers to take advantage of non-default receive | ||
| 179 | buffer size, and to send larger replies. | ||
| 180 | DNS query packets with EDNS0 extension is not compatible with | ||
| 181 | non-EDNS0 DNS servers. | ||
| 182 | .El | ||
| 183 | .Pp | ||
| 184 | The | ||
| 185 | .Fn res_init | ||
| 186 | routine reads the configuration file (if any; see | ||
| 187 | .Xr resolv.conf 5 ) | ||
| 188 | to get the default domain name, search list, and the Internet address | ||
| 189 | of the local name server(s). | ||
| 190 | If no server is configured, the host running | ||
| 191 | the resolver is tried. | ||
| 192 | The current domain name is defined by the hostname | ||
| 193 | if not specified in the configuration file; | ||
| 194 | it can be overridden by the environment variable | ||
| 195 | .Ev LOCALDOMAIN . | ||
| 196 | This environment variable may contain several blank-separated | ||
| 197 | tokens if you wish to override the | ||
| 198 | .Fa search list | ||
| 199 | on a per-process basis. | ||
| 200 | This is similar to the | ||
| 201 | .Fa search | ||
| 202 | command in the configuration file. | ||
| 203 | Another environment variable | ||
| 204 | .Ev RES_OPTIONS | ||
| 205 | can be set to override certain internal resolver options which | ||
| 206 | are otherwise set by changing fields in the | ||
| 207 | .Fa _res | ||
| 208 | structure or are inherited from the configuration file's | ||
| 209 | .Fa options | ||
| 210 | command. | ||
| 211 | The syntax of the | ||
| 212 | .Ev RES_OPTIONS | ||
| 213 | environment variable is explained in | ||
| 214 | .Xr resolv.conf 5 . | ||
| 215 | Initialization normally occurs on the first call | ||
| 216 | to one of the following routines. | ||
| 217 | .Pp | ||
| 218 | The | ||
| 219 | .Fn res_query | ||
| 220 | function provides an interface to the server query mechanism. | ||
| 221 | It constructs a query, sends it to the local server, | ||
| 222 | awaits a response, and makes preliminary checks on the reply. | ||
| 223 | The query requests information of the specified | ||
| 224 | .Fa type | ||
| 225 | and | ||
| 226 | .Fa class | ||
| 227 | for the specified fully qualified domain name | ||
| 228 | .Fa dname . | ||
| 229 | The reply message is left in the | ||
| 230 | .Fa answer | ||
| 231 | buffer with length | ||
| 232 | .Fa anslen | ||
| 233 | supplied by the caller. | ||
| 234 | Values for the | ||
| 235 | .Fa class | ||
| 236 | and | ||
| 237 | .Fa type | ||
| 238 | fields | ||
| 239 | are defined in | ||
| 240 | .Aq Pa arpa/nameser.h . | ||
| 241 | .Pp | ||
| 242 | The | ||
| 243 | .Fn res_search | ||
| 244 | routine makes a query and awaits a response like | ||
| 245 | .Fn res_query , | ||
| 246 | but in addition, it implements the default and search rules controlled by the | ||
| 247 | .Dv RES_DEFNAMES | ||
| 248 | and | ||
| 249 | .Dv RES_DNSRCH | ||
| 250 | options. | ||
| 251 | It returns the first successful reply. | ||
| 252 | .Pp | ||
| 253 | The remaining routines are lower-level routines used by | ||
| 254 | .Fn res_query . | ||
| 255 | The | ||
| 256 | .Fn res_mkquery | ||
| 257 | function constructs a standard query message and places it in | ||
| 258 | .Fa buf . | ||
| 259 | It returns the size of the query, or \-1 if the query is larger than | ||
| 260 | .Fa buflen . | ||
| 261 | The query type | ||
| 262 | .Fa op | ||
| 263 | is usually | ||
| 264 | .Dv QUERY , | ||
| 265 | but can be any of the query types defined in | ||
| 266 | .Aq Pa arpa/nameser.h . | ||
| 267 | The domain name for the query is given by | ||
| 268 | .Fa dname . | ||
| 269 | .Fa newrr | ||
| 270 | is currently unused but is intended for making update messages. | ||
| 271 | .Pp | ||
| 272 | The | ||
| 273 | .Fn res_send | ||
| 274 | routine sends a pre-formatted query and returns an answer. | ||
| 275 | It will call | ||
| 276 | .Fn res_init | ||
| 277 | if | ||
| 278 | .Dv RES_INIT | ||
| 279 | is not set, send the query to the local name server, and | ||
| 280 | handle timeouts and retries. | ||
| 281 | The length of the reply message is returned, or \-1 if there were errors. | ||
| 282 | .Pp | ||
| 283 | The | ||
| 284 | .Fn dn_comp | ||
| 285 | function compresses the domain name | ||
| 286 | .Fa exp_dn | ||
| 287 | and stores it in | ||
| 288 | .Fa comp_dn . | ||
| 289 | The size of the compressed name is returned or \-1 if there were errors. | ||
| 290 | The size of the array pointed to by | ||
| 291 | .Fa comp_dn | ||
| 292 | is given by | ||
| 293 | .Fa length . | ||
| 294 | The compression uses an array of pointers | ||
| 295 | .Fa dnptrs | ||
| 296 | to previously compressed names in the current message. | ||
| 297 | The first pointer points | ||
| 298 | to the beginning of the message and the list ends with | ||
| 299 | .Dv NULL . | ||
| 300 | The limit to the array is specified by | ||
| 301 | .Fa lastdnptr . | ||
| 302 | A side effect of | ||
| 303 | .Fn dn_comp | ||
| 304 | is to update the list of pointers for labels inserted into the message | ||
| 305 | as the name is compressed. | ||
| 306 | If | ||
| 307 | .Fa dnptrs | ||
| 308 | is | ||
| 309 | .Dv NULL , | ||
| 310 | names are not compressed. | ||
| 311 | If | ||
| 312 | .Fa lastdnptr | ||
| 313 | is | ||
| 314 | .Dv NULL , | ||
| 315 | the list of labels is not updated. | ||
| 316 | .Pp | ||
| 317 | The | ||
| 318 | .Fn dn_expand | ||
| 319 | entry expands the compressed domain name | ||
| 320 | .Fa comp_dn | ||
| 321 | to a full domain name. | ||
| 322 | The compressed name is contained in a query or reply message; | ||
| 323 | .Fa msg | ||
| 324 | is a pointer to the beginning of the message. | ||
| 325 | The uncompressed name is placed in the buffer indicated by | ||
| 326 | .Fa exp_dn | ||
| 327 | which is of size | ||
| 328 | .Fa length . | ||
| 329 | The size of compressed name is returned or \-1 if there was an error. | ||
| 330 | .Sh FILES | ||
| 331 | .Bl -tag -width "/etc/resolv.confXX" | ||
| 332 | .It Pa /etc/resolv.conf | ||
| 333 | The configuration file. | ||
| 334 | .El | ||
| 335 | .Sh SEE ALSO | ||
| 336 | .Xr gethostbyname 3 , | ||
| 337 | .Xr resolv.conf 5 , | ||
| 338 | .Xr hostname 7 , | ||
| 339 | .Xr named 8 | ||
| 340 | .Pp | ||
| 341 | .%T RFC 974 , | ||
| 342 | .%T RFC 1032 , | ||
| 343 | .%T RFC 1033 , | ||
| 344 | .%T RFC 1034 , | ||
| 345 | .%T RFC 1035 , | ||
| 346 | .%T RFC 1535 | ||
| 347 | .Rs | ||
| 348 | .%T "Name Server Operations Guide for BIND" | ||
| 349 | .Re | ||
| 350 | .Sh HISTORY | ||
| 351 | The | ||
| 352 | .Nm | ||
| 353 | function appeared in | ||
| 354 | .Bx 4.3 . | ||
