[19979] | 1 | .\" $Id: ares_init.3,v 1.2 2003-11-05 19:36:22 ghudson Exp $ |
---|
[11855] | 2 | .\" |
---|
| 3 | .\" Copyright 1998 by the Massachusetts Institute of Technology. |
---|
| 4 | .\" |
---|
| 5 | .\" Permission to use, copy, modify, and distribute this |
---|
| 6 | .\" software and its documentation for any purpose and without |
---|
| 7 | .\" fee is hereby granted, provided that the above copyright |
---|
| 8 | .\" notice appear in all copies and that both that copyright |
---|
| 9 | .\" notice and this permission notice appear in supporting |
---|
| 10 | .\" documentation, and that the name of M.I.T. not be used in |
---|
| 11 | .\" advertising or publicity pertaining to distribution of the |
---|
| 12 | .\" software without specific, written prior permission. |
---|
| 13 | .\" M.I.T. makes no representations about the suitability of |
---|
| 14 | .\" this software for any purpose. It is provided "as is" |
---|
| 15 | .\" without express or implied warranty. |
---|
| 16 | .\" |
---|
| 17 | .TH ARES_INIT 3 "21 July 1998" |
---|
| 18 | .SH NAME |
---|
| 19 | ares_init, ares_init_options \- Initialize a resolver channel |
---|
| 20 | .SH SYNOPSIS |
---|
| 21 | .nf |
---|
| 22 | .B #include <ares.h> |
---|
| 23 | .PP |
---|
| 24 | .B int ares_init(ares_channel *\fIchannel\fP) |
---|
| 25 | .B int ares_init_options(ares_channel *\fIchannel\fP, |
---|
| 26 | .B struct ares_options *\fIoptions\fP, int \fIoptmask\fP) |
---|
| 27 | .PP |
---|
| 28 | .B cc file.c -lares |
---|
| 29 | .fi |
---|
| 30 | .SH DESCRIPTION |
---|
| 31 | The |
---|
| 32 | .B ares_init |
---|
| 33 | function initializes a communications channel for name service |
---|
| 34 | lookups. If it returns successfully, |
---|
| 35 | .B ares_init |
---|
| 36 | will set the variable pointed to by |
---|
| 37 | .I channel |
---|
| 38 | to a handle used to identify the name service channel. The caller |
---|
| 39 | should invoke |
---|
| 40 | .BR ares_destroy (3) |
---|
| 41 | on the handle when the channel is no longer needed. |
---|
| 42 | .PP |
---|
| 43 | The |
---|
| 44 | .B ares_init_options |
---|
| 45 | function also initializes a name service channel, with additional |
---|
| 46 | options useful for applications requiring more control over name |
---|
| 47 | service configuration. The |
---|
| 48 | .I optmask |
---|
| 49 | parameter specifies which fields in the structure pointed to by |
---|
| 50 | .I options |
---|
| 51 | are set, as follows: |
---|
| 52 | .PP |
---|
[19979] | 53 | .TP 19 |
---|
[11855] | 54 | .B ARES_OPT_FLAGS |
---|
| 55 | .B int \fIflags\fP; |
---|
| 56 | .br |
---|
| 57 | Flags controlling the behavior of the resolver. See below for a |
---|
| 58 | description of possible flag values. |
---|
[19979] | 59 | .TP 19 |
---|
[11855] | 60 | .B ARES_OPT_TIMEOUT |
---|
| 61 | .B int \fItimeout\fP; |
---|
| 62 | .br |
---|
| 63 | The number of seconds each name server is given to respond to a query |
---|
| 64 | on the first try. (After the first try, the timeout algorithm becomes |
---|
| 65 | more complicated, but scales linearly with the value of |
---|
| 66 | \fItimeout\fP.) The default is five seconds. |
---|
[19979] | 67 | .TP 19 |
---|
[11855] | 68 | .B ARES_OPT_TRIES |
---|
| 69 | .B int \fItries\fP; |
---|
| 70 | .br |
---|
| 71 | The number of tries the resolver will try contacting each name server |
---|
| 72 | before giving up. The default is four tries. |
---|
[19979] | 73 | .TP 19 |
---|
[11855] | 74 | .B ARES_OPT_NDOTS |
---|
| 75 | .B int \fIndots\fP; |
---|
| 76 | .br |
---|
| 77 | The number of dots which must be present in a domain name for it to be |
---|
| 78 | queried for "as is" prior to querying for it with the default domain |
---|
| 79 | extensions appended. The default value is 1 unless set otherwise by |
---|
| 80 | resolv.conf or the RES_OPTIONS environment variable. |
---|
[19979] | 81 | .TP 19 |
---|
| 82 | .B ARES_OPT_UDP_PORT |
---|
| 83 | .B unsigned short \fIudp_port\fP; |
---|
[11855] | 84 | .br |
---|
[19979] | 85 | The port to use for queries UDP queries, in network byte order. The |
---|
| 86 | default value is 53 (in network byte order), the standard name service |
---|
| 87 | port. |
---|
| 88 | .TP 19 |
---|
| 89 | .B ARES_TCP_PORT |
---|
| 90 | .B unsigned short \fItcp_port\fP; |
---|
| 91 | .br |
---|
| 92 | The port to use for TCP queries, in network byte order. The default |
---|
| 93 | value is 53 (in network byte order), the standard name service port. |
---|
| 94 | .TP 19 |
---|
[11855] | 95 | .B ARES_OPT_SERVERS |
---|
| 96 | .B struct in_addr *\fIservers\fP; |
---|
| 97 | .br |
---|
| 98 | .B int \fInservers\fP; |
---|
| 99 | .br |
---|
| 100 | The list of servers to contact, instead of the servers specified in |
---|
| 101 | resolv.conf or the local named. |
---|
[19979] | 102 | .TP 19 |
---|
[11855] | 103 | .B ARES_OPT_DOMAINS |
---|
| 104 | .B char **\fIdomains\fP; |
---|
| 105 | .br |
---|
| 106 | .B int \fIndomains\fP; |
---|
| 107 | .br |
---|
| 108 | The domains to search, instead of the domains specified in resolv.conf |
---|
| 109 | or the domain derived from the kernel hostname variable. |
---|
[19979] | 110 | .TP 19 |
---|
[11855] | 111 | .B ARES_OPT_LOOKUPS |
---|
| 112 | .B char *\fIlookups\fP; |
---|
| 113 | .br |
---|
| 114 | The lookups to perform for host queries. |
---|
| 115 | .I lookups |
---|
| 116 | should be set to a string of the characters "b" or "f", where "b" |
---|
| 117 | indicates a DNS lookup and "f" indicates a lookup in the hosts file. |
---|
| 118 | .PP |
---|
| 119 | The |
---|
| 120 | .I flags |
---|
| 121 | field should be the bitwise or of some subset of the following values: |
---|
| 122 | .TP 23 |
---|
| 123 | .B ARES_FLAG_USEVC |
---|
| 124 | Always use TCP queries (the "virtual circuit") instead of UDP |
---|
| 125 | queries. Normally, TCP is only used if a UDP query yields a truncated |
---|
| 126 | result. |
---|
| 127 | .TP 23 |
---|
| 128 | .B ARES_FLAG_PRIMARY |
---|
| 129 | Only query the first server in the list of servers to query. |
---|
| 130 | .TP 23 |
---|
| 131 | .B ARES_FLAG_IGNTC |
---|
| 132 | If a truncated response to a UDP query is received, do not fall back |
---|
| 133 | to TCP; simply continue on with the truncated response. |
---|
| 134 | .TP 23 |
---|
| 135 | .B ARES_FLAG_NORECURSE |
---|
| 136 | Do not set the "recursion desired" bit on outgoing queries, so that |
---|
| 137 | the name server being contacted will not try to fetch the answer from |
---|
| 138 | other servers if it doesn't know the answer locally. |
---|
| 139 | .TP 23 |
---|
| 140 | .B ARES_FLAG_STAYOPEN |
---|
| 141 | Do not close communciations sockets when the number of active queries |
---|
| 142 | drops to zero. |
---|
| 143 | .TP 23 |
---|
| 144 | .B ARES_FLAG_NOSEARCH |
---|
| 145 | Do not use the default search domains; only query hostnames as-is or |
---|
| 146 | as aliases. |
---|
| 147 | .TP 23 |
---|
| 148 | .B ARES_FLAG_NOALIASES |
---|
| 149 | Do not honor the HOSTALIASES environment variable, which normally |
---|
| 150 | specifies a file of hostname translations. |
---|
| 151 | .TP 23 |
---|
| 152 | .B ARES_FLAG_NOCHECKRESP |
---|
| 153 | Do not discard responses with the SERVFAIL, NOTIMP, or REFUSED |
---|
| 154 | response code or responses whose questions don't match the questions |
---|
| 155 | in the request. Primarily useful for writing clients which might be |
---|
| 156 | used to test or debug name servers. |
---|
| 157 | .SH RETURN VALUES |
---|
| 158 | .I ares_init |
---|
| 159 | or |
---|
| 160 | .I ares_init_options |
---|
| 161 | can return any of the following values: |
---|
| 162 | .TP 14 |
---|
| 163 | .B ARES_SUCCESS |
---|
| 164 | Initialization succeeded. |
---|
| 165 | .TP 14 |
---|
| 166 | .B ARES_EFILE |
---|
| 167 | A configuration file could not be read. |
---|
| 168 | .TP 14 |
---|
| 169 | .B ARES_ENOMEM |
---|
| 170 | The process's available memory was exhausted. |
---|
| 171 | .SH SEE ALSO |
---|
| 172 | .BR ares_destroy (3) |
---|
| 173 | .SH AUTHOR |
---|
| 174 | Greg Hudson, MIT Information Systems |
---|
| 175 | .br |
---|
| 176 | Copyright 1998 by the Massachusetts Institute of Technology. |
---|