From 6afa76b65a3aa2af4e29d09a0e9e05488ca45fe0 Mon Sep 17 00:00:00 2001 From: itojun <> Date: Tue, 25 Jul 2000 04:52:55 +0000 Subject: document pitfall cases in argument parsing. sync with kame. --- src/lib/libc/net/getaddrinfo.3 | 67 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 3 deletions(-) diff --git a/src/lib/libc/net/getaddrinfo.3 b/src/lib/libc/net/getaddrinfo.3 index 9aac4c32c7..bff0344848 100644 --- a/src/lib/libc/net/getaddrinfo.3 +++ b/src/lib/libc/net/getaddrinfo.3 @@ -1,5 +1,5 @@ -.\" $OpenBSD: getaddrinfo.3,v 1.9 2000/06/30 16:52:44 itojun Exp $ -.\" $KAME: getaddrinfo.3,v 1.15 2000/06/30 16:46:00 itojun Exp $ +.\" $OpenBSD: getaddrinfo.3,v 1.10 2000/07/25 04:52:55 itojun Exp $ +.\" $KAME: getaddrinfo.3,v 1.21 2000/07/25 04:49:42 itojun Exp $ .\" .\" Copyright (c) 1983, 1987, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -251,6 +251,67 @@ is returned. This flag prevents any type of name resolution service (e.g., the DNS) from being called. .Pp +The arguments to +.Fn getaddrinfo +must sufficiently be consistent and unambiguous. +Here are pitfall cases you may encounter: +.Bl -bullet +.It +.Fn getaddrinfo +will raise error if members in +.Fa hints +structure is not consistent. +For example, for internet address families, +.Fn getaddrinfo +will raise error if you specify +.Dv SOCK_STREAM +to +.Fa ai_socktype +while you specify +.Dv IPPROTO_UDP +to +.Fa ai_protocol . +.It +If you specify a +.Fa servname +which is defined only for certain +.Fa ai_socktype , +.Fn getaddrinfo +will raise error because the arguments are not consistent. +For example, +.Fn getaddrinfo +will raise error if you ask for +.Dq Li tftp +service on +.Dv SOCK_STREAM . +.It +For internet address families, if you specify +.Fa servname +while you set +.Fa ai_socktype +to +.Dv SOCK_RAW , +.Fn getaddrinfo +will raise error, because service names are not defined for the internet +.Dv SOCK_RAW +space. +.It +If you specify numeric +.Fa servname , +while leaving +.Fa ai_socktype +and +.Fa ai_protocol +unspecified, +.Fn getaddrinfo +will raise error. +This is because the numeric +.Fa servname +does not identify any socket type, and +.Fn getaddrinfo +is not allowed to glob the argument in such case. +.El +.Pp All of the information returned by .Fn getaddrinfo is dynamically allocated: @@ -498,7 +559,7 @@ indicate an unknown error. .%A Atsushi Onoe .%T "An Extension of Format for IPv6 Scoped Addresses" .%R internet draft -.%N draft-ietf-ipngwg-scopedaddr-format-01.txt +.%N draft-ietf-ipngwg-scopedaddr-format-02.txt .%O work in progress material .Re .Rs -- cgit v1.2.3-55-g6feb