diff options
| author | cvs2svn <admin@example.com> | 1998-10-19 21:47:12 +0000 |
|---|---|---|
| committer | cvs2svn <admin@example.com> | 1998-10-19 21:47:12 +0000 |
| commit | 5170039cf1df2194faa85741f0733977525cd5c0 (patch) | |
| tree | c667406046ddb1efca5ed4316b02e43494241660 /src/lib/libc/net/gethostbyname.3 | |
| parent | 536c76cbb863bab152f19842ab88772c01e922c7 (diff) | |
| download | openbsd-OPENBSD_2_4_BASE.tar.gz openbsd-OPENBSD_2_4_BASE.tar.bz2 openbsd-OPENBSD_2_4_BASE.zip | |
This commit was manufactured by cvs2git to create tag 'OPENBSD_2_4_BASE'.OPENBSD_2_4_BASE
Diffstat (limited to 'src/lib/libc/net/gethostbyname.3')
| -rw-r--r-- | src/lib/libc/net/gethostbyname.3 | 266 |
1 files changed, 266 insertions, 0 deletions
diff --git a/src/lib/libc/net/gethostbyname.3 b/src/lib/libc/net/gethostbyname.3 new file mode 100644 index 0000000000..37069c0a59 --- /dev/null +++ b/src/lib/libc/net/gethostbyname.3 | |||
| @@ -0,0 +1,266 @@ | |||
| 1 | .\" $OpenBSD: gethostbyname.3,v 1.9 1998/09/07 16:44:35 aaron Exp $ | ||
| 2 | .\" | ||
| 3 | .\" Copyright (c) 1983, 1987, 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. All advertising materials mentioning features or use of this software | ||
| 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 | ||
| 20 | .\" without specific prior written permission. | ||
| 21 | .\" | ||
| 22 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
| 23 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 24 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 25 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
| 26 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 27 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 28 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 29 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 30 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 31 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 32 | .\" SUCH DAMAGE. | ||
| 33 | .\" | ||
| 34 | .Dd March 13, 1997 | ||
| 35 | .Dt GETHOSTBYNAME 3 | ||
| 36 | .Os | ||
| 37 | .Sh NAME | ||
| 38 | .Nm gethostbyname , | ||
| 39 | .Nm gethostbyname2 , | ||
| 40 | .Nm gethostbyaddr , | ||
| 41 | .Nm gethostent , | ||
| 42 | .Nm sethostent , | ||
| 43 | .Nm endhostent , | ||
| 44 | .Nm hstrerror , | ||
| 45 | .Nm herror | ||
| 46 | .Nd get network host entry | ||
| 47 | .Sh SYNOPSIS | ||
| 48 | .Fd #include <netdb.h> | ||
| 49 | .Fd extern int h_errno; | ||
| 50 | .Ft struct hostent * | ||
| 51 | .Fn gethostbyname "const char *name" | ||
| 52 | .Ft struct hostent * | ||
| 53 | .Fn gethostbyname2 "const char *name" "int af" | ||
| 54 | .Ft struct hostent * | ||
| 55 | .Fn gethostbyaddr "const char *addr" "int len" "int type" | ||
| 56 | .Ft struct hostent * | ||
| 57 | .Fn gethostent void | ||
| 58 | .Ft void | ||
| 59 | .Fn sethostent "int stayopen" | ||
| 60 | .Ft void | ||
| 61 | .Fn endhostent void | ||
| 62 | .Ft void | ||
| 63 | .Fn herror "const char *string" | ||
| 64 | .Ft const char * | ||
| 65 | .Fn hstrerror "int err" | ||
| 66 | .Sh DESCRIPTION | ||
| 67 | The | ||
| 68 | .Fn gethostbyname | ||
| 69 | and | ||
| 70 | .Fn gethostbyaddr | ||
| 71 | functions | ||
| 72 | each return a pointer to an object with the | ||
| 73 | following structure describing an internet host | ||
| 74 | referenced by name or by address, respectively. | ||
| 75 | This structure contains either the information obtained from the name server, | ||
| 76 | .Xr named 8 , | ||
| 77 | broken-out fields from a line in | ||
| 78 | .Pa /etc/hosts , | ||
| 79 | or database entries supplied by the | ||
| 80 | .Xr yp 8 | ||
| 81 | system . | ||
| 82 | If the local name server is not running these routines do a lookup in | ||
| 83 | .Pa /etc/hosts . | ||
| 84 | .Bd -literal | ||
| 85 | struct hostent { | ||
| 86 | char *h_name; /* official name of host */ | ||
| 87 | char **h_aliases; /* alias list */ | ||
| 88 | int h_addrtype; /* host address type */ | ||
| 89 | int h_length; /* length of address */ | ||
| 90 | char **h_addr_list; /* list of addresses from name server */ | ||
| 91 | }; | ||
| 92 | #define h_addr h_addr_list[0] /* address, for backward compatibility */ | ||
| 93 | .Ed | ||
| 94 | .Pp | ||
| 95 | The members of this structure are: | ||
| 96 | .Bl -tag -width h_addr_list | ||
| 97 | .It Fa h_name | ||
| 98 | Official name of the host. | ||
| 99 | .It Fa h_aliases | ||
| 100 | A zero terminated array of alternate names for the host. | ||
| 101 | .It Fa h_addrtype | ||
| 102 | The type of address being returned. | ||
| 103 | .It Fa h_length | ||
| 104 | The length, in bytes, of the address. | ||
| 105 | .It Fa h_addr_list | ||
| 106 | A zero terminated array of network addresses for the host. | ||
| 107 | Host addresses are returned in network byte order. | ||
| 108 | .It Fa h_addr | ||
| 109 | The first address in | ||
| 110 | .Fa h_addr_list ; | ||
| 111 | this is for backward compatibility. | ||
| 112 | .El | ||
| 113 | .Pp | ||
| 114 | When using the nameserver, | ||
| 115 | .Fn gethostbyname | ||
| 116 | will search for the named host in the current domain and its parents | ||
| 117 | unless the name ends in a dot. | ||
| 118 | If the name contains no dot, and if the environment variable | ||
| 119 | .Dq Ev HOSTALIASES | ||
| 120 | contains the name of an alias file, the alias file will first be searched | ||
| 121 | for an alias matching the input name. | ||
| 122 | See | ||
| 123 | .Xr hostname 7 | ||
| 124 | for the domain search procedure and the alias file format. | ||
| 125 | .Pp | ||
| 126 | .Fn Gethostbyname2 | ||
| 127 | is an advanced form of | ||
| 128 | .Fn gethostbyname | ||
| 129 | which allows lookups in address families other than | ||
| 130 | .Dv AF_INET , | ||
| 131 | for example | ||
| 132 | .Dv AF_INET6 . | ||
| 133 | .Pp | ||
| 134 | The | ||
| 135 | .Fn sethostent | ||
| 136 | function | ||
| 137 | may be used to request the use of a connected | ||
| 138 | .Tn TCP | ||
| 139 | socket for queries. | ||
| 140 | If the | ||
| 141 | .Fa stayopen | ||
| 142 | flag is non-zero, | ||
| 143 | this sets the option to send all queries to the name server using | ||
| 144 | .Tn TCP | ||
| 145 | and to retain the connection after each call to | ||
| 146 | .Fn gethostbyname | ||
| 147 | or | ||
| 148 | .Fn gethostbyaddr . | ||
| 149 | Otherwise, queries are performed using | ||
| 150 | .Tn UDP | ||
| 151 | datagrams. | ||
| 152 | .Pp | ||
| 153 | The | ||
| 154 | .Fn endhostent | ||
| 155 | function | ||
| 156 | closes the | ||
| 157 | .Tn TCP | ||
| 158 | connection. | ||
| 159 | .Pp | ||
| 160 | The | ||
| 161 | .Fn herror | ||
| 162 | function prints an error message describing the failure. If its argument | ||
| 163 | .Fa string | ||
| 164 | is | ||
| 165 | .Pf non Dv -NULL , | ||
| 166 | it is prepended to the message string and separated from it by a colon | ||
| 167 | and a space. The error message is printed with a trailing newline. | ||
| 168 | The contents of the error message is the same as that returned by | ||
| 169 | .Fn hstrerror | ||
| 170 | with argument | ||
| 171 | .Fa h_errno . | ||
| 172 | .Sh FILES | ||
| 173 | .Bl -tag -width /etc/hosts -compact | ||
| 174 | .It Pa /etc/hosts | ||
| 175 | .El | ||
| 176 | .Sh DIAGNOSTICS | ||
| 177 | Error return status from | ||
| 178 | .Fn gethostbyname , | ||
| 179 | .Fn gethostbyname2 , | ||
| 180 | and | ||
| 181 | .Fn gethostbyaddr | ||
| 182 | is indicated by return of a null pointer. | ||
| 183 | The external integer | ||
| 184 | .Va h_errno | ||
| 185 | may then be checked to see whether this is a temporary failure | ||
| 186 | or an invalid or unknown host. | ||
| 187 | .Pp | ||
| 188 | The variable | ||
| 189 | .Va h_errno | ||
| 190 | can have the following values: | ||
| 191 | .Bl -tag -width HOST_NOT_FOUND | ||
| 192 | .It Dv HOST_NOT_FOUND | ||
| 193 | No such host is known. | ||
| 194 | .It Dv TRY_AGAIN | ||
| 195 | This is usually a temporary error | ||
| 196 | and means that the local server did not receive | ||
| 197 | a response from an authoritative server. | ||
| 198 | A retry at some later time may succeed. | ||
| 199 | .It Dv NO_RECOVERY | ||
| 200 | Some unexpected server failure was encountered. | ||
| 201 | This is a non-recoverable error. | ||
| 202 | .It Dv NO_DATA | ||
| 203 | The requested name is valid but does not have an IP address; | ||
| 204 | this is not a temporary error. | ||
| 205 | This means that the name is known to the name server but there is no address | ||
| 206 | associated with this name. | ||
| 207 | Another type of request to the name server using this domain name | ||
| 208 | will result in an answer; | ||
| 209 | for example, a mail-forwarder may be registered for this domain. | ||
| 210 | .El | ||
| 211 | .Sh SEE ALSO | ||
| 212 | .Xr resolver 3 , | ||
| 213 | .Xr hosts 5 , | ||
| 214 | .Xr hostname 7 , | ||
| 215 | .Xr named 8 | ||
| 216 | .Sh CAVEAT | ||
| 217 | The | ||
| 218 | .Fn gethostent | ||
| 219 | function | ||
| 220 | reads the next line of | ||
| 221 | .Pa /etc/hosts , | ||
| 222 | opening the file if necessary. | ||
| 223 | .Pp | ||
| 224 | The | ||
| 225 | .Fn sethostent | ||
| 226 | function | ||
| 227 | opens and/or rewinds the file | ||
| 228 | .Pa /etc/hosts . | ||
| 229 | If the | ||
| 230 | .Fa stayopen | ||
| 231 | argument is non-zero, | ||
| 232 | the file will not be closed after each call to | ||
| 233 | .Fn gethostbyname , | ||
| 234 | .Fn gethostbyname2 , | ||
| 235 | or | ||
| 236 | .Fn gethostbyaddr . | ||
| 237 | .Pp | ||
| 238 | The | ||
| 239 | .Fn endhostent | ||
| 240 | function | ||
| 241 | closes the file. | ||
| 242 | .Sh HISTORY | ||
| 243 | The | ||
| 244 | .Fn herror | ||
| 245 | function appeared in | ||
| 246 | .Bx 4.3 . | ||
| 247 | The | ||
| 248 | .Fn endhostent , | ||
| 249 | .Fn gethostbyaddr , | ||
| 250 | .Fn gethostbyname , | ||
| 251 | .Fn gethostent , | ||
| 252 | and | ||
| 253 | .Fn sethostent | ||
| 254 | functions appeared in | ||
| 255 | .Bx 4.2 . | ||
| 256 | .Sh BUGS | ||
| 257 | These functions use static data storage; | ||
| 258 | if the data is needed for future use, it should be | ||
| 259 | copied before any subsequent calls overwrite it. | ||
| 260 | Only the Internet | ||
| 261 | address formats are currently understood. | ||
| 262 | .Pp | ||
| 263 | YP does not support any address families other than | ||
| 264 | .Dv AF_INET | ||
| 265 | and uses | ||
| 266 | the traditional database format. | ||
