diff options
Diffstat (limited to 'src/lib/libc')
| -rw-r--r-- | src/lib/libc/net/getnameinfo.3 | 171 | 
1 files changed, 171 insertions, 0 deletions
| diff --git a/src/lib/libc/net/getnameinfo.3 b/src/lib/libc/net/getnameinfo.3 new file mode 100644 index 0000000000..f9ada350cd --- /dev/null +++ b/src/lib/libc/net/getnameinfo.3 | |||
| @@ -0,0 +1,171 @@ | |||
| 1 | .\" $OpenBSD: getnameinfo.3,v 1.30 2004/12/20 22:15:29 millert Exp $ | ||
| 2 | .\" | ||
| 3 | .\" Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") | ||
| 4 | .\" Copyright (C) 2000, 2001 Internet Software Consortium. | ||
| 5 | .\" | ||
| 6 | .\" Permission to use, copy, modify, and distribute this software for any | ||
| 7 | .\" purpose with or without fee is hereby granted, provided that the above | ||
| 8 | .\" copyright notice and this permission notice appear in all copies. | ||
| 9 | .\" | ||
| 10 | .\" THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH | ||
| 11 | .\" REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
| 12 | .\" AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
| 13 | .\" INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
| 14 | .\" LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE | ||
| 15 | .\" OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
| 16 | .\" PERFORMANCE OF THIS SOFTWARE. | ||
| 17 | .\" | ||
| 18 | .Dd December 20, 2004 | ||
| 19 | .Dt GETNAMEINFO 3 | ||
| 20 | .Os | ||
| 21 | .Sh NAME | ||
| 22 | .Nm getnameinfo | ||
| 23 | .Nd socket address structure to hostname and service name | ||
| 24 | .Sh SYNOPSIS | ||
| 25 | .Fd #include <sys/types.h> | ||
| 26 | .Fd #include <sys/socket.h> | ||
| 27 | .Fd #include <netdb.h> | ||
| 28 | .Ft int | ||
| 29 | .Fn getnameinfo "const struct sockaddr *sa" "socklen_t salen" "char *host" "size_t hostlen" "char *serv" "size_t servlen" "int flags" | ||
| 30 | .Sh DESCRIPTION | ||
| 31 | The | ||
| 32 | .Fn getnameinfo | ||
| 33 | function is used to convert a | ||
| 34 | .Li sockaddr | ||
| 35 | structure to a pair of host name and service strings. | ||
| 36 | It is a replacement for and provides more flexibility than the | ||
| 37 | .Xr gethostbyaddr 3 | ||
| 38 | and | ||
| 39 | .Xr getservbyport 3 | ||
| 40 | functions and is the converse of the | ||
| 41 | .Xr getaddrinfo 3 | ||
| 42 | function. | ||
| 43 | .Pp | ||
| 44 | The | ||
| 45 | .Li sockaddr | ||
| 46 | structure | ||
| 47 | .Fa sa | ||
| 48 | should point to either a | ||
| 49 | .Li sockaddr_in | ||
| 50 | or | ||
| 51 | .Li sockaddr_in6 | ||
| 52 | structure (for IPv4 or IPv6 respectively) that is | ||
| 53 | .Fa salen | ||
| 54 | bytes long. | ||
| 55 | .Pp | ||
| 56 | The host and service names associated with | ||
| 57 | .Fa sa | ||
| 58 | are stored in | ||
| 59 | .Fa host | ||
| 60 | and | ||
| 61 | .Fa serv | ||
| 62 | which have size parameters | ||
| 63 | .Fa hostlen | ||
| 64 | and | ||
| 65 | .Fa servlen . | ||
| 66 | The maximum value for | ||
| 67 | .Fa hostlen | ||
| 68 | is | ||
| 69 | .Dv NI_MAXHOST | ||
| 70 | and | ||
| 71 | the maximum value for | ||
| 72 | .Fa servlen | ||
| 73 | is | ||
| 74 | .Dv NI_MAXSERV | ||
| 75 | - 32, | ||
| 76 | as defined by | ||
| 77 | .Aq Pa netdb.h . | ||
| 78 | .Pp | ||
| 79 | The | ||
| 80 | .Fa flags | ||
| 81 | argument is formed by | ||
| 82 | .Tn OR Ns 'ing | ||
| 83 | the following values: | ||
| 84 | .Bl -tag -width "NI_NUMERICHOSTXX" | ||
| 85 | .It Dv NI_NOFQDN | ||
| 86 | A fully qualified domain name is not required for local hosts. | ||
| 87 | The local part of the fully qualified domain name is returned instead. | ||
| 88 | .It Dv NI_NUMERICHOST | ||
| 89 | Return the address in numeric form, as if calling | ||
| 90 | .Xr inet_ntop 3 , | ||
| 91 | instead of a host name. | ||
| 92 | .It Dv NI_NAMEREQD | ||
| 93 | A name is required. | ||
| 94 | If the host name cannot be found in DNS and this flag is set, | ||
| 95 | a non-zero error code is returned. | ||
| 96 | If the host name is not found and the flag is not set, the | ||
| 97 | address is returned in numeric form. | ||
| 98 | .It NI_NUMERICSERV | ||
| 99 | The service name is returned as a digit string representing the port number. | ||
| 100 | .It NI_DGRAM | ||
| 101 | Specifies that the service being looked up is a datagram | ||
| 102 | service, and causes | ||
| 103 | .Xr getservbyport 3 | ||
| 104 | to be called with a second argument of | ||
| 105 | .Dq udp | ||
| 106 | instead of its default of | ||
| 107 | .Dq tcp . | ||
| 108 | This is required for the few ports (512-514) that have different services | ||
| 109 | for | ||
| 110 | .Tn UDP | ||
| 111 | and | ||
| 112 | .Tn TCP . | ||
| 113 | .Sh RETURN VALUES | ||
| 114 | .Fn getnameinfo | ||
| 115 | returns zero on success or one of the error codes listed in | ||
| 116 | .Xr gai_strerror 3 | ||
| 117 | if an error occurs. | ||
| 118 | .Sh SEE ALSO | ||
| 119 | .Xr inet_ntop 3 , | ||
| 120 | .Xr gai_strerror 3 , | ||
| 121 | .Xr getaddrinfo 3 , | ||
| 122 | .Xr gethostbyaddr 3 , | ||
| 123 | .Xr getservbyport 3 , | ||
| 124 | .Xr resolver 3 , | ||
| 125 | .Xr hosts 5 , | ||
| 126 | .Xr resolv.conf 5 , | ||
| 127 | .Xr services 5 , | ||
| 128 | .Xr hostname 7 , | ||
| 129 | .Xr named 8 | ||
| 130 | .Rs | ||
| 131 | .%A R. Gilligan | ||
| 132 | .%A S. Thomson | ||
| 133 | .%A J. Bound | ||
| 134 | .%A W. Stevens | ||
| 135 | .%T Basic Socket Interface Extensions for IPv6 | ||
| 136 | .%R RFC 2553 | ||
| 137 | .%D March 1999 | ||
| 138 | .Re | ||
| 139 | .Rs | ||
| 140 | .%A Tatsuya Jinmei | ||
| 141 | .%A Atsushi Onoe | ||
| 142 | .%T "An Extension of Format for IPv6 Scoped Addresses" | ||
| 143 | .%R internet draft | ||
| 144 | .%N draft-ietf-ipngwg-scopedaddr-format-02.txt | ||
| 145 | .%O work in progress material | ||
| 146 | .Re | ||
| 147 | .Rs | ||
| 148 | .%A Craig Metz | ||
| 149 | .%T Protocol Independence Using the Sockets API | ||
| 150 | .%B "Proceedings of the freenix track: 2000 USENIX annual technical conference" | ||
| 151 | .%D June 2000 | ||
| 152 | .Re | ||
| 153 | .Sh STANDARDS | ||
| 154 | The | ||
| 155 | .Fn getnameinfo | ||
| 156 | function is defined by the | ||
| 157 | .St -p1003.1g-2000 | ||
| 158 | draft specification and documented in | ||
| 159 | .Tn "RFC 2553" , | ||
| 160 | .Dq Basic Socket Interface Extensions for IPv6 . | ||
| 161 | .Sh BUGS | ||
| 162 | Due to the use of dynamic allocation, | ||
| 163 | .Fn getaddrinfo | ||
| 164 | is not thread-safe. | ||
| 165 | .Pp | ||
| 166 | .Ox | ||
| 167 | intentionally uses a different | ||
| 168 | .Dv NI_MAXHOST | ||
| 169 | value from what | ||
| 170 | .Tn "RFC 2553" | ||
| 171 | suggests, to avoid buffer length handling mistakes. | ||
