diff options
Diffstat (limited to 'src/lib/libc/net/getaddrinfo.3')
| -rw-r--r-- | src/lib/libc/net/getaddrinfo.3 | 577 |
1 files changed, 577 insertions, 0 deletions
diff --git a/src/lib/libc/net/getaddrinfo.3 b/src/lib/libc/net/getaddrinfo.3 new file mode 100644 index 0000000000..a9004e3207 --- /dev/null +++ b/src/lib/libc/net/getaddrinfo.3 | |||
| @@ -0,0 +1,577 @@ | |||
| 1 | .\" $OpenBSD: getaddrinfo.3,v 1.25 2003/08/08 09:26:02 jmc Exp $ | ||
| 2 | .\" $KAME: getaddrinfo.3,v 1.29 2001/02/12 09:24:45 itojun Exp $ | ||
| 3 | .\" | ||
| 4 | .\" Copyright (c) 1983, 1987, 1991, 1993 | ||
| 5 | .\" The Regents of the University of California. All rights reserved. | ||
| 6 | .\" | ||
| 7 | .\" Redistribution and use in source and binary forms, with or without | ||
| 8 | .\" modification, are permitted provided that the following conditions | ||
| 9 | .\" are met: | ||
| 10 | .\" 1. Redistributions of source code must retain the above copyright | ||
| 11 | .\" notice, this list of conditions and the following disclaimer. | ||
| 12 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
| 13 | .\" notice, this list of conditions and the following disclaimer in the | ||
| 14 | .\" documentation and/or other materials provided with the distribution. | ||
| 15 | .\" 3. Neither the name of the University nor the names of its contributors | ||
| 16 | .\" may be used to endorse or promote products derived from this software | ||
| 17 | .\" without specific prior written permission. | ||
| 18 | .\" | ||
| 19 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
| 20 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 21 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 22 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
| 23 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 24 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 25 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 26 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 27 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 28 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 29 | .\" SUCH DAMAGE. | ||
| 30 | .\" | ||
| 31 | .\" From: @(#)gethostbyname.3 8.4 (Berkeley) 5/25/95 | ||
| 32 | .\" | ||
| 33 | .Dd May 25, 1995 | ||
| 34 | .Dt GETADDRINFO 3 | ||
| 35 | .Os | ||
| 36 | .\" | ||
| 37 | .Sh NAME | ||
| 38 | .Nm getaddrinfo , | ||
| 39 | .Nm freeaddrinfo , | ||
| 40 | .Nm gai_strerror | ||
| 41 | .Nd nodename-to-address translation in protocol-independent manner | ||
| 42 | .\" | ||
| 43 | .Sh SYNOPSIS | ||
| 44 | .Fd #include <sys/types.h> | ||
| 45 | .Fd #include <sys/socket.h> | ||
| 46 | .Fd #include <netdb.h> | ||
| 47 | .Ft int | ||
| 48 | .Fn getaddrinfo "const char *nodename" "const char *servname" \ | ||
| 49 | "const struct addrinfo *hints" "struct addrinfo **res" | ||
| 50 | .Ft void | ||
| 51 | .Fn freeaddrinfo "struct addrinfo *ai" | ||
| 52 | .Ft "char *" | ||
| 53 | .Fn gai_strerror "int ecode" | ||
| 54 | .\" | ||
| 55 | .Sh DESCRIPTION | ||
| 56 | The | ||
| 57 | .Fn getaddrinfo | ||
| 58 | function is defined for protocol-independent nodename-to-address translation. | ||
| 59 | It performs the functionality of | ||
| 60 | .Xr gethostbyname 3 | ||
| 61 | and | ||
| 62 | .Xr getservbyname 3 , | ||
| 63 | but in a more sophisticated manner. | ||
| 64 | .Pp | ||
| 65 | The | ||
| 66 | .Li addrinfo | ||
| 67 | structure is defined as a result of including the | ||
| 68 | .Aq Pa netdb.h | ||
| 69 | header: | ||
| 70 | .Bd -literal | ||
| 71 | struct addrinfo { | ||
| 72 | int ai_flags; /* input flags */ | ||
| 73 | int ai_family; /* protocol family for socket */ | ||
| 74 | int ai_socktype; /* socket type */ | ||
| 75 | int ai_protocol; /* protocol for socket */ | ||
| 76 | socklen_t ai_addrlen; /* length of socket-address */ | ||
| 77 | struct sockaddr *ai_addr; /* socket-address for socket */ | ||
| 78 | char *ai_canonname; /* canonical name for service location */ | ||
| 79 | struct addrinfo *ai_next; /* pointer to next in list */ | ||
| 80 | }; | ||
| 81 | .Ed | ||
| 82 | .Pp | ||
| 83 | The | ||
| 84 | .Fa nodename | ||
| 85 | and | ||
| 86 | .Fa servname | ||
| 87 | arguments are pointers to NUL-terminated strings or | ||
| 88 | .Dv NULL . | ||
| 89 | One or both of these two arguments must be a non-null pointer. | ||
| 90 | In the normal client scenario, both the | ||
| 91 | .Fa nodename | ||
| 92 | and | ||
| 93 | .Fa servname | ||
| 94 | are specified. | ||
| 95 | In the normal server scenario, only the | ||
| 96 | .Fa servname | ||
| 97 | is specified. | ||
| 98 | A non-null | ||
| 99 | .Fa nodename | ||
| 100 | string can be either a node name or a numeric host address string | ||
| 101 | (i.e., a dotted-decimal IPv4 address or an IPv6 hex address). | ||
| 102 | A non-null | ||
| 103 | .Fa servname | ||
| 104 | string can be either a service name or a decimal port number. | ||
| 105 | .Pp | ||
| 106 | The caller can optionally pass an | ||
| 107 | .Li addrinfo | ||
| 108 | structure, pointed to by the third argument, | ||
| 109 | to provide hints concerning the type of socket that the caller supports. | ||
| 110 | In this | ||
| 111 | .Fa hints | ||
| 112 | structure all members other than | ||
| 113 | .Fa ai_flags , | ||
| 114 | .Fa ai_family , | ||
| 115 | .Fa ai_socktype , | ||
| 116 | and | ||
| 117 | .Fa ai_protocol | ||
| 118 | must be zero or a null pointer. | ||
| 119 | A value of | ||
| 120 | .Dv PF_UNSPEC | ||
| 121 | for | ||
| 122 | .Fa ai_family | ||
| 123 | means the caller will accept any protocol family. | ||
| 124 | A value of 0 for | ||
| 125 | .Fa ai_socktype | ||
| 126 | means the caller will accept any socket type. | ||
| 127 | A value of 0 for | ||
| 128 | .Fa ai_protocol | ||
| 129 | means the caller will accept any protocol. | ||
| 130 | For example, if the caller handles only TCP and not UDP, then the | ||
| 131 | .Fa ai_socktype | ||
| 132 | member of the hints structure should be set to | ||
| 133 | .Dv SOCK_STREAM | ||
| 134 | when | ||
| 135 | .Fn getaddrinfo | ||
| 136 | is called. | ||
| 137 | If the caller handles only IPv4 and not IPv6, then the | ||
| 138 | .Fa ai_family | ||
| 139 | member of the | ||
| 140 | .Fa hints | ||
| 141 | structure should be set to | ||
| 142 | .Dv PF_INET | ||
| 143 | when | ||
| 144 | .Fn getaddrinfo | ||
| 145 | is called. | ||
| 146 | If the third argument to | ||
| 147 | .Fn getaddrinfo | ||
| 148 | is a null pointer, this is the same as if the caller had filled in an | ||
| 149 | .Li addrinfo | ||
| 150 | structure initialized to zero with | ||
| 151 | .Fa ai_family | ||
| 152 | set to | ||
| 153 | .Dv PF_UNSPEC . | ||
| 154 | .Pp | ||
| 155 | Upon successful return a pointer to a linked list of one or more | ||
| 156 | .Li addrinfo | ||
| 157 | structures is returned through the final argument. | ||
| 158 | The caller can process each | ||
| 159 | .Li addrinfo | ||
| 160 | structure in this list by following the | ||
| 161 | .Fa ai_next | ||
| 162 | pointer, until a null pointer is encountered. | ||
| 163 | In each returned | ||
| 164 | .Li addrinfo | ||
| 165 | structure the three members | ||
| 166 | .Fa ai_family , | ||
| 167 | .Fa ai_socktype , | ||
| 168 | and | ||
| 169 | .Fa ai_protocol | ||
| 170 | are the corresponding arguments for a call to the | ||
| 171 | .Fn socket | ||
| 172 | function. | ||
| 173 | In each | ||
| 174 | .Li addrinfo | ||
| 175 | structure the | ||
| 176 | .Fa ai_addr | ||
| 177 | member points to a filled-in socket address structure whose length is | ||
| 178 | specified by the | ||
| 179 | .Fa ai_addrlen | ||
| 180 | member. | ||
| 181 | .Pp | ||
| 182 | If the | ||
| 183 | .Dv AI_PASSIVE | ||
| 184 | bit is set in the | ||
| 185 | .Fa ai_flags | ||
| 186 | member of the | ||
| 187 | .Fa hints | ||
| 188 | structure, then the caller plans to use the returned socket address | ||
| 189 | structure in a call to | ||
| 190 | .Fn bind . | ||
| 191 | In this case, if the | ||
| 192 | .Fa nodename | ||
| 193 | argument is a null pointer, then the IP address portion of the socket | ||
| 194 | address structure will be set to | ||
| 195 | .Dv INADDR_ANY | ||
| 196 | for an IPv4 address or | ||
| 197 | .Dv IN6ADDR_ANY_INIT | ||
| 198 | for an IPv6 address. | ||
| 199 | .Pp | ||
| 200 | If the | ||
| 201 | .Dv AI_PASSIVE | ||
| 202 | bit is not set in the | ||
| 203 | .Fa ai_flags | ||
| 204 | member of the | ||
| 205 | .Fa hints | ||
| 206 | structure, then the returned socket address structure will be ready for a | ||
| 207 | call to | ||
| 208 | .Fn connect | ||
| 209 | .Pq for a connection-oriented protocol | ||
| 210 | or either | ||
| 211 | .Fn connect , | ||
| 212 | .Fn sendto , | ||
| 213 | or | ||
| 214 | .Fn sendmsg | ||
| 215 | .Pq for a connectionless protocol . | ||
| 216 | In this case, if the | ||
| 217 | .Fa nodename | ||
| 218 | argument is a null pointer, then the IP address portion of the | ||
| 219 | socket address structure will be set to the loopback address. | ||
| 220 | .Pp | ||
| 221 | If the | ||
| 222 | .Dv AI_CANONNAME | ||
| 223 | bit is set in the | ||
| 224 | .Fa ai_flags | ||
| 225 | member of the | ||
| 226 | .Fa hints | ||
| 227 | structure, then upon successful return the | ||
| 228 | .Fa ai_canonname | ||
| 229 | member of the first | ||
| 230 | .Li addrinfo | ||
| 231 | structure in the linked list will point to a NUL-terminated string | ||
| 232 | containing the canonical name of the specified | ||
| 233 | .Fa nodename . | ||
| 234 | .Pp | ||
| 235 | If the | ||
| 236 | .Dv AI_NUMERICHOST | ||
| 237 | bit is set in the | ||
| 238 | .Fa ai_flags | ||
| 239 | member of the | ||
| 240 | .Fa hints | ||
| 241 | structure, then a non-null | ||
| 242 | .Fa nodename | ||
| 243 | string must be a numeric host address string. | ||
| 244 | Otherwise an error of | ||
| 245 | .Dv EAI_NONAME | ||
| 246 | is returned. | ||
| 247 | This flag prevents any type of name resolution service (e.g., the DNS) | ||
| 248 | from being called. | ||
| 249 | .Pp | ||
| 250 | The arguments to | ||
| 251 | .Fn getaddrinfo | ||
| 252 | must sufficiently be consistent and unambiguous. | ||
| 253 | Here are pitfall cases you may encounter: | ||
| 254 | .Bl -bullet | ||
| 255 | .It | ||
| 256 | .Fn getaddrinfo | ||
| 257 | will raise an error if members of the | ||
| 258 | .Fa hints | ||
| 259 | structure are not consistent. | ||
| 260 | For example, for internet address families, | ||
| 261 | .Fn getaddrinfo | ||
| 262 | will raise an error if you specify | ||
| 263 | .Dv SOCK_STREAM | ||
| 264 | to | ||
| 265 | .Fa ai_socktype | ||
| 266 | while you specify | ||
| 267 | .Dv IPPROTO_UDP | ||
| 268 | to | ||
| 269 | .Fa ai_protocol . | ||
| 270 | .It | ||
| 271 | If you specify a | ||
| 272 | .Fa servname | ||
| 273 | which is defined only for certain | ||
| 274 | .Fa ai_socktype , | ||
| 275 | .Fn getaddrinfo | ||
| 276 | will raise an error because the arguments are not consistent. | ||
| 277 | For example, | ||
| 278 | .Fn getaddrinfo | ||
| 279 | will raise an error if you ask for | ||
| 280 | .Dq Li tftp | ||
| 281 | service on | ||
| 282 | .Dv SOCK_STREAM . | ||
| 283 | .It | ||
| 284 | For internet address families, if you specify | ||
| 285 | .Fa servname | ||
| 286 | while you set | ||
| 287 | .Fa ai_socktype | ||
| 288 | to | ||
| 289 | .Dv SOCK_RAW , | ||
| 290 | .Fn getaddrinfo | ||
| 291 | will raise an error, because service names are not defined for the internet | ||
| 292 | .Dv SOCK_RAW | ||
| 293 | space. | ||
| 294 | .It | ||
| 295 | If you specify a numeric | ||
| 296 | .Fa servname , | ||
| 297 | while leaving | ||
| 298 | .Fa ai_socktype | ||
| 299 | and | ||
| 300 | .Fa ai_protocol | ||
| 301 | unspecified, | ||
| 302 | .Fn getaddrinfo | ||
| 303 | will raise an error. | ||
| 304 | This is because the numeric | ||
| 305 | .Fa servname | ||
| 306 | does not identify any socket type, and | ||
| 307 | .Fn getaddrinfo | ||
| 308 | is not allowed to glob the argument in such case. | ||
| 309 | .El | ||
| 310 | .Pp | ||
| 311 | All of the information returned by | ||
| 312 | .Fn getaddrinfo | ||
| 313 | is dynamically allocated: | ||
| 314 | the | ||
| 315 | .Li addrinfo | ||
| 316 | structures, the socket address structures, and canonical node name | ||
| 317 | strings pointed to by the addrinfo structures. | ||
| 318 | To return this information to the system the function | ||
| 319 | .Fn freeaddrinfo | ||
| 320 | is called. | ||
| 321 | The | ||
| 322 | .Fa addrinfo | ||
| 323 | structure pointed to by the | ||
| 324 | .Fa ai argument | ||
| 325 | is freed, along with any dynamic storage pointed to by the structure. | ||
| 326 | This operation is repeated until a | ||
| 327 | .Dv NULL | ||
| 328 | .Fa ai_next | ||
| 329 | pointer is encountered. | ||
| 330 | .Pp | ||
| 331 | To aid applications in printing error messages based on the | ||
| 332 | .Dv EAI_xxx | ||
| 333 | codes returned by | ||
| 334 | .Fn getaddrinfo , | ||
| 335 | .Fn gai_strerror | ||
| 336 | is defined. | ||
| 337 | The argument is one of the | ||
| 338 | .Dv EAI_xxx | ||
| 339 | values defined earlier and the return value points to a string describing | ||
| 340 | the error. | ||
| 341 | If the argument is not one of the | ||
| 342 | .Dv EAI_xxx | ||
| 343 | values, the function still returns a pointer to a string whose contents | ||
| 344 | indicate an unknown error. | ||
| 345 | .\" | ||
| 346 | .Ss Extension for scoped IPv6 address | ||
| 347 | The implementation allows experimental numeric IPv6 address notation with | ||
| 348 | scope identifier. | ||
| 349 | By appending the percent character and scope identifier to addresses, | ||
| 350 | you can fill the | ||
| 351 | .Li sin6_scope_id | ||
| 352 | field for addresses. | ||
| 353 | This would make management of scoped address easier, | ||
| 354 | and allows cut-and-paste input of scoped address. | ||
| 355 | .Pp | ||
| 356 | At this moment the code supports only link-local addresses with the format. | ||
| 357 | Scope identifier is hardcoded to the name of the hardware interface associated | ||
| 358 | with the link. | ||
| 359 | .Po | ||
| 360 | such as | ||
| 361 | .Li ne0 | ||
| 362 | .Pc . | ||
| 363 | An example is | ||
| 364 | .Dq Li fe80::1%ne0 , | ||
| 365 | which means | ||
| 366 | .Do | ||
| 367 | .Li fe80::1 | ||
| 368 | on the link associated with the | ||
| 369 | .Li ne0 | ||
| 370 | interface | ||
| 371 | .Dc . | ||
| 372 | .Pp | ||
| 373 | The implementation is still very experimental and non-standard. | ||
| 374 | The current implementation assumes a one-to-one relationship between | ||
| 375 | the interface and link, which is not necessarily true from the specification. | ||
| 376 | .\" | ||
| 377 | .Sh EXAMPLES | ||
| 378 | The following code tries to connect to | ||
| 379 | .Dq Li www.kame.net | ||
| 380 | service | ||
| 381 | .Dq Li http . | ||
| 382 | via stream socket. | ||
| 383 | It loops through all the addresses available, regardless of address family. | ||
| 384 | If the destination resolves to an IPv4 address, it will use | ||
| 385 | .Dv AF_INET | ||
| 386 | socket. | ||
| 387 | Similarly, if it resolves to IPv6, | ||
| 388 | .Dv AF_INET6 | ||
| 389 | socket is used. | ||
| 390 | Observe that there is no hardcoded reference to a particular address family. | ||
| 391 | The code works even if | ||
| 392 | .Nm getaddrinfo | ||
| 393 | returns addresses that are not IPv4/v6. | ||
| 394 | .Bd -literal -offset indent | ||
| 395 | struct addrinfo hints, *res, *res0; | ||
| 396 | int error; | ||
| 397 | int s; | ||
| 398 | const char *cause = NULL; | ||
| 399 | |||
| 400 | memset(&hints, 0, sizeof(hints)); | ||
| 401 | hints.ai_family = PF_UNSPEC; | ||
| 402 | hints.ai_socktype = SOCK_STREAM; | ||
| 403 | error = getaddrinfo("www.kame.net", "http", &hints, &res0); | ||
| 404 | if (error) { | ||
| 405 | errx(1, "%s", gai_strerror(error)); | ||
| 406 | /*NOTREACHED*/ | ||
| 407 | } | ||
| 408 | s = -1; | ||
| 409 | for (res = res0; res; res = res->ai_next) { | ||
| 410 | s = socket(res->ai_family, res->ai_socktype, | ||
| 411 | res->ai_protocol); | ||
| 412 | if (s < 0) { | ||
| 413 | cause = "socket"; | ||
| 414 | continue; | ||
| 415 | } | ||
| 416 | |||
| 417 | if (connect(s, res->ai_addr, res->ai_addrlen) < 0) { | ||
| 418 | cause = "connect"; | ||
| 419 | close(s); | ||
| 420 | s = -1; | ||
| 421 | continue; | ||
| 422 | } | ||
| 423 | |||
| 424 | break; /* okay we got one */ | ||
| 425 | } | ||
| 426 | if (s < 0) { | ||
| 427 | err(1, cause); | ||
| 428 | /*NOTREACHED*/ | ||
| 429 | } | ||
| 430 | freeaddrinfo(res0); | ||
| 431 | .Ed | ||
| 432 | .Pp | ||
| 433 | The following example tries to open a wildcard listening socket onto service | ||
| 434 | .Dq Li http , | ||
| 435 | for all the address families available. | ||
| 436 | .Bd -literal -offset indent | ||
| 437 | struct addrinfo hints, *res, *res0; | ||
| 438 | int error; | ||
| 439 | int s[MAXSOCK]; | ||
| 440 | int nsock; | ||
| 441 | const char *cause = NULL; | ||
| 442 | |||
| 443 | memset(&hints, 0, sizeof(hints)); | ||
| 444 | hints.ai_family = PF_UNSPEC; | ||
| 445 | hints.ai_socktype = SOCK_STREAM; | ||
| 446 | hints.ai_flags = AI_PASSIVE; | ||
| 447 | error = getaddrinfo(NULL, "http", &hints, &res0); | ||
| 448 | if (error) { | ||
| 449 | errx(1, "%s", gai_strerror(error)); | ||
| 450 | /*NOTREACHED*/ | ||
| 451 | } | ||
| 452 | nsock = 0; | ||
| 453 | for (res = res0; res && nsock < MAXSOCK; res = res->ai_next) { | ||
| 454 | s[nsock] = socket(res->ai_family, res->ai_socktype, | ||
| 455 | res->ai_protocol); | ||
| 456 | if (s[nsock] < 0) { | ||
| 457 | cause = "socket"; | ||
| 458 | continue; | ||
| 459 | } | ||
| 460 | |||
| 461 | if (bind(s[nsock], res->ai_addr, res->ai_addrlen) < 0) { | ||
| 462 | cause = "bind"; | ||
| 463 | close(s[nsock]); | ||
| 464 | continue; | ||
| 465 | } | ||
| 466 | (void) listen(s[nsock], 5); | ||
| 467 | |||
| 468 | nsock++; | ||
| 469 | } | ||
| 470 | if (nsock == 0) { | ||
| 471 | err(1, cause); | ||
| 472 | /*NOTREACHED*/ | ||
| 473 | } | ||
| 474 | freeaddrinfo(res0); | ||
| 475 | .Ed | ||
| 476 | .\" | ||
| 477 | .Sh DIAGNOSTICS | ||
| 478 | Error return status from | ||
| 479 | .Fn getaddrinfo | ||
| 480 | is zero on success and non-zero on errors. | ||
| 481 | Non-zero error codes are defined in | ||
| 482 | .Aq Pa netdb.h , | ||
| 483 | and as follows: | ||
| 484 | .Pp | ||
| 485 | .Bl -tag -width EAI_ADDRFAMILY -compact | ||
| 486 | .It Dv EAI_ADDRFAMILY | ||
| 487 | Address family for | ||
| 488 | .Fa nodename | ||
| 489 | not supported. | ||
| 490 | .It Dv EAI_AGAIN | ||
| 491 | Temporary failure in name resolution. | ||
| 492 | .It Dv EAI_BADFLAGS | ||
| 493 | Invalid value for | ||
| 494 | .Fa ai_flags . | ||
| 495 | .It Dv EAI_FAIL | ||
| 496 | Non-recoverable failure in name resolution. | ||
| 497 | .It Dv EAI_FAMILY | ||
| 498 | .Fa ai_family | ||
| 499 | not supported. | ||
| 500 | .It Dv EAI_MEMORY | ||
| 501 | Memory allocation failure. | ||
| 502 | .It Dv EAI_NODATA | ||
| 503 | No address associated with | ||
| 504 | .Fa nodename . | ||
| 505 | .It Dv EAI_NONAME | ||
| 506 | .Fa nodename | ||
| 507 | nor | ||
| 508 | .Fa servname | ||
| 509 | provided, or not known. | ||
| 510 | .It Dv EAI_SERVICE | ||
| 511 | .Fa servname | ||
| 512 | not supported for | ||
| 513 | .Fa ai_socktype . | ||
| 514 | .It Dv EAI_SOCKTYPE | ||
| 515 | .Fa ai_socktype | ||
| 516 | not supported. | ||
| 517 | .It Dv EAI_SYSTEM | ||
| 518 | System error returned in | ||
| 519 | .Va errno . | ||
| 520 | .El | ||
| 521 | .Pp | ||
| 522 | If called with proper argument, | ||
| 523 | .Fn gai_strerror | ||
| 524 | returns a pointer to a string describing the given error code. | ||
| 525 | If the argument is not one of the | ||
| 526 | .Dv EAI_xxx | ||
| 527 | values, the function still returns a pointer to a string whose contents | ||
| 528 | indicate an unknown error. | ||
| 529 | .\" | ||
| 530 | .Sh SEE ALSO | ||
| 531 | .Xr gethostbyname 3 , | ||
| 532 | .Xr getnameinfo 3 , | ||
| 533 | .Xr getservbyname 3 , | ||
| 534 | .Xr hosts 5 , | ||
| 535 | .Xr resolv.conf 5 , | ||
| 536 | .Xr services 5 , | ||
| 537 | .Xr hostname 7 , | ||
| 538 | .Xr named 8 | ||
| 539 | .Rs | ||
| 540 | .%A R. Gilligan | ||
| 541 | .%A S. Thomson | ||
| 542 | .%A J. Bound | ||
| 543 | .%A W. Stevens | ||
| 544 | .%T Basic Socket Interface Extensions for IPv6 | ||
| 545 | .%R RFC 2553 | ||
| 546 | .%D March 1999 | ||
| 547 | .Re | ||
| 548 | .Rs | ||
| 549 | .%A Tatsuya Jinmei | ||
| 550 | .%A Atsushi Onoe | ||
| 551 | .%T "An Extension of Format for IPv6 Scoped Addresses" | ||
| 552 | .%R internet draft | ||
| 553 | .%N draft-ietf-ipngwg-scopedaddr-format-02.txt | ||
| 554 | .%O work in progress material | ||
| 555 | .Re | ||
| 556 | .Rs | ||
| 557 | .%A Craig Metz | ||
| 558 | .%T Protocol Independence Using the Sockets API | ||
| 559 | .%B "Proceedings of the freenix track: 2000 USENIX annual technical conference" | ||
| 560 | .%D June 2000 | ||
| 561 | .Re | ||
| 562 | .\" | ||
| 563 | .Sh STANDARDS | ||
| 564 | The | ||
| 565 | .Fn getaddrinfo | ||
| 566 | function is defined in IEEE POSIX 1003.1g draft specification, | ||
| 567 | and documented in | ||
| 568 | .Dq Basic Socket Interface Extensions for IPv6 | ||
| 569 | .Pq RFC 2553 . | ||
| 570 | .\" | ||
| 571 | .Sh HISTORY | ||
| 572 | The implementation first appeared in WIDE Hydrangea IPv6 protocol stack kit. | ||
| 573 | .\" | ||
| 574 | .Sh BUGS | ||
| 575 | The current implementation is not thread-safe. | ||
| 576 | .Pp | ||
| 577 | The text was shamelessly copied from RFC 2553. | ||
