1 .\" Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
2 .\" Copyright (C) 2000, 2001, 2003 Internet Software Consortium.
4 .\" Permission to use, copy, modify, and distribute this software for any
5 .\" purpose with or without fee is hereby granted, provided that the above
6 .\" copyright notice and this permission notice appear in all copies.
8 .\" THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
9 .\" REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10 .\" AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
11 .\" INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12 .\" LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
13 .\" OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14 .\" PERFORMANCE OF THIS SOFTWARE.
16 .\" $Id: lwres_getaddrinfo.3,v 1.16.2.3 2004/03/15 04:45:02 marka Exp $
18 .TH "LWRES_GETADDRINFO" "3" "Jun 30, 2000" "BIND9" ""
20 lwres_getaddrinfo, lwres_freeaddrinfo \- socket address structure to host and service name
22 \fB#include <lwres/netdb.h>
26 lwres_getaddrinfo(const char *hostname, const char *servname, const struct addrinfo *hints, struct addrinfo **res);
31 lwres_freeaddrinfo(struct addrinfo *ai);
35 If the operating system does not provide a
36 \fBstruct addrinfo\fR,
37 the following structure is used:
41 int ai_flags; /* AI_PASSIVE, AI_CANONNAME */
42 int ai_family; /* PF_xxx */
43 int ai_socktype; /* SOCK_xxx */
44 int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
45 size_t ai_addrlen; /* length of ai_addr */
46 char *ai_canonname; /* canonical name for hostname */
47 struct sockaddr *ai_addr; /* binary address */
48 struct addrinfo *ai_next; /* next structure in linked list */
54 \fBlwres_getaddrinfo()\fR
55 is used to get a list of IP addresses and port numbers for host
59 The function is the lightweight resolver's implementation of
61 as defined in RFC2133.
65 are pointers to null-terminated
69 is either a host name or a numeric host address string: a dotted decimal
70 IPv4 address or an IPv6 address.
72 is either a decimal port number or a service name as listed in
76 is an optional pointer to a
77 \fBstruct addrinfo\fR.
78 This structure can be used to provide hints concerning the type of socket
79 that the caller supports or wishes to use.
80 The caller can supply the following structure elements in
84 The protocol family that should be used.
89 it means the caller will accept any protocol family supported by the
93 denotes the type of socket \(em
101 is zero the caller will accept any socket type.
104 indicates which transport protocol is wanted: IPPROTO_UDP or
108 is zero the caller will accept any protocol.
114 bit is set, a successful call to
115 \fBlwres_getaddrinfo()\fR
116 will return a null-terminated string containing the canonical name
117 of the specified hostname in
124 bit indicates that the returned socket address structure is intended
125 for used in a call to
127 In this case, if the hostname argument is a
129 pointer, then the IP address portion of the socket
130 address structure will be set to
132 for an IPv4 address or
133 \fBIN6ADDR_ANY_INIT\fR
140 bit, the returned socket address structure will be ready
143 for a connection-oriented protocol or
148 if a connectionless protocol was chosen.
149 The IP address portion of the socket address structure will be
150 set to the loopback address if
165 should be treated as a numeric string defining an IPv4 or IPv6 address
166 and no name resolution should be attempted.
168 All other elements of the \fBstruct addrinfo\fR passed
169 via \fIhints\fR must be zero.
171 A \fIhints\fR of \fBNULL\fR is treated as if
172 the caller provided a \fBstruct addrinfo\fR initialized to zero
176 After a successful call to
177 \fBlwres_getaddrinfo()\fR,
179 is a pointer to a linked list of one or more
183 \fBstruct addrinfo\fR
184 in this list cn be processed by following
189 pointer is encountered.
198 structure contain the corresponding arguments for a call to
202 structure in the list, the
204 member points to a filled-in socket address structure of length
207 All of the information returned by
208 \fBlwres_getaddrinfo()\fR
209 is dynamically allocated: the addrinfo structures, and the socket
210 address structures and canonical host name strings pointed to by the
212 Memory allocated for the dynamically allocated structures created by
214 \fBlwres_getaddrinfo()\fR
216 \fBlwres_freeaddrinfo()\fR.
219 \fBstruct addrinfo\fR
221 \fBlwres_getaddrinfo()\fR.
224 \fBlwres_getaddrinfo()\fR
225 returns zero on success or one of the error codes listed in
226 \fBgai_strerror\fR(3)
234 \fBlwres_getaddrinfo()\fR
240 \fBlwres_getaddrinfo\fR(3),
241 \fBlwres_freeaddrinfo\fR(3),
242 \fBlwres_gai_strerror\fR(3),
244 \fBgetservbyname\fR(3),