2 .\" Copyright (C) 2000, 2001 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 INTERNET SOFTWARE CONSORTIUM
9 .\" DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
10 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
11 .\" INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
12 .\" INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
13 .\" FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
14 .\" NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
15 .\" WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 .TH "LWRES_GETADDRINFO" "3" "Jun 30, 2000" "BIND9" ""
19 lwres_getaddrinfo, lwres_freeaddrinfo \- socket address structure to host and service name
21 \fB#include <lwres/netdb.h>
25 lwres_getaddrinfo(const char *hostname, const char *servname, const struct addrinfo *hints, struct addrinfo **res);
30 lwres_freeaddrinfo(struct addrinfo *ai);
33 If the operating system does not provide a
34 \fBstruct addrinfo\fR,
35 the following structure is used:
39 int ai_flags; /* AI_PASSIVE, AI_CANONNAME */
40 int ai_family; /* PF_xxx */
41 int ai_socktype; /* SOCK_xxx */
42 int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
43 size_t ai_addrlen; /* length of ai_addr */
44 char *ai_canonname; /* canonical name for hostname */
45 struct sockaddr *ai_addr; /* binary address */
46 struct addrinfo *ai_next; /* next structure in linked list */
52 \fBlwres_getaddrinfo()\fR
53 is used to get a list of IP addresses and port numbers for host
57 The function is the lightweight resolver's implementation of
59 as defined in RFC2133.
63 are pointers to null-terminated
67 is either a host name or a numeric host address string: a dotted decimal
68 IPv4 address or an IPv6 address.
70 is either a decimal port number or a service name as listed in
74 is an optional pointer to a
75 \fBstruct addrinfo\fR.
76 This structure can be used to provide hints concerning the type of socket
77 that the caller supports or wishes to use.
78 The caller can supply the following structure elements in
82 The protocol family that should be used.
87 it means the caller will accept any protocol family supported by the
91 denotes the type of socket \(em
99 is zero the caller will accept any socket type.
102 indicates which transport protocol is wanted: IPPROTO_UDP or
106 is zero the caller will accept any protocol.
112 bit is set, a successful call to
113 \fBlwres_getaddrinfo()\fR
114 will return a a null-terminated string containing the canonical name
115 of the specified hostname in
122 bit indicates that the returned socket address structure is intended
123 for used in a call to
125 In this case, if the hostname argument is a
127 pointer, then the IP address portion of the socket
128 address structure will be set to
130 for an IPv4 address or
131 \fBIN6ADDR_ANY_INIT\fR
138 bit, the returned socket address structure will be ready
141 for a connection-oriented protocol or
146 if a connectionless protocol was chosen.
147 The IP address portion of the socket address structure will be
148 set to the loopback address if
163 should be treated as a numeric string defining an IPv4 or IPv6 address
164 and no name resolution should be attempted.
166 All other elements of the \fBstruct addrinfo\fR passed
167 via \fIhints\fR must be zero.
169 A \fIhints\fR of \fBNULL\fR is treated as if
170 the caller provided a \fBstruct addrinfo\fR initialized to zero
174 After a successful call to
175 \fBlwres_getaddrinfo()\fR,
177 is a pointer to a linked list of one or more
181 \fBstruct addrinfo\fR
182 in this list cn be processed by following
187 pointer is encountered.
196 structure contain the corresponding arguments for a call to
200 structure in the list, the
202 member points to a filled-in socket address structure of length
205 All of the information returned by
206 \fBlwres_getaddrinfo()\fR
207 is dynamically allocated: the addrinfo structures, and the socket
208 address structures and canonical host name strings pointed to by the
210 Memory allocated for the dynamically allocated structures created by
212 \fBlwres_getaddrinfo()\fR
214 \fBlwres_freeaddrinfo()\fR.
217 \fBstruct addrinfo\fR
219 \fBlwres_getaddrinfo()\fR.
222 \fBlwres_getaddrinfo()\fR
223 returns zero on success or one of the error codes listed in
224 \fBgai_strerror\fR(3)
232 \fBlwres_getaddrinfo()\fR
238 \fBlwres_getaddrinfo\fR(3),
239 \fBlwres_freeaddrinfo\fR(3),
240 \fBlwres_gai_strerror\fR(3),
242 \fBgetservbyname\fR(3),