summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjaredy <>2004-12-21 03:40:31 +0000
committerjaredy <>2004-12-21 03:40:31 +0000
commit68be80875ba407b40a8f69c046ae81556db6b8c5 (patch)
treeddb3bb151b92c2f537353874e6fddb035158a1a5
parent3b14bd049e961cdc29a063c8bd9fedbc33060d1f (diff)
downloadopenbsd-68be80875ba407b40a8f69c046ae81556db6b8c5.tar.gz
openbsd-68be80875ba407b40a8f69c046ae81556db6b8c5.tar.bz2
openbsd-68be80875ba407b40a8f69c046ae81556db6b8c5.zip
- grammar, punctuation, spacing, and mdoc fixes
- remove first person - EAI_NONAME is already described in gai_strerror(3)
-rw-r--r--src/lib/libc/net/getaddrinfo.347
-rw-r--r--src/lib/libc/net/getnameinfo.316
2 files changed, 29 insertions, 34 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
99Denotes the type of socket that is wanted: 100Denotes the type of socket that is wanted:
100.Dv SOCK_STREAM , 101.Dv SOCK_STREAM ,
101.Dv SOCK_DGRAM 102.Dv SOCK_DGRAM ,
102or 103or
103.Dv SOCK_RAW . 104.Dv SOCK_RAW .
104When 105When
@@ -140,11 +141,11 @@ and no name resolution should be attempted.
140If the 141If the
141.Dv AI_PASSIVE 142.Dv AI_PASSIVE
142bit is set it indicates that the returned socket address structure 143bit is set it indicates that the returned socket address structure
143is intended for used in a call to 144is intended for use in a call to
144.Xr bind 2 . 145.Xr bind 2 .
145In this case, if the 146In this case, if the
146.Fa hostname 147.Fa hostname
147argument is a the null pointer, then the IP address portion of the 148argument is the null pointer, then the IP address portion of the
148socket address structure will be set to 149socket address structure will be set to
149.Dv INADDR_ANY 150.Dv INADDR_ANY
150for an IPv4 address or 151for an IPv4 address or
@@ -158,7 +159,7 @@ for use in a call to
158.Xr connect 2 159.Xr connect 2
159for a connection-oriented protocol or 160for a connection-oriented protocol or
160.Xr connect 2 , 161.Xr connect 2 ,
161.Xr sendto 2 162.Xr sendto 2 ,
162or 163or
163.Xr sendmsg 2 164.Xr sendmsg 2
164if a connectionless protocol was chosen. 165if a connectionless protocol was chosen.
@@ -167,7 +168,7 @@ The
167address portion of the socket address structure will be set to the 168address portion of the socket address structure will be set to the
168loopback address if 169loopback address if
169.Fa hostname 170.Fa hostname
170is the null pointer and the 171is the null pointer and
171.Dv AI_PASSIVE 172.Dv AI_PASSIVE
172is not set. 173is not set.
173.El 174.El
@@ -203,7 +204,7 @@ The list can be traversed by following the
203pointer in each 204pointer in each
204.Li addrinfo 205.Li addrinfo
205structure until a null pointer is encountered. 206structure until a null pointer is encountered.
206The three members, 207The three members
207.Fa ai_family, 208.Fa ai_family,
208.Fa ai_socktype, 209.Fa ai_socktype,
209and 210and
@@ -221,16 +222,17 @@ member points to a filled-in socket address structure of length
221.Pp 222.Pp
222This implementation of 223This implementation of
223.Fn getaddrinfo 224.Fn getaddrinfo
224allows experimental numeric IPv6 address notation with scope identifier. 225allows experimental numeric IPv6 address notation with scope identifiers.
225By appending the percent character and scope identifier to addresses, 226By appending the percent character and scope identifier to addresses,
226you can fill the 227one can fill the
227.Li sin6_scope_id 228.Li sin6_scope_id
228field for addresses. 229field for addresses.
229This would make management of scoped address easier, 230This would make management of scoped addresses easier
230and allows cut-and-paste input of scoped address. 231and allows cut-and-paste input of scoped addresses.
231.Pp 232.Pp
232At this moment the code supports only link-local addresses with the format. 233At this moment the code supports only link-local addresses with the format.
233Scope identifier is hardcoded to the name of the hardware interface associated 234The scope identifier is hardcoded to the name of the hardware interface
235associated
234with the link 236with the link
235.Po 237.Po
236such as 238such as
@@ -276,31 +278,22 @@ structure created by a call to
276returns zero on success or one of the error codes listed in 278returns zero on success or one of the error codes listed in
277.Xr gai_strerror 3 279.Xr gai_strerror 3
278if an error occurs. 280if an error occurs.
279If both
280.Fa hostname
281and
282.Fa servname
283are
284.Dv NULL ,
285.Fn getaddrinfo
286returns
287.Dv EAI_NONAME .
288.Sh EXAMPLES 281.Sh EXAMPLES
289The following code tries to connect to 282The following code tries to connect to
290.Dq Li www.kame.net 283.Dq Li www.kame.net
291service 284service
292.Dq Li http . 285.Dq Li http
293via stream socket. 286via a stream socket.
294It loops through all the addresses available, regardless of address family. 287It loops through all the addresses available, regardless of address family.
295If the destination resolves to an IPv4 address, it will use 288If the destination resolves to an IPv4 address, it will use an
296.Dv AF_INET 289.Dv AF_INET
297socket. 290socket.
298Similarly, if it resolves to IPv6, 291Similarly, if it resolves to IPv6, an
299.Dv AF_INET6 292.Dv AF_INET6
300socket is used. 293socket is used.
301Observe that there is no hardcoded reference to a particular address family. 294Observe that there is no hardcoded reference to a particular address family.
302The code works even if 295The code works even if
303.Nm getaddrinfo 296.Fn getaddrinfo
304returns addresses that are not IPv4/v6. 297returns addresses that are not IPv4/v6.
305.Bd -literal -offset indent 298.Bd -literal -offset indent
306struct addrinfo hints, *res, *res0; 299struct addrinfo hints, *res, *res0;
diff --git a/src/lib/libc/net/getnameinfo.3 b/src/lib/libc/net/getnameinfo.3
index ccb46faece..b83b9d5079 100644
--- a/src/lib/libc/net/getnameinfo.3
+++ b/src/lib/libc/net/getnameinfo.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: getnameinfo.3,v 1.34 2004/12/21 01:01:47 itojun Exp $ 1.\" $OpenBSD: getnameinfo.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.
@@ -26,7 +26,8 @@
26.Fd #include <sys/socket.h> 26.Fd #include <sys/socket.h>
27.Fd #include <netdb.h> 27.Fd #include <netdb.h>
28.Ft int 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" 29.Fn getnameinfo "const struct sockaddr *sa" "socklen_t salen" "char *host" \
30 "size_t hostlen" "char *serv" "size_t servlen" "int flags"
30.Sh DESCRIPTION 31.Sh DESCRIPTION
31The 32The
32.Fn getnameinfo 33.Fn getnameinfo
@@ -68,7 +69,7 @@ The maximum value for
68is 69is
69.Dv NI_MAXHOST 70.Dv NI_MAXHOST
70and 71and
71the maximum value for 72the maximum value for
72.Fa servlen 73.Fa servlen
73is 74is
74.Dv NI_MAXSERV , 75.Dv NI_MAXSERV ,
@@ -95,7 +96,7 @@ instead of a host name.
95A name is required. 96A name is required.
96If the host name cannot be found in DNS and this flag is set, 97If the host name cannot be found in DNS and this flag is set,
97a non-zero error code is returned. 98a non-zero error code is returned.
98If the host name is not found and the flag is not set, the 99If the host name is not found and the flag is not set, the
99address is returned in numeric form. 100address is returned in numeric form.
100.It NI_NUMERICSERV 101.It NI_NUMERICSERV
101The service name is returned as a digit string representing the port number. 102The service name is returned as a digit string representing the port number.
@@ -107,7 +108,7 @@ to be called with a second argument of
107.Dq udp 108.Dq udp
108instead of its default of 109instead of its default of
109.Dq tcp . 110.Dq tcp .
110This is required for the few ports (512-514) that have different services 111This is required for the few ports (512\-514) that have different services
111for 112for
112.Tn UDP 113.Tn UDP
113and 114and
@@ -222,8 +223,9 @@ when it is actually
222.Pp 223.Pp
223To prevent such attacks, the use of 224To prevent such attacks, the use of
224.Dv NI_NAMEREQD 225.Dv NI_NAMEREQD
225is recommended when you use the result of 226is recommended when the result of
226.Fn getnameinfo 227.Fn getnameinfo
228is used
227for access control purposes: 229for access control purposes:
228.Bd -literal -offset indent 230.Bd -literal -offset indent
229struct sockaddr *sa; 231struct sockaddr *sa;
@@ -241,7 +243,7 @@ if (error == 0) {
241 if (getaddrinfo(addr, "0", &hints, &res) == 0) { 243 if (getaddrinfo(addr, "0", &hints, &res) == 0) {
242 /* malicious PTR record */ 244 /* malicious PTR record */
243 freeaddrinfo(res); 245 freeaddrinfo(res);
244 printf("bogus PTR record\\n"); 246 printf("bogus PTR record\en");
245 return -1; 247 return -1;
246 } 248 }
247 /* addr is FQDN as a result of PTR lookup */ 249 /* addr is FQDN as a result of PTR lookup */