Merge from vendor branch GCC:
[dragonfly.git] / contrib / bind-9.3 / lib / lwres / man / lwres_getipnode.3
1 .\" Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC")
2 .\" Copyright (C) 2000, 2001, 2003 Internet Software Consortium.
3 .\" 
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.
7 .\" 
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.
15 .\"
16 .\" $Id: lwres_getipnode.3,v 1.13.2.2.4.6 2005/10/13 02:33:53 marka Exp $
17 .\"
18 .hy 0
19 .ad l
20 .\" ** You probably do not want to edit this file directly **
21 .\" It was generated using the DocBook XSL Stylesheets (version 1.69.1).
22 .\" Instead of manually editing it, you probably should edit the DocBook XML
23 .\" source for it and then use the DocBook XSL Stylesheets to regenerate it.
24 .TH "LWRES_GETIPNODE" "3" "Jun 30, 2000" "BIND9" "BIND9"
25 .\" disable hyphenation
26 .nh
27 .\" disable justification (adjust text to left margin only)
28 .ad l
29 .SH "NAME"
30 lwres_getipnodebyname, lwres_getipnodebyaddr, lwres_freehostent \- lightweight resolver nodename / address translation API
31 .SH "SYNOPSIS"
32 .nf
33 #include <lwres/netdb.h>
34 .fi
35 .HP 39
36 \fBstruct\ hostent\ *\ \fBlwres_getipnodebyname\fR\fR\fB(\fR\fBconst\ char\ *name\fR\fB, \fR\fBint\ af\fR\fB, \fR\fBint\ flags\fR\fB, \fR\fBint\ *error_num\fR\fB);\fR
37 .HP 39
38 \fBstruct\ hostent\ *\ \fBlwres_getipnodebyaddr\fR\fR\fB(\fR\fBconst\ void\ *src\fR\fB, \fR\fBsize_t\ len\fR\fB, \fR\fBint\ af\fR\fB, \fR\fBint\ *error_num\fR\fB);\fR
39 .HP 23
40 \fBvoid\ \fBlwres_freehostent\fR\fR\fB(\fR\fBstruct\ hostent\ *he\fR\fB);\fR
41 .SH "DESCRIPTION"
42 .PP
43 These functions perform thread safe, protocol independent nodename\-to\-address and address\-to\-nodename translation as defined in RFC2553.
44 .PP
45 They use a
46 \fBstruct hostent\fR
47 which is defined in
48 \fInamedb.h\fR:
49 .sp
50 .nf
51 struct  hostent {
52         char    *h_name;        /* official name of host */
53         char    **h_aliases;    /* alias list */
54         int     h_addrtype;     /* host address type */
55         int     h_length;       /* length of address */
56         char    **h_addr_list;  /* list of addresses from name server */
57 };
58 #define h_addr  h_addr_list[0]  /* address, for backward compatibility */
59 .fi
60 .sp
61 .PP
62 The members of this structure are:
63 .TP
64 \fBh_name\fR
65 The official (canonical) name of the host.
66 .TP
67 \fBh_aliases\fR
68 A NULL\-terminated array of alternate names (nicknames) for the host.
69 .TP
70 \fBh_addrtype\fR
71 The type of address being returned \- usually
72 \fBPF_INET\fR
73 or
74 \fBPF_INET6\fR.
75 .TP
76 \fBh_length\fR
77 The length of the address in bytes.
78 .TP
79 \fBh_addr_list\fR
80 A
81 \fBNULL\fR
82 terminated array of network addresses for the host. Host addresses are returned in network byte order.
83 .PP
84 \fBlwres_getipnodebyname()\fR
85 looks up addresses of protocol family
86 \fIaf\fR
87 for the hostname
88 \fIname\fR. The
89 \fIflags\fR
90 parameter contains ORed flag bits to specify the types of addresses that are searched for, and the types of addresses that are returned. The flag bits are:
91 .TP
92 \fBAI_V4MAPPED\fR
93 This is used with an
94 \fIaf\fR
95 of AF_INET6, and causes IPv4 addresses to be returned as IPv4\-mapped IPv6 addresses.
96 .TP
97 \fBAI_ALL\fR
98 This is used with an
99 \fIaf\fR
100 of AF_INET6, and causes all known addresses (IPv6 and IPv4) to be returned. If AI_V4MAPPED is also set, the IPv4 addresses are return as mapped IPv6 addresses.
101 .TP
102 \fBAI_ADDRCONFIG\fR
103 Only return an IPv6 or IPv4 address if here is an active network interface of that type. This is not currently implemented in the BIND 9 lightweight resolver, and the flag is ignored.
104 .TP
105 \fBAI_DEFAULT\fR
106 This default sets the
107 \fBAI_V4MAPPED\fR
108 and
109 \fBAI_ADDRCONFIG\fR
110 flag bits.
111 .PP
112 \fBlwres_getipnodebyaddr()\fR
113 performs a reverse lookup of address
114 \fIsrc\fR
115 which is
116 \fIlen\fR
117 bytes long.
118 \fIaf\fR
119 denotes the protocol family, typically
120 \fBPF_INET\fR
121 or
122 \fBPF_INET6\fR.
123 .PP
124 \fBlwres_freehostent()\fR
125 releases all the memory associated with the
126 \fBstruct hostent\fR
127 pointer
128 \fIhe\fR. Any memory allocated for the
129 \fBh_name\fR,
130 \fBh_addr_list\fR
131 and
132 \fBh_aliases\fR
133 is freed, as is the memory for the
134 \fBhostent\fR
135 structure itself.
136 .SH "RETURN VALUES"
137 .PP
138 If an error occurs,
139 \fBlwres_getipnodebyname()\fR
140 and
141 \fBlwres_getipnodebyaddr()\fR
142 set
143 \fI*error_num\fR
144 to an appropriate error code and the function returns a
145 \fBNULL\fR
146 pointer. The error codes and their meanings are defined in
147 \fI<lwres/netdb.h>\fR:
148 .TP
149 \fBHOST_NOT_FOUND\fR
150 No such host is known.
151 .TP
152 \fBNO_ADDRESS\fR
153 The server recognised the request and the name but no address is available. Another type of request to the name server for the domain might return an answer.
154 .TP
155 \fBTRY_AGAIN\fR
156 A temporary and possibly transient error occurred, such as a failure of a server to respond. The request may succeed if retried.
157 .TP
158 \fBNO_RECOVERY\fR
159 An unexpected failure occurred, and retrying the request is pointless.
160 .PP
161 \fBlwres_hstrerror\fR(3 )
162 translates these error codes to suitable error messages.
163 .SH "SEE ALSO"
164 .PP
165 \fBRFC2553\fR(),
166 \fBlwres\fR(3),
167 \fBlwres_gethostent\fR(3),
168 \fBlwres_getaddrinfo\fR(3),
169 \fBlwres_getnameinfo\fR(3),
170 \fBlwres_hstrerror\fR(3).