diff options
Diffstat (limited to 'src/lib/libc/net/resolver.3')
| -rw-r--r-- | src/lib/libc/net/resolver.3 | 172 |
1 files changed, 91 insertions, 81 deletions
diff --git a/src/lib/libc/net/resolver.3 b/src/lib/libc/net/resolver.3 index 99abe17f03..e820ea25ed 100644 --- a/src/lib/libc/net/resolver.3 +++ b/src/lib/libc/net/resolver.3 | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | .\" $NetBSD: resolver.3,v 1.5 1995/02/25 06:21:02 cgd Exp $ | 1 | .\" $OpenBSD: resolver.3,v 1.21 2007/05/31 19:19:30 jmc Exp $ |
| 2 | .\" | 2 | .\" |
| 3 | .\" Copyright (c) 1985, 1991, 1993 | 3 | .\" Copyright (c) 1985, 1991, 1993 |
| 4 | .\" The Regents of the University of California. All rights reserved. | 4 | .\" The Regents of the University of California. All rights reserved. |
| @@ -11,11 +11,7 @@ | |||
| 11 | .\" 2. Redistributions in binary form must reproduce the above copyright | 11 | .\" 2. Redistributions in binary form must reproduce the above copyright |
| 12 | .\" notice, this list of conditions and the following disclaimer in the | 12 | .\" notice, this list of conditions and the following disclaimer in the |
| 13 | .\" documentation and/or other materials provided with the distribution. | 13 | .\" documentation and/or other materials provided with the distribution. |
| 14 | .\" 3. All advertising materials mentioning features or use of this software | 14 | .\" 3. Neither the name of the University nor the names of its contributors |
| 15 | .\" must display the following acknowledgement: | ||
| 16 | .\" This product includes software developed by the University of | ||
| 17 | .\" California, Berkeley and its contributors. | ||
| 18 | .\" 4. Neither the name of the University nor the names of its contributors | ||
| 19 | .\" may be used to endorse or promote products derived from this software | 15 | .\" may be used to endorse or promote products derived from this software |
| 20 | .\" without specific prior written permission. | 16 | .\" without specific prior written permission. |
| 21 | .\" | 17 | .\" |
| @@ -31,11 +27,9 @@ | |||
| 31 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 27 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 32 | .\" SUCH DAMAGE. | 28 | .\" SUCH DAMAGE. |
| 33 | .\" | 29 | .\" |
| 34 | .\" @(#)resolver.3 8.1 (Berkeley) 6/4/93 | 30 | .Dd $Mdocdate: May 31 2007 $ |
| 35 | .\" | ||
| 36 | .Dd June 4, 1993 | ||
| 37 | .Dt RESOLVER 3 | 31 | .Dt RESOLVER 3 |
| 38 | .Os BSD 4.3 | 32 | .Os |
| 39 | .Sh NAME | 33 | .Sh NAME |
| 40 | .Nm res_query , | 34 | .Nm res_query , |
| 41 | .Nm res_search , | 35 | .Nm res_search , |
| @@ -50,69 +44,76 @@ | |||
| 50 | .Fd #include <netinet/in.h> | 44 | .Fd #include <netinet/in.h> |
| 51 | .Fd #include <arpa/nameser.h> | 45 | .Fd #include <arpa/nameser.h> |
| 52 | .Fd #include <resolv.h> | 46 | .Fd #include <resolv.h> |
| 47 | .Ft int | ||
| 53 | .Fo res_query | 48 | .Fo res_query |
| 54 | .Fa "char *dname" | 49 | .Fa "const char *dname" |
| 55 | .Fa "int class" | 50 | .Fa "int class" |
| 56 | .Fa "int type" | 51 | .Fa "int type" |
| 57 | .Fa "u_char *answer" | 52 | .Fa "unsigned char *answer" |
| 58 | .Fa "int anslen" | 53 | .Fa "int anslen" |
| 59 | .Fc | 54 | .Fc |
| 55 | .Ft int | ||
| 60 | .Fo res_search | 56 | .Fo res_search |
| 61 | .Fa "char *dname" | 57 | .Fa "const char *dname" |
| 62 | .Fa "int class" | 58 | .Fa "int class" |
| 63 | .Fa "int type" | 59 | .Fa "int type" |
| 64 | .Fa "u_char *answer" | 60 | .Fa "unsigned char *answer" |
| 65 | .Fa "int anslen" | 61 | .Fa "int anslen" |
| 66 | .Fc | 62 | .Fc |
| 63 | .Ft int | ||
| 67 | .Fo res_mkquery | 64 | .Fo res_mkquery |
| 68 | .Fa "int op" | 65 | .Fa "int op" |
| 69 | .Fa "char *dname" | 66 | .Fa "const char *dname" |
| 70 | .Fa "int class" | 67 | .Fa "int class" |
| 71 | .Fa "int type" | 68 | .Fa "int type" |
| 72 | .Fa "char *data" | 69 | .Fa "const unsigned char *data" |
| 73 | .Fa "int datalen" | 70 | .Fa "int datalen" |
| 74 | .Fa "struct rrec *newrr" | 71 | .Fa "const unsigned char *newrr" |
| 75 | .Fa "char *buf" | 72 | .Fa "unsigned char *buf" |
| 76 | .Fa "int buflen" | 73 | .Fa "int buflen" |
| 77 | .Fc | 74 | .Fc |
| 75 | .Ft int | ||
| 78 | .Fo res_send | 76 | .Fo res_send |
| 79 | .Fa "char *msg" | 77 | .Fa "const unsigned char *msg" |
| 80 | .Fa "int msglen" | 78 | .Fa "int msglen" |
| 81 | .Fa "char *answer" | 79 | .Fa "unsigned char *answer" |
| 82 | .Fa "int anslen" | 80 | .Fa "int anslen" |
| 83 | .Fc | 81 | .Fc |
| 84 | .Fn res_init | 82 | .Ft int |
| 83 | .Fn res_init "void" | ||
| 84 | .Ft int | ||
| 85 | .Fo dn_comp | 85 | .Fo dn_comp |
| 86 | .Fa "char *exp_dn" | 86 | .Fa "const char *exp_dn" |
| 87 | .Fa "char *comp_dn" | 87 | .Fa "unsigned char *comp_dn" |
| 88 | .Fa "int length" | 88 | .Fa "int length" |
| 89 | .Fa "char **dnptrs" | 89 | .Fa "unsigned char **dnptrs" |
| 90 | .Fa "char **lastdnptr" | 90 | .Fa "unsigned char **lastdnptr" |
| 91 | .Fc | 91 | .Fc |
| 92 | .Ft int | ||
| 92 | .Fo dn_expand | 93 | .Fo dn_expand |
| 93 | .Fa "u_char *msg" | 94 | .Fa "const unsigned char *msg" |
| 94 | .Fa "u_char *eomorig" | 95 | .Fa "const unsigned char *eomorig" |
| 95 | .Fa "u_char *comp_dn" | 96 | .Fa "const unsigned char *comp_dn" |
| 96 | .Fa "u_char *exp_dn" | 97 | .Fa "char *exp_dn" |
| 97 | .Fa "int length" | 98 | .Fa "int length" |
| 98 | .Fc | 99 | .Fc |
| 99 | .Sh DESCRIPTION | 100 | .Sh DESCRIPTION |
| 100 | These routines are used for making, sending and interpreting | 101 | These routines are used for making, sending, and interpreting |
| 101 | query and reply messages with Internet domain name servers. | 102 | query and reply messages with Internet domain name servers. |
| 102 | .Pp | 103 | .Pp |
| 103 | Global configuration and state information that is used by the | 104 | Global configuration and state information that is used by the |
| 104 | resolver routines is kept in the structure | 105 | resolver routines is kept in the structure |
| 105 | .Em _res . | 106 | .Li _res . |
| 106 | Most of the values have reasonable defaults and can be ignored. | 107 | Most of the values have reasonable defaults and can be ignored. |
| 107 | Options | 108 | Options stored in |
| 108 | stored in | 109 | .Li _res.options |
| 109 | .Em _res.options | ||
| 110 | are defined in | 110 | are defined in |
| 111 | .Pa resolv.h | 111 | .Aq Pa resolv.h |
| 112 | and are as follows. | 112 | and are as follows. |
| 113 | Options are stored as a simple bit mask containing the bitwise ``or'' | 113 | Options are stored as a simple bit mask containing the bitwise |
| 114 | .Tn OR | ||
| 114 | of the options enabled. | 115 | of the options enabled. |
| 115 | .Bl -tag -width RES_DEFNAMES | 116 | .Bl -tag -width RES_USE_INET6 |
| 116 | .It Dv RES_INIT | 117 | .It Dv RES_INIT |
| 117 | True if the initial name server address and default domain name are | 118 | True if the initial name server address and default domain name are |
| 118 | initialized (i.e., | 119 | initialized (i.e., |
| @@ -137,8 +138,7 @@ Used with | |||
| 137 | .Dv RES_USEVC | 138 | .Dv RES_USEVC |
| 138 | to keep the | 139 | to keep the |
| 139 | .Tn TCP | 140 | .Tn TCP |
| 140 | connection open between | 141 | connection open between queries. |
| 141 | queries. | ||
| 142 | This is useful only in programs that regularly do many queries. | 142 | This is useful only in programs that regularly do many queries. |
| 143 | .Tn UDP | 143 | .Tn UDP |
| 144 | should be the normal mode used. | 144 | should be the normal mode used. |
| @@ -165,16 +165,28 @@ will search for host names in the current domain and in parent domains; see | |||
| 165 | This is used by the standard host lookup routine | 165 | This is used by the standard host lookup routine |
| 166 | .Xr gethostbyname 3 . | 166 | .Xr gethostbyname 3 . |
| 167 | This option is enabled by default. | 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. | ||
| 168 | .El | 182 | .El |
| 169 | .Pp | 183 | .Pp |
| 170 | The | 184 | The |
| 171 | .Fn res_init | 185 | .Fn res_init |
| 172 | routine | 186 | routine reads the configuration file (if any; see |
| 173 | reads the configuration file (if any; see | ||
| 174 | .Xr resolv.conf 5 ) | 187 | .Xr resolv.conf 5 ) |
| 175 | to get the default domain name, | 188 | to get the default domain name, search list, and the Internet address |
| 176 | search list and | 189 | of the local name server(s). |
| 177 | the Internet address of the local name server(s). | ||
| 178 | If no server is configured, the host running | 190 | If no server is configured, the host running |
| 179 | the resolver is tried. | 191 | the resolver is tried. |
| 180 | The current domain name is defined by the hostname | 192 | The current domain name is defined by the hostname |
| @@ -212,20 +224,26 @@ The query requests information of the specified | |||
| 212 | .Fa type | 224 | .Fa type |
| 213 | and | 225 | and |
| 214 | .Fa class | 226 | .Fa class |
| 215 | for the specified fully-qualified domain name | 227 | for the specified fully qualified domain name |
| 216 | .Fa dname . | 228 | .Fa dname . |
| 217 | The reply message is left in the | 229 | The reply message is left in the |
| 218 | .Fa answer | 230 | .Fa answer |
| 219 | buffer with length | 231 | buffer with length |
| 220 | .Fa anslen | 232 | .Fa anslen |
| 221 | supplied by the caller. | 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 . | ||
| 222 | .Pp | 241 | .Pp |
| 223 | The | 242 | The |
| 224 | .Fn res_search | 243 | .Fn res_search |
| 225 | routine makes a query and awaits a response like | 244 | routine makes a query and awaits a response like |
| 226 | .Fn res_query , | 245 | .Fn res_query , |
| 227 | but in addition, it implements the default and search rules | 246 | but in addition, it implements the default and search rules controlled by the |
| 228 | controlled by the | ||
| 229 | .Dv RES_DEFNAMES | 247 | .Dv RES_DEFNAMES |
| 230 | and | 248 | and |
| 231 | .Dv RES_DNSRCH | 249 | .Dv RES_DNSRCH |
| @@ -236,11 +254,9 @@ The remaining routines are lower-level routines used by | |||
| 236 | .Fn res_query . | 254 | .Fn res_query . |
| 237 | The | 255 | The |
| 238 | .Fn res_mkquery | 256 | .Fn res_mkquery |
| 239 | function | 257 | function constructs a standard query message and places it in |
| 240 | constructs a standard query message and places it in | ||
| 241 | .Fa buf . | 258 | .Fa buf . |
| 242 | It returns the size of the query, or \-1 if the query is | 259 | It returns the size of the query, or \-1 if the query is larger than |
| 243 | larger than | ||
| 244 | .Fa buflen . | 260 | .Fa buflen . |
| 245 | The query type | 261 | The query type |
| 246 | .Fa op | 262 | .Fa op |
| @@ -250,26 +266,23 @@ but can be any of the query types defined in | |||
| 250 | .Aq Pa arpa/nameser.h . | 266 | .Aq Pa arpa/nameser.h . |
| 251 | The domain name for the query is given by | 267 | The domain name for the query is given by |
| 252 | .Fa dname . | 268 | .Fa dname . |
| 253 | .Fa Newrr | 269 | .Fa newrr |
| 254 | is currently unused but is intended for making update messages. | 270 | is currently unused but is intended for making update messages. |
| 255 | .Pp | 271 | .Pp |
| 256 | The | 272 | The |
| 257 | .Fn res_send | 273 | .Fn res_send |
| 258 | routine | 274 | routine sends a pre-formatted query and returns an answer. |
| 259 | sends a pre-formatted query and returns an answer. | ||
| 260 | It will call | 275 | It will call |
| 261 | .Fn res_init | 276 | .Fn res_init |
| 262 | if | 277 | if |
| 263 | .Dv RES_INIT | 278 | .Dv RES_INIT |
| 264 | is not set, send the query to the local name server, and | 279 | is not set, send the query to the local name server, and |
| 265 | handle timeouts and retries. | 280 | handle timeouts and retries. |
| 266 | The length of the reply message is returned, or | 281 | The length of the reply message is returned, or \-1 if there were errors. |
| 267 | \-1 if there were errors. | ||
| 268 | .Pp | 282 | .Pp |
| 269 | The | 283 | The |
| 270 | .Fn dn_comp | 284 | .Fn dn_comp |
| 271 | function | 285 | function compresses the domain name |
| 272 | compresses the domain name | ||
| 273 | .Fa exp_dn | 286 | .Fa exp_dn |
| 274 | and stores it in | 287 | and stores it in |
| 275 | .Fa comp_dn . | 288 | .Fa comp_dn . |
| @@ -278,24 +291,23 @@ The size of the array pointed to by | |||
| 278 | .Fa comp_dn | 291 | .Fa comp_dn |
| 279 | is given by | 292 | is given by |
| 280 | .Fa length . | 293 | .Fa length . |
| 281 | The compression uses | 294 | The compression uses an array of pointers |
| 282 | an array of pointers | ||
| 283 | .Fa dnptrs | 295 | .Fa dnptrs |
| 284 | to previously-compressed names in the current message. | 296 | to previously compressed names in the current message. |
| 285 | The first pointer points to | 297 | The first pointer points |
| 286 | to the beginning of the message and the list ends with | 298 | to the beginning of the message and the list ends with |
| 287 | .Dv NULL . | 299 | .Dv NULL . |
| 288 | The limit to the array is specified by | 300 | The limit to the array is specified by |
| 289 | .Fa lastdnptr . | 301 | .Fa lastdnptr . |
| 290 | A side effect of | 302 | A side effect of |
| 291 | .Fn dn_comp | 303 | .Fn dn_comp |
| 292 | is to update the list of pointers for | 304 | is to update the list of pointers for labels inserted into the message |
| 293 | labels inserted into the message | ||
| 294 | as the name is compressed. | 305 | as the name is compressed. |
| 295 | If | 306 | If |
| 296 | .Em dnptr | 307 | .Fa dnptrs |
| 297 | is | 308 | is |
| 298 | .Dv NULL, names are not compressed. | 309 | .Dv NULL , |
| 310 | names are not compressed. | ||
| 299 | If | 311 | If |
| 300 | .Fa lastdnptr | 312 | .Fa lastdnptr |
| 301 | is | 313 | is |
| @@ -304,10 +316,9 @@ the list of labels is not updated. | |||
| 304 | .Pp | 316 | .Pp |
| 305 | The | 317 | The |
| 306 | .Fn dn_expand | 318 | .Fn dn_expand |
| 307 | entry | 319 | entry expands the compressed domain name |
| 308 | expands the compressed domain name | ||
| 309 | .Fa comp_dn | 320 | .Fa comp_dn |
| 310 | to a full domain name | 321 | to a full domain name. |
| 311 | The compressed name is contained in a query or reply message; | 322 | The compressed name is contained in a query or reply message; |
| 312 | .Fa msg | 323 | .Fa msg |
| 313 | is a pointer to the beginning of the message. | 324 | is a pointer to the beginning of the message. |
| @@ -317,28 +328,27 @@ which is of size | |||
| 317 | .Fa length . | 328 | .Fa length . |
| 318 | The size of compressed name is returned or \-1 if there was an error. | 329 | The size of compressed name is returned or \-1 if there was an error. |
| 319 | .Sh FILES | 330 | .Sh FILES |
| 320 | .Bl -tag -width Pa | 331 | .Bl -tag -width "/etc/resolv.confXX" |
| 321 | /etc/resolv.conf | 332 | .It Pa /etc/resolv.conf |
| 322 | The configuration file | 333 | The configuration file. |
| 323 | see | ||
| 324 | .Xr resolv.conf 5 . | ||
| 325 | .El | 334 | .El |
| 326 | .Sh SEE ALSO | 335 | .Sh SEE ALSO |
| 327 | .Xr gethostbyname 3 , | 336 | .Xr gethostbyname 3 , |
| 328 | .Xr named 8 , | ||
| 329 | .Xr resolv.conf 5 , | 337 | .Xr resolv.conf 5 , |
| 330 | .Xr hostname 7 , | 338 | .Xr hostname 7 , |
| 339 | .Xr named 8 | ||
| 331 | .Pp | 340 | .Pp |
| 332 | .%T RFC1032 , | 341 | .%T RFC 974 , |
| 333 | .%T RFC1033 , | 342 | .%T RFC 1032 , |
| 334 | .%T RFC1034 , | 343 | .%T RFC 1033 , |
| 335 | .%T RFC1035 , | 344 | .%T RFC 1034 , |
| 336 | .%T RFC974 | 345 | .%T RFC 1035 , |
| 346 | .%T RFC 1535 | ||
| 337 | .Rs | 347 | .Rs |
| 338 | .%T "Name Server Operations Guide for BIND" | 348 | .%T "Name Server Operations Guide for BIND" |
| 339 | .Re | 349 | .Re |
| 340 | .Sh HISTORY | 350 | .Sh HISTORY |
| 341 | The | 351 | The |
| 342 | .Nm | 352 | .Nm |
| 343 | function appeared in | 353 | function appeared in |
| 344 | .Bx 4.3 . | 354 | .Bx 4.3 . |
