diff options
Diffstat (limited to 'src/lib/libc/net/getaddrinfo.3')
-rw-r--r-- | src/lib/libc/net/getaddrinfo.3 | 47 |
1 files changed, 20 insertions, 27 deletions
diff --git a/src/lib/libc/net/getaddrinfo.3 b/src/lib/libc/net/getaddrinfo.3 index cc5eaa4182..4fba44bb73 100644 --- a/src/lib/libc/net/getaddrinfo.3 +++ b/src/lib/libc/net/getaddrinfo.3 | |||
@@ -1,4 +1,4 @@ | |||
1 | .\" $OpenBSD: getaddrinfo.3,v 1.34 2004/12/21 01:01:47 itojun Exp $ | 1 | .\" $OpenBSD: getaddrinfo.3,v 1.35 2004/12/21 03:40:31 jaredy Exp $ |
2 | .\" | 2 | .\" |
3 | .\" Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") | 3 | .\" Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") |
4 | .\" Copyright (C) 2000, 2001 Internet Software Consortium. | 4 | .\" Copyright (C) 2000, 2001 Internet Software Consortium. |
@@ -27,7 +27,8 @@ | |||
27 | .Fd #include <sys/socket.h> | 27 | .Fd #include <sys/socket.h> |
28 | .Fd #include <netdb.h> | 28 | .Fd #include <netdb.h> |
29 | .Ft int | 29 | .Ft int |
30 | .Fn getaddrinfo "const char *hostname" "const char *servname" "const struct addrinfo *hints" "struct addrinfo **res" | 30 | .Fn getaddrinfo "const char *hostname" "const char *servname" \ |
31 | "const struct addrinfo *hints" "struct addrinfo **res" | ||
31 | .Ft void | 32 | .Ft void |
32 | .Fn freeaddrinfo "struct addrinfo *ai" | 33 | .Fn freeaddrinfo "struct addrinfo *ai" |
33 | .Sh DESCRIPTION | 34 | .Sh DESCRIPTION |
@@ -98,7 +99,7 @@ operating system. | |||
98 | .It Fa ai_socktype | 99 | .It Fa ai_socktype |
99 | Denotes the type of socket that is wanted: | 100 | Denotes the type of socket that is wanted: |
100 | .Dv SOCK_STREAM , | 101 | .Dv SOCK_STREAM , |
101 | .Dv SOCK_DGRAM | 102 | .Dv SOCK_DGRAM , |
102 | or | 103 | or |
103 | .Dv SOCK_RAW . | 104 | .Dv SOCK_RAW . |
104 | When | 105 | When |
@@ -140,11 +141,11 @@ and no name resolution should be attempted. | |||
140 | If the | 141 | If the |
141 | .Dv AI_PASSIVE | 142 | .Dv AI_PASSIVE |
142 | bit is set it indicates that the returned socket address structure | 143 | bit is set it indicates that the returned socket address structure |
143 | is intended for used in a call to | 144 | is intended for use in a call to |
144 | .Xr bind 2 . | 145 | .Xr bind 2 . |
145 | In this case, if the | 146 | In this case, if the |
146 | .Fa hostname | 147 | .Fa hostname |
147 | argument is a the null pointer, then the IP address portion of the | 148 | argument is the null pointer, then the IP address portion of the |
148 | socket address structure will be set to | 149 | socket address structure will be set to |
149 | .Dv INADDR_ANY | 150 | .Dv INADDR_ANY |
150 | for an IPv4 address or | 151 | for an IPv4 address or |
@@ -158,7 +159,7 @@ for use in a call to | |||
158 | .Xr connect 2 | 159 | .Xr connect 2 |
159 | for a connection-oriented protocol or | 160 | for a connection-oriented protocol or |
160 | .Xr connect 2 , | 161 | .Xr connect 2 , |
161 | .Xr sendto 2 | 162 | .Xr sendto 2 , |
162 | or | 163 | or |
163 | .Xr sendmsg 2 | 164 | .Xr sendmsg 2 |
164 | if a connectionless protocol was chosen. | 165 | if a connectionless protocol was chosen. |
@@ -167,7 +168,7 @@ The | |||
167 | address portion of the socket address structure will be set to the | 168 | address portion of the socket address structure will be set to the |
168 | loopback address if | 169 | loopback address if |
169 | .Fa hostname | 170 | .Fa hostname |
170 | is the null pointer and the | 171 | is the null pointer and |
171 | .Dv AI_PASSIVE | 172 | .Dv AI_PASSIVE |
172 | is not set. | 173 | is not set. |
173 | .El | 174 | .El |
@@ -203,7 +204,7 @@ The list can be traversed by following the | |||
203 | pointer in each | 204 | pointer in each |
204 | .Li addrinfo | 205 | .Li addrinfo |
205 | structure until a null pointer is encountered. | 206 | structure until a null pointer is encountered. |
206 | The three members, | 207 | The three members |
207 | .Fa ai_family, | 208 | .Fa ai_family, |
208 | .Fa ai_socktype, | 209 | .Fa ai_socktype, |
209 | and | 210 | and |
@@ -221,16 +222,17 @@ member points to a filled-in socket address structure of length | |||
221 | .Pp | 222 | .Pp |
222 | This implementation of | 223 | This implementation of |
223 | .Fn getaddrinfo | 224 | .Fn getaddrinfo |
224 | allows experimental numeric IPv6 address notation with scope identifier. | 225 | allows experimental numeric IPv6 address notation with scope identifiers. |
225 | By appending the percent character and scope identifier to addresses, | 226 | By appending the percent character and scope identifier to addresses, |
226 | you can fill the | 227 | one can fill the |
227 | .Li sin6_scope_id | 228 | .Li sin6_scope_id |
228 | field for addresses. | 229 | field for addresses. |
229 | This would make management of scoped address easier, | 230 | This would make management of scoped addresses easier |
230 | and allows cut-and-paste input of scoped address. | 231 | and allows cut-and-paste input of scoped addresses. |
231 | .Pp | 232 | .Pp |
232 | At this moment the code supports only link-local addresses with the format. | 233 | At this moment the code supports only link-local addresses with the format. |
233 | Scope identifier is hardcoded to the name of the hardware interface associated | 234 | The scope identifier is hardcoded to the name of the hardware interface |
235 | associated | ||
234 | with the link | 236 | with the link |
235 | .Po | 237 | .Po |
236 | such as | 238 | such as |
@@ -276,31 +278,22 @@ structure created by a call to | |||
276 | returns zero on success or one of the error codes listed in | 278 | returns zero on success or one of the error codes listed in |
277 | .Xr gai_strerror 3 | 279 | .Xr gai_strerror 3 |
278 | if an error occurs. | 280 | if an error occurs. |
279 | If both | ||
280 | .Fa hostname | ||
281 | and | ||
282 | .Fa servname | ||
283 | are | ||
284 | .Dv NULL , | ||
285 | .Fn getaddrinfo | ||
286 | returns | ||
287 | .Dv EAI_NONAME . | ||
288 | .Sh EXAMPLES | 281 | .Sh EXAMPLES |
289 | The following code tries to connect to | 282 | The following code tries to connect to |
290 | .Dq Li www.kame.net | 283 | .Dq Li www.kame.net |
291 | service | 284 | service |
292 | .Dq Li http . | 285 | .Dq Li http |
293 | via stream socket. | 286 | via a stream socket. |
294 | It loops through all the addresses available, regardless of address family. | 287 | It loops through all the addresses available, regardless of address family. |
295 | If the destination resolves to an IPv4 address, it will use | 288 | If the destination resolves to an IPv4 address, it will use an |
296 | .Dv AF_INET | 289 | .Dv AF_INET |
297 | socket. | 290 | socket. |
298 | Similarly, if it resolves to IPv6, | 291 | Similarly, if it resolves to IPv6, an |
299 | .Dv AF_INET6 | 292 | .Dv AF_INET6 |
300 | socket is used. | 293 | socket is used. |
301 | Observe that there is no hardcoded reference to a particular address family. | 294 | Observe that there is no hardcoded reference to a particular address family. |
302 | The code works even if | 295 | The code works even if |
303 | .Nm getaddrinfo | 296 | .Fn getaddrinfo |
304 | returns addresses that are not IPv4/v6. | 297 | returns addresses that are not IPv4/v6. |
305 | .Bd -literal -offset indent | 298 | .Bd -literal -offset indent |
306 | struct addrinfo hints, *res, *res0; | 299 | struct addrinfo hints, *res, *res0; |